diff options
Diffstat (limited to 'llvm/lib/Target/X86')
| -rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86TargetMachine.cpp | 86 | ||||
| -rw-r--r-- | llvm/lib/Target/X86/X86TargetMachine.h | 12 |
6 files changed, 35 insertions, 80 deletions
diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h index 9721fdcd4b9..b8a25a6bedf 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h @@ -37,7 +37,7 @@ class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter { MCContext *Context; MCStreamer *Streamer; public: - explicit X86ATTAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM, + explicit X86ATTAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : AsmPrinter(O, TM, T, V) { Subtarget = &TM.getSubtarget<X86Subtarget>(); diff --git a/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index 40b24f338fa..3fad77e8ca6 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -17,6 +17,7 @@ #include "X86ATTAsmPrinter.h" #include "X86IntelAsmPrinter.h" #include "X86Subtarget.h" +#include "llvm/Target/TargetRegistry.h" using namespace llvm; /// createX86CodePrinterPass - Returns a pass that prints the X86 assembly code @@ -24,7 +25,7 @@ using namespace llvm; /// machine description. /// FunctionPass *llvm::createX86CodePrinterPass(formatted_raw_ostream &o, - X86TargetMachine &tm, + TargetMachine &tm, bool verbose) { const X86Subtarget *Subtarget = &tm.getSubtarget<X86Subtarget>(); @@ -45,4 +46,10 @@ extern "C" int X86AsmPrinterForceLink; int X86AsmPrinterForceLink = 0; // Force static initialization. -extern "C" void LLVMInitializeX86AsmPrinter() { } +extern "C" void LLVMInitializeX86AsmPrinter() { + extern Target TheX86_32Target; + TargetRegistry::RegisterAsmPrinter(TheX86_32Target, createX86CodePrinterPass); + + extern Target TheX86_64Target; + TargetRegistry::RegisterAsmPrinter(TheX86_64Target, createX86CodePrinterPass); +} diff --git a/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h b/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h index 8872869187a..603de3e3736 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h +++ b/llvm/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h @@ -25,7 +25,7 @@ namespace llvm { struct VISIBILITY_HIDDEN X86IntelAsmPrinter : public AsmPrinter { - explicit X86IntelAsmPrinter(formatted_raw_ostream &O, X86TargetMachine &TM, + explicit X86IntelAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T, bool V) : AsmPrinter(O, TM, T, V) {} diff --git a/llvm/lib/Target/X86/X86.h b/llvm/lib/Target/X86/X86.h index ead4ce1f3f8..457e18ab0f3 100644 --- a/llvm/lib/Target/X86/X86.h +++ b/llvm/lib/Target/X86/X86.h @@ -47,7 +47,7 @@ FunctionPass *createX87FPRegKillInserterPass(); /// using the given target machine description. /// FunctionPass *createX86CodePrinterPass(formatted_raw_ostream &o, - X86TargetMachine &tm, + TargetMachine &tm, bool Verbose); /// createX86CodeEmitterPass - Return a pass that emits the collected X86 code diff --git a/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp index 40dc18df34b..c64084756c1 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -31,13 +31,18 @@ extern "C" int X86TargetMachineModule; int X86TargetMachineModule = 0; // Register the target. +extern Target TheX86_32Target; static RegisterTarget<X86_32TargetMachine> -X("x86", "32-bit X86: Pentium-Pro and above"); +X(TheX86_32Target, "x86", "32-bit X86: Pentium-Pro and above"); + +extern Target TheX86_64Target; static RegisterTarget<X86_64TargetMachine> -Y("x86-64", "64-bit X86: EM64T and AMD64"); +Y(TheX86_64Target, "x86-64", "64-bit X86: EM64T and AMD64"); // Force static initialization. -extern "C" void LLVMInitializeX86Target() { } +extern "C" void LLVMInitializeX86Target() { + +} // No assembler printer by default X86TargetMachine::AsmPrinterCtorFn X86TargetMachine::AsmPrinterCtor = 0; @@ -61,78 +66,23 @@ const TargetAsmInfo *X86TargetMachine::createTargetAsmInfo() const { } } -unsigned X86_32TargetMachine::getJITMatchQuality() { -#if defined(i386) || defined(__i386__) || defined(__x86__) || defined(_M_IX86) - return 10; -#endif - return 0; -} - -unsigned X86_64TargetMachine::getJITMatchQuality() { -#if defined(__x86_64__) || defined(_M_AMD64) - return 10; -#endif - return 0; -} - -unsigned X86_32TargetMachine::getModuleMatchQuality(const Module &M) { - // We strongly match "i[3-9]86-*". - std::string TT = M.getTargetTriple(); - if (TT.size() >= 5 && TT[0] == 'i' && TT[2] == '8' && TT[3] == '6' && - TT[4] == '-' && TT[1] - '3' < 6) - return 20; - // If the target triple is something non-X86, we don't match. - if (!TT.empty()) return 0; - - if (M.getEndianness() == Module::LittleEndian && - M.getPointerSize() == Module::Pointer32) - return 10; // Weak match - else if (M.getEndianness() != Module::AnyEndianness || - M.getPointerSize() != Module::AnyPointerSize) - return 0; // Match for some other target - - return getJITMatchQuality()/2; -} - -unsigned X86_64TargetMachine::getModuleMatchQuality(const Module &M) { - // We strongly match "x86_64-*". - std::string TT = M.getTargetTriple(); - if (TT.size() >= 7 && TT[0] == 'x' && TT[1] == '8' && TT[2] == '6' && - TT[3] == '_' && TT[4] == '6' && TT[5] == '4' && TT[6] == '-') - return 20; - - // We strongly match "amd64-*". - if (TT.size() >= 6 && TT[0] == 'a' && TT[1] == 'm' && TT[2] == 'd' && - TT[3] == '6' && TT[4] == '4' && TT[5] == '-') - return 20; - - // If the target triple is something non-X86-64, we don't match. - if (!TT.empty()) return 0; - - if (M.getEndianness() == Module::LittleEndian && - M.getPointerSize() == Module::Pointer64) - return 10; // Weak match - else if (M.getEndianness() != Module::AnyEndianness || - M.getPointerSize() != Module::AnyPointerSize) - return 0; // Match for some other target - - return getJITMatchQuality()/2; -} - -X86_32TargetMachine::X86_32TargetMachine(const Module &M, const std::string &FS) - : X86TargetMachine(M, FS, false) { +X86_32TargetMachine::X86_32TargetMachine(const Target &T, const Module &M, + const std::string &FS) + : X86TargetMachine(T, M, FS, false) { } -X86_64TargetMachine::X86_64TargetMachine(const Module &M, const std::string &FS) - : X86TargetMachine(M, FS, true) { +X86_64TargetMachine::X86_64TargetMachine(const Target &T, const Module &M, + const std::string &FS) + : X86TargetMachine(T, M, FS, true) { } /// X86TargetMachine ctor - Create an X86 target. /// -X86TargetMachine::X86TargetMachine(const Module &M, const std::string &FS, - bool is64Bit) - : Subtarget(M, FS, is64Bit), +X86TargetMachine::X86TargetMachine(const Target &T, const Module &M, + const std::string &FS, bool is64Bit) + : LLVMTargetMachine(T), + Subtarget(M, FS, is64Bit), DataLayout(Subtarget.getDataLayout()), FrameInfo(TargetFrameInfo::StackGrowsDown, Subtarget.getStackAlignment(), Subtarget.is64Bit() ? -8 : -4), diff --git a/llvm/lib/Target/X86/X86TargetMachine.h b/llvm/lib/Target/X86/X86TargetMachine.h index ea7a453a1ad..da6811bd236 100644 --- a/llvm/lib/Target/X86/X86TargetMachine.h +++ b/llvm/lib/Target/X86/X86TargetMachine.h @@ -44,12 +44,13 @@ protected: // To avoid having target depend on the asmprinter stuff libraries, asmprinter // set this functions to ctor pointer at startup time if they are linked in. typedef FunctionPass *(*AsmPrinterCtorFn)(formatted_raw_ostream &o, - X86TargetMachine &tm, + TargetMachine &tm, bool verbose); static AsmPrinterCtorFn AsmPrinterCtor; public: - X86TargetMachine(const Module &M, const std::string &FS, bool is64Bit); + X86TargetMachine(const Target &T, const Module &M, const std::string &FS, + bool is64Bit); virtual const X86InstrInfo *getInstrInfo() const { return &InstrInfo; } virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; } @@ -66,9 +67,6 @@ public: return Subtarget.isTargetELF() ? &ELFWriterInfo : 0; } - static unsigned getModuleMatchQuality(const Module &M); - static unsigned getJITMatchQuality(); - static void registerAsmPrinter(AsmPrinterCtorFn F) { AsmPrinterCtor = F; } @@ -101,7 +99,7 @@ public: /// class X86_32TargetMachine : public X86TargetMachine { public: - X86_32TargetMachine(const Module &M, const std::string &FS); + X86_32TargetMachine(const Target &T, const Module &M, const std::string &FS); static unsigned getJITMatchQuality(); static unsigned getModuleMatchQuality(const Module &M); @@ -111,7 +109,7 @@ public: /// class X86_64TargetMachine : public X86TargetMachine { public: - X86_64TargetMachine(const Module &M, const std::string &FS); + X86_64TargetMachine(const Target &T, const Module &M, const std::string &FS); static unsigned getJITMatchQuality(); static unsigned getModuleMatchQuality(const Module &M); |

