Revert 75762, 75763, 75766..75769, 75772..75775, 75778, 75780, 75782 to repair broken LLVM-GCC build.
Will revert 75770 in the llvm-gcc trunk.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75799 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 346e547..9acfcd2 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -128,8 +128,7 @@
   return outputFilename;
 }
 
-static formatted_raw_ostream *GetOutputStream(const char *TargetName, 
-                                              const char *ProgName) {
+static formatted_raw_ostream *GetOutputStream(const char *ProgName) {
   if (OutputFilename != "") {
     if (OutputFilename == "-")
       return &fouts();
@@ -170,10 +169,10 @@
   bool Binary = false;
   switch (FileType) {
   case TargetMachine::AssemblyFile:
-    if (TargetName[0] == 'c') {
-      if (TargetName[1] == 0)
+    if (MArch->Name[0] == 'c') {
+      if (MArch->Name[1] == 0)
         OutputFilename += ".cbe.c";
-      else if (TargetName[1] == 'p' && TargetName[2] == 'p')
+      else if (MArch->Name[1] == 'p' && MArch->Name[2] == 'p')
         OutputFilename += ".cpp";
       else
         OutputFilename += ".s";
@@ -249,13 +248,10 @@
 
   // Allocate target machine.  First, check whether the user has
   // explicitly specified an architecture to compile for.
-  const Target *TheTarget;
-  if (MArch) {
-    TheTarget = &MArch->TheTarget;
-  } else {
+  if (MArch == 0) {
     std::string Err;
-    TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
-    if (TheTarget == 0) {
+    MArch = TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err);
+    if (MArch == 0) {
       errs() << argv[0] << ": error auto-selecting target for module '"
              << Err << "'.  Please use the -march option to explicitly "
              << "pick a target.\n";
@@ -273,13 +269,12 @@
     FeaturesStr = Features.getString();
   }
 
-  std::auto_ptr<TargetMachine> 
-    target(TheTarget->createTargetMachine(mod, FeaturesStr));
+  std::auto_ptr<TargetMachine> target(MArch->CtorFn(mod, FeaturesStr));
   assert(target.get() && "Could not allocate target machine!");
   TargetMachine &Target = *target.get();
 
   // Figure out where we are going to send the output...
-  formatted_raw_ostream *Out = GetOutputStream(TheTarget->getName(), argv[0]);
+  formatted_raw_ostream *Out = GetOutputStream(argv[0]);
   if (Out == 0) return 1;
 
   CodeGenOpt::Level OLvl = CodeGenOpt::Default;
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index cb6c4ae..b4c4e77 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -328,9 +328,9 @@
     if ( _target == NULL ) {
         // create target machine from info for merged modules
         Module* mergedModule = _linker.getModule();
-        const Target *march = 
-          TargetRegistry::getClosestStaticTargetForModule(*mergedModule, 
-                                                          errMsg);
+        const TargetMachineRegistry::entry* march = 
+          TargetMachineRegistry::getClosestStaticTargetForModule(
+                                                       *mergedModule, errMsg);
         if ( march == NULL )
             return true;
 
@@ -351,7 +351,7 @@
         // construct LTModule, hand over ownership of module and target
         std::string FeatureStr =
           getFeatureString(_linker.getModule()->getTargetTriple().c_str());
-        _target = march->createTargetMachine(*mergedModule, FeatureStr.c_str());
+        _target = march->CtorFn(*mergedModule, FeatureStr.c_str());
     }
     return false;
 }
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index be6543c..38ee1cc 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -147,15 +147,15 @@
     if ( !m )
         return NULL;
     // find machine architecture for this module
-    const Target* march = 
-      TargetRegistry::getClosestStaticTargetForModule(*m, errMsg);
+    const TargetMachineRegistry::entry* march = 
+            TargetMachineRegistry::getClosestStaticTargetForModule(*m, errMsg);
 
     if ( march == NULL ) 
         return NULL;
 
     // construct LTModule, hand over ownership of module and target
     std::string FeatureStr = getFeatureString(m->getTargetTriple().c_str());
-    TargetMachine* target = march->createTargetMachine(*m, FeatureStr);
+    TargetMachine* target = march->CtorFn(*m, FeatureStr);
     return new LTOModule(m.take(), target);
 }