diff options
| author | Matthias Braun <matze@braunis.de> | 2016-05-10 01:32:40 +0000 |
|---|---|---|
| committer | Matthias Braun <matze@braunis.de> | 2016-05-10 01:32:40 +0000 |
| commit | 47cf918e20a0d5a38fea51885db060a1cdcaa4fc (patch) | |
| tree | 6256e0ed12c0403ed6f4b1fe494f931bdc429596 /llvm/lib/CodeGen/LLVMTargetMachine.cpp | |
| parent | ee5f36bd54fc791745f3f23b68adb83aca6123fd (diff) | |
| download | bcm5719-llvm-47cf918e20a0d5a38fea51885db060a1cdcaa4fc.tar.gz bcm5719-llvm-47cf918e20a0d5a38fea51885db060a1cdcaa4fc.zip | |
LLVMTargetMachine: Add functions to create MIModuleInfo/MIFunction; NFC
Add convenience function to create MachineModuleInfo and
MachineFunctionAnalysis passes and add them to a pass manager.
Despite factoring out some shared code in
LiveIntervalTest/LLVMTargetMachine this will be used by my upcoming llc
change.
llvm-svn: 269002
Diffstat (limited to 'llvm/lib/CodeGen/LLVMTargetMachine.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/LLVMTargetMachine.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp index ea113c894cf..46a0494ca06 100644 --- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp +++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp @@ -91,6 +91,20 @@ TargetIRAnalysis LLVMTargetMachine::getTargetIRAnalysis() { }); } +MachineModuleInfo & +LLVMTargetMachine::addMachineModuleInfo(PassManagerBase &PM) const { + MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo(), + *getMCRegisterInfo(), + getObjFileLowering()); + PM.add(MMI); + return *MMI; +} + +void LLVMTargetMachine::addMachineFunctionAnalysis(PassManagerBase &PM, + MachineFunctionInitializer *MFInitializer) const { + PM.add(new MachineFunctionAnalysis(*this, MFInitializer)); +} + /// addPassesToX helper drives creation and initialization of TargetPassConfig. static MCContext * addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM, @@ -125,14 +139,8 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM, PassConfig->addISelPrepare(); - // Install a MachineModuleInfo class, which is an immutable pass that holds - // all the per-module stuff we're generating, including MCContext. - MachineModuleInfo *MMI = new MachineModuleInfo( - *TM->getMCAsmInfo(), *TM->getMCRegisterInfo(), TM->getObjFileLowering()); - PM.add(MMI); - - // Set up a MachineFunction for the rest of CodeGen to work on. - PM.add(new MachineFunctionAnalysis(*TM, MFInitializer)); + MachineModuleInfo &MMI = TM->addMachineModuleInfo(PM); + TM->addMachineFunctionAnalysis(PM, MFInitializer); // Enable FastISel with -fast, but allow that to be overridden. TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE); @@ -160,7 +168,7 @@ addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM, PassConfig->setInitialized(); - return &MMI->getContext(); + return &MMI.getContext(); } bool LLVMTargetMachine::addPassesToEmitFile( |

