aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-24 14:02:14 +0000
committerChris Lattner <sabre@nondot.org>2003-08-24 14:02:14 +0000
commitbb43350e32c949ff9465eb898a2ed5ad9d1f3f9f (patch)
treea2a102bc3b8d8536c50ed7dec694c4660d27e7da
parent030574fd357b23ceb8def7e7622749b17bd61b16 (diff)
Add support for modules with "any" pointersize/endianness
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8122 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/llc/llc.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 4d1bb772ed..631ac99bd6 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -68,8 +68,6 @@ int main(int argc, char **argv) {
// 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 @@ int main(int argc, char **argv) {
// 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();