Move stuff out of the Optimizations directories into the appropriate Transforms
[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 #include "llvm/BasicBlock.h"
13
14 struct DeadCodeElimination : public MethodPass {
15   // External Interface:
16   //
17   static bool doDCE(Method *M);
18
19   // dceInstruction - Inspect the instruction at *BBI and figure out if it's
20   // [trivially] dead.  If so, remove the instruction and update the iterator
21   // to point to the instruction that immediately succeeded the original
22   // instruction.
23   //
24   static bool dceInstruction(BasicBlock::InstListType &BBIL,
25                              BasicBlock::iterator &BBI);
26
27   // Remove unused global values - This removes unused global values of no
28   // possible value.  This currently includes unused method prototypes and
29   // unitialized global variables.
30   //
31   static bool RemoveUnusedGlobalValues(Module *M);
32
33   // Pass Interface...
34   virtual bool doInitialization(Module *M) {
35     return RemoveUnusedGlobalValues(M);
36   }
37   virtual bool runOnMethod(Method *M) { return doDCE(M); }
38   virtual bool doFinalization(Module *M) {
39     return RemoveUnusedGlobalValues(M);
40   }
41 };
42
43
44
45 struct AgressiveDCE : public MethodPass {
46   // DoADCE - Execute the Agressive Dead Code Elimination Algorithm
47   //
48   static bool doADCE(Method *M);                        // Defined in ADCE.cpp
49
50   virtual bool runOnMethod(Method *M) {
51     return doADCE(M);
52   }
53 };
54
55
56 // SimplifyCFG - This function is used to do simplification of a CFG.  For
57 // example, it adjusts branches to branches to eliminate the extra hop, it
58 // eliminates unreachable basic blocks, and does other "peephole" optimization
59 // of the CFG.  It returns true if a modification was made, and returns an 
60 // iterator that designates the first element remaining after the block that
61 // was deleted.
62 //
63 // WARNING:  The entry node of a method may not be simplified.
64 //
65 bool SimplifyCFG(Method::iterator &BBIt);
66
67 #endif