convert LoopInfo.h and GraphWriter.h to use raw_ostream
[oota-llvm.git] / include / llvm / Analysis / ConstantFolding.h
index 4e996f9d089525b367e5c8e2d9b466d3ce5cd0fa..3e393ff6917cc4f84ce02954effc23cff01844b8 100644 (file)
@@ -2,8 +2,8 @@
 //
 //                     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 file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
 //
 //===----------------------------------------------------------------------===//
 //
 //
 //===----------------------------------------------------------------------===//
 
-#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;
+  class Type;
+  class LLVMContext;
 
+/// 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, LLVMContext &Context,
+                                  const TargetData *TD = 0);
+
+/// ConstantFoldConstantExpression - Attempt to fold the constant expression
+/// using the specified TargetData.  If successful, the constant result is
+/// result is returned, if not, null is returned.
+Constant *ConstantFoldConstantExpression(ConstantExpr *CE, LLVMContext &Context,
+                                         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(unsigned Opcode, const Type *DestTy,
+                                   Constant*const * Ops, unsigned NumOps,
+                                   LLVMContext &Context,
+                                   const TargetData *TD = 0);
+
+/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare
+/// instruction (icmp/fcmp) with the specified operands.  If it fails, it
+/// returns a constant expression of the specified operands.
+///
+Constant *ConstantFoldCompareInstOperands(unsigned Predicate,
+                                          Constant*const * Ops, unsigned NumOps,
+                                          LLVMContext &Context,
+                                          const TargetData *TD = 0);
+
+
+/// 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,
+                                                 LLVMContext &Context);
+  
 /// 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);
+bool canConstantFoldCallTo(const Function *F);
 
 /// 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* const* Operands, unsigned NumOperands);
 }
 
+#endif