diff options
| -rw-r--r-- | llvm/include/llvm/CodeGen/TargetPassConfig.h | 4 | ||||
| -rw-r--r-- | llvm/include/llvm/Target/TargetMachine.h | 1 | ||||
| -rw-r--r-- | llvm/include/llvm/Target/TargetOptions.h | 5 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/TargetPassConfig.cpp | 29 | ||||
| -rw-r--r-- | llvm/lib/Target/AArch64/AArch64TargetMachine.cpp | 10 |
5 files changed, 23 insertions, 26 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetPassConfig.h b/llvm/include/llvm/CodeGen/TargetPassConfig.h index fe56f622d04..c6987327c27 100644 --- a/llvm/include/llvm/CodeGen/TargetPassConfig.h +++ b/llvm/include/llvm/CodeGen/TargetPassConfig.h @@ -317,10 +317,6 @@ public: /// verification is enabled. void addVerifyPass(const std::string &Banner); - /// Check whether or not GlobalISel should be enabled by default. - /// Fallback/abort behavior is controlled via other methods. - virtual bool isGlobalISelEnabled() const; - /// Check whether or not GlobalISel should abort on error. /// When this is disabled, GlobalISel will fall back on SDISel instead of /// erroring out. diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index 97442f9a784..77f8bfefe1d 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -184,6 +184,7 @@ public: void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool getO0WantsFastISel() { return O0WantsFastISel; } void setO0WantsFastISel(bool Enable) { O0WantsFastISel = Enable; } + void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h index 70fac7833f3..f21b9792d10 100644 --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -104,7 +104,7 @@ namespace llvm { NoSignedZerosFPMath(false), HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false), GuaranteedTailCallOpt(false), StackSymbolOrdering(true), - EnableFastISel(false), UseInitArray(false), + EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false), DisableIntegratedAS(false), RelaxELFRelocations(false), FunctionSections(false), DataSections(false), UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false), @@ -186,6 +186,9 @@ namespace llvm { /// compile time. unsigned EnableFastISel : 1; + /// EnableGlobalISel - This flag enables global instruction selection. + unsigned EnableGlobalISel : 1; + /// UseInitArray - Use .init_array instead of .ctors for static /// constructors. unsigned UseInitArray : 1; diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp index c90a93d7e24..acdc814c45c 100644 --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -123,9 +123,9 @@ static cl::opt<cl::boolOrDefault> EnableFastISelOption("fast-isel", cl::Hidden, cl::desc("Enable the \"fast\" instruction selector")); -static cl::opt<cl::boolOrDefault> - EnableGlobalISel("global-isel", cl::Hidden, - cl::desc("Enable the \"global\" instruction selector")); +static cl::opt<cl::boolOrDefault> EnableGlobalISelOption( + "global-isel", cl::Hidden, + cl::desc("Enable the \"global\" instruction selector")); static cl::opt<std::string> PrintMachineInstrs( "print-machineinstrs", cl::ValueOptional, cl::desc("Print machine instrs"), @@ -704,19 +704,23 @@ void TargetPassConfig::addISelPrepare() { } bool TargetPassConfig::addCoreISelPasses() { - // Enable FastISel with -fast, but allow that to be overridden. + // Enable FastISel with -fast-isel, but allow that to be overridden. TM->setO0WantsFastISel(EnableFastISelOption != cl::BOU_FALSE); if (EnableFastISelOption == cl::BOU_TRUE || (TM->getOptLevel() == CodeGenOpt::None && TM->getO0WantsFastISel())) TM->setFastISel(true); - // Ask the target for an isel. - // Enable GlobalISel if the target wants to, but allow that to be overriden. + // Ask the target for an instruction selector. + bool EnableGlobalISel = TM->Options.EnableGlobalISel; // Explicitly enabling fast-isel should override implicitly enabled // global-isel. - if (EnableGlobalISel == cl::BOU_TRUE || - (EnableGlobalISel == cl::BOU_UNSET && isGlobalISelEnabled() && - EnableFastISelOption != cl::BOU_TRUE)) { + if (EnableGlobalISel && (EnableGlobalISelOption == cl::BOU_UNSET) && + (EnableFastISelOption == cl::BOU_TRUE)) + EnableGlobalISel = false; + if (EnableGlobalISelOption == cl::BOU_TRUE) + EnableGlobalISel = true; + + if (EnableGlobalISel) { if (addIRTranslator()) return true; @@ -1130,18 +1134,13 @@ void TargetPassConfig::addBlockPlacement() { //===---------------------------------------------------------------------===// /// GlobalISel Configuration //===---------------------------------------------------------------------===// - -bool TargetPassConfig::isGlobalISelEnabled() const { - return false; -} - bool TargetPassConfig::isGlobalISelAbortEnabled() const { if (EnableGlobalISelAbort.getNumOccurrences() > 0) return EnableGlobalISelAbort == 1; // When no abort behaviour is specified, we don't abort if the target says // that GISel is enabled. - return !isGlobalISelEnabled(); + return !TM->Options.EnableGlobalISel; } bool TargetPassConfig::reportDiagnosticWhenGlobalISelFallback() const { diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp index 5d00dc58a5a..94aa7edc953 100644 --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -243,6 +243,10 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT, getEffectiveCodeModel(TT, CM, JIT), OL), TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) { initAsmInfo(); + + // Enable GlobalISel at or below EnableGlobalISelAt0. + if (getOptLevel() <= EnableGlobalISelAtO) + setGlobalISel(true); } AArch64TargetMachine::~AArch64TargetMachine() = default; @@ -340,8 +344,6 @@ public: void addPostRegAlloc() override; void addPreSched2() override; void addPreEmitPass() override; - - bool isGlobalISelEnabled() const override; }; } // end anonymous namespace @@ -455,10 +457,6 @@ bool AArch64PassConfig::addGlobalInstructionSelect() { return false; } -bool AArch64PassConfig::isGlobalISelEnabled() const { - return TM->getOptLevel() <= EnableGlobalISelAtO; -} - bool AArch64PassConfig::addILPOpts() { if (EnableCondOpt) addPass(createAArch64ConditionOptimizerPass()); |

