Introduce MCCodeGenInfo, which keeps information that can affect codegen

(including compilation, assembly). Move relocation model Reloc::Model from
TargetMachine to MCCodeGenInfo so it's accessible even without TargetMachine.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2011-07-19 06:37:02 +00:00
parent 939ece1b5c
commit 439661395f
74 changed files with 641 additions and 314 deletions

View File

@@ -75,6 +75,7 @@ LTOCodeGenerator::LTOCodeGenerator()
{
InitializeAllTargets();
InitializeAllMCAsmInfos();
InitializeAllMCCodeGenInfos();
InitializeAllMCRegisterInfos();
InitializeAllMCSubtargetInfos();
InitializeAllAsmPrinters();
@@ -252,15 +253,16 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
// The relocation model is actually a static member of TargetMachine
// and needs to be set before the TargetMachine is instantiated.
Reloc::Model RelocModel = Reloc::Default;
switch( _codeModel ) {
case LTO_CODEGEN_PIC_MODEL_STATIC:
TargetMachine::setRelocationModel(Reloc::Static);
RelocModel = Reloc::Static;
break;
case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
TargetMachine::setRelocationModel(Reloc::PIC_);
RelocModel = Reloc::PIC_;
break;
case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
TargetMachine::setRelocationModel(Reloc::DynamicNoPIC);
RelocModel = Reloc::DynamicNoPIC;
break;
}
@@ -268,7 +270,8 @@ bool LTOCodeGenerator::determineTarget(std::string& errMsg)
SubtargetFeatures Features;
Features.getDefaultSubtargetFeatures(llvm::Triple(Triple));
std::string FeatureStr = Features.getString();
_target = march->createTargetMachine(Triple, _mCpu, FeatureStr);
_target = march->createTargetMachine(Triple, _mCpu, FeatureStr,
RelocModel);
}
return false;
}