2001-09-18 13:10:45 +00:00
|
|
|
//===-- llc.cpp - Implement the LLVM Compiler ----------------------------===//
|
2001-09-07 22:20:50 +00:00
|
|
|
//
|
|
|
|
// This is the llc compiler driver.
|
|
|
|
//
|
2001-09-18 13:10:45 +00:00
|
|
|
//===---------------------------------------------------------------------===//
|
2001-07-21 12:42:29 +00:00
|
|
|
|
|
|
|
#include "llvm/Bytecode/Reader.h"
|
2001-08-28 23:23:14 +00:00
|
|
|
#include "llvm/Optimizations/Normalize.h"
|
2001-09-14 05:34:53 +00:00
|
|
|
#include "llvm/Target/Sparc.h"
|
2001-09-18 13:10:45 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2001-07-23 17:46:59 +00:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2001-09-07 21:26:31 +00:00
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/Method.h"
|
2001-07-23 02:35:57 +00:00
|
|
|
|
2001-07-23 19:27:24 +00:00
|
|
|
cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
|
2001-07-23 02:35:57 +00:00
|
|
|
cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
|
|
|
|
|
2001-09-18 13:10:45 +00:00
|
|
|
|
|
|
|
//-------------------------- Internal Functions -----------------------------//
|
|
|
|
|
|
|
|
static void
|
|
|
|
NormalizeMethod(Method* method)
|
|
|
|
{
|
2001-08-28 23:23:14 +00:00
|
|
|
NormalizePhiConstantArgs(method);
|
|
|
|
}
|
|
|
|
|
2001-09-18 13:10:45 +00:00
|
|
|
|
|
|
|
//===---------------------------------------------------------------------===//
|
2001-07-21 12:42:29 +00:00
|
|
|
// Function main()
|
|
|
|
//
|
2001-08-28 23:23:14 +00:00
|
|
|
// Entry point for the llc compiler.
|
2001-09-18 13:10:45 +00:00
|
|
|
//===---------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
2001-07-23 02:35:57 +00:00
|
|
|
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
2001-09-14 04:32:55 +00:00
|
|
|
TargetMachine *Target = allocateSparcTargetMachine();
|
2001-08-28 23:23:14 +00:00
|
|
|
|
2001-09-14 05:34:53 +00:00
|
|
|
Module *M = ParseBytecodeFile(InputFilename);
|
2001-09-18 13:10:45 +00:00
|
|
|
if (M == 0)
|
|
|
|
{
|
|
|
|
cerr << "bytecode didn't read correctly.\n";
|
|
|
|
delete Target;
|
|
|
|
return 1;
|
|
|
|
}
|
2001-08-28 23:23:14 +00:00
|
|
|
|
2001-09-14 05:34:53 +00:00
|
|
|
bool Failed = false;
|
2001-09-18 13:10:45 +00:00
|
|
|
for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
|
|
|
|
{
|
|
|
|
Method *Meth = *MI;
|
2001-09-14 05:34:53 +00:00
|
|
|
|
2001-09-18 13:10:45 +00:00
|
|
|
NormalizeMethod(Meth);
|
2001-09-14 05:34:53 +00:00
|
|
|
|
2001-09-18 13:10:45 +00:00
|
|
|
if (Target->compileMethod(Meth))
|
|
|
|
{
|
|
|
|
cerr << "Error compiling " << InputFilename << "!\n";
|
|
|
|
Failed = true;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-14 05:34:53 +00:00
|
|
|
}
|
2001-07-21 12:42:29 +00:00
|
|
|
|
|
|
|
// Clean up and exit
|
2001-09-14 05:34:53 +00:00
|
|
|
delete M;
|
2001-09-14 04:32:55 +00:00
|
|
|
delete Target;
|
2001-09-14 05:34:53 +00:00
|
|
|
return Failed;
|
2001-07-21 12:42:29 +00:00
|
|
|
}
|
2001-09-14 03:37:52 +00:00
|
|
|
|
2001-09-18 13:10:45 +00:00
|
|
|
|