[flang-commits] [flang] [llvm] [flang][openmp] Adds Parser and Semantic Support for Interop Construct, and Init and Use Clauses. (PR #120584)
via flang-commits
flang-commits at lists.llvm.org
Wed Dec 25 20:52:06 PST 2024
swatheesh-mcw wrote:
> Please follow the common method for implementing modifiers, for example as in #117786.
>
> 1. The two modifiers should be prefixed with Omp, i.e. `OmpInteropPreference` and `OmpInteropType`. Please put them in the "modifiers" namespace in parse-tree.h (all classes are ordered alphabetically). When a modifier is a wrapper for ENUM_CLASS, the name of the enum should be `Value`, e.g. `ENUM_CLASS(Value, Something, SomethingElse)`.
>
> 2. In `OmpInitClause`, please add a line `MODIFIER_BOILERPLATE(OmpInteropPreference, OmpInteropType);`, and delete the WRAPPER_CLASS definitions. Please do not create nested wrapper classes for individual objects, i.e. delete the InteropVar. The tuple in the class should then be `std::tuple<MODIFIERS(), OmpObject>`. These macros will define a nested type "Modifier" in the class which is a variant with the two given members. The tuple will contain an "optional<list>" in place of the MODIFIERS macro.
>
> 3. In openmp-parsers.cpp there is a section with parsers for the individual modifiers, in your case, OmpInteropPreference and OmpInteropType. Please add the parsers there. Then, in the section below, where all the "OmpXyzClause::Modifier" are parsed, please add a parser for OmpInitClause::Modifier (it's just an alternative parser for the two modifiers). Then the parser for the OmpInitClause itself would just be `maybe(nonemptyList(Parser<OmpInitClause::Modifier>{}) / ":"), Parser<OmpObject>{}`.
>
> 4. In openmp-modifiers.h please add the two new modifiers to the DECLARE_DESCRIPTOR list (in alphabetical order). In openmp-modifiers.cpp, please add descriptors for these modifiers (also in alphabetical order). The definitions of the descriptors should be pretty clear based on the other definitions. The "name" refers to the name in the spec, i.e. "interop-preference" and "interop-type". The properties for the modifiers are "OmpUnique" for "interop-preference" and "OmpRequired" for the other one.
>
> 5. In check-omp-structure.cpp please call `OmpVerifyModifiers`. To get the optional list of modifiers use `OmpGetModifiers`, and to get a unique modifier, use `OmpGetUniqueModifier`. To iterate over repeatable modifiers use `OmpGetRepeatableModifier`. You can find examples of their use in that source file.
Hi @kparzysz, I tried making the `OmpInteropPreference` and `OmpInteropType` as individual modifiers in `openmp-parsers.cpp`and when tried adding alternative parser for these two modifiers as `OmpInitClause::Modifier`, I am facing the following issues:
1. Since the modifiers are comma separated, adding the parser support in `OmpInitClause::Modifier` as mentioned below results in tuple argument mismatch error.
`TYPE_PARSER(sourced(construct<OmpInitClause::Modifier>(sourced(
construct<OmpInitClause::Modifier>(maybe(
verbatim("PREFER_TYPE"_tok) >>
parenthesized(nonemptyList(Parser<OmpInteropPreference>{})) / ",")),
construct<OmpInitClause::Modifier>(nonemptyList(Parser<OmpInteropType>{}))))))`
2. If I use `OR (||)` operator instead of `COMMA (,)` to separate the modifiers, then it doesn't throw any error but the parser is not parsing the init clause properly.
3. I could see in `openmp-parsers.cpp` file, all the other clause modifiers are separated with `OR (||)` operator. I could see a sample of `MobClause` in which it supports parser for comma-separated individual modifiers but it takes object list as the other argument whereas we have just a single object for our `OmpInitClause`.
Can you suggest or direct me through an example where I can refer to create parser support for `OmpInitClause::Modifier`?
Thanks in advance!
https://github.com/llvm/llvm-project/pull/120584
More information about the flang-commits
mailing list