Skip to content

Commit 7f40216

Browse files
agozillonaokblast
authored andcommitted
[Flang][OpenMP][Dialect] Swap to using MLIR dialect enum to encode map flags (llvm#164043)
This PR shifts from using the LLVM OpenMP enumerator bit flags to an OpenMP dialect specific enumerator. This allows us to better represent map types that wouldn't be of interest to the LLVM backend and runtime in the dialect. Primarily things like ref_ptr/ref_ptee/ref_ptr_ptee/atach_none/attach_always/attach_auto which are of interest to the compiler for certrain transformations (primarily in the FIR transformation passes dealing with mapping), but the runtime has no need to know about them. It also means if another OpenMP implementation comes along they won't need to stick to the same bit flag system LLVM chose/do leg work to address it.
1 parent f217fd2 commit 7f40216

35 files changed

+422
-318
lines changed

flang/include/flang/Lower/DirectivesCommon.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
4040
#include "mlir/Dialect/SCF/IR/SCF.h"
4141
#include "mlir/IR/Value.h"
42-
#include "llvm/Frontend/OpenMP/OMPConstants.h"
4342
#include <list>
4443
#include <type_traits>
4544

flang/include/flang/Utils/OpenMP.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
2929
mlir::Location loc, mlir::Value baseAddr, mlir::Value varPtrPtr,
3030
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
3131
llvm::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
32-
uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
33-
mlir::Type retTy, bool partialMap = false,
32+
mlir::omp::ClauseMapFlags mapType,
33+
mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
34+
bool partialMap = false,
3435
mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
3536

3637
/// For an mlir value that does not have storage, allocate temporary storage

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,8 @@ bool ClauseProcessor::processHasDeviceAddr(
10801080
[&](const omp::clause::HasDeviceAddr &clause,
10811081
const parser::CharBlock &source) {
10821082
mlir::Location location = converter.genLocation(source);
1083-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1084-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
1085-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
1083+
mlir::omp::ClauseMapFlags mapTypeBits =
1084+
mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::implicit;
10861085
omp::ObjectList baseObjects;
10871086
llvm::transform(clause.v, std::back_inserter(baseObjects),
10881087
[&](const omp::Object &object) {
@@ -1217,8 +1216,7 @@ bool ClauseProcessor::processLink(
12171216

12181217
void ClauseProcessor::processMapObjects(
12191218
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
1220-
const omp::ObjectList &objects,
1221-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
1219+
const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
12221220
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
12231221
llvm::SmallVectorImpl<mlir::Value> &mapVars,
12241222
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
@@ -1310,10 +1308,7 @@ void ClauseProcessor::processMapObjects(
13101308
mlir::omp::MapInfoOp mapOp = utils::openmp::createMapInfoOp(
13111309
firOpBuilder, location, baseOp,
13121310
/*varPtrPtr=*/mlir::Value{}, asFortran.str(), bounds,
1313-
/*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{},
1314-
static_cast<
1315-
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
1316-
mapTypeBits),
1311+
/*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{}, mapTypeBits,
13171312
mlir::omp::VariableCaptureKind::ByRef, baseOp.getType(),
13181313
/*partialMap=*/false, mapperId);
13191314

@@ -1347,8 +1342,7 @@ bool ClauseProcessor::processMap(
13471342
objects] = clause.t;
13481343
if (attachMod)
13491344
TODO(currentLocation, "ATTACH modifier is not implemented yet");
1350-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1351-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
1345+
mlir::omp::ClauseMapFlags mapTypeBits = mlir::omp::ClauseMapFlags::none;
13521346
std::string mapperIdName = "__implicit_mapper";
13531347
// If the map type is specified, then process it else set the appropriate
13541348
// default value
@@ -1364,36 +1358,32 @@ bool ClauseProcessor::processMap(
13641358

13651359
switch (type) {
13661360
case Map::MapType::To:
1367-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
1361+
mapTypeBits |= mlir::omp::ClauseMapFlags::to;
13681362
break;
13691363
case Map::MapType::From:
1370-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
1364+
mapTypeBits |= mlir::omp::ClauseMapFlags::from;
13711365
break;
13721366
case Map::MapType::Tofrom:
1373-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
1374-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
1367+
mapTypeBits |=
1368+
mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::from;
13751369
break;
13761370
case Map::MapType::Storage:
1377-
// alloc and release is the default map_type for the Target Data
1378-
// Ops, i.e. if no bits for map_type is supplied then alloc/release
1379-
// (aka storage in 6.0+) is implicitly assumed based on the target
1380-
// directive. Default value for Target Data and Enter Data is alloc
1381-
// and for Exit Data it is release.
1371+
mapTypeBits |= mlir::omp::ClauseMapFlags::storage;
13821372
break;
13831373
}
13841374

13851375
if (typeMods) {
13861376
// TODO: Still requires "self" modifier, an OpenMP 6.0+ feature
13871377
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Always))
1388-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
1378+
mapTypeBits |= mlir::omp::ClauseMapFlags::always;
13891379
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Present))
1390-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
1380+
mapTypeBits |= mlir::omp::ClauseMapFlags::present;
13911381
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
1392-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
1382+
mapTypeBits |= mlir::omp::ClauseMapFlags::close;
13931383
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
1394-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
1384+
mapTypeBits |= mlir::omp::ClauseMapFlags::del;
13951385
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
1396-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
1386+
mapTypeBits |= mlir::omp::ClauseMapFlags::ompx_hold;
13971387
}
13981388

13991389
if (iterator) {
@@ -1437,12 +1427,12 @@ bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
14371427
TODO(clauseLocation, "Iterator modifier is not supported yet");
14381428
}
14391429

1440-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1430+
mlir::omp::ClauseMapFlags mapTypeBits =
14411431
std::is_same_v<llvm::remove_cvref_t<decltype(clause)>, omp::clause::To>
1442-
? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
1443-
: llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
1432+
? mlir::omp::ClauseMapFlags::to
1433+
: mlir::omp::ClauseMapFlags::from;
14441434
if (expectation && *expectation == omp::clause::To::Expectation::Present)
1445-
mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
1435+
mapTypeBits |= mlir::omp::ClauseMapFlags::present;
14461436
processMapObjects(stmtCtx, clauseLocation, objects, mapTypeBits,
14471437
parentMemberIndices, result.mapVars, mapSymbols);
14481438
};
@@ -1568,8 +1558,8 @@ bool ClauseProcessor::processUseDeviceAddr(
15681558
[&](const omp::clause::UseDeviceAddr &clause,
15691559
const parser::CharBlock &source) {
15701560
mlir::Location location = converter.genLocation(source);
1571-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1572-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
1561+
mlir::omp::ClauseMapFlags mapTypeBits =
1562+
mlir::omp::ClauseMapFlags::return_param;
15731563
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
15741564
parentMemberIndices, result.useDeviceAddrVars,
15751565
useDeviceSyms);
@@ -1589,8 +1579,8 @@ bool ClauseProcessor::processUseDevicePtr(
15891579
[&](const omp::clause::UseDevicePtr &clause,
15901580
const parser::CharBlock &source) {
15911581
mlir::Location location = converter.genLocation(source);
1592-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1593-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
1582+
mlir::omp::ClauseMapFlags mapTypeBits =
1583+
mlir::omp::ClauseMapFlags::return_param;
15941584
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
15951585
parentMemberIndices, result.useDevicePtrVars,
15961586
useDeviceSyms);

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,7 @@ class ClauseProcessor {
194194

195195
void processMapObjects(
196196
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
197-
const omp::ObjectList &objects,
198-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
197+
const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
199198
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
200199
llvm::SmallVectorImpl<mlir::Value> &mapVars,
201200
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include "flang/Semantics/openmp-modifiers.h"
1717
#include "flang/Semantics/symbol.h"
1818

19-
#include "llvm/Frontend/OpenMP/OMPConstants.h"
20-
2119
#include <list>
2220
#include <optional>
2321
#include <tuple>

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#include "mlir/Support/StateStack.h"
4646
#include "mlir/Transforms/RegionUtils.h"
4747
#include "llvm/ADT/STLExtras.h"
48-
#include "llvm/Frontend/OpenMP/OMPConstants.h"
4948

5049
using namespace Fortran::lower::omp;
5150
using namespace Fortran::common::openmp;
@@ -945,8 +944,7 @@ getDefaultmapIfPresent(const DefaultMapsTy &defaultMaps, mlir::Type varType) {
945944
return DefMap::ImplicitBehavior::Default;
946945
}
947946

948-
static std::pair<llvm::omp::OpenMPOffloadMappingFlags,
949-
mlir::omp::VariableCaptureKind>
947+
static std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
950948
getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
951949
lower::AbstractConverter &converter,
952950
const DefaultMapsTy &defaultMaps, mlir::Type varType,
@@ -967,8 +965,7 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
967965
return size <= ptrSize && align <= ptrAlign;
968966
};
969967

970-
llvm::omp::OpenMPOffloadMappingFlags mapFlag =
971-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
968+
mlir::omp::ClauseMapFlags mapFlag = mlir::omp::ClauseMapFlags::implicit;
972969

973970
auto implicitBehaviour = getDefaultmapIfPresent(defaultMaps, varType);
974971
if (implicitBehaviour == DefMap::ImplicitBehavior::Default) {
@@ -986,8 +983,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
986983
mlir::omp::DeclareTargetCaptureClause::link &&
987984
declareTargetOp.getDeclareTargetDeviceType() !=
988985
mlir::omp::DeclareTargetDeviceType::nohost) {
989-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
990-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
986+
mapFlag |= mlir::omp::ClauseMapFlags::to;
987+
mapFlag |= mlir::omp::ClauseMapFlags::from;
991988
}
992989
} else if (fir::isa_trivial(varType) || fir::isa_char(varType)) {
993990
// Scalars behave as if they were "firstprivate".
@@ -996,18 +993,18 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
996993
if (isLiteralType(varType)) {
997994
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
998995
} else {
999-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
996+
mapFlag |= mlir::omp::ClauseMapFlags::to;
1000997
}
1001998
} else if (!fir::isa_builtin_cptr_type(varType)) {
1002-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
1003-
mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
999+
mapFlag |= mlir::omp::ClauseMapFlags::to;
1000+
mapFlag |= mlir::omp::ClauseMapFlags::from;
10041001
}
10051002
return std::make_pair(mapFlag, captureKind);
10061003
}
10071004

10081005
switch (implicitBehaviour) {
10091006
case DefMap::ImplicitBehavior::Alloc:
1010-
return std::make_pair(llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE,
1007+
return std::make_pair(mlir::omp::ClauseMapFlags::storage,
10111008
mlir::omp::VariableCaptureKind::ByRef);
10121009
break;
10131010
case DefMap::ImplicitBehavior::Firstprivate:
@@ -1016,26 +1013,22 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
10161013
"behaviour");
10171014
break;
10181015
case DefMap::ImplicitBehavior::From:
1019-
return std::make_pair(mapFlag |=
1020-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM,
1016+
return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from,
10211017
mlir::omp::VariableCaptureKind::ByRef);
10221018
break;
10231019
case DefMap::ImplicitBehavior::Present:
1024-
return std::make_pair(mapFlag |=
1025-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT,
1020+
return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::present,
10261021
mlir::omp::VariableCaptureKind::ByRef);
10271022
break;
10281023
case DefMap::ImplicitBehavior::To:
1029-
return std::make_pair(mapFlag |=
1030-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
1024+
return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::to,
10311025
(fir::isa_trivial(varType) || fir::isa_char(varType))
10321026
? mlir::omp::VariableCaptureKind::ByCopy
10331027
: mlir::omp::VariableCaptureKind::ByRef);
10341028
break;
10351029
case DefMap::ImplicitBehavior::Tofrom:
1036-
return std::make_pair(mapFlag |=
1037-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
1038-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
1030+
return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
1031+
mlir::omp::ClauseMapFlags::to,
10391032
mlir::omp::VariableCaptureKind::ByRef);
10401033
break;
10411034
case DefMap::ImplicitBehavior::Default:
@@ -1044,9 +1037,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
10441037
break;
10451038
}
10461039

1047-
return std::make_pair(mapFlag |=
1048-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
1049-
llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
1040+
return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
1041+
mlir::omp::ClauseMapFlags::to,
10501042
mlir::omp::VariableCaptureKind::ByRef);
10511043
}
10521044

@@ -2612,18 +2604,14 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
26122604
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
26132605
eleType = refType.getElementType();
26142606

2615-
std::pair<llvm::omp::OpenMPOffloadMappingFlags,
2616-
mlir::omp::VariableCaptureKind>
2607+
std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
26172608
mapFlagAndKind = getImplicitMapTypeAndKind(
26182609
firOpBuilder, converter, defaultMaps, eleType, loc, sym);
26192610

26202611
mlir::Value mapOp = createMapInfoOp(
26212612
firOpBuilder, converter.getCurrentLocation(), baseOp,
26222613
/*varPtrPtr=*/mlir::Value{}, name.str(), bounds, /*members=*/{},
2623-
/*membersIndex=*/mlir::ArrayAttr{},
2624-
static_cast<
2625-
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
2626-
std::get<0>(mapFlagAndKind)),
2614+
/*membersIndex=*/mlir::ArrayAttr{}, std::get<0>(mapFlagAndKind),
26272615
std::get<1>(mapFlagAndKind), baseOp.getType(),
26282616
/*partialMap=*/false, mapperId);
26292617

flang/lib/Lower/OpenMP/Utils.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
273273
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
274274
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
275275
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
276-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits) {
276+
mlir::omp::ClauseMapFlags mapTypeBits) {
277277
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
278278

279279
/// Checks if an omp::Object is an array expression with a subscript, e.g.
@@ -414,11 +414,10 @@ mlir::Value createParentSymAndGenIntermediateMaps(
414414
// be safer to just pass OMP_MAP_NONE as the map type, but we may still
415415
// need some of the other map types the mapped member utilises, so for
416416
// now it's good to keep an eye on this.
417-
llvm::omp::OpenMPOffloadMappingFlags interimMapType = mapTypeBits;
418-
interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
419-
interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
420-
interimMapType &=
421-
~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
417+
mlir::omp::ClauseMapFlags interimMapType = mapTypeBits;
418+
interimMapType &= ~mlir::omp::ClauseMapFlags::to;
419+
interimMapType &= ~mlir::omp::ClauseMapFlags::from;
420+
interimMapType &= ~mlir::omp::ClauseMapFlags::return_param;
422421

423422
// Create a map for the intermediate member and insert it and it's
424423
// indices into the parentMemberIndices list to track it.
@@ -427,10 +426,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
427426
/*varPtrPtr=*/mlir::Value{}, asFortran,
428427
/*bounds=*/interimBounds,
429428
/*members=*/{},
430-
/*membersIndex=*/mlir::ArrayAttr{},
431-
static_cast<
432-
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
433-
interimMapType),
429+
/*membersIndex=*/mlir::ArrayAttr{}, interimMapType,
434430
mlir::omp::VariableCaptureKind::ByRef, curValue.getType());
435431

436432
parentMemberIndices.memberPlacementIndices.push_back(interimIndices);
@@ -563,7 +559,8 @@ void insertChildMapInfoIntoParent(
563559
// it allows this to work with enter and exit without causing MLIR
564560
// verification issues. The more appropriate thing may be to take
565561
// the "main" map type clause from the directive being used.
566-
uint64_t mapType = indices.second.memberMap[0].getMapType();
562+
mlir::omp::ClauseMapFlags mapType =
563+
indices.second.memberMap[0].getMapType();
567564

568565
llvm::SmallVector<mlir::Value> members;
569566
members.reserve(indices.second.memberMap.size());

flang/lib/Lower/OpenMP/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
134134
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
135135
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
136136
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
137-
llvm::omp::OpenMPOffloadMappingFlags mapTypeBits);
137+
mlir::omp::ClauseMapFlags mapTypeBits);
138138

139139
omp::ObjectList gatherObjectsOf(omp::Object derivedTypeMember,
140140
semantics::SemanticsContext &semaCtx);

flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#include "mlir/IR/Operation.h"
2121
#include "mlir/Pass/Pass.h"
2222

23-
#include "llvm/Frontend/OpenMP/OMPConstants.h"
24-
2523
namespace flangomp {
2624
#define GEN_PASS_DEF_AUTOMAPTOTARGETDATAPASS
2725
#include "flang/Optimizer/OpenMP/Passes.h.inc"
@@ -120,12 +118,9 @@ class AutomapToTargetDataPass
120118
builder, memOp.getLoc(), memOp.getMemref().getType(),
121119
memOp.getMemref(),
122120
TypeAttr::get(fir::unwrapRefType(memOp.getMemref().getType())),
123-
builder.getIntegerAttr(
124-
builder.getIntegerType(64, false),
125-
static_cast<unsigned>(
126-
isa<fir::StoreOp>(memOp)
127-
? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
128-
: llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE)),
121+
builder.getAttr<omp::ClauseMapFlagsAttr>(
122+
isa<fir::StoreOp>(memOp) ? omp::ClauseMapFlags::to
123+
: omp::ClauseMapFlags::del),
129124
builder.getAttr<omp::VariableCaptureKindAttr>(
130125
omp::VariableCaptureKind::ByCopy),
131126
/*var_ptr_ptr=*/mlir::Value{},

0 commit comments

Comments
 (0)