From a79b0620a08d94a58fd48787e78cc83924632ad8 Mon Sep 17 00:00:00 2001 From: Volkan Keles Date: Wed, 17 Jan 2018 22:34:21 +0000 Subject: Add a TargetOption to enable/disable GlobalISel Summary: This patch adds a new target option in order to control GlobalISel. This will allow the users to enable/disable GlobalISel prior to the backend by calling `TargetMachine::setGlobalISel(bool Enable)`. No test case as there is already a test to check GlobalISel command line options. See: CodeGen/AArch64/GlobalISel/gisel-commandline-option.ll. Reviewers: qcolombet, aemerson, ab, dsanders Reviewed By: qcolombet Subscribers: rovka, javed.absar, kristof.beyls, llvm-commits Differential Revision: https://reviews.llvm.org/D42137 llvm-svn: 322773 --- llvm/lib/CodeGen/TargetPassConfig.cpp | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'llvm/lib/CodeGen') 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 EnableFastISelOption("fast-isel", cl::Hidden, cl::desc("Enable the \"fast\" instruction selector")); -static cl::opt - EnableGlobalISel("global-isel", cl::Hidden, - cl::desc("Enable the \"global\" instruction selector")); +static cl::opt EnableGlobalISelOption( + "global-isel", cl::Hidden, + cl::desc("Enable the \"global\" instruction selector")); static cl::opt 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 { -- cgit v1.2.3