mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
LTO: Maintain target triple, FeatureStr and CGOptLevel in the module or LTOCodeGenerator.
This makes it easier to create new TargetMachines on demand. llvm-svn: 245781
This commit is contained in:
parent
42bf1dc33c
commit
772d0abe3e
@ -77,7 +77,7 @@ struct LTOCodeGenerator {
|
||||
|
||||
void setCpu(const char *mCpu) { MCpu = mCpu; }
|
||||
void setAttr(const char *mAttr) { MAttr = mAttr; }
|
||||
void setOptLevel(unsigned optLevel) { OptLevel = optLevel; }
|
||||
void setOptLevel(unsigned optLevel);
|
||||
|
||||
void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
|
||||
void setShouldEmbedUselists(bool Value) { ShouldEmbedUselists = Value; }
|
||||
@ -166,10 +166,12 @@ private:
|
||||
StringSet MustPreserveSymbols;
|
||||
StringSet AsmUndefinedRefs;
|
||||
std::vector<std::string> CodegenOptions;
|
||||
std::string FeatureStr;
|
||||
std::string MCpu;
|
||||
std::string MAttr;
|
||||
std::string NativeObjectPath;
|
||||
TargetOptions Options;
|
||||
CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
|
||||
unsigned OptLevel = 2;
|
||||
lto_diagnostic_handler_t DiagHandler = nullptr;
|
||||
void *DiagContext = nullptr;
|
||||
|
@ -164,6 +164,24 @@ void LTOCodeGenerator::setDebugInfo(lto_debug_model debug) {
|
||||
llvm_unreachable("Unknown debug format!");
|
||||
}
|
||||
|
||||
void LTOCodeGenerator::setOptLevel(unsigned level) {
|
||||
OptLevel = level;
|
||||
switch (OptLevel) {
|
||||
case 0:
|
||||
CGOptLevel = CodeGenOpt::None;
|
||||
break;
|
||||
case 1:
|
||||
CGOptLevel = CodeGenOpt::Less;
|
||||
break;
|
||||
case 2:
|
||||
CGOptLevel = CodeGenOpt::Default;
|
||||
break;
|
||||
case 3:
|
||||
CGOptLevel = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool LTOCodeGenerator::writeMergedModules(const char *path,
|
||||
std::string &errMsg) {
|
||||
if (!determineTarget(errMsg))
|
||||
@ -279,8 +297,10 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
return true;
|
||||
|
||||
std::string TripleStr = IRLinker.getModule()->getTargetTriple();
|
||||
if (TripleStr.empty())
|
||||
if (TripleStr.empty()) {
|
||||
TripleStr = sys::getDefaultTargetTriple();
|
||||
IRLinker.getModule()->setTargetTriple(TripleStr);
|
||||
}
|
||||
llvm::Triple Triple(TripleStr);
|
||||
|
||||
// create target machine from info for merged modules
|
||||
@ -292,7 +312,7 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
// the default set of features.
|
||||
SubtargetFeatures Features(MAttr);
|
||||
Features.getDefaultSubtargetFeatures(Triple);
|
||||
std::string FeatureStr = Features.getString();
|
||||
FeatureStr = Features.getString();
|
||||
// Set a default CPU for Darwin triples.
|
||||
if (MCpu.empty() && Triple.isOSDarwin()) {
|
||||
if (Triple.getArch() == llvm::Triple::x86_64)
|
||||
@ -303,22 +323,6 @@ bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
|
||||
MCpu = "cyclone";
|
||||
}
|
||||
|
||||
CodeGenOpt::Level CGOptLevel;
|
||||
switch (OptLevel) {
|
||||
case 0:
|
||||
CGOptLevel = CodeGenOpt::None;
|
||||
break;
|
||||
case 1:
|
||||
CGOptLevel = CodeGenOpt::Less;
|
||||
break;
|
||||
case 2:
|
||||
CGOptLevel = CodeGenOpt::Default;
|
||||
break;
|
||||
case 3:
|
||||
CGOptLevel = CodeGenOpt::Aggressive;
|
||||
break;
|
||||
}
|
||||
|
||||
TargetMach.reset(march->createTargetMachine(TripleStr, MCpu, FeatureStr,
|
||||
Options, RelocModel,
|
||||
CodeModel::Default, CGOptLevel));
|
||||
|
Loading…
Reference in New Issue
Block a user