diff options
author | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-01-21 07:31:50 +0000 |
commit | f4de63f65fa995e68e3cd268117ab065068be413 (patch) | |
tree | 2fd8cd44af0f23dafd94102c1c0152b1cd82fe4d /tools/opt | |
parent | aff5bcebb7fb9880e0a3518a8e7c999e738d531c (diff) | |
download | external_llvm-f4de63f65fa995e68e3cd268117ab065068be413.zip external_llvm-f4de63f65fa995e68e3cd268117ab065068be413.tar.gz external_llvm-f4de63f65fa995e68e3cd268117ab065068be413.tar.bz2 |
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
Diffstat (limited to 'tools/opt')
-rw-r--r-- | tools/opt/opt.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 8a2208d..7f9acf0 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -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]); |