Skip to content

Commit 0e532b3

Browse files
committed
Add region to DeclMapperOp. Move map clause to new DeclMapperInfoOp.
1 parent 50eb188 commit 0e532b3

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
@@ -653,7 +653,7 @@ def DistributeOp : OpenMP_Op<"distribute", traits = [
653653
will be executed in parallel by threads in the current context. These
654654
iterations are spread across threads that already exist in the enclosing
655655
region.
656-
656+
657657
The body region can only contain a single block which must contain a single
658658
operation. This operation must be another compatible loop wrapper or an
659659
`omp.loop_nest`.
@@ -1752,28 +1752,32 @@ def ScanOp : OpenMP_Op<"scan", [
17521752
//===----------------------------------------------------------------------===//
17531753
// 2.19.7.3 Declare Mapper Directive
17541754
//===----------------------------------------------------------------------===//
1755-
def DeclareMapperOp : OpenMP_Op<"declare_mapper", traits = [
1756-
Symbol], clauses = [
1757-
OpenMP_MapClause
1758-
]> {
1755+
def DeclareMapperOp : OpenMP_Op<"declare_mapper", singleRegion = 1> {
17591756
let summary = "declare mapper directive";
17601757
let description = [{
17611758
The declare mapper directive declares a user-defined mapper for a given
17621759
type, and defines a mapper-identifier that can be used in a map clause.
17631760
}] # clausesDescription;
17641761

1765-
let arguments = !con((ins SymbolNameAttr:$sym_name,
1766-
OpenMP_PointerLikeType:$var_ptr,
1767-
TypeAttr:$var_type), clausesArgs);
1762+
let arguments = (ins SymbolNameAttr:$sym_name,
1763+
TypeAttr:$var_type);
1764+
1765+
let assemblyFormat = "$sym_name `:` $var_type $region attr-dict";
1766+
}
1767+
1768+
def DeclareMapperInfoOp : OpenMP_Op<"declare_mapper_info", clauses = [
1769+
OpenMP_MapClause
1770+
]> {
1771+
let summary = "declare mapper info";
1772+
let description = [{
1773+
This Op is used to capture the map information related to it's
1774+
parent DeclareMapperOp.]>
1775+
}] # clausesDescription;
17681776

17691777
let builders = [
1770-
OpBuilder<(ins CArg<"const DeclareMapperOperands &">:$clauses)>
1778+
OpBuilder<(ins CArg<"const DeclareMapperInfoOperands &">:$clauses)>
17711779
];
17721780

1773-
// Override clause-based assemblyFormat.
1774-
let assemblyFormat = "$sym_name `:` $var_ptr `:` type($var_ptr) `:` $var_type" # " oilist(" #
1775-
clausesOptAssemblyFormat # ") attr-dict";
1776-
17771781
let hasVerifier = 1;
17781782
}
17791783

@@ -1889,7 +1893,7 @@ def MaskedOp : OpenMP_Op<"masked", clauses = [
18891893
], singleRegion = 1> {
18901894
let summary = "masked construct";
18911895
let description = [{
1892-
Masked construct allows to specify a structured block to be executed by a subset of
1896+
Masked construct allows to specify a structured block to be executed by a subset of
18931897
threads of the current team.
18941898
}] # clausesDescription;
18951899

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

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

24352435
//===----------------------------------------------------------------------===//
2436-
// DeclareMapperOp
2436+
// DeclareMapperInfoOp
24372437
//===----------------------------------------------------------------------===//
24382438

2439-
LogicalResult DeclareMapperOp::verify() {
2439+
LogicalResult DeclareMapperInfoOp::verify() {
24402440
return verifyMapClause(*this, getMapVars());
24412441
}
24422442

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)