add a note
[oota-llvm.git] / tools / llc / llc.cpp
index e71a7b985dba07b6f589e793d0fc97360ec92858..357eedd0b68e433540e5915902e951496d39b5c6 100644 (file)
@@ -23,7 +23,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/PluginLoader.h"
-#include "llvm/Support/PassNameParser.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Config/config.h"
@@ -48,6 +48,8 @@ static cl::opt<bool> Force("f", cl::desc("Overwrite output files"));
 static cl::opt<bool> Fast("fast", 
       cl::desc("Generate code quickly, potentially sacrificing code quality"));
 
+static cl::opt<std::string>
+TargetTriple("mtriple", cl::desc("Override target triple for module"));
 
 static cl::opt<const TargetMachineRegistry::Entry*, false, TargetNameParser>
 MArch("march", cl::desc("Architecture to generate code for:"));
@@ -76,11 +78,6 @@ FileType("filetype", cl::init(TargetMachine::AssemblyFile),
                   "  Emit a native dynamic library ('.so') file"),
        clEnumValEnd));
 
-// The LLCPassList is populated with passes that were registered using
-//  PassInfo::LLC by the FilteredPassNameParser:
-cl::list<const PassInfo*, bool, FilteredPassNameParser<PassInfo::LLC> >
-LLCPassList(cl::desc("Passes Available"));
-
 cl::opt<bool> NoVerify("disable-verify", cl::Hidden,
                        cl::desc("Do not verify input module"));
 
@@ -116,10 +113,12 @@ int main(int argc, char **argv) {
     }
     Module &mod = *M.get();
 
+    // If we are supposed to override the target triple, do so now.
+    if (!TargetTriple.empty())
+      mod.setTargetTriple(TargetTriple);
+    
     // Allocate target machine.  First, check whether the user has
     // explicitly specified an architecture to compile for.
-    TargetMachine* (*TargetMachineAllocator)(const Module&,
-                                             IntrinsicLowering *) = 0;
     if (MArch == 0) {
       std::string Err;
       MArch = TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err);
@@ -141,7 +140,7 @@ int main(int argc, char **argv) {
       FeaturesStr = Features.getString();
     }
 
-    std::auto_ptr<TargetMachine> target(MArch->CtorFn(mod, 0, FeaturesStr));
+    std::auto_ptr<TargetMachine> target(MArch->CtorFn(mod, FeaturesStr));
     assert(target.get() && "Could not allocate target machine!");
     TargetMachine &Target = *target.get();
     const TargetData &TD = Target.getTargetData();
@@ -150,19 +149,6 @@ int main(int argc, char **argv) {
     PassManager Passes;
     Passes.add(new TargetData(TD));
 
-    // Create a new pass for each one specified on the command line
-    for (unsigned i = 0; i < LLCPassList.size(); ++i) {
-      const PassInfo *aPass = LLCPassList[i];
-
-      if (aPass->getNormalCtor()) {
-        Pass *P = aPass->getNormalCtor()();
-        Passes.add(P);
-      } else {
-        std::cerr << argv[0] << ": cannot create pass: "
-                  << aPass->getPassName() << "\n";
-      }
-    }
-
 #ifndef NDEBUG
     if(!NoVerify)
       Passes.add(createVerifierPass());
@@ -230,14 +216,14 @@ int main(int argc, char **argv) {
         sys::RemoveFileOnSignal(sys::Path(OutputFilename));
       }
     }
-
+    
     // Ask the target to add backend passes as necessary.
     if (Target.addPassesToEmitFile(Passes, *Out, FileType, Fast)) {
       std::cerr << argv[0] << ": target '" << Target.getName()
                 << "' does not support generation of this file type!\n";
       if (Out != &std::cout) delete Out;
       // And the Out file is empty and useless, so remove it now.
-      std::remove(OutputFilename.c_str());
+      sys::Path(OutputFilename).eraseFromDisk();
       return 1;
     } else {
       // Run our queue of passes all at once now, efficiently.