summaryrefslogtreecommitdiff
path: root/lib/Target/MSP430
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2012-02-03 05:12:41 +0000
committerAndrew Trick <atrick@apple.com>2012-02-03 05:12:41 +0000
commit843ee2e6a46b2b2d74a84c2eea68dec35cb359cc (patch)
treedec3e0739c528df18c48902226d27f0ab109e040 /lib/Target/MSP430
parent8247e0dca6759d9a22ac4c5cf305fac052b285ac (diff)
downloadllvm-843ee2e6a46b2b2d74a84c2eea68dec35cb359cc.tar.gz
llvm-843ee2e6a46b2b2d74a84c2eea68dec35cb359cc.tar.bz2
llvm-843ee2e6a46b2b2d74a84c2eea68dec35cb359cc.tar.xz
Added TargetPassConfig. The first little step toward configuring codegen passes.
Allows command line overrides to be centralized in LLVMTargetMachine.cpp. LLVMTargetMachine can intercept common passes and give precedence to command line overrides. Allows adding "internal" target configuration options without touching TargetOptions. Encapsulates the PassManager. Provides a good point to initialize all CodeGen passes so that Pass ID's can be used in APIs. Allows modifying the target configuration hooks without rebuilding the world. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149672 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/MSP430')
-rw-r--r--lib/Target/MSP430/MSP430TargetMachine.cpp27
-rw-r--r--lib/Target/MSP430/MSP430TargetMachine.h4
2 files changed, 26 insertions, 5 deletions
diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp
index a0fc3daa3c..a2e97f11e5 100644
--- a/lib/Target/MSP430/MSP430TargetMachine.cpp
+++ b/lib/Target/MSP430/MSP430TargetMachine.cpp
@@ -38,14 +38,35 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T,
InstrInfo(*this), TLInfo(*this), TSInfo(*this),
FrameLowering(Subtarget) { }
+namespace {
+/// MSP430 Code Generator Pass Configuration Options.
+class MSP430PassConfig : public TargetPassConfig {
+public:
+ MSP430PassConfig(MSP430TargetMachine *TM, PassManagerBase &PM,
+ bool DisableVerifyFlag)
+ : TargetPassConfig(TM, PM, DisableVerifyFlag) {}
-bool MSP430TargetMachine::addInstSelector(PassManagerBase &PM) {
+ MSP430TargetMachine &getMSP430TargetMachine() const {
+ return getTM<MSP430TargetMachine>();
+ }
+
+ virtual bool addInstSelector();
+ virtual bool addPreEmitPass();
+};
+} // namespace
+
+TargetPassConfig *MSP430TargetMachine::createPassConfig(PassManagerBase &PM,
+ bool DisableVerify) {
+ return new MSP430PassConfig(this, PM, DisableVerify);
+}
+
+bool MSP430PassConfig::addInstSelector() {
// Install an instruction selector.
- PM.add(createMSP430ISelDag(*this, getOptLevel()));
+ PM.add(createMSP430ISelDag(getMSP430TargetMachine(), getOptLevel()));
return false;
}
-bool MSP430TargetMachine::addPreEmitPass(PassManagerBase &PM) {
+bool MSP430PassConfig::addPreEmitPass() {
// Must run branch selection immediately preceding the asm printer.
PM.add(createMSP430BranchSelectionPass());
return false;
diff --git a/lib/Target/MSP430/MSP430TargetMachine.h b/lib/Target/MSP430/MSP430TargetMachine.h
index 28d482a28f..19b7bf1b71 100644
--- a/lib/Target/MSP430/MSP430TargetMachine.h
+++ b/lib/Target/MSP430/MSP430TargetMachine.h
@@ -62,8 +62,8 @@ public:
return &TSInfo;
}
- virtual bool addInstSelector(PassManagerBase &PM);
- virtual bool addPreEmitPass(PassManagerBase &PM);
+ virtual TargetPassConfig *createPassConfig(PassManagerBase &PM,
+ bool DisableVerify);
}; // MSP430TargetMachine.
} // end namespace llvm