clang 24.0.0git
CIRGenBuiltinAMDGPU.cpp
Go to the documentation of this file.
1//===---- CIRGenBuiltinAMDGPU.cpp - Emit CIR for AMDGPU builtins ----------===//
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 contains code to emit AMDGPU Builtin calls.
10//
11//===----------------------------------------------------------------------===//
12
13#include "CIRGenFunction.h"
14
15#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
16#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
17#include "mlir/IR/Value.h"
19#include "llvm/IR/IntrinsicsAMDGPU.h"
20#include "llvm/Support/AMDGPUAddrSpace.h"
21#include "llvm/Support/ErrorHandling.h"
22#include "llvm/TargetParser/AtomicScope.h"
23
24using namespace clang;
25using namespace clang::CIRGen;
26using namespace cir;
27
28// Emit a no-operand intrinsic returning a pointer in the constant AS.
30 mlir::Location loc,
31 llvm::StringRef name) {
32 CIRGenBuilderTy &builder = cgf.getBuilder();
33 mlir::Type retTy = builder.getVoidPtrTy(cir::TargetAddressSpaceAttr::get(
34 builder.getContext(), llvm::AMDGPUAS::CONSTANT_ADDRESS));
35 return builder.emitIntrinsicCallOp(loc, name, retTy, mlir::ValueRange{});
36}
37
38/// Map a constant integral to memory order.
39static cir::MemOrder decodeAtomicOrder(const Expr *arg, ASTContext &ctx) {
40 Expr::EvalResult orderRes;
41 if (!arg->EvaluateAsInt(orderRes, ctx))
42 return cir::MemOrder::SequentiallyConsistent;
43 switch (orderRes.Val.getInt().getZExtValue()) {
44 case 0:
45 return cir::MemOrder::Relaxed;
46 case 1: // consume -> acquire
47 case 2:
48 return cir::MemOrder::Acquire;
49 case 3:
50 return cir::MemOrder::Release;
51 case 4:
52 return cir::MemOrder::AcquireRelease;
53 default:
54 return cir::MemOrder::SequentiallyConsistent;
55 }
56}
57
58/// Map an AMDGPU sync-scope string-literal argument onto cir::SyncScopeKind.
59/// An absent or unrecognized scope is system scope, which is the conservative
60/// choice and matches what an empty syncscope string means in LLVM.
61static cir::SyncScopeKind decodeAMDGPUSyncScope(const Expr *arg) {
62 const auto *sl =
63 llvm::dyn_cast<clang::StringLiteral>(arg->IgnoreParenCasts());
64 if (!sl)
65 return cir::SyncScopeKind::System;
66 return llvm::StringSwitch<cir::SyncScopeKind>(sl->getString())
67 .Case("singlethread", cir::SyncScopeKind::SingleThread)
68 .Case("wavefront", cir::SyncScopeKind::Wavefront)
69 .Case("workgroup", cir::SyncScopeKind::Workgroup)
70 .Case("agent", cir::SyncScopeKind::Device)
71 .Default(cir::SyncScopeKind::System);
72}
73
74static cir::SyncScopeKind convertAtomicScopeToCIR(llvm::AtomicScope scope) {
75 switch (scope) {
76 case llvm::AtomicScope::Single:
77 return cir::SyncScopeKind::SingleThread;
78 case llvm::AtomicScope::Wavefront:
79 return cir::SyncScopeKind::Wavefront;
80 case llvm::AtomicScope::Workgroup:
81 return cir::SyncScopeKind::Workgroup;
82 case llvm::AtomicScope::Cluster:
83 return cir::SyncScopeKind::Cluster;
84 case llvm::AtomicScope::Device:
85 return cir::SyncScopeKind::Device;
86 case llvm::AtomicScope::System:
87 return cir::SyncScopeKind::System;
88 }
89 llvm_unreachable("unknown atomic scope");
90}
91
92/// Emit one of the AMDGPU raw hardware atomic builtins as a cir.atomic.fetch.
93static mlir::Value emitAMDGPUAtomicRMW(CIRGenFunction &cgf,
94 const CallExpr *expr,
95 cir::AtomicFetchKind binOp,
96 bool hasVolatileArg) {
97 CIRGenBuilderTy &builder = cgf.getBuilder();
98 mlir::Location loc = cgf.getLoc(expr->getExprLoc());
99
100 Address ptr = cgf.emitPointerWithAlignment(expr->getArg(0));
101 mlir::Value val = cgf.emitScalarExpr(expr->getArg(1));
102
103 bool isVolatile;
104 if (hasVolatileArg) {
105 assert(expr->getNumArgs() >= 5);
106 // ds_faddf/fminf/fmaxf spell the volatile flag out as a constant argument.
107 Expr::EvalResult volRes;
108 isVolatile = expr->getArg(4)->EvaluateAsInt(volRes, cgf.getContext()) &&
109 volRes.Val.getInt().getBoolValue();
110 } else {
111 // Everything else infers it from the pointee type.
112 QualType argTy = expr->getArg(0)->IgnoreImpCasts()->getType();
113 isVolatile = argTy->castAs<clang::PointerType>()
116 }
117
118 // Some of these builtins spell out the ordering and scope; the rest take the
119 // monotonic/agent default described above.
120 cir::MemOrder order = cir::MemOrder::Relaxed;
121 cir::SyncScopeKind scope = cir::SyncScopeKind::Device;
122 if (expr->getNumArgs() >= 4) {
123 order = decodeAtomicOrder(expr->getArg(2), cgf.getContext());
124 scope = decodeAMDGPUSyncScope(expr->getArg(3));
125 }
126
127 auto rmw = cir::AtomicFetchOp::create(builder, loc, ptr.emitRawPointer(), val,
128 binOp, order, scope, isVolatile,
129 /*fetch_first=*/true);
130 rmw->setAttr(cir::CIRDialect::getAMDGPURawAtomicAttrName(),
131 builder.getUnitAttr());
132 return rmw->getResult(0);
133}
134
135// Emit the `amdgcn.dispatch.ptr` intrinsic, address-space-casting the
136// result to match \p e's return type when needed.
137// If \p e is null, returns the raw AS-4 pointer.
138static mlir::Value emitAMDGPUDispatchPtr(CIRGenFunction &cgf,
139 mlir::Location loc,
140 const CallExpr *e = nullptr) {
141 CIRGenBuilderTy &builder = cgf.getBuilder();
142 mlir::Value call =
143 emitAMDGPUConstantPtrIntrinsic(cgf, loc, "amdgcn.dispatch.ptr");
144 if (!e)
145 return call;
146 // Only cast when the caller-visible AS differs from the intrinsic's AS;
147 auto expectedPtrTy =
148 mlir::cast<cir::PointerType>(cgf.convertType(e->getType()));
149 auto callPtrTy = mlir::cast<cir::PointerType>(call.getType());
150 if (expectedPtrTy.getAddrSpace() == callPtrTy.getAddrSpace())
151 return call;
152 return builder.createAddrSpaceCast(loc, call, expectedPtrTy);
153}
154
156 mlir::Location loc) {
157 // OG also marks the result align 8 dereferenceable(256).
159 return emitAMDGPUConstantPtrIntrinsic(cgf, loc, "amdgcn.implicitarg.ptr");
160}
161
162static mlir::Value emitAMDGPUWorkGroupID(CIRGenFunction &cgf,
163 mlir::Location loc, unsigned index) {
164 static constexpr llvm::StringLiteral names[] = {"amdgcn.workgroup.id.x",
165 "amdgcn.workgroup.id.y",
166 "amdgcn.workgroup.id.z"};
167 CIRGenBuilderTy &builder = cgf.getBuilder();
168 return builder.emitIntrinsicCallOp(loc, names[index], builder.getUInt32Ty(),
169 mlir::ValueRange{});
170}
171
172// Load a \p ty value at byte \p offset from \p base as an invariant load.
174 mlir::Location loc, mlir::Value base,
175 mlir::Value offset, mlir::Type ty,
176 CharUnits align) {
177 CIRGenBuilderTy &builder = cgf.getBuilder();
178 mlir::Value addr = builder.createPtrStride(loc, base, offset);
179 cir::LoadOp load = builder.createAlignedLoad(loc, ty, addr, align);
180 load.setInvariant(true);
182 return load;
183}
184
185static mlir::Value emitAMDGPUGridSize(CIRGenFunction &cgf, mlir::Location loc,
186 unsigned index) {
187 CIRGenBuilderTy &builder = cgf.getBuilder();
188 const unsigned xOffset = 12;
189 mlir::Value dispatchPtr = emitAMDGPUDispatchPtr(cgf, loc);
190 // Indexing the HSA kernel_dispatch_packet struct.
192 cgf, loc, dispatchPtr, builder.getUInt64(xOffset + index * 4, loc),
194}
195
197 mlir::Location loc,
198 unsigned index) {
199 CIRGenBuilderTy &builder = cgf.getBuilder();
200 mlir::Value implicitArgPtr = emitAMDGPUImplicitArgPtr(cgf, loc);
201
202 // offsetof(amdhsa_implicit_kernarg_v5, block_count[index])
203 unsigned blockCountOffset = 0 + index * 4;
204 // offsetof(amdhsa_implicit_kernarg_v5, group_size[index])
205 unsigned groupSizeOffset = 12 + index * 2;
206 // offsetof(amdhsa_implicit_kernarg_v5, remainder[index])
207 unsigned remainderOffset = 18 + index * 2;
208
209 mlir::Value sizeOffset;
210 if (cgf.getLangOpts().OffloadUniformBlock) {
211 sizeOffset = builder.getUInt64(groupSizeOffset, loc);
212 } else {
213 mlir::Value blockCount = emitAMDGPUInvariantLoad(
214 cgf, loc, implicitArgPtr, builder.getUInt64(blockCountOffset, loc),
216 mlir::Value workgroupID = emitAMDGPUWorkGroupID(cgf, loc, index);
217 mlir::Value isFull =
218 builder.createCompare(loc, cir::CmpOpKind::lt, workgroupID, blockCount);
219 sizeOffset = builder.createSelect(loc, isFull,
220 builder.getUInt64(groupSizeOffset, loc),
221 builder.getUInt64(remainderOffset, loc));
222 }
223
224 mlir::Value size = emitAMDGPUInvariantLoad(cgf, loc, implicitArgPtr,
225 sizeOffset, builder.getUInt16Ty(),
227 return builder.createIntCast(size, builder.getUInt32Ty());
228}
229
231 mlir::Location loc,
232 unsigned index) {
233 CIRGenBuilderTy &builder = cgf.getBuilder();
234 mlir::Value dispatchPtr = emitAMDGPUDispatchPtr(cgf, loc);
235
236 // Indexing the HSA kernel_dispatch_packet struct.
237 mlir::Value groupSizeLd = emitAMDGPUInvariantLoad(
238 cgf, loc, dispatchPtr, builder.getUInt64(4 + index * 2, loc),
240 mlir::Value groupSize =
241 builder.createIntCast(groupSizeLd, builder.getUInt32Ty());
242
243 if (cgf.getLangOpts().OffloadUniformBlock)
244 return groupSize;
245
246 mlir::Value workgroupID = emitAMDGPUWorkGroupID(cgf, loc, index);
247 mlir::Value gridSize = emitAMDGPUInvariantLoad(
248 cgf, loc, dispatchPtr, builder.getUInt64(12 + index * 4, loc),
250 mlir::Value mul = builder.createMul(loc, workgroupID, groupSize);
251 mlir::Value remainder = builder.createSub(loc, gridSize, mul);
252 mlir::Value isPartial =
253 builder.createCompare(loc, cir::CmpOpKind::lt, remainder, groupSize);
254 return builder.createSelect(loc, isPartial, remainder, groupSize);
255}
256
257// \p index is 0, 1, and 2 for x, y, and z dimension, respectively.
258// Emit code based on Code Object ABI version.
259// COV_4 : Emit code to use dispatch ptr
260// COV_5+ : Emit code to use implicitarg ptr
261// COV_NONE : Emit code to load a global variable "__oclc_ABI_version"
262// and use its value for COV_4 or COV_5+ approach. It is used for
263// compiling device libraries in an ABI-agnostic way.
265 mlir::Location loc, unsigned index) {
266 llvm::CodeObjectVersionKind cov =
268
269 // Do not emit __oclc_ABI_version references with non-empty environment.
270 if (cov == llvm::CodeObjectVersionKind::COV_None &&
271 cgf.getTarget().getTriple().hasEnvironment())
272 cov = llvm::CodeObjectVersionKind::COV_6;
273
274 if (cov != llvm::CodeObjectVersionKind::COV_None)
275 return cov >= llvm::CodeObjectVersionKind::COV_5
277 : emitAMDGPUWorkGroupSizeV4(cgf, loc, index);
278
279 CIRGenBuilderTy &builder = cgf.getBuilder();
280 CIRGenModule &cgm = cgf.cgm;
281 StringRef name = "__oclc_ABI_version";
282 mlir::Type int32Ty = builder.getSInt32Ty();
283 auto abiVersionGV =
284 mlir::dyn_cast_or_null<cir::GlobalOp>(cgm.getGlobalValue(name));
285 if (!abiVersionGV)
286 abiVersionGV =
287 cgm.createGlobalOp(loc, name, int32Ty, /*isConstant=*/false,
290 mlir::Value abiVersionPtr = builder.createGetGlobal(loc, abiVersionGV);
291 mlir::Value abiVersion = builder.createAlignedLoad(
292 loc, int32Ty, abiVersionPtr,
294 mlir::Value isCOV5 = builder.createCompare(
295 loc, cir::CmpOpKind::ge, abiVersion,
296 builder.getConstantInt(loc, int32Ty, llvm::CodeObjectVersionKind::COV_5));
297 mlir::Value v5Impl = emitAMDGPUWorkGroupSizeV5(cgf, loc, index);
298 mlir::Value v4Impl = emitAMDGPUWorkGroupSizeV4(cgf, loc, index);
299 return builder.createSelect(loc, isCOV5, v5Impl, v4Impl);
300}
301
303 CIRGenFunction &cgf, const CallExpr *e, llvm::StringRef intrinsicName,
304 llvm::StringRef constrainedIntrinsicName) {
305 mlir::Value src0 = cgf.emitScalarExpr(e->getArg(0));
306 mlir::Value src1 = cgf.emitScalarExpr(e->getArg(1));
307 mlir::Location loc = cgf.getLoc(e->getExprLoc());
308
309 CIRGenBuilderTy &builder = cgf.getBuilder();
310
311 CIRGenFunction::CIRGenFPOptionsRAII fpOptsRAII(cgf, e);
312
313 if (builder.getIsFPConstrained()) {
314 cgf.cgm.errorNYI(e->getSourceRange(),
315 "constrained FP intrinsic support is NYI.");
316 }
317
318 return builder.emitIntrinsicCallOp(loc, intrinsicName, src0.getType(),
319 mlir::ValueRange{src0, src1});
320}
321
322static mlir::Value emitLogbBuiltin(CIRGenFunction &cgf, const CallExpr *e,
323 const llvm::fltSemantics &fSem) {
324 CIRGenBuilderTy &builder = cgf.getBuilder();
325 mlir::Location loc = cgf.getLoc(e->getExprLoc());
326
327 mlir::Value src0 = cgf.emitScalarExpr(e->getArg(0));
328 mlir::Type srcTy = src0.getType();
329 mlir::Type int32Ty = builder.getSInt32Ty();
330
331 mlir::Type frExpResMembers[] = {srcTy, int32Ty};
332 cir::RecordType frExpResTy = builder.getAnonRecordTy(
333 frExpResMembers, /*packed=*/false,
334 cir::RecordType::getAllDataKinds(frExpResMembers));
335
336 mlir::Value frExpResult = builder.emitIntrinsicCallOp(
337 loc, "frexp", frExpResTy, mlir::ValueRange{src0});
338
339 mlir::Value exp =
340 cir::ExtractMemberOp::create(builder, loc, int32Ty, frExpResult, 1);
341
342 mlir::Value negativeOne =
343 builder.getConstant(loc, cir::IntAttr::get(int32Ty, -1));
344 mlir::Value expMinus1 = builder.createNSWAdd(loc, exp, negativeOne);
345
346 mlir::Value siToFp = cir::CastOp::create(
347 builder, loc, srcTy, cir::CastKind::int_to_float, expMinus1);
348
349 mlir::Value fabs = cir::FAbsOp::create(builder, loc, src0);
350
351 llvm::APFloat infVal = llvm::APFloat::getInf(fSem);
352 mlir::Value inf = builder.getConstant(loc, cir::FPAttr::get(srcTy, infVal));
353
354 mlir::Value fabsNegInf =
355 builder.createCompare(loc, cir::CmpOpKind::one, fabs, inf);
356
357 mlir::Value sel = builder.createSelect(loc, fabsNegInf, siToFp, fabs);
358
359 llvm::APFloat zeroValue = llvm::APFloat::getZero(fSem);
360 mlir::Value zero =
361 builder.getConstant(loc, cir::FPAttr::get(srcTy, zeroValue));
362
363 mlir::Value srcEqZero =
364 builder.createCompare(loc, cir::CmpOpKind::eq, src0, zero);
365
366 llvm::APFloat negInfVal = llvm::APFloat::getInf(fSem, true);
367 mlir::Value negInf =
368 builder.getConstant(loc, cir::FPAttr::get(srcTy, negInfVal));
369
370 mlir::Value res = builder.createSelect(loc, srcEqZero, negInf, sel);
371
372 return res;
373}
374
375static mlir::Value
377 llvm::StringRef intrinsicName,
378 bool isImageStore) {
379 auto &builder = cgf.getBuilder();
380
382 for (unsigned i = 0, n = e->getNumArgs(); i < n; ++i)
383 args.push_back(cgf.emitScalarExpr(e->getArg(i)));
384
385 mlir::Type retTy = isImageStore ? cir::VoidType::get(builder.getContext())
386 : cgf.convertType(e->getType());
387
388 auto callOp = cir::LLVMIntrinsicCallOp::create(
389 builder, cgf.getLoc(e->getExprLoc()),
390 builder.getStringAttr(intrinsicName), retTy, args);
391
392 return callOp.getResult();
393}
394
395std::optional<mlir::Value>
397 const CallExpr *expr) {
398 switch (builtinId) {
399 case AMDGPU::BI__builtin_amdgcn_wave_reduce_add_u32:
400 case AMDGPU::BI__builtin_amdgcn_wave_reduce_sub_u32:
401 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_i32:
402 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_u32:
403 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_i32:
404 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_u32:
405 case AMDGPU::BI__builtin_amdgcn_wave_reduce_and_b32:
406 case AMDGPU::BI__builtin_amdgcn_wave_reduce_or_b32:
407 case AMDGPU::BI__builtin_amdgcn_wave_reduce_xor_b32:
408 case AMDGPU::BI__builtin_amdgcn_wave_reduce_add_u64:
409 case AMDGPU::BI__builtin_amdgcn_wave_reduce_sub_u64:
410 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_i64:
411 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_u64:
412 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_i64:
413 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_u64:
414 case AMDGPU::BI__builtin_amdgcn_wave_reduce_and_b64:
415 case AMDGPU::BI__builtin_amdgcn_wave_reduce_or_b64:
416 case AMDGPU::BI__builtin_amdgcn_wave_reduce_xor_b64: {
417 cgm.errorNYI(expr->getSourceRange(),
418 std::string("unimplemented AMDGPU builtin call: ") +
419 getContext().BuiltinInfo.getName(builtinId));
420 return mlir::Value{};
421 }
422 case AMDGPU::BI__builtin_amdgcn_div_scale:
423 case AMDGPU::BI__builtin_amdgcn_div_scalef: {
424 Address flagOutPtr = emitPointerWithAlignment(expr->getArg(3));
425 llvm::StringRef intrinsicName = "amdgcn.div.scale";
426 mlir::Value x = emitScalarExpr(expr->getArg(0));
427 mlir::Value y = emitScalarExpr(expr->getArg(1));
428 mlir::Value z = emitScalarExpr(expr->getArg(2));
429
430 auto i1Ty = builder.getUIntNTy(1);
431 mlir::Type resMembers[] = {x.getType(), i1Ty};
432 cir::RecordType resTy =
433 builder.getAnonRecordTy(resMembers, /*packed=*/false,
435
436 mlir::Value structResult =
437 cir::LLVMIntrinsicCallOp::create(builder, getLoc(expr->getExprLoc()),
438 builder.getStringAttr(intrinsicName),
439 resTy, {x, y, z})
440 .getResult();
441
442 mlir::Value result = cir::ExtractMemberOp::create(
443 builder, getLoc(expr->getExprLoc()), x.getType(), structResult, 0);
444 mlir::Value flag = cir::ExtractMemberOp::create(
445 builder, getLoc(expr->getExprLoc()), i1Ty, structResult, 1);
446
447 mlir::Type flagType = flagOutPtr.getElementType();
448 mlir::Value flagToStore =
449 cir::CastOp::create(builder, getLoc(expr->getExprLoc()), flagType,
450 cir::CastKind::int_to_bool, flag);
451 builder.createStore(getLoc(expr->getExprLoc()), flagToStore, flagOutPtr);
452 return result;
453 }
454 case AMDGPU::BI__builtin_amdgcn_div_fmas:
455 case AMDGPU::BI__builtin_amdgcn_div_fmasf:
456 return emitBuiltinWithOneOverloadedType<4>(expr, "amdgcn.div.fmas")
457 .getValue();
458 case AMDGPU::BI__builtin_amdgcn_mov_dpp8:
459 case AMDGPU::BI__builtin_amdgcn_mov_dpp:
460 case AMDGPU::BI__builtin_amdgcn_update_dpp: {
461 mlir::Location loc = getLoc(expr->getExprLoc());
462 unsigned iceArguments = 0;
464 getContext().GetBuiltinType(builtinId, error, &iceArguments);
465 assert(error == ASTContext::GE_None && "Should not codegen an error");
466 assert(expr->getNumArgs() == 5 || expr->getNumArgs() == 6 ||
467 expr->getNumArgs() == 2);
468
469 mlir::Type dataTy = convertType(expr->getArg(0)->getType());
470 unsigned size = cgm.getDataLayout().getTypeSizeInBits(dataTy);
471 cir::IntType intTy = builder.getUIntNTy(std::max(size, 32u));
472
473 bool isMovDpp8 = builtinId == AMDGPU::BI__builtin_amdgcn_mov_dpp8;
474 bool isMovDpp = builtinId == AMDGPU::BI__builtin_amdgcn_mov_dpp;
475 bool isUpdateDpp = builtinId == AMDGPU::BI__builtin_amdgcn_update_dpp;
476 llvm::StringRef intrinsicName =
477 isMovDpp8 ? "amdgcn.mov.dpp8" : "amdgcn.update.dpp";
478 cir::FuncType intrinsicTy =
479 getIntrinsicType(isMovDpp8 ? llvm::Intrinsic::amdgcn_mov_dpp8
480 : llvm::Intrinsic::amdgcn_update_dpp,
481 {intTy});
482
483 auto coerceTo = [&](mlir::Value from, mlir::Type to) -> mlir::Value {
484 if (from.getType() == to)
485 return from;
486 if (mlir::isa<cir::IntType>(from.getType()) &&
487 mlir::isa<cir::IntType>(to))
488 return builder.createIntCast(from, to);
489 return builder.createBitcast(from, to);
490 };
491
493 // __builtin_amdgcn_mov_dpp has no "old" operand at the source level, but
494 // the real intrinsic it lowers to requires one, so we synthesize a poison
495 // value for it since it is never meaningfully read.
496 if (isMovDpp)
497 args.push_back(builder.getConstant(loc, cir::PoisonAttr::get(intTy)));
498
499 // Number of builtin-level leading args that need zero-extend promotion when
500 // the data type is narrower than 32 bits.
501 unsigned numPromotedArgs = isUpdateDpp ? 2u : 1u;
502 for (unsigned i = 0; i != expr->getNumArgs(); ++i) {
503 mlir::Value v =
504 emitScalarOrConstFoldImmArg(iceArguments, i, expr->getArg(i));
505 if (i < numPromotedArgs && size < 32) {
506 mlir::Type sameWidthUTy = builder.getUIntNTy(size);
507 if (v.getType() != sameWidthUTy)
508 v = builder.createBitcast(v, sameWidthUTy);
509 v = builder.createIntCast(v, intTy);
510 }
511 args.push_back(coerceTo(v, intrinsicTy.getInput(i + unsigned(isMovDpp))));
512 }
513
514 mlir::Value result = builder.emitIntrinsicCallOp(loc, intrinsicName, intTy,
515 mlir::ValueRange(args));
516 if (size < 32 && !mlir::isa<cir::IntType>(dataTy))
517 result = builder.createIntCast(result, builder.getUIntNTy(size));
518 return coerceTo(result, dataTy);
519 }
520 case AMDGPU::BI__builtin_amdgcn_permlane16:
521 case AMDGPU::BI__builtin_amdgcn_permlanex16: {
522 llvm::StringRef intrinsicName =
523 builtinId == AMDGPU::BI__builtin_amdgcn_permlane16
524 ? "amdgcn.permlane16"
525 : "amdgcn.permlanex16";
526 return emitBuiltinWithOneOverloadedType<6>(expr, intrinsicName).getValue();
527 }
528 case AMDGPU::BI__builtin_amdgcn_permlane64:
529 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.permlane64")
530 .getValue();
531 case AMDGPU::BI__builtin_amdgcn_permlane_bcast:
532 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.bcast")
533 .getValue();
534 case AMDGPU::BI__builtin_amdgcn_permlane_up:
535 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.up")
536 .getValue();
537 case AMDGPU::BI__builtin_amdgcn_permlane_down:
538 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.down")
539 .getValue();
540 case AMDGPU::BI__builtin_amdgcn_permlane_xor:
541 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.xor")
542 .getValue();
543 case AMDGPU::BI__builtin_amdgcn_readlane:
544 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.readlane")
545 .getValue();
546 case AMDGPU::BI__builtin_amdgcn_readfirstlane:
547 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.readfirstlane")
548 .getValue();
549 case AMDGPU::BI__builtin_amdgcn_wave_shuffle:
550 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.wave.shuffle")
551 .getValue();
552 case AMDGPU::BI__builtin_amdgcn_div_fixup:
553 case AMDGPU::BI__builtin_amdgcn_div_fixupf:
554 case AMDGPU::BI__builtin_amdgcn_div_fixuph: {
555 mlir::Value src0 = emitScalarExpr(expr->getArg(0));
556 mlir::Value src1 = emitScalarExpr(expr->getArg(1));
557 mlir::Value src2 = emitScalarExpr(expr->getArg(2));
558 return builder.emitIntrinsicCallOp(getLoc(expr->getExprLoc()),
559 "amdgcn.div.fixup", src0.getType(),
560 mlir::ValueRange{src0, src1, src2});
561 }
562 case AMDGPU::BI__builtin_amdgcn_trig_preop:
563 case AMDGPU::BI__builtin_amdgcn_trig_preopf:
564 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.trig.preop")
565 .getValue();
566 case AMDGPU::BI__builtin_amdgcn_rcp:
567 case AMDGPU::BI__builtin_amdgcn_rcpf:
568 case AMDGPU::BI__builtin_amdgcn_rcph:
569 case AMDGPU::BI__builtin_amdgcn_rcp_bf16: {
570 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rcp").getValue();
571 }
572 case AMDGPU::BI__builtin_amdgcn_sqrt:
573 case AMDGPU::BI__builtin_amdgcn_sqrtf:
574 case AMDGPU::BI__builtin_amdgcn_sqrth:
575 case AMDGPU::BI__builtin_amdgcn_sqrt_bf16: {
576 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.sqrt").getValue();
577 }
578 case AMDGPU::BI__builtin_amdgcn_rsq:
579 case AMDGPU::BI__builtin_amdgcn_rsqf:
580 case AMDGPU::BI__builtin_amdgcn_rsqh:
581 case AMDGPU::BI__builtin_amdgcn_rsq_bf16: {
582 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rsq").getValue();
583 }
584 case AMDGPU::BI__builtin_amdgcn_rsq_clamp:
585 case AMDGPU::BI__builtin_amdgcn_rsq_clampf: {
586 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rsq.clamp")
587 .getValue();
588 }
589 case AMDGPU::BI__builtin_amdgcn_sinf:
590 case AMDGPU::BI__builtin_amdgcn_sinh:
591 case AMDGPU::BI__builtin_amdgcn_sin_bf16: {
592 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.sin").getValue();
593 }
594 case AMDGPU::BI__builtin_amdgcn_cosf:
595 case AMDGPU::BI__builtin_amdgcn_cosh:
596 case AMDGPU::BI__builtin_amdgcn_cos_bf16: {
597 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.cos").getValue();
598 }
599 case AMDGPU::BI__builtin_amdgcn_dispatch_ptr:
600 return emitAMDGPUDispatchPtr(*this, getLoc(expr->getExprLoc()), expr);
601 case AMDGPU::BI__builtin_amdgcn_logf:
602 case AMDGPU::BI__builtin_amdgcn_log_bf16: {
603 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.log").getValue();
604 }
605 case AMDGPU::BI__builtin_amdgcn_exp2f:
606 case AMDGPU::BI__builtin_amdgcn_exp2_bf16: {
607 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.exp2").getValue();
608 }
609 case AMDGPU::BI__builtin_amdgcn_log_clampf: {
610 cgm.errorNYI(expr->getSourceRange(),
611 std::string("unimplemented AMDGPU builtin call: ") +
612 getContext().BuiltinInfo.getName(builtinId));
613 return mlir::Value{};
614 }
615 case AMDGPU::BI__builtin_amdgcn_ldexp:
616 case AMDGPU::BI__builtin_amdgcn_ldexpf:
617 case AMDGPU::BI__builtin_amdgcn_ldexph: {
618 mlir::Value src0 = emitScalarExpr(expr->getArg(0));
619 mlir::Value src1 = emitScalarExpr(expr->getArg(1));
620 // For ldexph, the raw instruction has different behavior for out-of-bounds
621 // exponent values (implicit truncation instead of saturate to
622 // short_min/short_max), so truncate the exponent to i16 first.
623 mlir::Value exp =
624 builtinId == AMDGPU::BI__builtin_amdgcn_ldexph
625 ? cir::CastOp::create(builder, getLoc(expr->getExprLoc()),
626 builder.getSInt16Ty(),
627 cir::CastKind::integral, src1)
628 : src1;
629 return builder.emitIntrinsicCallOp(getLoc(expr->getExprLoc()), "ldexp",
630 src0.getType(),
631 mlir::ValueRange{src0, exp});
632 }
633 case AMDGPU::BI__builtin_amdgcn_frexp_mant:
634 case AMDGPU::BI__builtin_amdgcn_frexp_mantf:
635 case AMDGPU::BI__builtin_amdgcn_frexp_manth: {
636 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.frexp.mant")
637 .getValue();
638 }
639 case AMDGPU::BI__builtin_amdgcn_frexp_exp:
640 case AMDGPU::BI__builtin_amdgcn_frexp_expf:
641 case AMDGPU::BI__builtin_amdgcn_frexp_exph: {
642 cgm.errorNYI(expr->getSourceRange(),
643 std::string("unimplemented AMDGPU builtin call: ") +
644 getContext().BuiltinInfo.getName(builtinId));
645 return mlir::Value{};
646 }
647 case AMDGPU::BI__builtin_amdgcn_fract:
648 case AMDGPU::BI__builtin_amdgcn_fractf:
649 case AMDGPU::BI__builtin_amdgcn_fracth:
650 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.fract").getValue();
651 case AMDGPU::BI__builtin_amdgcn_lerp: {
652 cgm.errorNYI(expr->getSourceRange(),
653 std::string("unimplemented AMDGPU builtin call: ") +
654 getContext().BuiltinInfo.getName(builtinId));
655 return mlir::Value{};
656 }
657 case AMDGPU::BI__builtin_amdgcn_ubfe:
658 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.ubfe").getValue();
659 case AMDGPU::BI__builtin_amdgcn_sbfe:
660 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.sbfe").getValue();
661 case AMDGPU::BI__builtin_amdgcn_ballot_w32:
662 case AMDGPU::BI__builtin_amdgcn_ballot_w64:
663 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ballot",
664 convertType(expr->getType()))
665 .getValue();
666 case AMDGPU::BI__builtin_amdgcn_inverse_ballot_w32:
667 case AMDGPU::BI__builtin_amdgcn_inverse_ballot_w64:
668 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.inverse.ballot",
669 convertType(expr->getType()))
670 .getValue();
671 case AMDGPU::BI__builtin_amdgcn_tanhf:
672 case AMDGPU::BI__builtin_amdgcn_tanhh:
673 case AMDGPU::BI__builtin_amdgcn_tanh_bf16: {
674 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.tanh").getValue();
675 }
676 case AMDGPU::BI__builtin_amdgcn_uicmp:
677 case AMDGPU::BI__builtin_amdgcn_uicmpl:
678 case AMDGPU::BI__builtin_amdgcn_sicmp:
679 case AMDGPU::BI__builtin_amdgcn_sicmpl:
680 case AMDGPU::BI__builtin_amdgcn_fcmp:
681 case AMDGPU::BI__builtin_amdgcn_fcmpf: {
682 mlir::Value lhs = emitScalarExpr(expr->getArg(0));
683 mlir::Value rhs = emitScalarExpr(expr->getArg(1));
684
685 uint64_t imm =
686 expr->getArg(2)->EvaluateKnownConstInt(getContext()).getZExtValue();
687
688 cir::CmpOpKind pred;
689 switch (imm) {
690 case 0x1: // FCMP_OEQ
691 case 0x20: // ICMP_EQ
692 pred = cir::CmpOpKind::eq;
693 break;
694 case 0xe: // FCMP_UNE
695 case 0x21: // ICMP_NE
696 pred = cir::CmpOpKind::ne;
697 break;
698 case 0x2: // FCMP_OGT
699 case 0x22: // ICMP_UGT
700 case 0x26: // ICMP_SGT
701 pred = cir::CmpOpKind::gt;
702 break;
703 case 0x3: // FCMP_OGE
704 case 0x23: // ICMP_UGE
705 case 0x27: // ICMP_SGE
706 pred = cir::CmpOpKind::ge;
707 break;
708 case 0x4: // FCMP_OLT
709 case 0x24: // ICMP_ULT
710 case 0x28: // ICMP_SLT
711 pred = cir::CmpOpKind::lt;
712 break;
713 case 0x5: // FCMP_OLE
714 case 0x25: // ICMP_ULE
715 case 0x29: // ICMP_SLE
716 pred = cir::CmpOpKind::le;
717 break;
718 case 0x6: // FCMP_ONE
719 pred = cir::CmpOpKind::one;
720 break;
721 case 0x8: // FCMP_UNO
722 pred = cir::CmpOpKind::uno;
723 break;
724 default:
725 cgm.errorNYI(expr->getSourceRange(),
726 "amdgcn compare with unsupported predicate");
727 return mlir::Value{};
728 }
729
730 mlir::Location loc = getLoc(expr->getExprLoc());
731 mlir::Value cmp = builder.createCompare(loc, pred, lhs, rhs);
732 return builder.emitIntrinsicCallOp(loc, "amdgcn.ballot",
733 convertType(expr->getType()), cmp);
734 }
735 case AMDGPU::BI__builtin_amdgcn_class:
736 case AMDGPU::BI__builtin_amdgcn_classf:
737 case AMDGPU::BI__builtin_amdgcn_classh:
738 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.class",
739 convertType(expr->getType()))
740 .getValue();
741 case AMDGPU::BI__builtin_amdgcn_fmed3f:
742 case AMDGPU::BI__builtin_amdgcn_fmed3h:
743 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.fmed3").getValue();
744 case AMDGPU::BI__builtin_amdgcn_ds_append:
745 case AMDGPU::BI__builtin_amdgcn_ds_consume: {
746 cgm.errorNYI(expr->getSourceRange(),
747 std::string("unimplemented AMDGPU builtin call: ") +
748 getContext().BuiltinInfo.getName(builtinId));
749 return mlir::Value{};
750 }
751 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b64_i32:
752 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b64_v2i32:
753 case AMDGPU::BI__builtin_amdgcn_global_load_tr8_b64_v2i32:
755 expr, "amdgcn.global.load.tr.b64", convertType(expr->getType()))
756 .getValue();
757 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4i16:
758 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4f16:
759 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4bf16:
760 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8i16:
761 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8f16:
762 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8bf16:
763 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8i16:
764 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8f16:
765 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8bf16:
767 expr, "amdgcn.global.load.tr.b128", convertType(expr->getType()))
768 .getValue();
769 case AMDGPU::BI__builtin_amdgcn_global_load_tr4_b64_v2i32:
771 expr, "amdgcn.global.load.tr4.b64", convertType(expr->getType()))
772 .getValue();
773 case AMDGPU::BI__builtin_amdgcn_global_load_tr6_b96_v3i32:
775 expr, "amdgcn.global.load.tr6.b96", convertType(expr->getType()))
776 .getValue();
777 case AMDGPU::BI__builtin_amdgcn_ds_load_tr4_b64_v2i32:
778 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr4.b64",
779 convertType(expr->getType()))
780 .getValue();
781 case AMDGPU::BI__builtin_amdgcn_ds_load_tr6_b96_v3i32:
782 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr6.b96",
783 convertType(expr->getType()))
784 .getValue();
785 case AMDGPU::BI__builtin_amdgcn_ds_load_tr8_b64_v2i32:
786 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr8.b64",
787 convertType(expr->getType()))
788 .getValue();
789 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8i16:
790 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8f16:
791 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8bf16:
792 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr16.b128",
793 convertType(expr->getType()))
794 .getValue();
795 case AMDGPU::BI__builtin_amdgcn_ds_read_tr4_b64_v2i32:
796 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr4.b64",
797 convertType(expr->getType()))
798 .getValue();
799 case AMDGPU::BI__builtin_amdgcn_ds_read_tr8_b64_v2i32:
800 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr8.b64",
801 convertType(expr->getType()))
802 .getValue();
803 case AMDGPU::BI__builtin_amdgcn_ds_read_tr6_b96_v3i32:
804 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr6.b96",
805 convertType(expr->getType()))
806 .getValue();
807 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16:
808 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
809 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
810 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr16.b64",
811 convertType(expr->getType()))
812 .getValue();
813 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b32:
814 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b64:
815 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b128:
816 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b32:
817 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b64:
818 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b128: {
819 cgm.errorNYI(expr->getSourceRange(),
820 std::string("unimplemented AMDGPU builtin call: ") +
821 getContext().BuiltinInfo.getName(builtinId));
822 return mlir::Value{};
823 }
824 case AMDGPU::BI__builtin_amdgcn_cluster_load_b32:
825 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b32",
826 convertType(expr->getType()))
827 .getValue();
828 case AMDGPU::BI__builtin_amdgcn_cluster_load_b64:
829 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b64",
830 convertType(expr->getType()))
831 .getValue();
832 case AMDGPU::BI__builtin_amdgcn_cluster_load_b128:
833 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b128",
834 convertType(expr->getType()))
835 .getValue();
836 case AMDGPU::BI__builtin_amdgcn_load_to_lds:
838 expr, "amdgcn.load.to.lds",
839 cir::VoidType::get(builder.getContext()))
840 .getValue();
841 case AMDGPU::BI__builtin_amdgcn_load_async_to_lds:
843 expr, "amdgcn.load.async.to.lds",
844 cir::VoidType::get(builder.getContext()))
845 .getValue();
846 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_32x4B:
847 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_32x4B:
848 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_16x8B:
849 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_16x8B:
850 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_8x16B:
851 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_8x16B: {
852 cgm.errorNYI(expr->getSourceRange(),
853 std::string("unimplemented AMDGPU builtin call: ") +
854 getContext().BuiltinInfo.getName(builtinId));
855 return mlir::Value{};
856 }
857 case AMDGPU::BI__builtin_amdgcn_get_fpenv:
858 case AMDGPU::BI__builtin_amdgcn_set_fpenv: {
859 cgm.errorNYI(expr->getSourceRange(),
860 std::string("unimplemented AMDGPU builtin call: ") +
861 getContext().BuiltinInfo.getName(builtinId));
862 return mlir::Value{};
863 }
864 case AMDGPU::BI__builtin_amdgcn_read_exec:
865 case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
866 case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
867 // The exec mask is read as a ballot over an all-true predicate. The
868 // ballot is at least as wide as the wavefront, so that a wave64 target
869 // still reports both halves for the _lo/_hi forms.
870 mlir::Location loc = getLoc(expr->getExprLoc());
871 unsigned registerWidth =
872 builtinId == AMDGPU::BI__builtin_amdgcn_read_exec_lo ? 32 : 64;
873 unsigned ballotWidth =
874 std::max(getTarget().getGridValue().GV_Warp_Size, registerWidth);
875 cir::IntType ballotTy = builder.getUIntNTy(ballotWidth);
876
877 mlir::Value truePred = builder.getBool(true, loc).getResult();
878 mlir::Value result =
879 builder.emitIntrinsicCallOp(loc, "amdgcn.ballot", ballotTy, truePred);
880
881 if (builtinId == AMDGPU::BI__builtin_amdgcn_read_exec_hi)
882 result = builder.createShiftRight(loc, result, 32);
883 return builder.createIntCast(result, convertType(expr->getType()));
884 }
885 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
886 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
887 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
888 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_lh: {
889 cgm.errorNYI(expr->getSourceRange(),
890 std::string("unimplemented AMDGPU builtin call: ") +
891 getContext().BuiltinInfo.getName(builtinId));
892 return mlir::Value{};
893 }
894 case AMDGPU::BI__builtin_amdgcn_image_bvh8_intersect_ray:
895 case AMDGPU::BI__builtin_amdgcn_image_bvh_dual_intersect_ray: {
896 cgm.errorNYI(expr->getSourceRange(),
897 std::string("unimplemented AMDGPU builtin call: ") +
898 getContext().BuiltinInfo.getName(builtinId));
899 return mlir::Value{};
900 }
901 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_rtn:
902 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn:
903 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn:
904 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn: {
905 cgm.errorNYI(expr->getSourceRange(),
906 std::string("unimplemented AMDGPU builtin call: ") +
907 getContext().BuiltinInfo.getName(builtinId));
908 return mlir::Value{};
909 }
910 case AMDGPU::BI__builtin_amdgcn_image_load_1d_v4f32_i32:
911 case AMDGPU::BI__builtin_amdgcn_image_load_1d_v4f16_i32:
913 "amdgcn.image.load.1d", false);
914 case AMDGPU::BI__builtin_amdgcn_image_load_1darray_v4f32_i32:
915 case AMDGPU::BI__builtin_amdgcn_image_load_1darray_v4f16_i32:
917 *this, expr, "amdgcn.image.load.1darray", false);
918 case AMDGPU::BI__builtin_amdgcn_image_load_2d_f32_i32:
919 case AMDGPU::BI__builtin_amdgcn_image_load_2d_v4f32_i32:
920 case AMDGPU::BI__builtin_amdgcn_image_load_2d_v4f16_i32:
922 "amdgcn.image.load.2d", false);
923 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_f32_i32:
924 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_v4f32_i32:
925 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_v4f16_i32:
927 *this, expr, "amdgcn.image.load.2darray", false);
928 case AMDGPU::BI__builtin_amdgcn_image_load_3d_v4f32_i32:
929 case AMDGPU::BI__builtin_amdgcn_image_load_3d_v4f16_i32:
931 "amdgcn.image.load.3d", false);
932 case AMDGPU::BI__builtin_amdgcn_image_load_cube_v4f32_i32:
933 case AMDGPU::BI__builtin_amdgcn_image_load_cube_v4f16_i32:
935 "amdgcn.image.load.cube", false);
936 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1d_v4f32_i32:
937 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1d_v4f16_i32:
939 *this, expr, "amdgcn.image.load.mip.1d", false);
940 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1darray_v4f32_i32:
941 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1darray_v4f16_i32:
943 *this, expr, "amdgcn.image.load.mip.1darray", false);
944 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_f32_i32:
945 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_v4f32_i32:
946 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_v4f16_i32:
948 *this, expr, "amdgcn.image.load.mip.2d", false);
949 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_f32_i32:
950 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_v4f32_i32:
951 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_v4f16_i32:
953 *this, expr, "amdgcn.image.load.mip.2darray", false);
954 case AMDGPU::BI__builtin_amdgcn_image_load_mip_3d_v4f32_i32:
955 case AMDGPU::BI__builtin_amdgcn_image_load_mip_3d_v4f16_i32:
957 *this, expr, "amdgcn.image.load.mip.3d", false);
958 case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f32_i32:
959 case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f16_i32:
961 *this, expr, "amdgcn.image.load.mip.cube", false);
962 case AMDGPU::BI__builtin_amdgcn_image_store_1d_v4f32_i32:
963 case AMDGPU::BI__builtin_amdgcn_image_store_1d_v4f16_i32:
965 "amdgcn.image.store.1d", true);
966 case AMDGPU::BI__builtin_amdgcn_image_store_1darray_v4f32_i32:
967 case AMDGPU::BI__builtin_amdgcn_image_store_1darray_v4f16_i32:
969 *this, expr, "amdgcn.image.store.1darray", true);
970 case AMDGPU::BI__builtin_amdgcn_image_store_2d_f32_i32:
971 case AMDGPU::BI__builtin_amdgcn_image_store_2d_v4f32_i32:
972 case AMDGPU::BI__builtin_amdgcn_image_store_2d_v4f16_i32:
974 "amdgcn.image.store.2d", true);
975 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_f32_i32:
976 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_v4f32_i32:
977 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_v4f16_i32:
979 *this, expr, "amdgcn.image.store.2darray", true);
980 case AMDGPU::BI__builtin_amdgcn_image_store_3d_v4f32_i32:
981 case AMDGPU::BI__builtin_amdgcn_image_store_3d_v4f16_i32:
983 "amdgcn.image.store.3d", true);
984 case AMDGPU::BI__builtin_amdgcn_image_store_cube_v4f32_i32:
985 case AMDGPU::BI__builtin_amdgcn_image_store_cube_v4f16_i32:
987 "amdgcn.image.store.cube", true);
988 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1d_v4f32_i32:
989 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1d_v4f16_i32:
991 *this, expr, "amdgcn.image.store.mip.1d", true);
992 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1darray_v4f32_i32:
993 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1darray_v4f16_i32:
995 *this, expr, "amdgcn.image.store.mip.1darray", true);
996 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_f32_i32:
997 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_v4f32_i32:
998 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_v4f16_i32:
1000 *this, expr, "amdgcn.image.store.mip.2d", true);
1001 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_f32_i32:
1002 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_v4f32_i32:
1003 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_v4f16_i32:
1005 *this, expr, "amdgcn.image.store.mip.2darray", true);
1006 case AMDGPU::BI__builtin_amdgcn_image_store_mip_3d_v4f32_i32:
1007 case AMDGPU::BI__builtin_amdgcn_image_store_mip_3d_v4f16_i32:
1009 *this, expr, "amdgcn.image.store.mip.3d", true);
1010 case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f32_i32:
1011 case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f16_i32:
1013 *this, expr, "amdgcn.image.store.mip.cube", true);
1014 case AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f32_f32:
1015 case AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f16_f32:
1017 "amdgcn.image.sample.1d", false);
1018 case AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f32_f32:
1019 case AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f16_f32:
1021 *this, expr, "amdgcn.image.sample.1darray", false);
1022 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_f32_f32:
1023 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f32_f32:
1024 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f16_f32:
1026 "amdgcn.image.sample.2d", false);
1027 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_f32_f32:
1028 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f32_f32:
1029 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f16_f32:
1031 *this, expr, "amdgcn.image.sample.2darray", false);
1032 case AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f32_f32:
1033 case AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f16_f32:
1035 "amdgcn.image.sample.3d", false);
1036 case AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f32_f32:
1037 case AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f16_f32:
1039 *this, expr, "amdgcn.image.sample.cube", false);
1040 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1d_v4f32_f32:
1041 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1d_v4f16_f32:
1043 *this, expr, "amdgcn.image.sample.lz.1d", false);
1044 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1d_v4f32_f32:
1045 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1d_v4f16_f32:
1047 *this, expr, "amdgcn.image.sample.l.1d", false);
1048 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1d_v4f32_f32:
1049 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1d_v4f16_f32:
1051 *this, expr, "amdgcn.image.sample.d.1d", false);
1052 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_v4f32_f32:
1053 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_v4f16_f32:
1054 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_f32_f32:
1056 *this, expr, "amdgcn.image.sample.lz.2d", false);
1057 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_v4f32_f32:
1058 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_v4f16_f32:
1059 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_f32_f32:
1061 *this, expr, "amdgcn.image.sample.l.2d", false);
1062 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_v4f32_f32:
1063 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_v4f16_f32:
1064 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_f32_f32:
1066 *this, expr, "amdgcn.image.sample.d.2d", false);
1067 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_3d_v4f32_f32:
1068 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_3d_v4f16_f32:
1070 *this, expr, "amdgcn.image.sample.lz.3d", false);
1071 case AMDGPU::BI__builtin_amdgcn_image_sample_l_3d_v4f32_f32:
1072 case AMDGPU::BI__builtin_amdgcn_image_sample_l_3d_v4f16_f32:
1074 *this, expr, "amdgcn.image.sample.l.3d", false);
1075 case AMDGPU::BI__builtin_amdgcn_image_sample_d_3d_v4f32_f32:
1076 case AMDGPU::BI__builtin_amdgcn_image_sample_d_3d_v4f16_f32:
1078 *this, expr, "amdgcn.image.sample.d.3d", false);
1079 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_cube_v4f32_f32:
1080 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_cube_v4f16_f32:
1082 *this, expr, "amdgcn.image.sample.lz.cube", false);
1083 case AMDGPU::BI__builtin_amdgcn_image_sample_l_cube_v4f32_f32:
1084 case AMDGPU::BI__builtin_amdgcn_image_sample_l_cube_v4f16_f32:
1086 *this, expr, "amdgcn.image.sample.l.cube", false);
1087 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1darray_v4f32_f32:
1088 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1darray_v4f16_f32:
1090 *this, expr, "amdgcn.image.sample.lz.1darray", false);
1091 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1darray_v4f32_f32:
1092 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1darray_v4f16_f32:
1094 *this, expr, "amdgcn.image.sample.l.1darray", false);
1095 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1darray_v4f32_f32:
1096 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1darray_v4f16_f32:
1098 *this, expr, "amdgcn.image.sample.d.1darray", false);
1099 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_v4f32_f32:
1100 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_v4f16_f32:
1101 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_f32_f32:
1103 *this, expr, "amdgcn.image.sample.lz.2darray", false);
1104 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_v4f32_f32:
1105 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_v4f16_f32:
1106 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_f32_f32:
1108 *this, expr, "amdgcn.image.sample.l.2darray", false);
1109 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_v4f32_f32:
1110 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_v4f16_f32:
1111 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_f32_f32:
1113 *this, expr, "amdgcn.image.sample.d.2darray", false);
1114 case AMDGPU::BI__builtin_amdgcn_image_gather4_lz_2d_v4f32_f32:
1115 case AMDGPU::BI__builtin_amdgcn_image_gather4_lz_2d_v4f16_f32:
1117 *this, expr, "amdgcn.image.gather4.lz.2d", false);
1118 case AMDGPU::BI__builtin_amdgcn_mfma_scale_f32_16x16x128_f8f6f4:
1119 case AMDGPU::BI__builtin_amdgcn_mfma_scale_f32_32x32x64_f8f6f4: {
1120 cgm.errorNYI(expr->getSourceRange(),
1121 std::string("unimplemented AMDGPU builtin call: ") +
1122 getContext().BuiltinInfo.getName(builtinId));
1123 return mlir::Value{};
1124 }
1125 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32:
1126 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w32:
1127 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64:
1128 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w64:
1129 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w32:
1130 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w32:
1131 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w64:
1132 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w64:
1133 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32:
1134 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64:
1135 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w32:
1136 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w64:
1137 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32:
1138 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64:
1139 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32:
1140 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64:
1141 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32_gfx12:
1142 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64_gfx12:
1143 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w32_gfx12:
1144 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w64_gfx12:
1145 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32_gfx12:
1146 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64_gfx12:
1147 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w32_gfx12:
1148 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w64_gfx12:
1149 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32_gfx12:
1150 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64_gfx12:
1151 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12:
1152 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64_gfx12:
1153 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_fp8_w32_gfx12:
1154 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_fp8_w64_gfx12:
1155 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_bf8_w32_gfx12:
1156 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_bf8_w64_gfx12:
1157 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_fp8_w32_gfx12:
1158 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_fp8_w64_gfx12:
1159 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_bf8_w32_gfx12:
1160 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_bf8_w64_gfx12:
1161 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x32_iu4_w32_gfx12:
1162 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x32_iu4_w64_gfx12: {
1163 cgm.errorNYI(expr->getSourceRange(),
1164 std::string("unimplemented AMDGPU builtin call: ") +
1165 getContext().BuiltinInfo.getName(builtinId));
1166 return mlir::Value{};
1167 }
1168 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_f16_w32:
1169 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_f16_w64:
1170 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w32:
1171 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w64:
1172 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x32_f16_w32:
1173 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x32_f16_w64:
1174 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w32:
1175 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w64:
1176 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w32:
1177 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w64:
1178 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w32:
1179 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w64:
1180 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w32:
1181 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w64:
1182 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w32:
1183 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w64:
1184 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w32:
1185 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w64:
1186 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w32:
1187 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w64:
1188 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w32:
1189 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w64: {
1190 cgm.errorNYI(expr->getSourceRange(),
1191 std::string("unimplemented AMDGPU builtin call: ") +
1192 getContext().BuiltinInfo.getName(builtinId));
1193 return mlir::Value{};
1194 }
1195 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x4_f32:
1196 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x32_bf16:
1197 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x32_f16:
1198 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x32_f16:
1199 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x32_bf16:
1200 case AMDGPU::BI__builtin_amdgcn_wmma_bf16f32_16x16x32_bf16:
1201 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_fp8_fp8:
1202 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_fp8_bf8:
1203 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_bf8_fp8:
1204 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_bf8_bf8:
1205 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_fp8_fp8:
1206 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_fp8_bf8:
1207 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_bf8_fp8:
1208 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_bf8_bf8:
1209 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8:
1210 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8:
1211 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8:
1212 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8:
1213 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8:
1214 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8:
1215 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8:
1216 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8:
1217 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x64_iu8:
1218 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_f8f6f4:
1219 case AMDGPU::BI__builtin_amdgcn_wmma_f32_32x16x128_f4:
1220 case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4:
1221 case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4:
1222 case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_32x16x128_f4:
1223 case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4: {
1224 cgm.errorNYI(expr->getSourceRange(),
1225 std::string("unimplemented AMDGPU builtin call: ") +
1226 getContext().BuiltinInfo.getName(builtinId));
1227 return mlir::Value{};
1228 }
1229 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_f16:
1230 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_bf16:
1231 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x64_f16:
1232 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x64_bf16:
1233 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16f32_16x16x64_bf16:
1234 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_fp8_fp8:
1235 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_fp8_bf8:
1236 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_bf8_fp8:
1237 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_bf8_bf8:
1238 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_fp8_fp8:
1239 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_fp8_bf8:
1240 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_bf8_fp8:
1241 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_bf8_bf8:
1242 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x128_iu8: {
1243 cgm.errorNYI(expr->getSourceRange(),
1244 std::string("unimplemented AMDGPU builtin call: ") +
1245 getContext().BuiltinInfo.getName(builtinId));
1246 return mlir::Value{};
1247 }
1248 // amdgcn workgroup size
1249 case AMDGPU::BI__builtin_amdgcn_workgroup_size_x:
1250 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 0);
1251 case AMDGPU::BI__builtin_amdgcn_workgroup_size_y:
1252 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 1);
1253 case AMDGPU::BI__builtin_amdgcn_workgroup_size_z:
1254 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 2);
1255 // amdgcn grid size
1256 case AMDGPU::BI__builtin_amdgcn_grid_size_x:
1257 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 0);
1258 case AMDGPU::BI__builtin_amdgcn_grid_size_y:
1259 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 1);
1260 case AMDGPU::BI__builtin_amdgcn_grid_size_z:
1261 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 2);
1262 case AMDGPU::BI__builtin_r600_recipsqrt_ieee:
1263 case AMDGPU::BI__builtin_r600_recipsqrt_ieeef: {
1264 cgm.errorNYI(expr->getSourceRange(),
1265 std::string("unimplemented AMDGPU builtin call: ") +
1266 getContext().BuiltinInfo.getName(builtinId));
1267 return mlir::Value{};
1268 }
1269 case AMDGPU::BI__builtin_amdgcn_alignbit: {
1270 cgm.errorNYI(expr->getSourceRange(),
1271 std::string("unimplemented AMDGPU builtin call: ") +
1272 getContext().BuiltinInfo.getName(builtinId));
1273 return mlir::Value{};
1274 }
1275 case AMDGPU::BI__builtin_amdgcn_fence: {
1276 // The scope uses AMDGPU spelling on every target, like mapScopeToSPIRV.
1277 const llvm::Triple &triple = getTarget().getTriple();
1278 std::optional<std::pair<llvm::AtomicScope, bool>> parsed;
1279 if (std::optional<std::string> name =
1280 expr->getArg(1)->tryEvaluateString(getContext())) {
1281 parsed = llvm::parseAtomicScopeIRString(llvm::Triple("amdgcn-amd-amdhsa"),
1282 *name);
1283 if (!parsed && triple.isSPIRV())
1284 parsed = llvm::parseAtomicScopeIRString(triple, *name);
1285 }
1286 // SPIR-V drops one-as, AMDGPU needs a CIR sync scope for it.
1287 if (!parsed || (parsed->second && !triple.isSPIRV())) {
1288 cgm.errorNYI(expr->getSourceRange(), "__builtin_amdgcn_fence scope");
1289 return mlir::Value{};
1290 }
1291 // Sorted and unique, like MMRAMetadata::appendTags.
1293 addrSpaces.reserve(expr->getNumArgs() - 2);
1294 for (unsigned i = 2; i < expr->getNumArgs(); ++i) {
1295 if (std::optional<std::string> as =
1296 expr->getArg(i)->tryEvaluateString(getContext()))
1297 addrSpaces.push_back(std::move(*as));
1298 else
1299 cgm.error(expr->getExprLoc(),
1300 "expected an address space name as a string literal");
1301 }
1302 llvm::sort(addrSpaces);
1303 addrSpaces.erase(llvm::unique(addrSpaces), addrSpaces.end());
1305 mmras.reserve(addrSpaces.size());
1306 for (const std::string &as : addrSpaces)
1307 mmras.push_back(mlir::LLVM::MMRATagAttr::get(
1308 &getMLIRContext(), "amdgpu-synchronize-as", as));
1309
1310 auto fence = cir::AtomicFenceOp::create(
1311 builder, getLoc(expr->getExprLoc()),
1312 decodeAtomicOrder(expr->getArg(0), getContext()),
1313 cir::SyncScopeKindAttr::get(&getMLIRContext(),
1314 convertAtomicScopeToCIR(parsed->first)));
1315 if (!mmras.empty())
1316 fence->setAttr(mlir::LLVM::LLVMDialect::getMmraAttrName(),
1317 mmras.size() == 1 ? mmras.front()
1318 : builder.getArrayAttr(mmras));
1319 return mlir::Value{};
1320 }
1321 case AMDGPU::BI__builtin_amdgcn_atomic_inc32:
1322 case AMDGPU::BI__builtin_amdgcn_atomic_inc64:
1323 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::UIncWrap,
1324 /*hasVolatileArg=*/false);
1325 case AMDGPU::BI__builtin_amdgcn_atomic_dec32:
1326 case AMDGPU::BI__builtin_amdgcn_atomic_dec64:
1327 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::UDecWrap,
1328 /*hasVolatileArg=*/false);
1329 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f64:
1330 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f32:
1331 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32:
1332 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64:
1333 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f32:
1334 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f64:
1335 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Add,
1336 /*hasVolatileArg=*/false);
1337 case AMDGPU::BI__builtin_amdgcn_global_atomic_fmin_f64:
1338 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmin_f64:
1339 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Min,
1340 /*hasVolatileArg=*/false);
1341 case AMDGPU::BI__builtin_amdgcn_global_atomic_fmax_f64:
1342 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmax_f64:
1343 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Max,
1344 /*hasVolatileArg=*/false);
1345 // The ds_ float forms are the same operations with the volatile flag spelled
1346 // out as an argument.
1347 case AMDGPU::BI__builtin_amdgcn_ds_faddf:
1348 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Add,
1349 /*hasVolatileArg=*/true);
1350 case AMDGPU::BI__builtin_amdgcn_ds_fminf:
1351 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Min,
1352 /*hasVolatileArg=*/true);
1353 case AMDGPU::BI__builtin_amdgcn_ds_fmaxf:
1354 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Max,
1355 /*hasVolatileArg=*/true);
1356 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2f16:
1357 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16:
1358 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16:
1359 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_v2f16:
1360 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2bf16:
1361 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_v2bf16: {
1362 cgm.errorNYI(expr->getSourceRange(),
1363 std::string("unimplemented AMDGPU builtin call: ") +
1364 getContext().BuiltinInfo.getName(builtinId));
1365 return mlir::Value{};
1366 }
1367 case AMDGPU::BI__builtin_amdgcn_s_sendmsg_rtn:
1368 case AMDGPU::BI__builtin_amdgcn_s_sendmsg_rtnl:
1369 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.s.sendmsg.rtn",
1370 convertType(expr->getType()))
1371 .getValue();
1372 case AMDGPU::BI__builtin_amdgcn_permlane16_swap:
1373 case AMDGPU::BI__builtin_amdgcn_permlane32_swap: {
1374 cgm.errorNYI(expr->getSourceRange(),
1375 std::string("unimplemented AMDGPU builtin call: ") +
1376 getContext().BuiltinInfo.getName(builtinId));
1377 return mlir::Value{};
1378 }
1379 case AMDGPU::BI__builtin_amdgcn_bitop3_b32:
1380 case AMDGPU::BI__builtin_amdgcn_bitop3_b16:
1381 return emitBuiltinWithOneOverloadedType<4>(expr, "amdgcn.bitop3")
1382 .getValue();
1383 case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: {
1384 cgm.errorNYI(expr->getSourceRange(),
1385 std::string("unimplemented AMDGPU builtin call: ") +
1386 getContext().BuiltinInfo.getName(builtinId));
1387 return mlir::Value{};
1388 }
1389 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b8:
1390 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b16:
1391 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b32:
1392 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b64:
1393 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b96:
1394 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b128: {
1395 cgm.errorNYI(expr->getSourceRange(),
1396 std::string("unimplemented AMDGPU builtin call: ") +
1397 getContext().BuiltinInfo.getName(builtinId));
1398 return mlir::Value{};
1399 }
1400 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_format_v4f32:
1401 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_format_v4f16:
1403 expr, "amdgcn.raw.ptr.buffer.store.format",
1404 cir::VoidType::get(builder.getContext()))
1405 .getValue();
1406 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_format_v4f32:
1407 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_format_v4f16:
1409 expr, "amdgcn.raw.ptr.buffer.load.format",
1410 convertType(expr->getType()))
1411 .getValue();
1412 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b8:
1413 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b16:
1414 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b32:
1415 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b64:
1416 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b96:
1417 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b128: {
1418 cgm.errorNYI(expr->getSourceRange(),
1419 std::string("unimplemented AMDGPU builtin call: ") +
1420 getContext().BuiltinInfo.getName(builtinId));
1421 return mlir::Value{};
1422 }
1423 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32:
1425 expr, "amdgcn.raw.ptr.buffer.atomic.add")
1426 .getValue();
1427 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32:
1428 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f64:
1429 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16:
1431 expr, "amdgcn.raw.ptr.buffer.atomic.fadd")
1432 .getValue();
1433 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32:
1434 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64:
1436 expr, "amdgcn.raw.ptr.buffer.atomic.fmin")
1437 .getValue();
1438 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32:
1439 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64:
1441 expr, "amdgcn.raw.ptr.buffer.atomic.fmax")
1442 .getValue();
1443 case AMDGPU::BI__builtin_amdgcn_s_prefetch_data:
1445 expr, "amdgcn.s.prefetch.data",
1446 cir::VoidType::get(builder.getContext()))
1447 .getValue();
1448 case AMDGPU::BI__builtin_amdgcn_s_prefetch_inst:
1450 expr, "amdgcn.s.prefetch.inst",
1451 cir::VoidType::get(builder.getContext()))
1452 .getValue();
1453 case Builtin::BIlogbf:
1454 case Builtin::BI__builtin_logbf:
1455 return emitLogbBuiltin(*this, expr, llvm::APFloat::IEEEsingle());
1456 case Builtin::BIlogb:
1457 case Builtin::BI__builtin_logb:
1458 return emitLogbBuiltin(*this, expr, llvm::APFloat::IEEEdouble());
1459 case Builtin::BIscalbnf:
1460 case Builtin::BI__builtin_scalbnf:
1461 case Builtin::BIscalbn:
1462 case Builtin::BI__builtin_scalbn: {
1464 *this, expr, "ldexp", "experimental.constrained.ldexp");
1465 }
1466 default:
1467 return std::nullopt;
1468 }
1469}
static mlir::Value emitAMDGPUWorkGroupID(CIRGenFunction &cgf, mlir::Location loc, unsigned index)
static mlir::Value emitLogbBuiltin(CIRGenFunction &cgf, const CallExpr *e, const llvm::fltSemantics &fSem)
static mlir::Value emitAMDGCNImageOverloadedReturnType(CIRGenFunction &cgf, const CallExpr *e, llvm::StringRef intrinsicName, bool isImageStore)
static mlir::Value emitAMDGPUWorkGroupSizeV5(CIRGenFunction &cgf, mlir::Location loc, unsigned index)
static mlir::Value emitAMDGPUInvariantLoad(CIRGenFunction &cgf, mlir::Location loc, mlir::Value base, mlir::Value offset, mlir::Type ty, CharUnits align)
static cir::SyncScopeKind convertAtomicScopeToCIR(llvm::AtomicScope scope)
static mlir::Value emitAMDGPUImplicitArgPtr(CIRGenFunction &cgf, mlir::Location loc)
static mlir::Value emitAMDGPUGridSize(CIRGenFunction &cgf, mlir::Location loc, unsigned index)
static mlir::Value emitAMDGPUWorkGroupSizeV4(CIRGenFunction &cgf, mlir::Location loc, unsigned index)
static mlir::Value emitAMDGPUWorkGroupSize(CIRGenFunction &cgf, mlir::Location loc, unsigned index)
static cir::SyncScopeKind decodeAMDGPUSyncScope(const Expr *arg)
Map an AMDGPU sync-scope string-literal argument onto cir::SyncScopeKind.
static mlir::Value emitAMDGPUConstantPtrIntrinsic(CIRGenFunction &cgf, mlir::Location loc, llvm::StringRef name)
static mlir::Value emitAMDGPUAtomicRMW(CIRGenFunction &cgf, const CallExpr *expr, cir::AtomicFetchKind binOp, bool hasVolatileArg)
Emit one of the AMDGPU raw hardware atomic builtins as a cir.atomic.fetch.
static mlir::Value emitAMDGPUDispatchPtr(CIRGenFunction &cgf, mlir::Location loc, const CallExpr *e=nullptr)
static cir::MemOrder decodeAtomicOrder(const Expr *arg, ASTContext &ctx)
Map a constant integral to memory order.
static mlir::Value emitBinaryExpMaybeConstrainedFPBuiltin(CIRGenFunction &cgf, const CallExpr *e, llvm::StringRef intrinsicName, llvm::StringRef constrainedIntrinsicName)
static QualType getPointeeType(const MemRegion *R)
Enumerates target-specific builtins in their own namespaces within namespace clang.
mlir::Value createSub(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::None)
mlir::Value createNSWAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
cir::PtrStrideOp createPtrStride(mlir::Location loc, mlir::Value base, mlir::Value stride)
cir::GetGlobalOp createGetGlobal(mlir::Location loc, cir::GlobalOp global, bool threadLocal=false)
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy)
cir::CmpOp createCompare(mlir::Location loc, cir::CmpOpKind kind, mlir::Value lhs, mlir::Value rhs)
mlir::Value createSelect(mlir::Location loc, mlir::Value condition, mlir::Value trueValue, mlir::Value falseValue)
mlir::Value createMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowBehavior ob=OverflowBehavior::None)
cir::ConstantOp getConstantInt(mlir::Location loc, mlir::Type ty, int64_t value)
cir::PointerType getVoidPtrTy(clang::LangAS langAS=clang::LangAS::Default)
bool getIsFPConstrained() const
Query for the use of constrained floating point math.
mlir::Value createAddrSpaceCast(mlir::Location loc, mlir::Value src, mlir::Type newTy)
C++ view class that accepts both !cir.struct and !cir.union types.
Definition CIRTypes.h:150
static llvm::SmallVector< RecordMemberKind > getAllDataKinds(llvm::ArrayRef< mlir::Type > members)
One Data kind per member.
Definition CIRTypes.cpp:150
APSInt & getInt()
Definition APValue.h:573
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:245
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
CanQualType IntTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
@ GE_None
No error.
mlir::Type getElementType() const
Definition Address.h:125
mlir::Value emitRawPointer() const
Return the pointer contained in this class after authenticating it and adding offset to it if necessa...
Definition Address.h:112
cir::ConstantOp getUInt64(uint64_t c, mlir::Location loc)
mlir::Value emitIntrinsicCallOp(mlir::Location loc, const llvm::StringRef str, const mlir::Type &resTy, Operands &&...op)
cir::LoadOp createAlignedLoad(mlir::Location loc, mlir::Type ty, mlir::Value ptr, llvm::MaybeAlign align)
cir::StructType getAnonRecordTy(llvm::ArrayRef< mlir::Type > members, bool packed, llvm::ArrayRef< cir::RecordMemberKind > memberKinds)
Get a CIR anonymous struct type.
mlir::Type convertType(clang::QualType t)
Address emitPointerWithAlignment(const clang::Expr *expr, LValueBaseInfo *baseInfo=nullptr)
Given an expression with a pointer type, emit the value and compute our best estimate of the alignmen...
const clang::LangOptions & getLangOpts() const
const TargetInfo & getTarget() const
mlir::Location getLoc(clang::SourceLocation srcLoc)
Helpers to convert Clang's SourceLocation to a MLIR Location.
RValue emitBuiltinWithOneOverloadedType(const CallExpr *e, llvm::StringRef intrinName, mlir::Type resultType={})
Emit a simple LLVM intrinsic that takes N scalar arguments.
std::optional< mlir::Value > emitAMDGPUBuiltinExpr(unsigned builtinID, const CallExpr *expr)
Emit a call to an AMDGPU builtin function.
mlir::Value emitScalarExpr(const clang::Expr *e, bool ignoreResultAssign=false)
Emit the computation of the specified expression of scalar type.
CIRGenBuilderTy & getBuilder()
cir::FuncType getIntrinsicType(llvm::Intrinsic::ID id, llvm::ArrayRef< mlir::Type > overloadTys={})
Return the CIR signature of the LLVM intrinsic id, resolving its overloaded types to overloadTys.
mlir::MLIRContext & getMLIRContext()
clang::ASTContext & getContext() const
mlir::Value emitScalarOrConstFoldImmArg(unsigned iceArguments, unsigned idx, const Expr *argExpr)
This class organizes the cross-function state that is used while generating CIR code.
DiagnosticBuilder errorNYI(SourceLocation, llvm::StringRef)
Helpers to emit "not yet implemented" error diagnostics.
cir::GlobalOp createGlobalOp(mlir::Location loc, llvm::StringRef name, mlir::Type t, bool isConstant=false, mlir::ptr::MemorySpaceAttrInterface addrSpace={}, mlir::Operation *insertPoint=nullptr)
mlir::Operation * getGlobalValue(llvm::StringRef ref)
mlir::MLIRContext & getMLIRContext()
mlir::Value getValue() const
Return the value of this scalar value.
Definition CIRGenValue.h:57
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition Expr.h:3012
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition Expr.h:3216
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Definition Expr.h:3203
This is an opaque type for sizes expressed in character units.
Definition CharUnits.h:38
static CharUnits fromQuantity(QuantityType Quantity)
Construct a CharUnits quantity from a raw integer type.
Definition CharUnits.h:58
This represents one expression.
Definition Expr.h:114
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Definition Expr.cpp:283
QualType getType() const
Definition Expr.h:146
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition TypeBase.h:3403
A (possibly-)qualified type.
Definition TypeBase.h:938
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
Definition TypeBase.h:8530
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition Stmt.cpp:343
TargetOptions & getTargetOpts() const
Retrieve the target options.
Definition TargetInfo.h:334
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
llvm::CodeObjectVersionKind CodeObjectVersion
Code object version for AMDGPU.
const T * castAs() const
Member-template castAs<specific type>.
Definition TypeBase.h:9366
mlir::ptr::MemorySpaceAttrInterface toCIRAddressSpaceAttr(mlir::MLIRContext &ctx, clang::LangAS langAS)
Convert an AST LangAS to the appropriate CIR address space attribute interface.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
Top level wrappers for InstallAPI frontend operations.
static bool opCallAttrs()
static bool opLoadRangeNoundefMetadata()
EvalResult is a struct with detailed info about an evaluated expression.
Definition Expr.h:667
APValue Val
Val - This is the value the expression can be folded to.
Definition Expr.h:669
#define exp(__x)
Definition tgmath.h:431
#define fabs(__x)
Definition tgmath.h:549
#define remainder(__x, __y)
Definition tgmath.h:1090