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/CodeGen/Sparc.h"
20 #include "llvm/Support/CommandLine.h"
22 cl::String InputFilename ("", "Input filename", cl::NoFlags, "");
23 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
25 static bool CompileModule(Module *module, TargetMachine &Target) {
28 for (Module::MethodListType::const_iterator
29 methodIter = module->getMethodList().begin();
30 methodIter != module->getMethodList().end();
33 Method* method = *methodIter;
35 if (SelectInstructionsForMethod(method, Target))
38 cerr << "Instruction selection failed for method "
39 << method->getName() << "\n\n";
47 //---------------------------------------------------------------------------
50 // Entry point for the driver.
51 //---------------------------------------------------------------------------
53 int main(int argc, char** argv) {
54 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
57 Module *module = ParseBytecodeFile(InputFilename.getValue());
59 cerr << "bytecode didn't read correctly.\n";
63 bool failure = CompileModule(module, Target);
66 cerr << "Error compiling "
67 << InputFilename.getValue() << "!\n";
72 // Okay, we're done now... write out result...
73 // WriteBytecodeToFile(module,
74 // OutputFilename.getValue());