LICM shouldn't sink/delete debug information. Fix this and add a testcase.
[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     Constant *V,         ///< The source constant
33     const Type *DestTy   ///< The destination type
34   );
35   Constant *ConstantFoldSelectInstruction(LLVMContext &Context,
36                                           Constant *Cond,
37                                           Constant *V1, Constant *V2);
38   Constant *ConstantFoldExtractElementInstruction(LLVMContext &Context,
39                                                   Constant *Val,
40                                                   Constant *Idx);
41   Constant *ConstantFoldInsertElementInstruction(LLVMContext &Context,
42                                                  Constant *Val,
43                                                  Constant *Elt,
44                                                  Constant *Idx);
45   Constant *ConstantFoldShuffleVectorInstruction(LLVMContext &Context,
46                                                  Constant *V1,
47                                                  Constant *V2,
48                                                  Constant *Mask);
49   Constant *ConstantFoldExtractValueInstruction(LLVMContext &Context,
50                                                 Constant *Agg,
51                                                 const unsigned *Idxs,
52                                                 unsigned NumIdx);
53   Constant *ConstantFoldInsertValueInstruction(LLVMContext &Context,
54                                                Constant *Agg,
55                                                Constant *Val,
56                                                const unsigned *Idxs,
57                                                unsigned NumIdx);
58   Constant *ConstantFoldBinaryInstruction(LLVMContext &Context,
59                                           unsigned Opcode, Constant *V1,
60                                           Constant *V2);
61   Constant *ConstantFoldCompareInstruction(LLVMContext &Context,
62                                            unsigned short predicate, 
63                                            Constant *C1, Constant *C2);
64   Constant *ConstantFoldGetElementPtr(LLVMContext &Context, Constant *C,
65                                       bool inBounds,
66                                       Constant* const *Idxs, unsigned NumIdx);
67 } // End llvm namespace
68
69 #endif