Move DemoteRegToStack prototype out of DemoteRegToStack.h to this file.
[oota-llvm.git] / include / llvm / Transforms / Utils / Local.h
index 286aef993e00978c90c5932765c512753fcf9fbf..6df8da3de53510f738a82886b2f1cec0431284a1 100644 (file)
 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
 
 #include "llvm/Function.h"
+
+namespace llvm {
+
 class Pass;
+class PHINode;
+class AllocaInst;
 
 //===----------------------------------------------------------------------===//
 //  Local constant propagation...
@@ -34,6 +39,13 @@ bool doConstantPropagation(BasicBlock::iterator &I);
 ///
 bool ConstantFoldTerminator(BasicBlock *BB);
 
+/// ConstantFoldInstruction - Attempt to constant fold the specified
+/// instruction.  If successful, the constant result is returned, if not, null
+/// is returned.  Note that this function can only fail when attempting to fold
+/// instructions like loads and stores, which have no constant expression form.
+///
+Constant *ConstantFoldInstruction(Instruction *I);
+
 
 //===----------------------------------------------------------------------===//
 //  Local dead code elimination...
@@ -52,6 +64,15 @@ bool isInstructionTriviallyDead(Instruction *I);
 ///
 bool dceInstruction(BasicBlock::iterator &BBI);
 
+//===----------------------------------------------------------------------===//
+//  PHI Instruction Simplification
+//
+
+/// hasConstantValue - If the specified PHI node always merges together the same
+/// value, return the value, otherwise return null.
+///
+Value *hasConstantValue(PHINode *PN);
+
 
 //===----------------------------------------------------------------------===//
 //  Control Flow Graph Restructuring...
@@ -67,4 +88,14 @@ bool dceInstruction(BasicBlock::iterator &BBI);
 ///
 bool SimplifyCFG(BasicBlock *BB);
 
+/// DemoteRegToStack - This function takes a virtual register computed by an
+/// Instruction& X and replaces it with a slot in the stack frame, allocated via
+/// alloca.  This allows the CFG to be changed around without fear of
+/// invalidating the SSA information for the value.  It returns the pointer to
+/// the alloca inserted to create a stack slot for X.
+///
+AllocaInst *DemoteRegToStack(Instruction &X);
+
+} // End llvm namespace
+
 #endif