Make this a *real* header:
[oota-llvm.git] / include / llvm / Analysis / ConstantFolding.h
1 //===-- ConstantFolding.h - Analyze constant folding possibilities --------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This family of functions determines the possibility of performing constant
11 // folding.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_ANALYSIS_CONSTANTFOLDING_H
16 #define LLVM_ANALYSIS_CONSTANTFOLDING_H
17
18 namespace llvm {
19   class Constant;
20   class ConstantExpr;
21   class Instruction;
22   class TargetData;
23   class Function;
24
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.
29 ///
30 Constant *ConstantFoldInstruction(Instruction *I, const TargetData *TD = 0);
31
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 
36 /// form.
37 ///
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.
43 );
44
45
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);
50   
51 /// canConstantFoldCallTo - Return true if its even possible to fold a call to
52 /// the specified function.
53 bool canConstantFoldCallTo(Function *F);
54
55 /// ConstantFoldCall - Attempt to constant fold a call to the specified function
56 /// with the specified arguments, returning null if unsuccessful.
57 Constant *
58 ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands);
59 }
60
61 #endif