Skip to content

Commit 5ca5a1f

Browse files
committed
Add description for mapper_id. Add verifier check for valid mapper_id.
1 parent 002d715 commit 5ca5a1f

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
@@ -1054,6 +1054,8 @@ def MapInfoOp : OpenMP_Op<"map.info", [AttrSizedOperandSegments]> {
10541054
- 'map_type': OpenMP map type for this map capture, for example: from, to and
10551055
always. It's a bitfield composed of the OpenMP runtime flags stored in
10561056
OpenMPOffloadMappingFlags.
1057+
- 'mapper_id': OpenMP mapper map type modifier for this map capture. It's used to
1058+
specify a user defined mapper to be used for mapping.
10571059
- 'map_capture_type': Capture type for the variable e.g. this, byref, byvalue, byvla
10581060
this can affect how the variable is lowered.
10591061
- `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
@@ -1592,6 +1592,12 @@ static LogicalResult verifyMapClause(Operation *op, OperandRange mapVars) {
15921592

15931593
to ? updateToVars.insert(updateVar) : updateFromVars.insert(updateVar);
15941594
}
1595+
1596+
if (mapInfoOp.getMapperId() &&
1597+
!SymbolTable::lookupNearestSymbolFrom<omp::DeclareMapperOp>(
1598+
mapInfoOp, mapInfoOp.getMapperIdAttr())) {
1599+
return emitError(op->getLoc(), "invalid mapper id");
1600+
}
15951601
} else if (!isa<DeclareMapperInfoOp>(op)) {
15961602
emitError(op->getLoc(), "map argument is not a map entry operation");
15971603
}

mlir/test/Dialect/OpenMP/invalid.mlir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2661,3 +2661,13 @@ func.func @missing_workshare(%idx : index) {
26612661
}
26622662
return
26632663
}
2664+
2665+
// -----
2666+
llvm.func @invalid_mapper(%0 : !llvm.ptr) {
2667+
%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 = ""}
2668+
// expected-error @below {{invalid mapper id}}
2669+
omp.target_data map_entries(%1 : !llvm.ptr) {
2670+
omp.terminator
2671+
}
2672+
llvm.return
2673+
}

0 commit comments

Comments
 (0)