From bb43350e32c949ff9465eb898a2ed5ad9d1f3f9f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 24 Aug 2003 14:02:14 +0000 Subject: [PATCH] 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 --- tools/llc/llc.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 4d1bb772edf..631ac99bd6c 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 target((*TargetMachineAllocator)(Config)); + std::auto_ptr target((*TargetMachineAllocator)(0)); assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); const TargetData &TD = Target.getTargetData();