[llvm-commits] CVS: llvm/tools/llc/llc.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Aug 24 09:06:10 PDT 2003


Changes in directory llvm/tools/llc:

llc.cpp updated: 1.80 -> 1.81

---
Log message:

Add support for modules with "any" pointersize/endianness


---
Diffs of the changes:

Index: llvm/tools/llc/llc.cpp
diff -u llvm/tools/llc/llc.cpp:1.80 llvm/tools/llc/llc.cpp:1.81
--- llvm/tools/llc/llc.cpp:1.80	Wed Jul 30 10:29:55 2003
+++ llvm/tools/llc/llc.cpp	Sun Aug 24 09:02:14 2003
@@ -68,8 +68,6 @@
 
   // Allocate target machine.  First, check whether the user has
   // explicitly specified an architecture to compile for.
-  unsigned Config = (mod.isLittleEndian()   ? TM::LittleEndian : TM::BigEndian)|
-                    (mod.has32BitPointers() ? TM::PtrSize32    : TM::PtrSize64);
   TargetMachine* (*TargetMachineAllocator)(unsigned) = 0;
   switch (Arch) {
   case x86:
@@ -83,16 +81,28 @@
     // the module. This heuristic (ILP32, LE -> IA32; LP64, BE ->
     // SPARCV9) is kind of gross, but it will work until we have more
     // sophisticated target information to work from.
-    if (mod.isLittleEndian() && mod.has32BitPointers()) { 
+    if (mod.getEndianness()  == Module::LittleEndian &&
+        mod.getPointerSize() == Module::Pointer32) { 
       TargetMachineAllocator = allocateX86TargetMachine;
-    } else if (mod.isBigEndian() && mod.has64BitPointers()) {
+    } else if (mod.getEndianness()  == Module::BigEndian &&
+               mod.getPointerSize() == Module::Pointer64) { 
       TargetMachineAllocator = allocateSparcTargetMachine;
     } else {
-      assert(0 && "You must specify -march; I could not guess the default");
+      // If the module is target independent, favor a target which matches the
+      // current build system.
+#if defined(i386) || defined(__i386__) || defined(__x86__)
+      TargetMachineAllocator = allocateX86TargetMachine;
+#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9)
+      TargetMachineAllocator = allocateSparcTargetMachine;
+#else
+      std::cerr << argv[0] << ": module does not specify a target to use.  "
+                << "You must use the -march option.\n";
+      return 1;
+#endif
     } 
     break;
   }
-  std::auto_ptr<TargetMachine> target((*TargetMachineAllocator)(Config));
+  std::auto_ptr<TargetMachine> target((*TargetMachineAllocator)(0));
   assert(target.get() && "Could not allocate target machine!");
   TargetMachine &Target = *target.get();
   const TargetData &TD = Target.getTargetData();





More information about the llvm-commits mailing list