* Doxygenize API
[oota-llvm.git] / include / llvm / Transforms / Utils / Local.h
1 //===-- Local.h - Functions to perform local transformations -----*- C++ -*--=//
2 //
3 // This family of functions perform various local transformations to the
4 // program.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
9 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
10
11 #include "llvm/Function.h"
12 class Pass;
13
14 //===----------------------------------------------------------------------===//
15 //  Local constant propogation...
16 //
17
18 /// doConstantPropogation - Constant prop a specific instruction.  Returns true
19 /// and potentially moves the iterator if constant propogation was performed.
20 ///
21 bool doConstantPropogation(BasicBlock::iterator &I);
22
23 /// ConstantFoldTerminator - If a terminator instruction is predicated on a
24 /// constant value, convert it into an unconditional branch to the constant
25 /// destination.  This is a nontrivial operation because the successors of this
26 /// basic block must have their PHI nodes updated.
27 ///
28 bool ConstantFoldTerminator(BasicBlock *BB);
29
30
31 //===----------------------------------------------------------------------===//
32 //  Local dead code elimination...
33 //
34
35 /// isInstructionTriviallyDead - Return true if the result produced by the
36 /// instruction is not used, and the instruction has no side effects.
37 ///
38 bool isInstructionTriviallyDead(Instruction *I);
39
40
41 /// dceInstruction - Inspect the instruction at *BBI and figure out if it
42 /// isTriviallyDead.  If so, remove the instruction and update the iterator to
43 /// point to the instruction that immediately succeeded the original
44 /// instruction.
45 ///
46 bool dceInstruction(BasicBlock::iterator &BBI);
47
48
49 //===----------------------------------------------------------------------===//
50 //  Control Flow Graph Restructuring...
51 //
52
53 /// SimplifyCFG - This function is used to do simplification of a CFG.  For
54 /// example, it adjusts branches to branches to eliminate the extra hop, it
55 /// eliminates unreachable basic blocks, and does other "peephole" optimization
56 /// of the CFG.  It returns true if a modification was made, possibly deleting
57 /// the basic block that was pointed to.
58 ///
59 /// WARNING:  The entry node of a method may not be simplified.
60 ///
61 bool SimplifyCFG(BasicBlock *BB);
62
63
64 /// isCriticalEdge - Return true if the specified edge is a critical edge.
65 /// Critical edges are edges from a block with multiple successors to a block
66 /// with multiple predecessors.
67 ///
68 ///
69 bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum);
70
71 /// BreakCriticalEdge - Insert a new node node to split the critical edge.  This
72 /// will update DominatorSet and DominatorTree information if it is available,
73 /// thus calling this pass will not invalidate either of them.
74 ///
75 void BreakCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0);
76
77 #endif