[flang-commits] [flang] 381de9a - [flang][OpenMP] Compute the set of loop directives in parser, NFC (#206748)
via flang-commits
flang-commits at lists.llvm.org
Wed Jul 1 12:03:17 PDT 2026
Author: Krzysztof Parzyszek
Date: 2026-07-01T14:03:12-05:00
New Revision: 381de9a7811f222e7ffe18a0d0158dfe005454db
URL: https://github.com/llvm/llvm-project/commit/381de9a7811f222e7ffe18a0d0158dfe005454db
DIFF: https://github.com/llvm/llvm-project/commit/381de9a7811f222e7ffe18a0d0158dfe005454db.diff
LOG: [flang][OpenMP] Compute the set of loop directives in parser, NFC (#206748)
Use the constexpr functions for association and source language to
compute the set of loop-associated directives instead of listing them
individually.
Added:
Modified:
flang/lib/Parser/openmp-parsers.cpp
Removed:
################################################################################
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 1957c7c5947cd..2c5f9c19a944e 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -2603,48 +2603,21 @@ TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
static constexpr DirectiveSet GetLoopDirectives() {
using Directive = llvm::omp::Directive;
- constexpr DirectiveSet loopDirectives{
- unsigned(Directive::OMPD_distribute),
- unsigned(Directive::OMPD_distribute_parallel_do),
- unsigned(Directive::OMPD_distribute_parallel_do_simd),
- unsigned(Directive::OMPD_distribute_simd),
- unsigned(Directive::OMPD_do),
- unsigned(Directive::OMPD_do_simd),
- unsigned(Directive::OMPD_loop),
- unsigned(Directive::OMPD_masked_taskloop),
- unsigned(Directive::OMPD_masked_taskloop_simd),
- unsigned(Directive::OMPD_master_taskloop),
- unsigned(Directive::OMPD_master_taskloop_simd),
- unsigned(Directive::OMPD_parallel_do),
- unsigned(Directive::OMPD_parallel_do_simd),
- unsigned(Directive::OMPD_parallel_loop),
- unsigned(Directive::OMPD_parallel_masked_taskloop),
- unsigned(Directive::OMPD_parallel_masked_taskloop_simd),
- unsigned(Directive::OMPD_parallel_master_taskloop),
- unsigned(Directive::OMPD_parallel_master_taskloop_simd),
- unsigned(Directive::OMPD_simd),
- unsigned(Directive::OMPD_target_loop),
- unsigned(Directive::OMPD_target_parallel_do),
- unsigned(Directive::OMPD_target_parallel_do_simd),
- unsigned(Directive::OMPD_target_parallel_loop),
- unsigned(Directive::OMPD_target_simd),
- unsigned(Directive::OMPD_target_teams_distribute),
- unsigned(Directive::OMPD_target_teams_distribute_parallel_do),
- unsigned(Directive::OMPD_target_teams_distribute_parallel_do_simd),
- unsigned(Directive::OMPD_target_teams_distribute_simd),
- unsigned(Directive::OMPD_target_teams_loop),
- unsigned(Directive::OMPD_taskloop),
- unsigned(Directive::OMPD_taskloop_simd),
- unsigned(Directive::OMPD_teams_distribute),
- unsigned(Directive::OMPD_teams_distribute_parallel_do),
- unsigned(Directive::OMPD_teams_distribute_parallel_do_simd),
- unsigned(Directive::OMPD_teams_distribute_simd),
- unsigned(Directive::OMPD_teams_loop),
- unsigned(Directive::OMPD_fuse),
- unsigned(Directive::OMPD_tile),
- unsigned(Directive::OMPD_unroll),
- unsigned(Directive::OMPD_interchange),
- };
+ using SourceLanguage = llvm::omp::SourceLanguage;
+ DirectiveSet loopDirectives;
+
+ for (auto dirVal{llvm::to_underlying(Directive::First_)};
+ dirVal != llvm::to_underlying(Directive::Last_) + 1; ++dirVal) {
+ auto dirId{static_cast<Directive>(dirVal)};
+ auto assoc{getDirectiveAssociation(dirId)};
+ if (assoc == llvm::omp::Association::LoopNest ||
+ assoc == llvm::omp::Association::LoopSeq) {
+ auto langs{getDirectiveLanguages(dirId)};
+ if (llvm::to_underlying(langs & SourceLanguage::Fortran) != 0) {
+ loopDirectives.set(dirVal);
+ }
+ }
+ }
return loopDirectives;
}
More information about the flang-commits
mailing list