Add TargetRegistry::lookupTarget.
 - This is a simplified mechanism which just looks up a target based on the
   target triple, with a few additional flags.

 - Remove getClosestStaticTargetForModule, the moral equivalent is now:
     lookupTarget(Mod->getTargetTriple, true, false, ...);

 - This no longer does the fuzzy matching with target data (based on endianness
   and pointer width) that getClosestStaticTargetForModule was doing, but this
   was deemed unnecessary.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77111 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 6d66268..9f7f0a4 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -252,7 +252,10 @@
     }        
   } else {
     std::string Err;
-    TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
+    TheTarget = TargetRegistry::lookupTarget(mod.getTargetTriple(), 
+                                             /*FallbackToHost=*/true,
+                                             /*RequireJIT=*/false,
+                                             Err);
     if (TheTarget == 0) {
       errs() << argv[0] << ": error auto-selecting target for module '"
              << Err << "'.  Please use the -march option to explicitly "
diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp
index ffc9b55..5212ab1 100644
--- a/tools/llvm-mc/llvm-mc.cpp
+++ b/tools/llvm-mc/llvm-mc.cpp
@@ -147,7 +147,10 @@
   // Get the target specific parser.
   std::string Error;
   const Target *TheTarget =
-    TargetRegistry::getClosestStaticTargetForTriple(Triple, Error);
+    TargetRegistry::lookupTarget(Triple, 
+                                 /*FallbackToHost=*/true,
+                                 /*RequireJIT=*/false,
+                                 Error);
   if (TheTarget == 0) {
     errs() << ProgName << ": error: unable to get target for '" << Triple
            << "', see --version and --triple.\n";
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 93689e3..a264e73 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -330,8 +330,10 @@
         // create target machine from info for merged modules
         Module* mergedModule = _linker.getModule();
         const Target *march = 
-          TargetRegistry::getClosestStaticTargetForModule(*mergedModule, 
-                                                          errMsg);
+          TargetRegistry::lookupTarget(mergedModule->getTargetTriple(), 
+                                       /*FallbackToHost=*/true,
+                                       /*RequireJIT=*/false,
+                                       errMsg);
         if ( march == NULL )
             return true;
 
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index a72938a..83dda0c 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -145,9 +145,10 @@
     if ( !m )
         return NULL;
     // find machine architecture for this module
-    const Target* march = 
-      TargetRegistry::getClosestStaticTargetForModule(*m, errMsg);
-
+    const Target* march = TargetRegistry::lookupTarget(m->getTargetTriple(), 
+                                                       /*FallbackToHost=*/true,
+                                                       /*RequireJIT=*/false,
+                                                       errMsg);
     if ( march == NULL ) 
         return NULL;