~ubuntu-branches/ubuntu/feisty/clamav/feisty

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/Transforms/Utils/Local.h

  • Committer: Bazaar Package Importer
  • Author(s): Kees Cook
  • Date: 2007-02-20 10:33:44 UTC
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20070220103344-zgcu2psnx9d98fpa
Tags: upstream-0.90
ImportĀ upstreamĀ versionĀ 0.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//===-- Local.h - Functions to perform local transformations ----*- C++ -*-===//
2
 
//
3
 
//                     The LLVM Compiler Infrastructure
4
 
//
5
 
// This file is distributed under the University of Illinois Open Source
6
 
// License. See LICENSE.TXT for details.
7
 
//
8
 
//===----------------------------------------------------------------------===//
9
 
//
10
 
// This family of functions perform various local transformations to the
11
 
// program.
12
 
//
13
 
//===----------------------------------------------------------------------===//
14
 
 
15
 
#ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H
16
 
#define LLVM_TRANSFORMS_UTILS_LOCAL_H
17
 
 
18
 
namespace llvm {
19
 
 
20
 
class User;
21
 
class BasicBlock;
22
 
class BranchInst;
23
 
class Instruction;
24
 
class Value;
25
 
class Pass;
26
 
class PHINode;
27
 
class AllocaInst;
28
 
class ConstantExpr;
29
 
class TargetData;
30
 
 
31
 
template<typename T> class SmallVectorImpl;
32
 
  
33
 
//===----------------------------------------------------------------------===//
34
 
//  Local constant propagation.
35
 
//
36
 
 
37
 
/// ConstantFoldTerminator - If a terminator instruction is predicated on a
38
 
/// constant value, convert it into an unconditional branch to the constant
39
 
/// destination.  This is a nontrivial operation because the successors of this
40
 
/// basic block must have their PHI nodes updated.
41
 
///
42
 
bool ConstantFoldTerminator(BasicBlock *BB);
43
 
 
44
 
//===----------------------------------------------------------------------===//
45
 
//  Local dead code elimination.
46
 
//
47
 
 
48
 
/// isInstructionTriviallyDead - Return true if the result produced by the
49
 
/// instruction is not used, and the instruction has no side effects.
50
 
///
51
 
bool isInstructionTriviallyDead(Instruction *I);
52
 
 
53
 
/// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a
54
 
/// trivially dead instruction, delete it.  If that makes any of its operands
55
 
/// trivially dead, delete them too, recursively.  Return true if any
56
 
/// instructions were deleted.
57
 
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V);
58
 
 
59
 
/// RecursivelyDeleteDeadPHINode - If the specified value is an effectively
60
 
/// dead PHI node, due to being a def-use chain of single-use nodes that
61
 
/// either forms a cycle or is terminated by a trivially dead instruction,
62
 
/// delete it.  If that makes any of its operands trivially dead, delete them
63
 
/// too, recursively.  Return true if the PHI node is actually deleted.
64
 
bool RecursivelyDeleteDeadPHINode(PHINode *PN);
65
 
 
66
 
  
67
 
/// SimplifyInstructionsInBlock - Scan the specified basic block and try to
68
 
/// simplify any instructions in it and recursively delete dead instructions.
69
 
///
70
 
/// This returns true if it changed the code, note that it can delete
71
 
/// instructions in other blocks as well in this block.
72
 
bool SimplifyInstructionsInBlock(BasicBlock *BB, const TargetData *TD = 0);
73
 
    
74
 
//===----------------------------------------------------------------------===//
75
 
//  Control Flow Graph Restructuring.
76
 
//
77
 
 
78
 
/// RemovePredecessorAndSimplify - Like BasicBlock::removePredecessor, this
79
 
/// method is called when we're about to delete Pred as a predecessor of BB.  If
80
 
/// BB contains any PHI nodes, this drops the entries in the PHI nodes for Pred.
81
 
///
82
 
/// Unlike the removePredecessor method, this attempts to simplify uses of PHI
83
 
/// nodes that collapse into identity values.  For example, if we have:
84
 
///   x = phi(1, 0, 0, 0)
85
 
///   y = and x, z
86
 
///
87
 
/// .. and delete the predecessor corresponding to the '1', this will attempt to
88
 
/// recursively fold the 'and' to 0.
89
 
void RemovePredecessorAndSimplify(BasicBlock *BB, BasicBlock *Pred,
90
 
                                  TargetData *TD = 0);
91
 
    
92
 
  
93
 
/// MergeBasicBlockIntoOnlyPred - BB is a block with one predecessor and its
94
 
/// predecessor is known to have one successor (BB!).  Eliminate the edge
95
 
/// between them, moving the instructions in the predecessor into BB.  This
96
 
/// deletes the predecessor block.
97
 
///
98
 
void MergeBasicBlockIntoOnlyPred(BasicBlock *BB, Pass *P = 0);
99
 
    
100
 
 
101
 
/// TryToSimplifyUncondBranchFromEmptyBlock - BB is known to contain an
102
 
/// unconditional branch, and contains no instructions other than PHI nodes,
103
 
/// potential debug intrinsics and the branch.  If possible, eliminate BB by
104
 
/// rewriting all the predecessors to branch to the successor block and return
105
 
/// true.  If we can't transform, return false.
106
 
bool TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB);
107
 
 
108
 
/// EliminateDuplicatePHINodes - Check for and eliminate duplicate PHI
109
 
/// nodes in this block. This doesn't try to be clever about PHI nodes
110
 
/// which differ only in the order of the incoming values, but instcombine
111
 
/// orders them so it usually won't matter.
112
 
///
113
 
bool EliminateDuplicatePHINodes(BasicBlock *BB);
114
 
 
115
 
/// SimplifyCFG - This function is used to do simplification of a CFG.  For
116
 
/// example, it adjusts branches to branches to eliminate the extra hop, it
117
 
/// eliminates unreachable basic blocks, and does other "peephole" optimization
118
 
/// of the CFG.  It returns true if a modification was made, possibly deleting
119
 
/// the basic block that was pointed to.
120
 
///
121
 
bool SimplifyCFG(BasicBlock *BB, const TargetData *TD = 0);
122
 
 
123
 
/// FoldBranchToCommonDest - If this basic block is ONLY a setcc and a branch,
124
 
/// and if a predecessor branches to us and one of our successors, fold the
125
 
/// setcc into the predecessor and use logical operations to pick the right
126
 
/// destination.
127
 
bool FoldBranchToCommonDest(BranchInst *BI);
128
 
 
129
 
/// DemoteRegToStack - This function takes a virtual register computed by an
130
 
/// Instruction and replaces it with a slot in the stack frame, allocated via
131
 
/// alloca.  This allows the CFG to be changed around without fear of
132
 
/// invalidating the SSA information for the value.  It returns the pointer to
133
 
/// the alloca inserted to create a stack slot for X.
134
 
///
135
 
AllocaInst *DemoteRegToStack(Instruction &X,
136
 
                             bool VolatileLoads = false,
137
 
                             Instruction *AllocaPoint = 0);
138
 
 
139
 
/// DemotePHIToStack - This function takes a virtual register computed by a phi
140
 
/// node and replaces it with a slot in the stack frame, allocated via alloca.
141
 
/// The phi node is deleted and it returns the pointer to the alloca inserted. 
142
 
AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = 0);
143
 
 
144
 
} // End llvm namespace
145
 
 
146
 
#endif