2 //***************************************************************************
7 // Driver for llc compiler.
10 // 7/15/01 - Vikram Adve - Created
12 //**************************************************************************/
14 #include "llvm/Module.h"
15 #include "llvm/Method.h"
16 #include "llvm/Bytecode/Reader.h"
17 #include "llvm/Bytecode/Writer.h"
18 #include "llvm/CodeGen/InstrSelection.h"
19 #include "llvm/LLC/CompileContext.h"
20 #include "llvm/CodeGen/Sparc.h"
21 #include "LLCOptions.h"
23 CompileContext::~CompileContext() { delete targetMachine; }
25 static bool CompileModule(Module *module, CompileContext& ccontext,
26 LLCOptions &Options) {
29 for (Module::MethodListType::const_iterator
30 methodIter = module->getMethodList().begin();
31 methodIter != module->getMethodList().end();
34 Method* method = *methodIter;
36 if (SelectInstructionsForMethod(method, ccontext,
37 Options.IntOptionValue(DEBUG_INSTR_SELECT_OPT)))
40 cerr << "Instruction selection failed for method "
41 << method->getName() << "\n\n";
49 //---------------------------------------------------------------------------
52 // Entry point for the driver.
53 //---------------------------------------------------------------------------
55 int main(int argc, const char** argv, const char** envp) {
56 LLCOptions Options(argc, argv, envp);
57 CompileContext compileContext(new UltraSparc());
59 Module *module = ParseBytecodeFile(Options.getInputFileName());
61 cerr << "bytecode didn't read correctly.\n";
65 bool failure = CompileModule(module, compileContext, Options);
68 cerr << "Error compiling "
69 << Options.getInputFileName() << "!\n";
74 // Okay, we're done now... write out result...
75 // WriteBytecodeToFile(module,
76 // compileContext.getOptions().getOutputFileName);