[flang-commits] [flang] [flang][OpenMP] Move handling of OpenMP symbol flags to OpenMP.cpp (PR #75523)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Thu Dec 14 12:01:19 PST 2023
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/75523
The function `instantiateVariable` in Bridge.cpp has the following code:
```
if (var.getSymbol().test(
Fortran::semantics::Symbol::Flag::OmpThreadprivate))
Fortran::lower::genThreadprivateOp(*this, var);
if (var.getSymbol().test(
Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
Fortran::lower::genDeclareTargetIntGlobal(*this, var);
```
Implement `handleOpenMPSymbolProperties` in OpenMP.cpp, move the above code there, and have `instantiateVariable` call this function instead.
This would further separate OpenMP-related details into OpenMP.cpp.
>From 21261fef67dbbea956adf2e09b8abacd92d9caf3 Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Thu, 14 Dec 2023 13:45:17 -0600
Subject: [PATCH] [flang][OpenMP] Move handling of OpenMP symbol flags to
OpenMP.cpp
The function `instantiateVariable` in Bridge.cpp has the following code:
```
if (var.getSymbol().test(
Fortran::semantics::Symbol::Flag::OmpThreadprivate))
Fortran::lower::genThreadprivateOp(*this, var);
if (var.getSymbol().test(
Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
Fortran::lower::genDeclareTargetIntGlobal(*this, var);
```
Implement `handleOpenMPSymbolProperties` in OpenMP.cpp, move the above
code there, and have `instantiateVariable` call this function instead.
This would further separate OpenMP-related details into OpenMP.cpp.
---
flang/include/flang/Lower/OpenMP.h | 2 ++
flang/lib/Lower/Bridge.cpp | 8 +-------
flang/lib/Lower/OpenMP.cpp | 13 +++++++++++++
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/flang/include/flang/Lower/OpenMP.h b/flang/include/flang/Lower/OpenMP.h
index c9162761a08d54..a6ea26ee949fe7 100644
--- a/flang/include/flang/Lower/OpenMP.h
+++ b/flang/include/flang/Lower/OpenMP.h
@@ -56,6 +56,8 @@ void genOpenMPConstruct(AbstractConverter &, semantics::SemanticsContext &,
pft::Evaluation &, const parser::OpenMPConstruct &);
void genOpenMPDeclarativeConstruct(AbstractConverter &, pft::Evaluation &,
const parser::OpenMPDeclarativeConstruct &);
+void handleOpenMPSymbolProperties(AbstractConverter &converter,
+ const pft::Variable &var);
int64_t getCollapseValue(const Fortran::parser::OmpClauseList &clauseList);
void genThreadprivateOp(AbstractConverter &, const pft::Variable &);
void genDeclareTargetIntGlobal(AbstractConverter &, const pft::Variable &);
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 6ca910d2696742..1ec242fafc5b6d 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -4244,13 +4244,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::AggregateStoreMap &storeMap) {
Fortran::lower::instantiateVariable(*this, var, localSymbols, storeMap);
if (var.hasSymbol()) {
- if (var.getSymbol().test(
- Fortran::semantics::Symbol::Flag::OmpThreadprivate))
- Fortran::lower::genThreadprivateOp(*this, var);
-
- if (var.getSymbol().test(
- Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
- Fortran::lower::genDeclareTargetIntGlobal(*this, var);
+ handleOpenMPSymbolProperties(*this, var);
}
}
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 12b8ea82884d9d..9a798e641d1267 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -3483,6 +3483,19 @@ void Fortran::lower::genOpenMPDeclarativeConstruct(
ompDeclConstruct.u);
}
+void Fortran::lower::handleOpenMPSymbolProperties(
+ Fortran::lower::AbstractConverter &converter,
+ const Fortran::lower::pft::Variable &var) {
+ assert(var.hasSymbol() && "Expecting Symbol");
+ const Fortran::semantics::Symbol &sym = var.getSymbol();
+
+ if (sym.test(Fortran::semantics::Symbol::Flag::OmpThreadprivate))
+ Fortran::lower::genThreadprivateOp(converter, var);
+
+ if (sym.test(Fortran::semantics::Symbol::Flag::OmpDeclareTarget))
+ Fortran::lower::genDeclareTargetIntGlobal(converter, var);
+}
+
int64_t Fortran::lower::getCollapseValue(
const Fortran::parser::OmpClauseList &clauseList) {
for (const Fortran::parser::OmpClause &clause : clauseList.v) {
More information about the flang-commits
mailing list