aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llc/llc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/llc/llc.cpp')
-rw-r--r--tools/llc/llc.cpp54
1 files changed, 23 insertions, 31 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index fb5c1fc..789087f 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -1,14 +1,13 @@
-//===------------------------------------------------------------------------===
-// LLVM 'LLC' UTILITY
+//===-- llc.cpp - Implement the LLVM Compiler -----------------------------===//
//
// This is the llc compiler driver.
//
-//===------------------------------------------------------------------------===
+//===----------------------------------------------------------------------===//
#include "llvm/Bytecode/Reader.h"
#include "llvm/Optimizations/Normalize.h"
-#include "llvm/CodeGen/Sparc.h"
-#include "llvm/CodeGen/TargetMachine.h"
+#include "llvm/Target/Sparc.h"
+#include "llvm/Target/Machine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Module.h"
#include "llvm/Method.h"
@@ -20,46 +19,39 @@ static void NormalizeMethod(Method* method) {
NormalizePhiConstantArgs(method);
}
-
-static bool CompileModule(Module *M, TargetMachine &Target) {
- for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
- Method *Meth = *MI;
-
- NormalizeMethod(Meth);
-
- if (Target.compileMethod(Meth)) return true;
- }
-
- return false;
-}
-
-
-
-//---------------------------------------------------------------------------
+//===----------------------------------------------------------------------===//
// Function main()
+//===----------------------------------------------------------------------===//
//
// Entry point for the llc compiler.
-//---------------------------------------------------------------------------
-
+//
int main(int argc, char** argv) {
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
TargetMachine *Target = allocateSparcTargetMachine();
- Module *module = ParseBytecodeFile(InputFilename);
- if (module == 0) {
+ Module *M = ParseBytecodeFile(InputFilename);
+ if (M == 0) {
cerr << "bytecode didn't read correctly.\n";
+ delete Target;
return 1;
}
- if (CompileModule(module, *Target)) {
- cerr << "Error compiling " << InputFilename << "!\n";
- delete module;
- return 1;
+ bool Failed = false;
+ for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ Method *Meth = *MI;
+
+ NormalizeMethod(Meth);
+
+ if (Target->compileMethod(Meth)) {
+ cerr << "Error compiling " << InputFilename << "!\n";
+ Failed = true;
+ break;
+ }
}
// Clean up and exit
- delete module;
+ delete M;
delete Target;
- return 0;
+ return Failed;
}