summaryrefslogtreecommitdiff
path: root/tools/llc/llc.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-09-18 17:04:18 +0000
committerChris Lattner <sabre@nondot.org>2001-09-18 17:04:18 +0000
commitda784ee81f082781fb61258546fec7c82ba6a8f0 (patch)
tree89dd3682fb545bef0f0fbecb0e5781390631d864 /tools/llc/llc.cpp
parentbcbb6b3fac7259e8364b462c3fb6f4379e3508e5 (diff)
downloadllvm-da784ee81f082781fb61258546fec7c82ba6a8f0.tar.gz
llvm-da784ee81f082781fb61258546fec7c82ba6a8f0.tar.bz2
llvm-da784ee81f082781fb61258546fec7c82ba6a8f0.tar.xz
C++ gives us auto_ptr's, so we might as well use them. :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@629 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llc/llc.cpp')
-rw-r--r--tools/llc/llc.cpp54
1 files changed, 24 insertions, 30 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index 73298edade..77cc7cee16 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -11,6 +11,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Module.h"
#include "llvm/Method.h"
+#include <memory>
cl::String InputFilename ("", "Input filename", cl::NoFlags, "-");
cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
@@ -18,9 +19,7 @@ cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
//-------------------------- Internal Functions -----------------------------//
-static void
-NormalizeMethod(Method* method)
-{
+static void NormalizeMethod(Method* method) {
NormalizePhiConstantArgs(method);
}
@@ -31,39 +30,34 @@ NormalizeMethod(Method* method)
// Entry point for the llc compiler.
//===---------------------------------------------------------------------===//
-int
-main(int argc, char** argv)
-{
+int main(int argc, char **argv) {
+ // Parse command line options...
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
- TargetMachine *Target = allocateSparcTargetMachine();
-
- Module *M = ParseBytecodeFile(InputFilename);
- if (M == 0)
- {
- cerr << "bytecode didn't read correctly.\n";
- delete Target;
- return 1;
- }
- bool Failed = false;
- for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
- {
- Method *Meth = *MI;
+ // Allocate a target... in the future this will be controllable on the
+ // command line.
+ auto_ptr<TargetMachine> Target(allocateSparcTargetMachine());
+
+ // Load the module to be compiled...
+ auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
+ if (M.get() == 0) {
+ cerr << "bytecode didn't read correctly.\n";
+ return 1;
+ }
+
+ // Loop over all of the methods in the module, compiling them.
+ for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ Method *Meth = *MI;
- NormalizeMethod(Meth);
+ NormalizeMethod(Meth);
- if (Target->compileMethod(Meth))
- {
- cerr << "Error compiling " << InputFilename << "!\n";
- Failed = true;
- break;
- }
+ if (Target.get()->compileMethod(Meth)) {
+ cerr << "Error compiling " << InputFilename << "!\n";
+ return 1;
}
+ }
- // Clean up and exit
- delete M;
- delete Target;
- return Failed;
+ return 0;
}