Go to the documentation of this file.
16 #ifndef LLVM_IR_CONSTANTFOLDER_H
17 #define LLVM_IR_CONSTANTFOLDER_H
29 virtual void anchor();
41 bool HasNSW =
false)
const override {
42 auto *LC = dyn_cast<Constant>(
LHS);
43 auto *RC = dyn_cast<Constant>(
RHS);
50 auto *LC = dyn_cast<Constant>(
LHS);
51 auto *RC = dyn_cast<Constant>(
RHS);
58 auto *LC = dyn_cast<Constant>(
LHS);
59 auto *RC = dyn_cast<Constant>(
RHS);
66 auto *LC = dyn_cast<Constant>(
LHS);
67 auto *RC = dyn_cast<Constant>(
RHS);
74 bool IsInBounds =
false)
const override {
75 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
77 if (
any_of(IdxList, [](
Value *V) {
return !isa<Constant>(V); }))
89 auto *CC = dyn_cast<Constant>(
C);
90 auto *TC = dyn_cast<Constant>(True);
91 auto *
FC = dyn_cast<Constant>(False);
99 if (
auto *CAgg = dyn_cast<Constant>(Agg))
106 auto *CAgg = dyn_cast<Constant>(Agg);
107 auto *CVal = dyn_cast<Constant>(Val);
122 bool HasNUW =
false,
bool HasNSW =
false)
const override {
131 bool HasNUW =
false,
bool HasNSW =
false)
const override {
140 bool isExact =
false)
const override {
145 bool isExact =
false)
const override {
166 bool HasNUW =
false,
bool HasNSW =
false)
const override {
171 bool isExact =
false)
const override {
176 bool isExact =
false)
const override {
198 bool HasNUW =
false,
bool HasNSW =
false)
const override {
219 Type *DestTy)
const override {
228 Type *DestTy)
const override {
233 bool isSigned)
const override {
242 return CreateCast(Instruction::BitCast,
C, DestTy);
246 return CreateCast(Instruction::IntToPtr,
C, DestTy);
250 return CreateCast(Instruction::PtrToInt,
C, DestTy);
295 #endif // LLVM_IR_CONSTANTFOLDER_H
Constant * CreateExtractElement(Constant *Vec, Constant *Idx) const override
Constant * CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx) const override
This is an optimization pass for GlobalISel generic memory operations.
static Constant * getFDiv(Constant *C1, Constant *C2)
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Constant * CreateSExtOrBitCast(Constant *C, Type *DestTy) const override
static Constant * getNot(Constant *C)
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
static Constant * getFRem(Constant *C1, Constant *C2)
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
IRBuilderFolder - Interface for constant folding in IRBuilder.
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Constant * CreateAShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
The instances of the Type class are immutable: once they are created, they are never changed.
Constant * CreateFMul(Constant *LHS, Constant *RHS) const override
Constant * CreateShl(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Constant * CreateFNeg(Constant *C) const override
Constant * CreateSub(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Value * FoldAdd(Value *LHS, Value *RHS, bool HasNUW=false, bool HasNSW=false) const override
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Constant * CreateOr(Constant *LHS, Constant *RHS) const
Constant * CreateSRem(Constant *LHS, Constant *RHS) const override
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Value * FoldSelect(Value *C, Value *True, Value *False) const override
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Constant * CreateFRem(Constant *LHS, Constant *RHS) const override
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
ConstantFolder - Create constants with minimum, target independent, folding.
Constant * CreateSDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
Constant * CreateZExtOrBitCast(Constant *C, Type *DestTy) const override
(vector float) vec_cmpeq(*A, *B) C
Constant * CreateNeg(Constant *C, bool HasNUW=false, bool HasNSW=false) const override
Constant * CreateNot(Constant *C) const override
Constant * CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
static Constant * getXor(Constant *C1, Constant *C2)
static Constant * getURem(Constant *C1, Constant *C2)
Constant * CreateUDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
static Constant * getFNeg(Constant *C)
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Constant * CreatePtrToInt(Constant *C, Type *DestTy) const override
Value * FoldAnd(Value *LHS, Value *RHS) const override
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const override
This is an important base class in LLVM.
Constant * CreateFAdd(Constant *LHS, Constant *RHS) const override
Constant * CreateURem(Constant *LHS, Constant *RHS) const override
Constant * CreateBinOp(Instruction::BinaryOps Opc, Constant *LHS, Constant *RHS) const override
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getFSub(Constant *C1, Constant *C2)
Constant * CreatePointerCast(Constant *C, Type *DestTy) const override
static Constant * getOr(Constant *C1, Constant *C2)
Value * FoldOr(Value *LHS, Value *RHS) const override
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Constant * CreateMul(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Constant * CreateXor(Constant *LHS, Constant *RHS) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Constant * CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const override
Constant * CreateIntToPtr(Constant *C, Type *DestTy) const override
static Constant * getIntegerCast(Constant *C, Type *Ty, bool IsSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Constant * CreateShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask) const override
static Constant * getFMul(Constant *C1, Constant *C2)
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
Constant * CreateFSub(Constant *LHS, Constant *RHS) const override
Constant * CreateFPCast(Constant *C, Type *DestTy) const override
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override
static Constant * getAnd(Constant *C1, Constant *C2)
Constant * CreateBitCast(Constant *C, Type *DestTy) const override
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Constant * CreateTruncOrBitCast(Constant *C, Type *DestTy) const override
Constant * CreateLShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
Constant * CreateIntCast(Constant *C, Type *DestTy, bool isSigned) const override
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
static Constant * getSRem(Constant *C1, Constant *C2)
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Constant * CreateFDiv(Constant *LHS, Constant *RHS) const override
Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override
static Constant * getFAdd(Constant *C1, Constant *C2)
LLVM Value Representation.
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Constant * CreateCast(Instruction::CastOps Op, Constant *C, Type *DestTy) const override