17 Commits

Author SHA1 Message Date
Krzysztof Parzyszek
12cb376321
[flang][OpenMP] Diagnose whole assumed-size arrays on two clauses (#172510)
OpenMP 6.0 allows whole assumed-size arrays to appear as list items in
MAP and USE_DEVICE_ADDR clauses. This was not allowed in prior spec
versions.
2025-12-17 12:03:35 -06:00
Krzysztof Parzyszek
1451f3d9b0
[flang][OpenMP] Use StylizedInstance in converted clauses (#171907)
Invent `StylizedInstance` class to store special variables together with
the instantiated expression in omp::clause::Initializer. This will
eliminate the need for visiting the original AST nodes in lowering to
MLIR.
2025-12-12 08:09:25 -06:00
Krzysztof Parzyszek
c88ae6eb21
[flang][OpenMP] Move two utilities from Semantics to Parser, NFC (#168549)
Move `GetInnermostExecPart` and `IsStrictlyStructuredBlock` from
Semantics/openmp-utils.* to Parser/openmp-utils.*. These two only depend
on the AST contents and properties.
2025-11-18 11:44:03 -06:00
Krzysztof Parzyszek
ab049891cd
[flang][OpenMP] Reorganize ALLOCATE-related semantic checks (#165719)
For ALLOCATORS and executable ALLOCATE first perform list item checks in
the context of an individual ALLOCATE clause or directive respectively,
then perform "global" checks, e.g. whether all list items are present on
the ALLOCATE statement.

These changes allowed to simplify the checks for presence on ALLOCATE
statement and the use of a predefined allocator.

Additionally, allow variable list item lists to be empty, add a test for
the related spec restriction.

This is a first step towards unifying OpenMPDeclarativeAllocate and
OpenMPExecutableAllocate into a single directive.
2025-11-03 06:58:59 -06:00
Krzysztof Parzyszek
4d80e0c444
[flang][OpenMP] Add missing forward declarations and includes (#164860)
Add declarations/includes of Scope and Symbol to Semantics/openmp-utils.
2025-10-23 13:15:15 -05:00
Krzysztof Parzyszek
322dd63004
[flang][OpenMP] Refactor/update semantic checks for ALLOCATE directive (#164420)
OpenMP 5.0 and 5.1 allowed the ALLOCATE directive to appear in two
forms, declarative and executable. The syntax of an individual directive
was the same in both cases, but the semantic restrictions were slightly
different.

- Update the semantic checks to reflect the different restrictions,
gather them in a single function.
- Improve test for the presence of a TARGET region, add a check for
REQUIRES directive.
- Update tests.
2025-10-22 11:46:48 -05:00
Krzysztof Parzyszek
bd79667fc2
[flang][OpenMP] Set REQUIRES flags on program unit symbol (#163448)
REQUIRES clauses apply to the compilation unit, which the OpenMP spec
defines as the program unit in Fortran.

Don't set REQUIRES flags on all containing scopes, only on the containng
program unit, where flags coming from different directives are gathered.
If we wanted to set the flags on subprograms, we would need to first
accummulate all of them, then propagate them down to all subprograms.
That is not done as it is not necessary (the containing program unit is
always available).
2025-10-16 06:28:09 -05:00
Krzysztof Parzyszek
ba5141d27c
[flang][OpenMP] Check contatining scoping unit in DECLARE_SIMD (#161556)
Check if the name on DECLARE_SIMD is the name of the containing scoping
unit.

Fixes https://github.com/llvm/llvm-project/issues/161516
2025-10-01 16:12:30 -05:00
Krzysztof Parzyszek
89d79b65f7
[flang][OpenMP] Semantic checks for TASKGRAPH (#160115)
This verifies the "structural" restrictions on constructs encountered in
a TASKGRAPH construct.

There are also restrictions that apply to list items, specifically in
the following contexts:
- a list item on a clause on a replayable construct,
- data-sharing attributes for a variable on a replayable construct.
These restrictions are not verified, because that would require knowing
which clauses (on a potential compound directive) apply to the task-
generating construct of interest. This information is not available
during semantic checks.
2025-09-22 14:21:12 -05:00
Krzysztof Parzyszek
ad5778ff16
[flang][OpenMP] Use OmpDirectiveSpecification in THREADPRIVATE (#159632)
Since ODS doesn't store a list of OmpObjects (i.e. not as
OmpObjectList), some semantics-checking functions needed to be updated
to operate on a single object at a time.
2025-09-22 10:42:58 -05:00
Krzysztof Parzyszek
d89de09cb1
[flang][OpenMP] Reject blank common blocks more gracefully (#159626)
Parse them as "invalid" OmpObjects, then emit a diagnostic in semantic
checks.
2025-09-22 09:56:31 -05:00
Krzysztof Parzyszek
13547a9a77
[flang][OpenMP] Turn IsStrictlyStructuredBlock into utility function,… (#158111)
… NFC
2025-09-12 08:39:16 -05:00
Krzysztof Parzyszek
e368b5343d
[flang][OpenMP] Make OpenMPCriticalConstruct follow block structure (#152007)
This allows not having the END CRITICAL directive in certain situations.
Update semantic checks and symbol resolution.
2025-08-07 08:10:25 -05:00
Andre Kuhlenschmidt
062b22e462
[flang][openacc] Add semantic checks for atomic constructs (#149579)
An error report of the following code generating non-atomic code led us
to realize there are missing checks in the OpenACC atomics code. Add
some of those checks for atomic and sketch how the rest of the code
should proceed in checking the rest of the properties. The following
cases are all reported as errors.
```fortran
! Originally reported error!
!$acc atomic capture
a = b
c = b
!$acc end atomic capture
! Other ambiguous, but related errors!
!$acc atomic capture
x = i
i = x
!$acc end atomic capture
!$acc atomic capture
a = b
b = b
!$acc end atomic capture
!$acc atomic capture
a = b
a = c
!$acc end atomic capture
```
2025-07-30 08:13:07 -07:00
Krzysztof Parzyszek
2914a488c7
[flang][OpenMP] Sema checks, lowering with new format of MAP modifiers (#149137)
OpenMP 6.0 has changed the modifiers on the MAP clause. Previous patch
has introduced parsing support for them. This patch introduces
processing of the new forms in semantic checks and in lowering. This
only applies to existing modifiers, which were updated in the 6.0 spec.
Any of the newly introduced modifiers (SELF and REF) are ignored.
2025-07-22 07:37:47 -05:00
Krzysztof Parzyszek
638943b27e
[flang][OpenMP] Convert AST node for ALLOCATORS to use Block as body (#148005)
The ALLOCATORS construct is one of the few constructs that require a
special form of the associated block.
Convert the AST node to use OmpDirectiveSpecification for the directive
and the optional end directive, and to use parser::Block as the body:
the form of the block is checked in the semantic checks (with a more
meaningful message).
2025-07-11 06:45:11 -05:00
Krzysztof Parzyszek
ba116a8bed
[flang][OpenMP] Split check-omp-structure.cpp into smaller files, NFC (#146359)
Create these new files in flang/lib/Semantics:
  openmp-utils.cpp/.h         - Common utilities
  check-omp-atomic.cpp        - Atomic-related checks
  check-omp-loop.cpp          - Loop constructs/clauses
  check-omp-metadirective.cpp - Metadirective-related checks

Update lists of included headers, std in particular.

---------

Co-authored-by: Jack Styles <jack.styles@arm.com>
2025-07-01 11:12:00 -05:00