[Mlir-commits] [mlir] [mlir][spirv] Add GpuToLLVM cconv suited to Vulkan, migrate last tests (PR #123384)
Andrea Faulds
llvmlistbot at llvm.org
Tue Jan 21 04:27:18 PST 2025
================
@@ -970,33 +971,55 @@ LogicalResult LegalizeLaunchFuncOpPattern::matchAndRewrite(
else if (launchOp.getAsyncToken())
stream = streamCreateCallBuilder.create(loc, rewriter, {}).getResult();
- if (typeCheckKernelArgs) {
- // The current non-bare-pointer ABI is a bad fit for `mgpuLaunchKernel`,
- // which takes an untyped list of arguments. The type check here prevents
- // accidentally violating the assumption made in vulkan-runtime-wrappers.cpp
- // and creating a unchecked runtime ABI mismatch.
- // TODO(https://github.com/llvm/llvm-project/issues/73457): Change the ABI
- // here to remove the need for this type check.
- for (Value arg : launchOp.getKernelOperands()) {
- if (auto memrefTy = dyn_cast<MemRefType>(arg.getType())) {
- if (memrefTy.getRank() != 1 ||
- memrefTy.getElementTypeBitWidth() != 32) {
- return rewriter.notifyMatchFailure(
- launchOp, "Operand to launch op is not a rank-1 memref with "
- "32-bit element type.");
- }
- } else {
+ // Lower the kernel operands to match kernel parameters.
+ // Note: If `useBarePtrCallConv` is set in the type converter's options,
+ // the value of `kernelBarePtrCallConv` will be ignored.
+ OperandRange origArguments = launchOp.getKernelOperands();
+ SmallVector<Value, 8> llvmArguments = getTypeConverter()->promoteOperands(
+ loc, origArguments, adaptor.getKernelOperands(), rewriter,
+ /*useBarePtrCallConv=*/kernelBarePtrCallConv);
+ SmallVector<Value, 8> llvmArgumentsWithSizes;
----------------
andfau-amd wrote:
I prefer the explicit size in this case because `promoteOperands` returns a `SmallVector<Value, 4>`, which isn't going to be large enough once the sizes are added (three operands becomes six). But I guess it doesn't matter too much...
https://github.com/llvm/llvm-project/pull/123384
More information about the Mlir-commits
mailing list