allow demotion to volatile values
[oota-llvm.git] / include / llvm / Transforms / Utils / Local.h
index 2f83174249c2937ed32a362400f0576f093017bf..25183154272cfdafa82a76b8cf376b4f212c7773 100644 (file)
@@ -1,10 +1,10 @@
 //===-- 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
@@ -20,6 +20,9 @@
 namespace llvm {
 
 class Pass;
+class PHINode;
+class AllocaInst;
+class ConstantExpr;
 
 //===----------------------------------------------------------------------===//
 //  Local constant propagation...
@@ -37,6 +40,26 @@ 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);
+
+
+/// 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...
@@ -55,7 +78,6 @@ bool isInstructionTriviallyDead(Instruction *I);
 ///
 bool dceInstruction(BasicBlock::iterator &BBI);
 
-
 //===----------------------------------------------------------------------===//
 //  Control Flow Graph Restructuring...
 //
@@ -70,6 +92,14 @@ bool dceInstruction(BasicBlock::iterator &BBI);
 ///
 bool SimplifyCFG(BasicBlock *BB);
 
+/// 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.
+///
+AllocaInst *DemoteRegToStack(Instruction &X, bool VolatileLoads = false);
+
 } // End llvm namespace
 
 #endif