[flang] [llvm] [Flang][OpenMP] WIP: Add frontend support for declare variant (PR #130578)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 10 04:02:12 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff f3dcc0fe228f6a1a69147ead0a76ce0fe02d316d 642b452a85a04526215bcee21c046229562d0f35 --extensions cpp,h -- flang/include/flang/Parser/dump-parse-tree.h flang/include/flang/Parser/parse-tree.h flang/lib/Lower/OpenMP/OpenMP.cpp flang/lib/Parser/openmp-parsers.cpp flang/lib/Semantics/check-omp-structure.cpp flang/lib/Semantics/check-omp-structure.h flang/lib/Semantics/resolve-names.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 4b63681d90..c7bdc8503b 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -4026,7 +4026,6 @@ struct OmpAllocateClause {
std::tuple<MODIFIERS(), OmpObjectList> t;
};
-
// InteropType -> target || targetsync
struct OmpInteropType {
ENUM_CLASS(Value, Target, TargetSync)
@@ -4035,11 +4034,9 @@ struct OmpInteropType {
struct OmpAppendArgsClause {
struct OmpAppendOp {
- WRAPPER_CLASS_BOILERPLATE(
- OmpAppendOp, std::list<OmpInteropType>);
+ WRAPPER_CLASS_BOILERPLATE(OmpAppendOp, std::list<OmpInteropType>);
};
- WRAPPER_CLASS_BOILERPLATE(
- OmpAppendArgsClause, std::list<OmpAppendOp>);
+ WRAPPER_CLASS_BOILERPLATE(OmpAppendArgsClause, std::list<OmpAppendOp>);
};
// Ref: [5.2:216-217 (sort of, as it's only mentioned in passing)
@@ -4650,7 +4647,6 @@ struct OmpBlockDirective {
CharBlock source;
};
-
struct OmpDeclareVariantDirective {
TUPLE_CLASS_BOILERPLATE(OmpDeclareVariantDirective);
CharBlock source;
@@ -4735,8 +4731,8 @@ struct OpenMPDeclarativeConstruct {
std::variant<OpenMPDeclarativeAllocate, OpenMPDeclarativeAssumes,
OpenMPDeclareMapperConstruct, OpenMPDeclareReductionConstruct,
OpenMPDeclareSimdConstruct, OpenMPDeclareTargetConstruct,
- OmpDeclareVariantDirective, OpenMPThreadprivate, OpenMPRequiresConstruct, OpenMPUtilityConstruct,
- OmpMetadirectiveDirective>
+ OmpDeclareVariantDirective, OpenMPThreadprivate, OpenMPRequiresConstruct,
+ OpenMPUtilityConstruct, OmpMetadirectiveDirective>
u;
};
diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 55e2fcdb39..33376ba33f 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -3126,10 +3126,10 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
TODO(converter.getCurrentLocation(), "OpenMP ASSUMES declaration");
}
-static void genOMP(
- lower::AbstractConverter &converter, lower::SymMap &symTable,
- semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
- const parser::OmpDeclareVariantDirective &declareVariantDirective) {
+static void
+genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
+ const parser::OmpDeclareVariantDirective &declareVariantDirective) {
TODO(converter.getCurrentLocation(), "OpenMPDeclareVariantDirective");
}
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 25a9972be5..8777359fb6 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -559,7 +559,8 @@ TYPE_PARSER(construct<OmpAppendArgsClause::OmpAppendOp>(
TYPE_PARSER(construct<OmpAdjustArgsClause::OmpAdjustOp>(
"NOTHING" >> pure(OmpAdjustArgsClause::OmpAdjustOp::Value::Nothing) ||
- "NEED_DEVICE_PTR" >> pure(OmpAdjustArgsClause::OmpAdjustOp::Value::NeedDevicePtr)))
+ "NEED_DEVICE_PTR" >>
+ pure(OmpAdjustArgsClause::OmpAdjustOp::Value::NeedDevicePtr)))
// --- Parsers for clauses --------------------------------------------
@@ -827,7 +828,7 @@ TYPE_PARSER("ABSENT" >> construct<OmpClause>(construct<OmpClause::Absent>(
"ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) ||
"ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) ||
"ADJUST_ARGS" >> construct<OmpClause>(construct<OmpClause::AdjustArgs>(
- parenthesized(Parser<OmpAdjustArgsClause>{}))) ||
+ parenthesized(Parser<OmpAdjustArgsClause>{}))) ||
"AFFINITY" >> construct<OmpClause>(construct<OmpClause::Affinity>(
parenthesized(Parser<OmpAffinityClause>{}))) ||
"ALIGN" >> construct<OmpClause>(construct<OmpClause::Align>(
@@ -837,7 +838,7 @@ TYPE_PARSER("ABSENT" >> construct<OmpClause>(construct<OmpClause::Absent>(
"ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>(
parenthesized(Parser<OmpAllocateClause>{}))) ||
"APPEND_ARGS" >> construct<OmpClause>(construct<OmpClause::AppendArgs>(
- parenthesized(Parser<OmpAppendArgsClause>{}))) ||
+ parenthesized(Parser<OmpAppendArgsClause>{}))) ||
"ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>(
parenthesized(scalarIntExpr))) ||
"AT" >> construct<OmpClause>(construct<OmpClause::At>(
@@ -1232,9 +1233,9 @@ TYPE_PARSER(construct<OmpInitializerClause>(
construct<OmpInitializerClause>(Parser<OmpInitializerProc>{})))
// OpenMP 5.2: 7.5.4 Declare Variant directive
-TYPE_PARSER(sourced(construct<OmpDeclareVariantDirective>(
- verbatim("DECLARE VARIANT"_tok),
- "(" >> maybe(name / ":"), name / ")", Parser<OmpClauseList>{})))
+TYPE_PARSER(sourced(
+ construct<OmpDeclareVariantDirective>(verbatim("DECLARE VARIANT"_tok),
+ "(" >> maybe(name / ":"), name / ")", Parser<OmpClauseList>{})))
// 2.16 Declare Reduction Construct
TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>(
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index f34b16570b..7a5be38b95 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -1606,7 +1606,8 @@ void OmpStructureChecker::Leave(const parser::OpenMPDeclareSimdConstruct &) {
void OmpStructureChecker::Enter(const parser::OmpDeclareVariantDirective &x) {
const auto &dir{std::get<parser::Verbatim>(x.t)};
- PushContextAndClauseSets(dir.source, llvm::omp::Directive::OMPD_declare_variant);
+ PushContextAndClauseSets(
+ dir.source, llvm::omp::Directive::OMPD_declare_variant);
}
void OmpStructureChecker::Leave(const parser::OmpDeclareVariantDirective &) {
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 9a60f0d499..da84f71ada 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1496,7 +1496,7 @@ public:
bool Pre(const parser::OmpDeclareVariantDirective &x) {
AddOmpSourceRange(x.source);
- auto FindSymbolOrError = [](parser::Name& procName) {
+ auto FindSymbolOrError = [](parser::Name &procName) {
auto *symbol{FindSymbol(NonDerivedTypeScope(), procName)};
if (!symbol) {
context().Say(procName.source,
``````````
</details>
https://github.com/llvm/llvm-project/pull/130578
More information about the llvm-commits
mailing list