[llvm] r272158 - [RegBankSelect] Introduce a command line option to override the running mode.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 8 08:49:23 PDT 2016


Author: qcolombet
Date: Wed Jun  8 10:49:23 2016
New Revision: 272158

URL: http://llvm.org/viewvc/llvm-project?rev=272158&view=rev
Log:
[RegBankSelect] Introduce a command line option to override the running mode.

When the command line option is set, it overrides any thing that the
target may have set. The rationale is that we get what we asked for.

Options are respectively regbankselect-fast and regbankselect-greedy for
fast and greedy mode.

Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp

Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp?rev=272158&r1=272157&r2=272158&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp Wed Jun  8 10:49:23 2016
@@ -18,6 +18,7 @@
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/IR/Function.h"
 #include "llvm/Support/BlockFrequency.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 
@@ -25,6 +26,14 @@
 
 using namespace llvm;
 
+static cl::opt<RegBankSelect::Mode> RegBankSelectMode(
+    cl::desc("Mode of the RegBankSelect pass"), cl::Hidden, cl::Optional,
+    cl::values(clEnumValN(RegBankSelect::Mode::Fast, "regbankselect-fast",
+                          "Run the Fast mode (default mapping)"),
+               clEnumValN(RegBankSelect::Mode::Greedy, "regbankselect-greedy",
+                          "Use the Greedy mode (best local mapping)"),
+               clEnumValEnd));
+
 char RegBankSelect::ID = 0;
 INITIALIZE_PASS_BEGIN(RegBankSelect, "regbankselect",
                       "Assign register bank of generic virtual registers",
@@ -39,6 +48,11 @@ RegBankSelect::RegBankSelect(Mode Runnin
     : MachineFunctionPass(ID), RBI(nullptr), MRI(nullptr), TRI(nullptr),
       MBFI(nullptr), MBPI(nullptr), OptMode(RunningMode) {
   initializeRegBankSelectPass(*PassRegistry::getPassRegistry());
+  if (RegBankSelectMode.getNumOccurrences() != 0) {
+    OptMode = RegBankSelectMode;
+    if (RegBankSelectMode != RunningMode)
+      DEBUG(dbgs() << "RegBankSelect mode overrided by command line\n");
+  }
 }
 
 void RegBankSelect::init(MachineFunction &MF) {




More information about the llvm-commits mailing list