[all-commits] [llvm/llvm-project] ea2cfc: [flang][OpenMP] Implement flexible OpenMP clause r...

Krzysztof Parzyszek via All-commits all-commits at lists.llvm.org
Thu Mar 14 08:26:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb
      https://github.com/llvm/llvm-project/commit/ea2cfcc15b4a0c5e823ed173ac8701d1ba6081eb
  Author: Krzysztof Parzyszek <Krzysztof.Parzyszek at amd.com>
  Date:   2024-03-14 (Thu, 14 Mar 2024)

  Changed paths:
    M flang/lib/Lower/CMakeLists.txt
    A flang/lib/Lower/OpenMP/ClauseT.h
    A flang/lib/Lower/OpenMP/Clauses.cpp
    A flang/lib/Lower/OpenMP/Clauses.h

  Log Message:
  -----------
  [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]



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list