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
diff --git a/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp
index 4f07545..cc3d61e 100644
--- a/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp
+++ b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp
@@ -12,43 +12,10 @@
 #include "llvm/Target/TargetRegistry.h"
 using namespace llvm;
 
-Target llvm::TheMipsTarget;
-
-static unsigned Mips_TripleMatchQuality(const std::string &TT) {
-  // We strongly match "mips*-*".
-  if (TT.size() >= 5 && std::string(TT.begin(), TT.begin()+5) == "mips-")
-    return 20;
-  
-  if (TT.size() >= 13 && std::string(TT.begin(), 
-      TT.begin()+13) == "mipsallegrex-")
-    return 20;
-
-  return 0;
-}
-
-Target llvm::TheMipselTarget;
-
-static unsigned Mipsel_TripleMatchQuality(const std::string &TT) {
-  // We strongly match "mips*el-*".
-  if (TT.size() >= 7 && std::string(TT.begin(), TT.begin()+7) == "mipsel-")
-    return 20;
-
-  if (TT.size() >= 15 && std::string(TT.begin(), 
-      TT.begin()+15) == "mipsallegrexel-")
-    return 20;
-
-  if (TT.size() == 3 && std::string(TT.begin(), TT.begin()+3) == "psp")
-    return 20;
-
-  return 0;
-}
+Target llvm::TheMipsTarget, llvm::TheMipselTarget;
 
 extern "C" void LLVMInitializeMipsTargetInfo() { 
-  TargetRegistry::RegisterTarget(TheMipsTarget, "mips",
-                                  "Mips",
-                                  &Mips_TripleMatchQuality);
+  RegisterTarget<Triple::mips> X(TheMipsTarget, "mips", "Mips");
 
-  TargetRegistry::RegisterTarget(TheMipselTarget, "mipsel",
-                                  "Mipsel",
-                                  &Mipsel_TripleMatchQuality);
+  RegisterTarget<Triple::mipsel> Y(TheMipselTarget, "mipsel", "Mipsel");
 }