-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Flang][OpenMP][Dialect] Swap to using MLIR dialect enum to encode map flags #164043
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-mlir-openmp @llvm/pr-subscribers-flang-openmp Author: None (agozillon) ChangesThis 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. Patch is 112.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/164043.diff 32 Files Affected:
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 6ed3c1b7d61ee..2d6906738773a 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -39,7 +39,6 @@
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Value.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include <list>
#include <type_traits>
diff --git a/flang/include/flang/Utils/OpenMP.h b/flang/include/flang/Utils/OpenMP.h
index 01a94c9099808..bad0abb6f5788 100644
--- a/flang/include/flang/Utils/OpenMP.h
+++ b/flang/include/flang/Utils/OpenMP.h
@@ -29,8 +29,9 @@ mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
mlir::Location loc, mlir::Value baseAddr, mlir::Value varPtrPtr,
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
llvm::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
- uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
- mlir::Type retTy, bool partialMap = false,
+ mlir::omp::ClauseMapFlags mapType,
+ mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
+ bool partialMap = false,
mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
/// For an mlir value that does not have storage, allocate temporary storage
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 85398be778382..ce0c30cfcda75 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1080,9 +1080,8 @@ bool ClauseProcessor::processHasDeviceAddr(
[&](const omp::clause::HasDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::implicit;
omp::ObjectList baseObjects;
llvm::transform(clause.v, std::back_inserter(baseObjects),
[&](const omp::Object &object) {
@@ -1217,8 +1216,7 @@ bool ClauseProcessor::processLink(
void ClauseProcessor::processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
@@ -1310,10 +1308,7 @@ void ClauseProcessor::processMapObjects(
mlir::omp::MapInfoOp mapOp = utils::openmp::createMapInfoOp(
firOpBuilder, location, baseOp,
/*varPtrPtr=*/mlir::Value{}, asFortran.str(), bounds,
- /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- mapTypeBits),
+ /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{}, mapTypeBits,
mlir::omp::VariableCaptureKind::ByRef, baseOp.getType(),
/*partialMap=*/false, mapperId);
@@ -1347,8 +1342,7 @@ bool ClauseProcessor::processMap(
objects] = clause.t;
if (attachMod)
TODO(currentLocation, "ATTACH modifier is not implemented yet");
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
+ mlir::omp::ClauseMapFlags mapTypeBits = mlir::omp::ClauseMapFlags::none;
std::string mapperIdName = "__implicit_mapper";
// If the map type is specified, then process it else set the appropriate
// default value
@@ -1364,36 +1358,33 @@ bool ClauseProcessor::processMap(
switch (type) {
case Map::MapType::To:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::to;
break;
case Map::MapType::From:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Tofrom:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |=
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Storage:
- // alloc and release is the default map_type for the Target Data
- // Ops, i.e. if no bits for map_type is supplied then alloc/release
- // (aka storage in 6.0+) is implicitly assumed based on the target
- // directive. Default value for Target Data and Enter Data is alloc
- // and for Exit Data it is release.
+ default:
+ mapTypeBits |= mlir::omp::ClauseMapFlags::storage;
break;
}
if (typeMods) {
// TODO: Still requires "self" modifier, an OpenMP 6.0+ feature
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Always))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::always;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Present))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::close;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::del;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::ompx_hold;
}
if (iterator) {
@@ -1437,12 +1428,12 @@ bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
TODO(clauseLocation, "Iterator modifier is not supported yet");
}
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags mapTypeBits =
std::is_same_v<llvm::remove_cvref_t<decltype(clause)>, omp::clause::To>
- ? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
- : llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ ? mlir::omp::ClauseMapFlags::to
+ : mlir::omp::ClauseMapFlags::from;
if (expectation && *expectation == omp::clause::To::Expectation::Present)
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
processMapObjects(stmtCtx, clauseLocation, objects, mapTypeBits,
parentMemberIndices, result.mapVars, mapSymbols);
};
@@ -1568,8 +1559,8 @@ bool ClauseProcessor::processUseDeviceAddr(
[&](const omp::clause::UseDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDeviceAddrVars,
useDeviceSyms);
@@ -1589,8 +1580,8 @@ bool ClauseProcessor::processUseDevicePtr(
[&](const omp::clause::UseDevicePtr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDevicePtrVars,
useDeviceSyms);
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 9e352fa574a97..6452e39b97551 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -194,8 +194,7 @@ class ClauseProcessor {
void processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index ba34212dddba9..a0d49ce310581 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -16,8 +16,6 @@
#include "flang/Semantics/openmp-modifiers.h"
#include "flang/Semantics/symbol.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
#include <list>
#include <optional>
#include <tuple>
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index f86ee01355104..8edf25b341b69 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -44,7 +44,6 @@
#include "mlir/Support/StateStack.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
using namespace Fortran::lower::omp;
using namespace Fortran::common::openmp;
@@ -944,8 +943,7 @@ getDefaultmapIfPresent(const DefaultMapsTy &defaultMaps, mlir::Type varType) {
return DefMap::ImplicitBehavior::Default;
}
-static std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+static std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
lower::AbstractConverter &converter,
const DefaultMapsTy &defaultMaps, mlir::Type varType,
@@ -966,8 +964,7 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
return size <= ptrSize && align <= ptrAlign;
};
- llvm::omp::OpenMPOffloadMappingFlags mapFlag =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapFlag = mlir::omp::ClauseMapFlags::implicit;
auto implicitBehaviour = getDefaultmapIfPresent(defaultMaps, varType);
if (implicitBehaviour == DefMap::ImplicitBehavior::Default) {
@@ -985,8 +982,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
mlir::omp::DeclareTargetCaptureClause::link &&
declareTargetOp.getDeclareTargetDeviceType() !=
mlir::omp::DeclareTargetDeviceType::nohost) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
} else if (fir::isa_trivial(varType) || fir::isa_char(varType)) {
// Scalars behave as if they were "firstprivate".
@@ -995,18 +992,18 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
if (isLiteralType(varType)) {
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
} else {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
}
} else if (!fir::isa_builtin_cptr_type(varType)) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
return std::make_pair(mapFlag, captureKind);
}
switch (implicitBehaviour) {
case DefMap::ImplicitBehavior::Alloc:
- return std::make_pair(llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE,
+ return std::make_pair(mlir::omp::ClauseMapFlags::storage,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Firstprivate:
@@ -1015,26 +1012,22 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
"behaviour");
break;
case DefMap::ImplicitBehavior::From:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Present:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::present,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::To:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::to,
(fir::isa_trivial(varType) || fir::isa_char(varType))
? mlir::omp::VariableCaptureKind::ByCopy
: mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Tofrom:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Default:
@@ -1043,9 +1036,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
break;
}
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
}
@@ -2611,18 +2603,14 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
eleType = refType.getElementType();
- std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+ std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
mapFlagAndKind = getImplicitMapTypeAndKind(
firOpBuilder, converter, defaultMaps, eleType, loc, sym);
mlir::Value mapOp = createMapInfoOp(
firOpBuilder, converter.getCurrentLocation(), baseOp,
/*varPtrPtr=*/mlir::Value{}, name.str(), bounds, /*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- std::get<0>(mapFlagAndKind)),
+ /*membersIndex=*/mlir::ArrayAttr{}, std::get<0>(mapFlagAndKind),
std::get<1>(mapFlagAndKind), baseOp.getType(),
/*partialMap=*/false, mapperId);
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 37b926e2f23f2..6487f599df72a 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -273,7 +273,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits) {
+ mlir::omp::ClauseMapFlags mapTypeBits) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
/// Checks if an omp::Object is an array expression with a subscript, e.g.
@@ -414,11 +414,10 @@ mlir::Value createParentSymAndGenIntermediateMaps(
// be safer to just pass OMP_MAP_NONE as the map type, but we may still
// need some of the other map types the mapped member utilises, so for
// now it's good to keep an eye on this.
- llvm::omp::OpenMPOffloadMappingFlags interimMapType = mapTypeBits;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
- interimMapType &=
- ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags interimMapType = mapTypeBits;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::to;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::from;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::return_param;
// Create a map for the intermediate member and insert it and it's
// indices into the parentMemberIndices list to track it.
@@ -427,10 +426,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
/*varPtrPtr=*/mlir::Value{}, asFortran,
/*bounds=*/interimBounds,
/*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- interimMapType),
+ /*membersIndex=*/mlir::ArrayAttr{}, interimMapType,
mlir::omp::VariableCaptureKind::ByRef, curValue.getType());
parentMemberIndices.memberPlacementIndices.push_back(interimIndices);
@@ -563,7 +559,8 @@ void insertChildMapInfoIntoParent(
// it allows this to work with enter and exit without causing MLIR
// verification issues. The more appropriate thing may be to take
// the "main" map type clause from the directive being used.
- uint64_t mapType = indices.second.memberMap[0].getMapType();
+ mlir::omp::ClauseMapFlags mapType =
+ indices.second.memberMap[0].getMapType();
llvm::SmallVector<mlir::Value> members;
members.reserve(indices.second.memberMap.size());
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index 69499f9c7b621..ef1f37ac25529 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -134,7 +134,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits);
+ mlir::omp::ClauseMapFlags mapTypeBits);
omp::ObjectList gatherObjectsOf(omp::Object derivedTypeMember,
semantics::SemanticsContext &semaCtx);
diff --git a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
index 8b9991301aae8..817434ff3dc30 100644
--- a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
+++ b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
@@ -20,8 +20,6 @@
#include "mlir/IR/Operation.h"
#include "mlir/Pass/Pass.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
namespace flangomp {
#define GEN_PASS_DEF_AUTOMAPTOTARGETDATAPASS
#include "flang/Optimizer/OpenMP/Passes.h.inc"
@@ -120,12 +118,9 @@ class AutomapToTargetDataPass
builder, memOp.getLoc(), memOp.getMemref().getType...
[truncated]
|
|
@llvm/pr-subscribers-flang-fir-hlfir Author: None (agozillon) ChangesThis 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. Patch is 112.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/164043.diff 32 Files Affected:
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 6ed3c1b7d61ee..2d6906738773a 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -39,7 +39,6 @@
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Value.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include <list>
#include <type_traits>
diff --git a/flang/include/flang/Utils/OpenMP.h b/flang/include/flang/Utils/OpenMP.h
index 01a94c9099808..bad0abb6f5788 100644
--- a/flang/include/flang/Utils/OpenMP.h
+++ b/flang/include/flang/Utils/OpenMP.h
@@ -29,8 +29,9 @@ mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
mlir::Location loc, mlir::Value baseAddr, mlir::Value varPtrPtr,
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
llvm::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
- uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
- mlir::Type retTy, bool partialMap = false,
+ mlir::omp::ClauseMapFlags mapType,
+ mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
+ bool partialMap = false,
mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
/// For an mlir value that does not have storage, allocate temporary storage
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 85398be778382..ce0c30cfcda75 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1080,9 +1080,8 @@ bool ClauseProcessor::processHasDeviceAddr(
[&](const omp::clause::HasDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::implicit;
omp::ObjectList baseObjects;
llvm::transform(clause.v, std::back_inserter(baseObjects),
[&](const omp::Object &object) {
@@ -1217,8 +1216,7 @@ bool ClauseProcessor::processLink(
void ClauseProcessor::processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
@@ -1310,10 +1308,7 @@ void ClauseProcessor::processMapObjects(
mlir::omp::MapInfoOp mapOp = utils::openmp::createMapInfoOp(
firOpBuilder, location, baseOp,
/*varPtrPtr=*/mlir::Value{}, asFortran.str(), bounds,
- /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- mapTypeBits),
+ /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{}, mapTypeBits,
mlir::omp::VariableCaptureKind::ByRef, baseOp.getType(),
/*partialMap=*/false, mapperId);
@@ -1347,8 +1342,7 @@ bool ClauseProcessor::processMap(
objects] = clause.t;
if (attachMod)
TODO(currentLocation, "ATTACH modifier is not implemented yet");
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
+ mlir::omp::ClauseMapFlags mapTypeBits = mlir::omp::ClauseMapFlags::none;
std::string mapperIdName = "__implicit_mapper";
// If the map type is specified, then process it else set the appropriate
// default value
@@ -1364,36 +1358,33 @@ bool ClauseProcessor::processMap(
switch (type) {
case Map::MapType::To:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::to;
break;
case Map::MapType::From:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Tofrom:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |=
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Storage:
- // alloc and release is the default map_type for the Target Data
- // Ops, i.e. if no bits for map_type is supplied then alloc/release
- // (aka storage in 6.0+) is implicitly assumed based on the target
- // directive. Default value for Target Data and Enter Data is alloc
- // and for Exit Data it is release.
+ default:
+ mapTypeBits |= mlir::omp::ClauseMapFlags::storage;
break;
}
if (typeMods) {
// TODO: Still requires "self" modifier, an OpenMP 6.0+ feature
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Always))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::always;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Present))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::close;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::del;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::ompx_hold;
}
if (iterator) {
@@ -1437,12 +1428,12 @@ bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
TODO(clauseLocation, "Iterator modifier is not supported yet");
}
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags mapTypeBits =
std::is_same_v<llvm::remove_cvref_t<decltype(clause)>, omp::clause::To>
- ? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
- : llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ ? mlir::omp::ClauseMapFlags::to
+ : mlir::omp::ClauseMapFlags::from;
if (expectation && *expectation == omp::clause::To::Expectation::Present)
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
processMapObjects(stmtCtx, clauseLocation, objects, mapTypeBits,
parentMemberIndices, result.mapVars, mapSymbols);
};
@@ -1568,8 +1559,8 @@ bool ClauseProcessor::processUseDeviceAddr(
[&](const omp::clause::UseDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDeviceAddrVars,
useDeviceSyms);
@@ -1589,8 +1580,8 @@ bool ClauseProcessor::processUseDevicePtr(
[&](const omp::clause::UseDevicePtr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDevicePtrVars,
useDeviceSyms);
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 9e352fa574a97..6452e39b97551 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -194,8 +194,7 @@ class ClauseProcessor {
void processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index ba34212dddba9..a0d49ce310581 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -16,8 +16,6 @@
#include "flang/Semantics/openmp-modifiers.h"
#include "flang/Semantics/symbol.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
#include <list>
#include <optional>
#include <tuple>
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index f86ee01355104..8edf25b341b69 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -44,7 +44,6 @@
#include "mlir/Support/StateStack.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
using namespace Fortran::lower::omp;
using namespace Fortran::common::openmp;
@@ -944,8 +943,7 @@ getDefaultmapIfPresent(const DefaultMapsTy &defaultMaps, mlir::Type varType) {
return DefMap::ImplicitBehavior::Default;
}
-static std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+static std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
lower::AbstractConverter &converter,
const DefaultMapsTy &defaultMaps, mlir::Type varType,
@@ -966,8 +964,7 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
return size <= ptrSize && align <= ptrAlign;
};
- llvm::omp::OpenMPOffloadMappingFlags mapFlag =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapFlag = mlir::omp::ClauseMapFlags::implicit;
auto implicitBehaviour = getDefaultmapIfPresent(defaultMaps, varType);
if (implicitBehaviour == DefMap::ImplicitBehavior::Default) {
@@ -985,8 +982,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
mlir::omp::DeclareTargetCaptureClause::link &&
declareTargetOp.getDeclareTargetDeviceType() !=
mlir::omp::DeclareTargetDeviceType::nohost) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
} else if (fir::isa_trivial(varType) || fir::isa_char(varType)) {
// Scalars behave as if they were "firstprivate".
@@ -995,18 +992,18 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
if (isLiteralType(varType)) {
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
} else {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
}
} else if (!fir::isa_builtin_cptr_type(varType)) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
return std::make_pair(mapFlag, captureKind);
}
switch (implicitBehaviour) {
case DefMap::ImplicitBehavior::Alloc:
- return std::make_pair(llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE,
+ return std::make_pair(mlir::omp::ClauseMapFlags::storage,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Firstprivate:
@@ -1015,26 +1012,22 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
"behaviour");
break;
case DefMap::ImplicitBehavior::From:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Present:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::present,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::To:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::to,
(fir::isa_trivial(varType) || fir::isa_char(varType))
? mlir::omp::VariableCaptureKind::ByCopy
: mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Tofrom:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Default:
@@ -1043,9 +1036,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
break;
}
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
}
@@ -2611,18 +2603,14 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
eleType = refType.getElementType();
- std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+ std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
mapFlagAndKind = getImplicitMapTypeAndKind(
firOpBuilder, converter, defaultMaps, eleType, loc, sym);
mlir::Value mapOp = createMapInfoOp(
firOpBuilder, converter.getCurrentLocation(), baseOp,
/*varPtrPtr=*/mlir::Value{}, name.str(), bounds, /*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- std::get<0>(mapFlagAndKind)),
+ /*membersIndex=*/mlir::ArrayAttr{}, std::get<0>(mapFlagAndKind),
std::get<1>(mapFlagAndKind), baseOp.getType(),
/*partialMap=*/false, mapperId);
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 37b926e2f23f2..6487f599df72a 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -273,7 +273,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits) {
+ mlir::omp::ClauseMapFlags mapTypeBits) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
/// Checks if an omp::Object is an array expression with a subscript, e.g.
@@ -414,11 +414,10 @@ mlir::Value createParentSymAndGenIntermediateMaps(
// be safer to just pass OMP_MAP_NONE as the map type, but we may still
// need some of the other map types the mapped member utilises, so for
// now it's good to keep an eye on this.
- llvm::omp::OpenMPOffloadMappingFlags interimMapType = mapTypeBits;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
- interimMapType &=
- ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags interimMapType = mapTypeBits;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::to;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::from;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::return_param;
// Create a map for the intermediate member and insert it and it's
// indices into the parentMemberIndices list to track it.
@@ -427,10 +426,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
/*varPtrPtr=*/mlir::Value{}, asFortran,
/*bounds=*/interimBounds,
/*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- interimMapType),
+ /*membersIndex=*/mlir::ArrayAttr{}, interimMapType,
mlir::omp::VariableCaptureKind::ByRef, curValue.getType());
parentMemberIndices.memberPlacementIndices.push_back(interimIndices);
@@ -563,7 +559,8 @@ void insertChildMapInfoIntoParent(
// it allows this to work with enter and exit without causing MLIR
// verification issues. The more appropriate thing may be to take
// the "main" map type clause from the directive being used.
- uint64_t mapType = indices.second.memberMap[0].getMapType();
+ mlir::omp::ClauseMapFlags mapType =
+ indices.second.memberMap[0].getMapType();
llvm::SmallVector<mlir::Value> members;
members.reserve(indices.second.memberMap.size());
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index 69499f9c7b621..ef1f37ac25529 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -134,7 +134,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits);
+ mlir::omp::ClauseMapFlags mapTypeBits);
omp::ObjectList gatherObjectsOf(omp::Object derivedTypeMember,
semantics::SemanticsContext &semaCtx);
diff --git a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
index 8b9991301aae8..817434ff3dc30 100644
--- a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
+++ b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
@@ -20,8 +20,6 @@
#include "mlir/IR/Operation.h"
#include "mlir/Pass/Pass.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
namespace flangomp {
#define GEN_PASS_DEF_AUTOMAPTOTARGETDATAPASS
#include "flang/Optimizer/OpenMP/Passes.h.inc"
@@ -120,12 +118,9 @@ class AutomapToTargetDataPass
builder, memOp.getLoc(), memOp.getMemref().getType...
[truncated]
|
|
@llvm/pr-subscribers-mlir-llvm Author: None (agozillon) ChangesThis 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. Patch is 112.97 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/164043.diff 32 Files Affected:
diff --git a/flang/include/flang/Lower/DirectivesCommon.h b/flang/include/flang/Lower/DirectivesCommon.h
index 6ed3c1b7d61ee..2d6906738773a 100644
--- a/flang/include/flang/Lower/DirectivesCommon.h
+++ b/flang/include/flang/Lower/DirectivesCommon.h
@@ -39,7 +39,6 @@
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Value.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
#include <list>
#include <type_traits>
diff --git a/flang/include/flang/Utils/OpenMP.h b/flang/include/flang/Utils/OpenMP.h
index 01a94c9099808..bad0abb6f5788 100644
--- a/flang/include/flang/Utils/OpenMP.h
+++ b/flang/include/flang/Utils/OpenMP.h
@@ -29,8 +29,9 @@ mlir::omp::MapInfoOp createMapInfoOp(mlir::OpBuilder &builder,
mlir::Location loc, mlir::Value baseAddr, mlir::Value varPtrPtr,
llvm::StringRef name, llvm::ArrayRef<mlir::Value> bounds,
llvm::ArrayRef<mlir::Value> members, mlir::ArrayAttr membersIndex,
- uint64_t mapType, mlir::omp::VariableCaptureKind mapCaptureType,
- mlir::Type retTy, bool partialMap = false,
+ mlir::omp::ClauseMapFlags mapType,
+ mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy,
+ bool partialMap = false,
mlir::FlatSymbolRefAttr mapperId = mlir::FlatSymbolRefAttr());
/// For an mlir value that does not have storage, allocate temporary storage
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 85398be778382..ce0c30cfcda75 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -1080,9 +1080,8 @@ bool ClauseProcessor::processHasDeviceAddr(
[&](const omp::clause::HasDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::implicit;
omp::ObjectList baseObjects;
llvm::transform(clause.v, std::back_inserter(baseObjects),
[&](const omp::Object &object) {
@@ -1217,8 +1216,7 @@ bool ClauseProcessor::processLink(
void ClauseProcessor::processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
@@ -1310,10 +1308,7 @@ void ClauseProcessor::processMapObjects(
mlir::omp::MapInfoOp mapOp = utils::openmp::createMapInfoOp(
firOpBuilder, location, baseOp,
/*varPtrPtr=*/mlir::Value{}, asFortran.str(), bounds,
- /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- mapTypeBits),
+ /*members=*/{}, /*membersIndex=*/mlir::ArrayAttr{}, mapTypeBits,
mlir::omp::VariableCaptureKind::ByRef, baseOp.getType(),
/*partialMap=*/false, mapperId);
@@ -1347,8 +1342,7 @@ bool ClauseProcessor::processMap(
objects] = clause.t;
if (attachMod)
TODO(currentLocation, "ATTACH modifier is not implemented yet");
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE;
+ mlir::omp::ClauseMapFlags mapTypeBits = mlir::omp::ClauseMapFlags::none;
std::string mapperIdName = "__implicit_mapper";
// If the map type is specified, then process it else set the appropriate
// default value
@@ -1364,36 +1358,33 @@ bool ClauseProcessor::processMap(
switch (type) {
case Map::MapType::To:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::to;
break;
case Map::MapType::From:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Tofrom:
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapTypeBits |=
+ mlir::omp::ClauseMapFlags::to | mlir::omp::ClauseMapFlags::from;
break;
case Map::MapType::Storage:
- // alloc and release is the default map_type for the Target Data
- // Ops, i.e. if no bits for map_type is supplied then alloc/release
- // (aka storage in 6.0+) is implicitly assumed based on the target
- // directive. Default value for Target Data and Enter Data is alloc
- // and for Exit Data it is release.
+ default:
+ mapTypeBits |= mlir::omp::ClauseMapFlags::storage;
break;
}
if (typeMods) {
// TODO: Still requires "self" modifier, an OpenMP 6.0+ feature
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Always))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_ALWAYS;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::always;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Present))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Close))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_CLOSE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::close;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::Delete))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_DELETE;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::del;
if (llvm::is_contained(*typeMods, Map::MapTypeModifier::OmpxHold))
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_OMPX_HOLD;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::ompx_hold;
}
if (iterator) {
@@ -1437,12 +1428,12 @@ bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
TODO(clauseLocation, "Iterator modifier is not supported yet");
}
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags mapTypeBits =
std::is_same_v<llvm::remove_cvref_t<decltype(clause)>, omp::clause::To>
- ? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
- : llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ ? mlir::omp::ClauseMapFlags::to
+ : mlir::omp::ClauseMapFlags::from;
if (expectation && *expectation == omp::clause::To::Expectation::Present)
- mapTypeBits |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT;
+ mapTypeBits |= mlir::omp::ClauseMapFlags::present;
processMapObjects(stmtCtx, clauseLocation, objects, mapTypeBits,
parentMemberIndices, result.mapVars, mapSymbols);
};
@@ -1568,8 +1559,8 @@ bool ClauseProcessor::processUseDeviceAddr(
[&](const omp::clause::UseDeviceAddr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDeviceAddrVars,
useDeviceSyms);
@@ -1589,8 +1580,8 @@ bool ClauseProcessor::processUseDevicePtr(
[&](const omp::clause::UseDevicePtr &clause,
const parser::CharBlock &source) {
mlir::Location location = converter.genLocation(source);
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags mapTypeBits =
+ mlir::omp::ClauseMapFlags::return_param;
processMapObjects(stmtCtx, location, clause.v, mapTypeBits,
parentMemberIndices, result.useDevicePtrVars,
useDeviceSyms);
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 9e352fa574a97..6452e39b97551 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -194,8 +194,7 @@ class ClauseProcessor {
void processMapObjects(
lower::StatementContext &stmtCtx, mlir::Location clauseLocation,
- const omp::ObjectList &objects,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits,
+ const omp::ObjectList &objects, mlir::omp::ClauseMapFlags mapTypeBits,
std::map<Object, OmpMapParentAndMemberData> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapVars,
llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index ba34212dddba9..a0d49ce310581 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -16,8 +16,6 @@
#include "flang/Semantics/openmp-modifiers.h"
#include "flang/Semantics/symbol.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
#include <list>
#include <optional>
#include <tuple>
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index f86ee01355104..8edf25b341b69 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -44,7 +44,6 @@
#include "mlir/Support/StateStack.h"
#include "mlir/Transforms/RegionUtils.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
using namespace Fortran::lower::omp;
using namespace Fortran::common::openmp;
@@ -944,8 +943,7 @@ getDefaultmapIfPresent(const DefaultMapsTy &defaultMaps, mlir::Type varType) {
return DefMap::ImplicitBehavior::Default;
}
-static std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+static std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
lower::AbstractConverter &converter,
const DefaultMapsTy &defaultMaps, mlir::Type varType,
@@ -966,8 +964,7 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
return size <= ptrSize && align <= ptrAlign;
};
- llvm::omp::OpenMPOffloadMappingFlags mapFlag =
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_IMPLICIT;
+ mlir::omp::ClauseMapFlags mapFlag = mlir::omp::ClauseMapFlags::implicit;
auto implicitBehaviour = getDefaultmapIfPresent(defaultMaps, varType);
if (implicitBehaviour == DefMap::ImplicitBehavior::Default) {
@@ -985,8 +982,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
mlir::omp::DeclareTargetCaptureClause::link &&
declareTargetOp.getDeclareTargetDeviceType() !=
mlir::omp::DeclareTargetDeviceType::nohost) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
} else if (fir::isa_trivial(varType) || fir::isa_char(varType)) {
// Scalars behave as if they were "firstprivate".
@@ -995,18 +992,18 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
if (isLiteralType(varType)) {
captureKind = mlir::omp::VariableCaptureKind::ByCopy;
} else {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
}
} else if (!fir::isa_builtin_cptr_type(varType)) {
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- mapFlag |= llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+ mapFlag |= mlir::omp::ClauseMapFlags::to;
+ mapFlag |= mlir::omp::ClauseMapFlags::from;
}
return std::make_pair(mapFlag, captureKind);
}
switch (implicitBehaviour) {
case DefMap::ImplicitBehavior::Alloc:
- return std::make_pair(llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_NONE,
+ return std::make_pair(mlir::omp::ClauseMapFlags::storage,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Firstprivate:
@@ -1015,26 +1012,22 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
"behaviour");
break;
case DefMap::ImplicitBehavior::From:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Present:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_PRESENT,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::present,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::To:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::to,
(fir::isa_trivial(varType) || fir::isa_char(varType))
? mlir::omp::VariableCaptureKind::ByCopy
: mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Tofrom:
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
break;
case DefMap::ImplicitBehavior::Default:
@@ -1043,9 +1036,8 @@ getImplicitMapTypeAndKind(fir::FirOpBuilder &firOpBuilder,
break;
}
- return std::make_pair(mapFlag |=
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM |
- llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO,
+ return std::make_pair(mapFlag |= mlir::omp::ClauseMapFlags::from |
+ mlir::omp::ClauseMapFlags::to,
mlir::omp::VariableCaptureKind::ByRef);
}
@@ -2611,18 +2603,14 @@ genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
if (auto refType = mlir::dyn_cast<fir::ReferenceType>(baseOp.getType()))
eleType = refType.getElementType();
- std::pair<llvm::omp::OpenMPOffloadMappingFlags,
- mlir::omp::VariableCaptureKind>
+ std::pair<mlir::omp::ClauseMapFlags, mlir::omp::VariableCaptureKind>
mapFlagAndKind = getImplicitMapTypeAndKind(
firOpBuilder, converter, defaultMaps, eleType, loc, sym);
mlir::Value mapOp = createMapInfoOp(
firOpBuilder, converter.getCurrentLocation(), baseOp,
/*varPtrPtr=*/mlir::Value{}, name.str(), bounds, /*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- std::get<0>(mapFlagAndKind)),
+ /*membersIndex=*/mlir::ArrayAttr{}, std::get<0>(mapFlagAndKind),
std::get<1>(mapFlagAndKind), baseOp.getType(),
/*partialMap=*/false, mapperId);
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index 37b926e2f23f2..6487f599df72a 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -273,7 +273,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits) {
+ mlir::omp::ClauseMapFlags mapTypeBits) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
/// Checks if an omp::Object is an array expression with a subscript, e.g.
@@ -414,11 +414,10 @@ mlir::Value createParentSymAndGenIntermediateMaps(
// be safer to just pass OMP_MAP_NONE as the map type, but we may still
// need some of the other map types the mapped member utilises, so for
// now it's good to keep an eye on this.
- llvm::omp::OpenMPOffloadMappingFlags interimMapType = mapTypeBits;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO;
- interimMapType &= ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
- interimMapType &=
- ~llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_RETURN_PARAM;
+ mlir::omp::ClauseMapFlags interimMapType = mapTypeBits;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::to;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::from;
+ interimMapType &= ~mlir::omp::ClauseMapFlags::return_param;
// Create a map for the intermediate member and insert it and it's
// indices into the parentMemberIndices list to track it.
@@ -427,10 +426,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
/*varPtrPtr=*/mlir::Value{}, asFortran,
/*bounds=*/interimBounds,
/*members=*/{},
- /*membersIndex=*/mlir::ArrayAttr{},
- static_cast<
- std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
- interimMapType),
+ /*membersIndex=*/mlir::ArrayAttr{}, interimMapType,
mlir::omp::VariableCaptureKind::ByRef, curValue.getType());
parentMemberIndices.memberPlacementIndices.push_back(interimIndices);
@@ -563,7 +559,8 @@ void insertChildMapInfoIntoParent(
// it allows this to work with enter and exit without causing MLIR
// verification issues. The more appropriate thing may be to take
// the "main" map type clause from the directive being used.
- uint64_t mapType = indices.second.memberMap[0].getMapType();
+ mlir::omp::ClauseMapFlags mapType =
+ indices.second.memberMap[0].getMapType();
llvm::SmallVector<mlir::Value> members;
members.reserve(indices.second.memberMap.size());
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index 69499f9c7b621..ef1f37ac25529 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -134,7 +134,7 @@ mlir::Value createParentSymAndGenIntermediateMaps(
semantics::SemanticsContext &semaCtx, lower::StatementContext &stmtCtx,
omp::ObjectList &objectList, llvm::SmallVectorImpl<int64_t> &indices,
OmpMapParentAndMemberData &parentMemberIndices, llvm::StringRef asFortran,
- llvm::omp::OpenMPOffloadMappingFlags mapTypeBits);
+ mlir::omp::ClauseMapFlags mapTypeBits);
omp::ObjectList gatherObjectsOf(omp::Object derivedTypeMember,
semantics::SemanticsContext &semaCtx);
diff --git a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
index 8b9991301aae8..817434ff3dc30 100644
--- a/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
+++ b/flang/lib/Optimizer/OpenMP/AutomapToTargetData.cpp
@@ -20,8 +20,6 @@
#include "mlir/IR/Operation.h"
#include "mlir/Pass/Pass.h"
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
namespace flangomp {
#define GEN_PASS_DEF_AUTOMAPTOTARGETDATAPASS
#include "flang/Optimizer/OpenMP/Passes.h.inc"
@@ -120,12 +118,9 @@ class AutomapToTargetDataPass
builder, memOp.getLoc(), memOp.getMemref().getType...
[truncated]
|
|
I've kept this in one block PR as we'll have to do the swap for all pieces at the same time or we'll have breakages and it's for the most part just amending tests and swapping to using the new syntax for combining the map flags in various locations. The main additions are a new openmp dialect enumerator for the map flags, and then a simple conversion function in the OpenMPToLLVMIRTranslation step to convert to the LLVM/runtime map flags from the new dialect flags. Happy to split this into multiple stacked PRs though if we wish to. |
cabe4db to
616b6e4
Compare
|
I would have done it the other way, i.e. make the MLIR dialect use the LLVM's values, but I don't have a strong opinion on this. I guess if we were to autogenerate the LLVM enum, it would make more sense to do it that way, but it's ok as it is. |
…p flags 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.
616b6e4 to
36bd7a3
Compare
lands in favor of downstream ref patch f2b20d3 [Flang][OpenMP][Dialect] Swap to using MLIR dialect enum to encode map flags (llvm#164043)
…p 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.
…p 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.
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.