1 //===-- llc.cpp - Implement the LLVM Compiler -----------------------------===//
3 // This is the llc compiler driver.
5 //===----------------------------------------------------------------------===//
7 #include "llvm/Bytecode/Reader.h"
8 #include "llvm/Optimizations/Normalize.h"
9 #include "llvm/Target/Sparc.h"
10 #include "llvm/Target/Machine.h"
11 #include "llvm/Support/CommandLine.h"
12 #include "llvm/Module.h"
13 #include "llvm/Method.h"
15 cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
16 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
18 static void NormalizeMethod(Method* method) {
19 NormalizePhiConstantArgs(method);
22 //===----------------------------------------------------------------------===//
24 //===----------------------------------------------------------------------===//
26 // Entry point for the llc compiler.
28 int main(int argc, char** argv) {
29 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
30 TargetMachine *Target = allocateSparcTargetMachine();
32 Module *M = ParseBytecodeFile(InputFilename);
34 cerr << "bytecode didn't read correctly.\n";
40 for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
43 NormalizeMethod(Meth);
45 if (Target->compileMethod(Meth)) {
46 cerr << "Error compiling " << InputFilename << "!\n";