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 mlir::Type origTy = val.getType();
128 if (auto vecTy = mlir::dyn_cast<cir::VectorType>(origTy);
129 vecTy && mlir::isa<cir::IntType>(vecTy.getElementType())) {
130 auto bf16VecTy =
131 cir::VectorType::get(builder.getBfloat16Ty(), vecTy.getSize());
132 val = builder.createBitcast(loc, val, bf16VecTy);
133 ptr = ptr.withElementType(builder, bf16VecTy);
134 }
135
136 auto rmw = cir::AtomicFetchOp::create(builder, loc, ptr.emitRawPointer(), val,
137 binOp, order, scope, isVolatile,
138 /*fetch_first=*/true);
139 rmw->setAttr(cir::CIRDialect::getAMDGPURawAtomicAttrName(),
140 builder.getUnitAttr());
141 return builder.createBitcast(loc, rmw->getResult(0), origTy);
142}
143
144// Emit the `amdgcn.dispatch.ptr` intrinsic, address-space-casting the
145// result to match \p e's return type when needed.
146// If \p e is null, returns the raw AS-4 pointer.
147static mlir::Value emitAMDGPUDispatchPtr(CIRGenFunction &cgf,
148 mlir::Location loc,
149 const CallExpr *e = nullptr) {
150 CIRGenBuilderTy &builder = cgf.getBuilder();
151 mlir::Value call =
152 emitAMDGPUConstantPtrIntrinsic(cgf, loc, "amdgcn.dispatch.ptr");
153 if (!e)
154 return call;
155 // Only cast when the caller-visible AS differs from the intrinsic's AS;
156 auto expectedPtrTy =
157 mlir::cast<cir::PointerType>(cgf.convertType(e->getType()));
158 auto callPtrTy = mlir::cast<cir::PointerType>(call.getType());
159 if (expectedPtrTy.getAddrSpace() == callPtrTy.getAddrSpace())
160 return call;
161 return builder.createAddrSpaceCast(loc, call, expectedPtrTy);
162}
163
165 mlir::Location loc) {
166 // OG also marks the result align 8 dereferenceable(256).
168 return emitAMDGPUConstantPtrIntrinsic(cgf, loc, "amdgcn.implicitarg.ptr");
169}
170
171static mlir::Value emitAMDGPUWorkGroupID(CIRGenFunction &cgf,
172 mlir::Location loc, unsigned index) {
173 static constexpr llvm::StringLiteral names[] = {"amdgcn.workgroup.id.x",
174 "amdgcn.workgroup.id.y",
175 "amdgcn.workgroup.id.z"};
176 CIRGenBuilderTy &builder = cgf.getBuilder();
177 return builder.emitIntrinsicCallOp(loc, names[index], builder.getUInt32Ty(),
178 mlir::ValueRange{});
179}
180
181// Load a \p ty value at byte \p offset from \p base as an invariant load.
183 mlir::Location loc, mlir::Value base,
184 mlir::Value offset, mlir::Type ty,
185 CharUnits align) {
186 CIRGenBuilderTy &builder = cgf.getBuilder();
187 mlir::Value addr = builder.createPtrStride(loc, base, offset);
188 cir::LoadOp load = builder.createAlignedLoad(loc, ty, addr, align);
189 load.setInvariant(true);
191 return load;
192}
193
194static mlir::Value emitAMDGPUGridSize(CIRGenFunction &cgf, mlir::Location loc,
195 unsigned index) {
196 CIRGenBuilderTy &builder = cgf.getBuilder();
197 const unsigned xOffset = 12;
198 mlir::Value dispatchPtr = emitAMDGPUDispatchPtr(cgf, loc);
199 // Indexing the HSA kernel_dispatch_packet struct.
201 cgf, loc, dispatchPtr, builder.getUInt64(xOffset + index * 4, loc),
203}
204
206 mlir::Location loc,
207 unsigned index) {
208 CIRGenBuilderTy &builder = cgf.getBuilder();
209 mlir::Value implicitArgPtr = emitAMDGPUImplicitArgPtr(cgf, loc);
210
211 // offsetof(amdhsa_implicit_kernarg_v5, block_count[index])
212 unsigned blockCountOffset = 0 + index * 4;
213 // offsetof(amdhsa_implicit_kernarg_v5, group_size[index])
214 unsigned groupSizeOffset = 12 + index * 2;
215 // offsetof(amdhsa_implicit_kernarg_v5, remainder[index])
216 unsigned remainderOffset = 18 + index * 2;
217
218 mlir::Value sizeOffset;
219 if (cgf.getLangOpts().OffloadUniformBlock) {
220 sizeOffset = builder.getUInt64(groupSizeOffset, loc);
221 } else {
222 mlir::Value blockCount = emitAMDGPUInvariantLoad(
223 cgf, loc, implicitArgPtr, builder.getUInt64(blockCountOffset, loc),
225 mlir::Value workgroupID = emitAMDGPUWorkGroupID(cgf, loc, index);
226 mlir::Value isFull =
227 builder.createCompare(loc, cir::CmpOpKind::lt, workgroupID, blockCount);
228 sizeOffset = builder.createSelect(loc, isFull,
229 builder.getUInt64(groupSizeOffset, loc),
230 builder.getUInt64(remainderOffset, loc));
231 }
232
233 mlir::Value size = emitAMDGPUInvariantLoad(cgf, loc, implicitArgPtr,
234 sizeOffset, builder.getUInt16Ty(),
236 return builder.createIntCast(size, builder.getUInt32Ty());
237}
238
240 mlir::Location loc,
241 unsigned index) {
242 CIRGenBuilderTy &builder = cgf.getBuilder();
243 mlir::Value dispatchPtr = emitAMDGPUDispatchPtr(cgf, loc);
244
245 // Indexing the HSA kernel_dispatch_packet struct.
246 mlir::Value groupSizeLd = emitAMDGPUInvariantLoad(
247 cgf, loc, dispatchPtr, builder.getUInt64(4 + index * 2, loc),
249 mlir::Value groupSize =
250 builder.createIntCast(groupSizeLd, builder.getUInt32Ty());
251
252 if (cgf.getLangOpts().OffloadUniformBlock)
253 return groupSize;
254
255 mlir::Value workgroupID = emitAMDGPUWorkGroupID(cgf, loc, index);
256 mlir::Value gridSize = emitAMDGPUInvariantLoad(
257 cgf, loc, dispatchPtr, builder.getUInt64(12 + index * 4, loc),
259 mlir::Value mul = builder.createMul(loc, workgroupID, groupSize);
260 mlir::Value remainder = builder.createSub(loc, gridSize, mul);
261 mlir::Value isPartial =
262 builder.createCompare(loc, cir::CmpOpKind::lt, remainder, groupSize);
263 return builder.createSelect(loc, isPartial, remainder, groupSize);
264}
265
266// \p index is 0, 1, and 2 for x, y, and z dimension, respectively.
267// Emit code based on Code Object ABI version.
268// COV_4 : Emit code to use dispatch ptr
269// COV_5+ : Emit code to use implicitarg ptr
270// COV_NONE : Emit code to load a global variable "__oclc_ABI_version"
271// and use its value for COV_4 or COV_5+ approach. It is used for
272// compiling device libraries in an ABI-agnostic way.
274 mlir::Location loc, unsigned index) {
275 llvm::CodeObjectVersionKind cov =
277
278 // Do not emit __oclc_ABI_version references with non-empty environment.
279 if (cov == llvm::CodeObjectVersionKind::COV_None &&
280 cgf.getTarget().getTriple().hasEnvironment())
281 cov = llvm::CodeObjectVersionKind::COV_6;
282
283 if (cov != llvm::CodeObjectVersionKind::COV_None)
284 return cov >= llvm::CodeObjectVersionKind::COV_5
286 : emitAMDGPUWorkGroupSizeV4(cgf, loc, index);
287
288 CIRGenBuilderTy &builder = cgf.getBuilder();
289 CIRGenModule &cgm = cgf.cgm;
290 StringRef name = "__oclc_ABI_version";
291 mlir::Type int32Ty = builder.getSInt32Ty();
292 auto abiVersionGV =
293 mlir::dyn_cast_or_null<cir::GlobalOp>(cgm.getGlobalValue(name));
294 if (!abiVersionGV)
295 abiVersionGV =
296 cgm.createGlobalOp(loc, name, int32Ty, /*isConstant=*/false,
299 mlir::Value abiVersionPtr = builder.createGetGlobal(loc, abiVersionGV);
300 mlir::Value abiVersion = builder.createAlignedLoad(
301 loc, int32Ty, abiVersionPtr,
303 mlir::Value isCOV5 = builder.createCompare(
304 loc, cir::CmpOpKind::ge, abiVersion,
305 builder.getConstantInt(loc, int32Ty, llvm::CodeObjectVersionKind::COV_5));
306 mlir::Value v5Impl = emitAMDGPUWorkGroupSizeV5(cgf, loc, index);
307 mlir::Value v4Impl = emitAMDGPUWorkGroupSizeV4(cgf, loc, index);
308 return builder.createSelect(loc, isCOV5, v5Impl, v4Impl);
309}
310
312 CIRGenFunction &cgf, const CallExpr *e, llvm::StringRef intrinsicName,
313 llvm::StringRef constrainedIntrinsicName) {
314 mlir::Value src0 = cgf.emitScalarExpr(e->getArg(0));
315 mlir::Value src1 = cgf.emitScalarExpr(e->getArg(1));
316 mlir::Location loc = cgf.getLoc(e->getExprLoc());
317
318 CIRGenBuilderTy &builder = cgf.getBuilder();
319
320 CIRGenFunction::CIRGenFPOptionsRAII fpOptsRAII(cgf, e);
321
322 if (builder.getIsFPConstrained()) {
323 cgf.cgm.errorNYI(e->getSourceRange(),
324 "constrained FP intrinsic support is NYI.");
325 }
326
327 return builder.emitIntrinsicCallOp(loc, intrinsicName, src0.getType(),
328 mlir::ValueRange{src0, src1});
329}
330
331static mlir::Value emitLogbBuiltin(CIRGenFunction &cgf, const CallExpr *e,
332 const llvm::fltSemantics &fSem) {
333 CIRGenBuilderTy &builder = cgf.getBuilder();
334 mlir::Location loc = cgf.getLoc(e->getExprLoc());
335
336 mlir::Value src0 = cgf.emitScalarExpr(e->getArg(0));
337 mlir::Type srcTy = src0.getType();
338 mlir::Type int32Ty = builder.getSInt32Ty();
339
340 mlir::Type frExpResMembers[] = {srcTy, int32Ty};
341 cir::RecordType frExpResTy = builder.getAnonRecordTy(
342 frExpResMembers, /*packed=*/false,
343 cir::RecordType::getAllDataKinds(frExpResMembers));
344
345 mlir::Value frExpResult = builder.emitIntrinsicCallOp(
346 loc, "frexp", frExpResTy, mlir::ValueRange{src0});
347
348 mlir::Value exp =
349 cir::ExtractMemberOp::create(builder, loc, int32Ty, frExpResult, 1);
350
351 mlir::Value negativeOne =
352 builder.getConstant(loc, cir::IntAttr::get(int32Ty, -1));
353 mlir::Value expMinus1 = builder.createNSWAdd(loc, exp, negativeOne);
354
355 mlir::Value siToFp = cir::CastOp::create(
356 builder, loc, srcTy, cir::CastKind::int_to_float, expMinus1);
357
358 mlir::Value fabs = cir::FAbsOp::create(builder, loc, src0);
359
360 llvm::APFloat infVal = llvm::APFloat::getInf(fSem);
361 mlir::Value inf = builder.getConstant(loc, cir::FPAttr::get(srcTy, infVal));
362
363 mlir::Value fabsNegInf =
364 builder.createCompare(loc, cir::CmpOpKind::one, fabs, inf);
365
366 mlir::Value sel = builder.createSelect(loc, fabsNegInf, siToFp, fabs);
367
368 llvm::APFloat zeroValue = llvm::APFloat::getZero(fSem);
369 mlir::Value zero =
370 builder.getConstant(loc, cir::FPAttr::get(srcTy, zeroValue));
371
372 mlir::Value srcEqZero =
373 builder.createCompare(loc, cir::CmpOpKind::eq, src0, zero);
374
375 llvm::APFloat negInfVal = llvm::APFloat::getInf(fSem, true);
376 mlir::Value negInf =
377 builder.getConstant(loc, cir::FPAttr::get(srcTy, negInfVal));
378
379 mlir::Value res = builder.createSelect(loc, srcEqZero, negInf, sel);
380
381 return res;
382}
383
384static mlir::Value
386 llvm::StringRef intrinsicName,
387 bool isImageStore) {
388 auto &builder = cgf.getBuilder();
389
391 for (unsigned i = 0, n = e->getNumArgs(); i < n; ++i)
392 args.push_back(cgf.emitScalarExpr(e->getArg(i)));
393
394 mlir::Type retTy = isImageStore ? cir::VoidType::get(builder.getContext())
395 : cgf.convertType(e->getType());
396
397 auto callOp = cir::LLVMIntrinsicCallOp::create(
398 builder, cgf.getLoc(e->getExprLoc()),
399 builder.getStringAttr(intrinsicName), retTy, args);
400
401 return callOp.getResult();
402}
403
404static mlir::Value emitAMDGPUPredicate(CIRGenFunction &cgf, const CallExpr *e,
405 const llvm::Twine &name) {
406 CIRGenBuilderTy &builder = cgf.getBuilder();
407 mlir::Location loc = cgf.getLoc(e->getExprLoc());
408 mlir::Value result = cir::AMDGPUFeaturePredicateOp::create(
409 builder, loc, builder.getBoolTy(), builder.getStringAttr(name));
410 // Sema retypes the call to the logical operation type, which is int in C.
411 return builder.createBoolToInt(result, cgf.convertType(e->getType()));
412}
413
414std::optional<mlir::Value>
416 const CallExpr *expr) {
417 switch (builtinId) {
418 case AMDGPU::BI__builtin_amdgcn_wave_reduce_add_u32:
419 case AMDGPU::BI__builtin_amdgcn_wave_reduce_sub_u32:
420 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_i32:
421 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_u32:
422 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_i32:
423 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_u32:
424 case AMDGPU::BI__builtin_amdgcn_wave_reduce_and_b32:
425 case AMDGPU::BI__builtin_amdgcn_wave_reduce_or_b32:
426 case AMDGPU::BI__builtin_amdgcn_wave_reduce_xor_b32:
427 case AMDGPU::BI__builtin_amdgcn_wave_reduce_add_u64:
428 case AMDGPU::BI__builtin_amdgcn_wave_reduce_sub_u64:
429 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_i64:
430 case AMDGPU::BI__builtin_amdgcn_wave_reduce_min_u64:
431 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_i64:
432 case AMDGPU::BI__builtin_amdgcn_wave_reduce_max_u64:
433 case AMDGPU::BI__builtin_amdgcn_wave_reduce_and_b64:
434 case AMDGPU::BI__builtin_amdgcn_wave_reduce_or_b64:
435 case AMDGPU::BI__builtin_amdgcn_wave_reduce_xor_b64: {
436 cgm.errorNYI(expr->getSourceRange(),
437 std::string("unimplemented AMDGPU builtin call: ") +
438 getContext().BuiltinInfo.getName(builtinId));
439 return mlir::Value{};
440 }
441 case AMDGPU::BI__builtin_amdgcn_div_scale:
442 case AMDGPU::BI__builtin_amdgcn_div_scalef: {
443 Address flagOutPtr = emitPointerWithAlignment(expr->getArg(3));
444 llvm::StringRef intrinsicName = "amdgcn.div.scale";
445 mlir::Value x = emitScalarExpr(expr->getArg(0));
446 mlir::Value y = emitScalarExpr(expr->getArg(1));
447 mlir::Value z = emitScalarExpr(expr->getArg(2));
448
449 auto i1Ty = builder.getUIntNTy(1);
450 mlir::Type resMembers[] = {x.getType(), i1Ty};
451 cir::RecordType resTy =
452 builder.getAnonRecordTy(resMembers, /*packed=*/false,
454
455 mlir::Value structResult =
456 cir::LLVMIntrinsicCallOp::create(builder, getLoc(expr->getExprLoc()),
457 builder.getStringAttr(intrinsicName),
458 resTy, {x, y, z})
459 .getResult();
460
461 mlir::Value result = cir::ExtractMemberOp::create(
462 builder, getLoc(expr->getExprLoc()), x.getType(), structResult, 0);
463 mlir::Value flag = cir::ExtractMemberOp::create(
464 builder, getLoc(expr->getExprLoc()), i1Ty, structResult, 1);
465
466 mlir::Type flagType = flagOutPtr.getElementType();
467 mlir::Value flagToStore =
468 cir::CastOp::create(builder, getLoc(expr->getExprLoc()), flagType,
469 cir::CastKind::int_to_bool, flag);
470 builder.createStore(getLoc(expr->getExprLoc()), flagToStore, flagOutPtr);
471 return result;
472 }
473 case AMDGPU::BI__builtin_amdgcn_div_fmas:
474 case AMDGPU::BI__builtin_amdgcn_div_fmasf:
475 return emitBuiltinWithOneOverloadedType<4>(expr, "amdgcn.div.fmas")
476 .getValue();
477 case AMDGPU::BI__builtin_amdgcn_mov_dpp8:
478 case AMDGPU::BI__builtin_amdgcn_mov_dpp:
479 case AMDGPU::BI__builtin_amdgcn_update_dpp: {
480 mlir::Location loc = getLoc(expr->getExprLoc());
481 unsigned iceArguments = 0;
483 getContext().GetBuiltinType(builtinId, error, &iceArguments);
484 assert(error == ASTContext::GE_None && "Should not codegen an error");
485 assert(expr->getNumArgs() == 5 || expr->getNumArgs() == 6 ||
486 expr->getNumArgs() == 2);
487
488 mlir::Type dataTy = convertType(expr->getArg(0)->getType());
489 unsigned size = cgm.getDataLayout().getTypeSizeInBits(dataTy);
490 cir::IntType intTy = builder.getUIntNTy(std::max(size, 32u));
491
492 bool isMovDpp8 = builtinId == AMDGPU::BI__builtin_amdgcn_mov_dpp8;
493 bool isMovDpp = builtinId == AMDGPU::BI__builtin_amdgcn_mov_dpp;
494 bool isUpdateDpp = builtinId == AMDGPU::BI__builtin_amdgcn_update_dpp;
495 llvm::StringRef intrinsicName =
496 isMovDpp8 ? "amdgcn.mov.dpp8" : "amdgcn.update.dpp";
497 cir::FuncType intrinsicTy =
498 getIntrinsicType(isMovDpp8 ? llvm::Intrinsic::amdgcn_mov_dpp8
499 : llvm::Intrinsic::amdgcn_update_dpp,
500 {intTy});
501
502 auto coerceTo = [&](mlir::Value from, mlir::Type to) -> mlir::Value {
503 if (from.getType() == to)
504 return from;
505 if (mlir::isa<cir::IntType>(from.getType()) &&
506 mlir::isa<cir::IntType>(to))
507 return builder.createIntCast(from, to);
508 return builder.createBitcast(from, to);
509 };
510
512 // __builtin_amdgcn_mov_dpp has no "old" operand at the source level, but
513 // the real intrinsic it lowers to requires one, so we synthesize a poison
514 // value for it since it is never meaningfully read.
515 if (isMovDpp)
516 args.push_back(builder.getConstant(loc, cir::PoisonAttr::get(intTy)));
517
518 // Number of builtin-level leading args that need zero-extend promotion when
519 // the data type is narrower than 32 bits.
520 unsigned numPromotedArgs = isUpdateDpp ? 2u : 1u;
521 for (unsigned i = 0; i != expr->getNumArgs(); ++i) {
522 mlir::Value v =
523 emitScalarOrConstFoldImmArg(iceArguments, i, expr->getArg(i));
524 if (i < numPromotedArgs && size < 32) {
525 mlir::Type sameWidthUTy = builder.getUIntNTy(size);
526 if (v.getType() != sameWidthUTy)
527 v = builder.createBitcast(v, sameWidthUTy);
528 v = builder.createIntCast(v, intTy);
529 }
530 args.push_back(coerceTo(v, intrinsicTy.getInput(i + unsigned(isMovDpp))));
531 }
532
533 mlir::Value result = builder.emitIntrinsicCallOp(loc, intrinsicName, intTy,
534 mlir::ValueRange(args));
535 if (size < 32 && !mlir::isa<cir::IntType>(dataTy))
536 result = builder.createIntCast(result, builder.getUIntNTy(size));
537 return coerceTo(result, dataTy);
538 }
539 case AMDGPU::BI__builtin_amdgcn_permlane16:
540 case AMDGPU::BI__builtin_amdgcn_permlanex16: {
541 llvm::StringRef intrinsicName =
542 builtinId == AMDGPU::BI__builtin_amdgcn_permlane16
543 ? "amdgcn.permlane16"
544 : "amdgcn.permlanex16";
545 return emitBuiltinWithOneOverloadedType<6>(expr, intrinsicName).getValue();
546 }
547 case AMDGPU::BI__builtin_amdgcn_permlane64:
548 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.permlane64")
549 .getValue();
550 case AMDGPU::BI__builtin_amdgcn_permlane_bcast:
551 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.bcast")
552 .getValue();
553 case AMDGPU::BI__builtin_amdgcn_permlane_up:
554 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.up")
555 .getValue();
556 case AMDGPU::BI__builtin_amdgcn_permlane_down:
557 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.down")
558 .getValue();
559 case AMDGPU::BI__builtin_amdgcn_permlane_xor:
560 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.permlane.xor")
561 .getValue();
562 case AMDGPU::BI__builtin_amdgcn_readlane:
563 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.readlane")
564 .getValue();
565 case AMDGPU::BI__builtin_amdgcn_readfirstlane:
566 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.readfirstlane")
567 .getValue();
568 case AMDGPU::BI__builtin_amdgcn_wave_shuffle:
569 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.wave.shuffle")
570 .getValue();
571 case AMDGPU::BI__builtin_amdgcn_div_fixup:
572 case AMDGPU::BI__builtin_amdgcn_div_fixupf:
573 case AMDGPU::BI__builtin_amdgcn_div_fixuph: {
574 mlir::Value src0 = emitScalarExpr(expr->getArg(0));
575 mlir::Value src1 = emitScalarExpr(expr->getArg(1));
576 mlir::Value src2 = emitScalarExpr(expr->getArg(2));
577 return builder.emitIntrinsicCallOp(getLoc(expr->getExprLoc()),
578 "amdgcn.div.fixup", src0.getType(),
579 mlir::ValueRange{src0, src1, src2});
580 }
581 case AMDGPU::BI__builtin_amdgcn_trig_preop:
582 case AMDGPU::BI__builtin_amdgcn_trig_preopf:
583 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.trig.preop")
584 .getValue();
585 case AMDGPU::BI__builtin_amdgcn_rcp:
586 case AMDGPU::BI__builtin_amdgcn_rcpf:
587 case AMDGPU::BI__builtin_amdgcn_rcph:
588 case AMDGPU::BI__builtin_amdgcn_rcp_bf16: {
589 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rcp").getValue();
590 }
591 case AMDGPU::BI__builtin_amdgcn_sqrt:
592 case AMDGPU::BI__builtin_amdgcn_sqrtf:
593 case AMDGPU::BI__builtin_amdgcn_sqrth:
594 case AMDGPU::BI__builtin_amdgcn_sqrt_bf16: {
595 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.sqrt").getValue();
596 }
597 case AMDGPU::BI__builtin_amdgcn_rsq:
598 case AMDGPU::BI__builtin_amdgcn_rsqf:
599 case AMDGPU::BI__builtin_amdgcn_rsqh:
600 case AMDGPU::BI__builtin_amdgcn_rsq_bf16: {
601 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rsq").getValue();
602 }
603 case AMDGPU::BI__builtin_amdgcn_rsq_clamp:
604 case AMDGPU::BI__builtin_amdgcn_rsq_clampf: {
605 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.rsq.clamp")
606 .getValue();
607 }
608 case AMDGPU::BI__builtin_amdgcn_sinf:
609 case AMDGPU::BI__builtin_amdgcn_sinh:
610 case AMDGPU::BI__builtin_amdgcn_sin_bf16: {
611 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.sin").getValue();
612 }
613 case AMDGPU::BI__builtin_amdgcn_cosf:
614 case AMDGPU::BI__builtin_amdgcn_cosh:
615 case AMDGPU::BI__builtin_amdgcn_cos_bf16: {
616 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.cos").getValue();
617 }
618 case AMDGPU::BI__builtin_amdgcn_dispatch_ptr:
619 return emitAMDGPUDispatchPtr(*this, getLoc(expr->getExprLoc()), expr);
620 case AMDGPU::BI__builtin_amdgcn_logf:
621 case AMDGPU::BI__builtin_amdgcn_log_bf16: {
622 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.log").getValue();
623 }
624 case AMDGPU::BI__builtin_amdgcn_exp2f:
625 case AMDGPU::BI__builtin_amdgcn_exp2_bf16: {
626 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.exp2").getValue();
627 }
628 case AMDGPU::BI__builtin_amdgcn_log_clampf: {
629 cgm.errorNYI(expr->getSourceRange(),
630 std::string("unimplemented AMDGPU builtin call: ") +
631 getContext().BuiltinInfo.getName(builtinId));
632 return mlir::Value{};
633 }
634 case AMDGPU::BI__builtin_amdgcn_ldexp:
635 case AMDGPU::BI__builtin_amdgcn_ldexpf:
636 case AMDGPU::BI__builtin_amdgcn_ldexph: {
637 mlir::Value src0 = emitScalarExpr(expr->getArg(0));
638 mlir::Value src1 = emitScalarExpr(expr->getArg(1));
639 // For ldexph, the raw instruction has different behavior for out-of-bounds
640 // exponent values (implicit truncation instead of saturate to
641 // short_min/short_max), so truncate the exponent to i16 first.
642 mlir::Value exp =
643 builtinId == AMDGPU::BI__builtin_amdgcn_ldexph
644 ? cir::CastOp::create(builder, getLoc(expr->getExprLoc()),
645 builder.getSInt16Ty(),
646 cir::CastKind::integral, src1)
647 : src1;
648 return builder.emitIntrinsicCallOp(getLoc(expr->getExprLoc()), "ldexp",
649 src0.getType(),
650 mlir::ValueRange{src0, exp});
651 }
652 case AMDGPU::BI__builtin_amdgcn_frexp_mant:
653 case AMDGPU::BI__builtin_amdgcn_frexp_mantf:
654 case AMDGPU::BI__builtin_amdgcn_frexp_manth: {
655 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.frexp.mant")
656 .getValue();
657 }
658 case AMDGPU::BI__builtin_amdgcn_frexp_exp:
659 case AMDGPU::BI__builtin_amdgcn_frexp_expf:
660 case AMDGPU::BI__builtin_amdgcn_frexp_exph: {
661 cgm.errorNYI(expr->getSourceRange(),
662 std::string("unimplemented AMDGPU builtin call: ") +
663 getContext().BuiltinInfo.getName(builtinId));
664 return mlir::Value{};
665 }
666 case AMDGPU::BI__builtin_amdgcn_fract:
667 case AMDGPU::BI__builtin_amdgcn_fractf:
668 case AMDGPU::BI__builtin_amdgcn_fracth:
669 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.fract").getValue();
670 case AMDGPU::BI__builtin_amdgcn_lerp: {
671 cgm.errorNYI(expr->getSourceRange(),
672 std::string("unimplemented AMDGPU builtin call: ") +
673 getContext().BuiltinInfo.getName(builtinId));
674 return mlir::Value{};
675 }
676 case AMDGPU::BI__builtin_amdgcn_ubfe:
677 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.ubfe").getValue();
678 case AMDGPU::BI__builtin_amdgcn_sbfe:
679 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.sbfe").getValue();
680 case AMDGPU::BI__builtin_amdgcn_ballot_w32:
681 case AMDGPU::BI__builtin_amdgcn_ballot_w64:
682 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ballot",
683 convertType(expr->getType()))
684 .getValue();
685 case AMDGPU::BI__builtin_amdgcn_inverse_ballot_w32:
686 case AMDGPU::BI__builtin_amdgcn_inverse_ballot_w64:
687 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.inverse.ballot",
688 convertType(expr->getType()))
689 .getValue();
690 case AMDGPU::BI__builtin_amdgcn_tanhf:
691 case AMDGPU::BI__builtin_amdgcn_tanhh:
692 case AMDGPU::BI__builtin_amdgcn_tanh_bf16: {
693 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.tanh").getValue();
694 }
695 case AMDGPU::BI__builtin_amdgcn_uicmp:
696 case AMDGPU::BI__builtin_amdgcn_uicmpl:
697 case AMDGPU::BI__builtin_amdgcn_sicmp:
698 case AMDGPU::BI__builtin_amdgcn_sicmpl:
699 case AMDGPU::BI__builtin_amdgcn_fcmp:
700 case AMDGPU::BI__builtin_amdgcn_fcmpf: {
701 mlir::Value lhs = emitScalarExpr(expr->getArg(0));
702 mlir::Value rhs = emitScalarExpr(expr->getArg(1));
703
704 uint64_t imm =
705 expr->getArg(2)->EvaluateKnownConstInt(getContext()).getZExtValue();
706
707 cir::CmpOpKind pred;
708 switch (imm) {
709 case 0x1: // FCMP_OEQ
710 case 0x20: // ICMP_EQ
711 pred = cir::CmpOpKind::eq;
712 break;
713 case 0xe: // FCMP_UNE
714 case 0x21: // ICMP_NE
715 pred = cir::CmpOpKind::ne;
716 break;
717 case 0x2: // FCMP_OGT
718 case 0x22: // ICMP_UGT
719 case 0x26: // ICMP_SGT
720 pred = cir::CmpOpKind::gt;
721 break;
722 case 0x3: // FCMP_OGE
723 case 0x23: // ICMP_UGE
724 case 0x27: // ICMP_SGE
725 pred = cir::CmpOpKind::ge;
726 break;
727 case 0x4: // FCMP_OLT
728 case 0x24: // ICMP_ULT
729 case 0x28: // ICMP_SLT
730 pred = cir::CmpOpKind::lt;
731 break;
732 case 0x5: // FCMP_OLE
733 case 0x25: // ICMP_ULE
734 case 0x29: // ICMP_SLE
735 pred = cir::CmpOpKind::le;
736 break;
737 case 0x6: // FCMP_ONE
738 pred = cir::CmpOpKind::one;
739 break;
740 case 0x8: // FCMP_UNO
741 pred = cir::CmpOpKind::uno;
742 break;
743 default:
744 cgm.errorNYI(expr->getSourceRange(),
745 "amdgcn compare with unsupported predicate");
746 return mlir::Value{};
747 }
748
749 mlir::Location loc = getLoc(expr->getExprLoc());
750 mlir::Value cmp = builder.createCompare(loc, pred, lhs, rhs);
751 return builder.emitIntrinsicCallOp(loc, "amdgcn.ballot",
752 convertType(expr->getType()), cmp);
753 }
754 case AMDGPU::BI__builtin_amdgcn_class:
755 case AMDGPU::BI__builtin_amdgcn_classf:
756 case AMDGPU::BI__builtin_amdgcn_classh:
757 return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.class",
758 convertType(expr->getType()))
759 .getValue();
760 case AMDGPU::BI__builtin_amdgcn_fmed3f:
761 case AMDGPU::BI__builtin_amdgcn_fmed3h:
762 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.fmed3").getValue();
763 case AMDGPU::BI__builtin_amdgcn_ds_append:
764 case AMDGPU::BI__builtin_amdgcn_ds_consume: {
765 cgm.errorNYI(expr->getSourceRange(),
766 std::string("unimplemented AMDGPU builtin call: ") +
767 getContext().BuiltinInfo.getName(builtinId));
768 return mlir::Value{};
769 }
770 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b64_i32:
771 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b64_v2i32:
772 case AMDGPU::BI__builtin_amdgcn_global_load_tr8_b64_v2i32:
774 expr, "amdgcn.global.load.tr.b64", convertType(expr->getType()))
775 .getValue();
776 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4i16:
777 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4f16:
778 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v4bf16:
779 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8i16:
780 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8f16:
781 case AMDGPU::BI__builtin_amdgcn_global_load_tr_b128_v8bf16:
782 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8i16:
783 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8f16:
784 case AMDGPU::BI__builtin_amdgcn_global_load_tr16_b128_v8bf16:
786 expr, "amdgcn.global.load.tr.b128", convertType(expr->getType()))
787 .getValue();
788 case AMDGPU::BI__builtin_amdgcn_global_load_tr4_b64_v2i32:
790 expr, "amdgcn.global.load.tr4.b64", convertType(expr->getType()))
791 .getValue();
792 case AMDGPU::BI__builtin_amdgcn_global_load_tr6_b96_v3i32:
794 expr, "amdgcn.global.load.tr6.b96", convertType(expr->getType()))
795 .getValue();
796 case AMDGPU::BI__builtin_amdgcn_ds_load_tr4_b64_v2i32:
797 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr4.b64",
798 convertType(expr->getType()))
799 .getValue();
800 case AMDGPU::BI__builtin_amdgcn_ds_load_tr6_b96_v3i32:
801 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr6.b96",
802 convertType(expr->getType()))
803 .getValue();
804 case AMDGPU::BI__builtin_amdgcn_ds_load_tr8_b64_v2i32:
805 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr8.b64",
806 convertType(expr->getType()))
807 .getValue();
808 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8i16:
809 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8f16:
810 case AMDGPU::BI__builtin_amdgcn_ds_load_tr16_b128_v8bf16:
811 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.load.tr16.b128",
812 convertType(expr->getType()))
813 .getValue();
814 case AMDGPU::BI__builtin_amdgcn_ds_read_tr4_b64_v2i32:
815 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr4.b64",
816 convertType(expr->getType()))
817 .getValue();
818 case AMDGPU::BI__builtin_amdgcn_ds_read_tr8_b64_v2i32:
819 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr8.b64",
820 convertType(expr->getType()))
821 .getValue();
822 case AMDGPU::BI__builtin_amdgcn_ds_read_tr6_b96_v3i32:
823 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr6.b96",
824 convertType(expr->getType()))
825 .getValue();
826 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4i16:
827 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4f16:
828 case AMDGPU::BI__builtin_amdgcn_ds_read_tr16_b64_v4bf16:
829 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.ds.read.tr16.b64",
830 convertType(expr->getType()))
831 .getValue();
832 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b32:
833 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b64:
834 case AMDGPU::BI__builtin_amdgcn_global_load_monitor_b128:
835 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b32:
836 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b64:
837 case AMDGPU::BI__builtin_amdgcn_flat_load_monitor_b128: {
838 cgm.errorNYI(expr->getSourceRange(),
839 std::string("unimplemented AMDGPU builtin call: ") +
840 getContext().BuiltinInfo.getName(builtinId));
841 return mlir::Value{};
842 }
843 case AMDGPU::BI__builtin_amdgcn_cluster_load_b32:
844 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b32",
845 convertType(expr->getType()))
846 .getValue();
847 case AMDGPU::BI__builtin_amdgcn_cluster_load_b64:
848 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b64",
849 convertType(expr->getType()))
850 .getValue();
851 case AMDGPU::BI__builtin_amdgcn_cluster_load_b128:
852 return emitBuiltinWithOneOverloadedType<3>(expr, "amdgcn.cluster.load.b128",
853 convertType(expr->getType()))
854 .getValue();
855 case AMDGPU::BI__builtin_amdgcn_load_to_lds:
857 expr, "amdgcn.load.to.lds",
858 cir::VoidType::get(builder.getContext()))
859 .getValue();
860 case AMDGPU::BI__builtin_amdgcn_load_async_to_lds:
862 expr, "amdgcn.load.async.to.lds",
863 cir::VoidType::get(builder.getContext()))
864 .getValue();
865 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_32x4B:
866 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_32x4B:
867 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_16x8B:
868 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_16x8B:
869 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_load_8x16B:
870 case AMDGPU::BI__builtin_amdgcn_cooperative_atomic_store_8x16B: {
871 cgm.errorNYI(expr->getSourceRange(),
872 std::string("unimplemented AMDGPU builtin call: ") +
873 getContext().BuiltinInfo.getName(builtinId));
874 return mlir::Value{};
875 }
876 case AMDGPU::BI__builtin_amdgcn_get_fpenv:
877 case AMDGPU::BI__builtin_amdgcn_set_fpenv: {
878 cgm.errorNYI(expr->getSourceRange(),
879 std::string("unimplemented AMDGPU builtin call: ") +
880 getContext().BuiltinInfo.getName(builtinId));
881 return mlir::Value{};
882 }
883 case AMDGPU::BI__builtin_amdgcn_processor_is: {
884 assert(cgm.getTriple().isSPIRV() &&
885 "__builtin_amdgcn_processor_is should never reach CodeGen for "
886 "concrete targets!");
887 StringRef proc = cast<clang::StringLiteral>(expr->getArg(0))->getString();
888 return emitAMDGPUPredicate(*this, expr, "is." + proc);
889 }
890 case AMDGPU::BI__builtin_amdgcn_is_invocable: {
891 assert(cgm.getTriple().isSPIRV() &&
892 "__builtin_amdgcn_is_invocable should never reach CodeGen for "
893 "concrete targets!");
894 auto *fd = cast<FunctionDecl>(
895 cast<DeclRefExpr>(expr->getArg(0))->getReferencedDeclOfCallee());
896 StringRef rf =
897 getContext().BuiltinInfo.getRequiredFeatures(fd->getBuiltinID());
898 return emitAMDGPUPredicate(*this, expr, "has." + rf);
899 }
900 case AMDGPU::BI__builtin_amdgcn_read_exec:
901 case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
902 case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
903 // The exec mask is read as a ballot over an all-true predicate. The
904 // ballot is at least as wide as the wavefront, so that a wave64 target
905 // still reports both halves for the _lo/_hi forms.
906 mlir::Location loc = getLoc(expr->getExprLoc());
907 unsigned registerWidth =
908 builtinId == AMDGPU::BI__builtin_amdgcn_read_exec_lo ? 32 : 64;
909 unsigned ballotWidth =
910 std::max(getTarget().getGridValue().GV_Warp_Size, registerWidth);
911 cir::IntType ballotTy = builder.getUIntNTy(ballotWidth);
912
913 mlir::Value truePred = builder.getBool(true, loc).getResult();
914 mlir::Value result =
915 builder.emitIntrinsicCallOp(loc, "amdgcn.ballot", ballotTy, truePred);
916
917 if (builtinId == AMDGPU::BI__builtin_amdgcn_read_exec_hi)
918 result = builder.createShiftRight(loc, result, 32);
919 return builder.createIntCast(result, convertType(expr->getType()));
920 }
921 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray:
922 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_h:
923 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_l:
924 case AMDGPU::BI__builtin_amdgcn_image_bvh_intersect_ray_lh: {
925 cgm.errorNYI(expr->getSourceRange(),
926 std::string("unimplemented AMDGPU builtin call: ") +
927 getContext().BuiltinInfo.getName(builtinId));
928 return mlir::Value{};
929 }
930 case AMDGPU::BI__builtin_amdgcn_image_bvh8_intersect_ray:
931 case AMDGPU::BI__builtin_amdgcn_image_bvh_dual_intersect_ray: {
932 cgm.errorNYI(expr->getSourceRange(),
933 std::string("unimplemented AMDGPU builtin call: ") +
934 getContext().BuiltinInfo.getName(builtinId));
935 return mlir::Value{};
936 }
937 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_rtn:
938 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push4_pop1_rtn:
939 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop1_rtn:
940 case AMDGPU::BI__builtin_amdgcn_ds_bvh_stack_push8_pop2_rtn: {
941 cgm.errorNYI(expr->getSourceRange(),
942 std::string("unimplemented AMDGPU builtin call: ") +
943 getContext().BuiltinInfo.getName(builtinId));
944 return mlir::Value{};
945 }
946 case AMDGPU::BI__builtin_amdgcn_image_load_1d_v4f32_i32:
947 case AMDGPU::BI__builtin_amdgcn_image_load_1d_v4f16_i32:
949 "amdgcn.image.load.1d", false);
950 case AMDGPU::BI__builtin_amdgcn_image_load_1darray_v4f32_i32:
951 case AMDGPU::BI__builtin_amdgcn_image_load_1darray_v4f16_i32:
953 *this, expr, "amdgcn.image.load.1darray", false);
954 case AMDGPU::BI__builtin_amdgcn_image_load_2d_f32_i32:
955 case AMDGPU::BI__builtin_amdgcn_image_load_2d_v4f32_i32:
956 case AMDGPU::BI__builtin_amdgcn_image_load_2d_v4f16_i32:
958 "amdgcn.image.load.2d", false);
959 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_f32_i32:
960 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_v4f32_i32:
961 case AMDGPU::BI__builtin_amdgcn_image_load_2darray_v4f16_i32:
963 *this, expr, "amdgcn.image.load.2darray", false);
964 case AMDGPU::BI__builtin_amdgcn_image_load_3d_v4f32_i32:
965 case AMDGPU::BI__builtin_amdgcn_image_load_3d_v4f16_i32:
967 "amdgcn.image.load.3d", false);
968 case AMDGPU::BI__builtin_amdgcn_image_load_cube_v4f32_i32:
969 case AMDGPU::BI__builtin_amdgcn_image_load_cube_v4f16_i32:
971 "amdgcn.image.load.cube", false);
972 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1d_v4f32_i32:
973 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1d_v4f16_i32:
975 *this, expr, "amdgcn.image.load.mip.1d", false);
976 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1darray_v4f32_i32:
977 case AMDGPU::BI__builtin_amdgcn_image_load_mip_1darray_v4f16_i32:
979 *this, expr, "amdgcn.image.load.mip.1darray", false);
980 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_f32_i32:
981 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_v4f32_i32:
982 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2d_v4f16_i32:
984 *this, expr, "amdgcn.image.load.mip.2d", false);
985 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_f32_i32:
986 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_v4f32_i32:
987 case AMDGPU::BI__builtin_amdgcn_image_load_mip_2darray_v4f16_i32:
989 *this, expr, "amdgcn.image.load.mip.2darray", false);
990 case AMDGPU::BI__builtin_amdgcn_image_load_mip_3d_v4f32_i32:
991 case AMDGPU::BI__builtin_amdgcn_image_load_mip_3d_v4f16_i32:
993 *this, expr, "amdgcn.image.load.mip.3d", false);
994 case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f32_i32:
995 case AMDGPU::BI__builtin_amdgcn_image_load_mip_cube_v4f16_i32:
997 *this, expr, "amdgcn.image.load.mip.cube", false);
998 case AMDGPU::BI__builtin_amdgcn_image_store_1d_v4f32_i32:
999 case AMDGPU::BI__builtin_amdgcn_image_store_1d_v4f16_i32:
1001 "amdgcn.image.store.1d", true);
1002 case AMDGPU::BI__builtin_amdgcn_image_store_1darray_v4f32_i32:
1003 case AMDGPU::BI__builtin_amdgcn_image_store_1darray_v4f16_i32:
1005 *this, expr, "amdgcn.image.store.1darray", true);
1006 case AMDGPU::BI__builtin_amdgcn_image_store_2d_f32_i32:
1007 case AMDGPU::BI__builtin_amdgcn_image_store_2d_v4f32_i32:
1008 case AMDGPU::BI__builtin_amdgcn_image_store_2d_v4f16_i32:
1010 "amdgcn.image.store.2d", true);
1011 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_f32_i32:
1012 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_v4f32_i32:
1013 case AMDGPU::BI__builtin_amdgcn_image_store_2darray_v4f16_i32:
1015 *this, expr, "amdgcn.image.store.2darray", true);
1016 case AMDGPU::BI__builtin_amdgcn_image_store_3d_v4f32_i32:
1017 case AMDGPU::BI__builtin_amdgcn_image_store_3d_v4f16_i32:
1019 "amdgcn.image.store.3d", true);
1020 case AMDGPU::BI__builtin_amdgcn_image_store_cube_v4f32_i32:
1021 case AMDGPU::BI__builtin_amdgcn_image_store_cube_v4f16_i32:
1023 "amdgcn.image.store.cube", true);
1024 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1d_v4f32_i32:
1025 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1d_v4f16_i32:
1027 *this, expr, "amdgcn.image.store.mip.1d", true);
1028 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1darray_v4f32_i32:
1029 case AMDGPU::BI__builtin_amdgcn_image_store_mip_1darray_v4f16_i32:
1031 *this, expr, "amdgcn.image.store.mip.1darray", true);
1032 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_f32_i32:
1033 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_v4f32_i32:
1034 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2d_v4f16_i32:
1036 *this, expr, "amdgcn.image.store.mip.2d", true);
1037 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_f32_i32:
1038 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_v4f32_i32:
1039 case AMDGPU::BI__builtin_amdgcn_image_store_mip_2darray_v4f16_i32:
1041 *this, expr, "amdgcn.image.store.mip.2darray", true);
1042 case AMDGPU::BI__builtin_amdgcn_image_store_mip_3d_v4f32_i32:
1043 case AMDGPU::BI__builtin_amdgcn_image_store_mip_3d_v4f16_i32:
1045 *this, expr, "amdgcn.image.store.mip.3d", true);
1046 case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f32_i32:
1047 case AMDGPU::BI__builtin_amdgcn_image_store_mip_cube_v4f16_i32:
1049 *this, expr, "amdgcn.image.store.mip.cube", true);
1050 case AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f32_f32:
1051 case AMDGPU::BI__builtin_amdgcn_image_sample_1d_v4f16_f32:
1053 "amdgcn.image.sample.1d", false);
1054 case AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f32_f32:
1055 case AMDGPU::BI__builtin_amdgcn_image_sample_1darray_v4f16_f32:
1057 *this, expr, "amdgcn.image.sample.1darray", false);
1058 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_f32_f32:
1059 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f32_f32:
1060 case AMDGPU::BI__builtin_amdgcn_image_sample_2d_v4f16_f32:
1062 "amdgcn.image.sample.2d", false);
1063 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_f32_f32:
1064 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f32_f32:
1065 case AMDGPU::BI__builtin_amdgcn_image_sample_2darray_v4f16_f32:
1067 *this, expr, "amdgcn.image.sample.2darray", false);
1068 case AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f32_f32:
1069 case AMDGPU::BI__builtin_amdgcn_image_sample_3d_v4f16_f32:
1071 "amdgcn.image.sample.3d", false);
1072 case AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f32_f32:
1073 case AMDGPU::BI__builtin_amdgcn_image_sample_cube_v4f16_f32:
1075 *this, expr, "amdgcn.image.sample.cube", false);
1076 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1d_v4f32_f32:
1077 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1d_v4f16_f32:
1079 *this, expr, "amdgcn.image.sample.lz.1d", false);
1080 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1d_v4f32_f32:
1081 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1d_v4f16_f32:
1083 *this, expr, "amdgcn.image.sample.l.1d", false);
1084 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1d_v4f32_f32:
1085 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1d_v4f16_f32:
1087 *this, expr, "amdgcn.image.sample.d.1d", false);
1088 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_v4f32_f32:
1089 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_v4f16_f32:
1090 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2d_f32_f32:
1092 *this, expr, "amdgcn.image.sample.lz.2d", false);
1093 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_v4f32_f32:
1094 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_v4f16_f32:
1095 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2d_f32_f32:
1097 *this, expr, "amdgcn.image.sample.l.2d", false);
1098 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_v4f32_f32:
1099 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_v4f16_f32:
1100 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2d_f32_f32:
1102 *this, expr, "amdgcn.image.sample.d.2d", false);
1103 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_3d_v4f32_f32:
1104 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_3d_v4f16_f32:
1106 *this, expr, "amdgcn.image.sample.lz.3d", false);
1107 case AMDGPU::BI__builtin_amdgcn_image_sample_l_3d_v4f32_f32:
1108 case AMDGPU::BI__builtin_amdgcn_image_sample_l_3d_v4f16_f32:
1110 *this, expr, "amdgcn.image.sample.l.3d", false);
1111 case AMDGPU::BI__builtin_amdgcn_image_sample_d_3d_v4f32_f32:
1112 case AMDGPU::BI__builtin_amdgcn_image_sample_d_3d_v4f16_f32:
1114 *this, expr, "amdgcn.image.sample.d.3d", false);
1115 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_cube_v4f32_f32:
1116 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_cube_v4f16_f32:
1118 *this, expr, "amdgcn.image.sample.lz.cube", false);
1119 case AMDGPU::BI__builtin_amdgcn_image_sample_l_cube_v4f32_f32:
1120 case AMDGPU::BI__builtin_amdgcn_image_sample_l_cube_v4f16_f32:
1122 *this, expr, "amdgcn.image.sample.l.cube", false);
1123 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1darray_v4f32_f32:
1124 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_1darray_v4f16_f32:
1126 *this, expr, "amdgcn.image.sample.lz.1darray", false);
1127 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1darray_v4f32_f32:
1128 case AMDGPU::BI__builtin_amdgcn_image_sample_l_1darray_v4f16_f32:
1130 *this, expr, "amdgcn.image.sample.l.1darray", false);
1131 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1darray_v4f32_f32:
1132 case AMDGPU::BI__builtin_amdgcn_image_sample_d_1darray_v4f16_f32:
1134 *this, expr, "amdgcn.image.sample.d.1darray", false);
1135 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_v4f32_f32:
1136 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_v4f16_f32:
1137 case AMDGPU::BI__builtin_amdgcn_image_sample_lz_2darray_f32_f32:
1139 *this, expr, "amdgcn.image.sample.lz.2darray", false);
1140 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_v4f32_f32:
1141 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_v4f16_f32:
1142 case AMDGPU::BI__builtin_amdgcn_image_sample_l_2darray_f32_f32:
1144 *this, expr, "amdgcn.image.sample.l.2darray", false);
1145 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_v4f32_f32:
1146 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_v4f16_f32:
1147 case AMDGPU::BI__builtin_amdgcn_image_sample_d_2darray_f32_f32:
1149 *this, expr, "amdgcn.image.sample.d.2darray", false);
1150 case AMDGPU::BI__builtin_amdgcn_image_gather4_lz_2d_v4f32_f32:
1151 case AMDGPU::BI__builtin_amdgcn_image_gather4_lz_2d_v4f16_f32:
1153 *this, expr, "amdgcn.image.gather4.lz.2d", false);
1154 case AMDGPU::BI__builtin_amdgcn_mfma_scale_f32_16x16x128_f8f6f4:
1155 case AMDGPU::BI__builtin_amdgcn_mfma_scale_f32_32x32x64_f8f6f4: {
1156 cgm.errorNYI(expr->getSourceRange(),
1157 std::string("unimplemented AMDGPU builtin call: ") +
1158 getContext().BuiltinInfo.getName(builtinId));
1159 return mlir::Value{};
1160 }
1161 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32:
1162 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w32:
1163 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64:
1164 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_tied_w64:
1165 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w32:
1166 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w32:
1167 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w64:
1168 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_tied_w64:
1169 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32:
1170 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64:
1171 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w32:
1172 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w64:
1173 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32:
1174 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64:
1175 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32:
1176 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64:
1177 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32_gfx12:
1178 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64_gfx12:
1179 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w32_gfx12:
1180 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w64_gfx12:
1181 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32_gfx12:
1182 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64_gfx12:
1183 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w32_gfx12:
1184 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w64_gfx12:
1185 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32_gfx12:
1186 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64_gfx12:
1187 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32_gfx12:
1188 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64_gfx12:
1189 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_fp8_w32_gfx12:
1190 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_fp8_w64_gfx12:
1191 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_bf8_w32_gfx12:
1192 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_fp8_bf8_w64_gfx12:
1193 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_fp8_w32_gfx12:
1194 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_fp8_w64_gfx12:
1195 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_bf8_w32_gfx12:
1196 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf8_bf8_w64_gfx12:
1197 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x32_iu4_w32_gfx12:
1198 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x32_iu4_w64_gfx12: {
1199 cgm.errorNYI(expr->getSourceRange(),
1200 std::string("unimplemented AMDGPU builtin call: ") +
1201 getContext().BuiltinInfo.getName(builtinId));
1202 return mlir::Value{};
1203 }
1204 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_f16_w32:
1205 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_f16_w64:
1206 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w32:
1207 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf16_w64:
1208 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x32_f16_w32:
1209 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x32_f16_w64:
1210 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w32:
1211 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x32_bf16_w64:
1212 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w32:
1213 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu8_w64:
1214 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w32:
1215 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x32_iu4_w64:
1216 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w32:
1217 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x64_iu4_w64:
1218 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w32:
1219 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_fp8_w64:
1220 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w32:
1221 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_fp8_bf8_w64:
1222 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w32:
1223 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_fp8_w64:
1224 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w32:
1225 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x32_bf8_bf8_w64: {
1226 cgm.errorNYI(expr->getSourceRange(),
1227 std::string("unimplemented AMDGPU builtin call: ") +
1228 getContext().BuiltinInfo.getName(builtinId));
1229 return mlir::Value{};
1230 }
1231 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x4_f32:
1232 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x32_bf16:
1233 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x32_f16:
1234 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x32_f16:
1235 case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x32_bf16:
1236 case AMDGPU::BI__builtin_amdgcn_wmma_bf16f32_16x16x32_bf16:
1237 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_fp8_fp8:
1238 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_fp8_bf8:
1239 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_bf8_fp8:
1240 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x64_bf8_bf8:
1241 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_fp8_fp8:
1242 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_fp8_bf8:
1243 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_bf8_fp8:
1244 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x64_bf8_bf8:
1245 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_fp8_fp8:
1246 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_fp8_bf8:
1247 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_bf8_fp8:
1248 case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x128_bf8_bf8:
1249 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_fp8_fp8:
1250 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_fp8_bf8:
1251 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_bf8_fp8:
1252 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_bf8_bf8:
1253 case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x64_iu8:
1254 case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x128_f8f6f4:
1255 case AMDGPU::BI__builtin_amdgcn_wmma_f32_32x16x128_f4:
1256 case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4:
1257 case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4:
1258 case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_32x16x128_f4:
1259 case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4: {
1260 cgm.errorNYI(expr->getSourceRange(),
1261 std::string("unimplemented AMDGPU builtin call: ") +
1262 getContext().BuiltinInfo.getName(builtinId));
1263 return mlir::Value{};
1264 }
1265 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_f16:
1266 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_bf16:
1267 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x64_f16:
1268 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16_16x16x64_bf16:
1269 case AMDGPU::BI__builtin_amdgcn_swmmac_bf16f32_16x16x64_bf16:
1270 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_fp8_fp8:
1271 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_fp8_bf8:
1272 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_bf8_fp8:
1273 case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x128_bf8_bf8:
1274 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_fp8_fp8:
1275 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_fp8_bf8:
1276 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_bf8_fp8:
1277 case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x128_bf8_bf8:
1278 case AMDGPU::BI__builtin_amdgcn_swmmac_i32_16x16x128_iu8: {
1279 cgm.errorNYI(expr->getSourceRange(),
1280 std::string("unimplemented AMDGPU builtin call: ") +
1281 getContext().BuiltinInfo.getName(builtinId));
1282 return mlir::Value{};
1283 }
1284 // amdgcn workgroup size
1285 case AMDGPU::BI__builtin_amdgcn_workgroup_size_x:
1286 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 0);
1287 case AMDGPU::BI__builtin_amdgcn_workgroup_size_y:
1288 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 1);
1289 case AMDGPU::BI__builtin_amdgcn_workgroup_size_z:
1290 return emitAMDGPUWorkGroupSize(*this, getLoc(expr->getExprLoc()), 2);
1291 // amdgcn grid size
1292 case AMDGPU::BI__builtin_amdgcn_grid_size_x:
1293 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 0);
1294 case AMDGPU::BI__builtin_amdgcn_grid_size_y:
1295 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 1);
1296 case AMDGPU::BI__builtin_amdgcn_grid_size_z:
1297 return emitAMDGPUGridSize(*this, getLoc(expr->getExprLoc()), 2);
1298 case AMDGPU::BI__builtin_r600_recipsqrt_ieee:
1299 case AMDGPU::BI__builtin_r600_recipsqrt_ieeef: {
1300 cgm.errorNYI(expr->getSourceRange(),
1301 std::string("unimplemented AMDGPU builtin call: ") +
1302 getContext().BuiltinInfo.getName(builtinId));
1303 return mlir::Value{};
1304 }
1305 case AMDGPU::BI__builtin_amdgcn_alignbit: {
1306 cgm.errorNYI(expr->getSourceRange(),
1307 std::string("unimplemented AMDGPU builtin call: ") +
1308 getContext().BuiltinInfo.getName(builtinId));
1309 return mlir::Value{};
1310 }
1311 case AMDGPU::BI__builtin_amdgcn_fence: {
1312 // The scope uses AMDGPU spelling on every target, like mapScopeToSPIRV.
1313 const llvm::Triple &triple = getTarget().getTriple();
1314 std::optional<std::pair<llvm::AtomicScope, bool>> parsed;
1315 if (std::optional<std::string> name =
1316 expr->getArg(1)->tryEvaluateString(getContext())) {
1317 parsed = llvm::parseAMDGPUAtomicScopeIRString(*name);
1318 if (!parsed && triple.isSPIRV())
1319 parsed = llvm::parseAtomicScopeIRString(triple, *name);
1320 }
1321 // SPIR-V drops one-as, AMDGPU needs a CIR sync scope for it.
1322 if (!parsed || (parsed->second && !triple.isSPIRV())) {
1323 cgm.errorNYI(expr->getSourceRange(), "__builtin_amdgcn_fence scope");
1324 return mlir::Value{};
1325 }
1326 // Sorted and unique, like MMRAMetadata::appendTags.
1328 addrSpaces.reserve(expr->getNumArgs() - 2);
1329 for (unsigned i = 2; i < expr->getNumArgs(); ++i) {
1330 if (std::optional<std::string> as =
1331 expr->getArg(i)->tryEvaluateString(getContext()))
1332 addrSpaces.push_back(std::move(*as));
1333 else
1334 cgm.error(expr->getExprLoc(),
1335 "expected an address space name as a string literal");
1336 }
1337 llvm::sort(addrSpaces);
1338 addrSpaces.erase(llvm::unique(addrSpaces), addrSpaces.end());
1340 mmras.reserve(addrSpaces.size());
1341 for (const std::string &as : addrSpaces)
1342 mmras.push_back(mlir::LLVM::MMRATagAttr::get(
1343 &getMLIRContext(), "amdgpu-synchronize-as", as));
1344
1345 auto fence = cir::AtomicFenceOp::create(
1346 builder, getLoc(expr->getExprLoc()),
1347 decodeAtomicOrder(expr->getArg(0), getContext()),
1348 cir::SyncScopeKindAttr::get(&getMLIRContext(),
1349 convertAtomicScopeToCIR(parsed->first)));
1350 if (!mmras.empty())
1351 fence->setAttr(mlir::LLVM::LLVMDialect::getMmraAttrName(),
1352 mmras.size() == 1 ? mmras.front()
1353 : builder.getArrayAttr(mmras));
1354 return mlir::Value{};
1355 }
1356 case AMDGPU::BI__builtin_amdgcn_atomic_inc32:
1357 case AMDGPU::BI__builtin_amdgcn_atomic_inc64:
1358 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::UIncWrap,
1359 /*hasVolatileArg=*/false);
1360 case AMDGPU::BI__builtin_amdgcn_atomic_dec32:
1361 case AMDGPU::BI__builtin_amdgcn_atomic_dec64:
1362 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::UDecWrap,
1363 /*hasVolatileArg=*/false);
1364 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f64:
1365 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_f32:
1366 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f32:
1367 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_f64:
1368 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f32:
1369 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_f64:
1370 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2f16:
1371 case AMDGPU::BI__builtin_amdgcn_ds_atomic_fadd_v2bf16:
1372 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2f16:
1373 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_v2f16:
1374 case AMDGPU::BI__builtin_amdgcn_global_atomic_fadd_v2bf16:
1375 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fadd_v2bf16:
1376 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Add,
1377 /*hasVolatileArg=*/false);
1378 case AMDGPU::BI__builtin_amdgcn_global_atomic_fmin_f64:
1379 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmin_f64:
1380 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Min,
1381 /*hasVolatileArg=*/false);
1382 case AMDGPU::BI__builtin_amdgcn_global_atomic_fmax_f64:
1383 case AMDGPU::BI__builtin_amdgcn_flat_atomic_fmax_f64:
1384 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Max,
1385 /*hasVolatileArg=*/false);
1386 // The ds_ float forms are the same operations with the volatile flag spelled
1387 // out as an argument.
1388 case AMDGPU::BI__builtin_amdgcn_ds_faddf:
1389 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Add,
1390 /*hasVolatileArg=*/true);
1391 case AMDGPU::BI__builtin_amdgcn_ds_fminf:
1392 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Min,
1393 /*hasVolatileArg=*/true);
1394 case AMDGPU::BI__builtin_amdgcn_ds_fmaxf:
1395 return emitAMDGPUAtomicRMW(*this, expr, cir::AtomicFetchKind::Max,
1396 /*hasVolatileArg=*/true);
1397 case AMDGPU::BI__builtin_amdgcn_s_sendmsg_rtn:
1398 case AMDGPU::BI__builtin_amdgcn_s_sendmsg_rtnl:
1399 return emitBuiltinWithOneOverloadedType<1>(expr, "amdgcn.s.sendmsg.rtn",
1400 convertType(expr->getType()))
1401 .getValue();
1402 case AMDGPU::BI__builtin_amdgcn_permlane16_swap:
1403 case AMDGPU::BI__builtin_amdgcn_permlane32_swap: {
1404 cgm.errorNYI(expr->getSourceRange(),
1405 std::string("unimplemented AMDGPU builtin call: ") +
1406 getContext().BuiltinInfo.getName(builtinId));
1407 return mlir::Value{};
1408 }
1409 case AMDGPU::BI__builtin_amdgcn_bitop3_b32:
1410 case AMDGPU::BI__builtin_amdgcn_bitop3_b16:
1411 return emitBuiltinWithOneOverloadedType<4>(expr, "amdgcn.bitop3")
1412 .getValue();
1413 case AMDGPU::BI__builtin_amdgcn_make_buffer_rsrc: {
1414 cgm.errorNYI(expr->getSourceRange(),
1415 std::string("unimplemented AMDGPU builtin call: ") +
1416 getContext().BuiltinInfo.getName(builtinId));
1417 return mlir::Value{};
1418 }
1419 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b8:
1420 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b16:
1421 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b32:
1422 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b64:
1423 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b96:
1424 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_b128: {
1425 cgm.errorNYI(expr->getSourceRange(),
1426 std::string("unimplemented AMDGPU builtin call: ") +
1427 getContext().BuiltinInfo.getName(builtinId));
1428 return mlir::Value{};
1429 }
1430 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_format_v4f32:
1431 case AMDGPU::BI__builtin_amdgcn_raw_buffer_store_format_v4f16:
1433 expr, "amdgcn.raw.ptr.buffer.store.format",
1434 cir::VoidType::get(builder.getContext()))
1435 .getValue();
1436 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_format_v4f32:
1437 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_format_v4f16:
1439 expr, "amdgcn.raw.ptr.buffer.load.format",
1440 convertType(expr->getType()))
1441 .getValue();
1442 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b8:
1443 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b16:
1444 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b32:
1445 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b64:
1446 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b96:
1447 case AMDGPU::BI__builtin_amdgcn_raw_buffer_load_b128: {
1448 cgm.errorNYI(expr->getSourceRange(),
1449 std::string("unimplemented AMDGPU builtin call: ") +
1450 getContext().BuiltinInfo.getName(builtinId));
1451 return mlir::Value{};
1452 }
1453 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32:
1455 expr, "amdgcn.raw.ptr.buffer.atomic.add")
1456 .getValue();
1457 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32:
1458 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f64:
1459 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16:
1461 expr, "amdgcn.raw.ptr.buffer.atomic.fadd")
1462 .getValue();
1463 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32:
1464 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64:
1466 expr, "amdgcn.raw.ptr.buffer.atomic.fmin")
1467 .getValue();
1468 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32:
1469 case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64:
1471 expr, "amdgcn.raw.ptr.buffer.atomic.fmax")
1472 .getValue();
1473 case AMDGPU::BI__builtin_amdgcn_s_prefetch_data:
1475 expr, "amdgcn.s.prefetch.data",
1476 cir::VoidType::get(builder.getContext()))
1477 .getValue();
1478 case AMDGPU::BI__builtin_amdgcn_s_prefetch_inst:
1480 expr, "amdgcn.s.prefetch.inst",
1481 cir::VoidType::get(builder.getContext()))
1482 .getValue();
1483 case Builtin::BIlogbf:
1484 case Builtin::BI__builtin_logbf:
1485 return emitLogbBuiltin(*this, expr, llvm::APFloat::IEEEsingle());
1486 case Builtin::BIlogb:
1487 case Builtin::BI__builtin_logb:
1488 return emitLogbBuiltin(*this, expr, llvm::APFloat::IEEEdouble());
1489 case Builtin::BIscalbnf:
1490 case Builtin::BI__builtin_scalbnf:
1491 case Builtin::BIscalbn:
1492 case Builtin::BI__builtin_scalbn: {
1494 *this, expr, "ldexp", "experimental.constrained.ldexp");
1495 }
1496 default:
1497 return std::nullopt;
1498 }
1499}
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 emitAMDGPUPredicate(CIRGenFunction &cgf, const CallExpr *e, const llvm::Twine &name)
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, OverflowFlags flags=OverflowFlags::None)
mlir::Value createNSWAdd(mlir::Location loc, mlir::Value lhs, mlir::Value rhs)
mlir::Value createBoolToInt(mlir::Value src, mlir::Type newTy)
cir::ConstantOp getConstant(mlir::Location loc, mlir::TypedAttr attr)
cir::PtrStrideOp createPtrStride(mlir::Location loc, mlir::Value base, mlir::Value stride)
mlir::Value createMul(mlir::Location loc, mlir::Value lhs, mlir::Value rhs, OverflowFlags flags=OverflowFlags::None)
cir::GetGlobalOp createGetGlobal(mlir::Location loc, cir::GlobalOp global, bool threadLocal=false)
mlir::Value createIntCast(mlir::Value src, mlir::Type newTy)
mlir::Value createBitcast(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)
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)
cir::BoolType getBoolTy()
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:151
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.
Builtin::Context & BuiltinInfo
Definition ASTContext.h:854
CanQualType IntTy
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
@ GE_None
No error.
const char * getRequiredFeatures(unsigned ID) const
Definition Builtins.cpp:118
mlir::Type getElementType() const
Definition Address.h:125
Address withElementType(CIRGenBuilderTy &builder, mlir::Type ElemTy) const
Return address with different element type, a bitcast pointer, and the same alignment.
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:8662
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:9498
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.
U cast(CodeGen::Address addr)
Definition Address.h:327
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