LLVM 23.0.0git
AMDGPULowerKernelAttributes.cpp
Go to the documentation of this file.
1//===-- AMDGPULowerKernelAttributes.cpp------------------------------------===//
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/// \file This pass does attempts to make use of reqd_work_group_size metadata
10/// to eliminate loads from the dispatch packet and to constant fold OpenCL
11/// get_local_size-like functions.
12//
13//===----------------------------------------------------------------------===//
14
15#include "AMDGPU.h"
19#include "llvm/CodeGen/Passes.h"
20#include "llvm/IR/Constants.h"
21#include "llvm/IR/Function.h"
22#include "llvm/IR/IRBuilder.h"
25#include "llvm/IR/IntrinsicsAMDGPU.h"
26#include "llvm/IR/MDBuilder.h"
28#include "llvm/Pass.h"
29
30#define DEBUG_TYPE "amdgpu-lower-kernel-attributes"
31
32using namespace llvm;
33
34namespace {
35
36// Field offsets in hsa_kernel_dispatch_packet_t.
37enum DispatchPackedOffsets {
38 WORKGROUP_SIZE_X = 4,
39 WORKGROUP_SIZE_Y = 6,
40 WORKGROUP_SIZE_Z = 8,
41
42 GRID_SIZE_X = 12,
43 GRID_SIZE_Y = 16,
44 GRID_SIZE_Z = 20
45};
46
47// Field offsets to implicit kernel argument pointer.
48enum ImplicitArgOffsets {
49 HIDDEN_BLOCK_COUNT_X = 0,
50 HIDDEN_BLOCK_COUNT_Y = 4,
51 HIDDEN_BLOCK_COUNT_Z = 8,
52
53 HIDDEN_GROUP_SIZE_X = 12,
54 HIDDEN_GROUP_SIZE_Y = 14,
55 HIDDEN_GROUP_SIZE_Z = 16,
56
57 HIDDEN_REMAINDER_X = 18,
58 HIDDEN_REMAINDER_Y = 20,
59 HIDDEN_REMAINDER_Z = 22,
60
61 GRID_DIMS = 64
62};
63
64class AMDGPULowerKernelAttributes : public ModulePass {
65public:
66 static char ID;
67
68 AMDGPULowerKernelAttributes() : ModulePass(ID) {}
69
70 bool runOnModule(Module &M) override;
71
72 StringRef getPassName() const override { return "AMDGPU Kernel Attributes"; }
73
74 void getAnalysisUsage(AnalysisUsage &AU) const override {
75 AU.setPreservesAll();
76 }
77};
78
79Function *getBasePtrIntrinsic(Module &M, bool IsV5OrAbove) {
80 auto IntrinsicId = IsV5OrAbove ? Intrinsic::amdgcn_implicitarg_ptr
81 : Intrinsic::amdgcn_dispatch_ptr;
82 return Intrinsic::getDeclarationIfExists(&M, IntrinsicId);
83}
84
85} // end anonymous namespace
86
88 uint32_t MaxNumGroups) {
89 if (MaxNumGroups == 0 || MaxNumGroups == std::numeric_limits<uint32_t>::max())
90 return false;
91
92 if (!Load->getType()->isIntegerTy(32))
93 return false;
94
95 // TODO: If there is existing range metadata, preserve it if it is stricter.
96 if (Load->hasMetadata(LLVMContext::MD_range))
97 return false;
98
99 MDBuilder MDB(Load->getContext());
100 MDNode *Range = MDB.createRange(APInt(32, 1), APInt(32, MaxNumGroups + 1));
101 Load->setMetadata(LLVMContext::MD_range, Range);
102 return true;
103}
104
105static bool annotateGroupSizeLoadWithRangeMD(LoadInst *Load, bool IsRemainder) {
106 if (!Load->getType()->isIntegerTy(16))
107 return false;
108
109 // TODO: If there is existing range metadata, preserve it if it is stricter.
110 if (Load->hasMetadata(LLVMContext::MD_range))
111 return false;
112
113 MDBuilder MDB(Load->getContext());
114 MDNode *Range = MDB.createRange(
115 APInt(16, !IsRemainder),
116 APInt(16, AMDGPU::IsaInfo::getMaxFlatWorkGroupSize() + 1 - IsRemainder));
117 Load->setMetadata(LLVMContext::MD_range, Range);
118 return true;
119}
120
122 unsigned KnownNumGridDims) {
123 IntegerType *Ty = dyn_cast<IntegerType>(Load->getType());
124 if (!Ty || Ty->getBitWidth() < 3)
125 return false;
126
127 if (KnownNumGridDims != 0) {
128 Load->replaceAllUsesWith(
129 ConstantInt::get(Load->getType(), KnownNumGridDims));
130 return true;
131 }
132
133 // TODO: If there is existing range metadata, preserve it if it is stricter.
134 if (Load->hasMetadata(LLVMContext::MD_range))
135 return false;
136
137 MDBuilder MDB(Load->getContext());
138 MDNode *Range =
139 MDB.createRange(APInt(Ty->getBitWidth(), 1), APInt(Ty->getBitWidth(), 4));
140 Load->setMetadata(LLVMContext::MD_range, Range);
141 return true;
142}
143
144/// Compute the number of grid dimensions based on !reqd_work_group_size
145/// metadata
146static unsigned computeNumGridDims(const MDNode *ReqdWorkGroupSize) {
147 ConstantInt *KnownZ =
148 mdconst::extract<ConstantInt>(ReqdWorkGroupSize->getOperand(2));
149 if (KnownZ->getZExtValue() != 1)
150 return 3;
151
152 ConstantInt *KnownY =
153 mdconst::extract<ConstantInt>(ReqdWorkGroupSize->getOperand(1));
154 if (KnownY->getZExtValue() != 1)
155 return 2;
156
157 return 1;
158}
159
160static bool processUse(CallInst *CI, bool IsV5OrAbove) {
161 Function *F = CI->getFunction();
162
163 auto *MD = F->getMetadata("reqd_work_group_size");
164 const bool HasReqdWorkGroupSize = MD && MD->getNumOperands() == 3;
165
166 const bool HasUniformWorkGroupSize =
167 F->hasFnAttribute("uniform-work-group-size");
168
169 SmallVector<unsigned> MaxNumWorkgroups =
170 AMDGPU::getIntegerVecAttribute(*F, "amdgpu-max-num-workgroups",
171 /*Size=*/3, /*DefaultVal=*/0);
172
173 Value *BlockCounts[3] = {nullptr, nullptr, nullptr};
174 Value *GroupSizes[3] = {nullptr, nullptr, nullptr};
175 Value *Remainders[3] = {nullptr, nullptr, nullptr};
176 Value *GridSizes[3] = {nullptr, nullptr, nullptr};
177
178 const DataLayout &DL = F->getDataLayout();
179 bool MadeChange = false;
180
181 unsigned KnownNumGridDims = HasReqdWorkGroupSize ? computeNumGridDims(MD) : 0;
182
183 // We expect to see several GEP users, casted to the appropriate type and
184 // loaded.
185 for (User *U : CI->users()) {
186 if (!U->hasOneUse())
187 continue;
188
189 int64_t Offset = 0;
190 auto *Load = dyn_cast<LoadInst>(U); // Load from ImplicitArgPtr/DispatchPtr?
191 auto *BCI = dyn_cast<BitCastInst>(U);
192 if (!Load && !BCI) {
194 continue;
195 Load = dyn_cast<LoadInst>(*U->user_begin()); // Load from GEP?
196 BCI = dyn_cast<BitCastInst>(*U->user_begin());
197 }
198
199 if (BCI) {
200 if (!BCI->hasOneUse())
201 continue;
202 Load = dyn_cast<LoadInst>(*BCI->user_begin()); // Load from BCI?
203 }
204
205 if (!Load || !Load->isSimple())
206 continue;
207
208 unsigned LoadSize = DL.getTypeStoreSize(Load->getType());
209
210 // TODO: Handle merged loads.
211 if (IsV5OrAbove) { // Base is ImplicitArgPtr.
212 switch (Offset) {
213 case HIDDEN_BLOCK_COUNT_X:
214 if (LoadSize == 4) {
215 BlockCounts[0] = Load;
216 MadeChange |=
217 annotateGridSizeLoadWithRangeMD(Load, MaxNumWorkgroups[0]);
218 }
219 break;
220 case HIDDEN_BLOCK_COUNT_Y:
221 if (LoadSize == 4) {
222 BlockCounts[1] = Load;
223 MadeChange |=
224 annotateGridSizeLoadWithRangeMD(Load, MaxNumWorkgroups[1]);
225 }
226 break;
227 case HIDDEN_BLOCK_COUNT_Z:
228 if (LoadSize == 4) {
229 BlockCounts[2] = Load;
230 MadeChange |=
231 annotateGridSizeLoadWithRangeMD(Load, MaxNumWorkgroups[2]);
232 }
233 break;
234 case HIDDEN_GROUP_SIZE_X:
235 if (LoadSize == 2) {
236 GroupSizes[0] = Load;
237 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, false);
238 }
239 break;
240 case HIDDEN_GROUP_SIZE_Y:
241 if (LoadSize == 2) {
242 GroupSizes[1] = Load;
243 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, false);
244 }
245 break;
246 case HIDDEN_GROUP_SIZE_Z:
247 if (LoadSize == 2) {
248 GroupSizes[2] = Load;
249 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, false);
250 }
251 break;
252 case HIDDEN_REMAINDER_X:
253 if (LoadSize == 2) {
254 Remainders[0] = Load;
255 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, true);
256 }
257 break;
258 case HIDDEN_REMAINDER_Y:
259 if (LoadSize == 2) {
260 Remainders[1] = Load;
261 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, true);
262 }
263 break;
264 case HIDDEN_REMAINDER_Z:
265 if (LoadSize == 2) {
266 Remainders[2] = Load;
267 MadeChange |= annotateGroupSizeLoadWithRangeMD(Load, true);
268 }
269 break;
270
271 case GRID_DIMS:
272 if (LoadSize <= 2)
273 MadeChange |= annotateGridDimsLoadWithRangeMD(Load, KnownNumGridDims);
274 break;
275 default:
276 break;
277 }
278 } else { // Base is DispatchPtr.
279 switch (Offset) {
280 case WORKGROUP_SIZE_X:
281 if (LoadSize == 2)
282 GroupSizes[0] = Load;
283 break;
284 case WORKGROUP_SIZE_Y:
285 if (LoadSize == 2)
286 GroupSizes[1] = Load;
287 break;
288 case WORKGROUP_SIZE_Z:
289 if (LoadSize == 2)
290 GroupSizes[2] = Load;
291 break;
292 case GRID_SIZE_X:
293 if (LoadSize == 4)
294 GridSizes[0] = Load;
295 break;
296 case GRID_SIZE_Y:
297 if (LoadSize == 4)
298 GridSizes[1] = Load;
299 break;
300 case GRID_SIZE_Z:
301 if (LoadSize == 4)
302 GridSizes[2] = Load;
303 break;
304 default:
305 break;
306 }
307 }
308 }
309
310 if (IsV5OrAbove && HasUniformWorkGroupSize) {
311 // Under v5 __ockl_get_local_size returns the value computed by the
312 // expression:
313 //
314 // workgroup_id < hidden_block_count ? hidden_group_size :
315 // hidden_remainder
316 //
317 // For functions with the attribute uniform-work-group-size=true. we can
318 // evaluate workgroup_id < hidden_block_count as true, and thus
319 // hidden_group_size is returned for __ockl_get_local_size.
320 for (int I = 0; I < 3; ++I) {
321 Value *BlockCount = BlockCounts[I];
322 if (!BlockCount)
323 continue;
324
325 using namespace llvm::PatternMatch;
326 auto GroupIDIntrin =
330
331 for (User *ICmp : BlockCount->users()) {
332 if (match(ICmp, m_SpecificICmp(ICmpInst::ICMP_ULT, GroupIDIntrin,
333 m_Specific(BlockCount)))) {
334 ICmp->replaceAllUsesWith(llvm::ConstantInt::getTrue(ICmp->getType()));
335 MadeChange = true;
336 }
337 }
338 }
339
340 // All remainders should be 0 with uniform work group size.
341 for (Value *Remainder : Remainders) {
342 if (!Remainder)
343 continue;
344 Remainder->replaceAllUsesWith(
345 Constant::getNullValue(Remainder->getType()));
346 MadeChange = true;
347 }
348 } else if (HasUniformWorkGroupSize) { // Pre-V5.
349 // Pattern match the code used to handle partial workgroup dispatches in the
350 // library implementation of get_local_size, so the entire function can be
351 // constant folded with a known group size.
352 //
353 // uint r = grid_size - group_id * group_size;
354 // get_local_size = (r < group_size) ? r : group_size;
355 //
356 // If we have uniform-work-group-size (which is the default in OpenCL 1.2),
357 // the grid_size is required to be a multiple of group_size). In this case:
358 //
359 // grid_size - (group_id * group_size) < group_size
360 // ->
361 // grid_size < group_size + (group_id * group_size)
362 //
363 // (grid_size / group_size) < 1 + group_id
364 //
365 // grid_size / group_size is at least 1, so we can conclude the select
366 // condition is false (except for group_id == 0, where the select result is
367 // the same).
368 for (int I = 0; I < 3; ++I) {
369 Value *GroupSize = GroupSizes[I];
370 Value *GridSize = GridSizes[I];
371 if (!GroupSize || !GridSize)
372 continue;
373
374 using namespace llvm::PatternMatch;
375 auto GroupIDIntrin =
379
380 for (User *U : GroupSize->users()) {
381 auto *ZextGroupSize = dyn_cast<ZExtInst>(U);
382 if (!ZextGroupSize)
383 continue;
384
385 for (User *UMin : ZextGroupSize->users()) {
386 if (match(UMin, m_UMin(m_Sub(m_Specific(GridSize),
387 m_Mul(GroupIDIntrin,
388 m_Specific(ZextGroupSize))),
389 m_Specific(ZextGroupSize)))) {
390 if (HasReqdWorkGroupSize) {
391 ConstantInt *KnownSize =
392 mdconst::extract<ConstantInt>(MD->getOperand(I));
393 UMin->replaceAllUsesWith(ConstantFoldIntegerCast(
394 KnownSize, UMin->getType(), false, DL));
395 } else {
396 UMin->replaceAllUsesWith(ZextGroupSize);
397 }
398
399 MadeChange = true;
400 }
401 }
402 }
403 }
404 }
405
406 // Upgrade the old method of calculating the block size using the grid size.
407 // We pattern match any case where the implicit argument group size is the
408 // divisor to a dispatch packet grid size read of the same dimension.
409 if (IsV5OrAbove) {
410 for (int I = 0; I < 3; I++) {
411 Value *GroupSize = GroupSizes[I];
412 if (!GroupSize || !GroupSize->getType()->isIntegerTy(16))
413 continue;
414
415 for (User *U : GroupSize->users()) {
417 if (isa<ZExtInst>(Inst) && !Inst->use_empty())
418 Inst = cast<Instruction>(*Inst->user_begin());
419
420 using namespace llvm::PatternMatch;
421 if (!match(
422 Inst,
425 m_SpecificInt(GRID_SIZE_X + I * sizeof(uint32_t))))),
426 m_Value())))
427 continue;
428
429 IRBuilder<> Builder(Inst);
430
431 Value *GEP = Builder.CreateInBoundsGEP(
432 Builder.getInt8Ty(), CI,
433 {ConstantInt::get(Type::getInt64Ty(CI->getContext()),
434 HIDDEN_BLOCK_COUNT_X + I * sizeof(uint32_t))});
435 Instruction *BlockCount = Builder.CreateLoad(Builder.getInt32Ty(), GEP);
436 BlockCount->setMetadata(LLVMContext::MD_invariant_load,
437 MDNode::get(CI->getContext(), {}));
438 BlockCount->setMetadata(LLVMContext::MD_noundef,
439 MDNode::get(CI->getContext(), {}));
440
441 Value *BlockCountExt = Builder.CreateZExt(BlockCount, Inst->getType());
442 Inst->replaceAllUsesWith(BlockCountExt);
443 Inst->eraseFromParent();
444 MadeChange = true;
445 }
446 }
447 }
448
449 // If reqd_work_group_size is set, we can replace work group size with it.
450 if (!HasReqdWorkGroupSize)
451 return MadeChange;
452
453 for (int I = 0; I < 3; I++) {
454 Value *GroupSize = GroupSizes[I];
455 if (!GroupSize)
456 continue;
457
458 ConstantInt *KnownSize = mdconst::extract<ConstantInt>(MD->getOperand(I));
459 GroupSize->replaceAllUsesWith(
460 ConstantFoldIntegerCast(KnownSize, GroupSize->getType(), false, DL));
461 MadeChange = true;
462 }
463
464 return MadeChange;
465}
466
467// TODO: Move makeLIDRangeMetadata usage into here. Seem to not get
468// TargetPassConfig for subtarget.
469bool AMDGPULowerKernelAttributes::runOnModule(Module &M) {
470 bool MadeChange = false;
471 bool IsV5OrAbove =
473 Function *BasePtr = getBasePtrIntrinsic(M, IsV5OrAbove);
474
475 if (!BasePtr) // ImplicitArgPtr/DispatchPtr not used.
476 return false;
477
478 SmallPtrSet<Instruction *, 4> HandledUses;
479 for (auto *U : BasePtr->users()) {
480 CallInst *CI = cast<CallInst>(U);
481 if (HandledUses.insert(CI).second) {
482 if (processUse(CI, IsV5OrAbove))
483 MadeChange = true;
484 }
485 }
486
487 return MadeChange;
488}
489
490INITIALIZE_PASS_BEGIN(AMDGPULowerKernelAttributes, DEBUG_TYPE,
491 "AMDGPU Kernel Attributes", false, false)
492INITIALIZE_PASS_END(AMDGPULowerKernelAttributes, DEBUG_TYPE,
493 "AMDGPU Kernel Attributes", false, false)
494
495char AMDGPULowerKernelAttributes::ID = 0;
496
498 return new AMDGPULowerKernelAttributes();
499}
500
503 bool IsV5OrAbove =
505 Function *BasePtr = getBasePtrIntrinsic(*F.getParent(), IsV5OrAbove);
506
507 if (!BasePtr) // ImplicitArgPtr/DispatchPtr not used.
508 return PreservedAnalyses::all();
509
510 bool Changed = false;
511 for (Instruction &I : instructions(F)) {
512 if (CallInst *CI = dyn_cast<CallInst>(&I)) {
513 if (CI->getCalledFunction() == BasePtr)
514 Changed |= processUse(CI, IsV5OrAbove);
515 }
516 }
517
520}
static bool annotateGridSizeLoadWithRangeMD(LoadInst *Load, uint32_t MaxNumGroups)
static unsigned computeNumGridDims(const MDNode *ReqdWorkGroupSize)
Compute the number of grid dimensions based on !reqd_work_group_size metadata.
static bool annotateGroupSizeLoadWithRangeMD(LoadInst *Load, bool IsRemainder)
static bool annotateGridDimsLoadWithRangeMD(LoadInst *Load, unsigned KnownNumGridDims)
static bool processUse(CallInst *CI, bool IsV5OrAbove)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Expand Atomic instructions
This file contains the declarations for the subclasses of Constant, which represent the different fla...
#define DEBUG_TYPE
Hexagon Common GEP
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Definition PassSupport.h:44
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Definition PassSupport.h:39
Class for arbitrary precision integers.
Definition APInt.h:78
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
This class represents a function call, abstracting a target machine's calling convention.
@ ICMP_ULT
unsigned less than
Definition InstrTypes.h:701
This is the shared class of boolean and integer constants.
Definition Constants.h:87
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
Definition Constants.h:168
static LLVM_ABI Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2811
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
Class to represent integer types.
An instruction for reading from memory.
LLVM_ABI MDNode * createRange(const APInt &Lo, const APInt &Hi)
Return metadata describing the range [Lo, Hi).
Definition MDBuilder.cpp:96
Metadata node.
Definition Metadata.h:1080
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1572
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:255
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition Analysis.h:115
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition Type.h:257
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
user_iterator user_begin()
Definition Value.h:403
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:553
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:259
iterator_range< user_iterator > users()
Definition Value.h:427
bool use_empty() const
Definition Value.h:347
Changed
constexpr unsigned getMaxFlatWorkGroupSize()
unsigned getAMDHSACodeObjectVersion(const Module &M)
SmallVector< unsigned > getIntegerVecAttribute(const Function &F, StringRef Name, unsigned Size, unsigned DefaultVal)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
specific_intval< false > m_SpecificInt(const APInt &V)
Match a specific integer value or vector with all elements equal to the value.
match_combine_or< CastInst_match< OpTy, ZExtInst >, OpTy > m_ZExtOrSelf(const OpTy &Op)
bool match(Val *V, const Pattern &P)
specificval_ty m_Specific(const Value *V)
Match if we have a specific specified value.
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
BinaryOp_match< LHS, RHS, Instruction::Mul > m_Mul(const LHS &L, const RHS &R)
auto m_GEP(const OperandTypes &...Ops)
Matches GetElementPtrInst.
SpecificCmpClass_match< LHS, RHS, ICmpInst > m_SpecificICmp(CmpPredicate MatchPred, const LHS &L, const RHS &R)
OneOps_match< OpTy, Instruction::Load > m_Load(const OpTy &Op)
Matches LoadInst.
BinaryOp_match< LHS, RHS, Instruction::UDiv > m_UDiv(const LHS &L, const RHS &R)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
MaxMin_match< ICmpInst, LHS, RHS, umin_pred_ty > m_UMin(const LHS &L, const RHS &R)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition Metadata.h:668
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
@ Offset
Definition DWP.cpp:532
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
Value * GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, const DataLayout &DL, bool AllowNonInbounds=true)
Analyze the specified pointer to see if it can be expressed as a base pointer plus a constant offset.
ModulePass * createAMDGPULowerKernelAttributesPass()
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ UMin
Unsigned integer min implemented in terms of select(cmp()).
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
LLVM_ABI Constant * ConstantFoldIntegerCast(Constant *C, Type *DestTy, bool IsSigned, const DataLayout &DL)
Constant fold a zext, sext or trunc, depending on IsSigned and whether the DestTy is wider or narrowe...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)