move llvm/Transforms/Pass.h to the top level llvm/Pass.h file
[oota-llvm.git] / include / llvm / Transforms / Scalar / DCE.h
1 //===-- DCE.h - Functions that perform Dead Code Elimination -----*- C++ -*--=//
2 //
3 // This family of functions is useful for performing dead code elimination of 
4 // various sorts.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_OPT_DCE_H
9 #define LLVM_OPT_DCE_H
10
11 #include "llvm/Pass.h"
12
13 namespace opt {
14
15 struct DeadCodeElimination : public Pass {
16   // External Interface:
17   //
18   static bool doDCE(Method *M);
19
20   // Remove unused global values - This removes unused global values of no
21   // possible value.  This currently includes unused method prototypes and
22   // unitialized global variables.
23   //
24   static bool RemoveUnusedGlobalValues(Module *M);
25
26   // RemoveUnusedGlobalValuesAfterLink - This function is only to be used after
27   // linking the application.  It removes global variables with initializers and
28   // unreachable methods.  This should only be used after an application is
29   // linked, when it is not possible for an external entity to make a global
30   // value live again.
31   //
32   // static bool RemoveUnusedGlobalValuesAfterLink(Module *M); // TODO
33
34   // Pass Interface...
35   virtual bool doPassInitialization(Module *M) {
36     return RemoveUnusedGlobalValues(M);
37   }
38   virtual bool doPerMethodWork(Method *M) { return doDCE(M); }
39   virtual bool doPassFinalization(Module *M) {
40     return RemoveUnusedGlobalValues(M);
41   }
42 };
43
44
45
46 struct AgressiveDCE : public Pass {
47   // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
48   //
49   static bool doADCE(Method *M);                        // Defined in ADCE.cpp
50
51   virtual bool doPerMethodWork(Method *M) {
52     return doADCE(M);
53   }
54 };
55
56
57
58 // SimplifyCFG - This function is used to do simplification of a CFG.  For
59 // example, it adjusts branches to branches to eliminate the extra hop, it
60 // eliminates unreachable basic blocks, and does other "peephole" optimization
61 // of the CFG.  It returns true if a modification was made, and returns an 
62 // iterator that designates the first element remaining after the block that
63 // was deleted.
64 //
65 // WARNING:  The entry node of a method may not be simplified.
66 //
67 bool SimplifyCFG(Method::iterator &BBIt);
68
69 }  // End namespace opt
70
71 #endif