Update GEP constructors to use an iterator interface to fix
[oota-llvm.git] / lib / VMCore / ConstantFold.h
1 //===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===//
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 file defines the (internal) constant folding interfaces for LLVM.  These
11 // interfaces are used by the ConstantExpr::get* methods to automatically fold
12 // constants when possible.
13 //
14 // These operators may return a null object if I don't know how to perform the
15 // specified operation on the specified constant types.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef CONSTANTFOLDING_H
20 #define CONSTANTFOLDING_H
21
22 #include <iterator>
23
24 namespace llvm {
25   class Value;
26   class Constant;
27   class Type;
28
29   // Constant fold various types of instruction...
30   Constant *ConstantFoldCastInstruction(
31     unsigned opcode,     ///< The opcode of the cast
32     const Constant *V,   ///< The source constant
33     const Type *DestTy   ///< The destination type
34   );
35   Constant *ConstantFoldSelectInstruction(const Constant *Cond,
36                                           const Constant *V1,
37                                           const Constant *V2);
38   Constant *ConstantFoldExtractElementInstruction(const Constant *Val,
39                                                   const Constant *Idx);
40   Constant *ConstantFoldInsertElementInstruction(const Constant *Val,
41                                                  const Constant *Elt,
42                                                  const Constant *Idx);
43   Constant *ConstantFoldShuffleVectorInstruction(const Constant *V1,
44                                                  const Constant *V2,
45                                                  const Constant *Mask);
46   Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
47                                           const Constant *V2);
48   Constant *ConstantFoldCompareInstruction(unsigned short predicate, 
49                                            const Constant *C1, 
50                                            const Constant *C2);
51
52   Constant *ConstantFoldGetElementPtr(const Constant *C,
53                                       Constant* const *Idxs, unsigned NumIdx);
54 } // End llvm namespace
55
56 #endif