LLVM API Documentation
00001 //===-- Local.h - Functions to perform local transformations ----*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This family of functions perform various local transformations to the 00011 // program. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_TRANSFORMS_UTILS_LOCAL_H 00016 #define LLVM_TRANSFORMS_UTILS_LOCAL_H 00017 00018 namespace llvm { 00019 00020 class BasicBlock; 00021 class Instruction; 00022 class Value; 00023 class Pass; 00024 class PHINode; 00025 class AllocaInst; 00026 class ConstantExpr; 00027 class TargetData; 00028 00029 template<typename T> class SmallVectorImpl; 00030 00031 //===----------------------------------------------------------------------===// 00032 // Local constant propagation. 00033 // 00034 00035 /// ConstantFoldTerminator - If a terminator instruction is predicated on a 00036 /// constant value, convert it into an unconditional branch to the constant 00037 /// destination. This is a nontrivial operation because the successors of this 00038 /// basic block must have their PHI nodes updated. 00039 /// 00040 bool ConstantFoldTerminator(BasicBlock *BB); 00041 00042 //===----------------------------------------------------------------------===// 00043 // Local dead code elimination. 00044 // 00045 00046 /// isInstructionTriviallyDead - Return true if the result produced by the 00047 /// instruction is not used, and the instruction has no side effects. 00048 /// 00049 bool isInstructionTriviallyDead(Instruction *I); 00050 00051 00052 /// RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a 00053 /// trivially dead instruction, delete it. If that makes any of its operands 00054 /// trivially dead, delete them too, recursively. 00055 /// 00056 /// If DeadInst is specified, the vector is filled with the instructions that 00057 /// are actually deleted. 00058 void RecursivelyDeleteTriviallyDeadInstructions(Value *V, 00059 SmallVectorImpl<Instruction*> *DeadInst = 0); 00060 00061 //===----------------------------------------------------------------------===// 00062 // Control Flow Graph Restructuring. 00063 // 00064 00065 /// MergeBasicBlockIntoOnlyPred - BB is a block with one predecessor and its 00066 /// predecessor is known to have one successor (BB!). Eliminate the edge 00067 /// between them, moving the instructions in the predecessor into BB. This 00068 /// deletes the predecessor block. 00069 /// 00070 void MergeBasicBlockIntoOnlyPred(BasicBlock *BB); 00071 00072 00073 /// SimplifyCFG - This function is used to do simplification of a CFG. For 00074 /// example, it adjusts branches to branches to eliminate the extra hop, it 00075 /// eliminates unreachable basic blocks, and does other "peephole" optimization 00076 /// of the CFG. It returns true if a modification was made, possibly deleting 00077 /// the basic block that was pointed to. 00078 /// 00079 /// WARNING: The entry node of a method may not be simplified. 00080 /// 00081 bool SimplifyCFG(BasicBlock *BB); 00082 00083 /// DemoteRegToStack - This function takes a virtual register computed by an 00084 /// Instruction and replaces it with a slot in the stack frame, allocated via 00085 /// alloca. This allows the CFG to be changed around without fear of 00086 /// invalidating the SSA information for the value. It returns the pointer to 00087 /// the alloca inserted to create a stack slot for X. 00088 /// 00089 AllocaInst *DemoteRegToStack(Instruction &X, bool VolatileLoads = false, 00090 Instruction *AllocaPoint = 0); 00091 00092 /// DemotePHIToStack - This function takes a virtual register computed by a phi 00093 /// node and replaces it with a slot in the stack frame, allocated via alloca. 00094 /// The phi node is deleted and it returns the pointer to the alloca inserted. 00095 AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = 0); 00096 00097 } // End llvm namespace 00098 00099 #endif