[llvm-branch-commits] [flang] [llvm] [flang][OpenMP] Switch TableGen generation to use llvm::EnumSet (PR #211327)
Krzysztof Parzyszek via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 23 06:02:35 PDT 2026
https://github.com/kparzysz updated https://github.com/llvm/llvm-project/pull/211327
>From 49291613c37f6f2ac0ba6ddb3d124fa35c8a813e Mon Sep 17 00:00:00 2001
From: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
Date: Tue, 21 Jul 2026 09:08:19 -0500
Subject: [PATCH] [flang][OpenMP] Switch TableGen generation to use
llvm::EnumSet
Replace the remaining uses of the common::EnumSet-based OmpClauseSet to
llvm::omp::ClauseSet.
---
flang/lib/Semantics/check-omp-structure.cpp | 45 ++++++++++-----------
flang/lib/Semantics/check-omp-structure.h | 11 ++---
llvm/include/llvm/Frontend/OpenMP/OMP.td | 2 +-
3 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp
index 42b27a332966a..d10b25b3ef2cb 100644
--- a/flang/lib/Semantics/check-omp-structure.cpp
+++ b/flang/lib/Semantics/check-omp-structure.cpp
@@ -63,15 +63,13 @@ using namespace Fortran::semantics::omp;
using namespace Fortran::parser::omp;
template <>
-std::string ClauseSetToString(const OmpClauseSet &set,
+std::string ClauseSetToString(const llvm::omp::ClauseSet &set,
std::function<llvm::StringRef(llvm::omp::Clause)> getName) {
- std::string list;
- set.IterateOverMembers([&](llvm::omp::Clause o) {
- if (!list.empty())
- list.append(", ");
- list.append(parser::ToUpperCaseLetters(getName(o)));
- });
- return list;
+ std::vector<std::string> names;
+ for (llvm::omp::Clause c : set) {
+ names.push_back(parser::ToUpperCaseLetters(getName(c)));
+ }
+ return llvm::join(names, ", ");
}
OmpStructureChecker::OmpStructureChecker(SemanticsContext &context)
@@ -950,7 +948,8 @@ void OmpStructureChecker::CheckDirectiveDeprecation(
}
std::pair<const parser::OmpClause *, const parser::OmpClause *>
-OmpStructureChecker::FindMutuallyExclusiveClauses(OmpClauseSet exclusive,
+OmpStructureChecker::FindMutuallyExclusiveClauses(
+ llvm::omp::ClauseSet exclusive,
const std::vector<const parser::OmpClause *> &clauses) {
const parser::OmpClause *first{nullptr};
for (const parser::OmpClause *clause : clauses) {
@@ -1001,7 +1000,7 @@ void OmpStructureChecker::CheckClauses(parser::OmpDirectiveName dirName,
}
}
- OmpClauseSet notAllowed;
+ llvm::omp::ClauseSet notAllowed;
for (const parser::OmpClause *clause : allClauses) {
llvm::omp::Clause clauseId{clause->Id()};
@@ -1026,7 +1025,7 @@ void OmpStructureChecker::CheckClauses(parser::OmpDirectiveName dirName,
// Exclusive clauses aren't necessarily unique, but there is no way
// to specify a clause in both sets right now, and all clauses currently
// listed as exclusive also happen to be unique.
- OmpClauseSet uniqueSet{//
+ llvm::omp::ClauseSet uniqueSet{//
directiveClausesMap_[dirId].allowedOnce |
directiveClausesMap_[dirId].allowedExclusive};
@@ -1054,19 +1053,17 @@ void OmpStructureChecker::CheckClauses(parser::OmpDirectiveName dirName,
bool requiredPresent{false};
// Prepare the requiredSet relevant to the current OpenMP version.
- OmpClauseSet requiredSet;
- directiveClausesMap_[dirId].requiredOneOf.IterateOverMembers( //
- [&](llvm::omp::Clause id) {
- if (IsAllowedClause(id)) {
- requiredSet.set(id);
- }
- });
- requiredSet.IterateOverMembers( //
- [&](llvm::omp::Clause id) {
- if (!requiredPresent && present.count(id) != 0) {
- requiredPresent = true;
- }
- });
+ llvm::omp::ClauseSet requiredSet;
+ for (llvm::omp::Clause id : directiveClausesMap_[dirId].requiredOneOf) {
+ if (IsAllowedClause(id)) {
+ requiredSet.set(id);
+ }
+ }
+ for (llvm::omp::Clause id : requiredSet) {
+ if (!requiredPresent && present.count(id) != 0) {
+ requiredPresent = true;
+ }
+ }
if (!requiredPresent && !requiredSet.empty()) {
context_.Say(dirName.source,
diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h
index 6b137eb47469d..c5cf7d0c89b59 100644
--- a/flang/lib/Semantics/check-omp-structure.h
+++ b/flang/lib/Semantics/check-omp-structure.h
@@ -23,11 +23,6 @@
#include "llvm/ADT/iterator_range.h"
#include "llvm/Frontend/OpenMP/OMP.h"
-namespace Fortran::semantics {
-using OmpClauseSet =
- common::EnumSet<llvm::omp::Clause, llvm::omp::Clause_enumSize>;
-}
-
#define GEN_FLANG_DIRECTIVE_CLAUSE_SETS
#include "llvm/Frontend/OpenMP/OMP.inc"
@@ -53,10 +48,10 @@ using DirectivesClauseTriple = std::multimap<llvm::omp::Directive,
std::pair<llvm::omp::Directive, const llvm::omp::ClauseSet>>;
using OmpStructureCheckerBase = DirectiveStructureChecker<llvm::omp::Directive,
- llvm::omp::Clause, parser::OmpClause, OmpClauseSet>;
+ llvm::omp::Clause, parser::OmpClause, llvm::omp::ClauseSet>;
template <>
-std::string ClauseSetToString(const OmpClauseSet &set,
+std::string ClauseSetToString(const llvm::omp::ClauseSet &set,
std::function<llvm::StringRef(llvm::omp::Clause)> getName);
class OmpStructureChecker : public OmpStructureCheckerBase {
@@ -341,7 +336,7 @@ class OmpStructureChecker : public OmpStructureCheckerBase {
llvm::iterator_range<ClauseIterator> endClauses);
void AnalyzeObject(const parser::OmpObject &object);
std::pair<const parser::OmpClause *, const parser::OmpClause *>
- FindMutuallyExclusiveClauses(OmpClauseSet exclusive,
+ FindMutuallyExclusiveClauses(llvm::omp::ClauseSet exclusive,
const std::vector<const parser::OmpClause *> &clauses);
const parser::OpenMPConstruct *GetCurrentConstruct() const;
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index df0080e70255e..6c616f55aacfb 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -24,7 +24,7 @@ def OpenMP : DirectiveLanguage {
let loopModifierPrefix = "OMPLM_";
let makeEnumAvailableInNamespace = true;
let enableBitmaskEnumInNamespace = true;
- let clauseEnumSetClass = "Fortran::semantics::OmpClauseSet";
+ let clauseEnumSetClass = "llvm::omp::ClauseSet";
let flangClauseBaseClass = "OmpClause";
}
More information about the llvm-branch-commits
mailing list