mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
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
This commit is contained in:
parent
bcbb6b3fac
commit
da784ee81f
@ -11,6 +11,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
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, "");
|
||||||
@ -18,9 +19,7 @@ cl::String OutputFilename("o", "Output filename", cl::NoFlags, "");
|
|||||||
|
|
||||||
//-------------------------- Internal Functions -----------------------------//
|
//-------------------------- Internal Functions -----------------------------//
|
||||||
|
|
||||||
static void
|
static void NormalizeMethod(Method* method) {
|
||||||
NormalizeMethod(Method* method)
|
|
||||||
{
|
|
||||||
NormalizePhiConstantArgs(method);
|
NormalizePhiConstantArgs(method);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,39 +30,34 @@ NormalizeMethod(Method* method)
|
|||||||
// Entry point for the llc compiler.
|
// Entry point for the llc compiler.
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
|
|
||||||
int
|
int main(int argc, char **argv) {
|
||||||
main(int argc, char** argv)
|
// Parse command line options...
|
||||||
{
|
|
||||||
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n");
|
||||||
TargetMachine *Target = allocateSparcTargetMachine();
|
|
||||||
|
// Allocate a target... in the future this will be controllable on the
|
||||||
Module *M = ParseBytecodeFile(InputFilename);
|
// command line.
|
||||||
if (M == 0)
|
auto_ptr<TargetMachine> Target(allocateSparcTargetMachine());
|
||||||
{
|
|
||||||
cerr << "bytecode didn't read correctly.\n";
|
// Load the module to be compiled...
|
||||||
delete Target;
|
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);
|
||||||
|
|
||||||
|
if (Target.get()->compileMethod(Meth)) {
|
||||||
|
cerr << "Error compiling " << InputFilename << "!\n";
|
||||||
return 1;
|
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
|
return 0;
|
||||||
delete M;
|
|
||||||
delete Target;
|
|
||||||
return Failed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user