mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-09 11:25:55 +00:00
[multiversion] Implement the old pass manager's TTI wrapper pass in
terms of the new pass manager's TargetIRAnalysis. Yep, this is one of the nicer bits of the new pass manager's design. Passes can in many cases operate in a vacuum and so we can just nest things when convenient. This is particularly convenient here as I can now consolidate all of the TargetMachine logic on this analysis. The most important change here is that this pushes the function we need TTI for all the way into the TargetMachine, and re-creates the TTI object for each function rather than re-using it for each function. We're now prepared to teach the targets to produce function-specific TTI objects with specific subtargets cached, etc. One piece of feedback I'd love here is whether its worth renaming any of this stuff. None of the names really seem that awesome to me at this point, but TargetTransformInfoWrapperPass is particularly ... odd. TargetIRAnalysisWrapper might make more sense. I would want to do that rename separately anyways, but let me know what you think. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227731 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
|
#ifndef LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
|
||||||
#define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
|
#define LLVM_ANALYSIS_TARGETTRANSFORMINFO_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/Optional.h"
|
||||||
#include "llvm/IR/Intrinsics.h"
|
#include "llvm/IR/Intrinsics.h"
|
||||||
#include "llvm/IR/IntrinsicInst.h"
|
#include "llvm/IR/IntrinsicInst.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
@@ -791,7 +792,8 @@ private:
|
|||||||
/// This pass can be constructed from a TTI object which it stores internally
|
/// This pass can be constructed from a TTI object which it stores internally
|
||||||
/// and is queried by passes.
|
/// and is queried by passes.
|
||||||
class TargetTransformInfoWrapperPass : public ImmutablePass {
|
class TargetTransformInfoWrapperPass : public ImmutablePass {
|
||||||
TargetTransformInfo TTI;
|
TargetIRAnalysis TIRA;
|
||||||
|
Optional<TargetTransformInfo> TTI;
|
||||||
|
|
||||||
virtual void anchor();
|
virtual void anchor();
|
||||||
|
|
||||||
@@ -804,16 +806,16 @@ public:
|
|||||||
/// Use the constructor below or call one of the creation routines.
|
/// Use the constructor below or call one of the creation routines.
|
||||||
TargetTransformInfoWrapperPass();
|
TargetTransformInfoWrapperPass();
|
||||||
|
|
||||||
explicit TargetTransformInfoWrapperPass(TargetTransformInfo TTI);
|
explicit TargetTransformInfoWrapperPass(TargetIRAnalysis TIRA);
|
||||||
|
|
||||||
TargetTransformInfo &getTTI(Function &F) { return TTI; }
|
TargetTransformInfo &getTTI(Function &F);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Create an analysis pass wrapper around a TTI object.
|
/// \brief Create an analysis pass wrapper around a TTI object.
|
||||||
///
|
///
|
||||||
/// This analysis pass just holds the TTI instance and makes it available to
|
/// This analysis pass just holds the TTI instance and makes it available to
|
||||||
/// clients.
|
/// clients.
|
||||||
ImmutablePass *createTargetTransformInfoWrapperPass(TargetTransformInfo TTI);
|
ImmutablePass *createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
|
@@ -280,19 +280,24 @@ char TargetTransformInfoWrapperPass::ID = 0;
|
|||||||
void TargetTransformInfoWrapperPass::anchor() {}
|
void TargetTransformInfoWrapperPass::anchor() {}
|
||||||
|
|
||||||
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
|
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass()
|
||||||
: ImmutablePass(ID), TTI(NoTTIImpl(/*DataLayout*/ nullptr)) {
|
: ImmutablePass(ID) {
|
||||||
initializeTargetTransformInfoWrapperPassPass(
|
initializeTargetTransformInfoWrapperPassPass(
|
||||||
*PassRegistry::getPassRegistry());
|
*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
|
TargetTransformInfoWrapperPass::TargetTransformInfoWrapperPass(
|
||||||
TargetTransformInfo TTI)
|
TargetIRAnalysis TIRA)
|
||||||
: ImmutablePass(ID), TTI(std::move(TTI)) {
|
: ImmutablePass(ID), TIRA(std::move(TIRA)) {
|
||||||
initializeTargetTransformInfoWrapperPassPass(
|
initializeTargetTransformInfoWrapperPassPass(
|
||||||
*PassRegistry::getPassRegistry());
|
*PassRegistry::getPassRegistry());
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutablePass *
|
TargetTransformInfo &TargetTransformInfoWrapperPass::getTTI(Function &F) {
|
||||||
llvm::createTargetTransformInfoWrapperPass(TargetTransformInfo TTI) {
|
TTI = TIRA.run(F);
|
||||||
return new TargetTransformInfoWrapperPass(std::move(TTI));
|
return *TTI;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImmutablePass *
|
||||||
|
llvm::createTargetTransformInfoWrapperPass(TargetIRAnalysis TIRA) {
|
||||||
|
return new TargetTransformInfoWrapperPass(std::move(TIRA));
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,7 @@ static MCContext *addPassesToGenerateCode(LLVMTargetMachine *TM,
|
|||||||
AnalysisID StopAfter) {
|
AnalysisID StopAfter) {
|
||||||
|
|
||||||
// Add internal analysis passes from the target machine.
|
// Add internal analysis passes from the target machine.
|
||||||
PM.add(createTargetTransformInfoWrapperPass(TM->getTTI()));
|
PM.add(createTargetTransformInfoWrapperPass(TM->getTargetIRAnalysis()));
|
||||||
|
|
||||||
// Targets may override createPassConfig to provide a target-specific
|
// Targets may override createPassConfig to provide a target-specific
|
||||||
// subclass.
|
// subclass.
|
||||||
|
@@ -490,7 +490,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
|
|||||||
mergedModule->setDataLayout(TargetMach->getDataLayout());
|
mergedModule->setDataLayout(TargetMach->getDataLayout());
|
||||||
|
|
||||||
passes.add(new DataLayoutPass());
|
passes.add(new DataLayoutPass());
|
||||||
passes.add(createTargetTransformInfoWrapperPass(TargetMach->getTTI()));
|
passes.add(
|
||||||
|
createTargetTransformInfoWrapperPass(TargetMach->getTargetIRAnalysis()));
|
||||||
|
|
||||||
Triple TargetTriple(TargetMach->getTargetTriple());
|
Triple TargetTriple(TargetMach->getTargetTriple());
|
||||||
PassManagerBuilder PMB;
|
PassManagerBuilder PMB;
|
||||||
|
@@ -256,5 +256,6 @@ char *LLVMGetDefaultTargetTriple(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) {
|
void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM) {
|
||||||
unwrap(PM)->add(createTargetTransformInfoWrapperPass(unwrap(T)->getTTI()));
|
unwrap(PM)->add(
|
||||||
|
createTargetTransformInfoWrapperPass(unwrap(T)->getTargetIRAnalysis()));
|
||||||
}
|
}
|
||||||
|
@@ -427,8 +427,8 @@ int main(int argc, char **argv) {
|
|||||||
Passes.add(new DataLayoutPass());
|
Passes.add(new DataLayoutPass());
|
||||||
|
|
||||||
// Add internal analysis passes from the target machine.
|
// Add internal analysis passes from the target machine.
|
||||||
Passes.add(createTargetTransformInfoWrapperPass(
|
Passes.add(createTargetTransformInfoWrapperPass(TM ? TM->getTargetIRAnalysis()
|
||||||
TM ? TM->getTTI() : TargetTransformInfo(DL)));
|
: TargetIRAnalysis()));
|
||||||
|
|
||||||
std::unique_ptr<FunctionPassManager> FPasses;
|
std::unique_ptr<FunctionPassManager> FPasses;
|
||||||
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
|
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
|
||||||
@@ -436,7 +436,7 @@ int main(int argc, char **argv) {
|
|||||||
if (DL)
|
if (DL)
|
||||||
FPasses->add(new DataLayoutPass());
|
FPasses->add(new DataLayoutPass());
|
||||||
FPasses->add(createTargetTransformInfoWrapperPass(
|
FPasses->add(createTargetTransformInfoWrapperPass(
|
||||||
TM ? TM->getTTI() : TargetTransformInfo(DL)));
|
TM ? TM->getTargetIRAnalysis() : TargetIRAnalysis()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PrintBreakpoints) {
|
if (PrintBreakpoints) {
|
||||||
|
Reference in New Issue
Block a user