X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FTarget%2FTargetMachineRegistry.h;h=a1b13d360d0b05f696211ccf7d0d19a50200e38c;hb=617dd7baa6dfd3a7b5ee72ace37f6b6aeaa6006b;hp=280db90ced8cb976730cd8dd17c56cbb97017c4b;hpb=babf11f249c7c6399c66f2567d4e7efa9c37a9c3;p=oota-llvm.git diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h index 280db90ced8..a1b13d360d0 100644 --- a/include/llvm/Target/TargetMachineRegistry.h +++ b/include/llvm/Target/TargetMachineRegistry.h @@ -17,77 +17,36 @@ #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H #define LLVM_TARGET_TARGETMACHINEREGISTRY_H -#include "llvm/Support/Registry.h" +#include "llvm/Module.h" +#include "llvm/Target/TargetRegistry.h" namespace llvm { class Module; + class Target; class TargetMachine; - - struct TargetMachineRegistryEntry { - 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) {} - }; - - template<> - class RegistryTraits { - public: - typedef TargetMachineRegistryEntry entry; - - static const char *nameof(const entry &Entry) { return Entry.Name; } - static const char *descof(const entry &Entry) { return Entry.ShortDesc; } - }; - - struct TargetMachineRegistry : public Registry { - /// 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. - /// The type 'TargetMachineImpl' should provide a constructor with two + /// 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: - /// - const std::string& fs: target-specific string describing target + /// - const std::string& FS: target-specific string describing target /// flavour. - + template 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) { + 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); } };