[llvm-commits] [llvm] r55432 - /llvm/trunk/tools/opt/opt.cpp

Devang Patel dpatel at apple.com
Wed Aug 27 13:51:50 PDT 2008


Author: dpatel
Date: Wed Aug 27 15:51:49 2008
New Revision: 55432

URL: http://llvm.org/viewvc/llvm-project?rev=55432&view=rev
Log:
Backout 55429

Modified:
    llvm/trunk/tools/opt/opt.cpp

Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=55432&r1=55431&r2=55432&view=diff

==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Wed Aug 27 15:51:49 2008
@@ -22,8 +22,6 @@
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Target/SubtargetFeature.h"
 #include "llvm/Support/PassNameParser.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -95,22 +93,6 @@
 static cl::opt<bool>
 AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
 
-static cl::opt<const TargetMachineRegistry::entry*, false,
-               TargetMachineRegistry::Parser>
-MArch("march", cl::desc("Architecture to generate code for:"));
-
-static cl::opt<std::string>
-MCPU("mcpu", 
-  cl::desc("Target a specific cpu type (-mcpu=help for details)"),
-  cl::value_desc("cpu-name"),
-  cl::init(""));
-
-static cl::list<std::string>
-MAttrs("mattr", 
-  cl::CommaSeparated,
-  cl::desc("Target specific attributes (-mattr=help for details)"),
-  cl::value_desc("a1,+a2,-a3,..."));
-
 // ---------- Define Printers for module and function passes ------------
 namespace {
 
@@ -326,36 +308,6 @@
 //===----------------------------------------------------------------------===//
 // main for opt
 //
-
-TargetMachine *getTargetMachine(Module &Mod) {
-
-  if (MArch == 0) {
-    std::string Err;
-    MArch = 
-      TargetMachineRegistry::getClosestStaticTargetForModule(Mod, Err);
-    if (MArch == 0) {
-      std::cerr << "Error auto-selecting target for module '"
-                << Err << "'.  Please use the -march option to explicitly "
-                << "pick a target.\n";
-      return NULL;
-    }
-  }
-  
-  // Package up features to be passed to target/subtarget
-  std::string FeaturesStr;
-  if (MCPU.size() || MAttrs.size()) {
-    SubtargetFeatures Features;
-    Features.setCPU(MCPU);
-    for (unsigned i = 0; i != MAttrs.size(); ++i)
-      Features.AddFeature(MAttrs[i]);
-    FeaturesStr = Features.getString();
-  }
-  
-  TargetMachine *Target = MArch->CtorFn(Mod, FeaturesStr);
-  assert(Target && "Could not allocate target machine!");
-  return Target;
-}
-
 int main(int argc, char **argv) {
   llvm_shutdown_obj X;  // Call llvm_shutdown() on exit.
   try {
@@ -363,6 +315,10 @@
       "llvm .bc -> .bc modular optimizer and analysis printer\n");
     sys::PrintStackTraceOnErrorSignal();
 
+    // Allocate a full target machine description only if necessary.
+    // FIXME: The choice of target should be controllable on the command line.
+    std::auto_ptr<TargetMachine> target;
+
     std::string ErrorMessage;
 
     // Load the input module...





More information about the llvm-commits mailing list