2 //***************************************************************************
7 // Driver for llc compiler.
10 // 7/15/01 - Vikram Adve - Created
12 //**************************************************************************/
14 #include "llvm/Bytecode/Reader.h"
15 #include "llvm/Optimizations/Normalize.h"
16 #include "llvm/CodeGen/InstrSelection.h"
17 #include "llvm/CodeGen/InstrScheduling.h"
18 #include "llvm/CodeGen/Sparc.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Module.h"
21 #include "llvm/Method.h"
23 cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
24 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
27 static void NormalizeMethod(Method* method) {
28 NormalizePhiConstantArgs(method);
32 static bool CompileModule(Module *M, TargetMachine &Target) {
33 for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
36 NormalizeMethod(Meth);
38 if (SelectInstructionsForMethod(Meth, Target)) {
39 cerr << "Instruction selection failed for method "
40 << Meth->getName() << "\n\n";
44 if (ScheduleInstructionsWithSSA(Meth, Target)) {
45 cerr << "Instruction scheduling before allocation failed for method "
46 << Meth->getName() << "\n\n";
56 //---------------------------------------------------------------------------
59 // Entry point for the llc compiler.
60 //---------------------------------------------------------------------------
62 int main(int argc, char** argv) {
63 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
66 Module *module = ParseBytecodeFile(InputFilename);
68 cerr << "bytecode didn't read correctly.\n";
72 if (CompileModule(module, Target)) {
73 cerr << "Error compiling " << InputFilename << "!\n";