Add a flag to mark a dirty cache entry. This is not yet used, but will eventually
[oota-llvm.git] / include / llvm / Analysis / ConstantFolding.h
index 4e996f9d089525b367e5c8e2d9b466d3ce5cd0fa..9c19f111d16ef81d1403f565b527eebbe3405d91 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-using namespace llvm;
+#ifndef LLVM_ANALYSIS_CONSTANTFOLDING_H
+#define LLVM_ANALYSIS_CONSTANTFOLDING_H
 
 namespace llvm {
+  class Constant;
+  class ConstantExpr;
+  class Instruction;
+  class TargetData;
+  class Function;
 
+/// 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, const TargetData *TD = 0);
+
+/// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
+/// specified operands.  If successful, the constant result is returned, if not,
+/// null is returned.  Note that this function can fail when attempting to 
+/// fold instructions like loads and stores, which have no constant expression 
+/// form.
+///
+Constant *ConstantFoldInstOperands(
+  const Instruction *I, ///< The model instruction
+  Constant** Ops,       ///< The array of constant operands to use.
+  unsigned NumOps,      ///< The number of operands provided.
+  const TargetData *TD = 0 ///< Optional target information.
+);
+
+
+/// 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);
+  
 /// canConstantFoldCallTo - Return true if its even possible to fold a call to
 /// the specified function.
-extern
 bool canConstantFoldCallTo(Function *F);
 
-/// ConstantFoldFP - Given a function that evaluates the constant, return an
-///                  LLVM Constant that represents the evaluated constant
-extern Constant *
-ConstantFoldFP(double (*NativeFP)(double), double V, const Type *Ty);
-
 /// ConstantFoldCall - Attempt to constant fold a call to the specified function
 /// with the specified arguments, returning null if unsuccessful.
-extern Constant *
-ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands);
+Constant *
+ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands);
 }
 
+#endif