[flang-commits] [flang] [llvm] [OpenMP] Introduce descriptors for directives, clause groups and sets (PR #229522)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Oct 12 09:56:03 PDT 2026


================
@@ -95,9 +153,57 @@ Clauses descriptor::ModifierSet::getClauses(Version V) const {
 const descriptor::Clause &getDescriptor(Clause C) {
   return getClauseMap().at(C);
 }
+
+const descriptor::ClauseSet &getDescriptor(ClauseSet S) {
+  return getClauseSetMap().at(S);
+}
+
+const descriptor::Directive &getDescriptor(Directive D) {
+  ArrayRef<llvm::omp::Directive> Leafs = llvm::omp::getLeafConstructsOrSelf(D);
+  if (Leafs.size() == 1)
+    return getDirectiveMap().at(Leafs[0]);
+
+  static std::map<Directive, descriptor::Directive> Compound;
+  if (auto F = Compound.find(D); F != Compound.end())
+    return F->second;
+
+  // Combine details from all leafs into a single map and create a descriptor
+  // from it.
+  using Details = descriptor::details::Directive;
+  using DetailsMap = descriptor::DetailsMap<Details>;
+  DetailsMap Det;
+  // The name of the descriptor will be the spelling from the latest supported
+  // version.
+  llvm::omp::Version MaxV(0);
+
+  for (llvm::omp::Directive L : Leafs) {
+    const auto &Desc{getDescriptor(L)};
+    for (auto &[V, T] : Desc.getDetails()) {
+      MaxV = std::max(MaxV, V); // Used for descriptor's name.
+      auto F = Det.insert({V, Details{}}).first;
+      F->second.Props |= T.Props;
----------------
tblah wrote:

Some other examples (from AI agent):
- `Simdizable` in `parallel do simd`: `simd` is permitted inside a `simd` region but `parallel` is not
- `TeamsNestable` in `teams distribute`: `distribute` sets `TeamsNestable` but the whole construct is not nestable inside of `teams`
- `OrderConcurrentNestable` in `taskloop simd`: `simd` sets `OrderConcurrentNestable` but the outer `taskloop` is still not allowed directly inside an `order(concurrent)` region.

https://github.com/llvm/llvm-project/pull/229522


More information about the flang-commits mailing list