Skip to content

Commit 04831ef

Browse files
committed
Add description for mapper_id. Add verifier check for valid mapper_id.
1 parent e70f3c9 commit 04831ef

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@ def MapInfoOp : OpenMP_Op<"map.info", [AttrSizedOperandSegments]> {
10771077
- 'map_type': OpenMP map type for this map capture, for example: from, to and
10781078
always. It's a bitfield composed of the OpenMP runtime flags stored in
10791079
OpenMPOffloadMappingFlags.
1080+
- 'mapper_id': OpenMP mapper map type modifier for this map capture. It's used to
1081+
specify a user defined mapper to be used for mapping.
10801082
- 'map_capture_type': Capture type for the variable e.g. this, byref, byvalue, byvla
10811083
this can affect how the variable is lowered.
10821084
- `name`: Holds the name of variable as specified in user clause (including bounds).

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,12 @@ static LogicalResult verifyMapClause(Operation *op, OperandRange mapVars) {
16321632

16331633
to ? updateToVars.insert(updateVar) : updateFromVars.insert(updateVar);
16341634
}
1635+
1636+
if (mapInfoOp.getMapperId() &&
1637+
!SymbolTable::lookupNearestSymbolFrom<omp::DeclareMapperOp>(
1638+
mapInfoOp, mapInfoOp.getMapperIdAttr())) {
1639+
return emitError(op->getLoc(), "invalid mapper id");
1640+
}
16351641
} else if (!isa<DeclareMapperInfoOp>(op)) {
16361642
emitError(op->getLoc(), "map argument is not a map entry operation");
16371643
}

mlir/test/Dialect/OpenMP/invalid.mlir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,3 +2849,13 @@ func.func @missing_workshare(%idx : index) {
28492849
^bb0(%arg0: !llvm.ptr):
28502850
omp.terminator
28512851
}
2852+
2853+
// -----
2854+
llvm.func @invalid_mapper(%0 : !llvm.ptr) {
2855+
%1 = omp.map.info var_ptr(%0 : !llvm.ptr, !llvm.struct<"my_type", (i32)>) mapper(@my_mapper) map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
2856+
// expected-error @below {{invalid mapper id}}
2857+
omp.target_data map_entries(%1 : !llvm.ptr) {
2858+
omp.terminator
2859+
}
2860+
llvm.return
2861+
}

0 commit comments

Comments
 (0)