LLVM  14.0.0git
TargetFolder.h
Go to the documentation of this file.
1 //====- TargetFolder.h - Constant folding helper ---------------*- C++ -*-====//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the TargetFolder class, a helper for IRBuilder.
10 // It provides IRBuilder with a set of methods for creating constants with
11 // target dependent folding, in addition to the same target-independent
12 // folding that the ConstantFolder class provides. For general constant
13 // creation and folding, use ConstantExpr and the routines in
14 // llvm/Analysis/ConstantFolding.h.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_ANALYSIS_TARGETFOLDER_H
19 #define LLVM_ANALYSIS_TARGETFOLDER_H
20 
21 #include "llvm/ADT/ArrayRef.h"
23 #include "llvm/IR/Constants.h"
24 #include "llvm/IR/InstrTypes.h"
26 
27 namespace llvm {
28 
29 class DataLayout;
30 
31 /// TargetFolder - Create constants with target dependent folding.
32 class TargetFolder final : public IRBuilderFolder {
33  const DataLayout &DL;
34 
35  /// Fold - Fold the constant using target specific information.
36  Constant *Fold(Constant *C) const {
37  return ConstantFoldConstant(C, DL);
38  }
39 
40  virtual void anchor();
41 
42 public:
43  explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
44 
45  //===--------------------------------------------------------------------===//
46  // Value-based folders.
47  //
48  // Return an existing value or a constant if the operation can be simplified.
49  // Otherwise return nullptr.
50  //===--------------------------------------------------------------------===//
51  Value *FoldAdd(Value *LHS, Value *RHS, bool HasNUW = false,
52  bool HasNSW = false) const override {
53  auto *LC = dyn_cast<Constant>(LHS);
54  auto *RC = dyn_cast<Constant>(RHS);
55  if (LC && RC)
56  return Fold(ConstantExpr::getAdd(LC, RC, HasNUW, HasNSW));
57  return nullptr;
58  }
59 
60  Value *FoldAnd(Value *LHS, Value *RHS) const override {
61  auto *LC = dyn_cast<Constant>(LHS);
62  auto *RC = dyn_cast<Constant>(RHS);
63  if (LC && RC)
64  return Fold(ConstantExpr::getAnd(LC, RC));
65  return nullptr;
66  }
67 
68  Value *FoldOr(Value *LHS, Value *RHS) const override {
69  auto *LC = dyn_cast<Constant>(LHS);
70  auto *RC = dyn_cast<Constant>(RHS);
71  if (LC && RC)
72  return Fold(ConstantExpr::getOr(LC, RC));
73  return nullptr;
74  }
75 
77  auto *LC = dyn_cast<Constant>(LHS);
78  auto *RC = dyn_cast<Constant>(RHS);
79  if (LC && RC)
80  return ConstantExpr::getCompare(P, LC, RC);
81  return nullptr;
82  }
83 
84  Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
85  bool IsInBounds = false) const override {
86  if (auto *PC = dyn_cast<Constant>(Ptr)) {
87  // Every index must be constant.
88  if (any_of(IdxList, [](Value *V) { return !isa<Constant>(V); }))
89  return nullptr;
90  if (IsInBounds)
91  return Fold(ConstantExpr::getInBoundsGetElementPtr(Ty, PC, IdxList));
92  else
93  return Fold(ConstantExpr::getGetElementPtr(Ty, PC, IdxList));
94  }
95  return nullptr;
96  }
97 
98  Value *FoldSelect(Value *C, Value *True, Value *False) const override {
99  auto *CC = dyn_cast<Constant>(C);
100  auto *TC = dyn_cast<Constant>(True);
101  auto *FC = dyn_cast<Constant>(False);
102  if (CC && TC && FC)
103  return Fold(ConstantExpr::getSelect(CC, TC, FC));
104 
105  return nullptr;
106  }
107 
108  //===--------------------------------------------------------------------===//
109  // Binary Operators
110  //===--------------------------------------------------------------------===//
111 
112  Constant *CreateFAdd(Constant *LHS, Constant *RHS) const override {
113  return Fold(ConstantExpr::getFAdd(LHS, RHS));
114  }
116  bool HasNUW = false, bool HasNSW = false) const override {
117  return Fold(ConstantExpr::getSub(LHS, RHS, HasNUW, HasNSW));
118  }
119  Constant *CreateFSub(Constant *LHS, Constant *RHS) const override {
120  return Fold(ConstantExpr::getFSub(LHS, RHS));
121  }
123  bool HasNUW = false, bool HasNSW = false) const override {
124  return Fold(ConstantExpr::getMul(LHS, RHS, HasNUW, HasNSW));
125  }
126  Constant *CreateFMul(Constant *LHS, Constant *RHS) const override {
127  return Fold(ConstantExpr::getFMul(LHS, RHS));
128  }
130  bool isExact = false) const override {
131  return Fold(ConstantExpr::getUDiv(LHS, RHS, isExact));
132  }
134  bool isExact = false) const override {
135  return Fold(ConstantExpr::getSDiv(LHS, RHS, isExact));
136  }
137  Constant *CreateFDiv(Constant *LHS, Constant *RHS) const override {
138  return Fold(ConstantExpr::getFDiv(LHS, RHS));
139  }
140  Constant *CreateURem(Constant *LHS, Constant *RHS) const override {
141  return Fold(ConstantExpr::getURem(LHS, RHS));
142  }
143  Constant *CreateSRem(Constant *LHS, Constant *RHS) const override {
144  return Fold(ConstantExpr::getSRem(LHS, RHS));
145  }
146  Constant *CreateFRem(Constant *LHS, Constant *RHS) const override {
147  return Fold(ConstantExpr::getFRem(LHS, RHS));
148  }
150  bool HasNUW = false, bool HasNSW = false) const override {
151  return Fold(ConstantExpr::getShl(LHS, RHS, HasNUW, HasNSW));
152  }
154  bool isExact = false) const override {
155  return Fold(ConstantExpr::getLShr(LHS, RHS, isExact));
156  }
158  bool isExact = false) const override {
159  return Fold(ConstantExpr::getAShr(LHS, RHS, isExact));
160  }
161  Constant *CreateXor(Constant *LHS, Constant *RHS) const override {
162  return Fold(ConstantExpr::getXor(LHS, RHS));
163  }
164 
166  Constant *LHS, Constant *RHS) const override {
167  return Fold(ConstantExpr::get(Opc, LHS, RHS));
168  }
169 
170  //===--------------------------------------------------------------------===//
171  // Unary Operators
172  //===--------------------------------------------------------------------===//
173 
175  bool HasNUW = false, bool HasNSW = false) const override {
176  return Fold(ConstantExpr::getNeg(C, HasNUW, HasNSW));
177  }
178  Constant *CreateFNeg(Constant *C) const override {
179  return Fold(ConstantExpr::getFNeg(C));
180  }
181  Constant *CreateNot(Constant *C) const override {
182  return Fold(ConstantExpr::getNot(C));
183  }
184 
186  return Fold(ConstantExpr::get(Opc, C));
187  }
188 
189  //===--------------------------------------------------------------------===//
190  // Cast/Conversion Operators
191  //===--------------------------------------------------------------------===//
192 
194  Type *DestTy) const override {
195  if (C->getType() == DestTy)
196  return C; // avoid calling Fold
197  return Fold(ConstantExpr::getCast(Op, C, DestTy));
198  }
200  bool isSigned) const override {
201  if (C->getType() == DestTy)
202  return C; // avoid calling Fold
203  return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned));
204  }
205  Constant *CreatePointerCast(Constant *C, Type *DestTy) const override {
206  if (C->getType() == DestTy)
207  return C; // avoid calling Fold
208  return Fold(ConstantExpr::getPointerCast(C, DestTy));
209  }
210  Constant *CreateFPCast(Constant *C, Type *DestTy) const override {
211  if (C->getType() == DestTy)
212  return C; // avoid calling Fold
213  return Fold(ConstantExpr::getFPCast(C, DestTy));
214  }
215  Constant *CreateBitCast(Constant *C, Type *DestTy) const override {
216  return CreateCast(Instruction::BitCast, C, DestTy);
217  }
218  Constant *CreateIntToPtr(Constant *C, Type *DestTy) const override {
219  return CreateCast(Instruction::IntToPtr, C, DestTy);
220  }
221  Constant *CreatePtrToInt(Constant *C, Type *DestTy) const override {
222  return CreateCast(Instruction::PtrToInt, C, DestTy);
223  }
224  Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const override {
225  if (C->getType() == DestTy)
226  return C; // avoid calling Fold
227  return Fold(ConstantExpr::getZExtOrBitCast(C, DestTy));
228  }
229  Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const override {
230  if (C->getType() == DestTy)
231  return C; // avoid calling Fold
232  return Fold(ConstantExpr::getSExtOrBitCast(C, DestTy));
233  }
234  Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const override {
235  if (C->getType() == DestTy)
236  return C; // avoid calling Fold
237  return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy));
238  }
239 
241  Type *DestTy) const override {
242  if (C->getType() == DestTy)
243  return C; // avoid calling Fold
245  }
246 
247  //===--------------------------------------------------------------------===//
248  // Compare Instructions
249  //===--------------------------------------------------------------------===//
250 
252  Constant *RHS) const override {
253  return Fold(ConstantExpr::getCompare(P, LHS, RHS));
254  }
255 
256  //===--------------------------------------------------------------------===//
257  // Other Instructions
258  //===--------------------------------------------------------------------===//
259 
260  Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const override {
261  return Fold(ConstantExpr::getExtractElement(Vec, Idx));
262  }
263 
265  Constant *Idx) const override {
266  return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
267  }
268 
270  ArrayRef<int> Mask) const override {
271  return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
272  }
273 
275  ArrayRef<unsigned> IdxList) const override {
276  return Fold(ConstantExpr::getExtractValue(Agg, IdxList));
277  }
278 
280  ArrayRef<unsigned> IdxList) const override {
281  return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList));
282  }
283 };
284 
285 }
286 
287 #endif
llvm::TargetFolder::FoldAnd
Value * FoldAnd(Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:60
llvm::TargetFolder::CreateFSub
Constant * CreateFSub(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:119
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:22
llvm::ConstantExpr::getFDiv
static Constant * getFDiv(Constant *C1, Constant *C2)
Definition: Constants.cpp:2753
llvm::ConstantExpr::getExtractElement
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2572
llvm::ConstantExpr::getNot
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2704
llvm::ConstantExpr::getZExtOrBitCast
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2047
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:113
llvm::Instruction::UnaryOps
UnaryOps
Definition: Instruction.h:782
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:721
llvm::TargetFolder::FoldGEP
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const override
Definition: TargetFolder.h:84
llvm::TargetFolder::FoldICmp
Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:76
P
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
Definition: README-SSE.txt:411
llvm::ConstantExpr::getFRem
static Constant * getFRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2765
llvm::TargetFolder::CreateFRem
Constant * CreateFRem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:146
llvm::ConstantExpr::getFPCast
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
Definition: Constants.cpp:2103
llvm::IRBuilderFolder
IRBuilderFolder - Interface for constant folding in IRBuilder.
Definition: IRBuilderFolder.h:24
llvm::TargetFolder::CreateFCmp
Constant * CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:251
llvm::TargetFolder::CreatePtrToInt
Constant * CreatePtrToInt(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:221
R600_InstFlag::FC
@ FC
Definition: R600Defines.h:32
llvm::TargetFolder::CreateXor
Constant * CreateXor(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:161
llvm::ConstantExpr::getSelect
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
Definition: Constants.cpp:2440
llvm::ConstantExpr::getInsertValue
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2643
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::TargetFolder::CreateSDiv
Constant * CreateSDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:133
llvm::TargetFolder::CreateMul
Constant * CreateMul(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:122
llvm::TargetFolder::CreateInsertValue
Constant * CreateInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > IdxList) const override
Definition: TargetFolder.h:279
llvm::ConstantExpr::getInBoundsGetElementPtr
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1265
RHS
Value * RHS
Definition: X86PartialReduction.cpp:74
llvm::BitmaskEnumDetail::Mask
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.
Definition: BitmaskEnum.h:80
ConstantFolding.h
llvm::TargetFolder::CreateNot
Constant * CreateNot(Constant *C) const override
Definition: TargetFolder.h:181
llvm::TargetFolder::CreateFAdd
Constant * CreateFAdd(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:112
llvm::ConstantExpr::getPointerCast
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2065
llvm::ConstantExpr::getSub
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2721
LHS
Value * LHS
Definition: X86PartialReduction.cpp:73
Constants.h
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::TargetFolder::CreateLShr
Constant * CreateLShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:153
InstrTypes.h
llvm::ConstantExpr::getUDiv
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2743
llvm::Instruction::CastOps
CastOps
Definition: Instruction.h:803
llvm::TargetFolder::CreateExtractValue
Constant * CreateExtractValue(Constant *Agg, ArrayRef< unsigned > IdxList) const override
Definition: TargetFolder.h:274
llvm::ConstantExpr::getXor
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2777
llvm::ConstantExpr::getURem
static Constant * getURem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2757
llvm::TargetFolder::CreateExtractElement
Constant * CreateExtractElement(Constant *Vec, Constant *Idx) const override
Definition: TargetFolder.h:260
llvm::TargetFolder::CreatePointerCast
Constant * CreatePointerCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:205
llvm::ConstantExpr::getFNeg
static Constant * getFNeg(Constant *C)
Definition: Constants.cpp:2698
llvm::TargetFolder::CreateNeg
Constant * CreateNeg(Constant *C, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:174
llvm::ConstantExpr::getAShr
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2798
llvm::TargetFolder::CreateBitCast
Constant * CreateBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:215
llvm::ConstantExpr::getShuffleVector
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2617
llvm::ConstantExpr::getCompare
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
Definition: Constants.cpp:2418
llvm::TargetFolder::CreateFPCast
Constant * CreateFPCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:210
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::ConstantExpr::get
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.
Definition: Constants.cpp:2287
llvm::TargetFolder::CreateUDiv
Constant * CreateUDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:129
llvm::ConstantExpr::getShl
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2786
llvm::ConstantExpr::getFSub
static Constant * getFSub(Constant *C1, Constant *C2)
Definition: Constants.cpp:2728
llvm::ConstantExpr::getOr
static Constant * getOr(Constant *C1, Constant *C2)
Definition: Constants.cpp:2773
ArrayRef.h
IRBuilderFolder.h
llvm::TargetFolder::CreateUnOp
Constant * CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override
Definition: TargetFolder.h:185
llvm::TargetFolder::FoldSelect
Value * FoldSelect(Value *C, Value *True, Value *False) const override
Definition: TargetFolder.h:98
llvm::ConstantExpr::getCast
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
Definition: Constants.cpp:2008
llvm::ConstantExpr::getTruncOrBitCast
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2059
llvm::TargetFolder::CreateSRem
Constant * CreateSRem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:143
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::any_of
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1599
llvm::TargetFolder::CreatePointerBitCastOrAddrSpaceCast
Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:240
llvm::TargetFolder::FoldAdd
Value * FoldAdd(Value *LHS, Value *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:51
llvm::ConstantExpr::getSExtOrBitCast
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2053
llvm::TargetFolder::CreateIntCast
Constant * CreateIntCast(Constant *C, Type *DestTy, bool isSigned) const override
Definition: TargetFolder.h:199
llvm::TargetFolder::CreateZExtOrBitCast
Constant * CreateZExtOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:224
llvm::TargetFolder::CreateFMul
Constant * CreateFMul(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:126
llvm::ConstantExpr::getInsertElement
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2594
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::ConstantExpr::getIntegerCast
static Constant * getIntegerCast(Constant *C, Type *Ty, bool IsSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Definition: Constants.cpp:2091
llvm::ConstantExpr::getFMul
static Constant * getFMul(Constant *C1, Constant *C2)
Definition: Constants.cpp:2739
llvm::TargetFolder::CreateCast
Constant * CreateCast(Instruction::CastOps Op, Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:193
llvm::TargetFolder::CreateSExtOrBitCast
Constant * CreateSExtOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:229
llvm::TargetFolder::CreateBinOp
Constant * CreateBinOp(Instruction::BinaryOps Opc, Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:165
llvm::NVPTX::PTXLdStInstCode::V2
@ V2
Definition: NVPTX.h:123
llvm::ConstantExpr::getSDiv
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2748
llvm::TargetFolder
TargetFolder - Create constants with target dependent folding.
Definition: TargetFolder.h:32
llvm::TargetFolder::TargetFolder
TargetFolder(const DataLayout &DL)
Definition: TargetFolder.h:43
llvm::ConstantExpr::getNeg
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2691
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:325
llvm::ConstantExpr::getAdd
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2710
llvm::ConstantExpr::getAnd
static Constant * getAnd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2769
llvm::ConstantExpr::getGetElementPtr
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
Definition: Constants.h:1238
llvm::ConstantExpr::getLShr
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2793
llvm::TargetFolder::CreateIntToPtr
Constant * CreateIntToPtr(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:218
llvm::TargetFolder::CreateFNeg
Constant * CreateFNeg(Constant *C) const override
Definition: TargetFolder.h:178
llvm::TargetFolder::CreateShl
Constant * CreateShl(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:149
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:789
llvm::TargetFolder::CreateShuffleVector
Constant * CreateShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask) const override
Definition: TargetFolder.h:269
llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
Definition: Constants.cpp:2080
llvm::ConstantExpr::getSRem
static Constant * getSRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2761
llvm::ConstantExpr::getMul
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2732
llvm::ConstantFoldConstant
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Fold the constant using the specified DataLayout.
Definition: ConstantFolding.cpp:1172
llvm::TargetFolder::CreateSub
Constant * CreateSub(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:115
llvm::TargetFolder::FoldOr
Value * FoldOr(Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:68
llvm::TargetFolder::CreateTruncOrBitCast
Constant * CreateTruncOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:234
llvm::ConstantExpr::getFAdd
static Constant * getFAdd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2717
llvm::TargetFolder::CreateURem
Constant * CreateURem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:140
llvm::TargetFolder::CreateFDiv
Constant * CreateFDiv(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:137
llvm::TargetFolder::CreateAShr
Constant * CreateAShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:157
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::ConstantExpr::getExtractValue
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2667
llvm::TargetFolder::CreateInsertElement
Constant * CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx) const override
Definition: TargetFolder.h:264