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/TargetMachine.h"
11 #include "llvm/Support/CommandLine.h"
12 #include "llvm/Module.h"
13 #include "llvm/Method.h"
16 cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
17 cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
20 //-------------------------- Internal Functions -----------------------------//
22 static void NormalizeMethod(Method* method) {
23 NormalizePhiConstantArgs(method);
27 //===---------------------------------------------------------------------===//
30 // Entry point for the llc compiler.
31 //===---------------------------------------------------------------------===//
33 int main(int argc, char **argv) {
34 // Parse command line options...
35 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
37 // Allocate a target... in the future this will be controllable on the
39 auto_ptr<TargetMachine> Target(allocateSparcTargetMachine());
41 // Load the module to be compiled...
42 auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
44 cerr << "bytecode didn't read correctly.\n";
48 // Loop over all of the methods in the module, compiling them.
49 for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
52 NormalizeMethod(Meth);
54 if (Target.get()->compileMethod(Meth)) {
55 cerr << "Error compiling " << InputFilename << "!\n";