]> granicus.if.org Git - llvm/commitdiff
IPRA: Allow target to enable IPRA by default
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 14 Aug 2017 19:54:47 +0000 (19:54 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 14 Aug 2017 19:54:47 +0000 (19:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310876 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetMachine.h
lib/CodeGen/TargetPassConfig.cpp
lib/Target/TargetMachine.cpp

index 14c7a635a7c0d85175d031e4ff95d3793485736a..5421b22462ae3aa8122a40991c7b8e67e89dc6b8 100644 (file)
@@ -259,6 +259,12 @@ public:
   /// PEI. If false (virtual-register machines), then callee-save register
   /// spilling and scavenging are not needed or used.
   virtual bool usesPhysRegsForPEI() const { return true; }
+
+  /// True if the target wants to use interprocedural register allocation by
+  /// default. The -enable-ipra flag can be used to override this.
+  virtual bool useIPRA() const {
+    return false;
+  }
 };
 
 /// This class describes a target machine that is implemented with the LLVM
index 75a565e898f4f53eb5ba85a3a0e46af45bdf5ebd..481baea2dff074eaaa50105a47f42e6417ff46f6 100644 (file)
@@ -47,6 +47,9 @@
 
 using namespace llvm;
 
+cl::opt<bool> EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
+                         cl::desc("Enable interprocedural register allocation "
+                                  "to reduce load/store at procedure calls."));
 static cl::opt<bool> DisablePostRASched("disable-post-ra", cl::Hidden,
     cl::desc("Disable Post Regalloc Scheduler"));
 static cl::opt<bool> DisableBranchFold("disable-branch-fold", cl::Hidden,
@@ -362,6 +365,13 @@ TargetPassConfig::TargetPassConfig(LLVMTargetMachine &TM, PassManagerBase &pm)
   if (StringRef(PrintMachineInstrs.getValue()).equals(""))
     TM.Options.PrintMachineCode = true;
 
+  if (EnableIPRA.getNumOccurrences())
+    TM.Options.EnableIPRA = EnableIPRA;
+  else {
+    // If not explicitly specified, use target default.
+    TM.Options.EnableIPRA = TM.useIPRA();
+  }
+
   if (TM.Options.EnableIPRA)
     setRequiresCodeGenSCCOrder();
 
index b2578fb7a028f52e0f29db53bee9da2d906a7ae6..3b16dee5a0fa4228d5307383c664529dd65e7e08 100644 (file)
 #include "llvm/Target/TargetSubtargetInfo.h"
 using namespace llvm;
 
-cl::opt<bool> EnableIPRA("enable-ipra", cl::init(false), cl::Hidden,
-                         cl::desc("Enable interprocedural register allocation "
-                                  "to reduce load/store at procedure calls."));
-
 //---------------------------------------------------------------------------
 // TargetMachine Class
 //
@@ -45,8 +41,6 @@ TargetMachine::TargetMachine(const Target &T, StringRef DataLayoutString,
     : TheTarget(T), DL(DataLayoutString), TargetTriple(TT), TargetCPU(CPU),
       TargetFS(FS), AsmInfo(nullptr), MRI(nullptr), MII(nullptr), STI(nullptr),
       RequireStructuredCFG(false), DefaultOptions(Options), Options(Options) {
-  if (EnableIPRA.getNumOccurrences())
-    this->Options.EnableIPRA = EnableIPRA;
 }
 
 TargetMachine::~TargetMachine() {