[flang-commits] [flang] [flang][OpenMP] Rename enum OmpxHold to Ompx_Hold in parser (PR #113366)
Krzysztof Parzyszek via flang-commits
flang-commits at lists.llvm.org
Tue Oct 22 12:03:25 PDT 2024
https://github.com/kparzysz created https://github.com/llvm/llvm-project/pull/113366
The convention is to use enum names that match the source spelling (up to upper/lower case), including names with underscores.
Remove the special case from unparser, update tests.
>From af082b32e8d1cc1a9bf47de3a76c650e49cab58c Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 22 Oct 2024 13:59:10 -0500
Subject: [PATCH] [flang][OpenMP] Rename enum OmpxHold to Ompx_Hold in parser
The convention is to use enum names that match the source spelling
(up to upper/lower case), including names with underscores.
Remove the special case from unparser, update tests.
---
flang/include/flang/Parser/parse-tree.h | 2 +-
flang/lib/Lower/OpenMP/Clauses.cpp | 8 ++++----
flang/lib/Parser/openmp-parsers.cpp | 2 +-
flang/lib/Parser/unparse.cpp | 8 +-------
flang/test/Parser/OpenMP/map-modifiers.f90 | 8 ++++----
5 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h
index 4a3c992c4ec51b..358fb491b84fb0 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3455,7 +3455,7 @@ WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>);
// map-type-modifier -> ALWAYS | CLOSE | PRESENT | OMPX_HOLD
// map-type -> TO | FROM | TOFROM | ALLOC | RELEASE | DELETE
struct OmpMapClause {
- ENUM_CLASS(TypeModifier, Always, Close, Present, OmpxHold);
+ ENUM_CLASS(TypeModifier, Always, Close, Present, Ompx_Hold);
ENUM_CLASS(Type, To, From, Tofrom, Alloc, Release, Delete)
TUPLE_CLASS_BOILERPLATE(OmpMapClause);
std::tuple<std::optional<std::list<TypeModifier>>, std::optional<Type>,
diff --git a/flang/lib/Lower/OpenMP/Clauses.cpp b/flang/lib/Lower/OpenMP/Clauses.cpp
index 64d661256a187e..303b9ac5b7f4d5 100644
--- a/flang/lib/Lower/OpenMP/Clauses.cpp
+++ b/flang/lib/Lower/OpenMP/Clauses.cpp
@@ -843,10 +843,10 @@ Map make(const parser::OmpClause::Map &inp,
CLAUSET_ENUM_CONVERT( //
convert2, parser::OmpMapClause::TypeModifier, Map::MapTypeModifier,
// clang-format off
- MS(Always, Always)
- MS(Close, Close)
- MS(OmpxHold, OmpxHold)
- MS(Present, Present)
+ MS(Always, Always)
+ MS(Close, Close)
+ MS(Ompx_Hold, OmpxHold)
+ MS(Present, Present)
// clang-format on
);
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 52c7529369dfb5..9b4cdf3720b788 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -110,7 +110,7 @@ TYPE_PARSER(construct<OmpProcBindClause>(
TYPE_PARSER(construct<OmpMapClause::TypeModifier>(
"ALWAYS" >> pure(OmpMapClause::TypeModifier::Always) ||
"CLOSE" >> pure(OmpMapClause::TypeModifier::Close) ||
- "OMPX_HOLD" >> pure(OmpMapClause::TypeModifier::OmpxHold) ||
+ "OMPX_HOLD" >> pure(OmpMapClause::TypeModifier::Ompx_Hold) ||
"PRESENT" >> pure(OmpMapClause::TypeModifier::Present)))
TYPE_PARSER(
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index d1011fe58a0264..d65ddfabb05d9e 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -2087,13 +2087,6 @@ class UnparseVisitor {
}
Walk(std::get<OmpObjectList>(x.t));
}
- void Unparse(const OmpMapClause::TypeModifier &x) {
- if (x == OmpMapClause::TypeModifier::OmpxHold) {
- Word("OMPX_HOLD");
- } else {
- Word(OmpMapClause::EnumToString(x));
- }
- }
void Unparse(const OmpScheduleModifier &x) {
Walk(std::get<OmpScheduleModifier::Modifier1>(x.t));
Walk(",", std::get<std::optional<OmpScheduleModifier::Modifier2>>(x.t));
@@ -2801,6 +2794,7 @@ class UnparseVisitor {
WALK_NESTED_ENUM(OmpOrderClause, Type) // OMP order-type
WALK_NESTED_ENUM(OmpOrderModifier, Kind) // OMP order-modifier
WALK_NESTED_ENUM(OmpMapClause, Type) // OMP map-type
+ WALK_NESTED_ENUM(OmpMapClause, TypeModifier) // OMP map-type-modifier
#undef WALK_NESTED_ENUM
void Unparse(const ReductionOperator::Operator x) {
switch (x) {
diff --git a/flang/test/Parser/OpenMP/map-modifiers.f90 b/flang/test/Parser/OpenMP/map-modifiers.f90
index 4c6dcde5a20c5d..895e29f9101a51 100644
--- a/flang/test/Parser/OpenMP/map-modifiers.f90
+++ b/flang/test/Parser/OpenMP/map-modifiers.f90
@@ -18,7 +18,7 @@ subroutine f00(x)
!PARSE-TREE: OmpBeginBlockDirective
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
-!PARSE-TREE: | | TypeModifier = OmpxHold
+!PARSE-TREE: | | TypeModifier = Ompx_Hold
!PARSE-TREE: | | TypeModifier = Always
!PARSE-TREE: | | TypeModifier = Present
!PARSE-TREE: | | TypeModifier = Close
@@ -42,7 +42,7 @@ subroutine f01(x)
!PARSE-TREE: OmpBeginBlockDirective
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
-!PARSE-TREE: | | TypeModifier = OmpxHold
+!PARSE-TREE: | | TypeModifier = Ompx_Hold
!PARSE-TREE: | | TypeModifier = Always
!PARSE-TREE: | | TypeModifier = Present
!PARSE-TREE: | | TypeModifier = Close
@@ -104,7 +104,7 @@ subroutine f10(x)
!PARSE-TREE: OmpBeginBlockDirective
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
-!PARSE-TREE: | | TypeModifier = OmpxHold
+!PARSE-TREE: | | TypeModifier = Ompx_Hold
!PARSE-TREE: | | TypeModifier = Always
!PARSE-TREE: | | TypeModifier = Present
!PARSE-TREE: | | TypeModifier = Close
@@ -128,7 +128,7 @@ subroutine f11(x)
!PARSE-TREE: OmpBeginBlockDirective
!PARSE-TREE: | OmpBlockDirective -> llvm::omp::Directive = target
!PARSE-TREE: | OmpClauseList -> OmpClause -> Map -> OmpMapClause
-!PARSE-TREE: | | TypeModifier = OmpxHold
+!PARSE-TREE: | | TypeModifier = Ompx_Hold
!PARSE-TREE: | | TypeModifier = Always
!PARSE-TREE: | | TypeModifier = Present
!PARSE-TREE: | | TypeModifier = Close
More information about the flang-commits
mailing list