Typo
[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 is distributed under the University of Illinois Open Source
6 // 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 they don't know how to perform
15 // the specified operation on the specified constant types.
16 //
17 //===----------------------------------------------------------------------===//
18
19 #ifndef CONSTANTFOLDING_H
20 #define CONSTANTFOLDING_H
21
22 namespace llvm {
23   class Value;
24   class Constant;
25   class Type;
26   class LLVMContext;
27
28   // Constant fold various types of instruction...
29   Constant *ConstantFoldCastInstruction(
30     LLVMContext &Context,
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(LLVMContext &Context,
36                                           const Constant *Cond,
37                                           const Constant *V1,
38                                           const Constant *V2);
39   Constant *ConstantFoldExtractElementInstruction(LLVMContext &Context,
40                                                   const Constant *Val,
41                                                   const Constant *Idx);
42   Constant *ConstantFoldInsertElementInstruction(LLVMContext &Context,
43                                                  const Constant *Val,
44                                                  const Constant *Elt,
45                                                  const Constant *Idx);
46   Constant *ConstantFoldShuffleVectorInstruction(LLVMContext &Context,
47                                                  const Constant *V1,
48                                                  const Constant *V2,
49                                                  const Constant *Mask);
50   Constant *ConstantFoldExtractValueInstruction(LLVMContext &Context,
51                                                 const Constant *Agg,
52                                                 const unsigned *Idxs,
53                                                 unsigned NumIdx);
54   Constant *ConstantFoldInsertValueInstruction(LLVMContext &Context,
55                                                const Constant *Agg,
56                                                const Constant *Val,
57                                                const unsigned* Idxs,
58                                                unsigned NumIdx);
59   Constant *ConstantFoldBinaryInstruction(LLVMContext &Context,
60                                           unsigned Opcode, const Constant *V1,
61                                           const Constant *V2);
62   Constant *ConstantFoldCompareInstruction(LLVMContext &Context,
63                                            unsigned short predicate, 
64                                            const Constant *C1, 
65                                            const Constant *C2);
66   Constant *ConstantFoldGetElementPtr(LLVMContext &Context, const Constant *C,
67                                       Constant* const *Idxs, unsigned NumIdx);
68 } // End llvm namespace
69
70 #endif