llvm-project/clang/lib
Johannes Doerfert 1228d42dda [OpenMP][Part 2] Use reusable OpenMP context/traits handling
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-14 16:37:42 -06:00
..
ARCMigrate [ARCMT][NFC] Reduce #include dependencies 2020-02-12 19:10:46 +01:00
AST [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
ASTMatchers Remove clang::ast_type_traits namespace in favor of clang 2020-02-13 10:46:47 -08:00
Analysis [clang][Analysis] CallGraph: store the actual call `Expr*` in the CallGraphNode::CallRecord 2020-02-13 23:37:53 +03:00
Basic [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
CodeGen [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
CrossTU [clang] Replace SmallStr.str().str() with std::string conversion operator. 2020-01-29 21:27:46 -08:00
DirectoryWatcher Add missing newlines at EOF; NFC 2020-02-12 15:57:25 +00:00
Driver [Driver] Rename AddGoldPlugin to addLTOOptions. NFC 2020-02-14 08:06:37 -08:00
Edit [C++2a] Add __builtin_bit_cast, used to implement std::bit_cast 2019-07-02 18:28:13 +00:00
Format [clang-format] Add new option BeforeLambdaBody in Allman style. 2020-02-13 22:16:41 +01:00
Frontend Revert "[DebugInfo] Enable the debug entry values feature by default" 2020-02-12 11:59:04 +01:00
FrontendTool Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
Headers [Mips] Add intrinsics for 4-byte and 8-byte MSA loads/stores. 2020-02-11 11:47:30 +01:00
Index [clang][Index] Introduce a TemplateParm SymbolKind 2020-02-14 13:20:34 +01:00
Lex Prefer __vector over vector keyword for altivec 2020-02-10 20:23:26 +01:00
Parse [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
Rewrite [Rewrite][NFC] Add FIXMEs and tests for RemoveLineIfEmpty bug 2019-08-15 21:17:48 +00:00
Sema [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
Serialization [OpenMP][Part 2] Use reusable OpenMP context/traits handling 2020-02-14 16:37:42 -06:00
StaticAnalyzer [analyzer] StdLibraryFunctionsChecker: Use platform dependent EOF and UCharMax 2020-02-13 13:51:51 +01:00
Tooling [Support] On Windows, ensure hardware_concurrency() extends to all CPU sockets and all NUMA groups 2020-02-14 10:24:22 -05:00
CMakeLists.txt Reland [clang] DirectoryWatcher 2019-07-12 20:34:10 +00:00