Skip to content

Commit d96aaa0

Browse files
committed
Add region to DeclMapperOp. Move map clause to new DeclMapperInfoOp.
1 parent 7a8eb37 commit d96aaa0

File tree

3 files changed

+29
-23
lines changed

3 files changed

+29
-23
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def DistributeOp : OpenMP_Op<"distribute", traits = [
630630
will be executed in parallel by threads in the current context. These
631631
iterations are spread across threads that already exist in the enclosing
632632
region.
633-
633+
634634
The body region can only contain a single block which must contain a single
635635
operation. This operation must be another compatible loop wrapper or an
636636
`omp.loop_nest`.
@@ -1692,28 +1692,32 @@ def CancellationPointOp : OpenMP_Op<"cancellation_point", clauses = [
16921692
//===----------------------------------------------------------------------===//
16931693
// 2.19.7.3 Declare Mapper Directive
16941694
//===----------------------------------------------------------------------===//
1695-
def DeclareMapperOp : OpenMP_Op<"declare_mapper", traits = [
1696-
Symbol], clauses = [
1697-
OpenMP_MapClause
1698-
]> {
1695+
def DeclareMapperOp : OpenMP_Op<"declare_mapper", singleRegion = 1> {
16991696
let summary = "declare mapper directive";
17001697
let description = [{
17011698
The declare mapper directive declares a user-defined mapper for a given
17021699
type, and defines a mapper-identifier that can be used in a map clause.
17031700
}] # clausesDescription;
17041701

1705-
let arguments = !con((ins SymbolNameAttr:$sym_name,
1706-
OpenMP_PointerLikeType:$var_ptr,
1707-
TypeAttr:$var_type), clausesArgs);
1702+
let arguments = (ins SymbolNameAttr:$sym_name,
1703+
TypeAttr:$var_type);
1704+
1705+
let assemblyFormat = "$sym_name `:` $var_type $region attr-dict";
1706+
}
1707+
1708+
def DeclareMapperInfoOp : OpenMP_Op<"declare_mapper_info", clauses = [
1709+
OpenMP_MapClause
1710+
]> {
1711+
let summary = "declare mapper info";
1712+
let description = [{
1713+
This Op is used to capture the map information related to it's
1714+
parent DeclareMapperOp.]>
1715+
}] # clausesDescription;
17081716

17091717
let builders = [
1710-
OpBuilder<(ins CArg<"const DeclareMapperOperands &">:$clauses)>
1718+
OpBuilder<(ins CArg<"const DeclareMapperInfoOperands &">:$clauses)>
17111719
];
17121720

1713-
// Override clause-based assemblyFormat.
1714-
let assemblyFormat = "$sym_name `:` $var_ptr `:` type($var_ptr) `:` $var_type" # " oilist(" #
1715-
clausesOptAssemblyFormat # ") attr-dict";
1716-
17171721
let hasVerifier = 1;
17181722
}
17191723

@@ -1829,7 +1833,7 @@ def MaskedOp : OpenMP_Op<"masked", clauses = [
18291833
], singleRegion = 1> {
18301834
let summary = "masked construct";
18311835
let description = [{
1832-
Masked construct allows to specify a structured block to be executed by a subset of
1836+
Masked construct allows to specify a structured block to be executed by a subset of
18331837
threads of the current team.
18341838
}] # clausesDescription;
18351839

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,10 +2205,10 @@ LogicalResult DistributeOp::verifyRegions() {
22052205
}
22062206

22072207
//===----------------------------------------------------------------------===//
2208-
// DeclareMapperOp
2208+
// DeclareMapperInfoOp
22092209
//===----------------------------------------------------------------------===//
22102210

2211-
LogicalResult DeclareMapperOp::verify() {
2211+
LogicalResult DeclareMapperInfoOp::verify() {
22122212
return verifyMapClause(*this, getMapVars());
22132213
}
22142214

mlir/test/Dialect/OpenMP/ops.mlir

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -879,13 +879,15 @@ cleanup {
879879
omp.yield
880880
}
881881

882-
// CHECK: %[[DECL_VAR:.*]] = llvm.alloca %{{.*}}
883-
// CHECK: %[[DECL_MAP_INFO:.*]] = omp.map.info var_ptr(%[[DECL_VAR]] : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
884-
// CHECK: omp.declare_mapper @my_mapper : %[[DECL_VAR]] : !llvm.ptr : !llvm.struct<"my_type", (i32)> map_entries(%[[DECL_MAP_INFO]] : !llvm.ptr)
885-
%decl_c1 = arith.constant 1 : i64
886-
%decl_var = llvm.alloca %decl_c1 x !llvm.struct<"my_type", (i32)> : (i64) -> !llvm.ptr
887-
%decl_map_info = omp.map.info var_ptr(%decl_var : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
888-
omp.declare_mapper @my_mapper : %decl_var : !llvm.ptr : !llvm.struct<"my_type", (i32)> map_entries(%decl_map_info : !llvm.ptr)
882+
// CHECK: omp.declare_mapper @my_mapper : !llvm.struct<"my_type", (i32)>
883+
omp.declare_mapper @my_mapper : !llvm.struct<"my_type", (i32)> {
884+
^bb0(%arg: !llvm.ptr):
885+
// CHECK: %[[DECL_MAP_INFO:.*]] = omp.map.info var_ptr(%{{.*}} : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
886+
%decl_map_info = omp.map.info var_ptr(%arg : !llvm.ptr, !llvm.struct<"my_type", (i32)>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = ""}
887+
// CHECK: omp.declare_mapper_info map_entries(%[[DECL_MAP_INFO]] : !llvm.ptr)
888+
omp.declare_mapper_info map_entries(%decl_map_info : !llvm.ptr)
889+
omp.terminator
890+
}
889891

890892
// CHECK-LABEL: func @wsloop_reduction
891893
func.func @wsloop_reduction(%lb : index, %ub : index, %step : index) {

0 commit comments

Comments
 (0)