summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/LLVMTargetMachine.cpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2018-11-02 01:31:50 +0000
committerMatthias Braun <matze@braunis.de>2018-11-02 01:31:50 +0000
commite8f717aea86c4fbc0e3f3d2990765ffcd1ed8dbd (patch)
tree4b7317416fa404693c370e84134646a34c7baeb9 /llvm/lib/CodeGen/LLVMTargetMachine.cpp
parent3231e518a3b57d3a43100bf127fa3484005edafb (diff)
downloadbcm5719-llvm-e8f717aea86c4fbc0e3f3d2990765ffcd1ed8dbd.tar.gz
bcm5719-llvm-e8f717aea86c4fbc0e3f3d2990765ffcd1ed8dbd.zip
LLVMTargetMachine/TargetPassConfig: Simplify handling of start/stop options; NFC
- Make some TargetPassConfig methods that just check whether options have been set static. - Shuffle code in LLVMTargetMachine around so addPassesToGenerateCode only deals with TargetPassConfig now (but not with MCContext or the creation of MachineModuleInfo) llvm-svn: 345918
Diffstat (limited to 'llvm/lib/CodeGen/LLVMTargetMachine.cpp')
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp46
1 files changed, 21 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 90337903008..52e832cc38c 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -95,29 +95,22 @@ LLVMTargetMachine::getTargetTransformInfo(const Function &F) {
}
/// addPassesToX helper drives creation and initialization of TargetPassConfig.
-static MCContext *
-addPassesToGenerateCode(LLVMTargetMachine *TM, PassManagerBase &PM,
- bool DisableVerify, bool &WillCompleteCodeGenPipeline,
- raw_pwrite_stream &Out, MachineModuleInfo *MMI) {
+static TargetPassConfig *
+addPassesToGenerateCode(LLVMTargetMachine &TM, PassManagerBase &PM,
+ bool DisableVerify, MachineModuleInfo &MMI) {
// Targets may override createPassConfig to provide a target-specific
// subclass.
- TargetPassConfig *PassConfig = TM->createPassConfig(PM);
+ TargetPassConfig *PassConfig = TM.createPassConfig(PM);
// Set PassConfig options provided by TargetMachine.
PassConfig->setDisableVerify(DisableVerify);
- WillCompleteCodeGenPipeline = PassConfig->willCompleteCodeGenPipeline();
PM.add(PassConfig);
- if (!MMI)
- MMI = new MachineModuleInfo(TM);
- PM.add(MMI);
+ PM.add(&MMI);
if (PassConfig->addISelPasses())
return nullptr;
PassConfig->addMachinePasses();
PassConfig->setInitialized();
- if (!WillCompleteCodeGenPipeline)
- PM.add(createPrintMIRPass(Out));
-
- return &MMI->getContext();
+ return PassConfig;
}
bool LLVMTargetMachine::addAsmPrinter(PassManagerBase &PM,
@@ -201,14 +194,16 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
bool DisableVerify,
MachineModuleInfo *MMI) {
// Add common CodeGen passes.
- bool WillCompleteCodeGenPipeline = true;
- MCContext *Context = addPassesToGenerateCode(
- this, PM, DisableVerify, WillCompleteCodeGenPipeline, Out, MMI);
- if (!Context)
+ if (!MMI)
+ MMI = new MachineModuleInfo(this);
+ TargetPassConfig *PassConfig =
+ addPassesToGenerateCode(*this, PM, DisableVerify, *MMI);
+ if (!PassConfig)
return true;
- if (WillCompleteCodeGenPipeline &&
- addAsmPrinter(PM, Out, DwoOut, FileType, *Context))
+ if (!TargetPassConfig::willCompleteCodeGenPipeline()) {
+ PM.add(createPrintMIRPass(Out));
+ } else if (addAsmPrinter(PM, Out, DwoOut, FileType, MMI->getContext()))
return true;
PM.add(createFreeMachineFunctionPass());
@@ -224,14 +219,15 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
raw_pwrite_stream &Out,
bool DisableVerify) {
// Add common CodeGen passes.
- bool WillCompleteCodeGenPipeline = true;
- Ctx = addPassesToGenerateCode(this, PM, DisableVerify,
- WillCompleteCodeGenPipeline, Out,
- /*MachineModuleInfo*/ nullptr);
- if (!Ctx)
+ MachineModuleInfo *MMI = new MachineModuleInfo(this);
+ TargetPassConfig *PassConfig =
+ addPassesToGenerateCode(*this, PM, DisableVerify, *MMI);
+ if (!PassConfig)
return true;
- assert(WillCompleteCodeGenPipeline && "CodeGen pipeline has been altered");
+ assert(TargetPassConfig::willCompleteCodeGenPipeline() &&
+ "Cannot emit MC with limited codegen pipeline");
+ Ctx = &MMI->getContext();
if (Options.MCOptions.MCSaveTempLabels)
Ctx->setAllowTemporaryLabels(false);
OpenPOWER on IntegriCloud