diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 05:03:33 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-26 05:03:33 +0000 |
commit | 8977d087c693fd581db82bcff134d12da0f48bd3 (patch) | |
tree | 658de5d523595bb7928de54e705d38109d63e53b /include | |
parent | 8c2f1d7e44d214bc2242a8c6faa4b624b3876540 (diff) | |
download | external_llvm-8977d087c693fd581db82bcff134d12da0f48bd3.zip external_llvm-8977d087c693fd581db82bcff134d12da0f48bd3.tar.gz external_llvm-8977d087c693fd581db82bcff134d12da0f48bd3.tar.bz2 |
Factor commonality in triple match routines into helper template for registering
classes, and migrate existing targets over.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77126 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Target/TargetRegistry.h | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/include/llvm/Target/TargetRegistry.h b/include/llvm/Target/TargetRegistry.h index a216186..9c651f2 100644 --- a/include/llvm/Target/TargetRegistry.h +++ b/include/llvm/Target/TargetRegistry.h @@ -19,6 +19,7 @@ #ifndef LLVM_TARGET_TARGETREGISTRY_H #define LLVM_TARGET_TARGETREGISTRY_H +#include "llvm/ADT/Triple.h" // FIXME: We shouldn't need this header, but we need it until there is a // different interface to get the TargetAsmInfo. #include "llvm/Target/TargetMachine.h" @@ -281,23 +282,22 @@ namespace llvm { /// /// Target TheFooTarget; // The global target instance. /// - /// namespace { - /// struct FooInfo { - /// static const bool HasJIT = ...; - /// - /// static unsigned getTripleMatchQuality(const std::string &) { ... } - /// }; - /// } - /// /// extern "C" void LLVMInitializeFooTargetInfo() { - /// RegisterTarget<FooAsmPrinter> X(TheFooTarget, "foo", "Foo description"); + /// RegisterTarget<Triple::foo> X(TheFooTarget, "foo", "Foo description"); /// } - template<class TargetInfoImpl> + template<Triple::ArchType TargetArchType = Triple::InvalidArch, + bool HasJIT = false> struct RegisterTarget { RegisterTarget(Target &T, const char *Name, const char *Desc) { TargetRegistry::RegisterTarget(T, Name, Desc, - &TargetInfoImpl::getTripleMatchQuality, - TargetInfoImpl::HasJIT); + &getTripleMatchQuality, + HasJIT); + } + + static unsigned getTripleMatchQuality(const std::string &TT) { + if (Triple(TT.c_str()).getArch() == TargetArchType) + return 20; + return 0; } }; |