7 Commits

Author SHA1 Message Date
Krzysztof Parzyszek
e8e80d07c8
[OpenMP] Apply post-commit review comments in PR86289, NFC (#86828)
Fix include guard name, fix typo, add comments with OpenMP spec
sections.
2024-03-28 07:52:47 -05:00
Krzysztof Parzyszek
4d177435ba
[flang][OpenMP] Rename makeList overloads to make{Objects,Clauses}, NFC (#86725)
Reserve `makeList` to create a list given an explicit converter
function.
2024-03-27 11:37:09 -05:00
Krzysztof Parzyszek
148a55795d
[flang][OpenMP] Make OpenMP clause representation language-agnostic (#86289)
The clause templates defined in ClauseT.h were originally based on
flang's parse tree nodes. Since those representations are going to be
reused for clang (together with the clause splitting code), it makes
sense to separate them from flang, and instead have them based on the
actual OpenMP spec (v5.2).

The member names in the templates follow the naming presented in the
spec, and the representation (e.g. members) is derived from the clause
definitions as described in the spec.

Since the representations of some clauses has changed (while preserving
the information), the current code using the clauses (especially the
code converting parser::OmpClause to omp::Clause) needs to be adjusted.

This patch does not make any functional changes.
2024-03-26 13:54:26 -05:00
Krzysztof Parzyszek
63e70c0553
[flang][OpenMP] Convert repeatable clauses (except Map) in ClauseProc… (#81623)
…essor

Rename `findRepeatableClause` to `findRepeatableClause2`, and make the
new `findRepeatableClause` operate on new `omp::Clause` objects.

Leave `Map` unchanged, because it will require more changes for it to
work.

[Clause representation 3/6]
2024-03-15 07:04:42 -05:00
Krzysztof Parzyszek
f9e557961e
[flang][OpenMP] Convert unique clauses in ClauseProcessor (#81622)
Temporarily rename old clause list to `clauses2`, old clause iterator to
`ClauseIterator2`.
Change `findUniqueClause` to iterate over `omp::Clause` objects, modify
all handlers to operate on 'omp::clause::xyz` equivalents.

[Clause representation 2/6]
2024-03-14 17:24:40 -05:00
Krzysztof Parzyszek
5a77bdc3e7 Fix NDEBUG build: guard call to dump with #if/#endif 2024-03-14 11:47:50 -05:00
Krzysztof Parzyszek
ea2cfcc15b
[flang][OpenMP] Implement flexible OpenMP clause representation (#81621)
The new set of classes representing OpenMP classes mimics the contents
of parser::OmpClause, but differs in a few aspects:
- it can be easily created, copied, etc.
- is based on semantics::SomeExpr instead of parser objects.

This set of classes is geared towards a language-agnostic representation
of OpenMP clauses. While the class members are still based on flang's
`parser::OmpClause`, the classes themselves are actually C++ templates
parameterized with types essential to represent necessary information.
The two parameters are
- `IdType`: the type that can represent object's identity (for flang it
will be `semantics::Symbol *`),
- `ExprType`: the type that can represent expressions, arithmetic and
object references (`semantics::MaybeExpr` in flang).

The templates are defined in a namespace `tomp` (to distinguish it from
`omp`).

This patch introduces file "Clauses.cpp", which contains instantiations
of all of the templates for flang. The instantiations are members of
namespace `omp`, and include an all-encompassing variant class
`omp::Clause`, which is the analog of `parser::OmpClause`.
The class `OmpObject` is represented by `omp::Object`, which contains
the symbol associated with the object, and `semantics::MaybeExpr`
representing the designator for the symbol reference. For each specific
clause in the variant `parser::OmpClause`, there exists a `make`
function that will generate the corresponding `omp::Clause` from it. The
intent was to use the make functions as variant visitors. The creation
of a clause instance would then follow the pattern:
```
omp::Clause clause = std::visit([](auto &&s) { return make(s, semaCtx); }, parserClause.u);
```

If a new clause `foo` is added in the future, then:
- a new template `tomp::FooT` representing the clause needs to be added
to ClauseT.h,
- a new instance needs to be created in flang, this can be as simple as
`using Foo = tomp::FooT<...>`,
- a new make function needs to be implemented to create object of class
Foo from `parser::OmpClause::Foo`.

This patch only introduces the new classes, they are not yet used
anywhere.

[Clause representation 1/6]
2024-03-14 10:26:03 -05:00