diff options
author | Krzysztof Parzyszek <Krzysztof.Parzyszek@amd.com> | 2024-03-14 10:26:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-14 10:26:03 -0500 |
commit | ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb (patch) | |
tree | 7e4f2994c115f4836f0cd67b728a6e1fc4c9f7fc /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 68360dc85507350c9d38bcc6916debe29fd58fee (diff) | |
download | llvm-ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb.zip llvm-ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb.tar.gz llvm-ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb.tar.bz2 |
[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]
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions