Add support for optimization passes that use a TargetMachine object.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Vikram S. Adve 2002-09-16 16:09:43 +00:00
parent be376cf6d4
commit 18fdfc4eed
2 changed files with 20 additions and 7 deletions

View File

@ -1,7 +1,9 @@
LEVEL = ../..
TOOLNAME = opt
USEDLIBS = bcreader bcwriter instrument profpaths scalaropts \
USEDLIBS = bcreader bcwriter instrument profpaths \
sparc.a target.a mapping.a regalloc.a sched.a select.a preselect \
livevar.a sparc.a scalaropts \
ipo ipa.a datastructure.a transforms target.a analysis \
transformutils vmcore support
TOOLLINKOPTS = -ldl

View File

@ -12,7 +12,8 @@
#include "llvm/Bytecode/WriteBytecodePass.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/Sparc.h"
#include "llvm/Support/PassNameParser.h"
#include "Support/Signals.h"
#include <fstream>
@ -60,10 +61,15 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv,
" llvm .bc -> .bc modular optimizer\n");
// FIXME: This should be parameterizable eventually for different target
// types...
// FIXME: The choice of target should be controllable on the command line.
TargetData TD("opt target");
// Allocate a full target machine description only if necessary...
// FIXME: The choice of target should be controllable on the command line.
std::auto_ptr<TargetMachine> target;
TargetMachine* TM = NULL;
// Load the input module...
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
if (M.get() == 0) {
@ -105,8 +111,13 @@ int main(int argc, char **argv) {
if (Opt->getNormalCtor())
Passes.add(Opt->getNormalCtor()());
else if (Opt->getDataCtor())
Passes.add(Opt->getDataCtor()(TD)); // Pass dummy target data...
else
Passes.add(Opt->getDataCtor()(TD)); // Provide dummy target data...
else if (Opt->getTargetCtor()) {
if (target.get() == NULL)
target.reset(allocateSparcTargetMachine()); // FIXME: target option
assert(target.get() && "Could not allocate target machine!");
Passes.add(Opt->getTargetCtor()(*target.get()));
} else
cerr << argv[0] << ": cannot create pass: " << Opt->getPassName() << "\n";
if (PrintEachXForm)