1 //===-- ConstantFolding.h - Analyze constant folding possibilities --------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This family of functions determines the possibility of performing constant
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_ANALYSIS_CONSTANTFOLDING_H
16 #define LLVM_ANALYSIS_CONSTANTFOLDING_H
25 /// ConstantFoldInstruction - Attempt to constant fold the specified
26 /// instruction. If successful, the constant result is returned, if not, null
27 /// is returned. Note that this function can only fail when attempting to fold
28 /// instructions like loads and stores, which have no constant expression form.
30 Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0);
32 /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the
33 /// specified operands. If successful, the constant result is returned, if not,
34 /// null is returned. Note that this function can fail when attempting to
35 /// fold instructions like loads and stores, which have no constant expression
38 Constant *ConstantFoldInstOperands(
39 const Instruction *I, ///< The model instruction
40 Constant** Ops, ///< The array of constant operands to use.
41 unsigned NumOps, ///< The number of operands provided.
42 const TargetData *TD = 0 ///< Optional target information.
46 /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a
47 /// getelementptr constantexpr, return the constant value being addressed by the
48 /// constant expression, or null if something is funny and we can't decide.
49 Constant *ConstantFoldLoadThroughGEPConstantExpr(Constant *C, ConstantExpr *CE);
51 /// canConstantFoldCallTo - Return true if its even possible to fold a call to
52 /// the specified function.
53 bool canConstantFoldCallTo(Function *F);
55 /// ConstantFoldCall - Attempt to constant fold a call to the specified function
56 /// with the specified arguments, returning null if unsuccessful.
58 ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands);