[Mlir-commits] [mlir] 3f2f83e - [mlir] accept values with result numbers in gpu.launch_func
Alex Zinenko
llvmlistbot at llvm.org
Mon Jan 16 11:26:50 PST 2023
Author: Alex Zinenko
Date: 2023-01-16T19:26:42Z
New Revision: 3f2f83ef41419507bcdaf751b86713ef193b7de0
URL: https://github.com/llvm/llvm-project/commit/3f2f83ef41419507bcdaf751b86713ef193b7de0
DIFF: https://github.com/llvm/llvm-project/commit/3f2f83ef41419507bcdaf751b86713ef193b7de0.diff
LOG: [mlir] accept values with result numbers in gpu.launch_func
The parser of gpu.launch_func was incorrectly rejecting SSA values with
result numbers (`%0#0`) in the list of function arguments by using the
`parseArgument` function intended for region argument declarations, not
operands. Fix this by directly parsing comma-separated operands and
types.
Reviewed By: nicolasvasilache
Differential Revision: https://reviews.llvm.org/D141851
Added:
Modified:
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/test/Dialect/GPU/ops.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index f9018275f6a4a..7e1f536cef9d7 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -793,15 +793,13 @@ static ParseResult parseLaunchFuncOperands(
if (parser.parseOptionalKeyword("args"))
return success();
- SmallVector<OpAsmParser::Argument> args;
- if (parser.parseArgumentList(args, OpAsmParser::Delimiter::Paren,
- /*allowType=*/true))
- return failure();
- for (auto &arg : args) {
- argNames.push_back(arg.ssaName);
- argTypes.push_back(arg.type);
- }
- return success();
+ auto parseElement = [&]() -> ParseResult {
+ return failure(parser.parseOperand(argNames.emplace_back()) ||
+ parser.parseColonType(argTypes.emplace_back()));
+ };
+
+ return parser.parseCommaSeparatedList(OpAsmParser::Delimiter::Paren,
+ parseElement, " in argument list");
}
static void printLaunchFuncOperands(OpAsmPrinter &printer, Operation *,
diff --git a/mlir/test/Dialect/GPU/ops.mlir b/mlir/test/Dialect/GPU/ops.mlir
index 301ab91739965..5bb5efb2a4491 100644
--- a/mlir/test/Dialect/GPU/ops.mlir
+++ b/mlir/test/Dialect/GPU/ops.mlir
@@ -121,6 +121,8 @@ module attributes {gpu.container_module} {
}
}
+ func.func private @two_value_generator() -> (f32, memref<?xf32, 1>)
+
func.func @foo() {
%0 = "op"() : () -> (f32)
%1 = "op"() : () -> (memref<?xf32, 1>)
@@ -140,6 +142,11 @@ module attributes {gpu.container_module} {
// CHECK: %{{.*}} = gpu.launch_func async [%{{.*}}] @kernels::@kernel_2 blocks in (%{{.*}}, %{{.*}}, %{{.*}}) threads in (%{{.*}}, %{{.*}}, %{{.*}})
%t1 = gpu.launch_func async [%t0] @kernels::@kernel_2 blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst)
+ // CHECK: %[[VALUES:.*]]:2 = call
+ %values:2 = func.call @two_value_generator() : () -> (f32, memref<?xf32, 1>)
+ // CHECK: gpu.launch_func @kernels::@kernel_1 {{.*}} args(%[[VALUES]]#0 : f32, %[[VALUES]]#1 : memref<?xf32, 1>)
+ gpu.launch_func @kernels::@kernel_1 blocks in (%cst, %cst, %cst) threads in (%cst, %cst, %cst) args(%values#0 : f32, %values#1 : memref<?xf32, 1>)
+
return
}
More information about the Mlir-commits
mailing list