X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllc%2Fllc.cpp;h=a3312967d64942c85e79c5410aba57d9c646d737;hb=1e78f36127fb0e405d2cf893e2ce3381300a667b;hp=c8cefdb992eb01f74c6bfdcd513ed659399da6ac;hpb=cb465fc71ecb64d3d168a0cf754fa442abb0f6f9;p=oota-llvm.git diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index c8cefdb992e..a3312967d64 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -11,29 +11,31 @@ // //**************************************************************************/ -//************************** System Include Files **************************/ - -//*************************** User Include Files ***************************/ - #include "llvm/Module.h" #include "llvm/Method.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Bytecode/Writer.h" -#include "llvm/Codegen/InstrForest.h" -#include "llvm/Codegen/InstrSelection.h" -#include "llvm/LLC/LLCOptions.h" -#include "llvm/LLC/CompileContext.h" - -//************************** Forward Declarations **************************/ - -class Module; -class CompileContext; +#include "llvm/CodeGen/InstrSelection.h" +#include "llvm/CodeGen/Sparc.h" +#include "llvm/Support/CommandLine.h" +cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); +cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); -static bool CompileModule (Module *module, - CompileContext& compileContext); - -int DebugInstrSelectLevel = DEBUG_INSTR_TREES; +static bool CompileModule(Module *M, TargetMachine &Target) { + bool failed = false; + + for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) { + Method * method = *MI; + + if (SelectInstructionsForMethod(method, Target)) { + failed = true; + cerr << "Instruction selection failed for method " + << method->getName() << "\n\n"; + } + } + + return failed; +} //--------------------------------------------------------------------------- @@ -42,62 +44,23 @@ int DebugInstrSelectLevel = DEBUG_INSTR_TREES; // Entry point for the driver. //--------------------------------------------------------------------------- +int main(int argc, char** argv) { + cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n"); + UltraSparc Target; -int -main(int argc, const char** argv, const char** envp) -{ - CompileContext compileContext(argc, argv, envp); - - Module *module = - ParseBytecodeFile(compileContext.getOptions().getInputFileName()); - + Module *module = ParseBytecodeFile(InputFilename); if (module == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } - bool failure = CompileModule(module, compileContext); - - if (failure) - { - cerr << "Error compiling " - << compileContext.getOptions().getInputFileName() << "!\n"; - delete module; - return 1; - } - - // Okay, we're done now... write out result... - // WriteBytecodeToFile(module, - // compileContext.getOptions().getOutputFileName); + if (CompileModule(module, Target)) { + cerr << "Error compiling " << InputFilename << "!\n"; + delete module; + return 1; + } // Clean up and exit delete module; return 0; } - - -static bool -CompileModule(Module *module, - CompileContext& ccontext) -{ - bool failed = false; - - for (Module::MethodListType::const_iterator - methodIter = module->getMethodList().begin(); - methodIter != module->getMethodList().end(); - ++methodIter) - { - Method* method = *methodIter; - - if (SelectInstructionsForMethod(method, ccontext)) - { - failed = true; - cerr << "Instruction selection failed for method " - << (method->hasName()? method->getName() : "") - << endl << endl; - } - } - - return failed; -} -