Clean up driver

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@492 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2001-09-07 21:26:31 +00:00
parent ddceab8fbf
commit 46ac43c1bb

View File

@ -11,55 +11,44 @@
// //
//**************************************************************************/ //**************************************************************************/
#include "llvm/Module.h"
#include "llvm/Method.h"
#include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Reader.h"
#include "llvm/Optimizations/Normalize.h" #include "llvm/Optimizations/Normalize.h"
#include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelection.h"
#include "llvm/CodeGen/InstrScheduling.h" #include "llvm/CodeGen/InstrScheduling.h"
#include "llvm/CodeGen/Sparc.h" #include "llvm/CodeGen/Sparc.h"
#include "llvm/Support/CommandLine.h" #include "llvm/Support/CommandLine.h"
#include "llvm/Module.h"
#include "llvm/Method.h"
cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
void static void NormalizeMethod(Method* method) {
NormalizeMethod(Method* method)
{
NormalizePhiConstantArgs(method); NormalizePhiConstantArgs(method);
} }
static bool static bool CompileModule(Module *M, TargetMachine &Target) {
CompileModule(Module *M, TargetMachine &target) for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
{ Method *Meth = *MI;
bool failed = false;
for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
{
Method* method = *MI;
NormalizeMethod(method); NormalizeMethod(Meth);
failed = SelectInstructionsForMethod(method, target); if (SelectInstructionsForMethod(Meth, Target)) {
if (failed) cerr << "Instruction selection failed for method "
{ << Meth->getName() << "\n\n";
cerr << "Instruction selection failed for method " return true;
<< method->getName() << "\n\n";
break;
}
failed = ScheduleInstructionsWithSSA(method, target);
if (failed)
{
cerr << "Instruction scheduling before allocation failed for method "
<< method->getName() << "\n\n";
break;
}
} }
if (ScheduleInstructionsWithSSA(Meth, Target)) {
cerr << "Instruction scheduling before allocation failed for method "
<< Meth->getName() << "\n\n";
return true;
}
}
return failed; return false;
} }
@ -70,11 +59,9 @@ CompileModule(Module *M, TargetMachine &target)
// Entry point for the llc compiler. // Entry point for the llc compiler.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
int int main(int argc, char** argv) {
main(int argc, char** argv)
{
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n"); cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
UltraSparc target; UltraSparc Target;
Module *module = ParseBytecodeFile(InputFilename); Module *module = ParseBytecodeFile(InputFilename);
if (module == 0) { if (module == 0) {
@ -82,7 +69,7 @@ main(int argc, char** argv)
return 1; return 1;
} }
if (CompileModule(module, target)) { if (CompileModule(module, Target)) {
cerr << "Error compiling " << InputFilename << "!\n"; cerr << "Error compiling " << InputFilename << "!\n";
delete module; delete module;
return 1; return 1;