blob: e1a4905edcb48bde09d1365bb2c3d12cfaad0383 [file] [log] [blame]
Chris Lattner2cf137b2001-09-07 22:20:50 +00001//===------------------------------------------------------------------------===
2// LLVM 'LLC' UTILITY
3//
4// This is the llc compiler driver.
5//
6//===------------------------------------------------------------------------===
Vikram S. Adve2d94a342001-07-21 12:42:29 +00007
Vikram S. Adve2d94a342001-07-21 12:42:29 +00008#include "llvm/Bytecode/Reader.h"
Vikram S. Adve799aed02001-08-28 23:23:14 +00009#include "llvm/Optimizations/Normalize.h"
Chris Lattner9c0f8f22001-07-22 04:40:02 +000010#include "llvm/CodeGen/Sparc.h"
Chris Lattnere2472bb2001-07-23 17:46:59 +000011#include "llvm/Support/CommandLine.h"
Chris Lattnered226062001-09-07 21:26:31 +000012#include "llvm/Module.h"
13#include "llvm/Method.h"
Chris Lattner0af24642001-07-23 02:35:57 +000014
Chris Lattnerab0cc402001-07-23 19:27:24 +000015cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
Chris Lattner0af24642001-07-23 02:35:57 +000016cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
17
Chris Lattnered226062001-09-07 21:26:31 +000018static void NormalizeMethod(Method* method) {
Vikram S. Adve799aed02001-08-28 23:23:14 +000019 NormalizePhiConstantArgs(method);
20}
21
22
Chris Lattnered226062001-09-07 21:26:31 +000023static bool CompileModule(Module *M, TargetMachine &Target) {
24 for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
25 Method *Meth = *MI;
Chris Lattner9c0f8f22001-07-22 04:40:02 +000026
Chris Lattnered226062001-09-07 21:26:31 +000027 NormalizeMethod(Meth);
Vikram S. Adve799aed02001-08-28 23:23:14 +000028
Chris Lattner0a823a02001-09-14 03:37:52 +000029 if (Target.compileMethod(Meth)) return true;
Chris Lattnered226062001-09-07 21:26:31 +000030 }
Chris Lattner9c0f8f22001-07-22 04:40:02 +000031
Chris Lattnered226062001-09-07 21:26:31 +000032 return false;
Chris Lattner9c0f8f22001-07-22 04:40:02 +000033}
Vikram S. Adve2d94a342001-07-21 12:42:29 +000034
35
Vikram S. Adve799aed02001-08-28 23:23:14 +000036
Vikram S. Adve2d94a342001-07-21 12:42:29 +000037//---------------------------------------------------------------------------
38// Function main()
39//
Vikram S. Adve799aed02001-08-28 23:23:14 +000040// Entry point for the llc compiler.
Vikram S. Adve2d94a342001-07-21 12:42:29 +000041//---------------------------------------------------------------------------
42
Chris Lattnered226062001-09-07 21:26:31 +000043int main(int argc, char** argv) {
Chris Lattner0af24642001-07-23 02:35:57 +000044 cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
Chris Lattnered226062001-09-07 21:26:31 +000045 UltraSparc Target;
Vikram S. Adve799aed02001-08-28 23:23:14 +000046
Chris Lattnerab0cc402001-07-23 19:27:24 +000047 Module *module = ParseBytecodeFile(InputFilename);
Vikram S. Adve2d94a342001-07-21 12:42:29 +000048 if (module == 0) {
49 cerr << "bytecode didn't read correctly.\n";
50 return 1;
51 }
Vikram S. Adve799aed02001-08-28 23:23:14 +000052
Chris Lattnered226062001-09-07 21:26:31 +000053 if (CompileModule(module, Target)) {
Chris Lattnerab0cc402001-07-23 19:27:24 +000054 cerr << "Error compiling " << InputFilename << "!\n";
55 delete module;
56 return 1;
57 }
Vikram S. Adve2d94a342001-07-21 12:42:29 +000058
59 // Clean up and exit
60 delete module;
61 return 0;
62}
Chris Lattner0a823a02001-09-14 03:37:52 +000063