Skip to content

Commit ea2cfcc

Browse files
authored
[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]
1 parent 68360dc commit ea2cfcc

File tree

4 files changed

+1652
-0
lines changed

4 files changed

+1652
-0
lines changed

flang/lib/Lower/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ add_flang_library(FortranLower
2525
Mangler.cpp
2626
OpenACC.cpp
2727
OpenMP/ClauseProcessor.cpp
28+
OpenMP/Clauses.cpp
2829
OpenMP/DataSharingProcessor.cpp
2930
OpenMP/OpenMP.cpp
3031
OpenMP/ReductionProcessor.cpp

0 commit comments

Comments
 (0)