1249259Sdim//===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===//
2249259Sdim//
3249259Sdim//                     The LLVM Compiler Infrastructure
4249259Sdim//
5249259Sdim// This file is distributed under the University of Illinois Open Source
6249259Sdim// License. See LICENSE.TXT for details.
7249259Sdim//
8249259Sdim//===----------------------------------------------------------------------===//
9249259Sdim//
10249259Sdim// This file defines the (internal) constant folding interfaces for LLVM.  These
11249259Sdim// interfaces are used by the ConstantExpr::get* methods to automatically fold
12249259Sdim// constants when possible.
13249259Sdim//
14249259Sdim// These operators may return a null object if they don't know how to perform
15249259Sdim// the specified operation on the specified constant types.
16249259Sdim//
17249259Sdim//===----------------------------------------------------------------------===//
18249259Sdim
19249259Sdim#ifndef CONSTANTFOLDING_H
20249259Sdim#define CONSTANTFOLDING_H
21249259Sdim
22249259Sdim#include "llvm/ADT/ArrayRef.h"
23249259Sdim
24249259Sdimnamespace llvm {
25249259Sdim  class Value;
26249259Sdim  class Constant;
27249259Sdim  class Type;
28249259Sdim
29249259Sdim  // Constant fold various types of instruction...
30249259Sdim  Constant *ConstantFoldCastInstruction(
31249259Sdim    unsigned opcode,     ///< The opcode of the cast
32249259Sdim    Constant *V,         ///< The source constant
33249259Sdim    Type *DestTy   ///< The destination type
34249259Sdim  );
35249259Sdim  Constant *ConstantFoldSelectInstruction(Constant *Cond,
36249259Sdim                                          Constant *V1, Constant *V2);
37249259Sdim  Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx);
38249259Sdim  Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt,
39249259Sdim                                                 Constant *Idx);
40249259Sdim  Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2,
41249259Sdim                                                 Constant *Mask);
42249259Sdim  Constant *ConstantFoldExtractValueInstruction(Constant *Agg,
43249259Sdim                                                ArrayRef<unsigned> Idxs);
44249259Sdim  Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val,
45249259Sdim                                               ArrayRef<unsigned> Idxs);
46249259Sdim  Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1,
47249259Sdim                                          Constant *V2);
48249259Sdim  Constant *ConstantFoldCompareInstruction(unsigned short predicate,
49249259Sdim                                           Constant *C1, Constant *C2);
50249259Sdim  Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds,
51249259Sdim                                      ArrayRef<Constant *> Idxs);
52249259Sdim  Constant *ConstantFoldGetElementPtr(Constant *C, bool inBounds,
53249259Sdim                                      ArrayRef<Value *> Idxs);
54249259Sdim} // End llvm namespace
55249259Sdim
56249259Sdim#endif
57