* Passes return true if they change something, not if they fail
authorChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 01:31:43 +0000 (01:31 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Oct 2001 01:31:43 +0000 (01:31 +0000)
* Convert opt to use Pass's and convert optimizations to pass structure

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@870 91177308-0d34-0410-b5e6-96231b3b80d8

tools/opt/opt.cpp

index 973a78ff8d3f2f95d09f28f564d21d32c98ed68f..3d62ef8ebf59b71316acd2996f8b557d3d238444 100644 (file)
@@ -39,17 +39,17 @@ enum Opts {
 
 struct {
   enum Opts OptID;
-  bool (*OptPtr)(Module *C);
+  Pass *ThePass;
 } OptTable[] = {
-  { dce      , DoDeadCodeElimination },
-  { constprop, DoConstantPropogation }, 
-  { inlining , DoMethodInlining      },
-  { strip    , DoSymbolStripping     },
-  { mstrip   , DoFullSymbolStripping },
-  { indvars  , DoInductionVariableCannonicalize },
-  { sccp     , DoSCCP                },
-  { adce     , DoADCE                },
-  { raise    , DoRaiseRepresentation },
+  { dce      , new opt::DeadCodeElimination() },
+  { constprop, new opt::ConstantPropogation() }, 
+  { inlining , new opt::MethodInlining() },
+  { strip    , new opt::SymbolStripping() },
+  { mstrip   , new opt::FullSymbolStripping() },
+  { indvars  , new opt::InductionVariableCannonicalize() },
+  { sccp     , new opt::SCCPPass() },
+  { adce     , new opt::AgressiveDCE() },
+  { raise    , new opt::RaiseRepresentation() },
 };
 
 cl::String InputFilename ("", "Load <arg> file to optimize", cl::NoFlags, "-");
@@ -86,7 +86,7 @@ int main(int argc, char **argv) {
     unsigned j;
     for (j = 0; j < sizeof(OptTable)/sizeof(OptTable[0]); ++j) {
       if (Opt == OptTable[j].OptID) {
-        if (OptTable[j].OptPtr(C) && !Quiet)
+        if (OptTable[j].ThePass->run(C) && !Quiet)
           cerr << OptimizationList.getArgName(Opt)
               << " pass made modifications!\n";
         break;