[flang][OpenMP] Support lowering of metadirective (part 2) (#194424)
Lower non-constant `user={condition(expr)}` selectors in OpenMP
metadirectives to a runtime `fir.if` / `else` selection cascade.
Dynamic user conditions are handled in two separate phases:
- Static applicability uses only selector traits that are known at
compile time.
- Guarded ranking preserves selector specificity and dynamic-condition
scores for the path where the runtime condition evaluates to true.
Lowering first filters candidates using compile-time selector traits,
then orders the remaining candidates with the normal OpenMP variant
ranking rules. If the selected candidate has a non-constant user
condition, that condition is emitted as a `fir.if` guard. When the
condition evaluates to false, the `else` branch continues selection
among the remaining candidates.
For example:
```fortran
!$omp metadirective &
!$omp & when(user={condition(score(100): high)}: barrier) &
!$omp & when(user={condition(low)}: taskwait) &
!$omp & otherwise(nothing)
```
is selected as:
```text
if (high) barrier
else if (low) taskwait
else nothing
```
Scores attached to dynamic `condition(score(...): expr)` selectors are
preserved for the guarded candidate. As a result, those scores affect
ranking only on the runtime path where the condition is true, instead of
allowing a false runtime condition to influence unconditional selection.
This also fixes the interactions with `extension(match_any)` and
`extension(match_none)`:
- `match_any` can be satisfied by a runtime condition when no static
trait matches.
- If static traits already satisfy `match_any`, the dynamic condition
score is used only when the condition is true.
- `match_none` keeps the dynamic condition inactive for static
applicability while still preserving its score for ranking.
For example, this `match_any` selector is statically applicable through
`vendor(llvm)`, but the score on `flag` is used only when `flag`
evaluates to true:
```fortran
!$omp metadirective &
!$omp & when(implementation={extension(match_any), vendor(llvm)}, &
!$omp & user={condition(score(100): flag)}: barrier) &
!$omp & when(user={condition(score(10): .true.)}: taskwait) &
!$omp & otherwise(nothing)
```
is selected as:
```text
if (flag) barrier
else taskwait
```
The final fallback is the highest-ranked unguarded candidate, an
explicit `otherwise` / `default` clause, or implicit `nothing`.
This patch is part of the feature work for #188820 and is stacked on top
of [#193664](https://github.com/llvm/llvm-project/pull/193664).
Assisted with Copilot and GPT-5.4.