1*9880d681SAndroid Build Coastguard Worker //===-- ConstantFolding.h - Internal Constant Folding Interface -*- C++ -*-===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file defines the (internal) constant folding interfaces for LLVM. These 11*9880d681SAndroid Build Coastguard Worker // interfaces are used by the ConstantExpr::get* methods to automatically fold 12*9880d681SAndroid Build Coastguard Worker // constants when possible. 13*9880d681SAndroid Build Coastguard Worker // 14*9880d681SAndroid Build Coastguard Worker // These operators may return a null object if they don't know how to perform 15*9880d681SAndroid Build Coastguard Worker // the specified operation on the specified constant types. 16*9880d681SAndroid Build Coastguard Worker // 17*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_IR_CONSTANTFOLD_H 20*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_IR_CONSTANTFOLD_H 21*9880d681SAndroid Build Coastguard Worker 22*9880d681SAndroid Build Coastguard Worker namespace llvm { 23*9880d681SAndroid Build Coastguard Worker template <typename T> class ArrayRef; 24*9880d681SAndroid Build Coastguard Worker class Value; 25*9880d681SAndroid Build Coastguard Worker class Constant; 26*9880d681SAndroid Build Coastguard Worker class Type; 27*9880d681SAndroid Build Coastguard Worker 28*9880d681SAndroid Build Coastguard Worker // Constant fold various types of instruction... 29*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldCastInstruction( 30*9880d681SAndroid Build Coastguard Worker unsigned opcode, ///< The opcode of the cast 31*9880d681SAndroid Build Coastguard Worker Constant *V, ///< The source constant 32*9880d681SAndroid Build Coastguard Worker Type *DestTy ///< The destination type 33*9880d681SAndroid Build Coastguard Worker ); 34*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldSelectInstruction(Constant *Cond, 35*9880d681SAndroid Build Coastguard Worker Constant *V1, Constant *V2); 36*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldExtractElementInstruction(Constant *Val, Constant *Idx); 37*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldInsertElementInstruction(Constant *Val, Constant *Elt, 38*9880d681SAndroid Build Coastguard Worker Constant *Idx); 39*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldShuffleVectorInstruction(Constant *V1, Constant *V2, 40*9880d681SAndroid Build Coastguard Worker Constant *Mask); 41*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldExtractValueInstruction(Constant *Agg, 42*9880d681SAndroid Build Coastguard Worker ArrayRef<unsigned> Idxs); 43*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, 44*9880d681SAndroid Build Coastguard Worker ArrayRef<unsigned> Idxs); 45*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldBinaryInstruction(unsigned Opcode, Constant *V1, 46*9880d681SAndroid Build Coastguard Worker Constant *V2); 47*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldCompareInstruction(unsigned short predicate, 48*9880d681SAndroid Build Coastguard Worker Constant *C1, Constant *C2); 49*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool inBounds, 50*9880d681SAndroid Build Coastguard Worker ArrayRef<Constant *> Idxs); 51*9880d681SAndroid Build Coastguard Worker Constant *ConstantFoldGetElementPtr(Type *Ty, Constant *C, bool inBounds, 52*9880d681SAndroid Build Coastguard Worker ArrayRef<Value *> Idxs); 53*9880d681SAndroid Build Coastguard Worker } // End llvm namespace 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker #endif 56