Implement a more powerful, simpler, pass system. This pass system can figure

out how to run a collection of passes optimially given their behaviors and
charactaristics.

Convert code to use it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1507 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-01-21 07:31:50 +00:00
parent aff5bcebb7
commit f4de63f65f
32 changed files with 238 additions and 208 deletions

View File

@ -34,14 +34,13 @@ enum Opts {
indvars, instcombine, sccp, adce, raise,
// Interprocedural optimizations...
globaldce, swapstructs,
globaldce, swapstructs, sortstructs,
};
struct {
enum Opts OptID;
Pass *ThePass;
} OptTable[] = {
{ swapstructs, 0 },
{ dce , new opt::DeadCodeElimination() },
{ constprop , new opt::ConstantPropogation() },
{ inlining , new opt::MethodInlining() },
@ -55,8 +54,11 @@ struct {
{ raise , new RaisePointerReferences() },
{ trace , new InsertTraceCode(true, true) },
{ tracem , new InsertTraceCode(false, true) },
{ print , new PrintModulePass("Current Method: \n",&cerr) },
{ print , new PrintMethodPass("Current Method: \n",&cerr) },
{ cleangcc , new CleanupGCCOutput() },
{ globaldce , new GlobalDCE() },
{ swapstructs, new SimpleStructMutation(SimpleStructMutation::SwapElements) },
{ sortstructs, new SimpleStructMutation(SimpleStructMutation::SortElements) },
};
cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-");
@ -78,6 +80,7 @@ cl::EnumList<enum Opts> OptimizationList(cl::NoFlags,
clEnumVal(globaldce , "Remove unreachable globals"),
clEnumVal(swapstructs, "Swap structure types around"),
clEnumVal(sortstructs, "Sort structure elements"),
clEnumVal(cleangcc , "Cleanup GCC Output"),
clEnumVal(raise , "Raise to Higher Level"),
@ -95,18 +98,7 @@ static void RunOptimization(Module *M, enum Opts Opt) {
return;
}
// Special cases that haven't been fit into a consistent framework yet...
switch (Opt) {
case globaldce: {
GlobalDCE GDCE; GDCE.run(M); return;
}
case swapstructs: {
PrebuiltStructMutation SM(M, PrebuiltStructMutation::SortElements);
SM.run(M); return;
}
default:
cerr << "Optimization tables inconsistent!!\n";
}
cerr << "Optimization tables inconsistent!!\n";
}
int main(int argc, char **argv) {
@ -118,6 +110,8 @@ int main(int argc, char **argv) {
return 1;
}
PassManager Passes;
// Run all of the optimizations specified on the command line
for (unsigned i = 0; i < OptimizationList.size(); ++i)
RunOptimization(M.get(), OptimizationList[i]);