allow demotion to volatile values
[oota-llvm.git] / include / llvm / Transforms / Utils / Local.h
index 86cabec79589546604ac97be3ed554ade77bb413..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.
@@ -9,7 +16,13 @@
 #define LLVM_TRANSFORMS_UTILS_LOCAL_H
 
 #include "llvm/Function.h"
+
+namespace llvm {
+
 class Pass;
+class PHINode;
+class AllocaInst;
+class ConstantExpr;
 
 //===----------------------------------------------------------------------===//
 //  Local constant propagation...
@@ -27,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...
@@ -45,7 +78,6 @@ bool isInstructionTriviallyDead(Instruction *I);
 ///
 bool dceInstruction(BasicBlock::iterator &BBI);
 
-
 //===----------------------------------------------------------------------===//
 //  Control Flow Graph Restructuring...
 //
@@ -60,4 +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