diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 20:24:03 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-15 20:24:03 +0000 |
commit | fe5939fd18b28961606da555f9c0ca5d7099a19b (patch) | |
tree | 7d6c8b0869f698fb07f0ef49b12c444a1c9ed668 /include/llvm/Target | |
parent | b6b1170290c50b59a24a5dea8276b75f7d52ef8a (diff) | |
download | external_llvm-fe5939fd18b28961606da555f9c0ca5d7099a19b.tar.gz external_llvm-fe5939fd18b28961606da555f9c0ca5d7099a19b.tar.bz2 external_llvm-fe5939fd18b28961606da555f9c0ca5d7099a19b.zip |
Reapply TargetRegistry refactoring commits.
--- Reverse-merging r75799 into '.':
U test/Analysis/PointerTracking
U include/llvm/Target/TargetMachineRegistry.h
U include/llvm/Target/TargetMachine.h
U include/llvm/Target/TargetRegistry.h
U include/llvm/Target/TargetSelect.h
U tools/lto/LTOCodeGenerator.cpp
U tools/lto/LTOModule.cpp
U tools/llc/llc.cpp
U lib/Target/PowerPC/PPCTargetMachine.h
U lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
U lib/Target/PowerPC/PPCTargetMachine.cpp
U lib/Target/PowerPC/PPC.h
U lib/Target/ARM/ARMTargetMachine.cpp
U lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp
U lib/Target/ARM/ARMTargetMachine.h
U lib/Target/ARM/ARM.h
U lib/Target/XCore/XCoreTargetMachine.cpp
U lib/Target/XCore/XCoreTargetMachine.h
U lib/Target/PIC16/PIC16TargetMachine.cpp
U lib/Target/PIC16/PIC16TargetMachine.h
U lib/Target/Alpha/AsmPrinter/AlphaAsmPrinter.cpp
U lib/Target/Alpha/AlphaTargetMachine.cpp
U lib/Target/Alpha/AlphaTargetMachine.h
U lib/Target/X86/X86TargetMachine.h
U lib/Target/X86/X86.h
U lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h
U lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
U lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.h
U lib/Target/X86/X86TargetMachine.cpp
U lib/Target/MSP430/MSP430TargetMachine.cpp
U lib/Target/MSP430/MSP430TargetMachine.h
U lib/Target/CppBackend/CPPTargetMachine.h
U lib/Target/CppBackend/CPPBackend.cpp
U lib/Target/CBackend/CTargetMachine.h
U lib/Target/CBackend/CBackend.cpp
U lib/Target/TargetMachine.cpp
U lib/Target/IA64/IA64TargetMachine.cpp
U lib/Target/IA64/AsmPrinter/IA64AsmPrinter.cpp
U lib/Target/IA64/IA64TargetMachine.h
U lib/Target/IA64/IA64.h
U lib/Target/MSIL/MSILWriter.cpp
U lib/Target/CellSPU/SPUTargetMachine.h
U lib/Target/CellSPU/SPU.h
U lib/Target/CellSPU/AsmPrinter/SPUAsmPrinter.cpp
U lib/Target/CellSPU/SPUTargetMachine.cpp
U lib/Target/Mips/AsmPrinter/MipsAsmPrinter.cpp
U lib/Target/Mips/MipsTargetMachine.cpp
U lib/Target/Mips/MipsTargetMachine.h
U lib/Target/Mips/Mips.h
U lib/Target/Sparc/AsmPrinter/SparcAsmPrinter.cpp
U lib/Target/Sparc/SparcTargetMachine.cpp
U lib/Target/Sparc/SparcTargetMachine.h
U lib/ExecutionEngine/JIT/TargetSelect.cpp
U lib/Support/TargetRegistry.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Target')
-rw-r--r-- | include/llvm/Target/TargetMachine.h | 21 | ||||
-rw-r--r-- | include/llvm/Target/TargetMachineRegistry.h | 47 | ||||
-rw-r--r-- | include/llvm/Target/TargetRegistry.h | 16 | ||||
-rw-r--r-- | include/llvm/Target/TargetSelect.h | 4 |
4 files changed, 38 insertions, 50 deletions
diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index ce293d5114..5ac1d69941 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -19,6 +19,7 @@ namespace llvm { +class Target; class TargetAsmInfo; class TargetData; class TargetSubtarget; @@ -99,11 +100,14 @@ class TargetMachine { TargetMachine(const TargetMachine &); // DO NOT IMPLEMENT void operator=(const TargetMachine &); // DO NOT IMPLEMENT protected: // Can only create subclasses. - TargetMachine(); + TargetMachine(const Target &); /// getSubtargetImpl - virtual method implemented by subclasses that returns /// a reference to that target's TargetSubtarget-derived member variable. virtual const TargetSubtarget *getSubtargetImpl() const { return 0; } + + /// TheTarget - The Target that this machine was created for. + const Target &TheTarget; /// AsmInfo - Contains target specific asm information. /// @@ -116,18 +120,7 @@ protected: // Can only create subclasses. public: virtual ~TargetMachine(); - /// getModuleMatchQuality - This static method should be implemented by - /// targets to indicate how closely they match the specified module. This is - /// used by the LLC tool to determine which target to use when an explicit - /// -march option is not specified. If a target returns zero, it will never - /// be chosen without an explicit -march option. - static unsigned getModuleMatchQuality(const Module &) { return 0; } - - /// getJITMatchQuality - This static method should be implemented by targets - /// that provide JIT capabilities to indicate how suitable they are for - /// execution on the current host. If a value of 0 is returned, the target - /// will not be used unless an explicit -march option is used. - static unsigned getJITMatchQuality() { return 0; } + const Target &getTarget() const { return TheTarget; } // Interfaces to the major aspects of target machine information: // -- Instruction opcode and operand information @@ -308,7 +301,7 @@ public: /// class LLVMTargetMachine : public TargetMachine { protected: // Can only create subclasses. - LLVMTargetMachine() { } + LLVMTargetMachine(const Target &T) : TargetMachine(T) { } /// addCommonCodeGenPasses - Add standard LLVM codegen passes used for /// both emitting to assembly files or machine code output. diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h index b7ea448b20..6b78a58ab0 100644 --- a/include/llvm/Target/TargetMachineRegistry.h +++ b/include/llvm/Target/TargetMachineRegistry.h @@ -19,25 +19,21 @@ #include "llvm/Module.h" #include "llvm/Support/Registry.h" +#include "llvm/Target/TargetRegistry.h" namespace llvm { class Module; + class Target; class TargetMachine; struct TargetMachineRegistryEntry { + const Target &TheTarget; const char *Name; const char *ShortDesc; - TargetMachine *(*CtorFn)(const Module &, const std::string &); - unsigned (*ModuleMatchQualityFn)(const Module &M); - unsigned (*JITMatchQualityFn)(); public: - TargetMachineRegistryEntry(const char *N, const char *SD, - TargetMachine *(*CF)(const Module &, const std::string &), - unsigned (*MMF)(const Module &M), - unsigned (*JMF)()) - : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), - JITMatchQualityFn(JMF) {} + TargetMachineRegistryEntry(const Target &T, const char *N, const char *SD) + : TheTarget(T), Name(N), ShortDesc(SD) {} }; template<> @@ -50,24 +46,15 @@ namespace llvm { }; struct TargetMachineRegistry : public Registry<TargetMachine> { - /// getClosestStaticTargetForModule - Given an LLVM module, pick the best - /// target that is compatible with the module. If no close target can be - /// found, this returns null and sets the Error string to a reason. - static const entry *getClosestStaticTargetForModule(const Module &M, - std::string &Error); - - /// getClosestTargetForJIT - Pick the best target that is compatible with - /// the current host. If no close target can be found, this returns null - /// and sets the Error string to a reason. - static const entry *getClosestTargetForJIT(std::string &Error); }; //===--------------------------------------------------------------------===// /// RegisterTarget - This class is used to make targets automatically register - /// themselves with the tool they are linked. Targets should define an - /// instance of this and implement the static methods described in the - /// TargetMachine comments. + /// themselves with the tools they are linked with. Targets should define an + /// single global Target instance and register it using the TargetRegistry + /// interfaces. Targets must also include a static instance of this class. + /// /// The type 'TargetMachineImpl' should provide a constructor with two /// parameters: /// - const Module& M: the module that is being compiled: @@ -76,19 +63,19 @@ namespace llvm { template<class TargetMachineImpl> struct RegisterTarget { - RegisterTarget(const char *Name, const char *ShortDesc) - : Entry(Name, ShortDesc, &Allocator, - &TargetMachineImpl::getModuleMatchQuality, - &TargetMachineImpl::getJITMatchQuality), - Node(Entry) - {} + RegisterTarget(Target &T, const char *Name, const char *ShortDesc) + : Entry(T, Name, ShortDesc), + Node(Entry) { + TargetRegistry::RegisterTargetMachine(T, &Allocator); + } private: TargetMachineRegistry::entry Entry; TargetMachineRegistry::node Node; - static TargetMachine *Allocator(const Module &M, const std::string &FS) { - return new TargetMachineImpl(M, FS); + static TargetMachine *Allocator(const Target &T, const Module &M, + const std::string &FS) { + return new TargetMachineImpl(T, M, FS); } }; diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index 204d5b0c8f..95cf35c455 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -42,7 +42,8 @@ namespace llvm { typedef unsigned (*ModuleMatchQualityFnTy)(const Module &M); typedef unsigned (*JITMatchQualityFnTy)(); - typedef TargetMachine *(*TargetMachineCtorTy)(const Module &, + typedef TargetMachine *(*TargetMachineCtorTy)(const Target &, + const Module &, const std::string &); typedef FunctionPass *(*AsmPrinterCtorTy)(formatted_raw_ostream &, TargetMachine &, @@ -87,18 +88,22 @@ namespace llvm { /// getShortDescription - Get a short description of the target. const char *getShortDescription() const { return ShortDesc; } + /// getJITMatchQuality - Get the quality of this targets match for use as a + /// JIT. + unsigned getJITMatchQuality() const { return JITMatchQualityFn(); } + /// createTargetMachine - Create a target specific machine implementation. TargetMachine *createTargetMachine(const Module &M, - const std::string &Features) { + const std::string &Features) const { if (!TargetMachineCtorFn) return 0; - return TargetMachineCtorFn(M, Features); + return TargetMachineCtorFn(*this, M, Features); } /// createAsmPrinter - Create a target specific assembly printer pass. FunctionPass *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &M, - bool Verbose) { + bool Verbose) const { if (!AsmPrinterCtorFn) return 0; return AsmPrinterCtorFn(OS, M, Verbose); @@ -135,7 +140,8 @@ namespace llvm { /// @name Target Registration /// @{ - /// RegisterTarget - Register the given target. + /// RegisterTarget - Register the given target. Attempts to register a + /// target which has already been registered will be ignored. /// /// Clients are responsible for ensuring that registration doesn't occur /// while another thread is attempting to access the registry. Typically diff --git a/include/llvm/Target/TargetSelect.h b/include/llvm/Target/TargetSelect.h index 19b660b52d..a360f731ba 100644 --- a/include/llvm/Target/TargetSelect.h +++ b/include/llvm/Target/TargetSelect.h @@ -58,7 +58,9 @@ namespace llvm { inline bool InitializeNativeTarget() { // If we have a native target, initialize it to ensure it is linked in. #ifdef LLVM_NATIVE_ARCH -#define DoInit2(TARG) LLVMInitialize ## TARG () +#define DoInit2(TARG) \ + LLVMInitialize ## TARG ## Info (); \ + LLVMInitialize ## TARG () #define DoInit(T) DoInit2(T) DoInit(LLVM_NATIVE_ARCH); return false; |