Introducing plugable register allocators and instruction schedulers.
[oota-llvm.git] / tools / llc / llc.cpp
index 3880348da1740b3692f9b80a0617b20db0e6b6c5..19b2df65e79ed459b75da1b8d365efb04360f6c6 100644 (file)
@@ -14,7 +14,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Bytecode/Reader.h"
+#include "llvm/Codegen/LinkAllCodegenComponents.h"
 #include "llvm/Target/SubtargetFeature.h"
+#include "llvm/Target/TargetData.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetMachineRegistry.h"
 #include "llvm/Transforms/Scalar.h"
 #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"
+#include "llvm/LinkAllVMCore.h"
 #include <fstream>
 #include <iostream>
 #include <memory>
-#include <cstdio>
 
 using namespace llvm;
 
@@ -80,11 +81,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"));
 
@@ -126,8 +122,6 @@ int main(int argc, char **argv) {
     
     // 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);
@@ -149,27 +143,13 @@ 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();
 
     // Build up all of the passes that we want to do to the module...
     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";
-      }
-    }
+    Passes.add(new TargetData(*Target.getTargetData()));
 
 #ifndef NDEBUG
     if(!NoVerify)
@@ -239,6 +219,9 @@ int main(int argc, char **argv) {
       }
     }
 
+    if (FileType != TargetMachine::AssemblyFile)
+      std::cerr << "WARNING: only -filetype=asm is currently supported.\n";
+    
     // Ask the target to add backend passes as necessary.
     if (Target.addPassesToEmitFile(Passes, *Out, FileType, Fast)) {
       std::cerr << argv[0] << ": target '" << Target.getName()