mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 07:31:53 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269002 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c2cb1b7b04
commit
bf765dfe21
@ -29,6 +29,7 @@ class InstrItineraryData;
|
||||
class GlobalValue;
|
||||
class Mangler;
|
||||
class MachineFunctionInitializer;
|
||||
class MachineModuleInfo;
|
||||
class MCAsmInfo;
|
||||
class MCCodeGenInfo;
|
||||
class MCContext;
|
||||
@ -303,6 +304,13 @@ public:
|
||||
bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
|
||||
raw_pwrite_stream &OS,
|
||||
bool DisableVerify = true) override;
|
||||
|
||||
/// Add MachineModuleInfo pass to pass manager.
|
||||
MachineModuleInfo &addMachineModuleInfo(PassManagerBase &PM) const;
|
||||
|
||||
/// Add MachineFunctionAnalysis pass to pass manager.
|
||||
void addMachineFunctionAnalysis(PassManagerBase &PM,
|
||||
MachineFunctionInitializer *MFInitializer) const;
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@ -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(
|
||||
|
@ -3,8 +3,6 @@
|
||||
#include "llvm/CodeGen/LiveIntervalAnalysis.h"
|
||||
#include "llvm/CodeGen/MIRParser/MIRParser.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
|
||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||
#include "llvm/CodeGen/Passes.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
@ -69,12 +67,9 @@ std::unique_ptr<Module> parseMIR(LLVMContext &Context,
|
||||
if (!F)
|
||||
return nullptr;
|
||||
|
||||
MachineModuleInfo *MMI = new MachineModuleInfo(
|
||||
*TM.getMCAsmInfo(), *TM.getMCRegisterInfo(), nullptr);
|
||||
PM.add(MMI);
|
||||
|
||||
MachineFunctionAnalysis *MFA = new MachineFunctionAnalysis(TM, MIR.get());
|
||||
PM.add(MFA);
|
||||
const LLVMTargetMachine &LLVMTM = static_cast<const LLVMTargetMachine&>(TM);
|
||||
LLVMTM.addMachineModuleInfo(PM);
|
||||
LLVMTM.addMachineFunctionAnalysis(PM, MIR.get());
|
||||
|
||||
return M;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user