[all-commits] [llvm/llvm-project] f3dcf1: [flang][OpenMP] Support lowering of metadirective ...
Chi-Chun, Chen via All-commits
all-commits at lists.llvm.org
Tue Jun 2 10:57:30 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f3dcf16115f862f6fa5ea8e520b371f7e57a9c3d
https://github.com/llvm/llvm-project/commit/f3dcf16115f862f6fa5ea8e520b371f7e57a9c3d
Author: Chi-Chun, Chen <chichun.chen at hpe.com>
Date: 2026-06-02 (Tue, 02 Jun 2026)
Changed paths:
M flang/lib/Lower/OpenMP/OpenMP.cpp
M flang/lib/Lower/OpenMP/Utils.cpp
M flang/lib/Lower/OpenMP/Utils.h
R flang/test/Lower/OpenMP/Todo/begin-metadirective.f90
A flang/test/Lower/OpenMP/Todo/metadirective-declarative.f90
A flang/test/Lower/OpenMP/Todo/metadirective-dynamic.f90
R flang/test/Lower/OpenMP/Todo/metadirective-exec.f90
A flang/test/Lower/OpenMP/Todo/metadirective-loop.f90
R flang/test/Lower/OpenMP/Todo/metadirective-spec.f90
A flang/test/Lower/OpenMP/Todo/metadirective-structured-trait-property.f90
A flang/test/Lower/OpenMP/Todo/metadirective-target-device.f90
A flang/test/Lower/OpenMP/metadirective-construct.f90
A flang/test/Lower/OpenMP/metadirective-device-arch.f90
A flang/test/Lower/OpenMP/metadirective-device-isa.f90
A flang/test/Lower/OpenMP/metadirective-device-kind.f90
A flang/test/Lower/OpenMP/metadirective-implementation.f90
A flang/test/Lower/OpenMP/metadirective-nothing.f90
A flang/test/Lower/OpenMP/metadirective-user.f90
M flang/test/Semantics/OpenMP/metadirective-common.f90
Log Message:
-----------
[flang][OpenMP] Support lowering of metadirective (part 1) (#193664)
Add lowering support for OpenMP metadirective variants that can be
selected statically. Selection is performed during lowering with
`llvm::omp::OMPContext`, and only the selected directive variant is
lowered.
For example:
```fortran
subroutine static_vendor()
!$omp metadirective &
!$omp & when(implementation={vendor(llvm)}: barrier) &
!$omp & otherwise(nothing)
end subroutine
```
is lowered to a function containing `omp.barrier`, because `vendor(llvm)` is statically applicable when compiling with Flang.
Applicable variants are represented with `llvm::omp::VariantMatchInfo` and ranked using OpenMP context matching and selector scores from the LLVM frontend.
This patch supports both standalone metadirectives and begin/end
metadirectives. For begin/end metadirectives, the variant is selected
before lowering the enclosed region so that the selected directive
correctly wraps the region.
This initial static-resolution PR supports:
* implementation={vendor(...)}
* device={kind(...), isa(...), arch(...)}
* user={condition(<constant-expr>)}
* construct={parallel, target, teams, for}
* default, nothing, and otherwise clauses
This patch also preserves `score(...)` on constant user conditions so scored conditions participate correctly in variant ranking. When matching nested construct selectors, it includes constructs introduced by an enclosing selected begin/end metadirective.
Dynamic user conditions (#194424), `target_device` selectors, loop-associated directive variants, and complete construct support are deferred to follow-up patches.
This patch is part of the feature work for #188820.
Assisted by GitHub Copilot and GPT-5.4.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list