465 Commits

Author SHA1 Message Date
Zahira Ammarguellat
26fc3aa983
[OpenMP] Missing implicit otherwise clause in metadirective. (#127113)
Compiling this:
 `int main() {`
 ` #pragma omp metadirective when(use r= {condition(0)}`
`: parallel for)`
  `for (int i=0; i<10; i++)`
  ;
}`

is generating an error:
`error: expected expression`
The compiler is interpreting this as if it's compiling a `#pragma omp
metadirective` with no `otherwise` clause.
In the OMP5.2 specs chapter 7.4 it's mentioned that: 
`If no otherwise clause is specified the effect is as if one was
specified without an associated directive variant.`
This patch fixes the issue.
2025-02-28 08:02:35 -05:00
Nico Weber
13ca6050b0 Revert "default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (#125648)"
This reverts commit 73ad78cc57e10b932bddaa9034237f59bb566e6b.
Breaks check-clang, see comments on
https://github.com/llvm/llvm-project/pull/125648
2025-02-21 12:31:32 -05:00
Urvi Rav
73ad78cc57
default clause replaced by otherwise clause for metadirective in OpenMP 5.2 (#125648)
This PR replaces the `default` clause with the `otherwise` clause for
the `metadirective` in OpenMP. The `otherwise` clause serves as a
fallback condition when no directive from the `when` clauses is
selected. In the `when` clause, context selectors define traits
evaluated to determine the directive to be applied.
2025-02-21 15:41:04 +05:30
Zahira Ammarguellat
cf69b4c668
[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#126927)
This patch was reviewed and approved here:
https://github.com/llvm/llvm-project/pull/119891
However it has been reverted here:
083df25dc2
due to a build issue here:
https://lab.llvm.org/buildbot/#/builders/51/builds/10694

This patch is reintroducing the support.
2025-02-13 07:14:36 -05:00
Kazu Hirata
67e1e98811 Revert "[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)"
This reverts commit 070f84ebc89b11df616a83a56df9ac56efbab783.

Buildbot failure:
https://lab.llvm.org/buildbot/#/builders/51/builds/10694
2025-02-11 12:39:01 -08:00
Zahira Ammarguellat
070f84ebc8
[Clang] [OpenMP] Add support for '#pragma omp stripe'. (#119891)
Implement basic parsing and semantic support for `#pragma omp stripe`
constuct introduced in
https://www.openmp.org/wp-content/uploads/[OpenMP-API-Specification-6-0.pdf](https://www.openmp.org/wp-content/uploads/OpenMP-API-Specification-6-0.pdf),
section 11.7.
2025-02-11 13:58:21 -05:00
David Pagan
a5fc7c3ac1
[clang][OpenMP] New OpenMP 6.0 assumption clause, 'no_openmp_constructs' (#125933)
Add initial parsing/sema support for new assumption clause so clause can
be specified. For now, it's ignored, just like the others.

Added support for 'no_openmp_construct' to release notes.

Testing
- Updated appropriate LIT tests.
- Testing: check-all
2025-02-06 12:41:10 -08:00
Ritanya-B-Bharadwaj
8c36665267
[OpenMP]Initial parsing/sema support for target_device selector set (#118471)
This patch adds initial support for target_device selector set - Section
9.2 (Spec 6.0)
2025-02-05 19:24:24 +05:30
David Pagan
ad38e24eb7
[clang][OpenMP] Add 'align' modifier for 'allocate' clause (#121814)
The 'align' modifier is now accepted in the 'allocate' clause. Added LIT
tests covering codegen, PCH, template handling, and serialization for
'align' modifier.

Added support for align-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
2025-01-13 05:44:48 -08:00
Ivan R. Ivanov
7c9404c279
[flang][OpenMP] Add frontend support for ompx_bare clause (#111106) 2024-12-13 21:44:43 +09:00
Kazu Hirata
834dfd2315
[Parse] Remove ParseDiagnostic.h (#116496)
This patch removes clang/Parse/ParseDiagnostic.h because it just
forwards to clang/Basic/DiagnosticParse.h.
2024-11-18 07:19:33 -08:00
David Pagan
e8c4842f0c
[clang][OpenMP][NFC] Move 'allocate' clause modifier parsing into fun… (#115775)
…ction

Parsing of 'allocate' clause modifier ('allocator') has been moved into
a separate function in anticipation of adding another modifier
('align').
2024-11-11 16:11:16 -08:00
David Pagan
435e58468a
[clang][OpenMP] Add 'allocator' modifier for 'allocate' clause. (#114883)
The 'allocator' modifier is now accepted in the 'allocate' clause. Added
LIT tests covering codegen, PCH, template handling, and serialization
for 'allocator' modifier.

Added support for allocator-modifier to release notes.

Testing
- New allocate modifier LIT tests.
- OpenMP LIT tests.
- check-all
- relevant sollve_vv test cases
tests/5.2/scope/test_scope_allocate_construct.c
2024-11-05 17:06:41 -08:00
Jay Foad
4dd55c567a
[clang] Use {} instead of std::nullopt to initialize empty ArrayRef (#109399)
Follow up to #109133.
2024-10-24 10:23:40 +01:00
Michael Kruse
5b03efb85d
[Clang][OpenMP] Add permutation clause (#92030)
Add the permutation clause for the interchange directive which will be
introduced in the upcoming OpenMP 6.0 specification. A preview has been
published in
[Technical Report12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-10-09 14:56:43 +02:00
Mike Rice
13fa78c86d
[OpenMP][NFC] Remove executable cases from declaration switch (#106438)
The executable directives are handled earlier.
2024-08-28 15:46:53 -07:00
Shilei Tian
1c269929d0
[Clang][Sema][OpenMP] Allow thread_limit to accept multiple expressions (#102715) 2024-08-10 09:54:58 -04:00
Shilei Tian
0c2ded6706 [NFC] Fix compile warning introduced in #99732 2024-08-06 12:45:29 -04:00
Shilei Tian
cee594cf36
[Clang][Sema][OpenMP] Allow num_teams to accept multiple expressions (#99732)
By the OpenMP standard, `num_teams` clause can only accept one
expression (for now). In this patch, we extend it to allow to accept
multiple expressions when it is used with `target teams ompx_bare`
construct. This will allow to launch a multi-dim grid, same as CUDA/HIP.
2024-08-06 10:55:15 -04:00
Haojian Wu
31bb759d78 Fix an unused variable and -Wswitch warning after a42e515e3a9f3bb4e44389c097b89104d95b9b29 2024-08-05 14:05:14 +02:00
Julian Brown
a42e515e3a
[OpenMP] OpenMP 5.1 "assume" directive parsing support (#92731)
This is a minimal patch to support parsing for "omp assume" directives.
These are meant to be hints to a compiler's optimisers: as such, it is
legitimate (if not very useful) to ignore them. The patch builds on top
of the existing support for "omp assumes" directives (note spelling!).

Unlike the "omp [begin/end] assumes" directives, "omp assume" is
associated with a compound statement, i.e. it can appear within a
function. The "holds" assumption could (theoretically) be mapped onto
the existing builtin "__builtin_assume", though the latter applies to a
single point in the program, and the former to a range (i.e. the whole
of the associated compound statement).

This patch fixes sollve's OpenMP 5.1 "omp assume"-based tests.
2024-08-05 07:37:07 -04:00
nicebert
8470a23c48
[OpenMP] Defaultmap: fixes scalar issue, adds all variable category (#99315)
Fixes issue with defaultmap where scalar isn't handled correctly for
present modifier. Adds all variable cateogry introduced in OpenMP 5.2
and alters existing tests for error messages to check OpenMP 5.2
defaultmap messages.
2024-07-25 14:30:14 -05:00
Michael Kruse
5c93a94f5a
[Clang][OpenMP] Add interchange directive (#93022)
Add the interchange directive which will be introduced in the upcoming
OpenMP 6.0 specification. A preview has been published in [Technical
Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).
2024-07-19 09:24:40 +02:00
Michael Kruse
80865c01e1
[Clang][OpenMP] Add reverse directive (#92916)
Add the reverse directive which will be introduced in the upcoming
OpenMP 6.0 specification. A preview has been published in [Technical
Report 12](https://www.openmp.org/wp-content/uploads/openmp-TR12.pdf).

---------

Co-authored-by: Alexey Bataev <a.bataev@outlook.com>
2024-07-18 10:35:32 +02:00
Krzysztof Parzyszek
0ce801f91c
[clang][OpenMP] Implement isOpenMPExecutableDirective (#97089)
What is considered "executable" in clang differs slightly from the
OpenMP's "executable" category. In addition to the executable category,
subsidiary directives, and OMPD_error are considered executable.

Implement a function that performs that check.
2024-06-29 09:37:32 -05:00
Krzysztof Parzyszek
e24a21291a
[clang][OpenMP] Shorten directive classification in ParseOpenMP (#94691)
Use directive categories to simplify long lists of `case` statements in
the OpenMP parser. This is a step towards avoiding dependence on
explicitly specified sets of directives that can be expressed more
generically.
The upcoming OpenMP 6.0 will introduce many new combined directives, and
the more generically we handle directives, the easier the introduction
of the new standard will be.

---------

Co-authored-by: Alexey Bataev <a.bataev@outlook.com>
2024-06-26 08:11:09 -05:00
Mike Rice
5413a2bb84
[clang][OpenMP] Fix error handling of the adjust_args clause (#94696)
Static verifier noticed the current code has logically dead code parsing
the clause where IsComma is assigned. Fix this and improve the error
message received when a bad adjust-op is specified.

This will now be handled like 'map' where a nice diagnostic is given
with the correct values, then parsing continues on the next clause
reducing unhelpful diagnostics.
2024-06-24 13:37:49 -07:00
Krzysztof Parzyszek
ce7b670912
[clang][OpenMP] Simplify check for repeated clauses (#93611)
The `FirstClauses` is a vector of pointer-bool pairs, and the pointer
part of the pair is never used. Replace the vector with std::bitset, and
rename it to `SeenClauses` to make the purpose of it a bit clearer.
2024-05-30 14:49:13 -05:00
Vlad Serebrennikov
ed35a92c40
[clang] Introduce target-specific Sema components (#93179)
This patch introduces `SemaAMDGPU`, `SemaARM`, `SemaBPF`, `SemaHexagon`,
`SemaLoongArch`, `SemaMIPS`, `SemaNVPTX`, `SemaPPC`, `SemaSystemZ`,
`SemaWasm`. This continues previous efforts to split Sema up. Additional
context can be found in #84184 and #92682.

I decided to bundle target-specific components together because of their
low impact on `Sema`. That said, their impact on `SemaChecking.cpp` is
far from low, and I consider it a success.

Somewhat accidentally, I also moved Wasm- and AMDGPU-specific function
from `SemaDeclAttr.cpp`, because they were exposed in `Sema`. That went
well, and I consider it a success, too. I'd like to move the rest of
static target-specific functions out of `SemaDeclAttr.cpp` like we're
doing with built-ins in `SemaChecking.cpp` .
2024-05-30 19:59:59 +04:00
Krzysztof Parzyszek
9377412c5a [clang][OpenMP] Remove unused include of UniqueVector.h, NFC 2024-05-29 08:31:27 -05:00
Vlad Serebrennikov
874f511ae7
[clang] Introduce SemaCodeCompletion (#92311)
This patch continues previous efforts to split `Sema` up, this time
covering code completion.
Context can be found in #84184.
Dropping `Code` prefix from function names in `SemaCodeCompletion` would
make sense, but I think this PR has enough changes already.
As usual, formatting changes are done as a separate commit. Hopefully
this helps with the review.
2024-05-17 20:55:37 +04:00
jyu2-git
3acc691910
Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (#91821)
… (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.
2024-05-13 07:39:23 -07:00
Michael Kruse
b0b6c16b47
[Clang][OpenMP][Tile] Allow non-constant tile sizes. (#91345)
Allow non-constants in the `sizes` clause such as
```
#pragma omp tile sizes(a)
for (int i = 0; i < n; ++i)
```
This is permitted since tile was introduced in [OpenMP
5.1](https://www.openmp.org/spec-html/5.1/openmpsu53.html#x78-860002.11.9).

It is possible to sneak-in negative numbers at runtime as in
```
int a = -1;
#pragma omp tile sizes(a)
```
Even though it is not well-formed, it should still result in every loop
iteration to be executed exactly once, an invariant of the tile
construct that we should ensure. `ParseOpenMPExprListClause` is
extracted-out to be reused by the `permutation` clause of the
`interchange` construct. Some care was put into ensuring correct behavior
in template contexts.
2024-05-13 16:10:58 +02:00
Kazu Hirata
deffae5da1
[clang] Use StringRef::operator== instead of StringRef::equals (NFC) (#91844)
I'm planning to remove StringRef::equals in favor of
StringRef::operator==.

- StringRef::operator==/!= outnumber StringRef::equals by a factor of
  24 under clang/ in terms of their usage.

- The elimination of StringRef::equals brings StringRef closer to
  std::string_view, which has operator== but not equals.

- S == "foo" is more readable than S.equals("foo"), especially for
  !Long.Expression.equals("str") vs Long.Expression != "str".
2024-05-11 11:38:52 -07:00
Weaver
341aecc2dd Revert "Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (#91141)"
This reverts commit a99ce615f19fec6fbb835490b89f53cba3cf9eff.

Caused test failure on following buildbot:
https://lab.llvm.org/buildbot/#/builders/139/builds/65066
2024-05-08 11:12:14 +01:00
jyu2-git
a99ce615f1
Revert "Revert "[OpenMP][TR12] change property of map-type modifier."… (#91141)
… (#90885)"

This reverts commit eea81aa29848361eb5b24f24d2af643fdeb9adfd.

Also change isMapType as @vitalybuka suggested. Hope this fix sanitizer
build problem.
2024-05-07 23:11:07 -07:00
jyu2-git
b62c45cfe5
Fix sanitize problem. (#90800)
Currently isMapType could return OpenMPMapModifierKind.

The change is to return OpenMPMapTypeKind only, if it is not MapType
Kind OMPC_MAP_unknown is returned.
2024-05-02 20:54:20 -07:00
Vitaly Buka
eea81aa298
Revert "[OpenMP][TR12] change property of map-type modifier." (#90885)
Breaks
https://lab.llvm.org/buildbot/#/builders/5/builds/43086/steps/9/logs/stdio

Reverts llvm/llvm-project#90499
2024-05-02 12:58:23 -07:00
jyu2-git
f050660f4a
[OpenMP][TR12] change property of map-type modifier. (#90499)
map-type change to "default" instead "ultimate" from [OpenMP5.2]

The change is allowed map-type to be placed any locations within map
modifiers, besides the last location in the modifiers-list, also
map-type can be omitted afterward.
2024-05-01 07:34:10 -07:00
Vlad Serebrennikov
f69ded0d99
[clang] Introduce SemaOpenMP (#88642)
This patch moves OpenMP-related entities out of `Sema` to a newly
created `SemaOpenMP` class. This is a part of the effort to split `Sema`
up, and follows the recent example of CUDA, OpenACC, SYCL, HLSL.
Additional context can be found in
https://github.com/llvm/llvm-project/pull/82217,
https://github.com/llvm/llvm-project/pull/84184,
https://github.com/llvm/llvm-project/pull/87634.
2024-04-16 16:36:53 +04:00
Sandeep Kosuri
6d3bb85471
[OpenMP] Parse and Sema support for declare target in local scope (#83223)
- adds Parse and Sema support for the `declare target` directive inside
a function scope.
2024-03-06 19:46:23 +05:30
SunilKuravinakop
a74e9ce5dc
[OpenMP] atomic compare weak : Parser & AST support (#79475)
This is a support for " #pragma omp atomic compare weak". It has Parser
& AST support for now.

---------

Authored-by: Sunil Kuravinakop <kuravina@pe28vega.us.cray.com>
2024-01-31 06:32:06 -05:00
Sandeep Kosuri
ecc080c07d
[OpenMP] return empty stmt for nothing (#74042)
- `nothing` directive was effecting the `if` block structure which it
should not. So return an empty statement instead of an error statement
while parsing to avoid this.
2023-12-03 13:33:38 +05:30
Sandeep Kosuri
6e0101684e
[OpenMP] Support for nothing in metadirective (#73690)
- Removed an unnecessary check that was preventing `nothing` to work
properly inside `metadirective`.
2023-11-29 15:13:43 +05:30
Sunil Kuravinakop
d033f51a0a [OpenMP] atomic compare fail : Parser & AST support
Diff Revision: https://reviews.llvm.org/D123235
2023-11-26 13:34:34 -06:00
Shraiysh
8840eb3fb5
[flang][OpenMP] Add semantic check for declare target (#72770) 2023-11-22 16:13:14 -06:00
Krzysztof Parzyszek
ddfed815c9 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit edd675ac283909397880f85ba68d0d5f99dc1be2.

This breaks clang build where every component is a shared library.

The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of
libclangBasic.so, uses `getOpenMPClauseName` which isn't:

/usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio
n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int
)':
OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o
mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam
e(llvm::omp::Clause)'
2023-11-20 10:48:06 -06:00
Aaron Ballman
8bd06d5b65
[C23] Complete support for WG14 N2508 (#71398)
In Clang 16, we implemented the ability to add a label at the end of a
compound statement. These changes complete the implementation by
allowing a label to be followed by a declaration in C.

Note, this seems to have fixed an issue with some OpenMP stand-alone
directives not being properly diagnosed as per:
https://www.openmp.org/spec-html/5.1/openmpsu19.html#x34-330002.1.3
(The same requirement exists in OpenMP 5.2 as well.)
2023-11-20 10:52:11 -05:00
Sunil Kuravinakop
edd675ac28 [OpenMP] atomic compare fail : Parser & AST support
Diff Revision: https://reviews.llvm.org/D123235
2023-11-20 03:05:31 -06:00
Mitch Phillips
a141a9fa97 Revert "[OpenMP] atomic compare fail : Parser & AST support"
This reverts commit 086b65340cca2648a2a91a0a47d28c7d9bafd1e5.

Reason: Broke under -Werror. More details in
https://reviews.llvm.org/D123235
2023-11-08 11:20:17 +01:00