Change llc command line for register allocators


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8815 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/docs/CommandGuide/llc.html b/docs/CommandGuide/llc.html
index 26e6803..8788a7a 100644
--- a/docs/CommandGuide/llc.html
+++ b/docs/CommandGuide/llc.html
@@ -95,11 +95,6 @@
 	Disable frame pointer elimination optimization.
 	<p>
 
-	<li>-disable-local-ra    
-	<br>
-	Use Simple RA instead of Local RegAlloc.
-	<p>
-
 	<li>-disable-pattern-isel
 	<br>
 	Use the 'simple' X86 instruction selector.
@@ -146,13 +141,11 @@
 	architectures are:
 
 	<dl compact>
-		<di> x86               
-		<dd>
-		IA-32 (Pentium and above)
-		<p>
+		<di> x86
+		<dd>IA-32 (Pentium and above)</dd>
 
-		<di> sparc             
-		<dd>SPARC V9
+		<di> sparc
+		<dd>SPARC V9</dd>
 	</dl>
 	<p>
 
@@ -166,6 +159,19 @@
 	Print generated machine code.
 	<p>
 
+	<li>-regalloc=&lt;ra&gt;
+	<br>
+        Specify the register allocator to use. The default is <i>simple<i>.
+        Valid register allocators are:
+	<dl compact>
+		<di> simple
+		<dd>Very simple register allocator</dd>
+
+		<di> local
+		<dd>Local register allocator</dd>
+	</dl>
+	<p>
+
 	<li> -help
 	<br>
 	Print a summary of command line options.
diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h
index 5f8a19d..309bf66 100644
--- a/include/llvm/CodeGen/Passes.h
+++ b/include/llvm/CodeGen/Passes.h
@@ -19,6 +19,8 @@
 //
 extern const PassInfo *PHIEliminationID;
 
+enum RegAllocName { simple, local };
+
 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
 /// from SSA form to use explicit registers by spilling every register.  Wow,
 /// great policy huh?
diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp
index 60f8bbc..8f6829f 100644
--- a/lib/Target/X86/X86TargetMachine.cpp
+++ b/lib/Target/X86/X86TargetMachine.cpp
@@ -16,8 +16,15 @@
 #include "Support/Statistic.h"
 
 namespace {
-  cl::opt<bool> NoLocalRA("disable-local-ra",
-                          cl::desc("Use Simple RA instead of Local RegAlloc"));
+  cl::opt<RegAllocName>
+  RegAlloc("regalloc",
+           cl::desc("Register allocator to use: (default = simple)"),
+           cl::Prefix,
+           cl::values(clEnumVal(simple, "  simple register allocator"),
+                      clEnumVal(local,  "  local register allocator"),
+                      0),
+           cl::init(local));
+
   cl::opt<bool> PrintCode("print-machineinstrs",
 			  cl::desc("Print generated machine code"));
   cl::opt<bool> NoPatternISel("disable-pattern-isel", cl::init(true),
@@ -66,10 +73,16 @@
     PM.add(createMachineFunctionPrinterPass());
 
   // Perform register allocation to convert to a concrete x86 representation
-  if (NoLocalRA)
+  switch (RegAlloc) {
+  case simple:
     PM.add(createSimpleRegisterAllocator());
-  else
+    break;
+  case local:
     PM.add(createLocalRegisterAllocator());
+    break;
+  default:
+    assert(0 && "no register allocator selected");
+  }
 
   if (PrintCode)
     PM.add(createMachineFunctionPrinterPass());
@@ -113,10 +126,16 @@
     PM.add(createMachineFunctionPrinterPass());
 
   // Perform register allocation to convert to a concrete x86 representation
-  if (NoLocalRA)
+  switch (RegAlloc) {
+  case simple:
     PM.add(createSimpleRegisterAllocator());
-  else
+    break;
+  case local:
     PM.add(createLocalRegisterAllocator());
+    break;
+  default:
+    assert(0 && "no register allocator selected");
+  }
 
   if (PrintCode)
     PM.add(createMachineFunctionPrinterPass());
diff --git a/test/CodeGen/X86/2002-12-23-LocalRAProblem.llx b/test/CodeGen/X86/2002-12-23-LocalRAProblem.llx
index 05b760a..1511df3 100644
--- a/test/CodeGen/X86/2002-12-23-LocalRAProblem.llx
+++ b/test/CodeGen/X86/2002-12-23-LocalRAProblem.llx
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | lli -force-interpreter=false -disable-local-ra=false
+; RUN: llvm-as < %s | lli -force-interpreter=false -regalloc=simple
 ;-print-machineinstrs 
 
 int %main() {
diff --git a/test/CodeGen/X86/2002-12-23-SubProblem.llx b/test/CodeGen/X86/2002-12-23-SubProblem.llx
index 2782325..5f5a4cf 100644
--- a/test/CodeGen/X86/2002-12-23-SubProblem.llx
+++ b/test/CodeGen/X86/2002-12-23-SubProblem.llx
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | lli -force-interpreter=false -disable-local-ra
+; RUN: llvm-as < %s | lli -force-interpreter=false -regalloc=simple
 
 int %main(int %B) {
 	;%B = add int 0, 1