2001-07-21 12:42:29 +00:00
|
|
|
// $Id$
|
|
|
|
//***************************************************************************
|
|
|
|
// File:
|
|
|
|
// llc.cpp
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Driver for llc compiler.
|
|
|
|
//
|
|
|
|
// History:
|
|
|
|
// 7/15/01 - Vikram Adve - Created
|
|
|
|
//
|
|
|
|
//**************************************************************************/
|
|
|
|
|
|
|
|
#include "llvm/Module.h"
|
|
|
|
#include "llvm/Method.h"
|
|
|
|
#include "llvm/Bytecode/Reader.h"
|
2001-07-21 20:58:30 +00:00
|
|
|
#include "llvm/CodeGen/InstrSelection.h"
|
2001-07-22 04:40:02 +00:00
|
|
|
#include "llvm/CodeGen/Sparc.h"
|
2001-07-23 17:46:59 +00:00
|
|
|
#include "llvm/Support/CommandLine.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-07-23 19:27:24 +00:00
|
|
|
static bool CompileModule(Module *M, TargetMachine &Target) {
|
2001-07-22 04:40:02 +00:00
|
|
|
bool failed = false;
|
|
|
|
|
2001-07-23 19:27:24 +00:00
|
|
|
for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
|
|
|
|
Method * method = *MI;
|
2001-07-22 04:40:02 +00:00
|
|
|
|
2001-07-23 19:27:24 +00:00
|
|
|
if (SelectInstructionsForMethod(method, Target)) {
|
|
|
|
failed = true;
|
|
|
|
cerr << "Instruction selection failed for method "
|
|
|
|
<< method->getName() << "\n\n";
|
2001-07-22 04:40:02 +00:00
|
|
|
}
|
2001-07-23 19:27:24 +00:00
|
|
|
}
|
2001-07-22 04:40:02 +00:00
|
|
|
|
|
|
|
return failed;
|
|
|
|
}
|
2001-07-21 12:42:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Function main()
|
|
|
|
//
|
|
|
|
// Entry point for the driver.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2001-07-23 02:35:57 +00:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
2001-07-23 03:09:03 +00:00
|
|
|
UltraSparc Target;
|
2001-07-23 02:35:57 +00:00
|
|
|
|
2001-07-23 19:27:24 +00:00
|
|
|
Module *module = ParseBytecodeFile(InputFilename);
|
2001-07-21 12:42:29 +00:00
|
|
|
if (module == 0) {
|
|
|
|
cerr << "bytecode didn't read correctly.\n";
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-07-23 19:27:24 +00:00
|
|
|
if (CompileModule(module, Target)) {
|
|
|
|
cerr << "Error compiling " << InputFilename << "!\n";
|
|
|
|
delete module;
|
|
|
|
return 1;
|
|
|
|
}
|
2001-07-21 12:42:29 +00:00
|
|
|
|
|
|
|
// Clean up and exit
|
|
|
|
delete module;
|
|
|
|
return 0;
|
|
|
|
}
|