[flang-commits] [flang] [flang][OpenMP] Remove unnecessary `Fortran::` qualification, NFC (PR #92298)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Wed May 15 10:38:57 PDT 2024
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/92298
The `Fortran::` namespace is obvious for all parts of the code in this PR.
>From d29939f4e5ba9f1c410542748b934f7c8e786b50 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Wed, 15 May 2024 12:22:26 -0500
Subject: [PATCH] [flang][OpenMP] Remove unnecessary Fortran:: qualification,
NFC
The `Fortran::` namespace is obvious for all parts of the code
in this PR.
---
flang/lib/Lower/OpenMP/ClauseProcessor.cpp | 201 ++--
flang/lib/Lower/OpenMP/ClauseProcessor.h | 113 +-
flang/lib/Lower/OpenMP/Clauses.cpp | 7 +-
flang/lib/Lower/OpenMP/Clauses.h | 7 +-
.../lib/Lower/OpenMP/DataSharingProcessor.cpp | 148 ++-
flang/lib/Lower/OpenMP/DataSharingProcessor.h | 66 +-
flang/lib/Lower/OpenMP/OpenMP.cpp | 1057 ++++++++---------
flang/lib/Lower/OpenMP/ReductionProcessor.cpp | 23 +-
flang/lib/Lower/OpenMP/ReductionProcessor.h | 13 +-
flang/lib/Lower/OpenMP/Utils.cpp | 100 +-
flang/lib/Lower/OpenMP/Utils.h | 24 +-
11 files changed, 790 insertions(+), 969 deletions(-)
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
index 0ea87314d571f..40d66460a6984 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp
@@ -62,13 +62,13 @@ getSimdModifier(const omp::clause::Schedule &clause) {
}
static void
-genAllocateClause(Fortran::lower::AbstractConverter &converter,
+genAllocateClause(lower::AbstractConverter &converter,
const omp::clause::Allocate &clause,
llvm::SmallVectorImpl<mlir::Value> &allocatorOperands,
llvm::SmallVectorImpl<mlir::Value> &allocateOperands) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::Location currentLocation = converter.getCurrentLocation();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
auto &objects = std::get<omp::ObjectList>(clause.t);
@@ -144,7 +144,7 @@ genDependKindAttr(fir::FirOpBuilder &firOpBuilder,
}
static mlir::Value
-getIfClauseOperand(Fortran::lower::AbstractConverter &converter,
+getIfClauseOperand(lower::AbstractConverter &converter,
const omp::clause::If &clause,
omp::clause::If::DirectiveNameModifier directiveName,
mlir::Location clauseLocation) {
@@ -154,7 +154,7 @@ getIfClauseOperand(Fortran::lower::AbstractConverter &converter,
if (directive && directive.value() != directiveName)
return nullptr;
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::Value ifVal = fir::getBase(
converter.genExprValue(std::get<omp::SomeExpr>(clause.t), stmtCtx));
@@ -163,12 +163,11 @@ getIfClauseOperand(Fortran::lower::AbstractConverter &converter,
}
static void addUseDeviceClause(
- Fortran::lower::AbstractConverter &converter,
- const omp::ObjectList &objects,
+ lower::AbstractConverter &converter, const omp::ObjectList &objects,
llvm::SmallVectorImpl<mlir::Value> &operands,
llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &useDeviceSyms) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) {
genObjectList(objects, converter, operands);
for (mlir::Value &operand : operands) {
checkMapType(operand.getLoc(), operand.getType());
@@ -179,7 +178,7 @@ static void addUseDeviceClause(
useDeviceSyms.push_back(object.id());
}
-static void convertLoopBounds(Fortran::lower::AbstractConverter &converter,
+static void convertLoopBounds(lower::AbstractConverter &converter,
mlir::Location loc,
mlir::omp::CollapseClauseOps &result,
std::size_t loopVarTypeSize) {
@@ -202,45 +201,43 @@ static void convertLoopBounds(Fortran::lower::AbstractConverter &converter,
//===----------------------------------------------------------------------===//
bool ClauseProcessor::processCollapse(
- mlir::Location currentLocation, Fortran::lower::pft::Evaluation &eval,
+ mlir::Location currentLocation, lower::pft::Evaluation &eval,
mlir::omp::CollapseClauseOps &result,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &iv) const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &iv) const {
bool found = false;
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
// Collect the loops to collapse.
- Fortran::lower::pft::Evaluation *doConstructEval =
- &eval.getFirstNestedEvaluation();
- if (doConstructEval->getIf<Fortran::parser::DoConstruct>()
- ->IsDoConcurrent()) {
+ lower::pft::Evaluation *doConstructEval = &eval.getFirstNestedEvaluation();
+ if (doConstructEval->getIf<parser::DoConstruct>()->IsDoConcurrent()) {
TODO(currentLocation, "Do Concurrent in Worksharing loop construct");
}
std::int64_t collapseValue = 1l;
if (auto *clause = findUniqueClause<omp::clause::Collapse>()) {
- collapseValue = Fortran::evaluate::ToInt64(clause->v).value();
+ collapseValue = evaluate::ToInt64(clause->v).value();
found = true;
}
std::size_t loopVarTypeSize = 0;
do {
- Fortran::lower::pft::Evaluation *doLoop =
+ lower::pft::Evaluation *doLoop =
&doConstructEval->getFirstNestedEvaluation();
- auto *doStmt = doLoop->getIf<Fortran::parser::NonLabelDoStmt>();
+ auto *doStmt = doLoop->getIf<parser::NonLabelDoStmt>();
assert(doStmt && "Expected do loop to be in the nested evaluation");
const auto &loopControl =
- std::get<std::optional<Fortran::parser::LoopControl>>(doStmt->t);
- const Fortran::parser::LoopControl::Bounds *bounds =
- std::get_if<Fortran::parser::LoopControl::Bounds>(&loopControl->u);
+ std::get<std::optional<parser::LoopControl>>(doStmt->t);
+ const parser::LoopControl::Bounds *bounds =
+ std::get_if<parser::LoopControl::Bounds>(&loopControl->u);
assert(bounds && "Expected bounds for worksharing do loop");
- Fortran::lower::StatementContext stmtCtx;
- result.loopLBVar.push_back(fir::getBase(converter.genExprValue(
- *Fortran::semantics::GetExpr(bounds->lower), stmtCtx)));
- result.loopUBVar.push_back(fir::getBase(converter.genExprValue(
- *Fortran::semantics::GetExpr(bounds->upper), stmtCtx)));
+ lower::StatementContext stmtCtx;
+ result.loopLBVar.push_back(fir::getBase(
+ converter.genExprValue(*semantics::GetExpr(bounds->lower), stmtCtx)));
+ result.loopUBVar.push_back(fir::getBase(
+ converter.genExprValue(*semantics::GetExpr(bounds->upper), stmtCtx)));
if (bounds->step) {
- result.loopStepVar.push_back(fir::getBase(converter.genExprValue(
- *Fortran::semantics::GetExpr(bounds->step), stmtCtx)));
+ result.loopStepVar.push_back(fir::getBase(
+ converter.genExprValue(*semantics::GetExpr(bounds->step), stmtCtx)));
} else { // If `step` is not present, assume it as `1`.
result.loopStepVar.push_back(firOpBuilder.createIntegerConstant(
currentLocation, firOpBuilder.getIntegerType(32), 1));
@@ -280,9 +277,9 @@ bool ClauseProcessor::processDefault() const {
return false;
}
-bool ClauseProcessor::processDevice(Fortran::lower::StatementContext &stmtCtx,
+bool ClauseProcessor::processDevice(lower::StatementContext &stmtCtx,
mlir::omp::DeviceClauseOps &result) const {
- const Fortran::parser::CharBlock *source = nullptr;
+ const parser::CharBlock *source = nullptr;
if (auto *clause = findUniqueClause<omp::clause::Device>(&source)) {
mlir::Location clauseLocation = converter.genLocation(*source);
if (auto deviceModifier =
@@ -320,9 +317,9 @@ bool ClauseProcessor::processDeviceType(
return false;
}
-bool ClauseProcessor::processFinal(Fortran::lower::StatementContext &stmtCtx,
+bool ClauseProcessor::processFinal(lower::StatementContext &stmtCtx,
mlir::omp::FinalClauseOps &result) const {
- const Fortran::parser::CharBlock *source = nullptr;
+ const parser::CharBlock *source = nullptr;
if (auto *clause = findUniqueClause<omp::clause::Final>(&source)) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::Location clauseLocation = converter.genLocation(*source);
@@ -339,7 +336,7 @@ bool ClauseProcessor::processFinal(Fortran::lower::StatementContext &stmtCtx,
bool ClauseProcessor::processHint(mlir::omp::HintClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::Hint>()) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- int64_t hintValue = *Fortran::evaluate::ToInt64(clause->v);
+ int64_t hintValue = *evaluate::ToInt64(clause->v);
result.hintAttr = firOpBuilder.getI64IntegerAttr(hintValue);
return true;
}
@@ -356,7 +353,7 @@ bool ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const {
}
bool ClauseProcessor::processNumTeams(
- Fortran::lower::StatementContext &stmtCtx,
+ lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const {
// TODO Get lower and upper bounds for num_teams when parser is updated to
// accept both.
@@ -371,7 +368,7 @@ bool ClauseProcessor::processNumTeams(
}
bool ClauseProcessor::processNumThreads(
- Fortran::lower::StatementContext &stmtCtx,
+ lower::StatementContext &stmtCtx,
mlir::omp::NumThreadsClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::NumThreads>()) {
// OMPIRBuilder expects `NUM_THREADS` clause as a `Value`.
@@ -388,7 +385,7 @@ bool ClauseProcessor::processOrdered(
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
int64_t orderedClauseValue = 0l;
if (clause->v.has_value())
- orderedClauseValue = *Fortran::evaluate::ToInt64(*clause->v);
+ orderedClauseValue = *evaluate::ToInt64(*clause->v);
result.orderedAttr = firOpBuilder.getI64IntegerAttr(orderedClauseValue);
return true;
}
@@ -396,7 +393,7 @@ bool ClauseProcessor::processOrdered(
}
bool ClauseProcessor::processPriority(
- Fortran::lower::StatementContext &stmtCtx,
+ lower::StatementContext &stmtCtx,
mlir::omp::PriorityClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::Priority>()) {
result.priorityVar =
@@ -420,8 +417,7 @@ bool ClauseProcessor::processSafelen(
mlir::omp::SafelenClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::Safelen>()) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- const std::optional<std::int64_t> safelenVal =
- Fortran::evaluate::ToInt64(clause->v);
+ const std::optional<std::int64_t> safelenVal = evaluate::ToInt64(clause->v);
result.safelenAttr = firOpBuilder.getI64IntegerAttr(*safelenVal);
return true;
}
@@ -429,7 +425,7 @@ bool ClauseProcessor::processSafelen(
}
bool ClauseProcessor::processSchedule(
- Fortran::lower::StatementContext &stmtCtx,
+ lower::StatementContext &stmtCtx,
mlir::omp::ScheduleClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::Schedule>()) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -479,8 +475,7 @@ bool ClauseProcessor::processSimdlen(
mlir::omp::SimdlenClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::Simdlen>()) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- const std::optional<std::int64_t> simdlenVal =
- Fortran::evaluate::ToInt64(clause->v);
+ const std::optional<std::int64_t> simdlenVal = evaluate::ToInt64(clause->v);
result.simdlenAttr = firOpBuilder.getI64IntegerAttr(*simdlenVal);
return true;
}
@@ -488,7 +483,7 @@ bool ClauseProcessor::processSimdlen(
}
bool ClauseProcessor::processThreadLimit(
- Fortran::lower::StatementContext &stmtCtx,
+ lower::StatementContext &stmtCtx,
mlir::omp::ThreadLimitClauseOps &result) const {
if (auto *clause = findUniqueClause<omp::clause::ThreadLimit>()) {
result.threadLimitVar =
@@ -509,8 +504,7 @@ bool ClauseProcessor::processUntied(mlir::omp::UntiedClauseOps &result) const {
bool ClauseProcessor::processAllocate(
mlir::omp::AllocateClauseOps &result) const {
return findRepeatableClause<omp::clause::Allocate>(
- [&](const omp::clause::Allocate &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Allocate &clause, const parser::CharBlock &) {
genAllocateClause(converter, clause, result.allocatorVars,
result.allocateVars);
});
@@ -521,30 +515,28 @@ bool ClauseProcessor::processCopyin() const {
mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint();
firOpBuilder.setInsertionPointToStart(firOpBuilder.getAllocaBlock());
auto checkAndCopyHostAssociateVar =
- [&](Fortran::semantics::Symbol *sym,
+ [&](semantics::Symbol *sym,
mlir::OpBuilder::InsertPoint *copyAssignIP = nullptr) {
- assert(sym->has<Fortran::semantics::HostAssocDetails>() &&
+ assert(sym->has<semantics::HostAssocDetails>() &&
"No host-association found");
if (converter.isPresentShallowLookup(*sym))
converter.copyHostAssociateVar(*sym, copyAssignIP);
};
bool hasCopyin = findRepeatableClause<omp::clause::Copyin>(
- [&](const omp::clause::Copyin &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Copyin &clause, const parser::CharBlock &) {
for (const omp::Object &object : clause.v) {
- Fortran::semantics::Symbol *sym = object.id();
+ semantics::Symbol *sym = object.id();
assert(sym && "Expecting symbol");
if (const auto *commonDetails =
- sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
+ sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDetails->objects())
checkAndCopyHostAssociateVar(&*mem, &insPt);
break;
}
- if (Fortran::semantics::IsAllocatableOrObjectPointer(
- &sym->GetUltimate()))
+ if (semantics::IsAllocatableOrObjectPointer(&sym->GetUltimate()))
TODO(converter.getCurrentLocation(),
"pointer or allocatable variables in Copyin clause");
- assert(sym->has<Fortran::semantics::HostAssocDetails>() &&
+ assert(sym->has<semantics::HostAssocDetails>() &&
"No host-association found");
checkAndCopyHostAssociateVar(sym);
}
@@ -616,7 +608,7 @@ void TypeInfo::typeScan(mlir::Type ty) {
// Create a function that performs a copy between two variables, compatible
// with their types and attributes.
static mlir::func::FuncOp
-createCopyFunc(mlir::Location loc, Fortran::lower::AbstractConverter &converter,
+createCopyFunc(mlir::Location loc, lower::AbstractConverter &converter,
mlir::Type varType, fir::FortranVariableFlagsEnum varAttrs) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
mlir::ModuleOp module = builder.getModule();
@@ -671,7 +663,7 @@ createCopyFunc(mlir::Location loc, Fortran::lower::AbstractConverter &converter,
bool ClauseProcessor::processCopyprivate(
mlir::Location currentLocation,
mlir::omp::CopyprivateClauseOps &result) const {
- auto addCopyPrivateVar = [&](Fortran::semantics::Symbol *sym) {
+ auto addCopyPrivateVar = [&](semantics::Symbol *sym) {
mlir::Value symVal = converter.getSymbolAddress(*sym);
auto declOp = symVal.getDefiningOp<hlfir::DeclareOp>();
if (!declOp)
@@ -704,12 +696,11 @@ bool ClauseProcessor::processCopyprivate(
};
bool hasCopyPrivate = findRepeatableClause<clause::Copyprivate>(
- [&](const clause::Copyprivate &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const clause::Copyprivate &clause, const parser::CharBlock &) {
for (const Object &object : clause.v) {
- Fortran::semantics::Symbol *sym = object.id();
+ semantics::Symbol *sym = object.id();
if (const auto *commonDetails =
- sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
+ sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDetails->objects())
addCopyPrivateVar(&*mem);
break;
@@ -725,8 +716,7 @@ bool ClauseProcessor::processDepend(mlir::omp::DependClauseOps &result) const {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
return findRepeatableClause<omp::clause::Depend>(
- [&](const omp::clause::Depend &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Depend &clause, const parser::CharBlock &) {
using Depend = omp::clause::Depend;
assert(std::holds_alternative<Depend::WithLocators>(clause.u) &&
"Only the modern form is handled at the moment");
@@ -741,15 +731,15 @@ bool ClauseProcessor::processDepend(mlir::omp::DependClauseOps &result) const {
for (const omp::Object &object : objects) {
assert(object.ref() && "Expecting designator");
- if (Fortran::evaluate::ExtractSubstring(*object.ref())) {
+ if (evaluate::ExtractSubstring(*object.ref())) {
TODO(converter.getCurrentLocation(),
"substring not supported for task depend");
- } else if (Fortran::evaluate::IsArrayElement(*object.ref())) {
+ } else if (evaluate::IsArrayElement(*object.ref())) {
TODO(converter.getCurrentLocation(),
"array sections not supported for task depend");
}
- Fortran::semantics::Symbol *sym = object.id();
+ semantics::Symbol *sym = object.id();
const mlir::Value variable = converter.getSymbolAddress(*sym);
result.dependVars.push_back(variable);
}
@@ -760,11 +750,10 @@ bool ClauseProcessor::processHasDeviceAddr(
mlir::omp::HasDeviceAddrClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &isDeviceSymbols)
- const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSymbols) const {
return findRepeatableClause<omp::clause::HasDeviceAddr>(
[&](const omp::clause::HasDeviceAddr &devAddrClause,
- const Fortran::parser::CharBlock &) {
+ const parser::CharBlock &) {
addUseDeviceClause(converter, devAddrClause.v, result.hasDeviceAddrVars,
isDeviceTypes, isDeviceLocs, isDeviceSymbols);
});
@@ -774,19 +763,18 @@ bool ClauseProcessor::processIf(
omp::clause::If::DirectiveNameModifier directiveName,
mlir::omp::IfClauseOps &result) const {
bool found = false;
- findRepeatableClause<omp::clause::If>(
- [&](const omp::clause::If &clause,
- const Fortran::parser::CharBlock &source) {
- mlir::Location clauseLocation = converter.genLocation(source);
- mlir::Value operand = getIfClauseOperand(converter, clause,
- directiveName, clauseLocation);
- // Assume that, at most, a single 'if' clause will be applicable to the
- // given directive.
- if (operand) {
- result.ifVar = operand;
- found = true;
- }
- });
+ findRepeatableClause<omp::clause::If>([&](const omp::clause::If &clause,
+ const parser::CharBlock &source) {
+ mlir::Location clauseLocation = converter.genLocation(source);
+ mlir::Value operand =
+ getIfClauseOperand(converter, clause, directiveName, clauseLocation);
+ // Assume that, at most, a single 'if' clause will be applicable to the
+ // given directive.
+ if (operand) {
+ result.ifVar = operand;
+ found = true;
+ }
+ });
return found;
}
@@ -794,11 +782,10 @@ bool ClauseProcessor::processIsDevicePtr(
mlir::omp::IsDevicePtrClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &isDeviceSymbols)
- const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSymbols) const {
return findRepeatableClause<omp::clause::IsDevicePtr>(
[&](const omp::clause::IsDevicePtr &devPtrClause,
- const Fortran::parser::CharBlock &) {
+ const parser::CharBlock &) {
addUseDeviceClause(converter, devPtrClause.v, result.isDevicePtrVars,
isDeviceTypes, isDeviceLocs, isDeviceSymbols);
});
@@ -807,7 +794,7 @@ bool ClauseProcessor::processIsDevicePtr(
bool ClauseProcessor::processLink(
llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const {
return findRepeatableClause<omp::clause::Link>(
- [&](const omp::clause::Link &clause, const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Link &clause, const parser::CharBlock &) {
// Case: declare target link(var1, var2)...
gatherFuncAndVarSyms(
clause.v, mlir::omp::DeclareTargetCaptureClause::link, result);
@@ -815,25 +802,24 @@ bool ClauseProcessor::processLink(
}
bool ClauseProcessor::processMap(
- mlir::Location currentLocation, Fortran::lower::StatementContext &stmtCtx,
+ mlir::Location currentLocation, lower::StatementContext &stmtCtx,
mlir::omp::MapClauseOps &result,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *mapSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *mapSyms,
llvm::SmallVectorImpl<mlir::Location> *mapSymLocs,
llvm::SmallVectorImpl<mlir::Type> *mapSymTypes) const {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
// We always require tracking of symbols, even if the caller does not,
// so we create an optionally used local set of symbols when the mapSyms
// argument is not present.
- llvm::SmallVector<const Fortran::semantics::Symbol *> localMapSyms;
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *ptrMapSyms =
+ llvm::SmallVector<const semantics::Symbol *> localMapSyms;
+ llvm::SmallVectorImpl<const semantics::Symbol *> *ptrMapSyms =
mapSyms ? mapSyms : &localMapSyms;
- std::map<const Fortran::semantics::Symbol *,
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>>
parentMemberIndices;
bool clauseFound = findRepeatableClause<omp::clause::Map>(
- [&](const omp::clause::Map &clause,
- const Fortran::parser::CharBlock &source) {
+ [&](const omp::clause::Map &clause, const parser::CharBlock &source) {
using Map = omp::clause::Map;
mlir::Location clauseLocation = converter.genLocation(source);
const auto &mapType = std::get<std::optional<Map::MapType>>(clause.t);
@@ -881,9 +867,9 @@ bool ClauseProcessor::processMap(
llvm::SmallVector<mlir::Value> bounds;
std::stringstream asFortran;
- Fortran::lower::AddrAndBoundsInfo info =
- Fortran::lower::gatherDataOperandAddrAndBounds<
- mlir::omp::MapBoundsOp, mlir::omp::MapBoundsType>(
+ lower::AddrAndBoundsInfo info =
+ lower::gatherDataOperandAddrAndBounds<mlir::omp::MapBoundsOp,
+ mlir::omp::MapBoundsType>(
converter, firOpBuilder, semaCtx, stmtCtx, *object.id(),
object.ref(), clauseLocation, asFortran, bounds,
treatIndexAsSection);
@@ -928,18 +914,16 @@ bool ClauseProcessor::processMap(
bool ClauseProcessor::processReduction(
mlir::Location currentLocation, mlir::omp::ReductionClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> *outReductionTypes,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *outReductionSyms)
- const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> *outReductionSyms) const {
return findRepeatableClause<omp::clause::Reduction>(
- [&](const omp::clause::Reduction &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Reduction &clause, const parser::CharBlock &) {
// Use local lists of reductions to prevent variables from other
// already-processed reduction clauses from impacting this reduction.
// For example, the whole `reductionVars` array is queried to decide
// whether to do the reduction byref.
llvm::SmallVector<mlir::Value> reductionVars;
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
- llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSyms;
+ llvm::SmallVector<const semantics::Symbol *> reductionSyms;
ReductionProcessor rp;
rp.addDeclareReduction(currentLocation, converter, clause,
reductionVars, reductionDeclSymbols,
@@ -965,7 +949,7 @@ bool ClauseProcessor::processReduction(
bool ClauseProcessor::processSectionsReduction(
mlir::Location currentLocation, mlir::omp::ReductionClauseOps &) const {
return findRepeatableClause<omp::clause::Reduction>(
- [&](const omp::clause::Reduction &, const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Reduction &, const parser::CharBlock &) {
TODO(currentLocation, "OMPC_Reduction");
});
}
@@ -973,7 +957,7 @@ bool ClauseProcessor::processSectionsReduction(
bool ClauseProcessor::processTo(
llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const {
return findRepeatableClause<omp::clause::To>(
- [&](const omp::clause::To &clause, const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::To &clause, const parser::CharBlock &) {
// Case: declare target to(func, var1, var2)...
gatherFuncAndVarSyms(std::get<ObjectList>(clause.t),
mlir::omp::DeclareTargetCaptureClause::to, result);
@@ -983,8 +967,7 @@ bool ClauseProcessor::processTo(
bool ClauseProcessor::processEnter(
llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const {
return findRepeatableClause<omp::clause::Enter>(
- [&](const omp::clause::Enter &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::Enter &clause, const parser::CharBlock &) {
// Case: declare target enter(func, var1, var2)...
gatherFuncAndVarSyms(
clause.v, mlir::omp::DeclareTargetCaptureClause::enter, result);
@@ -995,11 +978,9 @@ bool ClauseProcessor::processUseDeviceAddr(
mlir::omp::UseDeviceClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &useDeviceSyms)
- const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) const {
return findRepeatableClause<omp::clause::UseDeviceAddr>(
- [&](const omp::clause::UseDeviceAddr &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::UseDeviceAddr &clause, const parser::CharBlock &) {
addUseDeviceClause(converter, clause.v, result.useDeviceAddrVars,
useDeviceTypes, useDeviceLocs, useDeviceSyms);
});
@@ -1009,11 +990,9 @@ bool ClauseProcessor::processUseDevicePtr(
mlir::omp::UseDeviceClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &useDeviceSyms)
- const {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) const {
return findRepeatableClause<omp::clause::UseDevicePtr>(
- [&](const omp::clause::UseDevicePtr &clause,
- const Fortran::parser::CharBlock &) {
+ [&](const omp::clause::UseDevicePtr &clause, const parser::CharBlock &) {
addUseDeviceClause(converter, clause.v, result.useDevicePtrVars,
useDeviceTypes, useDeviceLocs, useDeviceSyms);
});
diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.h b/flang/lib/Lower/OpenMP/ClauseProcessor.h
index 54ffcd0c964bf..7e7a291b94aee 100644
--- a/flang/lib/Lower/OpenMP/ClauseProcessor.h
+++ b/flang/lib/Lower/OpenMP/ClauseProcessor.h
@@ -47,44 +47,43 @@ namespace omp {
/// construct.
class ClauseProcessor {
public:
- ClauseProcessor(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+ ClauseProcessor(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses)
: converter(converter), semaCtx(semaCtx), clauses(clauses) {}
// 'Unique' clauses: They can appear at most once in the clause list.
- bool processCollapse(
- mlir::Location currentLocation, Fortran::lower::pft::Evaluation &eval,
- mlir::omp::CollapseClauseOps &result,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &iv) const;
+ bool
+ processCollapse(mlir::Location currentLocation, lower::pft::Evaluation &eval,
+ mlir::omp::CollapseClauseOps &result,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &iv) const;
bool processDefault() const;
- bool processDevice(Fortran::lower::StatementContext &stmtCtx,
+ bool processDevice(lower::StatementContext &stmtCtx,
mlir::omp::DeviceClauseOps &result) const;
bool processDeviceType(mlir::omp::DeviceTypeClauseOps &result) const;
- bool processFinal(Fortran::lower::StatementContext &stmtCtx,
+ bool processFinal(lower::StatementContext &stmtCtx,
mlir::omp::FinalClauseOps &result) const;
- bool
- processHasDeviceAddr(mlir::omp::HasDeviceAddrClauseOps &result,
- llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
- llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- &isDeviceSymbols) const;
+ bool processHasDeviceAddr(
+ mlir::omp::HasDeviceAddrClauseOps &result,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSymbols) const;
bool processHint(mlir::omp::HintClauseOps &result) const;
bool processMergeable(mlir::omp::MergeableClauseOps &result) const;
bool processNowait(mlir::omp::NowaitClauseOps &result) const;
- bool processNumTeams(Fortran::lower::StatementContext &stmtCtx,
+ bool processNumTeams(lower::StatementContext &stmtCtx,
mlir::omp::NumTeamsClauseOps &result) const;
- bool processNumThreads(Fortran::lower::StatementContext &stmtCtx,
+ bool processNumThreads(lower::StatementContext &stmtCtx,
mlir::omp::NumThreadsClauseOps &result) const;
bool processOrdered(mlir::omp::OrderedClauseOps &result) const;
- bool processPriority(Fortran::lower::StatementContext &stmtCtx,
+ bool processPriority(lower::StatementContext &stmtCtx,
mlir::omp::PriorityClauseOps &result) const;
bool processProcBind(mlir::omp::ProcBindClauseOps &result) const;
bool processSafelen(mlir::omp::SafelenClauseOps &result) const;
- bool processSchedule(Fortran::lower::StatementContext &stmtCtx,
+ bool processSchedule(lower::StatementContext &stmtCtx,
mlir::omp::ScheduleClauseOps &result) const;
bool processSimdlen(mlir::omp::SimdlenClauseOps &result) const;
- bool processThreadLimit(Fortran::lower::StatementContext &stmtCtx,
+ bool processThreadLimit(lower::StatementContext &stmtCtx,
mlir::omp::ThreadLimitClauseOps &result) const;
bool processUntied(mlir::omp::UntiedClauseOps &result) const;
@@ -98,12 +97,11 @@ class ClauseProcessor {
processEnter(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
bool processIf(omp::clause::If::DirectiveNameModifier directiveName,
mlir::omp::IfClauseOps &result) const;
- bool
- processIsDevicePtr(mlir::omp::IsDevicePtrClauseOps &result,
- llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
- llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- &isDeviceSymbols) const;
+ bool processIsDevicePtr(
+ mlir::omp::IsDevicePtrClauseOps &result,
+ llvm::SmallVectorImpl<mlir::Type> &isDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &isDeviceLocs,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &isDeviceSymbols) const;
bool
processLink(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
@@ -113,35 +111,32 @@ class ClauseProcessor {
// They may be used later on to create the block_arguments for some of the
// target directives that require it.
bool processMap(
- mlir::Location currentLocation, Fortran::lower::StatementContext &stmtCtx,
+ mlir::Location currentLocation, lower::StatementContext &stmtCtx,
mlir::omp::MapClauseOps &result,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *mapSyms =
- nullptr,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *mapSyms = nullptr,
llvm::SmallVectorImpl<mlir::Location> *mapSymLocs = nullptr,
llvm::SmallVectorImpl<mlir::Type> *mapSymTypes = nullptr) const;
bool processReduction(
mlir::Location currentLocation, mlir::omp::ReductionClauseOps &result,
llvm::SmallVectorImpl<mlir::Type> *reductionTypes = nullptr,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *reductionSyms =
+ llvm::SmallVectorImpl<const semantics::Symbol *> *reductionSyms =
nullptr) const;
bool processSectionsReduction(mlir::Location currentLocation,
mlir::omp::ReductionClauseOps &result) const;
bool processTo(llvm::SmallVectorImpl<DeclareTargetCapturePair> &result) const;
- bool
- processUseDeviceAddr(mlir::omp::UseDeviceClauseOps &result,
- llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
- llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- &useDeviceSyms) const;
- bool
- processUseDevicePtr(mlir::omp::UseDeviceClauseOps &result,
- llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
- llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- &useDeviceSyms) const;
+ bool processUseDeviceAddr(
+ mlir::omp::UseDeviceClauseOps &result,
+ llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) const;
+ bool processUseDevicePtr(
+ mlir::omp::UseDeviceClauseOps &result,
+ llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
+ llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) const;
template <typename T>
- bool processMotionClauses(Fortran::lower::StatementContext &stmtCtx,
+ bool processMotionClauses(lower::StatementContext &stmtCtx,
mlir::omp::MapClauseOps &result);
// Call this method for these clauses that should be supported but are not
@@ -162,36 +157,34 @@ class ClauseProcessor {
/// `nullptr` if not present. If more than one instance is expected, use
/// `findRepeatableClause` instead.
template <typename T>
- const T *
- findUniqueClause(const Fortran::parser::CharBlock **source = nullptr) const;
+ const T *findUniqueClause(const parser::CharBlock **source = nullptr) const;
/// Call `callbackFn` for each occurrence of the given clause. Return `true`
/// if at least one instance was found.
template <typename T>
bool findRepeatableClause(
- std::function<void(const T &, const Fortran::parser::CharBlock &source)>
+ std::function<void(const T &, const parser::CharBlock &source)>
callbackFn) const;
/// Set the `result` to a new `mlir::UnitAttr` if the clause is present.
template <typename T>
bool markClauseOccurrence(mlir::UnitAttr &result) const;
- Fortran::lower::AbstractConverter &converter;
- Fortran::semantics::SemanticsContext &semaCtx;
+ lower::AbstractConverter &converter;
+ semantics::SemanticsContext &semaCtx;
List<Clause> clauses;
};
template <typename T>
-bool ClauseProcessor::processMotionClauses(
- Fortran::lower::StatementContext &stmtCtx,
- mlir::omp::MapClauseOps &result) {
- std::map<const Fortran::semantics::Symbol *,
+bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
+ mlir::omp::MapClauseOps &result) {
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>>
parentMemberIndices;
- llvm::SmallVector<const Fortran::semantics::Symbol *> mapSymbols;
+ llvm::SmallVector<const semantics::Symbol *> mapSymbols;
bool clauseFound = findRepeatableClause<T>(
- [&](const T &clause, const Fortran::parser::CharBlock &source) {
+ [&](const T &clause, const parser::CharBlock &source) {
mlir::Location clauseLocation = converter.genLocation(source);
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -209,9 +202,9 @@ bool ClauseProcessor::processMotionClauses(
llvm::SmallVector<mlir::Value> bounds;
std::stringstream asFortran;
- Fortran::lower::AddrAndBoundsInfo info =
- Fortran::lower::gatherDataOperandAddrAndBounds<
- mlir::omp::MapBoundsOp, mlir::omp::MapBoundsType>(
+ lower::AddrAndBoundsInfo info =
+ lower::gatherDataOperandAddrAndBounds<mlir::omp::MapBoundsOp,
+ mlir::omp::MapBoundsType>(
converter, firOpBuilder, semaCtx, stmtCtx, *object.id(),
object.ref(), clauseLocation, asFortran, bounds,
treatIndexAsSection);
@@ -277,8 +270,8 @@ ClauseProcessor::findClause(ClauseIterator begin, ClauseIterator end) {
}
template <typename T>
-const T *ClauseProcessor::findUniqueClause(
- const Fortran::parser::CharBlock **source) const {
+const T *
+ClauseProcessor::findUniqueClause(const parser::CharBlock **source) const {
ClauseIterator it = findClause<T>(clauses.begin(), clauses.end());
if (it != clauses.end()) {
if (source)
@@ -290,8 +283,8 @@ const T *ClauseProcessor::findUniqueClause(
template <typename T>
bool ClauseProcessor::findRepeatableClause(
- std::function<void(const T &, const Fortran::parser::CharBlock &source)>
- callbackFn) const {
+ std::function<void(const T &, const parser::CharBlock &source)> callbackFn)
+ const {
bool found = false;
ClauseIterator nextIt, endIt = clauses.end();
for (ClauseIterator it = clauses.begin(); it != endIt; it = nextIt) {
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index 87370c92964a5..1e3fea7c4cdc7 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -150,9 +150,8 @@ Object makeObject(const parser::OmpObject &object,
return makeObject(std::get<parser::Designator>(object.u), semaCtx);
}
-std::optional<Object>
-getBaseObject(const Object &object,
- Fortran::semantics::SemanticsContext &semaCtx) {
+std::optional<Object> getBaseObject(const Object &object,
+ semantics::SemanticsContext &semaCtx) {
// If it's just the symbol, then there is no base.
if (!object.id())
return std::nullopt;
@@ -1211,7 +1210,7 @@ UsesAllocators make(const parser::OmpClause::UsesAllocators &inp,
// Write: empty
} // namespace clause
-Clause makeClause(const Fortran::parser::OmpClause &cls,
+Clause makeClause(const parser::OmpClause &cls,
semantics::SemanticsContext &semaCtx) {
return std::visit(
[&](auto &&s) {
diff --git a/flang/lib/Lower/OpenMP/Clauses.h b/flang/lib/Lower/OpenMP/Clauses.h
index ca610c6528962..5391b134e979d 100644
--- a/flang/lib/Lower/OpenMP/Clauses.h
+++ b/flang/lib/Lower/OpenMP/Clauses.h
@@ -107,9 +107,8 @@ std::optional<ResultTy> maybeApply(FuncTy &&func,
return std::move(func(*arg));
}
-std::optional<Object>
-getBaseObject(const Object &object,
- Fortran::semantics::SemanticsContext &semaCtx);
+std::optional<Object> getBaseObject(const Object &object,
+ semantics::SemanticsContext &semaCtx);
namespace clause {
using DefinedOperator = tomp::type::DefinedOperatorT<IdTy, ExprTy>;
@@ -262,7 +261,7 @@ Clause makeClause(llvm::omp::Clause id, Specific &&specific,
return Clause(typename Clause::BaseT{id, specific}, source);
}
-Clause makeClause(const Fortran::parser::OmpClause &cls,
+Clause makeClause(const parser::OmpClause &cls,
semantics::SemanticsContext &semaCtx);
List<Clause> makeClauses(const parser::OmpClauseList &clauses,
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
index 82d8d8dd98ea2..84e745f28f974 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
@@ -25,7 +25,7 @@ namespace omp {
void DataSharingProcessor::processStep1(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms) {
collectSymbolsForPrivatization();
collectDefaultSymbols();
collectImplicitSymbols();
@@ -57,14 +57,14 @@ void DataSharingProcessor::processStep2(mlir::Operation *op, bool isLoop) {
}
void DataSharingProcessor::insertDeallocs() {
- for (const Fortran::semantics::Symbol *sym : privatizedSymbols)
- if (Fortran::semantics::IsAllocatable(sym->GetUltimate())) {
+ for (const semantics::Symbol *sym : privatizedSymbols)
+ if (semantics::IsAllocatable(sym->GetUltimate())) {
if (!useDelayedPrivatization) {
converter.createHostAssociateVarCloneDealloc(*sym);
return;
}
- Fortran::lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
+ lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
assert(hsb && "Host symbol box not found");
mlir::Type symType = hsb.getAddr().getType();
mlir::Location symLoc = hsb.getAddr().getLoc();
@@ -91,10 +91,10 @@ void DataSharingProcessor::insertDeallocs() {
}
}
-void DataSharingProcessor::cloneSymbol(const Fortran::semantics::Symbol *sym) {
+void DataSharingProcessor::cloneSymbol(const semantics::Symbol *sym) {
// Privatization for symbols which are pre-determined (like loop index
// variables) happen separately, for everything else privatize here.
- if (sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
+ if (sym->test(semantics::Symbol::Flag::OmpPreDetermined))
return;
bool success = converter.createHostAssociateVarClone(*sym);
(void)success;
@@ -102,22 +102,21 @@ void DataSharingProcessor::cloneSymbol(const Fortran::semantics::Symbol *sym) {
}
void DataSharingProcessor::copyFirstPrivateSymbol(
- const Fortran::semantics::Symbol *sym,
- mlir::OpBuilder::InsertPoint *copyAssignIP) {
- if (sym->test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate))
+ const semantics::Symbol *sym, mlir::OpBuilder::InsertPoint *copyAssignIP) {
+ if (sym->test(semantics::Symbol::Flag::OmpFirstPrivate))
converter.copyHostAssociateVar(*sym, copyAssignIP);
}
void DataSharingProcessor::copyLastPrivateSymbol(
- const Fortran::semantics::Symbol *sym,
+ const semantics::Symbol *sym,
[[maybe_unused]] mlir::OpBuilder::InsertPoint *lastPrivIP) {
- if (sym->test(Fortran::semantics::Symbol::Flag::OmpLastPrivate))
+ if (sym->test(semantics::Symbol::Flag::OmpLastPrivate))
converter.copyHostAssociateVar(*sym, lastPrivIP);
}
void DataSharingProcessor::collectOmpObjectListSymbol(
const omp::ObjectList &objects,
- llvm::SetVector<const Fortran::semantics::Symbol *> &symbolSet) {
+ llvm::SetVector<const semantics::Symbol *> &symbolSet) {
for (const omp::Object &object : objects)
symbolSet.insert(object.id());
}
@@ -150,9 +149,9 @@ bool DataSharingProcessor::needBarrier() {
// initialization of firstprivate variables and post-update of lastprivate
// variables.
// Emit implicit barrier for linear clause. Maybe on somewhere else.
- for (const Fortran::semantics::Symbol *sym : privatizedSymbols) {
- if (sym->test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate) &&
- sym->test(Fortran::semantics::Symbol::Flag::OmpLastPrivate))
+ for (const semantics::Symbol *sym : privatizedSymbols) {
+ if (sym->test(semantics::Symbol::Flag::OmpFirstPrivate) &&
+ sym->test(semantics::Symbol::Flag::OmpLastPrivate))
return true;
}
return false;
@@ -238,26 +237,26 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) {
}
}
-static const Fortran::parser::CharBlock *
-getSource(const Fortran::semantics::SemanticsContext &semaCtx,
- const Fortran::lower::pft::Evaluation &eval) {
- const Fortran::parser::CharBlock *source = nullptr;
+static const parser::CharBlock *
+getSource(const semantics::SemanticsContext &semaCtx,
+ const lower::pft::Evaluation &eval) {
+ const parser::CharBlock *source = nullptr;
- auto ompConsVisit = [&](const Fortran::parser::OpenMPConstruct &x) {
- std::visit(Fortran::common::visitors{
- [&](const Fortran::parser::OpenMPSectionsConstruct &x) {
+ auto ompConsVisit = [&](const parser::OpenMPConstruct &x) {
+ std::visit(common::visitors{
+ [&](const parser::OpenMPSectionsConstruct &x) {
source = &std::get<0>(x.t).source;
},
- [&](const Fortran::parser::OpenMPLoopConstruct &x) {
+ [&](const parser::OpenMPLoopConstruct &x) {
source = &std::get<0>(x.t).source;
},
- [&](const Fortran::parser::OpenMPBlockConstruct &x) {
+ [&](const parser::OpenMPBlockConstruct &x) {
source = &std::get<0>(x.t).source;
},
- [&](const Fortran::parser::OpenMPCriticalConstruct &x) {
+ [&](const parser::OpenMPCriticalConstruct &x) {
source = &std::get<0>(x.t).source;
},
- [&](const Fortran::parser::OpenMPAtomicConstruct &x) {
+ [&](const parser::OpenMPAtomicConstruct &x) {
std::visit([&](const auto &x) { source = &x.source; },
x.u);
},
@@ -266,14 +265,10 @@ getSource(const Fortran::semantics::SemanticsContext &semaCtx,
x.u);
};
- eval.visit(Fortran::common::visitors{
- [&](const Fortran::parser::OpenMPConstruct &x) { ompConsVisit(x); },
- [&](const Fortran::parser::OpenMPDeclarativeConstruct &x) {
- source = &x.source;
- },
- [&](const Fortran::parser::OmpEndLoopDirective &x) {
- source = &x.source;
- },
+ eval.visit(common::visitors{
+ [&](const parser::OpenMPConstruct &x) { ompConsVisit(x); },
+ [&](const parser::OpenMPDeclarativeConstruct &x) { source = &x.source; },
+ [&](const parser::OmpEndLoopDirective &x) { source = &x.source; },
[&](const auto &x) {},
});
@@ -281,12 +276,9 @@ getSource(const Fortran::semantics::SemanticsContext &semaCtx,
}
void DataSharingProcessor::collectSymbolsInNestedRegions(
- Fortran::lower::pft::Evaluation &eval,
- Fortran::semantics::Symbol::Flag flag,
- llvm::SetVector<const Fortran::semantics::Symbol *>
- &symbolsInNestedRegions) {
- for (Fortran::lower::pft::Evaluation &nestedEval :
- eval.getNestedEvaluations()) {
+ lower::pft::Evaluation &eval, semantics::Symbol::Flag flag,
+ llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions) {
+ for (lower::pft::Evaluation &nestedEval : eval.getNestedEvaluations()) {
if (nestedEval.hasNestedEvaluations()) {
if (nestedEval.isConstruct())
// Recursively look for OpenMP constructs within `nestedEval`'s region
@@ -307,46 +299,45 @@ void DataSharingProcessor::collectSymbolsInNestedRegions(
// Later, in current context, all symbols in the set
// `defaultSymbols` - `symbolsInNestedRegions` will be privatized.
void DataSharingProcessor::collectSymbols(
- Fortran::semantics::Symbol::Flag flag,
- llvm::SetVector<const Fortran::semantics::Symbol *> &symbols) {
+ semantics::Symbol::Flag flag,
+ llvm::SetVector<const semantics::Symbol *> &symbols) {
// Collect all scopes associated with 'eval'.
- llvm::SetVector<const Fortran::semantics::Scope *> clauseScopes;
- std::function<void(const Fortran::semantics::Scope *)> collectScopes =
- [&](const Fortran::semantics::Scope *scope) {
+ llvm::SetVector<const semantics::Scope *> clauseScopes;
+ std::function<void(const semantics::Scope *)> collectScopes =
+ [&](const semantics::Scope *scope) {
clauseScopes.insert(scope);
- for (const Fortran::semantics::Scope &child : scope->children())
+ for (const semantics::Scope &child : scope->children())
collectScopes(&child);
};
- const Fortran::parser::CharBlock *source =
+ const parser::CharBlock *source =
clauses.empty() ? getSource(semaCtx, eval) : &clauses.front().source;
- const Fortran::semantics::Scope *curScope = nullptr;
+ const semantics::Scope *curScope = nullptr;
if (source && !source->empty()) {
curScope = &semaCtx.FindScope(*source);
collectScopes(curScope);
}
// Collect all symbols referenced in the evaluation being processed,
// that matches 'flag'.
- llvm::SetVector<const Fortran::semantics::Symbol *> allSymbols;
+ llvm::SetVector<const semantics::Symbol *> allSymbols;
converter.collectSymbolSet(eval, allSymbols, flag,
/*collectSymbols=*/true,
/*collectHostAssociatedSymbols=*/true);
- llvm::SetVector<const Fortran::semantics::Symbol *> symbolsInNestedRegions;
+ llvm::SetVector<const semantics::Symbol *> symbolsInNestedRegions;
collectSymbolsInNestedRegions(eval, flag, symbolsInNestedRegions);
// Filter-out symbols that must not be privatized.
- bool collectImplicit = flag == Fortran::semantics::Symbol::Flag::OmpImplicit;
- auto isPrivatizable = [](const Fortran::semantics::Symbol &sym) -> bool {
- return !Fortran::semantics::IsProcedure(sym) &&
- !sym.GetUltimate().has<Fortran::semantics::DerivedTypeDetails>() &&
- !sym.GetUltimate().has<Fortran::semantics::NamelistDetails>() &&
- !Fortran::semantics::IsImpliedDoIndex(sym.GetUltimate());
+ bool collectImplicit = flag == semantics::Symbol::Flag::OmpImplicit;
+ auto isPrivatizable = [](const semantics::Symbol &sym) -> bool {
+ return !semantics::IsProcedure(sym) &&
+ !sym.GetUltimate().has<semantics::DerivedTypeDetails>() &&
+ !sym.GetUltimate().has<semantics::NamelistDetails>() &&
+ !semantics::IsImpliedDoIndex(sym.GetUltimate());
};
for (const auto *sym : allSymbols) {
assert(curScope && "couldn't find current scope");
if (isPrivatizable(*sym) && !symbolsInNestedRegions.contains(sym) &&
!privatizedSymbols.contains(sym) &&
- !sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined) &&
- (collectImplicit ||
- !sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit)) &&
+ !sym->test(semantics::Symbol::Flag::OmpPreDetermined) &&
+ (collectImplicit || !sym->test(semantics::Symbol::Flag::OmpImplicit)) &&
clauseScopes.contains(&sym->owner()))
symbols.insert(sym);
}
@@ -358,10 +349,9 @@ void DataSharingProcessor::collectDefaultSymbols() {
if (const auto *defaultClause =
std::get_if<omp::clause::Default>(&clause.u)) {
if (defaultClause->v == DataSharingAttribute::Private)
- collectSymbols(Fortran::semantics::Symbol::Flag::OmpPrivate,
- defaultSymbols);
+ collectSymbols(semantics::Symbol::Flag::OmpPrivate, defaultSymbols);
else if (defaultClause->v == DataSharingAttribute::Firstprivate)
- collectSymbols(Fortran::semantics::Symbol::Flag::OmpFirstPrivate,
+ collectSymbols(semantics::Symbol::Flag::OmpFirstPrivate,
defaultSymbols);
}
}
@@ -370,16 +360,15 @@ void DataSharingProcessor::collectDefaultSymbols() {
void DataSharingProcessor::collectImplicitSymbols() {
// There will be no implicit symbols when a default clause is present.
if (defaultSymbols.empty())
- collectSymbols(Fortran::semantics::Symbol::Flag::OmpImplicit,
- implicitSymbols);
+ collectSymbols(semantics::Symbol::Flag::OmpImplicit, implicitSymbols);
}
void DataSharingProcessor::privatize(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
- for (const Fortran::semantics::Symbol *sym : privatizedSymbols) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms) {
+ for (const semantics::Symbol *sym : privatizedSymbols) {
if (const auto *commonDet =
- sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
+ sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDet->objects())
doPrivatize(&*mem, clauseOps, privateSyms);
} else
@@ -389,9 +378,9 @@ void DataSharingProcessor::privatize(
void DataSharingProcessor::copyLastPrivatize(mlir::Operation *op) {
insertLastPrivateCompare(op);
- for (const Fortran::semantics::Symbol *sym : privatizedSymbols)
+ for (const semantics::Symbol *sym : privatizedSymbols)
if (const auto *commonDet =
- sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
+ sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDet->objects()) {
copyLastPrivateSymbol(&*mem, &lastPrivIP);
}
@@ -402,36 +391,34 @@ void DataSharingProcessor::copyLastPrivatize(mlir::Operation *op) {
void DataSharingProcessor::defaultPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
- for (const Fortran::semantics::Symbol *sym : defaultSymbols)
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms) {
+ for (const semantics::Symbol *sym : defaultSymbols)
doPrivatize(sym, clauseOps, privateSyms);
}
void DataSharingProcessor::implicitPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
- for (const Fortran::semantics::Symbol *sym : implicitSymbols)
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms) {
+ for (const semantics::Symbol *sym : implicitSymbols)
doPrivatize(sym, clauseOps, privateSyms);
}
void DataSharingProcessor::doPrivatize(
- const Fortran::semantics::Symbol *sym,
- mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
+ const semantics::Symbol *sym, mlir::omp::PrivateClauseOps *clauseOps,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms) {
if (!useDelayedPrivatization) {
cloneSymbol(sym);
copyFirstPrivateSymbol(sym);
return;
}
- Fortran::lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
+ lower::SymbolBox hsb = converter.lookupOneLevelUpSymbol(*sym);
assert(hsb && "Host symbol box not found");
mlir::Type symType = hsb.getAddr().getType();
mlir::Location symLoc = hsb.getAddr().getLoc();
std::string privatizerName = sym->name().ToString() + ".privatizer";
- bool isFirstPrivate =
- sym->test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate);
+ bool isFirstPrivate = sym->test(semantics::Symbol::Flag::OmpFirstPrivate);
mlir::omp::PrivateClauseOp privatizerOp = [&]() {
auto moduleOp = firOpBuilder.getModule();
@@ -468,8 +455,7 @@ void DataSharingProcessor::doPrivatize(
hlfir::translateToExtendedValue(
symLoc, firOpBuilder, hlfir::Entity{allocRegion.getArgument(0)},
/*contiguousHint=*/
- Fortran::evaluate::IsSimplyContiguous(
- *sym, converter.getFoldingContext()))
+ evaluate::IsSimplyContiguous(*sym, converter.getFoldingContext()))
.first;
symTable->addSymbol(*sym, localExV);
diff --git a/flang/lib/Lower/OpenMP/DataSharingProcessor.h b/flang/lib/Lower/OpenMP/DataSharingProcessor.h
index ec6848f7bba36..111266eeb7848 100644
--- a/flang/lib/Lower/OpenMP/DataSharingProcessor.h
+++ b/flang/lib/Lower/OpenMP/DataSharingProcessor.h
@@ -37,65 +37,61 @@ class DataSharingProcessor {
mlir::OpBuilder::InsertPoint insPt;
mlir::Value loopIV;
// Symbols in private, firstprivate, and/or lastprivate clauses.
- llvm::SetVector<const Fortran::semantics::Symbol *> privatizedSymbols;
- llvm::SetVector<const Fortran::semantics::Symbol *> defaultSymbols;
- llvm::SetVector<const Fortran::semantics::Symbol *> implicitSymbols;
- llvm::DenseMap<const Fortran::semantics::Symbol *, mlir::omp::PrivateClauseOp>
+ llvm::SetVector<const semantics::Symbol *> privatizedSymbols;
+ llvm::SetVector<const semantics::Symbol *> defaultSymbols;
+ llvm::SetVector<const semantics::Symbol *> implicitSymbols;
+ llvm::DenseMap<const semantics::Symbol *, mlir::omp::PrivateClauseOp>
symToPrivatizer;
- Fortran::lower::AbstractConverter &converter;
- Fortran::semantics::SemanticsContext &semaCtx;
+ lower::AbstractConverter &converter;
+ semantics::SemanticsContext &semaCtx;
fir::FirOpBuilder &firOpBuilder;
omp::List<omp::Clause> clauses;
- Fortran::lower::pft::Evaluation &eval;
+ lower::pft::Evaluation &eval;
bool useDelayedPrivatization;
- Fortran::lower::SymMap *symTable;
+ lower::SymMap *symTable;
bool needBarrier();
- void
- collectSymbols(Fortran::semantics::Symbol::Flag flag,
- llvm::SetVector<const Fortran::semantics::Symbol *> &symbols);
+ void collectSymbols(semantics::Symbol::Flag flag,
+ llvm::SetVector<const semantics::Symbol *> &symbols);
void collectSymbolsInNestedRegions(
- Fortran::lower::pft::Evaluation &eval,
- Fortran::semantics::Symbol::Flag flag,
- llvm::SetVector<const Fortran::semantics::Symbol *>
- &symbolsInNestedRegions);
+ lower::pft::Evaluation &eval, semantics::Symbol::Flag flag,
+ llvm::SetVector<const semantics::Symbol *> &symbolsInNestedRegions);
void collectOmpObjectListSymbol(
const omp::ObjectList &objects,
- llvm::SetVector<const Fortran::semantics::Symbol *> &symbolSet);
+ llvm::SetVector<const semantics::Symbol *> &symbolSet);
void collectSymbolsForPrivatization();
void insertBarrier();
void collectDefaultSymbols();
void collectImplicitSymbols();
- void privatize(
- mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms);
+ void privatize(mlir::omp::PrivateClauseOps *clauseOps,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms);
void defaultPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms);
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms);
void implicitPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms);
- void doPrivatize(
- const Fortran::semantics::Symbol *sym,
- mlir::omp::PrivateClauseOps *clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms);
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms);
+ void
+ doPrivatize(const semantics::Symbol *sym,
+ mlir::omp::PrivateClauseOps *clauseOps,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms);
void copyLastPrivatize(mlir::Operation *op);
void insertLastPrivateCompare(mlir::Operation *op);
- void cloneSymbol(const Fortran::semantics::Symbol *sym);
+ void cloneSymbol(const semantics::Symbol *sym);
void
- copyFirstPrivateSymbol(const Fortran::semantics::Symbol *sym,
+ copyFirstPrivateSymbol(const semantics::Symbol *sym,
mlir::OpBuilder::InsertPoint *copyAssignIP = nullptr);
- void copyLastPrivateSymbol(const Fortran::semantics::Symbol *sym,
+ void copyLastPrivateSymbol(const semantics::Symbol *sym,
mlir::OpBuilder::InsertPoint *lastPrivIP);
void insertDeallocs();
public:
- DataSharingProcessor(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+ DataSharingProcessor(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses,
- Fortran::lower::pft::Evaluation &eval,
+ lower::pft::Evaluation &eval,
bool useDelayedPrivatization = false,
- Fortran::lower::SymMap *symTable = nullptr)
+ lower::SymMap *symTable = nullptr)
: hasLastPrivateOp(false), converter(converter), semaCtx(semaCtx),
firOpBuilder(converter.getFirOpBuilder()), clauses(clauses), eval(eval),
useDelayedPrivatization(useDelayedPrivatization), symTable(symTable) {}
@@ -111,9 +107,9 @@ class DataSharingProcessor {
// Step2 performs the copying for lastprivates and requires knowledge of the
// MLIR operation to insert the last private update. Step2 adds
// dealocation code as well.
- void processStep1(mlir::omp::PrivateClauseOps *clauseOps = nullptr,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- *privateSyms = nullptr);
+ void processStep1(
+ mlir::omp::PrivateClauseOps *clauseOps = nullptr,
+ llvm::SmallVectorImpl<const semantics::Symbol *> *privateSyms = nullptr);
void processStep2(mlir::Operation *op, bool isLoop);
void setLoopIV(mlir::Value iv) {
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index f05cf1f5120f8..af27c59eb9937 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -45,45 +45,45 @@ using namespace Fortran::lower::omp;
// Code generation helper functions
//===----------------------------------------------------------------------===//
-static void genOMPDispatch(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
+static void genOMPDispatch(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
+ const ConstructQueue &queue,
ConstructQueue::iterator item);
-static Fortran::lower::pft::Evaluation *
-getCollapsedLoopEval(Fortran::lower::pft::Evaluation &eval, int collapseValue) {
+static lower::pft::Evaluation *
+getCollapsedLoopEval(lower::pft::Evaluation &eval, int collapseValue) {
// Return the Evaluation of the innermost collapsed loop, or the current one
// if there was no COLLAPSE.
if (collapseValue == 0)
return &eval;
- Fortran::lower::pft::Evaluation *curEval = &eval.getFirstNestedEvaluation();
+ lower::pft::Evaluation *curEval = &eval.getFirstNestedEvaluation();
for (int i = 1; i < collapseValue; i++) {
// The nested evaluations should be DoConstructs (i.e. they should form
// a loop nest). Each DoConstruct is a tuple <NonLabelDoStmt, Block,
// EndDoStmt>.
- assert(curEval->isA<Fortran::parser::DoConstruct>());
+ assert(curEval->isA<parser::DoConstruct>());
curEval = &*std::next(curEval->getNestedEvaluations().begin());
}
return curEval;
}
-static void genNestedEvaluations(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::pft::Evaluation &eval,
+static void genNestedEvaluations(lower::AbstractConverter &converter,
+ lower::pft::Evaluation &eval,
int collapseValue = 0) {
- Fortran::lower::pft::Evaluation *curEval =
- getCollapsedLoopEval(eval, collapseValue);
+ lower::pft::Evaluation *curEval = getCollapsedLoopEval(eval, collapseValue);
- for (Fortran::lower::pft::Evaluation &e : curEval->getNestedEvaluations())
+ for (lower::pft::Evaluation &e : curEval->getNestedEvaluations())
converter.genEval(e);
}
-static fir::GlobalOp globalInitialization(
- Fortran::lower::AbstractConverter &converter,
- fir::FirOpBuilder &firOpBuilder, const Fortran::semantics::Symbol &sym,
- const Fortran::lower::pft::Variable &var, mlir::Location currentLocation) {
+static fir::GlobalOp globalInitialization(lower::AbstractConverter &converter,
+ fir::FirOpBuilder &firOpBuilder,
+ const semantics::Symbol &sym,
+ const lower::pft::Variable &var,
+ mlir::Location currentLocation) {
mlir::Type ty = converter.genType(sym);
std::string globalName = converter.mangleName(sym);
mlir::StringAttr linkage = firOpBuilder.createInternalLinkage();
@@ -91,9 +91,9 @@ static fir::GlobalOp globalInitialization(
firOpBuilder.createGlobal(currentLocation, ty, globalName, linkage);
// Create default initialization for non-character scalar.
- if (Fortran::semantics::IsAllocatableOrObjectPointer(&sym)) {
+ if (semantics::IsAllocatableOrObjectPointer(&sym)) {
mlir::Type baseAddrType = mlir::dyn_cast<fir::BoxType>(ty).getEleTy();
- Fortran::lower::createGlobalInitialization(
+ lower::createGlobalInitialization(
firOpBuilder, global, [&](fir::FirOpBuilder &b) {
mlir::Value nullAddr =
b.createNullConstant(currentLocation, baseAddrType);
@@ -102,7 +102,7 @@ static fir::GlobalOp globalInitialization(
b.create<fir::HasValueOp>(currentLocation, box);
});
} else {
- Fortran::lower::createGlobalInitialization(
+ lower::createGlobalInitialization(
firOpBuilder, global, [&](fir::FirOpBuilder &b) {
mlir::Value undef = b.create<fir::UndefOp>(currentLocation, ty);
b.create<fir::HasValueOp>(currentLocation, undef);
@@ -126,20 +126,19 @@ static fir::ExtendedValue getExtendedValue(fir::ExtendedValue base,
}
#ifndef NDEBUG
-static bool isThreadPrivate(Fortran::lower::SymbolRef sym) {
- if (const auto *details =
- sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
+static bool isThreadPrivate(lower::SymbolRef sym) {
+ if (const auto *details = sym->detailsIf<semantics::CommonBlockDetails>()) {
for (const auto &obj : details->objects())
- if (!obj->test(Fortran::semantics::Symbol::Flag::OmpThreadprivate))
+ if (!obj->test(semantics::Symbol::Flag::OmpThreadprivate))
return false;
return true;
}
- return sym->test(Fortran::semantics::Symbol::Flag::OmpThreadprivate);
+ return sym->test(semantics::Symbol::Flag::OmpThreadprivate);
}
#endif
-static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::pft::Evaluation &eval) {
+static void threadPrivatizeVars(lower::AbstractConverter &converter,
+ lower::pft::Evaluation &eval) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::Location currentLocation = converter.getCurrentLocation();
mlir::OpBuilder::InsertionGuard guard(firOpBuilder);
@@ -152,7 +151,7 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
// non-threadprivate variable. This can happen, for instance, with a common
// block, declared in a separate module, used by a parent procedure and
// privatized in its child procedure.
- auto genThreadprivateOp = [&](Fortran::lower::SymbolRef sym) -> mlir::Value {
+ auto genThreadprivateOp = [&](lower::SymbolRef sym) -> mlir::Value {
assert(isThreadPrivate(sym));
mlir::Value symValue = converter.getSymbolAddress(sym);
mlir::Operation *op = symValue.getDefiningOp();
@@ -164,28 +163,28 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
currentLocation, symValue.getType(), symValue);
};
- llvm::SetVector<const Fortran::semantics::Symbol *> threadprivateSyms;
+ llvm::SetVector<const semantics::Symbol *> threadprivateSyms;
converter.collectSymbolSet(eval, threadprivateSyms,
- Fortran::semantics::Symbol::Flag::OmpThreadprivate,
+ semantics::Symbol::Flag::OmpThreadprivate,
/*collectSymbols=*/true,
/*collectHostAssociatedSymbols=*/true);
- std::set<Fortran::semantics::SourceName> threadprivateSymNames;
+ std::set<semantics::SourceName> threadprivateSymNames;
// For a COMMON block, the ThreadprivateOp is generated for itself instead of
// its members, so only bind the value of the new copied ThreadprivateOp
// inside the parallel region to the common block symbol only once for
// multiple members in one COMMON block.
- llvm::SetVector<const Fortran::semantics::Symbol *> commonSyms;
+ llvm::SetVector<const semantics::Symbol *> commonSyms;
for (std::size_t i = 0; i < threadprivateSyms.size(); i++) {
- const Fortran::semantics::Symbol *sym = threadprivateSyms[i];
+ const semantics::Symbol *sym = threadprivateSyms[i];
mlir::Value symThreadprivateValue;
// The variable may be used more than once, and each reference has one
// symbol with the same name. Only do once for references of one variable.
if (threadprivateSymNames.find(sym->name()) != threadprivateSymNames.end())
continue;
threadprivateSymNames.insert(sym->name());
- if (const Fortran::semantics::Symbol *common =
- Fortran::semantics::FindCommonBlockContaining(sym->GetUltimate())) {
+ if (const semantics::Symbol *common =
+ semantics::FindCommonBlockContaining(sym->GetUltimate())) {
mlir::Value commonThreadprivateValue;
if (commonSyms.contains(common)) {
commonThreadprivateValue = converter.getSymbolAddress(*common);
@@ -194,7 +193,7 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
converter.bindSymbol(*common, commonThreadprivateValue);
commonSyms.insert(common);
}
- symThreadprivateValue = Fortran::lower::genCommonBlockMember(
+ symThreadprivateValue = lower::genCommonBlockMember(
converter, currentLocation, *sym, commonThreadprivateValue);
} else {
symThreadprivateValue = genThreadprivateOp(*sym);
@@ -208,9 +207,9 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
}
static mlir::Operation *
-createAndSetPrivatizedLoopVar(Fortran::lower::AbstractConverter &converter,
+createAndSetPrivatizedLoopVar(lower::AbstractConverter &converter,
mlir::Location loc, mlir::Value indexVal,
- const Fortran::semantics::Symbol *sym) {
+ const semantics::Symbol *sym) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint();
firOpBuilder.setInsertionPointToStart(firOpBuilder.getAllocaBlock());
@@ -250,8 +249,7 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
mlir::omp::UseDeviceClauseOps &clauseOps,
llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- &useDeviceSymbols) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSymbols) {
auto moveElementToBack = [](size_t idx, auto &vector) {
auto *iter = std::next(vector.begin(), idx);
vector.push_back(*iter);
@@ -285,23 +283,20 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
/// Extract the list of function and variable symbols affected by the given
/// 'declare target' directive and return the intended device type for them.
static void getDeclareTargetInfo(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
mlir::omp::DeclareTargetClauseOps &clauseOps,
llvm::SmallVectorImpl<DeclareTargetCapturePair> &symbolAndClause) {
- const auto &spec = std::get<Fortran::parser::OmpDeclareTargetSpecifier>(
- declareTargetConstruct.t);
- if (const auto *objectList{
- Fortran::parser::Unwrap<Fortran::parser::OmpObjectList>(spec.u)}) {
+ const auto &spec =
+ std::get<parser::OmpDeclareTargetSpecifier>(declareTargetConstruct.t);
+ if (const auto *objectList{parser::Unwrap<parser::OmpObjectList>(spec.u)}) {
ObjectList objects{makeObjects(*objectList, semaCtx)};
// Case: declare target(func, var1, var2)
gatherFuncAndVarSyms(objects, mlir::omp::DeclareTargetCaptureClause::to,
symbolAndClause);
} else if (const auto *clauseList{
- Fortran::parser::Unwrap<Fortran::parser::OmpClauseList>(
- spec.u)}) {
+ parser::Unwrap<parser::OmpClauseList>(spec.u)}) {
List<Clause> clauses = makeClauses(*clauseList, semaCtx);
if (clauses.empty()) {
// Case: declare target, implicit capture of function
@@ -322,11 +317,10 @@ static void getDeclareTargetInfo(
}
static void collectDeferredDeclareTargets(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
- llvm::SmallVectorImpl<Fortran::lower::OMPDeferredDeclareTargetInfo>
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
+ llvm::SmallVectorImpl<lower::OMPDeferredDeclareTargetInfo>
&deferredDeclareTarget) {
mlir::omp::DeclareTargetClauseOps clauseOps;
llvm::SmallVector<DeclareTargetCapturePair> symbolAndClause;
@@ -337,8 +331,8 @@ static void collectDeferredDeclareTargets(
mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
for (const DeclareTargetCapturePair &symClause : symbolAndClause) {
- mlir::Operation *op = mod.lookupSymbol(converter.mangleName(
- std::get<const Fortran::semantics::Symbol &>(symClause)));
+ mlir::Operation *op = mod.lookupSymbol(
+ converter.mangleName(std::get<const semantics::Symbol &>(symClause)));
if (!op) {
deferredDeclareTarget.push_back({std::get<0>(symClause),
@@ -350,11 +344,9 @@ static void collectDeferredDeclareTargets(
static std::optional<mlir::omp::DeclareTargetDeviceType>
getDeclareTargetFunctionDevice(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct
- &declareTargetConstruct) {
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareTargetConstruct &declareTargetConstruct) {
mlir::omp::DeclareTargetClauseOps clauseOps;
llvm::SmallVector<DeclareTargetCapturePair> symbolAndClause;
getDeclareTargetInfo(converter, semaCtx, eval, declareTargetConstruct,
@@ -364,8 +356,8 @@ getDeclareTargetFunctionDevice(
// directive is a function or subroutine
mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
for (const DeclareTargetCapturePair &symClause : symbolAndClause) {
- mlir::Operation *op = mod.lookupSymbol(converter.mangleName(
- std::get<const Fortran::semantics::Symbol &>(symClause)));
+ mlir::Operation *op = mod.lookupSymbol(
+ converter.mangleName(std::get<const semantics::Symbol &>(symClause)));
if (mlir::isa_and_nonnull<mlir::func::FuncOp>(op))
return clauseOps.deviceType;
@@ -392,16 +384,15 @@ getDeclareTargetFunctionDevice(
/// entry block arguments.
/// \param [in] wrapperArgs - entry block arguments of parent loop wrappers.
static void
-genLoopVars(mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
- mlir::Location &loc,
- llvm::ArrayRef<const Fortran::semantics::Symbol *> args,
- llvm::ArrayRef<const Fortran::semantics::Symbol *> wrapperSyms = {},
+genLoopVars(mlir::Operation *op, lower::AbstractConverter &converter,
+ mlir::Location &loc, llvm::ArrayRef<const semantics::Symbol *> args,
+ llvm::ArrayRef<const semantics::Symbol *> wrapperSyms = {},
llvm::ArrayRef<mlir::BlockArgument> wrapperArgs = {}) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
auto ®ion = op->getRegion(0);
std::size_t loopVarTypeSize = 0;
- for (const Fortran::semantics::Symbol *arg : args)
+ for (const semantics::Symbol *arg : args)
loopVarTypeSize = std::max(loopVarTypeSize, arg->GetUltimate().size());
mlir::Type loopVarType = getLoopVarType(converter, loopVarTypeSize);
llvm::SmallVector<mlir::Type> tiv(args.size(), loopVarType);
@@ -424,11 +415,11 @@ genLoopVars(mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
firOpBuilder.setInsertionPointAfter(storeOp);
}
-static void genReductionVars(
- mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
- mlir::Location &loc,
- llvm::ArrayRef<const Fortran::semantics::Symbol *> reductionArgs,
- llvm::ArrayRef<mlir::Type> reductionTypes) {
+static void
+genReductionVars(mlir::Operation *op, lower::AbstractConverter &converter,
+ mlir::Location &loc,
+ llvm::ArrayRef<const semantics::Symbol *> reductionArgs,
+ llvm::ArrayRef<mlir::Type> reductionTypes) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
llvm::SmallVector<mlir::Location> blockArgLocs(reductionArgs.size(), loc);
@@ -443,8 +434,7 @@ static void genReductionVars(
}
static void
-markDeclareTarget(mlir::Operation *op,
- Fortran::lower::AbstractConverter &converter,
+markDeclareTarget(mlir::Operation *op, lower::AbstractConverter &converter,
mlir::omp::DeclareTargetCaptureClause captureClause,
mlir::omp::DeclareTargetDeviceType deviceType) {
// TODO: Add support for program local variables with declare target applied
@@ -477,14 +467,13 @@ struct OpWithBodyGenInfo {
/// which the code is being generated and returns the arguments of the op's
/// region.
using GenOMPRegionEntryCBFn =
- std::function<llvm::SmallVector<const Fortran::semantics::Symbol *>(
+ std::function<llvm::SmallVector<const semantics::Symbol *>(
mlir::Operation *)>;
- OpWithBodyGenInfo(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- mlir::Location loc, Fortran::lower::pft::Evaluation &eval,
- llvm::omp::Directive dir)
+ OpWithBodyGenInfo(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, mlir::Location loc,
+ lower::pft::Evaluation &eval, llvm::omp::Directive dir)
: converter(converter), symTable(symTable), semaCtx(semaCtx), loc(loc),
eval(eval), dir(dir) {}
@@ -503,9 +492,9 @@ struct OpWithBodyGenInfo {
return *this;
}
- OpWithBodyGenInfo &setReductions(
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *value1,
- llvm::SmallVectorImpl<mlir::Type> *value2) {
+ OpWithBodyGenInfo &
+ setReductions(llvm::SmallVectorImpl<const semantics::Symbol *> *value1,
+ llvm::SmallVectorImpl<mlir::Type> *value2) {
reductionSymbols = value1;
reductionTypes = value2;
return *this;
@@ -517,15 +506,15 @@ struct OpWithBodyGenInfo {
}
/// [inout] converter to use for the clauses.
- Fortran::lower::AbstractConverter &converter;
+ lower::AbstractConverter &converter;
/// [in] Symbol table
- Fortran::lower::SymMap &symTable;
+ lower::SymMap &symTable;
/// [in] Semantics context
- Fortran::semantics::SemanticsContext &semaCtx;
+ semantics::SemanticsContext &semaCtx;
/// [in] location in source code.
mlir::Location loc;
/// [in] current PFT node/evaluation.
- Fortran::lower::pft::Evaluation &eval;
+ lower::pft::Evaluation &eval;
/// [in] leaf directive for which to generate the op body.
llvm::omp::Directive dir;
/// [in] is this an outer operation - prevents privatization.
@@ -535,8 +524,7 @@ struct OpWithBodyGenInfo {
/// [in] if provided, processes the construct's data-sharing attributes.
DataSharingProcessor *dsp = nullptr;
/// [in] if provided, list of reduction symbols
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *reductionSymbols =
- nullptr;
+ llvm::SmallVectorImpl<const semantics::Symbol *> *reductionSymbols = nullptr;
/// [in] if provided, list of reduction types
llvm::SmallVectorImpl<mlir::Type> *reductionTypes = nullptr;
/// [in] if provided, emits the op's region entry. Otherwise, an emtpy block
@@ -565,8 +553,7 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
// argument. Also update the symbol's address with the mlir argument value.
// e.g. For loops the argument is the induction variable. And all further
// uses of the induction variable should use this mlir value.
- auto regionArgs =
- [&]() -> llvm::SmallVector<const Fortran::semantics::Symbol *> {
+ auto regionArgs = [&]() -> llvm::SmallVector<const semantics::Symbol *> {
if (info.genRegionEntryCB != nullptr) {
return info.genRegionEntryCB(&op);
}
@@ -580,8 +567,7 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
// If it is an unstructured region and is not the outer region of a combined
// construct, create empty blocks for all evaluations.
if (info.eval.lowerAsUnstructured() && !info.outerCombined)
- Fortran::lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp,
- mlir::omp::YieldOp>(
+ lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp, mlir::omp::YieldOp>(
firOpBuilder, info.eval.getNestedEvaluations());
// Start with privatization, so that the lowering of the nested
@@ -617,8 +603,7 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
// is delayed past this point. Insert a temporary terminator here, then
// delete it.
firOpBuilder.setInsertionPointToEnd(&op.getRegion(0).back());
- auto *temp =
- Fortran::lower::genOpenMPTerminator(firOpBuilder, &op, info.loc);
+ auto *temp = lower::genOpenMPTerminator(firOpBuilder, &op, info.loc);
firOpBuilder.setInsertionPointAfter(marker);
genNestedEvaluations(info.converter, info.eval);
temp->erase();
@@ -662,8 +647,7 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
if (auto *exitBlock = getUniqueExit(op.getRegion(0))) {
firOpBuilder.setInsertionPointToEnd(exitBlock);
- auto *term =
- Fortran::lower::genOpenMPTerminator(firOpBuilder, &op, info.loc);
+ auto *term = lower::genOpenMPTerminator(firOpBuilder, &op, info.loc);
// Only insert lastprivate code when there actually is an exit block.
// Such a block may not exist if the nested code produced an infinite
// loop (this may not make sense in production code, but a user could
@@ -699,13 +683,11 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
}
static void genBodyOfTargetDataOp(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::omp::TargetDataOp &dataOp,
- llvm::ArrayRef<mlir::Type> useDeviceTypes,
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::omp::TargetDataOp &dataOp, llvm::ArrayRef<mlir::Type> useDeviceTypes,
llvm::ArrayRef<mlir::Location> useDeviceLocs,
- llvm::ArrayRef<const Fortran::semantics::Symbol *> useDeviceSymbols,
+ llvm::ArrayRef<const semantics::Symbol *> useDeviceSymbols,
const mlir::Location ¤tLocation, const ConstructQueue &queue,
ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
@@ -721,7 +703,7 @@ static void genBodyOfTargetDataOp(
converter.bindSymbol(*argSymbol, arg);
} else {
// Avoid capture of a reference to a structured binding.
- const Fortran::semantics::Symbol *sym = argSymbol;
+ const semantics::Symbol *sym = argSymbol;
extVal.match(
[&](const fir::MutableBoxValue &mbv) {
converter.bindSymbol(
@@ -751,8 +733,7 @@ static void genBodyOfTargetDataOp(
// Create blocks for unstructured regions. This has to be done since
// blocks are initially allocated with the function as the parent region.
if (eval.lowerAsUnstructured()) {
- Fortran::lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp,
- mlir::omp::YieldOp>(
+ lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp, mlir::omp::YieldOp>(
firOpBuilder, eval.getNestedEvaluations());
}
@@ -772,12 +753,10 @@ static void genBodyOfTargetDataOp(
// This functions creates a block for the body of the targetOp's region. It adds
// all the symbols present in mapSymbols as block arguments to this block.
static void
-genBodyOfTargetOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::omp::TargetOp &targetOp,
- llvm::ArrayRef<const Fortran::semantics::Symbol *> mapSyms,
+genBodyOfTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::omp::TargetOp &targetOp,
+ llvm::ArrayRef<const semantics::Symbol *> mapSyms,
llvm::ArrayRef<mlir::Location> mapSymLocs,
llvm::ArrayRef<mlir::Type> mapSymTypes,
const mlir::Location ¤tLocation,
@@ -812,7 +791,7 @@ genBodyOfTargetOp(Fortran::lower::AbstractConverter &converter,
for (auto [argIndex, argSymbol] : llvm::enumerate(mapSyms)) {
const mlir::BlockArgument &arg = region.getArgument(argIndex);
// Avoid capture of a reference to a structured binding.
- const Fortran::semantics::Symbol *sym = argSymbol;
+ const semantics::Symbol *sym = argSymbol;
// Structure component symbols don't have bindings.
if (sym->owner().IsDerivedType())
continue;
@@ -914,8 +893,7 @@ genBodyOfTargetOp(Fortran::lower::AbstractConverter &converter,
// Create blocks for unstructured regions. This has to be done since
// blocks are initially allocated with the function as the parent region.
if (eval.lowerAsUnstructured()) {
- Fortran::lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp,
- mlir::omp::YieldOp>(
+ lower::createEmptyRegionBlocks<mlir::omp::TerminatorOp, mlir::omp::YieldOp>(
firOpBuilder, eval.getNestedEvaluations());
}
@@ -946,20 +924,20 @@ static OpTy genOpWithBody(const OpWithBodyGenInfo &info,
// Code generation functions for clauses
//===----------------------------------------------------------------------===//
-static void
-genCriticalDeclareClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- const List<Clause> &clauses, mlir::Location loc,
- mlir::omp::CriticalClauseOps &clauseOps,
- llvm::StringRef name) {
+static void genCriticalDeclareClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
+ const List<Clause> &clauses,
+ mlir::Location loc,
+ mlir::omp::CriticalClauseOps &clauseOps,
+ llvm::StringRef name) {
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processHint(clauseOps);
clauseOps.nameAttr =
mlir::StringAttr::get(converter.getFirOpBuilder().getContext(), name);
}
-static void genFlushClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genFlushClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const ObjectList &objects,
const List<Clause> &clauses, mlir::Location loc,
llvm::SmallVectorImpl<mlir::Value> &operandRange) {
@@ -970,20 +948,20 @@ static void genFlushClauses(Fortran::lower::AbstractConverter &converter,
TODO(converter.getCurrentLocation(), "Handle OmpMemoryOrderClause");
}
-static void genLoopNestClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, const List<Clause> &clauses,
- mlir::Location loc, mlir::omp::LoopNestClauseOps &clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &iv) {
+static void
+genLoopNestClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, const List<Clause> &clauses,
+ mlir::Location loc, mlir::omp::LoopNestClauseOps &clauseOps,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &iv) {
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processCollapse(loc, eval, clauseOps, iv);
clauseOps.loopInclusiveAttr = converter.getFirOpBuilder().getUnitAttr();
}
static void
-genOrderedRegionClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+genOrderedRegionClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::OrderedRegionClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -991,13 +969,12 @@ genOrderedRegionClauses(Fortran::lower::AbstractConverter &converter,
}
static void genParallelClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx, const List<Clause> &clauses,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx, const List<Clause> &clauses,
mlir::Location loc, bool processReduction,
mlir::omp::ParallelClauseOps &clauseOps,
llvm::SmallVectorImpl<mlir::Type> &reductionTypes,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &reductionSyms) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSyms) {
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processAllocate(clauseOps);
cp.processDefault();
@@ -1012,8 +989,8 @@ static void genParallelClauses(
}
}
-static void genSectionsClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genSectionsClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::SectionsClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1023,8 +1000,8 @@ static void genSectionsClauses(Fortran::lower::AbstractConverter &converter,
// TODO Support delayed privatization.
}
-static void genSimdClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genSimdClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::SimdClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1039,8 +1016,8 @@ static void genSimdClauses(Fortran::lower::AbstractConverter &converter,
loc, llvm::omp::Directive::OMPD_simd);
}
-static void genSingleClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genSingleClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::SingleClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1051,18 +1028,17 @@ static void genSingleClauses(Fortran::lower::AbstractConverter &converter,
}
static void genTargetClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx, const List<Clause> &clauses,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx, const List<Clause> &clauses,
mlir::Location loc, bool processHostOnlyClauses, bool processReduction,
mlir::omp::TargetClauseOps &clauseOps,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &mapSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
llvm::SmallVectorImpl<mlir::Location> &mapLocs,
llvm::SmallVectorImpl<mlir::Type> &mapTypes,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &deviceAddrSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &deviceAddrSyms,
llvm::SmallVectorImpl<mlir::Location> &deviceAddrLocs,
llvm::SmallVectorImpl<mlir::Type> &deviceAddrTypes,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &devicePtrSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &devicePtrSyms,
llvm::SmallVectorImpl<mlir::Location> &devicePtrLocs,
llvm::SmallVectorImpl<mlir::Type> &devicePtrTypes) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1087,13 +1063,12 @@ static void genTargetClauses(
}
static void genTargetDataClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx, const List<Clause> &clauses,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx, const List<Clause> &clauses,
mlir::Location loc, mlir::omp::TargetDataClauseOps &clauseOps,
llvm::SmallVectorImpl<mlir::Type> &useDeviceTypes,
llvm::SmallVectorImpl<mlir::Location> &useDeviceLocs,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &useDeviceSyms) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &useDeviceSyms) {
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processDevice(stmtCtx, clauseOps);
cp.processIf(llvm::omp::Directive::OMPD_target_data, clauseOps);
@@ -1119,9 +1094,8 @@ static void genTargetDataClauses(
}
static void genTargetEnterExitUpdateDataClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx, const List<Clause> &clauses,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx, const List<Clause> &clauses,
mlir::Location loc, llvm::omp::Directive directive,
mlir::omp::TargetEnterExitUpdateDataClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1138,9 +1112,9 @@ static void genTargetEnterExitUpdateDataClauses(
}
}
-static void genTaskClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx,
+static void genTaskClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::TaskClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1158,8 +1132,8 @@ static void genTaskClauses(Fortran::lower::AbstractConverter &converter,
loc, llvm::omp::Directive::OMPD_task);
}
-static void genTaskgroupClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genTaskgroupClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::TaskgroupClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1168,8 +1142,8 @@ static void genTaskgroupClauses(Fortran::lower::AbstractConverter &converter,
llvm::omp::Directive::OMPD_taskgroup);
}
-static void genTaskwaitClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
+static void genTaskwaitClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::TaskwaitClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1177,9 +1151,9 @@ static void genTaskwaitClauses(Fortran::lower::AbstractConverter &converter,
loc, llvm::omp::Directive::OMPD_taskwait);
}
-static void genTeamsClauses(Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx,
+static void genTeamsClauses(lower::AbstractConverter &converter,
+ semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx,
const List<Clause> &clauses, mlir::Location loc,
mlir::omp::TeamsClauseOps &clauseOps) {
ClauseProcessor cp(converter, semaCtx, clauses);
@@ -1194,12 +1168,11 @@ static void genTeamsClauses(Fortran::lower::AbstractConverter &converter,
}
static void genWsloopClauses(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::StatementContext &stmtCtx, const List<Clause> &clauses,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::StatementContext &stmtCtx, const List<Clause> &clauses,
mlir::Location loc, mlir::omp::WsloopClauseOps &clauseOps,
llvm::SmallVectorImpl<mlir::Type> &reductionTypes,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &reductionSyms) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> &reductionSyms) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
ClauseProcessor cp(converter, semaCtx, clauses);
cp.processNowait(clauseOps);
@@ -1220,21 +1193,19 @@ static void genWsloopClauses(
//===----------------------------------------------------------------------===//
static mlir::omp::BarrierOp
-genBarrierOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genBarrierOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
return converter.getFirOpBuilder().create<mlir::omp::BarrierOp>(loc);
}
static mlir::omp::CriticalOp
-genCriticalOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genCriticalOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item,
- const std::optional<Fortran::parser::Name> &name) {
+ const std::optional<parser::Name> &name) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::FlatSymbolRefAttr nameAttr;
@@ -1261,22 +1232,19 @@ genCriticalOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::DistributeOp
-genDistributeOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genDistributeOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
TODO(loc, "Distribute construct");
return nullptr;
}
static mlir::omp::FlushOp
-genFlushOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ObjectList &objects, const ConstructQueue &queue,
- ConstructQueue::iterator item) {
+genFlushOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ObjectList &objects,
+ const ConstructQueue &queue, ConstructQueue::iterator item) {
llvm::SmallVector<mlir::Value> operandRange;
genFlushClauses(converter, semaCtx, objects, item->clauses, loc,
operandRange);
@@ -1286,11 +1254,10 @@ genFlushOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::MasterOp
-genMasterOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genMasterOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
return genOpWithBody<mlir::omp::MasterOp>(
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
llvm::omp::Directive::OMPD_master),
@@ -1298,20 +1265,18 @@ genMasterOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::OrderedOp
-genOrderedOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genOrderedOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
TODO(loc, "OMPD_ordered");
return nullptr;
}
static mlir::omp::OrderedRegionOp
-genOrderedRegionOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genOrderedRegionOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
mlir::omp::OrderedRegionClauseOps clauseOps;
genOrderedRegionClauses(converter, semaCtx, item->clauses, loc, clauseOps);
@@ -1323,18 +1288,17 @@ genOrderedRegionOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::ParallelOp
-genParallelOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genParallelOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item,
bool outerCombined = false) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
mlir::omp::ParallelClauseOps clauseOps;
- llvm::SmallVector<const Fortran::semantics::Symbol *> privateSyms;
+ llvm::SmallVector<const semantics::Symbol *> privateSyms;
llvm::SmallVector<mlir::Type> reductionTypes;
- llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSyms;
+ llvm::SmallVector<const semantics::Symbol *> reductionSyms;
genParallelClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
/*processReduction=*/!outerCombined, clauseOps,
reductionTypes, reductionSyms);
@@ -1385,15 +1349,14 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
firOpBuilder.createBlock(®ion, /*insertPt=*/{}, privateVarTypes,
privateVarLocs);
- llvm::SmallVector<const Fortran::semantics::Symbol *> allSymbols =
- reductionSyms;
+ llvm::SmallVector<const semantics::Symbol *> allSymbols = reductionSyms;
allSymbols.append(privateSyms);
for (auto [arg, prv] : llvm::zip_equal(allSymbols, region.getArguments())) {
fir::ExtendedValue hostExV = converter.getSymbolExtendedValue(*arg);
converter.bindSymbol(*arg, hlfir::translateToExtendedValue(
loc, firOpBuilder, hlfir::Entity{prv},
/*contiguousHint=*/
- Fortran::evaluate::IsSimplyContiguous(
+ evaluate::IsSimplyContiguous(
*arg, converter.getFoldingContext()))
.first);
}
@@ -1406,11 +1369,10 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::SectionOp
-genSectionOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genSectionOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
// Currently only private/firstprivate clause is handled, and
// all privatization is done within `omp.section` operations.
return genOpWithBody<mlir::omp::SectionOp>(
@@ -1421,10 +1383,9 @@ genSectionOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::SectionsOp
-genSectionsOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genSectionsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
mlir::omp::SectionsClauseOps clauseOps;
genSectionsClauses(converter, semaCtx, item->clauses, loc, clauseOps);
@@ -1478,7 +1439,7 @@ genSectionsOp(Fortran::lower::AbstractConverter &converter,
mlir::OpBuilder::InsertPoint insp = builder.saveInsertionPoint();
const auto &objList = std::get<ObjectList>(lastp->t);
for (const Object &object : objList) {
- Fortran::semantics::Symbol *sym = object.id();
+ semantics::Symbol *sym = object.id();
converter.copyHostAssociateVar(*sym, &insp);
}
}
@@ -1498,19 +1459,18 @@ genSectionsOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::SimdOp
-genSimdOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genSimdOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval);
dsp.processStep1();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
mlir::omp::LoopNestClauseOps loopClauseOps;
mlir::omp::SimdClauseOps simdClauseOps;
- llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
+ llvm::SmallVector<const semantics::Symbol *> iv;
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopClauseOps, iv);
genSimdClauses(converter, semaCtx, item->clauses, loc, simdClauseOps);
@@ -1521,7 +1481,7 @@ genSimdOp(Fortran::lower::AbstractConverter &converter,
// TODO: Add reduction-related arguments to the wrapper's entry block.
firOpBuilder.createBlock(&simdOp.getRegion());
firOpBuilder.setInsertionPoint(
- Fortran::lower::genOpenMPTerminator(firOpBuilder, simdOp, loc));
+ lower::genOpenMPTerminator(firOpBuilder, simdOp, loc));
// Create nested omp.loop_nest and fill body with loop contents.
auto loopOp = firOpBuilder.create<mlir::omp::LoopNestOp>(loc, loopClauseOps);
@@ -1546,11 +1506,10 @@ genSimdOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::SingleOp
-genSingleOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genSingleOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
mlir::omp::SingleClauseOps clauseOps;
genSingleClauses(converter, semaCtx, item->clauses, loc, clauseOps);
@@ -1562,21 +1521,19 @@ genSingleOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TargetOp
-genTargetOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item,
- bool outerCombined = false) {
+genTargetOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item, bool outerCombined = false) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
bool processHostOnlyClauses =
!llvm::cast<mlir::omp::OffloadModuleInterface>(*converter.getModuleOp())
.getIsTargetDevice();
mlir::omp::TargetClauseOps clauseOps;
- llvm::SmallVector<const Fortran::semantics::Symbol *> mapSyms, devicePtrSyms,
+ llvm::SmallVector<const semantics::Symbol *> mapSyms, devicePtrSyms,
deviceAddrSyms;
llvm::SmallVector<mlir::Location> mapLocs, devicePtrLocs, deviceAddrLocs;
llvm::SmallVector<mlir::Type> mapTypes, devicePtrTypes, deviceAddrTypes;
@@ -1590,12 +1547,12 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
// The following code follows the implicit data-mapping rules to map all the
// symbols used inside the region that have not been explicitly mapped using
// the map clause.
- auto captureImplicitMap = [&](const Fortran::semantics::Symbol &sym) {
+ auto captureImplicitMap = [&](const semantics::Symbol &sym) {
if (llvm::find(mapSyms, &sym) == mapSyms.end()) {
mlir::Value baseOp = converter.getSymbolAddress(sym);
if (!baseOp)
- if (const auto *details = sym.template detailsIf<
- Fortran::semantics::HostAssocDetails>()) {
+ if (const auto *details =
+ sym.template detailsIf<semantics::HostAssocDetails>()) {
baseOp = converter.getSymbolAddress(details->symbol());
converter.copySymbolBinding(details->symbol(), sym);
}
@@ -1606,21 +1563,20 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
fir::ExtendedValue dataExv = converter.getSymbolExtendedValue(sym);
name << sym.name().ToString();
- Fortran::lower::AddrAndBoundsInfo info = getDataOperandBaseAddr(
+ lower::AddrAndBoundsInfo info = getDataOperandBaseAddr(
converter, firOpBuilder, sym, converter.getCurrentLocation());
if (mlir::isa<fir::BaseBoxType>(
fir::unwrapRefType(info.addr.getType())))
- bounds =
- Fortran::lower::genBoundsOpsFromBox<mlir::omp::MapBoundsOp,
- mlir::omp::MapBoundsType>(
- firOpBuilder, converter.getCurrentLocation(), converter,
- dataExv, info);
+ bounds = lower::genBoundsOpsFromBox<mlir::omp::MapBoundsOp,
+ mlir::omp::MapBoundsType>(
+ firOpBuilder, converter.getCurrentLocation(), converter, dataExv,
+ info);
if (mlir::isa<fir::SequenceType>(
fir::unwrapRefType(info.addr.getType()))) {
bool dataExvIsAssumedSize =
- Fortran::semantics::IsAssumedSizeArray(sym.GetUltimate());
- bounds = Fortran::lower::genBaseBoundsOps<mlir::omp::MapBoundsOp,
- mlir::omp::MapBoundsType>(
+ semantics::IsAssumedSizeArray(sym.GetUltimate());
+ bounds = lower::genBaseBoundsOps<mlir::omp::MapBoundsOp,
+ mlir::omp::MapBoundsType>(
firOpBuilder, converter.getCurrentLocation(), converter, dataExv,
dataExvIsAssumedSize);
}
@@ -1671,7 +1627,7 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
}
}
};
- Fortran::lower::pft::visitAllSymbols(eval, captureImplicitMap);
+ lower::pft::visitAllSymbols(eval, captureImplicitMap);
auto targetOp = firOpBuilder.create<mlir::omp::TargetOp>(loc, clauseOps);
genBodyOfTargetOp(converter, symTable, semaCtx, eval, targetOp, mapSyms,
@@ -1680,16 +1636,15 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TargetDataOp
-genTargetDataOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genTargetDataOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
mlir::omp::TargetDataClauseOps clauseOps;
llvm::SmallVector<mlir::Type> useDeviceTypes;
llvm::SmallVector<mlir::Location> useDeviceLocs;
- llvm::SmallVector<const Fortran::semantics::Symbol *> useDeviceSyms;
+ llvm::SmallVector<const semantics::Symbol *> useDeviceSyms;
genTargetDataClauses(converter, semaCtx, stmtCtx, item->clauses, loc,
clauseOps, useDeviceTypes, useDeviceLocs, useDeviceSyms);
@@ -1703,14 +1658,14 @@ genTargetDataOp(Fortran::lower::AbstractConverter &converter,
}
template <typename OpTy>
-static OpTy
-genTargetEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- mlir::Location loc, const ConstructQueue &queue,
- ConstructQueue::iterator item) {
+static OpTy genTargetEnterExitUpdateDataOp(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ mlir::Location loc,
+ const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
// GCC 9.3.0 emits a (probably) bogus warning about an unused variable.
[[maybe_unused]] llvm::omp::Directive directive;
@@ -1732,12 +1687,11 @@ genTargetEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TaskOp
-genTaskOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
- Fortran::lower::StatementContext stmtCtx;
+genTaskOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
+ lower::StatementContext stmtCtx;
mlir::omp::TaskClauseOps clauseOps;
genTaskClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps);
@@ -1749,10 +1703,9 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TaskgroupOp
-genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genTaskgroupOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
mlir::omp::TaskgroupClauseOps clauseOps;
genTaskgroupClauses(converter, semaCtx, item->clauses, loc, clauseOps);
@@ -1765,19 +1718,17 @@ genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TaskloopOp
-genTaskloopOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genTaskloopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
TODO(loc, "Taskloop construct");
}
static mlir::omp::TaskwaitOp
-genTaskwaitOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genTaskwaitOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
mlir::omp::TaskwaitClauseOps clauseOps;
genTaskwaitClauses(converter, semaCtx, item->clauses, loc, clauseOps);
@@ -1786,22 +1737,19 @@ genTaskwaitOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::TaskyieldOp
-genTaskyieldOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
+genTaskyieldOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
const ConstructQueue &queue, ConstructQueue::iterator item) {
return converter.getFirOpBuilder().create<mlir::omp::TaskyieldOp>(loc);
}
static mlir::omp::TeamsOp
-genTeamsOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item,
- bool outerCombined = false) {
- Fortran::lower::StatementContext stmtCtx;
+genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item, bool outerCombined = false) {
+ lower::StatementContext stmtCtx;
mlir::omp::TeamsClauseOps clauseOps;
genTeamsClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps);
@@ -1814,21 +1762,20 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
}
static mlir::omp::WsloopOp
-genWsloopOp(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+genWsloopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval);
dsp.processStep1();
- Fortran::lower::StatementContext stmtCtx;
+ lower::StatementContext stmtCtx;
mlir::omp::LoopNestClauseOps loopClauseOps;
mlir::omp::WsloopClauseOps wsClauseOps;
- llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
+ llvm::SmallVector<const semantics::Symbol *> iv;
llvm::SmallVector<mlir::Type> reductionTypes;
- llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSyms;
+ llvm::SmallVector<const semantics::Symbol *> reductionSyms;
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
loopClauseOps, iv);
genWsloopClauses(converter, semaCtx, stmtCtx, item->clauses, loc, wsClauseOps,
@@ -1841,7 +1788,7 @@ genWsloopOp(Fortran::lower::AbstractConverter &converter,
mlir::Block *wsloopEntryBlock = firOpBuilder.createBlock(
&wsloopOp.getRegion(), {}, reductionTypes, reductionLocs);
firOpBuilder.setInsertionPoint(
- Fortran::lower::genOpenMPTerminator(firOpBuilder, wsloopOp, loc));
+ lower::genOpenMPTerminator(firOpBuilder, wsloopOp, loc));
// Create nested omp.loop_nest and fill body with loop contents.
auto loopOp = firOpBuilder.create<mlir::omp::LoopNestOp>(loc, loopClauseOps);
@@ -1871,38 +1818,36 @@ genWsloopOp(Fortran::lower::AbstractConverter &converter,
//===----------------------------------------------------------------------===//
static void genCompositeDistributeParallelDo(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
TODO(loc, "Composite DISTRIBUTE PARALLEL DO");
}
static void genCompositeDistributeParallelDoSimd(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval, mlir::Location loc,
- const ConstructQueue &queue, ConstructQueue::iterator item) {
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ mlir::Location loc, const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
TODO(loc, "Composite DISTRIBUTE PARALLEL DO SIMD");
}
-static void
-genCompositeDistributeSimd(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
- ConstructQueue::iterator item) {
+static void genCompositeDistributeSimd(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ mlir::Location loc,
+ const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
TODO(loc, "Composite DISTRIBUTE SIMD");
}
-static void genCompositeDoSimd(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
+static void genCompositeDoSimd(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
+ const ConstructQueue &queue,
ConstructQueue::iterator item) {
ClauseProcessor cp(converter, semaCtx, item->clauses);
cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
@@ -1919,13 +1864,13 @@ static void genCompositeDoSimd(Fortran::lower::AbstractConverter &converter,
genWsloopOp(converter, symTable, semaCtx, eval, loc, queue, item);
}
-static void
-genCompositeTaskloopSimd(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
- ConstructQueue::iterator item) {
+static void genCompositeTaskloopSimd(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ mlir::Location loc,
+ const ConstructQueue &queue,
+ ConstructQueue::iterator item) {
TODO(loc, "Composite TASKLOOP SIMD");
}
@@ -1933,11 +1878,11 @@ genCompositeTaskloopSimd(Fortran::lower::AbstractConverter &converter,
// Dispatch
//===----------------------------------------------------------------------===//
-static void genOMPDispatch(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- mlir::Location loc, const ConstructQueue &queue,
+static void genOMPDispatch(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval, mlir::Location loc,
+ const ConstructQueue &queue,
ConstructQueue::iterator item) {
assert(item != queue.end());
@@ -2058,38 +2003,30 @@ static void genOMPDispatch(Fortran::lower::AbstractConverter &converter,
//===----------------------------------------------------------------------===//
static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclarativeAllocate &declarativeAllocate) {
+genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclarativeAllocate &declarativeAllocate) {
TODO(converter.getCurrentLocation(), "OpenMPDeclarativeAllocate");
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareReductionConstruct
- &declareReductionConstruct) {
+static void genOMP(
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareReductionConstruct &declareReductionConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPDeclareReductionConstruct");
}
-static void genOMP(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareSimdConstruct &declareSimdConstruct) {
+static void
+genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareSimdConstruct &declareSimdConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPDeclareSimdConstruct");
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct
- &declareTargetConstruct) {
+static void
+genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclareTargetConstruct &declareTargetConstruct) {
mlir::omp::DeclareTargetClauseOps clauseOps;
llvm::SmallVector<DeclareTargetCapturePair> symbolAndClause;
mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
@@ -2097,8 +2034,8 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
clauseOps, symbolAndClause);
for (const DeclareTargetCapturePair &symClause : symbolAndClause) {
- mlir::Operation *op = mod.lookupSymbol(converter.mangleName(
- std::get<const Fortran::semantics::Symbol &>(symClause)));
+ mlir::Operation *op = mod.lookupSymbol(
+ converter.mangleName(std::get<const semantics::Symbol &>(symClause)));
// Some symbols are deferred until later in the module, these are handled
// upon finalization of the module for OpenMP inside of Bridge, so we simply
@@ -2113,33 +2050,28 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
}
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPRequiresConstruct &requiresConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPRequiresConstruct &requiresConstruct) {
// Requires directives are gathered and processed in semantics and
// then combined in the lowering bridge before triggering codegen
// just once. Hence, there is no need to lower each individual
// occurrence here.
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPThreadprivate &threadprivate) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPThreadprivate &threadprivate) {
// The directive is lowered when instantiating the variable to
// support the case of threadprivate variable declared in module.
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclarativeConstruct &ompDeclConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclarativeConstruct &ompDeclConstruct) {
std::visit(
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
ompDeclConstruct.u);
@@ -2149,18 +2081,14 @@ genOMP(Fortran::lower::AbstractConverter &converter,
// OpenMPStandaloneConstruct visitors
//===----------------------------------------------------------------------===//
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPSimpleStandaloneConstruct
- &simpleStandaloneConstruct) {
- const auto &directive =
- std::get<Fortran::parser::OmpSimpleStandaloneDirective>(
- simpleStandaloneConstruct.t);
+static void genOMP(
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPSimpleStandaloneConstruct &simpleStandaloneConstruct) {
+ const auto &directive = std::get<parser::OmpSimpleStandaloneDirective>(
+ simpleStandaloneConstruct.t);
List<Clause> clauses = makeClauses(
- std::get<Fortran::parser::OmpClauseList>(simpleStandaloneConstruct.t),
- semaCtx);
+ std::get<parser::OmpClauseList>(simpleStandaloneConstruct.t), semaCtx);
mlir::Location currentLocation = converter.genLocation(directive.source);
ConstructQueue queue{
@@ -2177,17 +2105,15 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
}
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPFlushConstruct &flushConstruct) {
- const auto &verbatim = std::get<Fortran::parser::Verbatim>(flushConstruct.t);
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPFlushConstruct &flushConstruct) {
+ const auto &verbatim = std::get<parser::Verbatim>(flushConstruct.t);
const auto &objectList =
- std::get<std::optional<Fortran::parser::OmpObjectList>>(flushConstruct.t);
+ std::get<std::optional<parser::OmpObjectList>>(flushConstruct.t);
const auto &clauseList =
- std::get<std::optional<std::list<Fortran::parser::OmpMemoryOrderClause>>>(
+ std::get<std::optional<std::list<parser::OmpMemoryOrderClause>>>(
flushConstruct.t);
ObjectList objects =
objectList ? makeObjects(*objectList, semaCtx) : ObjectList{};
@@ -2204,30 +2130,25 @@ genOMP(Fortran::lower::AbstractConverter &converter,
queue, queue.begin());
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPCancelConstruct &cancelConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPCancelConstruct &cancelConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPCancelConstruct");
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPCancellationPointConstruct
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPCancellationPointConstruct
&cancellationPointConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPCancelConstruct");
}
static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPStandaloneConstruct &standaloneConstruct) {
+genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPStandaloneConstruct &standaloneConstruct) {
std::visit(
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
standaloneConstruct.u);
@@ -2237,79 +2158,68 @@ genOMP(Fortran::lower::AbstractConverter &converter,
// OpenMPConstruct visitors
//===----------------------------------------------------------------------===//
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPAllocatorsConstruct &allocsConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPAllocatorsConstruct &allocsConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPAllocatorsConstruct");
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPAtomicConstruct &atomicConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPAtomicConstruct &atomicConstruct) {
std::visit(
- Fortran::common::visitors{
- [&](const Fortran::parser::OmpAtomicRead &atomicRead) {
+ common::visitors{
+ [&](const parser::OmpAtomicRead &atomicRead) {
mlir::Location loc = converter.genLocation(atomicRead.source);
- Fortran::lower::genOmpAccAtomicRead<
- Fortran::parser::OmpAtomicRead,
- Fortran::parser::OmpAtomicClauseList>(converter, atomicRead,
- loc);
+ lower::genOmpAccAtomicRead<parser::OmpAtomicRead,
+ parser::OmpAtomicClauseList>(
+ converter, atomicRead, loc);
},
- [&](const Fortran::parser::OmpAtomicWrite &atomicWrite) {
+ [&](const parser::OmpAtomicWrite &atomicWrite) {
mlir::Location loc = converter.genLocation(atomicWrite.source);
- Fortran::lower::genOmpAccAtomicWrite<
- Fortran::parser::OmpAtomicWrite,
- Fortran::parser::OmpAtomicClauseList>(converter, atomicWrite,
- loc);
+ lower::genOmpAccAtomicWrite<parser::OmpAtomicWrite,
+ parser::OmpAtomicClauseList>(
+ converter, atomicWrite, loc);
},
- [&](const Fortran::parser::OmpAtomic &atomicConstruct) {
+ [&](const parser::OmpAtomic &atomicConstruct) {
mlir::Location loc = converter.genLocation(atomicConstruct.source);
- Fortran::lower::genOmpAtomic<Fortran::parser::OmpAtomic,
- Fortran::parser::OmpAtomicClauseList>(
+ lower::genOmpAtomic<parser::OmpAtomic, parser::OmpAtomicClauseList>(
converter, atomicConstruct, loc);
},
- [&](const Fortran::parser::OmpAtomicUpdate &atomicUpdate) {
+ [&](const parser::OmpAtomicUpdate &atomicUpdate) {
mlir::Location loc = converter.genLocation(atomicUpdate.source);
- Fortran::lower::genOmpAccAtomicUpdate<
- Fortran::parser::OmpAtomicUpdate,
- Fortran::parser::OmpAtomicClauseList>(converter, atomicUpdate,
- loc);
+ lower::genOmpAccAtomicUpdate<parser::OmpAtomicUpdate,
+ parser::OmpAtomicClauseList>(
+ converter, atomicUpdate, loc);
},
- [&](const Fortran::parser::OmpAtomicCapture &atomicCapture) {
+ [&](const parser::OmpAtomicCapture &atomicCapture) {
mlir::Location loc = converter.genLocation(atomicCapture.source);
- Fortran::lower::genOmpAccAtomicCapture<
- Fortran::parser::OmpAtomicCapture,
- Fortran::parser::OmpAtomicClauseList>(converter, atomicCapture,
- loc);
+ lower::genOmpAccAtomicCapture<parser::OmpAtomicCapture,
+ parser::OmpAtomicClauseList>(
+ converter, atomicCapture, loc);
},
},
atomicConstruct.u);
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPBlockConstruct &blockConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPBlockConstruct &blockConstruct) {
const auto &beginBlockDirective =
- std::get<Fortran::parser::OmpBeginBlockDirective>(blockConstruct.t);
+ std::get<parser::OmpBeginBlockDirective>(blockConstruct.t);
const auto &endBlockDirective =
- std::get<Fortran::parser::OmpEndBlockDirective>(blockConstruct.t);
+ std::get<parser::OmpEndBlockDirective>(blockConstruct.t);
mlir::Location currentLocation =
converter.genLocation(beginBlockDirective.source);
const auto origDirective =
- std::get<Fortran::parser::OmpBlockDirective>(beginBlockDirective.t).v;
+ std::get<parser::OmpBlockDirective>(beginBlockDirective.t).v;
List<Clause> clauses = makeClauses(
- std::get<Fortran::parser::OmpClauseList>(beginBlockDirective.t), semaCtx);
+ std::get<parser::OmpClauseList>(beginBlockDirective.t), semaCtx);
clauses.append(makeClauses(
- std::get<Fortran::parser::OmpClauseList>(endBlockDirective.t), semaCtx));
+ std::get<parser::OmpClauseList>(endBlockDirective.t), semaCtx));
assert(llvm::omp::blockConstructSet.test(origDirective) &&
"Expected block construct");
@@ -2356,51 +2266,44 @@ genOMP(Fortran::lower::AbstractConverter &converter,
queue.begin());
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPCriticalConstruct &criticalConstruct) {
- const auto &cd =
- std::get<Fortran::parser::OmpCriticalDirective>(criticalConstruct.t);
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPCriticalConstruct &criticalConstruct) {
+ const auto &cd = std::get<parser::OmpCriticalDirective>(criticalConstruct.t);
List<Clause> clauses =
- makeClauses(std::get<Fortran::parser::OmpClauseList>(cd.t), semaCtx);
+ makeClauses(std::get<parser::OmpClauseList>(cd.t), semaCtx);
ConstructQueue queue{buildConstructQueue(
converter.getFirOpBuilder().getModule(), semaCtx, eval, cd.source,
llvm::omp::Directive::OMPD_critical, clauses)};
- const auto &name = std::get<std::optional<Fortran::parser::Name>>(cd.t);
+ const auto &name = std::get<std::optional<parser::Name>>(cd.t);
mlir::Location currentLocation = converter.getCurrentLocation();
genCriticalOp(converter, symTable, semaCtx, eval, currentLocation, queue,
queue.begin(), name);
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPExecutableAllocate &execAllocConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPExecutableAllocate &execAllocConstruct) {
TODO(converter.getCurrentLocation(), "OpenMPExecutableAllocate");
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPLoopConstruct &loopConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPLoopConstruct &loopConstruct) {
const auto &beginLoopDirective =
- std::get<Fortran::parser::OmpBeginLoopDirective>(loopConstruct.t);
+ std::get<parser::OmpBeginLoopDirective>(loopConstruct.t);
List<Clause> clauses = makeClauses(
- std::get<Fortran::parser::OmpClauseList>(beginLoopDirective.t), semaCtx);
+ std::get<parser::OmpClauseList>(beginLoopDirective.t), semaCtx);
if (auto &endLoopDirective =
- std::get<std::optional<Fortran::parser::OmpEndLoopDirective>>(
+ std::get<std::optional<parser::OmpEndLoopDirective>>(
loopConstruct.t)) {
clauses.append(makeClauses(
- std::get<Fortran::parser::OmpClauseList>(endLoopDirective->t),
- semaCtx));
+ std::get<parser::OmpClauseList>(endLoopDirective->t), semaCtx));
}
mlir::Location currentLocation =
@@ -2417,12 +2320,10 @@ static void genOMP(Fortran::lower::AbstractConverter &converter,
queue.begin());
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPSectionConstruct §ionConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPSectionConstruct §ionConstruct) {
mlir::Location loc = converter.getCurrentLocation();
ConstructQueue queue{buildConstructQueue(
converter.getFirOpBuilder().getModule(), semaCtx, eval,
@@ -2430,22 +2331,18 @@ genOMP(Fortran::lower::AbstractConverter &converter,
genOMPDispatch(converter, symTable, semaCtx, eval, loc, queue, queue.begin());
}
-static void
-genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPSectionsConstruct §ionsConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPSectionsConstruct §ionsConstruct) {
const auto &beginSectionsDirective =
- std::get<Fortran::parser::OmpBeginSectionsDirective>(sectionsConstruct.t);
+ std::get<parser::OmpBeginSectionsDirective>(sectionsConstruct.t);
List<Clause> clauses = makeClauses(
- std::get<Fortran::parser::OmpClauseList>(beginSectionsDirective.t),
- semaCtx);
+ std::get<parser::OmpClauseList>(beginSectionsDirective.t), semaCtx);
const auto &endSectionsDirective =
- std::get<Fortran::parser::OmpEndSectionsDirective>(sectionsConstruct.t);
+ std::get<parser::OmpEndSectionsDirective>(sectionsConstruct.t);
clauses.append(makeClauses(
- std::get<Fortran::parser::OmpClauseList>(endSectionsDirective.t),
- semaCtx));
+ std::get<parser::OmpClauseList>(endSectionsDirective.t), semaCtx));
mlir::Location currentLocation = converter.getCurrentLocation();
llvm::omp::Directive directive =
@@ -2459,11 +2356,10 @@ genOMP(Fortran::lower::AbstractConverter &converter,
queue.begin());
}
-static void genOMP(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPConstruct &ompConstruct) {
+static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPConstruct &ompConstruct) {
std::visit(
[&](auto &&s) { return genOMP(converter, symTable, semaCtx, eval, s); },
ompConstruct.u);
@@ -2482,62 +2378,57 @@ mlir::Operation *Fortran::lower::genOpenMPTerminator(fir::FirOpBuilder &builder,
return builder.create<mlir::omp::TerminatorOp>(loc);
}
-void Fortran::lower::genOpenMPConstruct(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPConstruct &omp) {
+void Fortran::lower::genOpenMPConstruct(lower::AbstractConverter &converter,
+ lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPConstruct &omp) {
symTable.pushScope();
genOMP(converter, symTable, semaCtx, eval, omp);
symTable.popScope();
}
void Fortran::lower::genOpenMPDeclarativeConstruct(
- Fortran::lower::AbstractConverter &converter,
- Fortran::lower::SymMap &symTable,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclarativeConstruct &omp) {
+ lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclarativeConstruct &omp) {
genOMP(converter, symTable, semaCtx, eval, omp);
genNestedEvaluations(converter, eval);
}
void Fortran::lower::genOpenMPSymbolProperties(
- Fortran::lower::AbstractConverter &converter,
- const Fortran::lower::pft::Variable &var) {
+ lower::AbstractConverter &converter, const lower::pft::Variable &var) {
assert(var.hasSymbol() && "Expecting Symbol");
- const Fortran::semantics::Symbol &sym = var.getSymbol();
+ const semantics::Symbol &sym = var.getSymbol();
- if (sym.test(Fortran::semantics::Symbol::Flag::OmpThreadprivate))
- Fortran::lower::genThreadprivateOp(converter, var);
+ if (sym.test(semantics::Symbol::Flag::OmpThreadprivate))
+ lower::genThreadprivateOp(converter, var);
- if (sym.test(Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
- Fortran::lower::genDeclareTargetIntGlobal(converter, var);
+ if (sym.test(semantics::Symbol::Flag::OmpDeclareTarget))
+ lower::genDeclareTargetIntGlobal(converter, var);
}
-int64_t Fortran::lower::getCollapseValue(
- const Fortran::parser::OmpClauseList &clauseList) {
- for (const Fortran::parser::OmpClause &clause : clauseList.v) {
+int64_t
+Fortran::lower::getCollapseValue(const parser::OmpClauseList &clauseList) {
+ for (const parser::OmpClause &clause : clauseList.v) {
if (const auto &collapseClause =
- std::get_if<Fortran::parser::OmpClause::Collapse>(&clause.u)) {
- const auto *expr = Fortran::semantics::GetExpr(collapseClause->v);
- return Fortran::evaluate::ToInt64(*expr).value();
+ std::get_if<parser::OmpClause::Collapse>(&clause.u)) {
+ const auto *expr = semantics::GetExpr(collapseClause->v);
+ return evaluate::ToInt64(*expr).value();
}
}
return 1;
}
-void Fortran::lower::genThreadprivateOp(
- Fortran::lower::AbstractConverter &converter,
- const Fortran::lower::pft::Variable &var) {
+void Fortran::lower::genThreadprivateOp(lower::AbstractConverter &converter,
+ const lower::pft::Variable &var) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::Location currentLocation = converter.getCurrentLocation();
- const Fortran::semantics::Symbol &sym = var.getSymbol();
+ const semantics::Symbol &sym = var.getSymbol();
mlir::Value symThreadprivateValue;
- if (const Fortran::semantics::Symbol *common =
- Fortran::semantics::FindCommonBlockContaining(sym.GetUltimate())) {
+ if (const semantics::Symbol *common =
+ semantics::FindCommonBlockContaining(sym.GetUltimate())) {
mlir::Value commonValue = converter.getSymbolAddress(*common);
if (mlir::isa<mlir::omp::ThreadprivateOp>(commonValue.getDefiningOp())) {
// Generate ThreadprivateOp for a common block instead of its members and
@@ -2600,8 +2491,7 @@ void Fortran::lower::genThreadprivateOp(
// that have the implicit SAVE attribute, to simplifiy LLVM-IR and MLIR
// generation.
void Fortran::lower::genDeclareTargetIntGlobal(
- Fortran::lower::AbstractConverter &converter,
- const Fortran::lower::pft::Variable &var) {
+ lower::AbstractConverter &converter, const lower::pft::Variable &var) {
if (!var.isGlobal()) {
// A non-global variable which can be in a declare target directive must
// be a variable in the main program, and it has the implicit SAVE
@@ -2613,48 +2503,42 @@ void Fortran::lower::genDeclareTargetIntGlobal(
}
bool Fortran::lower::isOpenMPTargetConstruct(
- const Fortran::parser::OpenMPConstruct &omp) {
+ const parser::OpenMPConstruct &omp) {
llvm::omp::Directive dir = llvm::omp::Directive::OMPD_unknown;
- if (const auto *block =
- std::get_if<Fortran::parser::OpenMPBlockConstruct>(&omp.u)) {
- const auto &begin =
- std::get<Fortran::parser::OmpBeginBlockDirective>(block->t);
- dir = std::get<Fortran::parser::OmpBlockDirective>(begin.t).v;
+ if (const auto *block = std::get_if<parser::OpenMPBlockConstruct>(&omp.u)) {
+ const auto &begin = std::get<parser::OmpBeginBlockDirective>(block->t);
+ dir = std::get<parser::OmpBlockDirective>(begin.t).v;
} else if (const auto *loop =
- std::get_if<Fortran::parser::OpenMPLoopConstruct>(&omp.u)) {
- const auto &begin =
- std::get<Fortran::parser::OmpBeginLoopDirective>(loop->t);
- dir = std::get<Fortran::parser::OmpLoopDirective>(begin.t).v;
+ std::get_if<parser::OpenMPLoopConstruct>(&omp.u)) {
+ const auto &begin = std::get<parser::OmpBeginLoopDirective>(loop->t);
+ dir = std::get<parser::OmpLoopDirective>(begin.t).v;
}
return llvm::omp::allTargetSet.test(dir);
}
void Fortran::lower::gatherOpenMPDeferredDeclareTargets(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclarativeConstruct &ompDecl,
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclarativeConstruct &ompDecl,
llvm::SmallVectorImpl<OMPDeferredDeclareTargetInfo>
&deferredDeclareTarget) {
- std::visit(
- Fortran::common::visitors{
- [&](const Fortran::parser::OpenMPDeclareTargetConstruct &ompReq) {
- collectDeferredDeclareTargets(converter, semaCtx, eval, ompReq,
- deferredDeclareTarget);
- },
- [&](const auto &) {},
- },
- ompDecl.u);
+ std::visit(common::visitors{
+ [&](const parser::OpenMPDeclareTargetConstruct &ompReq) {
+ collectDeferredDeclareTargets(converter, semaCtx, eval,
+ ompReq, deferredDeclareTarget);
+ },
+ [&](const auto &) {},
+ },
+ ompDecl.u);
}
bool Fortran::lower::isOpenMPDeviceDeclareTarget(
- Fortran::lower::AbstractConverter &converter,
- Fortran::semantics::SemanticsContext &semaCtx,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclarativeConstruct &ompDecl) {
+ lower::AbstractConverter &converter, semantics::SemanticsContext &semaCtx,
+ lower::pft::Evaluation &eval,
+ const parser::OpenMPDeclarativeConstruct &ompDecl) {
return std::visit(
- Fortran::common::visitors{
- [&](const Fortran::parser::OpenMPDeclareTargetConstruct &ompReq) {
+ common::visitors{
+ [&](const parser::OpenMPDeclareTargetConstruct &ompReq) {
mlir::omp::DeclareTargetDeviceType targetType =
getDeclareTargetFunctionDevice(converter, semaCtx, eval, ompReq)
.value_or(mlir::omp::DeclareTargetDeviceType::host);
@@ -2701,20 +2585,19 @@ bool Fortran::lower::markOpenMPDeferredDeclareTargetFunctions(
return deviceCodeFound;
}
-void Fortran::lower::genOpenMPRequires(
- mlir::Operation *mod, const Fortran::semantics::Symbol *symbol) {
+void Fortran::lower::genOpenMPRequires(mlir::Operation *mod,
+ const semantics::Symbol *symbol) {
using MlirRequires = mlir::omp::ClauseRequires;
- using SemaRequires = Fortran::semantics::WithOmpDeclarative::RequiresFlag;
+ using SemaRequires = semantics::WithOmpDeclarative::RequiresFlag;
if (auto offloadMod =
llvm::dyn_cast<mlir::omp::OffloadModuleInterface>(mod)) {
- Fortran::semantics::WithOmpDeclarative::RequiresFlags semaFlags;
+ semantics::WithOmpDeclarative::RequiresFlags semaFlags;
if (symbol) {
- Fortran::common::visit(
+ common::visit(
[&](const auto &details) {
- if constexpr (std::is_base_of_v<
- Fortran::semantics::WithOmpDeclarative,
- std::decay_t<decltype(details)>>) {
+ if constexpr (std::is_base_of_v<semantics::WithOmpDeclarative,
+ std::decay_t<decltype(details)>>) {
if (details.has_ompRequires())
semaFlags = *details.ompRequires();
}
diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
index b3f08eb81c799..be6dcd6f5569a 100644
--- a/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
+++ b/flang/lib/Lower/OpenMP/ReductionProcessor.cpp
@@ -72,8 +72,8 @@ ReductionProcessor::ReductionIdentifier ReductionProcessor::getReductionType(
bool ReductionProcessor::supportedIntrinsicProcReduction(
const omp::clause::ProcedureDesignator &pd) {
- Fortran::semantics::Symbol *sym = pd.v.id();
- if (!sym->GetUltimate().attrs().test(Fortran::semantics::Attr::INTRINSIC))
+ semantics::Symbol *sym = pd.v.id();
+ if (!sym->GetUltimate().attrs().test(semantics::Attr::INTRINSIC))
return false;
auto redType = llvm::StringSwitch<bool>(getRealName(sym).ToString())
.Case("max", true)
@@ -180,7 +180,7 @@ ReductionProcessor::getReductionInitValue(mlir::Location loc, mlir::Type type,
case ReductionIdentifier::NEQV:
if (auto cplxTy = mlir::dyn_cast<fir::ComplexType>(type)) {
mlir::Type realTy =
- Fortran::lower::convertReal(builder.getContext(), cplxTy.getFKind());
+ lower::convertReal(builder.getContext(), cplxTy.getFKind());
mlir::Value initRe = builder.createRealConstant(
loc, realTy, getOperationIdentity(redId, loc));
mlir::Value initIm = builder.createRealConstant(loc, realTy, 0);
@@ -680,13 +680,11 @@ bool ReductionProcessor::doReductionByRef(
}
void ReductionProcessor::addDeclareReduction(
- mlir::Location currentLocation,
- Fortran::lower::AbstractConverter &converter,
+ mlir::Location currentLocation, lower::AbstractConverter &converter,
const omp::clause::Reduction &reduction,
llvm::SmallVectorImpl<mlir::Value> &reductionVars,
llvm::SmallVectorImpl<mlir::Attribute> &reductionDeclSymbols,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- *reductionSymbols) {
+ llvm::SmallVectorImpl<const semantics::Symbol *> *reductionSymbols) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
if (std::get<std::optional<omp::clause::Reduction::ReductionModifier>>(
@@ -716,7 +714,7 @@ void ReductionProcessor::addDeclareReduction(
// should happen byref
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
for (const Object &object : objectList) {
- const Fortran::semantics::Symbol *symbol = object.id();
+ const semantics::Symbol *symbol = object.id();
if (reductionSymbols)
reductionSymbols->push_back(symbol);
mlir::Value symVal = converter.getSymbolAddress(*symbol);
@@ -731,8 +729,7 @@ void ReductionProcessor::addDeclareReduction(
// information needed to iterate over the array
if (mlir::isa<fir::SequenceType>(eleType)) {
// For Host associated symbols, use `SymbolBox` instead
- Fortran::lower::SymbolBox symBox =
- converter.lookupOneLevelUpSymbol(*symbol);
+ lower::SymbolBox symBox = converter.lookupOneLevelUpSymbol(*symbol);
hlfir::Entity entity{symBox.getAddr()};
entity = genVariableBox(currentLocation, builder, entity);
mlir::Value box = entity.getBase();
@@ -828,12 +825,12 @@ void ReductionProcessor::addDeclareReduction(
}
}
-const Fortran::semantics::SourceName
-ReductionProcessor::getRealName(const Fortran::semantics::Symbol *symbol) {
+const semantics::SourceName
+ReductionProcessor::getRealName(const semantics::Symbol *symbol) {
return symbol->GetUltimate().name();
}
-const Fortran::semantics::SourceName
+const semantics::SourceName
ReductionProcessor::getRealName(const omp::clause::ProcedureDesignator &pd) {
return getRealName(pd.v.id());
}
diff --git a/flang/lib/Lower/OpenMP/ReductionProcessor.h b/flang/lib/Lower/OpenMP/ReductionProcessor.h
index 8b116a4c52041..2852abad00369 100644
--- a/flang/lib/Lower/OpenMP/ReductionProcessor.h
+++ b/flang/lib/Lower/OpenMP/ReductionProcessor.h
@@ -67,10 +67,10 @@ class ReductionProcessor {
static bool
supportedIntrinsicProcReduction(const omp::clause::ProcedureDesignator &pd);
- static const Fortran::semantics::SourceName
- getRealName(const Fortran::semantics::Symbol *symbol);
+ static const semantics::SourceName
+ getRealName(const semantics::Symbol *symbol);
- static const Fortran::semantics::SourceName
+ static const semantics::SourceName
getRealName(const omp::clause::ProcedureDesignator &pd);
static bool
@@ -124,13 +124,12 @@ class ReductionProcessor {
/// Creates a reduction declaration and associates it with an OpenMP block
/// directive.
static void addDeclareReduction(
- mlir::Location currentLocation,
- Fortran::lower::AbstractConverter &converter,
+ mlir::Location currentLocation, lower::AbstractConverter &converter,
const omp::clause::Reduction &reduction,
llvm::SmallVectorImpl<mlir::Value> &reductionVars,
llvm::SmallVectorImpl<mlir::Attribute> &reductionDeclSymbols,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
- *reductionSymbols = nullptr);
+ llvm::SmallVectorImpl<const semantics::Symbol *> *reductionSymbols =
+ nullptr);
};
template <typename FloatOp, typename IntegerOp>
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index cb1d1a5a7f3dd..4d665e6dd34c5 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -52,22 +52,22 @@ int64_t getCollapseValue(const List<Clause> &clauses) {
}
void genObjectList(const ObjectList &objects,
- Fortran::lower::AbstractConverter &converter,
+ lower::AbstractConverter &converter,
llvm::SmallVectorImpl<mlir::Value> &operands) {
for (const Object &object : objects) {
- const Fortran::semantics::Symbol *sym = object.id();
+ const semantics::Symbol *sym = object.id();
assert(sym && "Expected Symbol");
if (mlir::Value variable = converter.getSymbolAddress(*sym)) {
operands.push_back(variable);
} else if (const auto *details =
- sym->detailsIf<Fortran::semantics::HostAssocDetails>()) {
+ sym->detailsIf<semantics::HostAssocDetails>()) {
operands.push_back(converter.getSymbolAddress(details->symbol()));
converter.copySymbolBinding(details->symbol(), *sym);
}
}
}
-mlir::Type getLoopVarType(Fortran::lower::AbstractConverter &converter,
+mlir::Type getLoopVarType(lower::AbstractConverter &converter,
std::size_t loopVarTypeSize) {
// OpenMP runtime requires 32-bit or 64-bit loop variables.
loopVarTypeSize = loopVarTypeSize * 8;
@@ -85,24 +85,21 @@ mlir::Type getLoopVarType(Fortran::lower::AbstractConverter &converter,
return converter.getFirOpBuilder().getIntegerType(loopVarTypeSize);
}
-Fortran::semantics::Symbol *
-getIterationVariableSymbol(const Fortran::lower::pft::Evaluation &eval) {
- return eval.visit(Fortran::common::visitors{
- [&](const Fortran::parser::DoConstruct &doLoop) {
+semantics::Symbol *
+getIterationVariableSymbol(const lower::pft::Evaluation &eval) {
+ return eval.visit(common::visitors{
+ [&](const parser::DoConstruct &doLoop) {
if (const auto &maybeCtrl = doLoop.GetLoopControl()) {
- using LoopControl = Fortran::parser::LoopControl;
+ using LoopControl = parser::LoopControl;
if (auto *bounds = std::get_if<LoopControl::Bounds>(&maybeCtrl->u)) {
- static_assert(
- std::is_same_v<decltype(bounds->name),
- Fortran::parser::Scalar<Fortran::parser::Name>>);
+ static_assert(std::is_same_v<decltype(bounds->name),
+ parser::Scalar<parser::Name>>);
return bounds->name.thing.symbol;
}
}
- return static_cast<Fortran::semantics::Symbol *>(nullptr);
- },
- [](auto &&) {
- return static_cast<Fortran::semantics::Symbol *>(nullptr);
+ return static_cast<semantics::Symbol *>(nullptr);
},
+ [](auto &&) { return static_cast<semantics::Symbol *>(nullptr); },
});
}
@@ -139,12 +136,11 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
}
static int
-getComponentPlacementInParent(const Fortran::semantics::Symbol *componentSym) {
- const auto *derived =
- componentSym->owner()
- .derivedTypeSpec()
- ->typeSymbol()
- .detailsIf<Fortran::semantics::DerivedTypeDetails>();
+getComponentPlacementInParent(const semantics::Symbol *componentSym) {
+ const auto *derived = componentSym->owner()
+ .derivedTypeSpec()
+ ->typeSymbol()
+ .detailsIf<semantics::DerivedTypeDetails>();
assert(derived &&
"expected derived type details when processing component symbol");
for (auto [placement, name] : llvm::enumerate(derived->componentNames()))
@@ -155,7 +151,7 @@ getComponentPlacementInParent(const Fortran::semantics::Symbol *componentSym) {
static std::optional<Object>
getComponentObject(std::optional<Object> object,
- Fortran::semantics::SemanticsContext &semaCtx) {
+ semantics::SemanticsContext &semaCtx) {
if (!object)
return std::nullopt;
@@ -176,7 +172,7 @@ getComponentObject(std::optional<Object> object,
static void
generateMemberPlacementIndices(const Object &object,
llvm::SmallVectorImpl<int> &indices,
- Fortran::semantics::SemanticsContext &semaCtx) {
+ semantics::SemanticsContext &semaCtx) {
auto compObj = getComponentObject(object, semaCtx);
while (compObj) {
indices.push_back(getComponentPlacementInParent(compObj->id()));
@@ -189,16 +185,14 @@ generateMemberPlacementIndices(const Object &object,
void addChildIndexAndMapToParent(
const omp::Object &object,
- std::map<const Fortran::semantics::Symbol *,
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
- mlir::omp::MapInfoOp &mapOp,
- Fortran::semantics::SemanticsContext &semaCtx) {
- std::optional<Fortran::evaluate::DataRef> dataRef =
- ExtractDataRef(object.designator);
+ mlir::omp::MapInfoOp &mapOp, semantics::SemanticsContext &semaCtx) {
+ std::optional<evaluate::DataRef> dataRef = ExtractDataRef(object.designator);
assert(dataRef.has_value() &&
"DataRef could not be extracted during mapping of derived type "
"cannot proceed");
- const Fortran::semantics::Symbol *parentSym = &dataRef->GetFirstSymbol();
+ const semantics::Symbol *parentSym = &dataRef->GetFirstSymbol();
assert(parentSym && "Could not find parent symbol during lower of "
"a component member in OpenMP map clause");
llvm::SmallVector<int> indices;
@@ -236,14 +230,14 @@ static mlir::DenseIntElementsAttr createDenseElementsAttrFromIndices(
llvm::SmallVector<int64_t> shape;
calculateShapeAndFillIndices(shape, memberPlacementData);
- llvm::SmallVector<int> indicesFlattened = std::accumulate(
- memberPlacementData.begin(), memberPlacementData.end(),
- llvm::SmallVector<int>(),
- [](llvm::SmallVector<int> &x, OmpMapMemberIndicesData y) {
- x.insert(x.end(), y.memberPlacementIndices.begin(),
- y.memberPlacementIndices.end());
- return x;
- });
+ llvm::SmallVector<int> indicesFlattened =
+ std::accumulate(memberPlacementData.begin(), memberPlacementData.end(),
+ llvm::SmallVector<int>(),
+ [](llvm::SmallVector<int> &x, OmpMapMemberIndicesData y) {
+ x.insert(x.end(), y.memberPlacementIndices.begin(),
+ y.memberPlacementIndices.end());
+ return x;
+ });
return mlir::DenseIntElementsAttr::get(
mlir::VectorType::get(shape,
@@ -252,11 +246,11 @@ static mlir::DenseIntElementsAttr createDenseElementsAttrFromIndices(
}
void insertChildMapInfoIntoParent(
- Fortran::lower::AbstractConverter &converter,
- std::map<const Fortran::semantics::Symbol *,
+ lower::AbstractConverter &converter,
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapOperands,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &mapSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
llvm::SmallVectorImpl<mlir::Type> *mapSymTypes,
llvm::SmallVectorImpl<mlir::Location> *mapSymLocs) {
for (auto indices : parentMemberIndices) {
@@ -323,30 +317,28 @@ void insertChildMapInfoIntoParent(
}
}
-Fortran::semantics::Symbol *
-getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject) {
- Fortran::semantics::Symbol *sym = nullptr;
+semantics::Symbol *getOmpObjectSymbol(const parser::OmpObject &ompObject) {
+ semantics::Symbol *sym = nullptr;
std::visit(
- Fortran::common::visitors{
- [&](const Fortran::parser::Designator &designator) {
+ common::visitors{
+ [&](const parser::Designator &designator) {
if (auto *arrayEle =
- Fortran::parser::Unwrap<Fortran::parser::ArrayElement>(
- designator)) {
+ parser::Unwrap<parser::ArrayElement>(designator)) {
// Use getLastName to retrieve the arrays symbol, this will
// provide the farthest right symbol (the last) in a designator,
// i.e. providing something like the following:
// "dtype1%dtype2%array[2:10]", will result in "array"
sym = GetLastName(arrayEle->base).symbol;
- } else if (auto *structComp = Fortran::parser::Unwrap<
- Fortran::parser::StructureComponent>(designator)) {
- sym = structComp->component.symbol;
- } else if (const Fortran::parser::Name *name =
- Fortran::semantics::getDesignatorNameIfDataRef(
+ } else if (auto *structComp =
+ parser::Unwrap<parser::StructureComponent>(
designator)) {
+ sym = structComp->component.symbol;
+ } else if (const parser::Name *name =
+ semantics::getDesignatorNameIfDataRef(designator)) {
sym = name->symbol;
}
},
- [&](const Fortran::parser::Name &name) { sym = name.symbol; }},
+ [&](const parser::Name &name) { sym = name.symbol; }},
ompObject.u);
return sym;
}
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index 345ce55620ee9..d20f9187640f0 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -42,8 +42,7 @@ class AbstractConverter;
namespace omp {
using DeclareTargetCapturePair =
- std::pair<mlir::omp::DeclareTargetCaptureClause,
- const Fortran::semantics::Symbol &>;
+ std::pair<mlir::omp::DeclareTargetCaptureClause, const semantics::Symbol &>;
// A small helper structure for keeping track of a component members MapInfoOp
// and index data when lowering OpenMP map clauses. Keeps track of the
@@ -69,24 +68,24 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
void addChildIndexAndMapToParent(
const omp::Object &object,
- std::map<const Fortran::semantics::Symbol *,
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
- mlir::omp::MapInfoOp &mapOp, Fortran::semantics::SemanticsContext &semaCtx);
+ mlir::omp::MapInfoOp &mapOp, semantics::SemanticsContext &semaCtx);
void insertChildMapInfoIntoParent(
- Fortran::lower::AbstractConverter &converter,
- std::map<const Fortran::semantics::Symbol *,
+ lower::AbstractConverter &converter,
+ std::map<const semantics::Symbol *,
llvm::SmallVector<OmpMapMemberIndicesData>> &parentMemberIndices,
llvm::SmallVectorImpl<mlir::Value> &mapOperands,
- llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> &mapSyms,
+ llvm::SmallVectorImpl<const semantics::Symbol *> &mapSyms,
llvm::SmallVectorImpl<mlir::Type> *mapSymTypes,
llvm::SmallVectorImpl<mlir::Location> *mapSymLocs);
-mlir::Type getLoopVarType(Fortran::lower::AbstractConverter &converter,
+mlir::Type getLoopVarType(lower::AbstractConverter &converter,
std::size_t loopVarTypeSize);
-Fortran::semantics::Symbol *
-getIterationVariableSymbol(const Fortran::lower::pft::Evaluation &eval);
+semantics::Symbol *
+getIterationVariableSymbol(const lower::pft::Evaluation &eval);
void gatherFuncAndVarSyms(
const ObjectList &objects, mlir::omp::DeclareTargetCaptureClause clause,
@@ -94,11 +93,10 @@ void gatherFuncAndVarSyms(
int64_t getCollapseValue(const List<Clause> &clauses);
-Fortran::semantics::Symbol *
-getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject);
+semantics::Symbol *getOmpObjectSymbol(const parser::OmpObject &ompObject);
void genObjectList(const ObjectList &objects,
- Fortran::lower::AbstractConverter &converter,
+ lower::AbstractConverter &converter,
llvm::SmallVectorImpl<mlir::Value> &operands);
} // namespace omp
More information about the flang-commits
mailing list