allow demotion to volatile values
[oota-llvm.git] / include / llvm / Transforms / Utils / Local.h
index fb26db6685648638ce8f34e0eafd4cb0a2d945b2..25183154272cfdafa82a76b8cf376b4f212c7773 100644 (file)
@@ -1,4 +1,11 @@
-//===-- Local.h - Functions to perform local transformations -----*- C++ -*--=//
+//===-- Local.h - Functions to perform local transformations ----*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
 //
 // This family of functions perform various local transformations to the
 // program.
 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
 
 #include "llvm/Function.h"
+
+namespace llvm {
+
 class Pass;
+class PHINode;
+class AllocaInst;
+class ConstantExpr;
 
 //===----------------------------------------------------------------------===//
-//  Local constant propogation...
+//  Local constant propagation...
 //
 
-/// doConstantPropogation - Constant prop a specific instruction.  Returns true
-/// and potentially moves the iterator if constant propogation was performed.
+/// doConstantPropagation - Constant prop a specific instruction.  Returns true
+/// and potentially moves the iterator if constant propagation was performed.
 ///
-bool doConstantPropogation(BasicBlock::iterator &I);
+bool doConstantPropagation(BasicBlock::iterator &I);
 
 /// ConstantFoldTerminator - If a terminator instruction is predicated on a
 /// constant value, convert it into an unconditional branch to the constant
@@ -27,6 +40,26 @@ bool doConstantPropogation(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);
+
+
+/// canConstantFoldCallTo - Return true if its even possible to fold a call to
+/// the specified function.
+bool canConstantFoldCallTo(Function *F);
+
+/// ConstantFoldCall - Attempt to constant fold a call to the specified function
+/// with the specified arguments, returning null if unsuccessful.
+Constant *ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands);
+
+/// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a
+/// getelementptr constantexpr, return the constant value being addressed by the
+/// constant expression, or null if something is funny and we can't decide.
+Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE);
 
 //===----------------------------------------------------------------------===//
 //  Local dead code elimination...
@@ -45,7 +78,6 @@ bool isInstructionTriviallyDead(Instruction *I);
 ///
 bool dceInstruction(BasicBlock::iterator &BBI);
 
-
 //===----------------------------------------------------------------------===//
 //  Control Flow Graph Restructuring...
 //
@@ -60,18 +92,14 @@ bool dceInstruction(BasicBlock::iterator &BBI);
 ///
 bool SimplifyCFG(BasicBlock *BB);
 
-
-/// isCriticalEdge - Return true if the specified edge is a critical edge.
-/// Critical edges are edges from a block with multiple successors to a block
-/// with multiple predecessors.
-///
+/// DemoteRegToStack - This function takes a virtual register computed by an
+/// Instruction 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.
 ///
-bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum);
+AllocaInst *DemoteRegToStack(Instruction &X, bool VolatileLoads = false);
 
-/// BreakCriticalEdge - Insert a new node node to split the critical edge.  This
-/// will update DominatorSet and DominatorTree information if it is available,
-/// thus calling this pass will not invalidate either of them.
-///
-void BreakCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0);
+} // End llvm namespace
 
 #endif