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 "llvm/Tools/CommandLine.h"
23 cl::String InputFilename ("", "Input filename", cl::NoFlags, "");
24 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
27 CompileContext::~CompileContext() { delete targetMachine; }
29 static bool CompileModule(Module *module, CompileContext& ccontext) {
32 for (Module::MethodListType::const_iterator
33 methodIter = module->getMethodList().begin();
34 methodIter != module->getMethodList().end();
37 Method* method = *methodIter;
39 if (SelectInstructionsForMethod(method, ccontext))
42 cerr << "Instruction selection failed for method "
43 << method->getName() << "\n\n";
51 //---------------------------------------------------------------------------
54 // Entry point for the driver.
55 //---------------------------------------------------------------------------
57 int main(int argc, char** argv) {
58 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
59 CompileContext compileContext(new UltraSparc());
61 Module *module = ParseBytecodeFile(InputFilename.getValue());
63 cerr << "bytecode didn't read correctly.\n";
67 bool failure = CompileModule(module, compileContext);
70 cerr << "Error compiling "
71 << InputFilename.getValue() << "!\n";
76 // Okay, we're done now... write out result...
77 // WriteBytecodeToFile(module,
78 // OutputFilename.getValue());