[llvm-commits] CVS: llvm/tools/lli/JIT/Emitter.cpp JIT.cpp

John Criswell criswell at choi.cs.uiuc.edu
Thu Jun 26 16:38:34 PDT 2003


Changes in directory llvm/tools/lli/JIT:

Emitter.cpp updated: 1.14.2.1 -> 1.14.2.2
JIT.cpp updated: 1.7 -> 1.7.2.1

---
Log message:

Merged with mainline on Thursday, June 26, 2003.


---
Diffs of the changes:

Index: llvm/tools/lli/JIT/Emitter.cpp
diff -u llvm/tools/lli/JIT/Emitter.cpp:1.14.2.1 llvm/tools/lli/JIT/Emitter.cpp:1.14.2.2
--- llvm/tools/lli/JIT/Emitter.cpp:1.14.2.1	Mon Jun 23 14:04:54 2003
+++ llvm/tools/lli/JIT/Emitter.cpp	Thu Jun 26 16:36:16 2003
@@ -74,6 +74,9 @@
   static const long pageSize = sysconf(_SC_PAGESIZE);
 
 #if defined(i386) || defined(__i386__) || defined(__x86__)
+#if defined(MAP_ANON) && !defined(MAP_ANONYMOUS)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
   pa = mmap(0, pageSize*NumPages, PROT_READ|PROT_WRITE|PROT_EXEC,
             MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);  /* fd = 0  */
 #elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)


Index: llvm/tools/lli/JIT/JIT.cpp
diff -u llvm/tools/lli/JIT/JIT.cpp:1.7 llvm/tools/lli/JIT/JIT.cpp:1.7.2.1
--- llvm/tools/lli/JIT/JIT.cpp:1.7	Fri Jun  6 01:59:55 2003
+++ llvm/tools/lli/JIT/JIT.cpp	Thu Jun 26 16:36:16 2003
@@ -15,19 +15,23 @@
 #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)
+                  clEnumValN(Sparc, "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
@@ -36,28 +40,31 @@
 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;
-  } else if (Arch == "sparc") {
+    break;
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+  case Sparc:
     TargetMachineAllocator = allocateSparcTargetMachine;
-  }
-
-  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 {
+    break;
+#endif
+  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) {
@@ -68,6 +75,7 @@
 
   setupPassManager();
 
+#if defined(sparc) || defined(__sparc__) || defined(__sparcv9)
   // THIS GOES BEYOND UGLY HACKS
   if (TM.getName() == "UltraSparc-Native") {
     extern Pass *createPreSelectionPass(TargetMachine &TM);
@@ -77,6 +85,7 @@
     PM.add(createPreSelectionPass(TM));
     PM.run(*M);
   }
+#endif
 
   emitGlobals();
 }





More information about the llvm-commits mailing list