summaryrefslogtreecommitdiff
path: root/llvm/lib/Frontend/OpenMP/OMPContext.cpp
AgeCommit message (Collapse)Author
2025-05-09[OpenMP] implementation set controls elision for begin declare variant (#139287)Johannes Doerfert
The device and implementation set should trigger elision of tokens if they do not match statically in a begin/end declare variant. This simply extends the logic from the device set only and includes the implementation set. Reported by @kkwli.
2025-02-12[OpenMP][OpenMPIRBuilder] Support SPIR-V device variant matches (#126801)Nick Sarnie
We should be able to use `spirv64` as a device variant match and it should be considered a GPU. Also add the triple to an RTTI check. Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
2025-02-09This commit fixes the build failure due to OMP_TRAIT_PROPERTY macro r… ↵Ritanya-B-Bharadwaj
(#126222) …edefinition - https://github.com/llvm/llvm-project/issues/126043
2025-02-05[OpenMP] Fix multiply defined macro warningJoseph Huber
2025-02-05[OpenMP]Initial parsing/sema support for target_device selector set (#118471)Ritanya-B-Bharadwaj
This patch adds initial support for target_device selector set - Section 9.2 (Spec 6.0)
2024-12-17[Offload] Add support for loongarch64 to host pluginwanglei
This adds support for the loongarch64 architecture to the offload host plugin. Similar to #115773 To fix some test issues, I've had to add the LoongArch64 target to: - CompilerInvocation::ParseLangArgs - linkDevice in ClangLinuxWrapper.cpp - OMPContext::OMPContext (to set the device_kind_cpu trait) Reviewed By: jhuber6 Pull Request: https://github.com/llvm/llvm-project/pull/120173
2024-05-16[llvm] Drop explicit conversions of string literals to StringRef (NFC)Kazu Hirata
We routinely rely on implicit conversions of string literals to StringRef so that we can use operator==(StringRef, StringRef).
2024-03-15Reapply [libomptarget] Build plugins-nextgen for SystemZ (#83978)Ulrich Weigand
The plugin was not getting built as the build_generic_elf64 macro assumes the LLVM triple processor name matches the CMake processor name, which is unfortunately not the case for SystemZ. Fix this by providing two separate arguments instead. Actually building the plugin exposed a number of other issues causing various test failures. Specifically, I've had to add the SystemZ target to - CompilerInvocation::ParseLangArgs - linkDevice in ClangLinuxWrapper.cpp - OMPContext::OMPContext (to set the device_kind_cpu trait) - LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt - a check_plugin_target call in libomptarget/src/CMakeLists.txt Finally, I've had to set a number of test cases to UNSUPPORTED on s390x-ibm-linux-gnu; all these tests were already marked as UNSUPPORTED for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu and are failing on s390x for what seem to be the same reason. In addition, this also requires support for BE ELF files in plugins-nextgen: https://github.com/llvm/llvm-project/pull/85246
2024-03-06Revert "[libomptarget] Build plugins-nextgen for SystemZ (#83978)"Ulrich Weigand
This reverts commit 3ecd38c8e1d34b1e4639a1de9f0cb56c7957cbd2.
2024-03-06[libomptarget] Build plugins-nextgen for SystemZ (#83978)Ulrich Weigand
The plugin was not getting built as the build_generic_elf64 macro assumes the LLVM triple processor name matches the CMake processor name, which is unfortunately not the case for SystemZ. Fix this by providing two separate arguments instead. Actually building the plugin exposed a number of other issues causing various test failures. Specifically, I've had to add the SystemZ target to - CompilerInvocation::ParseLangArgs - linkDevice in ClangLinuxWrapper.cpp - OMPContext::OMPContext (to set the device_kind_cpu trait) - LIBOMPTARGET_ALL_TARGETS in libomptarget/CMakeLists.txt - a check_plugin_target call in libomptarget/src/CMakeLists.txt Finally, I've had to set a number of test cases to UNSUPPORTED on s390x-ibm-linux-gnu; all these tests were already marked as UNSUPPORTED for x86_64-pc-linux-gnu and aarch64-unknown-linux-gnu and are failing on s390x for what seem to be the same reason. In addition, this also requires support for BE ELF files in plugins-nextgen: https://github.com/llvm/llvm-project/pull/83976
2023-02-07[NFC][TargetParser] Remove llvm/ADT/Triple.hArchibald Elliott
I also ran `git clang-format` to get the headers in the right order for the new location, which has changed the order of other headers in two files.
2022-12-20[llvm] Use std::optional instead of OptionalKazu Hirata
This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-17[llvm] llvm::Optional::value => operator*/operator->Fangrui Song
std::optional::value() has undesired exception checking semantics and is unavailable in some older Xcode. The call sites block std::optional migration.
2022-12-02[llvm] Use std::nullopt instead of None (NFC)Kazu Hirata
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-07-13[llvm] Use value instead of getValue (NFC)Kazu Hirata
2022-06-25[llvm] Don't use Optional::hasValue (NFC)Kazu Hirata
This patch replaces Optional::hasValue with the implicit cast to bool in conditionals only.
2022-06-25Revert "Don't use Optional::hasValue (NFC)"Kazu Hirata
This reverts commit aa8feeefd3ac6c78ee8f67bf033976fc7d68bc6d.
2022-06-25Don't use Optional::hasValue (NFC)Kazu Hirata
2022-03-12Cleanup includes: DebugInfo & CodeGenserge-sans-paille
Discourse thread: https://discourse.llvm.org/t/include-what-you-use-include-cleanup Differential Revision: https://reviews.llvm.org/D121332
2021-03-11Revert "[OpenMP] Do not propagate match extensions to nested contexts"Johannes Doerfert
Two tests failed for some reason, need to investigate: https://lab.llvm.org/buildbot/#/builders/109/builds/10399 This reverts commit ad9e98b8efa0138559eb640023695dab54967a8d.
2021-03-11[OpenMP] Do not propagate match extensions to nested contextsJohannes Doerfert
If we have nested declare variant context, it doesn't make sense to inherit the match extension from the parent. Instead, just skip it. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D95764
2021-01-07[OpenMP][FIX] Avoid string literal comparison, use `StringRef::equal`Johannes Doerfert
2021-01-07[OpenMP][Fix] Make the arch selector for x86_64 workJohannes Doerfert
The triple uses a bar "x86-64" instead of an underscore. Since we have troubles accepting x86-64 as an identifier, we stick with x86_64 in the frontend and translate it explicitly. Reviewed By: tianshilei1992 Differential Revision: https://reviews.llvm.org/D93786
2021-01-02[PowerPC] Enable OpenMP for powerpcle target. [5/5]Brandon Bergren
Enable OpenMP for powerpcle to match the rest of powerpc*. Update tests. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D92445
2020-07-29[OpenMP] Allow traits for the OpenMP context selector `isa`Johannes Doerfert
It was unclear what `isa` was supposed to mean so we did not provide any traits for this context selector. With this patch we will allow *any* string or identifier. We use the target attribute and target info to determine if the trait matches. In other words, we will check if the provided value is a target feature that is available (at the call site). Fixes PR46338 Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D83281
2020-04-14[ADT/STLExtras.h] - Add llvm::is_sorted wrapper and update callers.Georgii Rymar
It can be used to avoid passing the begin and end of a range. This makes the code shorter and it is consistent with another wrappers we already have. Differential revision: https://reviews.llvm.org/D78016
2020-04-07[OpenMP] Add match_{all,any,none} declare variant selector extensions.Johannes Doerfert
By default, all traits in the OpenMP context selector have to match for it to be acceptable. Though, we sometimes want a single property out of multiple to match (=any) or no match at all (=none). We offer these choices as extensions via `implementation={extension(match_{all,any,none})}` to the user. The choice will affect the entire context selector not only the traits following the match property. The first user will be D75788. There we can replace ``` #pragma omp begin declare variant match(device={arch(nvptx64)}) #define __CUDA__ #include <__clang_cuda_cmath.h> // TODO: Hack until we support an extension to the match clause that allows "or". #undef __CLANG_CUDA_CMATH_H__ #undef __CUDA__ #pragma omp end declare variant #pragma omp begin declare variant match(device={arch(nvptx)}) #define __CUDA__ #include <__clang_cuda_cmath.h> #undef __CUDA__ #pragma omp end declare variant ``` with the much simpler ``` #pragma omp begin declare variant match(device={arch(nvptx, nvptx64)}, implementation={extension(match_any)}) #define __CUDA__ #include <__clang_cuda_cmath.h> #undef __CUDA__ #pragma omp end declare variant ``` Reviewed By: mikerice Differential Revision: https://reviews.llvm.org/D77414
2020-03-29[OpenMP] set_bits iterator yields unsigned elements, no reference (NFC).Florian Hahn
BitVector::set_bits() returns an iterator range yielding unsinged elements, which always will be copied while const & gives the impression that there will be no copy. Newer version of clang complain: warning: loop variable 'SetBitsIt' is always a copy because the range of type 'iterator_range<llvm::BitVector::const_set_bits_iterator>' (aka 'iterator_range<const_set_bits_iterator_impl<llvm::BitVector> >') does not return a reference [-Wrange-loop-analysis] Reviewers: jdoerfert, rnk Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D77010
2020-03-27[OpenMP] `omp begin/end declare variant` - part 1, parsingJohannes Doerfert
This is the first part extracted from D71179 and cleaned up. This patch provides parsing support for `omp begin/end declare variant`, as defined in OpenMP technical report 8 (TR8) [0]. A major purpose of this patch is to provide proper math.h/cmath support for OpenMP target offloading. See PR42061, PR42798, PR42799. The current code was developed with this feature in mind, see [1]. [0] https://www.openmp.org/wp-content/uploads/openmp-TR8.pdf [1] https://reviews.llvm.org/D61399#change-496lQkg0mhRN Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D74941
2020-03-23[OpenMP][NFC] Reduce instantiation time with different data structureJohannes Doerfert
See rational here: https://reviews.llvm.org/D71847#1922648 Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D76170
2020-02-15[NFC] Revert unnecessary parts of b91c267380Johannes Doerfert
In b91c267380 I accidentally introduced fixes that were not necessary after 1a93285c686a. All but the `llvm_unreachable` are reverted again.
2020-02-15[FIX] Remove warnings and UB after 1228d42ddab8Johannes Doerfert
2020-02-14Fix -Wstring-compare warnings in new OpenMP codeReid Kleckner
2020-02-14[OpenMP][Part 2] Use reusable OpenMP context/traits handlingJohannes Doerfert
This patch implements an almost complete handling of OpenMP contexts/traits such that we can reuse most of the logic in Flang through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP. All but construct SIMD specifiers, e.g., inbranch, and the device ISA selector are define in `llvm/lib/Frontend/OpenMP/OMPKinds.def`. From these definitions we generate the enum classes `TraitSet`, `TraitSelector`, and `TraitProperty` as well as conversion and helper functions in `llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}`. The above enum classes are used in the parser, sema, and the AST attribute. The latter is not a collection of multiple primitive variant arguments that contain encodings via numbers and strings but instead a tree that mirrors the `match` clause (see `struct OpenMPTraitInfo`). The changes to the parser make it more forgiving when wrong syntax is read and they also resulted in more specialized diagnostics. The tests are updated and the core issues are detected as before. Here and elsewhere this patch tries to be generic, thus we do not distinguish what selector set, selector, or property is parsed except if they do behave exceptionally, as for example `user={condition(EXPR)}` does. The sema logic changed in two ways: First, the OMPDeclareVariantAttr representation changed, as mentioned above, and the sema was adjusted to work with the new `OpenMPTraitInfo`. Second, the matching and scoring logic moved into `OMPContext.{h,cpp}`. It is implemented on a flat representation of the `match` clause that is not tied to clang. `OpenMPTraitInfo` provides a method to generate this flat structure (see `struct VariantMatchInfo`) by computing integer score values and boolean user conditions from the `clang::Expr` we keep for them. The OpenMP context is now an explicit object (see `struct OMPContext`). This is in anticipation of construct traits that need to be tracked. The OpenMP context, as well as the `VariantMatchInfo`, are basically made up of a set of active or respectively required traits, e.g., 'host', and an ordered container of constructs which allows duplication. Matching and scoring is kept as generic as possible to allow easy extension in the future. --- Test changes: The messages checked in `OpenMP/declare_variant_messages.{c,cpp}` have been auto generated to match the new warnings and notes of the parser. The "subset" checks were reversed causing the wrong version to be picked. The tests have been adjusted to correct this. We do not print scores if the user did not provide one. We print spaces to make lists in the `match` clause more legible. Reviewers: kiranchandramohan, ABataev, RaviNarayanaswamy, gtbercea, grokos, sdmitriev, JonChesterfield, hfinkel, fghanim Subscribers: merge_guards_bot, rampitec, mgorny, hiraditya, aheejin, fedor.sergeev, simoncook, bollu, guansong, dexonsmith, jfb, s.egerton, llvm-commits, cfe-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D71830
2020-02-03Fix MSVC "result of 32-bit shift implicitly converted to 64 bits" warning. NFCI.Simon Pilgrim
2020-02-03Fixed a -Wunused-variable warning in no-assertion buildsDmitri Gribenko
2020-02-03[OpenMP] Fix GCC warnings. NFC.Martin Storsjö
Remove an extra semicolon, and add llvm_unreachable to avoid warnings about control reaching the end of a non-void function.
2020-02-02[OpenMP][Part 1] Reusable OpenMP context/traits handlingJohannes Doerfert
This is the first of multiple parts to make OpenMP context/trait handling reusable and generic. This patch was originally part of D71830 but with the unit tests it can be tested independently. This patch implements an almost complete handling of OpenMP contexts/traits such that we can reuse most of the logic in Flang through the OMPContext.{h,cpp} in llvm/Frontend/OpenMP. All but construct SIMD specifiers, e.g., inbranch, and the device ISA selector are define in llvm/lib/Frontend/OpenMP/OMPKinds.def. From these definitions we generate the enum classes TraitSet, TraitSelector, and TraitProperty as well as conversion and helper functions in llvm/lib/Frontend/OpenMP/OMPContext.{h,cpp}. The OpenMP context is now an explicit object (see `struct OMPContext`). This is in anticipation of construct traits that need to be tracked. The OpenMP context, as well as the VariantMatchInfo, are basically made up of a set of active or respectively required traits, e.g., 'host', and an ordered container of constructs which allows duplication. Matching and scoring is kept as generic as possible to allow easy extension in the future. Reviewed By: JonChesterfield Differential Revision: https://reviews.llvm.org/D71847