LLVM  15.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"
25 
26 namespace llvm {
27 
28 class Constant;
29 class DataLayout;
30 class Type;
31 
32 /// TargetFolder - Create constants with target dependent folding.
33 class TargetFolder final : public IRBuilderFolder {
34  const DataLayout &DL;
35 
36  /// Fold - Fold the constant using target specific information.
37  Constant *Fold(Constant *C) const {
38  return ConstantFoldConstant(C, DL);
39  }
40 
41  virtual void anchor();
42 
43 public:
44  explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
45 
46  //===--------------------------------------------------------------------===//
47  // Value-based folders.
48  //
49  // Return an existing value or a constant if the operation can be simplified.
50  // Otherwise return nullptr.
51  //===--------------------------------------------------------------------===//
52  Value *FoldAdd(Value *LHS, Value *RHS, bool HasNUW = false,
53  bool HasNSW = false) const override {
54  auto *LC = dyn_cast<Constant>(LHS);
55  auto *RC = dyn_cast<Constant>(RHS);
56  if (LC && RC)
57  return Fold(ConstantExpr::getAdd(LC, RC, HasNUW, HasNSW));
58  return nullptr;
59  }
60 
61  Value *FoldAnd(Value *LHS, Value *RHS) const override {
62  auto *LC = dyn_cast<Constant>(LHS);
63  auto *RC = dyn_cast<Constant>(RHS);
64  if (LC && RC)
65  return Fold(ConstantExpr::getAnd(LC, RC));
66  return nullptr;
67  }
68 
69  Value *FoldOr(Value *LHS, Value *RHS) const override {
70  auto *LC = dyn_cast<Constant>(LHS);
71  auto *RC = dyn_cast<Constant>(RHS);
72  if (LC && RC)
73  return Fold(ConstantExpr::getOr(LC, RC));
74  return nullptr;
75  }
76 
78  auto *LC = dyn_cast<Constant>(LHS);
79  auto *RC = dyn_cast<Constant>(RHS);
80  if (LC && RC)
81  return ConstantExpr::getCompare(P, LC, RC);
82  return nullptr;
83  }
84 
85  Value *FoldGEP(Type *Ty, Value *Ptr, ArrayRef<Value *> IdxList,
86  bool IsInBounds = false) const override {
87  if (auto *PC = dyn_cast<Constant>(Ptr)) {
88  // Every index must be constant.
89  if (any_of(IdxList, [](Value *V) { return !isa<Constant>(V); }))
90  return nullptr;
91  if (IsInBounds)
92  return Fold(ConstantExpr::getInBoundsGetElementPtr(Ty, PC, IdxList));
93  else
94  return Fold(ConstantExpr::getGetElementPtr(Ty, PC, IdxList));
95  }
96  return nullptr;
97  }
98 
99  Value *FoldSelect(Value *C, Value *True, Value *False) const override {
100  auto *CC = dyn_cast<Constant>(C);
101  auto *TC = dyn_cast<Constant>(True);
102  auto *FC = dyn_cast<Constant>(False);
103  if (CC && TC && FC)
104  return Fold(ConstantExpr::getSelect(CC, TC, FC));
105 
106  return nullptr;
107  }
108 
110  ArrayRef<unsigned> IdxList) const override {
111  if (auto *CAgg = dyn_cast<Constant>(Agg))
112  return Fold(ConstantExpr::getExtractValue(CAgg, IdxList));
113  return nullptr;
114  };
115 
117  ArrayRef<unsigned> IdxList) const override {
118  auto *CAgg = dyn_cast<Constant>(Agg);
119  auto *CVal = dyn_cast<Constant>(Val);
120  if (CAgg && CVal)
121  return Fold(ConstantExpr::getInsertValue(CAgg, CVal, IdxList));
122  return nullptr;
123  }
124 
125  //===--------------------------------------------------------------------===//
126  // Binary Operators
127  //===--------------------------------------------------------------------===//
128 
129  Constant *CreateFAdd(Constant *LHS, Constant *RHS) const override {
130  return Fold(ConstantExpr::getFAdd(LHS, RHS));
131  }
133  bool HasNUW = false, bool HasNSW = false) const override {
134  return Fold(ConstantExpr::getSub(LHS, RHS, HasNUW, HasNSW));
135  }
136  Constant *CreateFSub(Constant *LHS, Constant *RHS) const override {
137  return Fold(ConstantExpr::getFSub(LHS, RHS));
138  }
140  bool HasNUW = false, bool HasNSW = false) const override {
141  return Fold(ConstantExpr::getMul(LHS, RHS, HasNUW, HasNSW));
142  }
143  Constant *CreateFMul(Constant *LHS, Constant *RHS) const override {
144  return Fold(ConstantExpr::getFMul(LHS, RHS));
145  }
147  bool isExact = false) const override {
148  return Fold(ConstantExpr::getUDiv(LHS, RHS, isExact));
149  }
151  bool isExact = false) const override {
152  return Fold(ConstantExpr::getSDiv(LHS, RHS, isExact));
153  }
154  Constant *CreateFDiv(Constant *LHS, Constant *RHS) const override {
155  return Fold(ConstantExpr::getFDiv(LHS, RHS));
156  }
157  Constant *CreateURem(Constant *LHS, Constant *RHS) const override {
158  return Fold(ConstantExpr::getURem(LHS, RHS));
159  }
160  Constant *CreateSRem(Constant *LHS, Constant *RHS) const override {
161  return Fold(ConstantExpr::getSRem(LHS, RHS));
162  }
163  Constant *CreateFRem(Constant *LHS, Constant *RHS) const override {
164  return Fold(ConstantExpr::getFRem(LHS, RHS));
165  }
167  bool HasNUW = false, bool HasNSW = false) const override {
168  return Fold(ConstantExpr::getShl(LHS, RHS, HasNUW, HasNSW));
169  }
171  bool isExact = false) const override {
172  return Fold(ConstantExpr::getLShr(LHS, RHS, isExact));
173  }
175  bool isExact = false) const override {
176  return Fold(ConstantExpr::getAShr(LHS, RHS, isExact));
177  }
178  Constant *CreateXor(Constant *LHS, Constant *RHS) const override {
179  return Fold(ConstantExpr::getXor(LHS, RHS));
180  }
181 
183  Constant *LHS, Constant *RHS) const override {
184  return Fold(ConstantExpr::get(Opc, LHS, RHS));
185  }
186 
187  //===--------------------------------------------------------------------===//
188  // Unary Operators
189  //===--------------------------------------------------------------------===//
190 
192  bool HasNUW = false, bool HasNSW = false) const override {
193  return Fold(ConstantExpr::getNeg(C, HasNUW, HasNSW));
194  }
195  Constant *CreateFNeg(Constant *C) const override {
196  return Fold(ConstantExpr::getFNeg(C));
197  }
198  Constant *CreateNot(Constant *C) const override {
199  return Fold(ConstantExpr::getNot(C));
200  }
201 
203  return Fold(ConstantExpr::get(Opc, C));
204  }
205 
206  //===--------------------------------------------------------------------===//
207  // Cast/Conversion Operators
208  //===--------------------------------------------------------------------===//
209 
211  Type *DestTy) const override {
212  if (C->getType() == DestTy)
213  return C; // avoid calling Fold
214  return Fold(ConstantExpr::getCast(Op, C, DestTy));
215  }
217  bool isSigned) const override {
218  if (C->getType() == DestTy)
219  return C; // avoid calling Fold
220  return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned));
221  }
222  Constant *CreatePointerCast(Constant *C, Type *DestTy) const override {
223  if (C->getType() == DestTy)
224  return C; // avoid calling Fold
225  return Fold(ConstantExpr::getPointerCast(C, DestTy));
226  }
227  Constant *CreateFPCast(Constant *C, Type *DestTy) const override {
228  if (C->getType() == DestTy)
229  return C; // avoid calling Fold
230  return Fold(ConstantExpr::getFPCast(C, DestTy));
231  }
232  Constant *CreateBitCast(Constant *C, Type *DestTy) const override {
233  return CreateCast(Instruction::BitCast, C, DestTy);
234  }
235  Constant *CreateIntToPtr(Constant *C, Type *DestTy) const override {
236  return CreateCast(Instruction::IntToPtr, C, DestTy);
237  }
238  Constant *CreatePtrToInt(Constant *C, Type *DestTy) const override {
239  return CreateCast(Instruction::PtrToInt, C, DestTy);
240  }
241  Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const override {
242  if (C->getType() == DestTy)
243  return C; // avoid calling Fold
244  return Fold(ConstantExpr::getZExtOrBitCast(C, DestTy));
245  }
246  Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const override {
247  if (C->getType() == DestTy)
248  return C; // avoid calling Fold
249  return Fold(ConstantExpr::getSExtOrBitCast(C, DestTy));
250  }
251  Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const override {
252  if (C->getType() == DestTy)
253  return C; // avoid calling Fold
254  return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy));
255  }
256 
258  Type *DestTy) const override {
259  if (C->getType() == DestTy)
260  return C; // avoid calling Fold
262  }
263 
264  //===--------------------------------------------------------------------===//
265  // Compare Instructions
266  //===--------------------------------------------------------------------===//
267 
269  Constant *RHS) const override {
270  return Fold(ConstantExpr::getCompare(P, LHS, RHS));
271  }
272 
273  //===--------------------------------------------------------------------===//
274  // Other Instructions
275  //===--------------------------------------------------------------------===//
276 
277  Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const override {
278  return Fold(ConstantExpr::getExtractElement(Vec, Idx));
279  }
280 
282  Constant *Idx) const override {
283  return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
284  }
285 
287  ArrayRef<int> Mask) const override {
288  return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
289  }
290 };
291 
292 }
293 
294 #endif
llvm::TargetFolder::FoldAnd
Value * FoldAnd(Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:61
llvm::TargetFolder::CreateFSub
Constant * CreateFSub(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:136
llvm::TargetFolder::FoldExtractValue
Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override
Definition: TargetFolder.h:109
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::ConstantExpr::getFDiv
static Constant * getFDiv(Constant *C1, Constant *C2)
Definition: Constants.cpp:2766
llvm::ConstantExpr::getExtractElement
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2585
llvm::ConstantExpr::getNot
static Constant * getNot(Constant *C)
Definition: Constants.cpp:2717
llvm::ConstantExpr::getZExtOrBitCast
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2049
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:779
llvm::CmpInst::Predicate
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Definition: InstrTypes.h:719
llvm::TargetFolder::FoldGEP
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const override
Definition: TargetFolder.h:85
llvm::TargetFolder::FoldICmp
Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:77
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:2778
llvm::TargetFolder::CreateFRem
Constant * CreateFRem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:163
llvm::ConstantExpr::getFPCast
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
Definition: Constants.cpp:2116
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:268
llvm::TargetFolder::CreatePtrToInt
Constant * CreatePtrToInt(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:238
R600_InstFlag::FC
@ FC
Definition: R600Defines.h:32
llvm::TargetFolder::CreateXor
Constant * CreateXor(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:178
llvm::ConstantExpr::getSelect
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
Definition: Constants.cpp:2453
llvm::ConstantExpr::getInsertValue
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2656
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:150
llvm::TargetFolder::CreateMul
Constant * CreateMul(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:139
llvm::ConstantExpr::getInBoundsGetElementPtr
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Definition: Constants.h:1274
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
ConstantFolding.h
llvm::TargetFolder::CreateNot
Constant * CreateNot(Constant *C) const override
Definition: TargetFolder.h:198
llvm::TargetFolder::CreateFAdd
Constant * CreateFAdd(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:129
llvm::ConstantExpr::getPointerCast
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
Definition: Constants.cpp:2078
llvm::ConstantExpr::getSub
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2734
llvm::BitmaskEnumDetail::Mask
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.
Definition: BitmaskEnum.h:80
LHS
Value * LHS
Definition: X86PartialReduction.cpp:75
Constants.h
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
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:170
llvm::ConstantExpr::getUDiv
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2756
llvm::Instruction::CastOps
CastOps
Definition: Instruction.h:800
llvm::ConstantExpr::getXor
static Constant * getXor(Constant *C1, Constant *C2)
Definition: Constants.cpp:2790
llvm::ConstantExpr::getURem
static Constant * getURem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2770
llvm::TargetFolder::CreateExtractElement
Constant * CreateExtractElement(Constant *Vec, Constant *Idx) const override
Definition: TargetFolder.h:277
llvm::TargetFolder::CreatePointerCast
Constant * CreatePointerCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:222
llvm::ConstantExpr::getFNeg
static Constant * getFNeg(Constant *C)
Definition: Constants.cpp:2711
llvm::TargetFolder::CreateNeg
Constant * CreateNeg(Constant *C, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:191
llvm::ConstantExpr::getAShr
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2811
llvm::TargetFolder::CreateBitCast
Constant * CreateBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:232
llvm::ConstantExpr::getShuffleVector
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2630
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:2431
llvm::TargetFolder::CreateFPCast
Constant * CreateFPCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:227
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:2300
llvm::TargetFolder::CreateUDiv
Constant * CreateUDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:146
llvm::ConstantExpr::getShl
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2799
llvm::ConstantExpr::getFSub
static Constant * getFSub(Constant *C1, Constant *C2)
Definition: Constants.cpp:2741
llvm::ConstantExpr::getOr
static Constant * getOr(Constant *C1, Constant *C2)
Definition: Constants.cpp:2786
ArrayRef.h
IRBuilderFolder.h
TemplateParamKind::Type
@ Type
llvm::TargetFolder::CreateUnOp
Constant * CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override
Definition: TargetFolder.h:202
llvm::TargetFolder::FoldInsertValue
Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override
Definition: TargetFolder.h:116
llvm::TargetFolder::FoldSelect
Value * FoldSelect(Value *C, Value *True, Value *False) const override
Definition: TargetFolder.h:99
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:2010
llvm::ConstantExpr::getTruncOrBitCast
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2061
llvm::TargetFolder::CreateSRem
Constant * CreateSRem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:160
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:1624
llvm::TargetFolder::CreatePointerBitCastOrAddrSpaceCast
Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:257
llvm::TargetFolder::FoldAdd
Value * FoldAdd(Value *LHS, Value *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:52
llvm::ConstantExpr::getSExtOrBitCast
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
Definition: Constants.cpp:2055
llvm::TargetFolder::CreateIntCast
Constant * CreateIntCast(Constant *C, Type *DestTy, bool isSigned) const override
Definition: TargetFolder.h:216
llvm::TargetFolder::CreateZExtOrBitCast
Constant * CreateZExtOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:241
llvm::TargetFolder::CreateFMul
Constant * CreateFMul(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:143
llvm::ConstantExpr::getInsertElement
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
Definition: Constants.cpp:2607
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:2104
llvm::ConstantExpr::getFMul
static Constant * getFMul(Constant *C1, Constant *C2)
Definition: Constants.cpp:2752
llvm::TargetFolder::CreateCast
Constant * CreateCast(Instruction::CastOps Op, Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:210
llvm::TargetFolder::CreateSExtOrBitCast
Constant * CreateSExtOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:246
llvm::TargetFolder::CreateBinOp
Constant * CreateBinOp(Instruction::BinaryOps Opc, Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:182
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:2761
llvm::TargetFolder
TargetFolder - Create constants with target dependent folding.
Definition: TargetFolder.h:33
llvm::TargetFolder::TargetFolder
TargetFolder(const DataLayout &DL)
Definition: TargetFolder.h:44
llvm::ConstantExpr::getNeg
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2704
llvm::AMDGPU::SendMsg::Op
Op
Definition: SIDefines.h:345
llvm::ConstantExpr::getAdd
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2723
llvm::ConstantExpr::getAnd
static Constant * getAnd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2782
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:1247
llvm::ConstantExpr::getLShr
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Definition: Constants.cpp:2806
llvm::TargetFolder::CreateIntToPtr
Constant * CreateIntToPtr(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:235
llvm::TargetFolder::CreateFNeg
Constant * CreateFNeg(Constant *C) const override
Definition: TargetFolder.h:195
llvm::TargetFolder::CreateShl
Constant * CreateShl(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:166
llvm::Instruction::BinaryOps
BinaryOps
Definition: Instruction.h:786
llvm::TargetFolder::CreateShuffleVector
Constant * CreateShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask) const override
Definition: TargetFolder.h:286
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:2093
llvm::ConstantExpr::getSRem
static Constant * getSRem(Constant *C1, Constant *C2)
Definition: Constants.cpp:2774
llvm::ConstantExpr::getMul
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Definition: Constants.cpp:2745
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:1206
llvm::TargetFolder::CreateSub
Constant * CreateSub(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Definition: TargetFolder.h:132
llvm::TargetFolder::FoldOr
Value * FoldOr(Value *LHS, Value *RHS) const override
Definition: TargetFolder.h:69
llvm::TargetFolder::CreateTruncOrBitCast
Constant * CreateTruncOrBitCast(Constant *C, Type *DestTy) const override
Definition: TargetFolder.h:251
llvm::ConstantExpr::getFAdd
static Constant * getFAdd(Constant *C1, Constant *C2)
Definition: Constants.cpp:2730
llvm::TargetFolder::CreateURem
Constant * CreateURem(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:157
llvm::TargetFolder::CreateFDiv
Constant * CreateFDiv(Constant *LHS, Constant *RHS) const override
Definition: TargetFolder.h:154
llvm::TargetFolder::CreateAShr
Constant * CreateAShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
Definition: TargetFolder.h:174
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:2680
llvm::TargetFolder::CreateInsertElement
Constant * CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx) const override
Definition: TargetFolder.h:281