[Mlir-commits] [mlir] f3ead88 - [MLIR][OpenMP] Removed the ambiguity in flush op assembly syntax
Kiran Kumar T P
llvmlistbot at llvm.org
Mon Sep 28 21:12:22 PDT 2020
Author: Kiran Kumar T P
Date: 2020-09-29T09:41:46+05:30
New Revision: f3ead88e9c6c352edb10cba43e62696fc852c7d6
URL: https://github.com/llvm/llvm-project/commit/f3ead88e9c6c352edb10cba43e62696fc852c7d6
DIFF: https://github.com/llvm/llvm-project/commit/f3ead88e9c6c352edb10cba43e62696fc852c7d6.diff
LOG: [MLIR][OpenMP] Removed the ambiguity in flush op assembly syntax
Summary:
========
Bugzilla Ticket No: Bug 46884 [https://bugs.llvm.org/show_bug.cgi?id=46884]
Flush op assembly syntax was ambiguous:
Consider the below test case:
flush operation is not having any arguments.
But the next statement token i.e "%2" is read as the argument for flush operation and then translator issues an error.
***************************************************************
$ cat -n flush.mlir
1 llvm.func @_QQmain(%arg0: !llvm.i32) {
2 %0 = llvm.mlir.constant(1 : i64) : !llvm.i64
3 %1 = llvm.alloca %0 x !llvm.i32 {in_type = i32, name = "a"} : (!llvm.i64) -> !llvm.ptr<i32>
4 omp.flush
5 %2 = llvm.load %1 : !llvm.ptr<i32>
6 llvm.return
7 }
$ mlir-translate -mlir-to-llvmir flush.mlir
flush.mlir:5:6: error: expected ':'
%2 = llvm.load %1 : !llvm.ptr<i32>
^
***************************************************************
Solution:
=========
Introduced begin ( `(` ) and end token ( `)` ) to determince the begin and end of variadic arguments.
The patch includes code changes and testcase modifications.
Reviewed By: Valentin Clement, Mehdi AMINI
Differential Revision: https://reviews.llvm.org/D88376
Added:
Modified:
mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
mlir/test/Dialect/OpenMP/ops.mlir
mlir/test/Target/openmp-llvm.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
index ae0a5f3b6faa..4fa30d056183 100644
--- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -124,7 +124,7 @@ def FlushOp : OpenMP_Op<"flush"> {
let arguments = (ins Variadic<AnyType>:$varList);
- let assemblyFormat = "attr-dict ($varList^ `:` type($varList))?";
+ let assemblyFormat = [{ ( `(` $varList^ `:` type($varList) `)` )? attr-dict}];
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Dialect/OpenMP/ops.mlir b/mlir/test/Dialect/OpenMP/ops.mlir
index cfcfe0db2a15..c74f55b761c2 100644
--- a/mlir/test/Dialect/OpenMP/ops.mlir
+++ b/mlir/test/Dialect/OpenMP/ops.mlir
@@ -29,19 +29,19 @@ func @omp_taskyield() -> () {
}
// CHECK-LABEL: func @omp_flush
-// CHECK-SAME: %[[ARG0:.*]]: !llvm.i32
+// CHECK-SAME: ([[ARG0:%.*]]: !llvm.i32) {
func @omp_flush(%arg0 : !llvm.i32) -> () {
// Test without data var
// CHECK: omp.flush
omp.flush
// Test with one data var
- // CHECK: omp.flush %[[ARG0]] : !llvm.i32
- "omp.flush"(%arg0) : (!llvm.i32) -> ()
+ // CHECK: omp.flush([[ARG0]] : !llvm.i32)
+ omp.flush(%arg0 : !llvm.i32)
// Test with two data var
- // CHECK: omp.flush %[[ARG0]], %[[ARG0]] : !llvm.i32, !llvm.i32
- "omp.flush"(%arg0, %arg0): (!llvm.i32, !llvm.i32) -> ()
+ // CHECK: omp.flush([[ARG0]], [[ARG0]] : !llvm.i32, !llvm.i32)
+ omp.flush(%arg0, %arg0: !llvm.i32, !llvm.i32)
return
}
diff --git a/mlir/test/Target/openmp-llvm.mlir b/mlir/test/Target/openmp-llvm.mlir
index 1cfae359b935..518fa6fce2d4 100644
--- a/mlir/test/Target/openmp-llvm.mlir
+++ b/mlir/test/Target/openmp-llvm.mlir
@@ -24,10 +24,18 @@ llvm.func @test_flush_construct(%arg0: !llvm.i32) {
omp.flush
// CHECK: call void @__kmpc_flush(%struct.ident_t* @{{[0-9]+}}
- omp.flush %arg0 : !llvm.i32
+ omp.flush (%arg0 : !llvm.i32)
// CHECK: call void @__kmpc_flush(%struct.ident_t* @{{[0-9]+}}
- omp.flush %arg0, %arg0 : !llvm.i32, !llvm.i32
+ omp.flush (%arg0, %arg0 : !llvm.i32, !llvm.i32)
+
+ %0 = llvm.mlir.constant(1 : i64) : !llvm.i64
+ // CHECK: alloca {{.*}} align 4
+ %1 = llvm.alloca %0 x !llvm.i32 {in_type = i32, name = "a"} : (!llvm.i64) -> !llvm.ptr<i32>
+ // CHECK: call void @__kmpc_flush(%struct.ident_t* @{{[0-9]+}}
+ omp.flush
+ // CHECK: load i32, i32*
+ %2 = llvm.load %1 : !llvm.ptr<i32>
// CHECK-NEXT: ret void
llvm.return
More information about the Mlir-commits
mailing list