Use more structured command line option processing
authorChris Lattner <sabre@nondot.org>
Tue, 17 Jun 2003 15:43:13 +0000 (15:43 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Jun 2003 15:43:13 +0000 (15:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6742 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/JIT.cpp
lib/ExecutionEngine/Makefile
tools/lli/Makefile

index 5a3245b91b60e8f30f5d42194c46c61f9ed5efa7..229754775c11fd2b0d9c3ecb9cf974143fed0820 100644 (file)
 #include "llvm/PassManager.h"
 
 namespace {
-  cl::opt<std::string>
-  Arch("march", cl::desc("Architecture: `x86' or `sparc'"), cl::Prefix,
-       cl::value_desc("machine architecture"));
-  
-  static std::string DefaultArch = 
+  enum ArchName { nojit, x86, sparc };
+
+  cl::opt<ArchName>
+  Arch("march", cl::desc("Architecture to JIT to:"), cl::Prefix,
+       cl::values(clEnumVal(x86, "  IA-32 (pentium and above)"),
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+                  clEnumVal(sparc, "  Sparc-V9"),
+#endif
+                  0),
 #if defined(i386) || defined(__i386__) || defined(__x86__)
-  "x86";
+  cl::init(x86)
 #elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
-  "sparc";
+  cl::init(sparc)
 #else
-  "";
+  cl::init(nojit)
 #endif
+       );
 }
 
 /// createJIT - Create an return a new JIT compiler if there is one available
@@ -35,30 +40,31 @@ namespace {
 ExecutionEngine *ExecutionEngine::createJIT(Module *M, unsigned Config) {
   
   TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
-  if (Arch == "")
-    Arch = DefaultArch;
 
   // Allow a command-line switch to override what *should* be the default target
   // machine for this platform. This allows for debugging a Sparc JIT on X86 --
   // our X86 machines are much faster at recompiling LLVM and linking lli.
-  if (Arch == "x86") {
+  switch (Arch) {
+  case x86:
     TargetMachineAllocator = allocateX86TargetMachine;
+    break;
 #if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
-  } else if (Arch == "sparc") {
+  case sparc:
     TargetMachineAllocator = allocateSparcTargetMachine;
+    break;
 #endif
-  }
-
-  if (TargetMachineAllocator) {
-    // Allocate a target...
-    TargetMachine *Target = (*TargetMachineAllocator)(Config);
-    assert(Target && "Could not allocate target machine!");
-
-    // Create the virtual machine object...
-    return new VM(M, Target);
-  } else {
+  default:
+    assert(0 && "-march flag not supported on this host!");
+  case nojit:
     return 0;
   }
+
+  // Allocate a target...
+  TargetMachine *Target = (*TargetMachineAllocator)(Config);
+  assert(Target && "Could not allocate target machine!");
+  
+  // Create the virtual machine object...
+  return new VM(M, Target);
 }
 
 VM::VM(Module *M, TargetMachine *tm) : ExecutionEngine(M), TM(*tm) {
index 54ed699f9e1279f41e99b56e305aa3c91942fea0..b97e4115ac06c0a71794d6d3981500bf4fd747be 100644 (file)
@@ -2,25 +2,9 @@ LEVEL = ../..
 TOOLNAME = lli
 PARALLEL_DIRS = Interpreter JIT
 
-# FIXME: This enables testing the Sparc JIT on x86.
-# Perhaps in the future this should be a ./configure option.
-
-# Generic JIT libraries
-JITLIBS   = lli-jit codegen
-ARCHLIBS  =
-
-# What the X86 JIT requires
-JITLIBS  += x86
-ARCHLIBS += 
-
-# What the Sparc JIT requires
-JITLIBS  += sparc 
-ARCHLIBS  = sched livevar instrument.a profpaths transformutils.a \
-           bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \
-           mapping select postopts.a preopts
-
-USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts \
-           analysis.a support.a target.a $(ARCHLIBS)
+JITLIBS  = lli-jit codegen x86
+USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts.a \
+           analysis.a support.a target.a 
 
 # Have gcc tell the linker to export symbols from the program so that
 # dynamically loaded modules can be linked against them.
index 54ed699f9e1279f41e99b56e305aa3c91942fea0..b97e4115ac06c0a71794d6d3981500bf4fd747be 100644 (file)
@@ -2,25 +2,9 @@ LEVEL = ../..
 TOOLNAME = lli
 PARALLEL_DIRS = Interpreter JIT
 
-# FIXME: This enables testing the Sparc JIT on x86.
-# Perhaps in the future this should be a ./configure option.
-
-# Generic JIT libraries
-JITLIBS   = lli-jit codegen
-ARCHLIBS  =
-
-# What the X86 JIT requires
-JITLIBS  += x86
-ARCHLIBS += 
-
-# What the Sparc JIT requires
-JITLIBS  += sparc 
-ARCHLIBS  = sched livevar instrument.a profpaths transformutils.a \
-           bcwriter transforms.a ipo.a ipa.a datastructure.a regalloc \
-           mapping select postopts.a preopts
-
-USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts \
-           analysis.a support.a target.a $(ARCHLIBS)
+JITLIBS  = lli-jit codegen x86
+USEDLIBS = lli-interpreter $(JITLIBS) bcreader vmcore scalaropts.a \
+           analysis.a support.a target.a 
 
 # Have gcc tell the linker to export symbols from the program so that
 # dynamically loaded modules can be linked against them.