Skip to content

Commit 86513d3

Browse files
committed
Add description for mapper_id. Add verifier check for valid mapper_id.
1 parent f7c3a65 commit 86513d3

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
@@ -1631,6 +1631,12 @@ static LogicalResult verifyMapClause(Operation *op, OperandRange mapVars) {
16311631

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

mlir/test/Dialect/OpenMP/invalid.mlir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2842,3 +2842,13 @@ func.func @missing_workshare(%idx : index) {
28422842
}
28432843
return
28442844
}
2845+
2846+
// -----
2847+
llvm.func @invalid_mapper(%0 : !llvm.ptr) {
2848+
%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 = ""}
2849+
// expected-error @below {{invalid mapper id}}
2850+
omp.target_data map_entries(%1 : !llvm.ptr) {
2851+
omp.terminator
2852+
}
2853+
llvm.return
2854+
}

0 commit comments

Comments
 (0)