1 //===------------------------------------------------------------------------===
4 // This is the llc compiler driver.
6 //===------------------------------------------------------------------------===
8 #include "llvm/Bytecode/Reader.h"
9 #include "llvm/Optimizations/Normalize.h"
10 #include "llvm/CodeGen/InstrSelection.h"
11 #include "llvm/CodeGen/InstrScheduling.h"
12 #include "llvm/CodeGen/Sparc.h"
13 #include "llvm/Support/CommandLine.h"
14 #include "llvm/Module.h"
15 #include "llvm/Method.h"
17 cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
18 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
20 static void NormalizeMethod(Method* method) {
21 NormalizePhiConstantArgs(method);
25 static bool CompileModule(Module *M, TargetMachine &Target) {
26 for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
29 NormalizeMethod(Meth);
31 if (SelectInstructionsForMethod(Meth, Target)) {
32 cerr << "Instruction selection failed for method " << Meth->getName()
37 if (ScheduleInstructionsWithSSA(Meth, Target)) {
38 cerr << "Instruction scheduling before allocation failed for method "
39 << Meth->getName() << "\n\n";
49 //---------------------------------------------------------------------------
52 // Entry point for the llc compiler.
53 //---------------------------------------------------------------------------
55 int main(int argc, char** argv) {
56 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
59 Module *module = ParseBytecodeFile(InputFilename);
61 cerr << "bytecode didn't read correctly.\n";
65 if (CompileModule(module, Target)) {
66 cerr << "Error compiling " << InputFilename << "!\n";