mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
Merge the 'analyze' mode code with the 'opt' mode code. Eliminate the
'autodetect .ll files' functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1c548b645b
commit
7f500f7f2a
@ -10,7 +10,7 @@ LEVEL = ../..
|
|||||||
TOOLNAME = opt
|
TOOLNAME = opt
|
||||||
REQUIRES_EH := 1
|
REQUIRES_EH := 1
|
||||||
|
|
||||||
USEDLIBS = LLVMAsmParser.a LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a \
|
USEDLIBS = LLVMBCReader.a LLVMBCWriter.a LLVMInstrumentation.a \
|
||||||
LLVMScalarOpts.a LLVMipo.a LLVMipa.a LLVMDataStructure \
|
LLVMScalarOpts.a LLVMipo.a LLVMipa.a LLVMDataStructure \
|
||||||
LLVMTransforms.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \
|
LLVMTransforms.a LLVMTarget.a LLVMTransformUtils.a LLVMAnalysis.a \
|
||||||
LLVMCore.a LLVMSupport.a LLVMbzip2.a LLVMSystem.a
|
LLVMCore.a LLVMSupport.a LLVMbzip2.a LLVMSystem.a
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/Assembly/Parser.h"
|
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
#include "llvm/Bytecode/Reader.h"
|
||||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
#include "llvm/Bytecode/WriteBytecodePass.h"
|
||||||
@ -37,9 +36,8 @@ using namespace llvm;
|
|||||||
// The OptimizationList is automatically populated with registered Passes by the
|
// The OptimizationList is automatically populated with registered Passes by the
|
||||||
// PassNameParser.
|
// PassNameParser.
|
||||||
//
|
//
|
||||||
static cl::list<const PassInfo*, bool,
|
static cl::list<const PassInfo*, bool, PassNameParser>
|
||||||
FilteredPassNameParser<PassInfo::Optimization> >
|
PassList(cl::desc("Optimizations available:"));
|
||||||
OptimizationList(cl::desc("Optimizations available:"));
|
|
||||||
|
|
||||||
|
|
||||||
// Other command line options...
|
// Other command line options...
|
||||||
@ -74,12 +72,6 @@ QuietA("quiet", cl::desc("Alias for -q"), cl::aliasopt(Quiet));
|
|||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
|
AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
|
||||||
|
|
||||||
// The AnalysesList is automatically populated with registered Passes by the
|
|
||||||
// PassNameParser.
|
|
||||||
static
|
|
||||||
cl::list<const PassInfo*, bool, FilteredPassNameParser<PassInfo::Analysis> >
|
|
||||||
AnalysesList(cl::desc("Analyses available:"));
|
|
||||||
|
|
||||||
static Timer BytecodeLoadTimer("Bytecode Loader");
|
static Timer BytecodeLoadTimer("Bytecode Loader");
|
||||||
|
|
||||||
// ---------- Define Printers for module and function passes ------------
|
// ---------- Define Printers for module and function passes ------------
|
||||||
@ -166,57 +158,7 @@ int main(int argc, char **argv) {
|
|||||||
" llvm .bc -> .bc modular optimizer and analysis printer \n");
|
" llvm .bc -> .bc modular optimizer and analysis printer \n");
|
||||||
sys::PrintStackTraceOnErrorSignal();
|
sys::PrintStackTraceOnErrorSignal();
|
||||||
|
|
||||||
if (AnalyzeOnly) {
|
// Allocate a full target machine description only if necessary.
|
||||||
Module *CurMod = 0;
|
|
||||||
#if 0
|
|
||||||
TimeRegion RegionTimer(BytecodeLoadTimer);
|
|
||||||
#endif
|
|
||||||
CurMod = ParseBytecodeFile(InputFilename);
|
|
||||||
ParseError Err;
|
|
||||||
if (!CurMod && !(CurMod = ParseAssemblyFile(InputFilename,&Err))){
|
|
||||||
std::cerr << argv[0] << ": " << Err.getMessage() << "\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a PassManager to hold and optimize the collection of passes we
|
|
||||||
// are about to build...
|
|
||||||
PassManager Passes;
|
|
||||||
|
|
||||||
// Add an appropriate TargetData instance for this module...
|
|
||||||
Passes.add(new TargetData(CurMod));
|
|
||||||
|
|
||||||
// Make sure the input LLVM is well formed.
|
|
||||||
if (!NoVerify)
|
|
||||||
Passes.add(createVerifierPass());
|
|
||||||
|
|
||||||
// Create a new optimization pass for each one specified on the
|
|
||||||
// command line
|
|
||||||
for (unsigned i = 0; i < AnalysesList.size(); ++i) {
|
|
||||||
const PassInfo *Analysis = AnalysesList[i];
|
|
||||||
|
|
||||||
if (Analysis->getNormalCtor()) {
|
|
||||||
Pass *P = Analysis->getNormalCtor()();
|
|
||||||
Passes.add(P);
|
|
||||||
|
|
||||||
if (BasicBlockPass *BBP = dynamic_cast<BasicBlockPass*>(P))
|
|
||||||
Passes.add(new BasicBlockPassPrinter(Analysis));
|
|
||||||
else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P))
|
|
||||||
Passes.add(new FunctionPassPrinter(Analysis));
|
|
||||||
else
|
|
||||||
Passes.add(new ModulePassPrinter(Analysis));
|
|
||||||
|
|
||||||
} else
|
|
||||||
std::cerr << argv[0] << ": cannot create pass: "
|
|
||||||
<< Analysis->getPassName() << "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
Passes.run(*CurMod);
|
|
||||||
|
|
||||||
delete CurMod;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Allocate a full target machine description only if necessary...
|
|
||||||
// FIXME: The choice of target should be controllable on the command line.
|
// FIXME: The choice of target should be controllable on the command line.
|
||||||
std::auto_ptr<TargetMachine> target;
|
std::auto_ptr<TargetMachine> target;
|
||||||
|
|
||||||
@ -275,22 +217,30 @@ int main(int argc, char **argv) {
|
|||||||
Passes.add(new TargetData(M.get()));
|
Passes.add(new TargetData(M.get()));
|
||||||
|
|
||||||
// Create a new optimization pass for each one specified on the command line
|
// Create a new optimization pass for each one specified on the command line
|
||||||
for (unsigned i = 0; i < OptimizationList.size(); ++i) {
|
for (unsigned i = 0; i < PassList.size(); ++i) {
|
||||||
const PassInfo *Opt = OptimizationList[i];
|
const PassInfo *PassInf = PassList[i];
|
||||||
|
Pass *P = 0;
|
||||||
if (Opt->getNormalCtor())
|
if (PassInf->getNormalCtor())
|
||||||
Passes.add(Opt->getNormalCtor()());
|
P = PassInf->getNormalCtor()();
|
||||||
else if (Opt->getTargetCtor()) {
|
else if (PassInf->getTargetCtor()) {
|
||||||
#if 0
|
|
||||||
if (target.get() == NULL)
|
|
||||||
target.reset(allocateSparcTargetMachine()); // FIXME: target option
|
|
||||||
#endif
|
|
||||||
assert(target.get() && "Could not allocate target machine!");
|
assert(target.get() && "Could not allocate target machine!");
|
||||||
Passes.add(Opt->getTargetCtor()(*target.get()));
|
P = PassInf->getTargetCtor()(*target.get());
|
||||||
} else
|
} else
|
||||||
std::cerr << argv[0] << ": cannot create pass: " << Opt->getPassName()
|
std::cerr << argv[0] << ": cannot create pass: "
|
||||||
<< "\n";
|
<< PassInf->getPassName() << "\n";
|
||||||
|
if (P) {
|
||||||
|
Passes.add(P);
|
||||||
|
|
||||||
|
if (AnalyzeOnly) {
|
||||||
|
if (BasicBlockPass *BBP = dynamic_cast<BasicBlockPass*>(P))
|
||||||
|
Passes.add(new BasicBlockPassPrinter(PassInf));
|
||||||
|
else if (FunctionPass *FP = dynamic_cast<FunctionPass*>(P))
|
||||||
|
Passes.add(new FunctionPassPrinter(PassInf));
|
||||||
|
else
|
||||||
|
Passes.add(new ModulePassPrinter(PassInf));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PrintEachXForm)
|
if (PrintEachXForm)
|
||||||
Passes.add(new PrintModulePass(&std::cerr));
|
Passes.add(new PrintModulePass(&std::cerr));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user