2 //***************************************************************************
7 // Driver for llc compiler.
10 // 7/15/01 - Vikram Adve - Created
12 //**************************************************************************/
14 //************************** System Include Files **************************/
16 //*************************** User Include Files ***************************/
18 #include "llvm/Module.h"
19 #include "llvm/Method.h"
20 #include "llvm/Bytecode/Reader.h"
21 #include "llvm/Bytecode/Writer.h"
22 #include "llvm/Codegen/InstrForest.h"
23 #include "llvm/Codegen/InstrSelection.h"
24 #include "llvm/LLC/LLCOptions.h"
25 #include "llvm/LLC/CompileContext.h"
27 //************************** Forward Declarations **************************/
33 static bool CompileModule (Module *module,
34 CompileContext& compileContext);
36 int DebugInstrSelectLevel = DEBUG_INSTR_TREES;
39 //---------------------------------------------------------------------------
42 // Entry point for the driver.
43 //---------------------------------------------------------------------------
47 main(int argc, const char** argv, const char** envp)
49 CompileContext compileContext(argc, argv, envp);
52 ParseBytecodeFile(compileContext.getOptions().getInputFileName());
55 cerr << "bytecode didn't read correctly.\n";
59 bool failure = CompileModule(module, compileContext);
63 cerr << "Error compiling "
64 << compileContext.getOptions().getInputFileName() << "!\n";
69 // Okay, we're done now... write out result...
70 // WriteBytecodeToFile(module,
71 // compileContext.getOptions().getOutputFileName);
80 CompileModule(Module *module,
81 CompileContext& ccontext)
85 for (Module::MethodListType::const_iterator
86 methodIter = module->getMethodList().begin();
87 methodIter != module->getMethodList().end();
90 Method* method = *methodIter;
92 if (SelectInstructionsForMethod(method, ccontext))
95 cerr << "Instruction selection failed for method "
96 << (method->hasName()? method->getName() : "")