xref: /llvm-project/flang/lib/Parser/openmp-parsers.cpp (revision 15ab7be2e049bc0f4ea6744ca037395686a923bc)
164ab3302SCarolineConcatto //===-- lib/Parser/openmp-parsers.cpp -------------------------------------===//
264ab3302SCarolineConcatto //
364ab3302SCarolineConcatto // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
464ab3302SCarolineConcatto // See https://llvm.org/LICENSE.txt for license information.
564ab3302SCarolineConcatto // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
664ab3302SCarolineConcatto //
764ab3302SCarolineConcatto //===----------------------------------------------------------------------===//
864ab3302SCarolineConcatto 
964ab3302SCarolineConcatto // Top-level grammar specification for OpenMP.
1064ab3302SCarolineConcatto // See OpenMP-4.5-grammar.txt for documentation.
1164ab3302SCarolineConcatto 
1264ab3302SCarolineConcatto #include "basic-parsers.h"
1364ab3302SCarolineConcatto #include "expr-parsers.h"
1464ab3302SCarolineConcatto #include "misc-parsers.h"
1564ab3302SCarolineConcatto #include "stmt-parser.h"
1664ab3302SCarolineConcatto #include "token-parsers.h"
1764ab3302SCarolineConcatto #include "type-parser-implementation.h"
1864ab3302SCarolineConcatto #include "flang/Parser/parse-tree.h"
1933faa828SKrzysztof Parzyszek #include "llvm/ADT/ArrayRef.h"
2033faa828SKrzysztof Parzyszek #include "llvm/ADT/STLExtras.h"
2133faa828SKrzysztof Parzyszek #include "llvm/ADT/StringRef.h"
2233faa828SKrzysztof Parzyszek #include "llvm/Frontend/OpenMP/OMP.h"
2364ab3302SCarolineConcatto 
2464ab3302SCarolineConcatto // OpenMP Directives and Clauses
2564ab3302SCarolineConcatto namespace Fortran::parser {
2664ab3302SCarolineConcatto 
2764ab3302SCarolineConcatto constexpr auto startOmpLine = skipStuffBeforeStatement >> "!$OMP "_sptok;
2864ab3302SCarolineConcatto constexpr auto endOmpLine = space >> endOfLine;
2964ab3302SCarolineConcatto 
3033faa828SKrzysztof Parzyszek /// Parse OpenMP directive name (this includes compound directives).
3133faa828SKrzysztof Parzyszek struct OmpDirectiveNameParser {
3233faa828SKrzysztof Parzyszek   using resultType = llvm::omp::Directive;
3333faa828SKrzysztof Parzyszek   using Token = TokenStringMatch<false, false>;
3433faa828SKrzysztof Parzyszek 
3533faa828SKrzysztof Parzyszek   std::optional<resultType> Parse(ParseState &state) const {
3633faa828SKrzysztof Parzyszek     for (const NameWithId &nid : directives()) {
3733faa828SKrzysztof Parzyszek       if (attempt(Token(nid.first.data())).Parse(state)) {
3833faa828SKrzysztof Parzyszek         return nid.second;
3933faa828SKrzysztof Parzyszek       }
4033faa828SKrzysztof Parzyszek     }
4133faa828SKrzysztof Parzyszek     return std::nullopt;
4233faa828SKrzysztof Parzyszek   }
4333faa828SKrzysztof Parzyszek 
4433faa828SKrzysztof Parzyszek private:
4533faa828SKrzysztof Parzyszek   using NameWithId = std::pair<std::string, llvm::omp::Directive>;
4633faa828SKrzysztof Parzyszek 
4733faa828SKrzysztof Parzyszek   llvm::iterator_range<const NameWithId *> directives() const;
4833faa828SKrzysztof Parzyszek   void initTokens(NameWithId *) const;
4933faa828SKrzysztof Parzyszek };
5033faa828SKrzysztof Parzyszek 
5133faa828SKrzysztof Parzyszek llvm::iterator_range<const OmpDirectiveNameParser::NameWithId *>
5233faa828SKrzysztof Parzyszek OmpDirectiveNameParser::directives() const {
5333faa828SKrzysztof Parzyszek   static NameWithId table[llvm::omp::Directive_enumSize];
5433faa828SKrzysztof Parzyszek   [[maybe_unused]] static bool init = (initTokens(table), true);
5533faa828SKrzysztof Parzyszek   return llvm::make_range(std::cbegin(table), std::cend(table));
5633faa828SKrzysztof Parzyszek }
5733faa828SKrzysztof Parzyszek 
5833faa828SKrzysztof Parzyszek void OmpDirectiveNameParser::initTokens(NameWithId *table) const {
5933faa828SKrzysztof Parzyszek   for (size_t i{0}, e{llvm::omp::Directive_enumSize}; i != e; ++i) {
6033faa828SKrzysztof Parzyszek     auto id{static_cast<llvm::omp::Directive>(i)};
6133faa828SKrzysztof Parzyszek     llvm::StringRef name{llvm::omp::getOpenMPDirectiveName(id)};
6233faa828SKrzysztof Parzyszek     table[i] = std::make_pair(name.str(), id);
6333faa828SKrzysztof Parzyszek   }
6433faa828SKrzysztof Parzyszek   // Sort the table with respect to the directive name length in a descending
6533faa828SKrzysztof Parzyszek   // order. This is to make sure that longer names are tried first, before
6633faa828SKrzysztof Parzyszek   // any potential prefix (e.g. "target update" before "target").
6733faa828SKrzysztof Parzyszek   std::sort(table, table + llvm::omp::Directive_enumSize,
6833faa828SKrzysztof Parzyszek       [](auto &a, auto &b) { return a.first.size() > b.first.size(); });
6933faa828SKrzysztof Parzyszek }
7033faa828SKrzysztof Parzyszek 
7152755ac2SKrzysztof Parzyszek template <typename Clause, typename Separator> struct ModifierList {
7252755ac2SKrzysztof Parzyszek   constexpr ModifierList(Separator sep) : sep_(sep) {}
7352755ac2SKrzysztof Parzyszek   constexpr ModifierList(const ModifierList &) = default;
7452755ac2SKrzysztof Parzyszek   constexpr ModifierList(ModifierList &&) = default;
75973fa983SKrzysztof Parzyszek 
7652755ac2SKrzysztof Parzyszek   using resultType = std::list<typename Clause::Modifier>;
77973fa983SKrzysztof Parzyszek 
78973fa983SKrzysztof Parzyszek   std::optional<resultType> Parse(ParseState &state) const {
7952755ac2SKrzysztof Parzyszek     auto listp{nonemptySeparated(Parser<typename Clause::Modifier>{}, sep_)};
8052755ac2SKrzysztof Parzyszek     if (auto result{attempt(listp).Parse(state)}) {
81973fa983SKrzysztof Parzyszek       if (!attempt(":"_tok).Parse(state)) {
82697d65deSKrzysztof Parzyszek         return std::nullopt;
83697d65deSKrzysztof Parzyszek       }
8452755ac2SKrzysztof Parzyszek       return std::move(result);
85697d65deSKrzysztof Parzyszek     }
8652755ac2SKrzysztof Parzyszek     return resultType{};
87697d65deSKrzysztof Parzyszek   }
88697d65deSKrzysztof Parzyszek 
89697d65deSKrzysztof Parzyszek private:
90697d65deSKrzysztof Parzyszek   const Separator sep_;
91697d65deSKrzysztof Parzyszek };
92697d65deSKrzysztof Parzyszek 
9352755ac2SKrzysztof Parzyszek // Use a function to create ModifierList because functions allow "partial"
9452755ac2SKrzysztof Parzyszek // template argument deduction: "modifierList<Clause>(sep)" would be legal,
9552755ac2SKrzysztof Parzyszek // while "ModifierList<Clause>(sep)" would complain about a missing template
9652755ac2SKrzysztof Parzyszek // argument "Separator".
9752755ac2SKrzysztof Parzyszek template <typename Clause, typename Separator>
9852755ac2SKrzysztof Parzyszek constexpr ModifierList<Clause, Separator> modifierList(Separator sep) {
9952755ac2SKrzysztof Parzyszek   return ModifierList<Clause, Separator>(sep);
1001c6ec29bSKrzysztof Parzyszek }
1011c6ec29bSKrzysztof Parzyszek 
10203cbe426SKrzysztof Parzyszek // Parse the input as any modifier from ClauseTy, but only succeed if
10303cbe426SKrzysztof Parzyszek // the result was the SpecificTy. It requires that SpecificTy is one
10403cbe426SKrzysztof Parzyszek // of the alternatives in ClauseTy::Modifier.
10503cbe426SKrzysztof Parzyszek // The reason to have this is that ClauseTy::Modifier has "source",
10603cbe426SKrzysztof Parzyszek // while specific modifiers don't. This class allows to parse a specific
10703cbe426SKrzysztof Parzyszek // modifier together with obtaining its location.
10803cbe426SKrzysztof Parzyszek template <typename SpecificTy, typename ClauseTy>
10903cbe426SKrzysztof Parzyszek struct SpecificModifierParser {
11003cbe426SKrzysztof Parzyszek   using resultType = typename ClauseTy::Modifier;
11103cbe426SKrzysztof Parzyszek   std::optional<resultType> Parse(ParseState &state) const {
11203cbe426SKrzysztof Parzyszek     if (auto result{attempt(Parser<resultType>{}).Parse(state)}) {
11303cbe426SKrzysztof Parzyszek       if (std::holds_alternative<SpecificTy>(result->u)) {
11403cbe426SKrzysztof Parzyszek         return result;
11503cbe426SKrzysztof Parzyszek       }
11603cbe426SKrzysztof Parzyszek     }
11703cbe426SKrzysztof Parzyszek     return std::nullopt;
11803cbe426SKrzysztof Parzyszek   }
11903cbe426SKrzysztof Parzyszek };
12003cbe426SKrzysztof Parzyszek 
12164ab3302SCarolineConcatto // OpenMP Clauses
122973fa983SKrzysztof Parzyszek 
123973fa983SKrzysztof Parzyszek // [5.0] 2.1.6 iterator-specifier -> type-declaration-stmt = subscript-triple |
124973fa983SKrzysztof Parzyszek //                                   identifier = subscript-triple
125973fa983SKrzysztof Parzyszek // [5.0:47:17-18] In an iterator-specifier, if the iterator-type is not
126973fa983SKrzysztof Parzyszek // specified then the type of that iterator is default integer.
127973fa983SKrzysztof Parzyszek // [5.0:49:14] The iterator-type must be an integer type.
128973fa983SKrzysztof Parzyszek static std::list<EntityDecl> makeEntityList(std::list<ObjectName> &&names) {
129973fa983SKrzysztof Parzyszek   std::list<EntityDecl> entities;
130973fa983SKrzysztof Parzyszek 
131973fa983SKrzysztof Parzyszek   for (auto iter = names.begin(), end = names.end(); iter != end; ++iter) {
132973fa983SKrzysztof Parzyszek     EntityDecl entityDecl(
133973fa983SKrzysztof Parzyszek         /*ObjectName=*/std::move(*iter), std::optional<ArraySpec>{},
134973fa983SKrzysztof Parzyszek         std::optional<CoarraySpec>{}, std::optional<CharLength>{},
135973fa983SKrzysztof Parzyszek         std::optional<Initialization>{});
136973fa983SKrzysztof Parzyszek     entities.push_back(std::move(entityDecl));
137973fa983SKrzysztof Parzyszek   }
138973fa983SKrzysztof Parzyszek   return entities;
139973fa983SKrzysztof Parzyszek }
140973fa983SKrzysztof Parzyszek 
141973fa983SKrzysztof Parzyszek static TypeDeclarationStmt makeIterSpecDecl(
142973fa983SKrzysztof Parzyszek     DeclarationTypeSpec &&spec, std::list<ObjectName> &&names) {
143973fa983SKrzysztof Parzyszek   return TypeDeclarationStmt(
144973fa983SKrzysztof Parzyszek       std::move(spec), std::list<AttrSpec>{}, makeEntityList(std::move(names)));
145973fa983SKrzysztof Parzyszek }
146973fa983SKrzysztof Parzyszek 
147973fa983SKrzysztof Parzyszek static TypeDeclarationStmt makeIterSpecDecl(std::list<ObjectName> &&names) {
148973fa983SKrzysztof Parzyszek   // Assume INTEGER without kind selector.
149973fa983SKrzysztof Parzyszek   DeclarationTypeSpec typeSpec(
150973fa983SKrzysztof Parzyszek       IntrinsicTypeSpec{IntegerTypeSpec{std::nullopt}});
151973fa983SKrzysztof Parzyszek 
152973fa983SKrzysztof Parzyszek   return TypeDeclarationStmt(std::move(typeSpec), std::list<AttrSpec>{},
153973fa983SKrzysztof Parzyszek       makeEntityList(std::move(names)));
154973fa983SKrzysztof Parzyszek }
155973fa983SKrzysztof Parzyszek 
156*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpDirectiveSpecification>(
157*15ab7be2SKrzysztof Parzyszek     OmpDirectiveNameParser{}, maybe(indirect(Parser<OmpClauseList>{})))))
158*15ab7be2SKrzysztof Parzyszek 
15970e96dc3SKrzysztof Parzyszek // --- Parsers for context traits -------------------------------------
16070e96dc3SKrzysztof Parzyszek 
16170e96dc3SKrzysztof Parzyszek static std::string nameToString(Name &&name) { return name.ToString(); }
16270e96dc3SKrzysztof Parzyszek 
16370e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitPropertyName>( //
164c8593239SKrzysztof Parzyszek     construct<OmpTraitPropertyName>(space >> charLiteralConstantWithoutKind) ||
165c8593239SKrzysztof Parzyszek     construct<OmpTraitPropertyName>(
166c8593239SKrzysztof Parzyszek         applyFunction(nameToString, Parser<Name>{})))))
16770e96dc3SKrzysztof Parzyszek 
16870e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitScore>( //
169c8593239SKrzysztof Parzyszek     "SCORE"_id >> parenthesized(scalarIntExpr))))
17070e96dc3SKrzysztof Parzyszek 
171c8593239SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitPropertyExtension::Complex>(
17270e96dc3SKrzysztof Parzyszek     Parser<OmpTraitPropertyName>{},
17370e96dc3SKrzysztof Parzyszek     parenthesized(nonemptySeparated(
174c8593239SKrzysztof Parzyszek         indirect(Parser<OmpTraitPropertyExtension>{}), ",")))))
17570e96dc3SKrzysztof Parzyszek 
176c8593239SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitPropertyExtension>(
177c8593239SKrzysztof Parzyszek     construct<OmpTraitPropertyExtension>(
178c8593239SKrzysztof Parzyszek         Parser<OmpTraitPropertyExtension::Complex>{}) ||
179c8593239SKrzysztof Parzyszek     construct<OmpTraitPropertyExtension>(Parser<OmpTraitPropertyName>{}) ||
180c8593239SKrzysztof Parzyszek     construct<OmpTraitPropertyExtension>(scalarExpr))))
18170e96dc3SKrzysztof Parzyszek 
18270e96dc3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpTraitSelectorName::Value>(
183c8593239SKrzysztof Parzyszek     "ARCH"_id >> pure(OmpTraitSelectorName::Value::Arch) ||
184c8593239SKrzysztof Parzyszek     "ATOMIC_DEFAULT_MEM_ORDER"_id >>
18570e96dc3SKrzysztof Parzyszek         pure(OmpTraitSelectorName::Value::Atomic_Default_Mem_Order) ||
186c8593239SKrzysztof Parzyszek     "CONDITION"_id >> pure(OmpTraitSelectorName::Value::Condition) ||
187c8593239SKrzysztof Parzyszek     "DEVICE_NUM"_id >> pure(OmpTraitSelectorName::Value::Device_Num) ||
188c8593239SKrzysztof Parzyszek     "EXTENSION"_id >> pure(OmpTraitSelectorName::Value::Extension) ||
189c8593239SKrzysztof Parzyszek     "ISA"_id >> pure(OmpTraitSelectorName::Value::Isa) ||
190c8593239SKrzysztof Parzyszek     "KIND"_id >> pure(OmpTraitSelectorName::Value::Kind) ||
191c8593239SKrzysztof Parzyszek     "REQUIRES"_id >> pure(OmpTraitSelectorName::Value::Requires) ||
192c8593239SKrzysztof Parzyszek     "SIMD"_id >> pure(OmpTraitSelectorName::Value::Simd) ||
193c8593239SKrzysztof Parzyszek     "UID"_id >> pure(OmpTraitSelectorName::Value::Uid) ||
194c8593239SKrzysztof Parzyszek     "VENDOR"_id >> pure(OmpTraitSelectorName::Value::Vendor)))
19570e96dc3SKrzysztof Parzyszek 
19670e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitSelectorName>(
19770e96dc3SKrzysztof Parzyszek     // Parse predefined names first (because of SIMD).
19870e96dc3SKrzysztof Parzyszek     construct<OmpTraitSelectorName>(Parser<OmpTraitSelectorName::Value>{}) ||
199c8593239SKrzysztof Parzyszek     construct<OmpTraitSelectorName>(OmpDirectiveNameParser{}) ||
200c8593239SKrzysztof Parzyszek     // identifier-or-string for extensions
201c8593239SKrzysztof Parzyszek     construct<OmpTraitSelectorName>(
202c8593239SKrzysztof Parzyszek         applyFunction(nameToString, Parser<Name>{})) ||
203c8593239SKrzysztof Parzyszek     construct<OmpTraitSelectorName>(space >> charLiteralConstantWithoutKind))))
20470e96dc3SKrzysztof Parzyszek 
205c8593239SKrzysztof Parzyszek // Parser for OmpTraitSelector::Properties
206c8593239SKrzysztof Parzyszek template <typename... PropParser>
207c8593239SKrzysztof Parzyszek static constexpr auto propertyListParser(PropParser... pp) {
208c8593239SKrzysztof Parzyszek   // Parse the property list "(score(expr): item1...)" in three steps:
209c8593239SKrzysztof Parzyszek   // 1. Parse the "("
210c8593239SKrzysztof Parzyszek   // 2. Parse the optional "score(expr):"
211c8593239SKrzysztof Parzyszek   // 3. Parse the "item1, ...)", together with the ")".
212c8593239SKrzysztof Parzyszek   // The reason for including the ")" in the 3rd step is to force parsing
213c8593239SKrzysztof Parzyszek   // the entire list in each of the alternative property parsers. Otherwise,
214c8593239SKrzysztof Parzyszek   // the name parser could stop after "foo" in "(foo, bar(1))", without
215c8593239SKrzysztof Parzyszek   // allowing the next parser to give the list a try.
216c8593239SKrzysztof Parzyszek   auto listOf{[](auto parser) { //
217c8593239SKrzysztof Parzyszek     return nonemptySeparated(parser, ",");
218c8593239SKrzysztof Parzyszek   }};
21970e96dc3SKrzysztof Parzyszek 
220c8593239SKrzysztof Parzyszek   using P = OmpTraitProperty;
221c8593239SKrzysztof Parzyszek   return maybe("(" >> //
222c8593239SKrzysztof Parzyszek       construct<OmpTraitSelector::Properties>(
223c8593239SKrzysztof Parzyszek           maybe(Parser<OmpTraitScore>{} / ":"),
224c8593239SKrzysztof Parzyszek           (attempt(listOf(sourced(construct<P>(pp))) / ")") || ...)));
225c8593239SKrzysztof Parzyszek }
226c8593239SKrzysztof Parzyszek 
227c8593239SKrzysztof Parzyszek // Parser for OmpTraitSelector
228c8593239SKrzysztof Parzyszek struct TraitSelectorParser {
229c8593239SKrzysztof Parzyszek   using resultType = OmpTraitSelector;
230c8593239SKrzysztof Parzyszek 
231c8593239SKrzysztof Parzyszek   constexpr TraitSelectorParser(Parser<OmpTraitSelectorName> p) : np(p) {}
232c8593239SKrzysztof Parzyszek 
233c8593239SKrzysztof Parzyszek   std::optional<resultType> Parse(ParseState &state) const {
234c8593239SKrzysztof Parzyszek     auto name{attempt(np).Parse(state)};
235c8593239SKrzysztof Parzyszek     if (!name.has_value()) {
236c8593239SKrzysztof Parzyszek       return std::nullopt;
237c8593239SKrzysztof Parzyszek     }
238c8593239SKrzysztof Parzyszek 
239c8593239SKrzysztof Parzyszek     // Default fallback parser for lists that cannot be parser using the
240c8593239SKrzysztof Parzyszek     // primary property parser.
241c8593239SKrzysztof Parzyszek     auto extParser{Parser<OmpTraitPropertyExtension>{}};
242c8593239SKrzysztof Parzyszek 
243c8593239SKrzysztof Parzyszek     if (auto *v{std::get_if<OmpTraitSelectorName::Value>(&name->u)}) {
244c8593239SKrzysztof Parzyszek       // (*) The comments below show the sections of the OpenMP spec that
245c8593239SKrzysztof Parzyszek       // describe given trait. The cases marked with a (*) are those where
246c8593239SKrzysztof Parzyszek       // the spec doesn't assign any list-type to these traits, but for
247c8593239SKrzysztof Parzyszek       // convenience they can be treated as if they were.
248c8593239SKrzysztof Parzyszek       switch (*v) {
249c8593239SKrzysztof Parzyszek       // name-list properties
250c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Arch: // [6.0:319:18]
251c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Extension: // [6.0:319:30]
252c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Isa: // [6.0:319:15]
253c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Kind: // [6.0:319:10]
254c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Uid: // [6.0:319:23](*)
255c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Vendor: { // [6.0:319:27]
256c8593239SKrzysztof Parzyszek         auto pp{propertyListParser(Parser<OmpTraitPropertyName>{}, extParser)};
257c8593239SKrzysztof Parzyszek         return OmpTraitSelector(std::move(*name), std::move(*pp.Parse(state)));
258c8593239SKrzysztof Parzyszek       }
259c8593239SKrzysztof Parzyszek       // clause-list
260c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Atomic_Default_Mem_Order:
261c8593239SKrzysztof Parzyszek         // [6.0:321:26-29](*)
262c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Requires: // [6.0:319:33]
263c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Simd: { // [6.0:318:31]
264c8593239SKrzysztof Parzyszek         auto pp{propertyListParser(indirect(Parser<OmpClause>{}), extParser)};
265c8593239SKrzysztof Parzyszek         return OmpTraitSelector(std::move(*name), std::move(*pp.Parse(state)));
266c8593239SKrzysztof Parzyszek       }
267c8593239SKrzysztof Parzyszek       // expr-list
268c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Condition: // [6.0:321:33](*)
269c8593239SKrzysztof Parzyszek       case OmpTraitSelectorName::Value::Device_Num: { // [6.0:321:23-24](*)
270c8593239SKrzysztof Parzyszek         auto pp{propertyListParser(scalarExpr, extParser)};
271c8593239SKrzysztof Parzyszek         return OmpTraitSelector(std::move(*name), std::move(*pp.Parse(state)));
272c8593239SKrzysztof Parzyszek       }
273c8593239SKrzysztof Parzyszek       } // switch
274c8593239SKrzysztof Parzyszek     } else {
275c8593239SKrzysztof Parzyszek       // The other alternatives are `llvm::omp::Directive`, and `std::string`.
276c8593239SKrzysztof Parzyszek       // The former doesn't take any properties[1], the latter is a name of an
277c8593239SKrzysztof Parzyszek       // extension[2].
278c8593239SKrzysztof Parzyszek       // [1] [6.0:319:1-2]
279c8593239SKrzysztof Parzyszek       // [2] [6.0:319:36-37]
280c8593239SKrzysztof Parzyszek       auto pp{propertyListParser(extParser)};
281c8593239SKrzysztof Parzyszek       return OmpTraitSelector(std::move(*name), std::move(*pp.Parse(state)));
282c8593239SKrzysztof Parzyszek     }
283c8593239SKrzysztof Parzyszek 
284c8593239SKrzysztof Parzyszek     llvm_unreachable("Unhandled trait name?");
285c8593239SKrzysztof Parzyszek   }
286c8593239SKrzysztof Parzyszek 
287c8593239SKrzysztof Parzyszek private:
288c8593239SKrzysztof Parzyszek   const Parser<OmpTraitSelectorName> np;
289c8593239SKrzysztof Parzyszek };
290c8593239SKrzysztof Parzyszek 
291c8593239SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitSelector>(
292c8593239SKrzysztof Parzyszek     sourced(TraitSelectorParser(Parser<OmpTraitSelectorName>{})))))
29370e96dc3SKrzysztof Parzyszek 
29470e96dc3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpTraitSetSelectorName::Value>(
295c8593239SKrzysztof Parzyszek     "CONSTRUCT"_id >> pure(OmpTraitSetSelectorName::Value::Construct) ||
296c8593239SKrzysztof Parzyszek     "DEVICE"_id >> pure(OmpTraitSetSelectorName::Value::Device) ||
297c8593239SKrzysztof Parzyszek     "IMPLEMENTATION"_id >>
298c8593239SKrzysztof Parzyszek         pure(OmpTraitSetSelectorName::Value::Implementation) ||
299c8593239SKrzysztof Parzyszek     "TARGET_DEVICE"_id >> pure(OmpTraitSetSelectorName::Value::Target_Device) ||
300c8593239SKrzysztof Parzyszek     "USER"_id >> pure(OmpTraitSetSelectorName::Value::User)))
30170e96dc3SKrzysztof Parzyszek 
30270e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitSetSelectorName>(
30370e96dc3SKrzysztof Parzyszek     Parser<OmpTraitSetSelectorName::Value>{})))
30470e96dc3SKrzysztof Parzyszek 
30570e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTraitSetSelector>( //
30670e96dc3SKrzysztof Parzyszek     Parser<OmpTraitSetSelectorName>{},
307c8593239SKrzysztof Parzyszek     "=" >> braced(nonemptySeparated(Parser<OmpTraitSelector>{}, ",")))))
30870e96dc3SKrzysztof Parzyszek 
30970e96dc3SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpContextSelectorSpecification>(
310c8593239SKrzysztof Parzyszek     nonemptySeparated(Parser<OmpTraitSetSelector>{}, ","))))
31170e96dc3SKrzysztof Parzyszek 
31270e96dc3SKrzysztof Parzyszek // Parser<OmpContextSelector> == Parser<traits::OmpContextSelectorSpecification>
31370e96dc3SKrzysztof Parzyszek 
314cfd67c21SKrzysztof Parzyszek // --- Parsers for clause modifiers -----------------------------------
315cfd67c21SKrzysztof Parzyszek 
31605096590SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAlignment>(scalarIntExpr))
31705096590SKrzysztof Parzyszek 
318cdbd2287SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAlignModifier>( //
319cdbd2287SKrzysztof Parzyszek     "ALIGN" >> parenthesized(scalarIntExpr)))
320cdbd2287SKrzysztof Parzyszek 
321cdbd2287SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAllocatorComplexModifier>(
322cdbd2287SKrzysztof Parzyszek     "ALLOCATOR" >> parenthesized(scalarIntExpr)))
323cdbd2287SKrzysztof Parzyszek 
324cdbd2287SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAllocatorSimpleModifier>(scalarIntExpr))
325cdbd2287SKrzysztof Parzyszek 
32652755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpChunkModifier>( //
32752755ac2SKrzysztof Parzyszek     "SIMD" >> pure(OmpChunkModifier::Value::Simd)))
32852755ac2SKrzysztof Parzyszek 
32952755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpDependenceType>(
33052755ac2SKrzysztof Parzyszek     "SINK" >> pure(OmpDependenceType::Value::Sink) ||
33152755ac2SKrzysztof Parzyszek     "SOURCE" >> pure(OmpDependenceType::Value::Source)))
33252755ac2SKrzysztof Parzyszek 
33305096590SKrzysztof Parzyszek TYPE_PARSER(construct<OmpDeviceModifier>(
33405096590SKrzysztof Parzyszek     "ANCESTOR" >> pure(OmpDeviceModifier::Value::Ancestor) ||
33505096590SKrzysztof Parzyszek     "DEVICE_NUM" >> pure(OmpDeviceModifier::Value::Device_Num)))
33605096590SKrzysztof Parzyszek 
33752755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpExpectation>( //
33852755ac2SKrzysztof Parzyszek     "PRESENT" >> pure(OmpExpectation::Value::Present)))
33952755ac2SKrzysztof Parzyszek 
340973fa983SKrzysztof Parzyszek TYPE_PARSER(construct<OmpIteratorSpecifier>(
341973fa983SKrzysztof Parzyszek     // Using Parser<TypeDeclarationStmt> or Parser<EntityDecl> has the problem
342973fa983SKrzysztof Parzyszek     // that they will attempt to treat what follows the '=' as initialization.
343973fa983SKrzysztof Parzyszek     // There are several issues with that,
344973fa983SKrzysztof Parzyszek     // 1. integer :: i = 0:10 will be parsed as "integer :: i = 0", followed
345973fa983SKrzysztof Parzyszek     // by triplet ":10".
346973fa983SKrzysztof Parzyszek     // 2. integer :: j = i:10 will be flagged as an error because the
347973fa983SKrzysztof Parzyszek     // initializer 'i' must be constant (in declarations). In an iterator
348973fa983SKrzysztof Parzyszek     // specifier the 'j' is not an initializer and can be a variable.
349973fa983SKrzysztof Parzyszek     (applyFunction<TypeDeclarationStmt>(makeIterSpecDecl,
350973fa983SKrzysztof Parzyszek          Parser<DeclarationTypeSpec>{} / maybe("::"_tok),
351973fa983SKrzysztof Parzyszek          nonemptyList(Parser<ObjectName>{}) / "="_tok) ||
352973fa983SKrzysztof Parzyszek         applyFunction<TypeDeclarationStmt>(
353973fa983SKrzysztof Parzyszek             makeIterSpecDecl, nonemptyList(Parser<ObjectName>{}) / "="_tok)),
354973fa983SKrzysztof Parzyszek     subscriptTriplet))
355973fa983SKrzysztof Parzyszek 
356973fa983SKrzysztof Parzyszek // [5.0] 2.1.6 iterator -> iterator-specifier-list
35752755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpIterator>( //
35852755ac2SKrzysztof Parzyszek     "ITERATOR" >>
359973fa983SKrzysztof Parzyszek     parenthesized(nonemptyList(sourced(Parser<OmpIteratorSpecifier>{})))))
360973fa983SKrzysztof Parzyszek 
36133faa828SKrzysztof Parzyszek TYPE_PARSER(construct<OmpLastprivateModifier>(
36233faa828SKrzysztof Parzyszek     "CONDITIONAL" >> pure(OmpLastprivateModifier::Value::Conditional)))
36333faa828SKrzysztof Parzyszek 
364cfd67c21SKrzysztof Parzyszek // 2.15.3.7 LINEAR (linear-list: linear-step)
365cfd67c21SKrzysztof Parzyszek //          linear-list -> list | modifier(list)
366cfd67c21SKrzysztof Parzyszek //          linear-modifier -> REF | VAL | UVAL
367cfd67c21SKrzysztof Parzyszek TYPE_PARSER(construct<OmpLinearModifier>( //
368cfd67c21SKrzysztof Parzyszek     "REF" >> pure(OmpLinearModifier::Value::Ref) ||
369cfd67c21SKrzysztof Parzyszek     "VAL" >> pure(OmpLinearModifier::Value::Val) ||
370cfd67c21SKrzysztof Parzyszek     "UVAL" >> pure(OmpLinearModifier::Value::Uval)))
371cfd67c21SKrzysztof Parzyszek 
37252755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpMapper>( //
37352755ac2SKrzysztof Parzyszek     "MAPPER"_tok >> parenthesized(Parser<ObjectName>{})))
37452755ac2SKrzysztof Parzyszek 
37552755ac2SKrzysztof Parzyszek // map-type -> ALLOC | DELETE | FROM | RELEASE | TO | TOFROM
37652755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpMapType>( //
37752755ac2SKrzysztof Parzyszek     "ALLOC" >> pure(OmpMapType::Value::Alloc) ||
37852755ac2SKrzysztof Parzyszek     "DELETE" >> pure(OmpMapType::Value::Delete) ||
37952755ac2SKrzysztof Parzyszek     "FROM" >> pure(OmpMapType::Value::From) ||
38052755ac2SKrzysztof Parzyszek     "RELEASE" >> pure(OmpMapType::Value::Release) ||
38152755ac2SKrzysztof Parzyszek     "TO"_id >> pure(OmpMapType::Value::To) ||
38252755ac2SKrzysztof Parzyszek     "TOFROM" >> pure(OmpMapType::Value::Tofrom)))
38352755ac2SKrzysztof Parzyszek 
38452755ac2SKrzysztof Parzyszek // map-type-modifier -> ALWAYS | CLOSE | OMPX_HOLD | PRESENT
38552755ac2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpMapTypeModifier>(
38652755ac2SKrzysztof Parzyszek     "ALWAYS" >> pure(OmpMapTypeModifier::Value::Always) ||
38752755ac2SKrzysztof Parzyszek     "CLOSE" >> pure(OmpMapTypeModifier::Value::Close) ||
38852755ac2SKrzysztof Parzyszek     "OMPX_HOLD" >> pure(OmpMapTypeModifier::Value::Ompx_Hold) ||
38952755ac2SKrzysztof Parzyszek     "PRESENT" >> pure(OmpMapTypeModifier::Value::Present)))
39052755ac2SKrzysztof Parzyszek 
391cfd67c21SKrzysztof Parzyszek // 2.15.3.6 REDUCTION (reduction-identifier: variable-name-list)
392cfd67c21SKrzysztof Parzyszek TYPE_PARSER(construct<OmpReductionIdentifier>(Parser<DefinedOperator>{}) ||
393cfd67c21SKrzysztof Parzyszek     construct<OmpReductionIdentifier>(Parser<ProcedureDesignator>{}))
394cfd67c21SKrzysztof Parzyszek 
395e79cd246SKrzysztof Parzyszek TYPE_PARSER(construct<OmpOrderModifier>(
396e79cd246SKrzysztof Parzyszek     "REPRODUCIBLE" >> pure(OmpOrderModifier::Value::Reproducible) ||
397e79cd246SKrzysztof Parzyszek     "UNCONSTRAINED" >> pure(OmpOrderModifier::Value::Unconstrained)))
398e79cd246SKrzysztof Parzyszek 
399e79cd246SKrzysztof Parzyszek TYPE_PARSER(construct<OmpOrderingModifier>(
400e79cd246SKrzysztof Parzyszek     "MONOTONIC" >> pure(OmpOrderingModifier::Value::Monotonic) ||
401e79cd246SKrzysztof Parzyszek     "NONMONOTONIC" >> pure(OmpOrderingModifier::Value::Nonmonotonic) ||
402e79cd246SKrzysztof Parzyszek     "SIMD" >> pure(OmpOrderingModifier::Value::Simd)))
403e79cd246SKrzysztof Parzyszek 
404bde79c0eSKrzysztof Parzyszek TYPE_PARSER(construct<OmpPrescriptiveness>(
405bde79c0eSKrzysztof Parzyszek     "STRICT" >> pure(OmpPrescriptiveness::Value::Strict)))
406bde79c0eSKrzysztof Parzyszek 
4074fc1141eSKrzysztof Parzyszek TYPE_PARSER(construct<OmpReductionModifier>(
4084fc1141eSKrzysztof Parzyszek     "INSCAN" >> pure(OmpReductionModifier::Value::Inscan) ||
4094fc1141eSKrzysztof Parzyszek     "TASK" >> pure(OmpReductionModifier::Value::Task) ||
4104fc1141eSKrzysztof Parzyszek     "DEFAULT" >> pure(OmpReductionModifier::Value::Default)))
4114fc1141eSKrzysztof Parzyszek 
41203cbe426SKrzysztof Parzyszek TYPE_PARSER(construct<OmpStepComplexModifier>( //
41303cbe426SKrzysztof Parzyszek     "STEP" >> parenthesized(scalarIntExpr)))
41403cbe426SKrzysztof Parzyszek 
41503cbe426SKrzysztof Parzyszek TYPE_PARSER(construct<OmpStepSimpleModifier>(scalarIntExpr))
41603cbe426SKrzysztof Parzyszek 
417cfd67c21SKrzysztof Parzyszek TYPE_PARSER(construct<OmpTaskDependenceType>(
418cfd67c21SKrzysztof Parzyszek     "DEPOBJ" >> pure(OmpTaskDependenceType::Value::Depobj) ||
419cfd67c21SKrzysztof Parzyszek     "IN"_id >> pure(OmpTaskDependenceType::Value::In) ||
420cfd67c21SKrzysztof Parzyszek     "INOUT"_id >> pure(OmpTaskDependenceType::Value::Inout) ||
421cfd67c21SKrzysztof Parzyszek     "INOUTSET"_id >> pure(OmpTaskDependenceType::Value::Inoutset) ||
422cfd67c21SKrzysztof Parzyszek     "MUTEXINOUTSET" >> pure(OmpTaskDependenceType::Value::Mutexinoutset) ||
423cfd67c21SKrzysztof Parzyszek     "OUT" >> pure(OmpTaskDependenceType::Value::Out)))
424cfd67c21SKrzysztof Parzyszek 
4254fc1141eSKrzysztof Parzyszek TYPE_PARSER(construct<OmpVariableCategory>(
4264fc1141eSKrzysztof Parzyszek     "AGGREGATE" >> pure(OmpVariableCategory::Value::Aggregate) ||
4274fc1141eSKrzysztof Parzyszek     "ALL"_id >> pure(OmpVariableCategory::Value::All) ||
4284fc1141eSKrzysztof Parzyszek     "ALLOCATABLE" >> pure(OmpVariableCategory::Value::Allocatable) ||
4294fc1141eSKrzysztof Parzyszek     "POINTER" >> pure(OmpVariableCategory::Value::Pointer) ||
4304fc1141eSKrzysztof Parzyszek     "SCALAR" >> pure(OmpVariableCategory::Value::Scalar)))
4314fc1141eSKrzysztof Parzyszek 
432e79cd246SKrzysztof Parzyszek // This could be auto-generated.
43305096590SKrzysztof Parzyszek TYPE_PARSER(
43405096590SKrzysztof Parzyszek     sourced(construct<OmpAffinityClause::Modifier>(Parser<OmpIterator>{})))
43505096590SKrzysztof Parzyszek 
43605096590SKrzysztof Parzyszek TYPE_PARSER(
43705096590SKrzysztof Parzyszek     sourced(construct<OmpAlignedClause::Modifier>(Parser<OmpAlignment>{})))
43805096590SKrzysztof Parzyszek 
439cdbd2287SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpAllocateClause::Modifier>(sourced(
440cdbd2287SKrzysztof Parzyszek     construct<OmpAllocateClause::Modifier>(Parser<OmpAlignModifier>{}) ||
441cdbd2287SKrzysztof Parzyszek     construct<OmpAllocateClause::Modifier>(
442cdbd2287SKrzysztof Parzyszek         Parser<OmpAllocatorComplexModifier>{}) ||
443cdbd2287SKrzysztof Parzyszek     construct<OmpAllocateClause::Modifier>(
444cdbd2287SKrzysztof Parzyszek         Parser<OmpAllocatorSimpleModifier>{})))))
445cdbd2287SKrzysztof Parzyszek 
446cdbd2287SKrzysztof Parzyszek TYPE_PARSER(sourced(
447cdbd2287SKrzysztof Parzyszek     construct<OmpDefaultmapClause::Modifier>(Parser<OmpVariableCategory>{})))
448cdbd2287SKrzysztof Parzyszek 
449bde79c0eSKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpDependClause::TaskDep::Modifier>(sourced(
450bde79c0eSKrzysztof Parzyszek     construct<OmpDependClause::TaskDep::Modifier>(Parser<OmpIterator>{}) ||
451bde79c0eSKrzysztof Parzyszek     construct<OmpDependClause::TaskDep::Modifier>(
452bde79c0eSKrzysztof Parzyszek         Parser<OmpTaskDependenceType>{})))))
453bde79c0eSKrzysztof Parzyszek 
45405096590SKrzysztof Parzyszek TYPE_PARSER(
45505096590SKrzysztof Parzyszek     sourced(construct<OmpDeviceClause::Modifier>(Parser<OmpDeviceModifier>{})))
45605096590SKrzysztof Parzyszek 
45752755ac2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpFromClause::Modifier>(
45852755ac2SKrzysztof Parzyszek     sourced(construct<OmpFromClause::Modifier>(Parser<OmpExpectation>{}) ||
45952755ac2SKrzysztof Parzyszek         construct<OmpFromClause::Modifier>(Parser<OmpMapper>{}) ||
46052755ac2SKrzysztof Parzyszek         construct<OmpFromClause::Modifier>(Parser<OmpIterator>{})))))
46152755ac2SKrzysztof Parzyszek 
462bde79c0eSKrzysztof Parzyszek TYPE_PARSER(sourced(
463bde79c0eSKrzysztof Parzyszek     construct<OmpGrainsizeClause::Modifier>(Parser<OmpPrescriptiveness>{})))
464bde79c0eSKrzysztof Parzyszek 
46533faa828SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpIfClause::Modifier>(OmpDirectiveNameParser{})))
46633faa828SKrzysztof Parzyszek 
46758f9c4fcSKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpInReductionClause::Modifier>(
46858f9c4fcSKrzysztof Parzyszek     Parser<OmpReductionIdentifier>{})))
46958f9c4fcSKrzysztof Parzyszek 
47033faa828SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpLastprivateClause::Modifier>(
47133faa828SKrzysztof Parzyszek     Parser<OmpLastprivateModifier>{})))
47233faa828SKrzysztof Parzyszek 
47303cbe426SKrzysztof Parzyszek TYPE_PARSER(sourced(
47403cbe426SKrzysztof Parzyszek     construct<OmpLinearClause::Modifier>(Parser<OmpLinearModifier>{}) ||
47503cbe426SKrzysztof Parzyszek     construct<OmpLinearClause::Modifier>(Parser<OmpStepComplexModifier>{}) ||
47603cbe426SKrzysztof Parzyszek     construct<OmpLinearClause::Modifier>(Parser<OmpStepSimpleModifier>{})))
47703cbe426SKrzysztof Parzyszek 
47852755ac2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpMapClause::Modifier>(
47952755ac2SKrzysztof Parzyszek     sourced(construct<OmpMapClause::Modifier>(Parser<OmpMapTypeModifier>{}) ||
48052755ac2SKrzysztof Parzyszek         construct<OmpMapClause::Modifier>(Parser<OmpMapper>{}) ||
48152755ac2SKrzysztof Parzyszek         construct<OmpMapClause::Modifier>(Parser<OmpIterator>{}) ||
48252755ac2SKrzysztof Parzyszek         construct<OmpMapClause::Modifier>(Parser<OmpMapType>{})))))
48352755ac2SKrzysztof Parzyszek 
484e79cd246SKrzysztof Parzyszek TYPE_PARSER(
485e79cd246SKrzysztof Parzyszek     sourced(construct<OmpOrderClause::Modifier>(Parser<OmpOrderModifier>{})))
486e79cd246SKrzysztof Parzyszek 
487bde79c0eSKrzysztof Parzyszek TYPE_PARSER(sourced(
488bde79c0eSKrzysztof Parzyszek     construct<OmpNumTasksClause::Modifier>(Parser<OmpPrescriptiveness>{})))
489bde79c0eSKrzysztof Parzyszek 
490e79cd246SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpReductionClause::Modifier>(sourced(
491e79cd246SKrzysztof Parzyszek     construct<OmpReductionClause::Modifier>(Parser<OmpReductionModifier>{}) ||
492e79cd246SKrzysztof Parzyszek     construct<OmpReductionClause::Modifier>(
493e79cd246SKrzysztof Parzyszek         Parser<OmpReductionIdentifier>{})))))
494e79cd246SKrzysztof Parzyszek 
495e79cd246SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpScheduleClause::Modifier>(sourced(
496e79cd246SKrzysztof Parzyszek     construct<OmpScheduleClause::Modifier>(Parser<OmpChunkModifier>{}) ||
497e79cd246SKrzysztof Parzyszek     construct<OmpScheduleClause::Modifier>(Parser<OmpOrderingModifier>{})))))
498e79cd246SKrzysztof Parzyszek 
49958f9c4fcSKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpTaskReductionClause::Modifier>(
50058f9c4fcSKrzysztof Parzyszek     Parser<OmpReductionIdentifier>{})))
50158f9c4fcSKrzysztof Parzyszek 
50252755ac2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpToClause::Modifier>(
50352755ac2SKrzysztof Parzyszek     sourced(construct<OmpToClause::Modifier>(Parser<OmpExpectation>{}) ||
50452755ac2SKrzysztof Parzyszek         construct<OmpToClause::Modifier>(Parser<OmpMapper>{}) ||
50552755ac2SKrzysztof Parzyszek         construct<OmpToClause::Modifier>(Parser<OmpIterator>{})))))
50652755ac2SKrzysztof Parzyszek 
507*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpWhenClause::Modifier>( //
508*15ab7be2SKrzysztof Parzyszek     Parser<OmpContextSelector>{})))
509*15ab7be2SKrzysztof Parzyszek 
510cfd67c21SKrzysztof Parzyszek // --- Parsers for clauses --------------------------------------------
511cfd67c21SKrzysztof Parzyszek 
51252755ac2SKrzysztof Parzyszek /// `MOBClause` is a clause that has a
51352755ac2SKrzysztof Parzyszek ///   std::tuple<Modifiers, OmpObjectList, bool>.
51452755ac2SKrzysztof Parzyszek /// Helper function to create a typical modifiers-objects clause, where the
51552755ac2SKrzysztof Parzyszek /// commas separating individual modifiers are optional, and the clause
51652755ac2SKrzysztof Parzyszek /// contains a bool member to indicate whether it was fully comma-separated
51752755ac2SKrzysztof Parzyszek /// or not.
51852755ac2SKrzysztof Parzyszek template <bool CommaSeparated, typename MOBClause>
51952755ac2SKrzysztof Parzyszek static inline MOBClause makeMobClause(
52052755ac2SKrzysztof Parzyszek     std::list<typename MOBClause::Modifier> &&mods, OmpObjectList &&objs) {
52152755ac2SKrzysztof Parzyszek   if (!mods.empty()) {
52252755ac2SKrzysztof Parzyszek     return MOBClause{std::move(mods), std::move(objs), CommaSeparated};
52352755ac2SKrzysztof Parzyszek   } else {
52452755ac2SKrzysztof Parzyszek     using ListTy = std::list<typename MOBClause::Modifier>;
52552755ac2SKrzysztof Parzyszek     return MOBClause{std::optional<ListTy>{}, std::move(objs), CommaSeparated};
52652755ac2SKrzysztof Parzyszek   }
52752755ac2SKrzysztof Parzyszek }
52852755ac2SKrzysztof Parzyszek 
529ea3534b3SKrzysztof Parzyszek // [5.0] 2.10.1 affinity([aff-modifier:] locator-list)
530ea3534b3SKrzysztof Parzyszek //              aff-modifier: interator-modifier
531ea3534b3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAffinityClause>(
53205096590SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpAffinityClause::Modifier>{}) / ":"),
53305096590SKrzysztof Parzyszek     Parser<OmpObjectList>{}))
534ea3534b3SKrzysztof Parzyszek 
53564ab3302SCarolineConcatto // 2.15.3.1 DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
536*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpDefaultClause::DataSharingAttribute>(
537608f4ae1SKrzysztof Parzyszek     "PRIVATE" >> pure(OmpDefaultClause::DataSharingAttribute::Private) ||
538608f4ae1SKrzysztof Parzyszek     "FIRSTPRIVATE" >>
539608f4ae1SKrzysztof Parzyszek         pure(OmpDefaultClause::DataSharingAttribute::Firstprivate) ||
540608f4ae1SKrzysztof Parzyszek     "SHARED" >> pure(OmpDefaultClause::DataSharingAttribute::Shared) ||
541608f4ae1SKrzysztof Parzyszek     "NONE" >> pure(OmpDefaultClause::DataSharingAttribute::None)))
54264ab3302SCarolineConcatto 
543*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpDefaultClause>(
544*15ab7be2SKrzysztof Parzyszek     construct<OmpDefaultClause>(
545*15ab7be2SKrzysztof Parzyszek         Parser<OmpDefaultClause::DataSharingAttribute>{}) ||
546*15ab7be2SKrzysztof Parzyszek     construct<OmpDefaultClause>(Parser<OmpDirectiveSpecification>{})))
547*15ab7be2SKrzysztof Parzyszek 
548c68c2899SKiran Chandramohan // 2.5 PROC_BIND (MASTER | CLOSE | PRIMARY | SPREAD)
54964ab3302SCarolineConcatto TYPE_PARSER(construct<OmpProcBindClause>(
550608f4ae1SKrzysztof Parzyszek     "CLOSE" >> pure(OmpProcBindClause::AffinityPolicy::Close) ||
551608f4ae1SKrzysztof Parzyszek     "MASTER" >> pure(OmpProcBindClause::AffinityPolicy::Master) ||
552608f4ae1SKrzysztof Parzyszek     "PRIMARY" >> pure(OmpProcBindClause::AffinityPolicy::Primary) ||
553608f4ae1SKrzysztof Parzyszek     "SPREAD" >> pure(OmpProcBindClause::AffinityPolicy::Spread)))
55464ab3302SCarolineConcatto 
555973fa983SKrzysztof Parzyszek TYPE_PARSER(construct<OmpMapClause>(
55652755ac2SKrzysztof Parzyszek     applyFunction<OmpMapClause>(makeMobClause<true>,
55752755ac2SKrzysztof Parzyszek         modifierList<OmpMapClause>(","_tok), Parser<OmpObjectList>{}) ||
55852755ac2SKrzysztof Parzyszek     applyFunction<OmpMapClause>(makeMobClause<false>,
55952755ac2SKrzysztof Parzyszek         modifierList<OmpMapClause>(maybe(","_tok)), Parser<OmpObjectList>{})))
56064ab3302SCarolineConcatto 
561e72f5738SDossay Oryspayev // [OpenMP 5.0]
562e72f5738SDossay Oryspayev // 2.19.7.2 defaultmap(implicit-behavior[:variable-category])
563e72f5738SDossay Oryspayev //  implicit-behavior -> ALLOC | TO | FROM | TOFROM | FIRSRTPRIVATE | NONE |
564e72f5738SDossay Oryspayev //  DEFAULT
5654c4a4134SKrzysztof Parzyszek //  variable-category -> ALL | SCALAR | AGGREGATE | ALLOCATABLE | POINTER
56664ab3302SCarolineConcatto TYPE_PARSER(construct<OmpDefaultmapClause>(
56764ab3302SCarolineConcatto     construct<OmpDefaultmapClause::ImplicitBehavior>(
568e72f5738SDossay Oryspayev         "ALLOC" >> pure(OmpDefaultmapClause::ImplicitBehavior::Alloc) ||
569e72f5738SDossay Oryspayev         "TO"_id >> pure(OmpDefaultmapClause::ImplicitBehavior::To) ||
570e72f5738SDossay Oryspayev         "FROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::From) ||
571e72f5738SDossay Oryspayev         "TOFROM" >> pure(OmpDefaultmapClause::ImplicitBehavior::Tofrom) ||
572e72f5738SDossay Oryspayev         "FIRSTPRIVATE" >>
573e72f5738SDossay Oryspayev             pure(OmpDefaultmapClause::ImplicitBehavior::Firstprivate) ||
574e72f5738SDossay Oryspayev         "NONE" >> pure(OmpDefaultmapClause::ImplicitBehavior::None) ||
575e72f5738SDossay Oryspayev         "DEFAULT" >> pure(OmpDefaultmapClause::ImplicitBehavior::Default)),
5764fc1141eSKrzysztof Parzyszek     maybe(":" >> nonemptyList(Parser<OmpDefaultmapClause::Modifier>{}))))
57764ab3302SCarolineConcatto 
578e79cd246SKrzysztof Parzyszek TYPE_PARSER(construct<OmpScheduleClause::Kind>(
579e79cd246SKrzysztof Parzyszek     "STATIC" >> pure(OmpScheduleClause::Kind::Static) ||
580e79cd246SKrzysztof Parzyszek     "DYNAMIC" >> pure(OmpScheduleClause::Kind::Dynamic) ||
581e79cd246SKrzysztof Parzyszek     "GUIDED" >> pure(OmpScheduleClause::Kind::Guided) ||
582e79cd246SKrzysztof Parzyszek     "AUTO" >> pure(OmpScheduleClause::Kind::Auto) ||
583e79cd246SKrzysztof Parzyszek     "RUNTIME" >> pure(OmpScheduleClause::Kind::Runtime)))
58464ab3302SCarolineConcatto 
585e79cd246SKrzysztof Parzyszek TYPE_PARSER(construct<OmpScheduleClause>(
586e79cd246SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpScheduleClause::Modifier>{}) / ":"),
587e79cd246SKrzysztof Parzyszek     Parser<OmpScheduleClause::Kind>{}, maybe("," >> scalarIntExpr)))
58864ab3302SCarolineConcatto 
589d9ff6703SSesha Kalyur // device([ device-modifier :] scalar-integer-expression)
590d9ff6703SSesha Kalyur TYPE_PARSER(construct<OmpDeviceClause>(
59105096590SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpDeviceClause::Modifier>{}) / ":"),
592d9ff6703SSesha Kalyur     scalarIntExpr))
593d9ff6703SSesha Kalyur 
594849c4402SAkash Banerjee // device_type(any | host | nohost)
595849c4402SAkash Banerjee TYPE_PARSER(construct<OmpDeviceTypeClause>(
596608f4ae1SKrzysztof Parzyszek     "ANY" >> pure(OmpDeviceTypeClause::DeviceTypeDescription::Any) ||
597608f4ae1SKrzysztof Parzyszek     "HOST" >> pure(OmpDeviceTypeClause::DeviceTypeDescription::Host) ||
598608f4ae1SKrzysztof Parzyszek     "NOHOST" >> pure(OmpDeviceTypeClause::DeviceTypeDescription::Nohost)))
599849c4402SAkash Banerjee 
60064ab3302SCarolineConcatto // 2.12 IF (directive-name-modifier: scalar-logical-expr)
60164ab3302SCarolineConcatto TYPE_PARSER(construct<OmpIfClause>(
60233faa828SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpIfClause::Modifier>{}) / ":"),
60364ab3302SCarolineConcatto     scalarLogicalExpr))
60464ab3302SCarolineConcatto 
60564ab3302SCarolineConcatto TYPE_PARSER(construct<OmpReductionClause>(
6064fc1141eSKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpReductionClause::Modifier>{}) / ":"),
6074fc1141eSKrzysztof Parzyszek     Parser<OmpObjectList>{}))
60864ab3302SCarolineConcatto 
6096a3c4a40SNimish Mishra // OMP 5.0 2.19.5.6 IN_REDUCTION (reduction-identifier: variable-name-list)
6106a3c4a40SNimish Mishra TYPE_PARSER(construct<OmpInReductionClause>(
61158f9c4fcSKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpInReductionClause::Modifier>{}) / ":"),
61258f9c4fcSKrzysztof Parzyszek     Parser<OmpObjectList>{}))
61358f9c4fcSKrzysztof Parzyszek 
61458f9c4fcSKrzysztof Parzyszek TYPE_PARSER(construct<OmpTaskReductionClause>(
61558f9c4fcSKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpTaskReductionClause::Modifier>{}) / ":"),
61658f9c4fcSKrzysztof Parzyszek     Parser<OmpObjectList>{}))
6176a3c4a40SNimish Mishra 
6186311ab21SEthan Luis McDonough // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
6196311ab21SEthan Luis McDonough // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier
6206311ab21SEthan Luis McDonough //                                   [, allocate-modifier] :]
6216311ab21SEthan Luis McDonough //                                   variable-name-list)
6226311ab21SEthan Luis McDonough //                allocate-modifier -> allocator | align
623e355f85bSIrina Dobrescu TYPE_PARSER(construct<OmpAllocateClause>(
624cdbd2287SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpAllocateClause::Modifier>{}) / ":"),
625e355f85bSIrina Dobrescu     Parser<OmpObjectList>{}))
626e355f85bSIrina Dobrescu 
627f87737f3SKrzysztof Parzyszek // iteration-offset -> +/- non-negative-constant-expr
628f87737f3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpIterationOffset>(
629f87737f3SKrzysztof Parzyszek     Parser<DefinedOperator>{}, scalarIntConstantExpr))
630f87737f3SKrzysztof Parzyszek 
631f87737f3SKrzysztof Parzyszek // iteration -> iteration-variable [+/- nonnegative-scalar-integer-constant]
632f87737f3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpIteration>(name, maybe(Parser<OmpIterationOffset>{})))
633f87737f3SKrzysztof Parzyszek 
634f87737f3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpIterationVector>(nonemptyList(Parser<OmpIteration>{})))
635f87737f3SKrzysztof Parzyszek 
636f87737f3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpDoacross>(
637f87737f3SKrzysztof Parzyszek     construct<OmpDoacross>(construct<OmpDoacross::Sink>(
638f87737f3SKrzysztof Parzyszek         "SINK"_tok >> ":"_tok >> Parser<OmpIterationVector>{})) ||
639f87737f3SKrzysztof Parzyszek     construct<OmpDoacross>(construct<OmpDoacross::Source>("SOURCE"_tok))))
64064ab3302SCarolineConcatto 
64164ab3302SCarolineConcatto TYPE_CONTEXT_PARSER("Omp Depend clause"_en_US,
64264ab3302SCarolineConcatto     construct<OmpDependClause>(
643bde79c0eSKrzysztof Parzyszek         // Try to parse OmpDoacross first, because TaskDep will succeed on
644bde79c0eSKrzysztof Parzyszek         // "sink: xxx", interpreting it to not have any modifiers, and "sink"
645bde79c0eSKrzysztof Parzyszek         // being an OmpObject. Parsing of the TaskDep variant will stop right
646bde79c0eSKrzysztof Parzyszek         // after the "sink", leaving the ": xxx" unvisited.
647bde79c0eSKrzysztof Parzyszek         construct<OmpDependClause>(Parser<OmpDoacross>{}) ||
648bde79c0eSKrzysztof Parzyszek         // Parse TaskDep after Doacross.
649f87737f3SKrzysztof Parzyszek         construct<OmpDependClause>(construct<OmpDependClause::TaskDep>(
650bde79c0eSKrzysztof Parzyszek             maybe(nonemptyList(Parser<OmpDependClause::TaskDep::Modifier>{}) /
651bde79c0eSKrzysztof Parzyszek                 ": "),
652bde79c0eSKrzysztof Parzyszek             Parser<OmpObjectList>{}))))
653f87737f3SKrzysztof Parzyszek 
654f87737f3SKrzysztof Parzyszek TYPE_CONTEXT_PARSER("Omp Doacross clause"_en_US,
655f87737f3SKrzysztof Parzyszek     construct<OmpDoacrossClause>(Parser<OmpDoacross>{}))
65664ab3302SCarolineConcatto 
6571c6ec29bSKrzysztof Parzyszek TYPE_PARSER(construct<OmpFromClause>(
65852755ac2SKrzysztof Parzyszek     applyFunction<OmpFromClause>(makeMobClause<true>,
65952755ac2SKrzysztof Parzyszek         modifierList<OmpFromClause>(","_tok), Parser<OmpObjectList>{}) ||
66052755ac2SKrzysztof Parzyszek     applyFunction<OmpFromClause>(makeMobClause<false>,
66152755ac2SKrzysztof Parzyszek         modifierList<OmpFromClause>(maybe(","_tok)), Parser<OmpObjectList>{})))
6621c6ec29bSKrzysztof Parzyszek 
6631c6ec29bSKrzysztof Parzyszek TYPE_PARSER(construct<OmpToClause>(
66452755ac2SKrzysztof Parzyszek     applyFunction<OmpToClause>(makeMobClause<true>,
66552755ac2SKrzysztof Parzyszek         modifierList<OmpToClause>(","_tok), Parser<OmpObjectList>{}) ||
66652755ac2SKrzysztof Parzyszek     applyFunction<OmpToClause>(makeMobClause<false>,
66752755ac2SKrzysztof Parzyszek         modifierList<OmpToClause>(maybe(","_tok)), Parser<OmpObjectList>{})))
6681c6ec29bSKrzysztof Parzyszek 
66903cbe426SKrzysztof Parzyszek OmpLinearClause makeLinearFromOldSyntax(OmpLinearClause::Modifier &&lm,
67003cbe426SKrzysztof Parzyszek     OmpObjectList &&objs, std::optional<OmpLinearClause::Modifier> &&ssm) {
67103cbe426SKrzysztof Parzyszek   std::list<OmpLinearClause::Modifier> mods;
67203cbe426SKrzysztof Parzyszek   mods.emplace_back(std::move(lm));
67303cbe426SKrzysztof Parzyszek   if (ssm) {
67403cbe426SKrzysztof Parzyszek     mods.emplace_back(std::move(*ssm));
67503cbe426SKrzysztof Parzyszek   }
67603cbe426SKrzysztof Parzyszek   return OmpLinearClause{std::move(objs),
67703cbe426SKrzysztof Parzyszek       mods.empty() ? decltype(mods){} : std::move(mods),
67803cbe426SKrzysztof Parzyszek       /*PostModified=*/false};
67903cbe426SKrzysztof Parzyszek }
68003cbe426SKrzysztof Parzyszek 
68103cbe426SKrzysztof Parzyszek TYPE_PARSER(
68203cbe426SKrzysztof Parzyszek     // Parse the "modifier(x)" first, because syntacticaly it will match
68303cbe426SKrzysztof Parzyszek     // an array element (i.e. a list item).
68403cbe426SKrzysztof Parzyszek     // LINEAR(linear-modifier(list) [: step-simple-modifier])
68503cbe426SKrzysztof Parzyszek     construct<OmpLinearClause>( //
68603cbe426SKrzysztof Parzyszek         applyFunction<OmpLinearClause>(makeLinearFromOldSyntax,
68703cbe426SKrzysztof Parzyszek             SpecificModifierParser<OmpLinearModifier, OmpLinearClause>{},
68803cbe426SKrzysztof Parzyszek             parenthesized(Parser<OmpObjectList>{}),
68903cbe426SKrzysztof Parzyszek             maybe(":"_tok >> SpecificModifierParser<OmpStepSimpleModifier,
69003cbe426SKrzysztof Parzyszek                                  OmpLinearClause>{}))) ||
69103cbe426SKrzysztof Parzyszek     // LINEAR(list [: modifiers])
69203cbe426SKrzysztof Parzyszek     construct<OmpLinearClause>( //
69303cbe426SKrzysztof Parzyszek         Parser<OmpObjectList>{},
69403cbe426SKrzysztof Parzyszek         maybe(":"_tok >> nonemptyList(Parser<OmpLinearClause::Modifier>{})),
69503cbe426SKrzysztof Parzyszek         /*PostModified=*/pure(true)))
69664ab3302SCarolineConcatto 
6970653698dSNimishMishra // OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
6980653698dSNimishMishra TYPE_PARSER(construct<OmpDetachClause>(Parser<OmpObject>{}))
6990653698dSNimishMishra 
70064ab3302SCarolineConcatto // 2.8.1 ALIGNED (list: alignment)
70105096590SKrzysztof Parzyszek TYPE_PARSER(construct<OmpAlignedClause>(Parser<OmpObjectList>{},
70205096590SKrzysztof Parzyszek     maybe(":" >> nonemptyList(Parser<OmpAlignedClause::Modifier>{}))))
70364ab3302SCarolineConcatto 
704f87737f3SKrzysztof Parzyszek TYPE_PARSER(construct<OmpUpdateClause>(
705f87737f3SKrzysztof Parzyszek     construct<OmpUpdateClause>(Parser<OmpDependenceType>{}) ||
706f87737f3SKrzysztof Parzyszek     construct<OmpUpdateClause>(Parser<OmpTaskDependenceType>{})))
707f87737f3SKrzysztof Parzyszek 
708e79cd246SKrzysztof Parzyszek TYPE_PARSER(construct<OmpOrderClause>(
709e79cd246SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpOrderClause::Modifier>{}) / ":"),
710e79cd246SKrzysztof Parzyszek     "CONCURRENT" >> pure(OmpOrderClause::Ordering::Concurrent)))
711a7d352c7SKavitha Natarajan 
712*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpMatchClause>(
713*15ab7be2SKrzysztof Parzyszek     Parser<traits::OmpContextSelectorSpecification>{}))
714*15ab7be2SKrzysztof Parzyszek 
715*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpOtherwiseClause>(
716*15ab7be2SKrzysztof Parzyszek     maybe(sourced(Parser<OmpDirectiveSpecification>{}))))
717*15ab7be2SKrzysztof Parzyszek 
718*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(construct<OmpWhenClause>(
719*15ab7be2SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpWhenClause::Modifier>{}) / ":"),
720*15ab7be2SKrzysztof Parzyszek     maybe(sourced(Parser<OmpDirectiveSpecification>{}))))
721*15ab7be2SKrzysztof Parzyszek 
7225621929fSKiran Chandramohan // OMP 5.2 12.6.1 grainsize([ prescriptiveness :] scalar-integer-expression)
7235621929fSKiran Chandramohan TYPE_PARSER(construct<OmpGrainsizeClause>(
724bde79c0eSKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpGrainsizeClause::Modifier>{}) / ":"),
7255621929fSKiran Chandramohan     scalarIntExpr))
7265621929fSKiran Chandramohan 
7275621929fSKiran Chandramohan // OMP 5.2 12.6.2 num_tasks([ prescriptiveness :] scalar-integer-expression)
7285621929fSKiran Chandramohan TYPE_PARSER(construct<OmpNumTasksClause>(
729bde79c0eSKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpNumTasksClause::Modifier>{}) / ":"),
7305621929fSKiran Chandramohan     scalarIntExpr))
7315621929fSKiran Chandramohan 
73264ab3302SCarolineConcatto TYPE_PARSER(
73364ab3302SCarolineConcatto     construct<OmpObject>(designator) || construct<OmpObject>("/" >> name / "/"))
73464ab3302SCarolineConcatto 
735f9824439SKrzysztof Parzyszek // OMP 5.0 2.19.4.5 LASTPRIVATE ([lastprivate-modifier :] list)
736f9824439SKrzysztof Parzyszek TYPE_PARSER(construct<OmpLastprivateClause>(
73733faa828SKrzysztof Parzyszek     maybe(nonemptyList(Parser<OmpLastprivateClause::Modifier>{}) / ":"),
738f9824439SKrzysztof Parzyszek     Parser<OmpObjectList>{}))
739f9824439SKrzysztof Parzyszek 
74050e73aeeSKareem Ergawy // OMP 5.2 11.7.1 BIND ( PARALLEL | TEAMS | THREAD )
74150e73aeeSKareem Ergawy TYPE_PARSER(construct<OmpBindClause>(
742608f4ae1SKrzysztof Parzyszek     "PARALLEL" >> pure(OmpBindClause::Binding::Parallel) ||
743608f4ae1SKrzysztof Parzyszek     "TEAMS" >> pure(OmpBindClause::Binding::Teams) ||
744608f4ae1SKrzysztof Parzyszek     "THREAD" >> pure(OmpBindClause::Binding::Thread)))
74550e73aeeSKareem Ergawy 
7464df366cdSMats Petersson TYPE_PARSER(construct<OmpAlignClause>(scalarIntExpr))
7474df366cdSMats Petersson 
74875e6d0ebSMats Petersson TYPE_PARSER(construct<OmpAtClause>(
74975e6d0ebSMats Petersson     "EXECUTION" >> pure(OmpAtClause::ActionTime::Execution) ||
75075e6d0ebSMats Petersson     "COMPILATION" >> pure(OmpAtClause::ActionTime::Compilation)))
75175e6d0ebSMats Petersson 
75275e6d0ebSMats Petersson TYPE_PARSER(construct<OmpSeverityClause>(
75375e6d0ebSMats Petersson     "FATAL" >> pure(OmpSeverityClause::Severity::Fatal) ||
75475e6d0ebSMats Petersson     "WARNING" >> pure(OmpSeverityClause::Severity::Warning)))
75575e6d0ebSMats Petersson 
75675e6d0ebSMats Petersson TYPE_PARSER(construct<OmpMessageClause>(expr))
75775e6d0ebSMats Petersson 
758d95d3d2aSsameeran joshi TYPE_PARSER(
759d95d3d2aSsameeran joshi     "ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) ||
760d95d3d2aSsameeran joshi     "ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) ||
761ea3534b3SKrzysztof Parzyszek     "AFFINITY" >> construct<OmpClause>(construct<OmpClause::Affinity>(
762ea3534b3SKrzysztof Parzyszek                       parenthesized(Parser<OmpAffinityClause>{}))) ||
7634df366cdSMats Petersson     "ALIGN" >> construct<OmpClause>(construct<OmpClause::Align>(
7644df366cdSMats Petersson                    parenthesized(Parser<OmpAlignClause>{}))) ||
7656bd0a445SValentin Clement     "ALIGNED" >> construct<OmpClause>(construct<OmpClause::Aligned>(
7666bd0a445SValentin Clement                      parenthesized(Parser<OmpAlignedClause>{}))) ||
767442aac5dSsameeran joshi     "ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>(
768442aac5dSsameeran joshi                       parenthesized(Parser<OmpAllocateClause>{}))) ||
769c9e967afSIrina Dobrescu     "ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>(
770c9e967afSIrina Dobrescu                        parenthesized(scalarIntExpr))) ||
77175e6d0ebSMats Petersson     "AT" >> construct<OmpClause>(construct<OmpClause::At>(
77275e6d0ebSMats Petersson                 parenthesized(Parser<OmpAtClause>{}))) ||
773d5fb5960SSergio Afonso     "ATOMIC_DEFAULT_MEM_ORDER" >>
774d5fb5960SSergio Afonso         construct<OmpClause>(construct<OmpClause::AtomicDefaultMemOrder>(
775d5fb5960SSergio Afonso             parenthesized(Parser<OmpAtomicDefaultMemOrderClause>{}))) ||
77650e73aeeSKareem Ergawy     "BIND" >> construct<OmpClause>(construct<OmpClause::Bind>(
77750e73aeeSKareem Ergawy                   parenthesized(Parser<OmpBindClause>{}))) ||
77864ab3302SCarolineConcatto     "COLLAPSE" >> construct<OmpClause>(construct<OmpClause::Collapse>(
77964ab3302SCarolineConcatto                       parenthesized(scalarIntConstantExpr))) ||
78064ab3302SCarolineConcatto     "COPYIN" >> construct<OmpClause>(construct<OmpClause::Copyin>(
78164ab3302SCarolineConcatto                     parenthesized(Parser<OmpObjectList>{}))) ||
78264ab3302SCarolineConcatto     "COPYPRIVATE" >> construct<OmpClause>(construct<OmpClause::Copyprivate>(
78364ab3302SCarolineConcatto                          (parenthesized(Parser<OmpObjectList>{})))) ||
784f72c384bSsameeran joshi     "DEFAULT"_id >> construct<OmpClause>(construct<OmpClause::Default>(
785f72c384bSsameeran joshi                         parenthesized(Parser<OmpDefaultClause>{}))) ||
7866bd0a445SValentin Clement     "DEFAULTMAP" >> construct<OmpClause>(construct<OmpClause::Defaultmap>(
7876bd0a445SValentin Clement                         parenthesized(Parser<OmpDefaultmapClause>{}))) ||
7886bd0a445SValentin Clement     "DEPEND" >> construct<OmpClause>(construct<OmpClause::Depend>(
7896bd0a445SValentin Clement                     parenthesized(Parser<OmpDependClause>{}))) ||
790c478aab6SKrzysztof Parzyszek     "DESTROY" >>
791c478aab6SKrzysztof Parzyszek         construct<OmpClause>(construct<OmpClause::Destroy>(maybe(parenthesized(
792c478aab6SKrzysztof Parzyszek             construct<OmpDestroyClause>(Parser<OmpObject>{}))))) ||
79364ab3302SCarolineConcatto     "DEVICE" >> construct<OmpClause>(construct<OmpClause::Device>(
794d9ff6703SSesha Kalyur                     parenthesized(Parser<OmpDeviceClause>{}))) ||
795849c4402SAkash Banerjee     "DEVICE_TYPE" >> construct<OmpClause>(construct<OmpClause::DeviceType>(
796849c4402SAkash Banerjee                          parenthesized(Parser<OmpDeviceTypeClause>{}))) ||
79764ab3302SCarolineConcatto     "DIST_SCHEDULE" >>
7981a6f4399Ssameeran joshi         construct<OmpClause>(construct<OmpClause::DistSchedule>(
79964ab3302SCarolineConcatto             parenthesized("STATIC" >> maybe("," >> scalarIntExpr)))) ||
800f87737f3SKrzysztof Parzyszek     "DOACROSS" >>
801f87737f3SKrzysztof Parzyszek         construct<OmpClause>(parenthesized(Parser<OmpDoacrossClause>{})) ||
802d5fb5960SSergio Afonso     "DYNAMIC_ALLOCATORS" >>
803d5fb5960SSergio Afonso         construct<OmpClause>(construct<OmpClause::DynamicAllocators>()) ||
8048840eb3fSShraiysh     "ENTER" >> construct<OmpClause>(construct<OmpClause::Enter>(
8058840eb3fSShraiysh                    parenthesized(Parser<OmpObjectList>{}))) ||
806e67e09a7SAnchu Rajendran S     "EXCLUSIVE" >> construct<OmpClause>(construct<OmpClause::Exclusive>(
807e67e09a7SAnchu Rajendran S                        parenthesized(Parser<OmpObjectList>{}))) ||
8086658e1a3SAnchu Rajendran S     "FILTER" >> construct<OmpClause>(construct<OmpClause::Filter>(
8096658e1a3SAnchu Rajendran S                     parenthesized(scalarIntExpr))) ||
81064ab3302SCarolineConcatto     "FINAL" >> construct<OmpClause>(construct<OmpClause::Final>(
81164ab3302SCarolineConcatto                    parenthesized(scalarLogicalExpr))) ||
81264ab3302SCarolineConcatto     "FIRSTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Firstprivate>(
81364ab3302SCarolineConcatto                           parenthesized(Parser<OmpObjectList>{}))) ||
81464ab3302SCarolineConcatto     "FROM" >> construct<OmpClause>(construct<OmpClause::From>(
8151c6ec29bSKrzysztof Parzyszek                   parenthesized(Parser<OmpFromClause>{}))) ||
8161c6ec29bSKrzysztof Parzyszek     "FULL" >> construct<OmpClause>(construct<OmpClause::Full>()) ||
81764ab3302SCarolineConcatto     "GRAINSIZE" >> construct<OmpClause>(construct<OmpClause::Grainsize>(
8185621929fSKiran Chandramohan                        parenthesized(Parser<OmpGrainsizeClause>{}))) ||
81980b571c6SRaghu Maddhipatla     "HAS_DEVICE_ADDR" >>
82080b571c6SRaghu Maddhipatla         construct<OmpClause>(construct<OmpClause::HasDeviceAddr>(
82180b571c6SRaghu Maddhipatla             parenthesized(Parser<OmpObjectList>{}))) ||
82242ecf188Ssameeran joshi     "HINT" >> construct<OmpClause>(
82342ecf188Ssameeran joshi                   construct<OmpClause::Hint>(parenthesized(constantExpr))) ||
8246bd0a445SValentin Clement     "IF" >> construct<OmpClause>(construct<OmpClause::If>(
8256bd0a445SValentin Clement                 parenthesized(Parser<OmpIfClause>{}))) ||
82664ab3302SCarolineConcatto     "INBRANCH" >> construct<OmpClause>(construct<OmpClause::Inbranch>()) ||
827e67e09a7SAnchu Rajendran S     "INCLUSIVE" >> construct<OmpClause>(construct<OmpClause::Inclusive>(
828e67e09a7SAnchu Rajendran S                        parenthesized(Parser<OmpObjectList>{}))) ||
82964ab3302SCarolineConcatto     "IS_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::IsDevicePtr>(
83080b571c6SRaghu Maddhipatla                            parenthesized(Parser<OmpObjectList>{}))) ||
83164ab3302SCarolineConcatto     "LASTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Lastprivate>(
832f9824439SKrzysztof Parzyszek                          parenthesized(Parser<OmpLastprivateClause>{}))) ||
8336bd0a445SValentin Clement     "LINEAR" >> construct<OmpClause>(construct<OmpClause::Linear>(
8346bd0a445SValentin Clement                     parenthesized(Parser<OmpLinearClause>{}))) ||
83564ab3302SCarolineConcatto     "LINK" >> construct<OmpClause>(construct<OmpClause::Link>(
83664ab3302SCarolineConcatto                   parenthesized(Parser<OmpObjectList>{}))) ||
8376bd0a445SValentin Clement     "MAP" >> construct<OmpClause>(construct<OmpClause::Map>(
8386bd0a445SValentin Clement                  parenthesized(Parser<OmpMapClause>{}))) ||
839*15ab7be2SKrzysztof Parzyszek     "MATCH" >> construct<OmpClause>(construct<OmpClause::Match>(
840*15ab7be2SKrzysztof Parzyszek                    parenthesized(Parser<OmpMatchClause>{}))) ||
84164ab3302SCarolineConcatto     "MERGEABLE" >> construct<OmpClause>(construct<OmpClause::Mergeable>()) ||
84275e6d0ebSMats Petersson     "MESSAGE" >> construct<OmpClause>(construct<OmpClause::Message>(
84375e6d0ebSMats Petersson                      parenthesized(Parser<OmpMessageClause>{}))) ||
8448035d38dSMats Petersson     "NOCONTEXT" >> construct<OmpClause>(construct<OmpClause::Nocontext>(
8458035d38dSMats Petersson                        parenthesized(scalarLogicalExpr))) ||
84664ab3302SCarolineConcatto     "NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) ||
847b9a8f34dSArnamoy Bhattacharyya     "NONTEMPORAL" >> construct<OmpClause>(construct<OmpClause::Nontemporal>(
848b9a8f34dSArnamoy Bhattacharyya                          parenthesized(nonemptyList(name)))) ||
84964ab3302SCarolineConcatto     "NOTINBRANCH" >>
85064ab3302SCarolineConcatto         construct<OmpClause>(construct<OmpClause::Notinbranch>()) ||
8518035d38dSMats Petersson     "NOVARIANTS" >> construct<OmpClause>(construct<OmpClause::Novariants>(
8528035d38dSMats Petersson                         parenthesized(scalarLogicalExpr))) ||
853e282ae57Ssameeran joshi     "NOWAIT" >> construct<OmpClause>(construct<OmpClause::Nowait>()) ||
85464ab3302SCarolineConcatto     "NUM_TASKS" >> construct<OmpClause>(construct<OmpClause::NumTasks>(
8555621929fSKiran Chandramohan                        parenthesized(Parser<OmpNumTasksClause>{}))) ||
85664ab3302SCarolineConcatto     "NUM_TEAMS" >> construct<OmpClause>(construct<OmpClause::NumTeams>(
85764ab3302SCarolineConcatto                        parenthesized(scalarIntExpr))) ||
85864ab3302SCarolineConcatto     "NUM_THREADS" >> construct<OmpClause>(construct<OmpClause::NumThreads>(
85964ab3302SCarolineConcatto                          parenthesized(scalarIntExpr))) ||
8607c9404c2SIvan R. Ivanov     "OMPX_BARE" >> construct<OmpClause>(construct<OmpClause::OmpxBare>()) ||
861a7d352c7SKavitha Natarajan     "ORDER" >> construct<OmpClause>(construct<OmpClause::Order>(
862a7d352c7SKavitha Natarajan                    parenthesized(Parser<OmpOrderClause>{}))) ||
86364ab3302SCarolineConcatto     "ORDERED" >> construct<OmpClause>(construct<OmpClause::Ordered>(
86464ab3302SCarolineConcatto                      maybe(parenthesized(scalarIntConstantExpr)))) ||
865*15ab7be2SKrzysztof Parzyszek     "OTHERWISE" >> construct<OmpClause>(construct<OmpClause::Otherwise>(
866*15ab7be2SKrzysztof Parzyszek                        maybe(parenthesized(Parser<OmpOtherwiseClause>{})))) ||
86784bf4b7cSAbid Malik     "PARTIAL" >> construct<OmpClause>(construct<OmpClause::Partial>(
86884bf4b7cSAbid Malik                      maybe(parenthesized(scalarIntConstantExpr)))) ||
86964ab3302SCarolineConcatto     "PRIORITY" >> construct<OmpClause>(construct<OmpClause::Priority>(
87064ab3302SCarolineConcatto                       parenthesized(scalarIntExpr))) ||
87164ab3302SCarolineConcatto     "PRIVATE" >> construct<OmpClause>(construct<OmpClause::Private>(
87264ab3302SCarolineConcatto                      parenthesized(Parser<OmpObjectList>{}))) ||
87334958d11Ssameeran joshi     "PROC_BIND" >> construct<OmpClause>(construct<OmpClause::ProcBind>(
87434958d11Ssameeran joshi                        parenthesized(Parser<OmpProcBindClause>{}))) ||
87558f9c4fcSKrzysztof Parzyszek     "REDUCTION"_id >> construct<OmpClause>(construct<OmpClause::Reduction>(
8764d0aad96SValentin Clement                           parenthesized(Parser<OmpReductionClause>{}))) ||
8776a3c4a40SNimish Mishra     "IN_REDUCTION" >> construct<OmpClause>(construct<OmpClause::InReduction>(
8786a3c4a40SNimish Mishra                           parenthesized(Parser<OmpInReductionClause>{}))) ||
8790653698dSNimishMishra     "DETACH" >> construct<OmpClause>(construct<OmpClause::Detach>(
8800653698dSNimishMishra                     parenthesized(Parser<OmpDetachClause>{}))) ||
8816280bc1cSsameeran joshi     "TASK_REDUCTION" >>
8826280bc1cSsameeran joshi         construct<OmpClause>(construct<OmpClause::TaskReduction>(
88358f9c4fcSKrzysztof Parzyszek             parenthesized(Parser<OmpTaskReductionClause>{}))) ||
884d95d3d2aSsameeran joshi     "RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) ||
885d95d3d2aSsameeran joshi     "RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
886d5fb5960SSergio Afonso     "REVERSE_OFFLOAD" >>
887d5fb5960SSergio Afonso         construct<OmpClause>(construct<OmpClause::ReverseOffload>()) ||
88864ab3302SCarolineConcatto     "SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>(
88964ab3302SCarolineConcatto                      parenthesized(scalarIntConstantExpr))) ||
8906bd0a445SValentin Clement     "SCHEDULE" >> construct<OmpClause>(construct<OmpClause::Schedule>(
8916bd0a445SValentin Clement                       parenthesized(Parser<OmpScheduleClause>{}))) ||
892d95d3d2aSsameeran joshi     "SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) ||
89375e6d0ebSMats Petersson     "SEVERITY" >> construct<OmpClause>(construct<OmpClause::Severity>(
89475e6d0ebSMats Petersson                       parenthesized(Parser<OmpSeverityClause>{}))) ||
89564ab3302SCarolineConcatto     "SHARED" >> construct<OmpClause>(construct<OmpClause::Shared>(
89664ab3302SCarolineConcatto                     parenthesized(Parser<OmpObjectList>{}))) ||
89764ab3302SCarolineConcatto     "SIMD"_id >> construct<OmpClause>(construct<OmpClause::Simd>()) ||
89864ab3302SCarolineConcatto     "SIMDLEN" >> construct<OmpClause>(construct<OmpClause::Simdlen>(
89964ab3302SCarolineConcatto                      parenthesized(scalarIntConstantExpr))) ||
9008feb5d41SAbid Malik     "SIZES" >> construct<OmpClause>(construct<OmpClause::Sizes>(
9018feb5d41SAbid Malik                    parenthesized(nonemptyList(scalarIntExpr)))) ||
9025b03efb8SMichael Kruse     "PERMUTATION" >> construct<OmpClause>(construct<OmpClause::Permutation>(
9035b03efb8SMichael Kruse                          parenthesized(nonemptyList(scalarIntExpr)))) ||
90464ab3302SCarolineConcatto     "THREADS" >> construct<OmpClause>(construct<OmpClause::Threads>()) ||
90564ab3302SCarolineConcatto     "THREAD_LIMIT" >> construct<OmpClause>(construct<OmpClause::ThreadLimit>(
90664ab3302SCarolineConcatto                           parenthesized(scalarIntExpr))) ||
90764ab3302SCarolineConcatto     "TO" >> construct<OmpClause>(construct<OmpClause::To>(
9081c6ec29bSKrzysztof Parzyszek                 parenthesized(Parser<OmpToClause>{}))) ||
90964ab3302SCarolineConcatto     "USE_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::UseDevicePtr>(
910d6ef90f6SRaghu Maddhipatla                             parenthesized(Parser<OmpObjectList>{}))) ||
911f85a8456SRaghu Maddhipatla     "USE_DEVICE_ADDR" >>
912f85a8456SRaghu Maddhipatla         construct<OmpClause>(construct<OmpClause::UseDeviceAddr>(
913f85a8456SRaghu Maddhipatla             parenthesized(Parser<OmpObjectList>{}))) ||
914d5fb5960SSergio Afonso     "UNIFIED_ADDRESS" >>
915d5fb5960SSergio Afonso         construct<OmpClause>(construct<OmpClause::UnifiedAddress>()) ||
916d5fb5960SSergio Afonso     "UNIFIED_SHARED_MEMORY" >>
917d5fb5960SSergio Afonso         construct<OmpClause>(construct<OmpClause::UnifiedSharedMemory>()) ||
91864ab3302SCarolineConcatto     "UNIFORM" >> construct<OmpClause>(construct<OmpClause::Uniform>(
91964ab3302SCarolineConcatto                      parenthesized(nonemptyList(name)))) ||
920c478aab6SKrzysztof Parzyszek     "UNTIED" >> construct<OmpClause>(construct<OmpClause::Untied>()) ||
921c478aab6SKrzysztof Parzyszek     "UPDATE" >> construct<OmpClause>(construct<OmpClause::Update>(
922*15ab7be2SKrzysztof Parzyszek                     parenthesized(Parser<OmpUpdateClause>{}))) ||
923*15ab7be2SKrzysztof Parzyszek     "WHEN" >> construct<OmpClause>(construct<OmpClause::When>(
924*15ab7be2SKrzysztof Parzyszek                   parenthesized(Parser<OmpWhenClause>{}))))
92564ab3302SCarolineConcatto 
92664ab3302SCarolineConcatto // [Clause, [Clause], ...]
92764ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpClauseList>(
92864ab3302SCarolineConcatto     many(maybe(","_tok) >> sourced(Parser<OmpClause>{})))))
92964ab3302SCarolineConcatto 
930df859f90SKrzysztof Parzyszek // 2.1 (variable | /common-block/ | array-sections)
93164ab3302SCarolineConcatto TYPE_PARSER(construct<OmpObjectList>(nonemptyList(Parser<OmpObject>{})))
93264ab3302SCarolineConcatto 
933df859f90SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpErrorDirective>(
934df859f90SKrzysztof Parzyszek     verbatim("ERROR"_tok), Parser<OmpClauseList>{})))
935df859f90SKrzysztof Parzyszek 
936df859f90SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpNothingDirective>("NOTHING" >> ok)))
937df859f90SKrzysztof Parzyszek 
938df859f90SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OpenMPUtilityConstruct>(
939df859f90SKrzysztof Parzyszek     sourced(construct<OpenMPUtilityConstruct>(
940df859f90SKrzysztof Parzyszek         sourced(Parser<OmpErrorDirective>{}))) ||
941df859f90SKrzysztof Parzyszek     sourced(construct<OpenMPUtilityConstruct>(
942df859f90SKrzysztof Parzyszek         sourced(Parser<OmpNothingDirective>{}))))))
943df859f90SKrzysztof Parzyszek 
944*15ab7be2SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OmpMetadirectiveDirective>(
945*15ab7be2SKrzysztof Parzyszek     "METADIRECTIVE" >> Parser<OmpClauseList>{})))
946*15ab7be2SKrzysztof Parzyszek 
94764ab3302SCarolineConcatto // Omp directives enclosing do loop
94864ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpLoopDirective>(first(
94964ab3302SCarolineConcatto     "DISTRIBUTE PARALLEL DO SIMD" >>
9502ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_distribute_parallel_do_simd),
95164ab3302SCarolineConcatto     "DISTRIBUTE PARALLEL DO" >>
9522ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_distribute_parallel_do),
9532ddba308SValentin Clement     "DISTRIBUTE SIMD" >> pure(llvm::omp::Directive::OMPD_distribute_simd),
9542ddba308SValentin Clement     "DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_distribute),
9552ddba308SValentin Clement     "DO SIMD" >> pure(llvm::omp::Directive::OMPD_do_simd),
9562ddba308SValentin Clement     "DO" >> pure(llvm::omp::Directive::OMPD_do),
957826bde5dSAnchu Rajendran S     "LOOP" >> pure(llvm::omp::Directive::OMPD_loop),
9586658e1a3SAnchu Rajendran S     "MASKED TASKLOOP SIMD" >>
9596658e1a3SAnchu Rajendran S         pure(llvm::omp::Directive::OMPD_masked_taskloop_simd),
9606658e1a3SAnchu Rajendran S     "MASKED TASKLOOP" >> pure(llvm::omp::Directive::OMPD_masked_taskloop),
961092a819eSKiran Chandramohan     "MASTER TASKLOOP SIMD" >>
962092a819eSKiran Chandramohan         pure(llvm::omp::Directive::OMPD_master_taskloop_simd),
963092a819eSKiran Chandramohan     "MASTER TASKLOOP" >> pure(llvm::omp::Directive::OMPD_master_taskloop),
9642ddba308SValentin Clement     "PARALLEL DO SIMD" >> pure(llvm::omp::Directive::OMPD_parallel_do_simd),
9652ddba308SValentin Clement     "PARALLEL DO" >> pure(llvm::omp::Directive::OMPD_parallel_do),
9666658e1a3SAnchu Rajendran S     "PARALLEL MASKED TASKLOOP SIMD" >>
9676658e1a3SAnchu Rajendran S         pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop_simd),
9686658e1a3SAnchu Rajendran S     "PARALLEL MASKED TASKLOOP" >>
9696658e1a3SAnchu Rajendran S         pure(llvm::omp::Directive::OMPD_parallel_masked_taskloop),
970092a819eSKiran Chandramohan     "PARALLEL MASTER TASKLOOP SIMD" >>
971092a819eSKiran Chandramohan         pure(llvm::omp::Directive::OMPD_parallel_master_taskloop_simd),
972092a819eSKiran Chandramohan     "PARALLEL MASTER TASKLOOP" >>
973092a819eSKiran Chandramohan         pure(llvm::omp::Directive::OMPD_parallel_master_taskloop),
9742ddba308SValentin Clement     "SIMD" >> pure(llvm::omp::Directive::OMPD_simd),
975826bde5dSAnchu Rajendran S     "TARGET LOOP" >> pure(llvm::omp::Directive::OMPD_target_loop),
97664ab3302SCarolineConcatto     "TARGET PARALLEL DO SIMD" >>
9772ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_target_parallel_do_simd),
9782ddba308SValentin Clement     "TARGET PARALLEL DO" >> pure(llvm::omp::Directive::OMPD_target_parallel_do),
979826bde5dSAnchu Rajendran S     "TARGET PARALLEL LOOP" >>
980826bde5dSAnchu Rajendran S         pure(llvm::omp::Directive::OMPD_target_parallel_loop),
9812ddba308SValentin Clement     "TARGET SIMD" >> pure(llvm::omp::Directive::OMPD_target_simd),
98264ab3302SCarolineConcatto     "TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD" >>
9832ddba308SValentin Clement         pure(llvm::omp::Directive::
9842ddba308SValentin Clement                 OMPD_target_teams_distribute_parallel_do_simd),
98564ab3302SCarolineConcatto     "TARGET TEAMS DISTRIBUTE PARALLEL DO" >>
9862ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do),
98764ab3302SCarolineConcatto     "TARGET TEAMS DISTRIBUTE SIMD" >>
9882ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_target_teams_distribute_simd),
98964ab3302SCarolineConcatto     "TARGET TEAMS DISTRIBUTE" >>
9902ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_target_teams_distribute),
991826bde5dSAnchu Rajendran S     "TARGET TEAMS LOOP" >> pure(llvm::omp::Directive::OMPD_target_teams_loop),
9922ddba308SValentin Clement     "TASKLOOP SIMD" >> pure(llvm::omp::Directive::OMPD_taskloop_simd),
9932ddba308SValentin Clement     "TASKLOOP" >> pure(llvm::omp::Directive::OMPD_taskloop),
99464ab3302SCarolineConcatto     "TEAMS DISTRIBUTE PARALLEL DO SIMD" >>
9952ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_teams_distribute_parallel_do_simd),
99664ab3302SCarolineConcatto     "TEAMS DISTRIBUTE PARALLEL DO" >>
9972ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_teams_distribute_parallel_do),
99864ab3302SCarolineConcatto     "TEAMS DISTRIBUTE SIMD" >>
9992ddba308SValentin Clement         pure(llvm::omp::Directive::OMPD_teams_distribute_simd),
10008feb5d41SAbid Malik     "TEAMS DISTRIBUTE" >> pure(llvm::omp::Directive::OMPD_teams_distribute),
100150e73aeeSKareem Ergawy     "TEAMS LOOP" >> pure(llvm::omp::Directive::OMPD_teams_loop),
100284bf4b7cSAbid Malik     "TILE" >> pure(llvm::omp::Directive::OMPD_tile),
100384bf4b7cSAbid Malik     "UNROLL" >> pure(llvm::omp::Directive::OMPD_unroll)))))
100464ab3302SCarolineConcatto 
100564ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpBeginLoopDirective>(
100664ab3302SCarolineConcatto     sourced(Parser<OmpLoopDirective>{}), Parser<OmpClauseList>{})))
100764ab3302SCarolineConcatto 
100864ab3302SCarolineConcatto // 2.14.1 construct-type-clause -> PARALLEL | SECTIONS | DO | TASKGROUP
100964ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpCancelType>(
101064ab3302SCarolineConcatto     first("PARALLEL" >> pure(OmpCancelType::Type::Parallel),
101164ab3302SCarolineConcatto         "SECTIONS" >> pure(OmpCancelType::Type::Sections),
101264ab3302SCarolineConcatto         "DO" >> pure(OmpCancelType::Type::Do),
101364ab3302SCarolineConcatto         "TASKGROUP" >> pure(OmpCancelType::Type::Taskgroup)))))
101464ab3302SCarolineConcatto 
101564ab3302SCarolineConcatto // 2.14.2 Cancellation Point construct
101664ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPCancellationPointConstruct>(
101764ab3302SCarolineConcatto     verbatim("CANCELLATION POINT"_tok), Parser<OmpCancelType>{})))
101864ab3302SCarolineConcatto 
101964ab3302SCarolineConcatto // 2.14.1 Cancel construct
102064ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPCancelConstruct>(verbatim("CANCEL"_tok),
102164ab3302SCarolineConcatto     Parser<OmpCancelType>{}, maybe("IF" >> parenthesized(scalarLogicalExpr)))))
102264ab3302SCarolineConcatto 
102300e1cc4cSMats Petersson TYPE_PARSER(sourced(construct<OmpFailClause>(
102400e1cc4cSMats Petersson     parenthesized(indirect(Parser<OmpMemoryOrderClause>{})))))
102500e1cc4cSMats Petersson 
1026952c9d3aSclementval // 2.17.7 Atomic construct/2.17.8 Flush construct [OpenMP 5.0]
1027aa179d80SValentin Clement //        memory-order-clause ->
1028aa179d80SValentin Clement //                               seq_cst
1029aa179d80SValentin Clement //                               acq_rel
1030cd503166SKiran Kumar T P //                               release
1031cd503166SKiran Kumar T P //                               acquire
1032aa179d80SValentin Clement //                               relaxed
1033aa179d80SValentin Clement TYPE_PARSER(sourced(construct<OmpMemoryOrderClause>(
1034aa179d80SValentin Clement     sourced("SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) ||
1035aa179d80SValentin Clement         "ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) ||
1036aa179d80SValentin Clement         "RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
1037aa179d80SValentin Clement         "ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) ||
1038aa179d80SValentin Clement         "RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>())))))
1039cd503166SKiran Kumar T P 
1040d5fb5960SSergio Afonso // 2.4 Requires construct [OpenMP 5.0]
1041d5fb5960SSergio Afonso //        atomic-default-mem-order-clause ->
1042d5fb5960SSergio Afonso //                               seq_cst
1043d5fb5960SSergio Afonso //                               acq_rel
1044d5fb5960SSergio Afonso //                               relaxed
1045d5fb5960SSergio Afonso TYPE_PARSER(construct<OmpAtomicDefaultMemOrderClause>(
1046edc2fb07SSergio Afonso     "SEQ_CST" >> pure(common::OmpAtomicDefaultMemOrderType::SeqCst) ||
1047edc2fb07SSergio Afonso     "ACQ_REL" >> pure(common::OmpAtomicDefaultMemOrderType::AcqRel) ||
1048edc2fb07SSergio Afonso     "RELAXED" >> pure(common::OmpAtomicDefaultMemOrderType::Relaxed)))
1049d5fb5960SSergio Afonso 
1050e43b3b08Ssameeran joshi // 2.17.7 Atomic construct
1051e43b3b08Ssameeran joshi //        atomic-clause -> memory-order-clause | HINT(hint-expression)
1052e43b3b08Ssameeran joshi TYPE_PARSER(sourced(construct<OmpAtomicClause>(
1053e43b3b08Ssameeran joshi     construct<OmpAtomicClause>(Parser<OmpMemoryOrderClause>{}) ||
105400e1cc4cSMats Petersson     construct<OmpAtomicClause>("FAIL" >> Parser<OmpFailClause>{}) ||
1055e43b3b08Ssameeran joshi     construct<OmpAtomicClause>("HINT" >>
1056e43b3b08Ssameeran joshi         sourced(construct<OmpClause>(
1057e43b3b08Ssameeran joshi             construct<OmpClause::Hint>(parenthesized(constantExpr))))))))
1058e43b3b08Ssameeran joshi 
1059e43b3b08Ssameeran joshi // atomic-clause-list -> [atomic-clause, [atomic-clause], ...]
1060e43b3b08Ssameeran joshi TYPE_PARSER(sourced(construct<OmpAtomicClauseList>(
1061e43b3b08Ssameeran joshi     many(maybe(","_tok) >> sourced(Parser<OmpAtomicClause>{})))))
1062e43b3b08Ssameeran joshi 
1063c478aab6SKrzysztof Parzyszek TYPE_PARSER(sourced(construct<OpenMPDepobjConstruct>(verbatim("DEPOBJ"_tok),
1064c478aab6SKrzysztof Parzyszek     parenthesized(Parser<OmpObject>{}), sourced(Parser<OmpClause>{}))))
1065c478aab6SKrzysztof Parzyszek 
1066cd503166SKiran Kumar T P TYPE_PARSER(sourced(construct<OpenMPFlushConstruct>(verbatim("FLUSH"_tok),
1067f1569b1eSsameeran joshi     many(maybe(","_tok) >> sourced(Parser<OmpMemoryOrderClause>{})),
1068cd503166SKiran Kumar T P     maybe(parenthesized(Parser<OmpObjectList>{})))))
106964ab3302SCarolineConcatto 
107064ab3302SCarolineConcatto // Simple Standalone Directives
107164ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpSimpleStandaloneDirective>(first(
10722ddba308SValentin Clement     "BARRIER" >> pure(llvm::omp::Directive::OMPD_barrier),
10732ddba308SValentin Clement     "ORDERED" >> pure(llvm::omp::Directive::OMPD_ordered),
1074e67e09a7SAnchu Rajendran S     "SCAN" >> pure(llvm::omp::Directive::OMPD_scan),
10752ddba308SValentin Clement     "TARGET ENTER DATA" >> pure(llvm::omp::Directive::OMPD_target_enter_data),
10762ddba308SValentin Clement     "TARGET EXIT DATA" >> pure(llvm::omp::Directive::OMPD_target_exit_data),
10772ddba308SValentin Clement     "TARGET UPDATE" >> pure(llvm::omp::Directive::OMPD_target_update),
10782ddba308SValentin Clement     "TASKWAIT" >> pure(llvm::omp::Directive::OMPD_taskwait),
10792ddba308SValentin Clement     "TASKYIELD" >> pure(llvm::omp::Directive::OMPD_taskyield)))))
108064ab3302SCarolineConcatto 
108164ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPSimpleStandaloneConstruct>(
108264ab3302SCarolineConcatto     Parser<OmpSimpleStandaloneDirective>{}, Parser<OmpClauseList>{})))
108364ab3302SCarolineConcatto 
108464ab3302SCarolineConcatto // Standalone Constructs
108564ab3302SCarolineConcatto TYPE_PARSER(
108664ab3302SCarolineConcatto     sourced(construct<OpenMPStandaloneConstruct>(
108764ab3302SCarolineConcatto                 Parser<OpenMPSimpleStandaloneConstruct>{}) ||
108864ab3302SCarolineConcatto         construct<OpenMPStandaloneConstruct>(Parser<OpenMPFlushConstruct>{}) ||
108964ab3302SCarolineConcatto         construct<OpenMPStandaloneConstruct>(Parser<OpenMPCancelConstruct>{}) ||
109064ab3302SCarolineConcatto         construct<OpenMPStandaloneConstruct>(
1091c478aab6SKrzysztof Parzyszek             Parser<OpenMPCancellationPointConstruct>{}) ||
1092*15ab7be2SKrzysztof Parzyszek         construct<OpenMPStandaloneConstruct>(
1093*15ab7be2SKrzysztof Parzyszek             Parser<OmpMetadirectiveDirective>{}) ||
1094c478aab6SKrzysztof Parzyszek         construct<OpenMPStandaloneConstruct>(Parser<OpenMPDepobjConstruct>{})) /
109564ab3302SCarolineConcatto     endOfLine)
109664ab3302SCarolineConcatto 
109764ab3302SCarolineConcatto // Directives enclosing structured-block
10982ddba308SValentin Clement TYPE_PARSER(construct<OmpBlockDirective>(first(
10996658e1a3SAnchu Rajendran S     "MASKED" >> pure(llvm::omp::Directive::OMPD_masked),
11002ddba308SValentin Clement     "MASTER" >> pure(llvm::omp::Directive::OMPD_master),
11012ddba308SValentin Clement     "ORDERED" >> pure(llvm::omp::Directive::OMPD_ordered),
11026658e1a3SAnchu Rajendran S     "PARALLEL MASKED" >> pure(llvm::omp::Directive::OMPD_parallel_masked),
1103092a819eSKiran Chandramohan     "PARALLEL MASTER" >> pure(llvm::omp::Directive::OMPD_parallel_master),
11042ddba308SValentin Clement     "PARALLEL WORKSHARE" >> pure(llvm::omp::Directive::OMPD_parallel_workshare),
11052ddba308SValentin Clement     "PARALLEL" >> pure(llvm::omp::Directive::OMPD_parallel),
1106843c2fbeSKiran Chandramohan     "SCOPE" >> pure(llvm::omp::Directive::OMPD_scope),
11072ddba308SValentin Clement     "SINGLE" >> pure(llvm::omp::Directive::OMPD_single),
11082ddba308SValentin Clement     "TARGET DATA" >> pure(llvm::omp::Directive::OMPD_target_data),
11092ddba308SValentin Clement     "TARGET PARALLEL" >> pure(llvm::omp::Directive::OMPD_target_parallel),
11102ddba308SValentin Clement     "TARGET TEAMS" >> pure(llvm::omp::Directive::OMPD_target_teams),
11112ddba308SValentin Clement     "TARGET" >> pure(llvm::omp::Directive::OMPD_target),
11122ddba308SValentin Clement     "TASK"_id >> pure(llvm::omp::Directive::OMPD_task),
11132ddba308SValentin Clement     "TASKGROUP" >> pure(llvm::omp::Directive::OMPD_taskgroup),
11142ddba308SValentin Clement     "TEAMS" >> pure(llvm::omp::Directive::OMPD_teams),
11152ddba308SValentin Clement     "WORKSHARE" >> pure(llvm::omp::Directive::OMPD_workshare))))
111664ab3302SCarolineConcatto 
111764ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpBeginBlockDirective>(
111864ab3302SCarolineConcatto     sourced(Parser<OmpBlockDirective>{}), Parser<OmpClauseList>{})))
111964ab3302SCarolineConcatto 
112064ab3302SCarolineConcatto TYPE_PARSER(construct<OmpReductionInitializerClause>(
112164ab3302SCarolineConcatto     "INITIALIZER" >> parenthesized("OMP_PRIV =" >> expr)))
112264ab3302SCarolineConcatto 
112364ab3302SCarolineConcatto // 2.16 Declare Reduction Construct
112464ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>(
112564ab3302SCarolineConcatto     verbatim("DECLARE REDUCTION"_tok),
1126cfd67c21SKrzysztof Parzyszek     "(" >> Parser<OmpReductionIdentifier>{} / ":",
112764ab3302SCarolineConcatto     nonemptyList(Parser<DeclarationTypeSpec>{}) / ":",
112864ab3302SCarolineConcatto     Parser<OmpReductionCombiner>{} / ")",
112964ab3302SCarolineConcatto     maybe(Parser<OmpReductionInitializerClause>{}))))
113064ab3302SCarolineConcatto 
113164ab3302SCarolineConcatto // declare-target with list
113264ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpDeclareTargetWithList>(
113364ab3302SCarolineConcatto     parenthesized(Parser<OmpObjectList>{}))))
113464ab3302SCarolineConcatto 
113564ab3302SCarolineConcatto // declare-target with clause
113664ab3302SCarolineConcatto TYPE_PARSER(
113764ab3302SCarolineConcatto     sourced(construct<OmpDeclareTargetWithClause>(Parser<OmpClauseList>{})))
113864ab3302SCarolineConcatto 
113964ab3302SCarolineConcatto // declare-target-specifier
114064ab3302SCarolineConcatto TYPE_PARSER(
114164ab3302SCarolineConcatto     construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithList>{}) ||
114264ab3302SCarolineConcatto     construct<OmpDeclareTargetSpecifier>(Parser<OmpDeclareTargetWithClause>{}))
114364ab3302SCarolineConcatto 
114464ab3302SCarolineConcatto // 2.10.6 Declare Target Construct
114564ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPDeclareTargetConstruct>(
114664ab3302SCarolineConcatto     verbatim("DECLARE TARGET"_tok), Parser<OmpDeclareTargetSpecifier>{})))
114764ab3302SCarolineConcatto 
1148ec1e0c5eSMats Petersson // declare-mapper-specifier
1149ec1e0c5eSMats Petersson TYPE_PARSER(construct<OmpDeclareMapperSpecifier>(
1150ec1e0c5eSMats Petersson     maybe(name / ":" / !":"_tok), typeSpec / "::", name))
1151ec1e0c5eSMats Petersson 
1152ec1e0c5eSMats Petersson // OpenMP 5.2: 5.8.8 Declare Mapper Construct
1153ec1e0c5eSMats Petersson TYPE_PARSER(sourced(construct<OpenMPDeclareMapperConstruct>(
1154ec1e0c5eSMats Petersson     verbatim("DECLARE MAPPER"_tok),
1155ec1e0c5eSMats Petersson     "(" >> Parser<OmpDeclareMapperSpecifier>{} / ")", Parser<OmpClauseList>{})))
1156ec1e0c5eSMats Petersson 
115764ab3302SCarolineConcatto TYPE_PARSER(construct<OmpReductionCombiner>(Parser<AssignmentStmt>{}) ||
115864ab3302SCarolineConcatto     construct<OmpReductionCombiner>(
115964ab3302SCarolineConcatto         construct<OmpReductionCombiner::FunctionCombiner>(
116064ab3302SCarolineConcatto             construct<Call>(Parser<ProcedureDesignator>{},
116164ab3302SCarolineConcatto                 parenthesized(optionalList(actualArgSpec))))))
116264ab3302SCarolineConcatto 
11634536c6acSKiran Kumar T P // 2.17.7 atomic -> ATOMIC [clause [,]] atomic-clause [[,] clause] |
11644536c6acSKiran Kumar T P //                  ATOMIC [clause]
11654536c6acSKiran Kumar T P //       clause -> memory-order-clause | HINT(hint-expression)
11664536c6acSKiran Kumar T P //       memory-order-clause -> SEQ_CST | ACQ_REL | RELEASE | ACQUIRE | RELAXED
116764ab3302SCarolineConcatto //       atomic-clause -> READ | WRITE | UPDATE | CAPTURE
116864ab3302SCarolineConcatto 
116964ab3302SCarolineConcatto // OMP END ATOMIC
117064ab3302SCarolineConcatto TYPE_PARSER(construct<OmpEndAtomic>(startOmpLine >> "END ATOMIC"_tok))
117164ab3302SCarolineConcatto 
11724536c6acSKiran Kumar T P // OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] READ [MEMORY-ORDER-CLAUSE-LIST]
117364ab3302SCarolineConcatto TYPE_PARSER("ATOMIC" >>
11749b49392dSThirumalai Shaktivel     sourced(construct<OmpAtomicRead>(
11759b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / maybe(","_tok), verbatim("READ"_tok),
11769b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt),
11779b49392dSThirumalai Shaktivel         maybe(Parser<OmpEndAtomic>{} / endOmpLine))))
117864ab3302SCarolineConcatto 
11794536c6acSKiran Kumar T P // OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] CAPTURE [MEMORY-ORDER-CLAUSE-LIST]
1180d95d3d2aSsameeran joshi TYPE_PARSER("ATOMIC" >>
11819b49392dSThirumalai Shaktivel     sourced(construct<OmpAtomicCapture>(
11829b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / maybe(","_tok), verbatim("CAPTURE"_tok),
11839b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt),
11849b49392dSThirumalai Shaktivel         statement(assignmentStmt), Parser<OmpEndAtomic>{} / endOmpLine)))
118564ab3302SCarolineConcatto 
118603b5f8f0SMats Petersson TYPE_PARSER(construct<OmpAtomicCompareIfStmt>(indirect(Parser<IfStmt>{})) ||
118703b5f8f0SMats Petersson     construct<OmpAtomicCompareIfStmt>(indirect(Parser<IfConstruct>{})))
118803b5f8f0SMats Petersson 
118903b5f8f0SMats Petersson // OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] COMPARE [MEMORY-ORDER-CLAUSE-LIST]
119003b5f8f0SMats Petersson TYPE_PARSER("ATOMIC" >>
119103b5f8f0SMats Petersson     sourced(construct<OmpAtomicCompare>(
119203b5f8f0SMats Petersson         Parser<OmpAtomicClauseList>{} / maybe(","_tok), verbatim("COMPARE"_tok),
119303b5f8f0SMats Petersson         Parser<OmpAtomicClauseList>{} / endOmpLine,
119403b5f8f0SMats Petersson         Parser<OmpAtomicCompareIfStmt>{},
119503b5f8f0SMats Petersson         maybe(Parser<OmpEndAtomic>{} / endOmpLine))))
119603b5f8f0SMats Petersson 
11974536c6acSKiran Kumar T P // OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] UPDATE [MEMORY-ORDER-CLAUSE-LIST]
119864ab3302SCarolineConcatto TYPE_PARSER("ATOMIC" >>
11999b49392dSThirumalai Shaktivel     sourced(construct<OmpAtomicUpdate>(
12009b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / maybe(","_tok), verbatim("UPDATE"_tok),
12019b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt),
12029b49392dSThirumalai Shaktivel         maybe(Parser<OmpEndAtomic>{} / endOmpLine))))
120364ab3302SCarolineConcatto 
1204e43b3b08Ssameeran joshi // OMP ATOMIC [atomic-clause-list]
12059b49392dSThirumalai Shaktivel TYPE_PARSER(sourced(construct<OmpAtomic>(verbatim("ATOMIC"_tok),
1206e43b3b08Ssameeran joshi     Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt),
12079b49392dSThirumalai Shaktivel     maybe(Parser<OmpEndAtomic>{} / endOmpLine))))
120864ab3302SCarolineConcatto 
12094536c6acSKiran Kumar T P // OMP ATOMIC [MEMORY-ORDER-CLAUSE-LIST] WRITE [MEMORY-ORDER-CLAUSE-LIST]
121064ab3302SCarolineConcatto TYPE_PARSER("ATOMIC" >>
12119b49392dSThirumalai Shaktivel     sourced(construct<OmpAtomicWrite>(
12129b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / maybe(","_tok), verbatim("WRITE"_tok),
12139b49392dSThirumalai Shaktivel         Parser<OmpAtomicClauseList>{} / endOmpLine, statement(assignmentStmt),
12149b49392dSThirumalai Shaktivel         maybe(Parser<OmpEndAtomic>{} / endOmpLine))))
121564ab3302SCarolineConcatto 
121664ab3302SCarolineConcatto // Atomic Construct
121764ab3302SCarolineConcatto TYPE_PARSER(construct<OpenMPAtomicConstruct>(Parser<OmpAtomicRead>{}) ||
121864ab3302SCarolineConcatto     construct<OpenMPAtomicConstruct>(Parser<OmpAtomicCapture>{}) ||
121903b5f8f0SMats Petersson     construct<OpenMPAtomicConstruct>(Parser<OmpAtomicCompare>{}) ||
122064ab3302SCarolineConcatto     construct<OpenMPAtomicConstruct>(Parser<OmpAtomicWrite>{}) ||
122164ab3302SCarolineConcatto     construct<OpenMPAtomicConstruct>(Parser<OmpAtomicUpdate>{}) ||
122264ab3302SCarolineConcatto     construct<OpenMPAtomicConstruct>(Parser<OmpAtomic>{}))
122364ab3302SCarolineConcatto 
122464ab3302SCarolineConcatto // 2.13.2 OMP CRITICAL
122564ab3302SCarolineConcatto TYPE_PARSER(startOmpLine >>
122664ab3302SCarolineConcatto     sourced(construct<OmpEndCriticalDirective>(
122764ab3302SCarolineConcatto         verbatim("END CRITICAL"_tok), maybe(parenthesized(name)))) /
122864ab3302SCarolineConcatto         endOmpLine)
122964ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpCriticalDirective>(verbatim("CRITICAL"_tok),
1230fe2d053cSNimish Mishra                 maybe(parenthesized(name)), Parser<OmpClauseList>{})) /
123164ab3302SCarolineConcatto     endOmpLine)
123264ab3302SCarolineConcatto 
123364ab3302SCarolineConcatto TYPE_PARSER(construct<OpenMPCriticalConstruct>(
123464ab3302SCarolineConcatto     Parser<OmpCriticalDirective>{}, block, Parser<OmpEndCriticalDirective>{}))
123564ab3302SCarolineConcatto 
12368035d38dSMats Petersson TYPE_PARSER(sourced(construct<OmpDispatchDirective>(
12378035d38dSMats Petersson     verbatim("DISPATCH"_tok), Parser<OmpClauseList>{})))
12388035d38dSMats Petersson 
12398035d38dSMats Petersson TYPE_PARSER(
12408035d38dSMats Petersson     construct<OmpEndDispatchDirective>(startOmpLine >> "END DISPATCH"_tok))
12418035d38dSMats Petersson 
12428035d38dSMats Petersson TYPE_PARSER(sourced(construct<OpenMPDispatchConstruct>(
12438035d38dSMats Petersson     Parser<OmpDispatchDirective>{} / endOmpLine, block,
12448035d38dSMats Petersson     maybe(Parser<OmpEndDispatchDirective>{} / endOmpLine))))
12458035d38dSMats Petersson 
1246c9e967afSIrina Dobrescu // 2.11.3 Executable Allocate directive
1247c9e967afSIrina Dobrescu TYPE_PARSER(
1248c9e967afSIrina Dobrescu     sourced(construct<OpenMPExecutableAllocate>(verbatim("ALLOCATE"_tok),
1249c9e967afSIrina Dobrescu         maybe(parenthesized(Parser<OmpObjectList>{})), Parser<OmpClauseList>{},
1250c9e967afSIrina Dobrescu         maybe(nonemptyList(Parser<OpenMPDeclarativeAllocate>{})) / endOmpLine,
1251c9e967afSIrina Dobrescu         statement(allocateStmt))))
1252c9e967afSIrina Dobrescu 
12536311ab21SEthan Luis McDonough // 6.7 Allocators construct [OpenMP 5.2]
12546311ab21SEthan Luis McDonough //     allocators-construct -> ALLOCATORS [allocate-clause [,]]
12556311ab21SEthan Luis McDonough //                                allocate-stmt
12566311ab21SEthan Luis McDonough //                             [omp-end-allocators-construct]
12576311ab21SEthan Luis McDonough TYPE_PARSER(sourced(construct<OpenMPAllocatorsConstruct>(
12586311ab21SEthan Luis McDonough     verbatim("ALLOCATORS"_tok), Parser<OmpClauseList>{} / endOmpLine,
12596311ab21SEthan Luis McDonough     statement(allocateStmt), maybe(Parser<OmpEndAllocators>{} / endOmpLine))))
12606311ab21SEthan Luis McDonough 
12616311ab21SEthan Luis McDonough TYPE_PARSER(construct<OmpEndAllocators>(startOmpLine >> "END ALLOCATORS"_tok))
12626311ab21SEthan Luis McDonough 
126364ab3302SCarolineConcatto // 2.8.2 Declare Simd construct
126464ab3302SCarolineConcatto TYPE_PARSER(
126564ab3302SCarolineConcatto     sourced(construct<OpenMPDeclareSimdConstruct>(verbatim("DECLARE SIMD"_tok),
126664ab3302SCarolineConcatto         maybe(parenthesized(name)), Parser<OmpClauseList>{})))
126764ab3302SCarolineConcatto 
1268d5fb5960SSergio Afonso // 2.4 Requires construct
1269d5fb5960SSergio Afonso TYPE_PARSER(sourced(construct<OpenMPRequiresConstruct>(
12706a1be11bSSergio Afonso     verbatim("REQUIRES"_tok), Parser<OmpClauseList>{})))
1271d5fb5960SSergio Afonso 
127264ab3302SCarolineConcatto // 2.15.2 Threadprivate directive
127364ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OpenMPThreadprivate>(
127464ab3302SCarolineConcatto     verbatim("THREADPRIVATE"_tok), parenthesized(Parser<OmpObjectList>{}))))
127564ab3302SCarolineConcatto 
1276c9e967afSIrina Dobrescu // 2.11.3 Declarative Allocate directive
1277c9e967afSIrina Dobrescu TYPE_PARSER(
1278c9e967afSIrina Dobrescu     sourced(construct<OpenMPDeclarativeAllocate>(verbatim("ALLOCATE"_tok),
1279c9e967afSIrina Dobrescu         parenthesized(Parser<OmpObjectList>{}), Parser<OmpClauseList>{})) /
1280c9e967afSIrina Dobrescu     lookAhead(endOmpLine / !statement(allocateStmt)))
1281c9e967afSIrina Dobrescu 
128264ab3302SCarolineConcatto // Declarative constructs
128364ab3302SCarolineConcatto TYPE_PARSER(startOmpLine >>
1284779f40c0SKiran Chandramohan     withMessage("expected OpenMP construct"_err_en_US,
128564ab3302SCarolineConcatto         sourced(construct<OpenMPDeclarativeConstruct>(
128664ab3302SCarolineConcatto                     Parser<OpenMPDeclareReductionConstruct>{}) ||
128764ab3302SCarolineConcatto             construct<OpenMPDeclarativeConstruct>(
1288ec1e0c5eSMats Petersson                 Parser<OpenMPDeclareMapperConstruct>{}) ||
1289ec1e0c5eSMats Petersson             construct<OpenMPDeclarativeConstruct>(
129064ab3302SCarolineConcatto                 Parser<OpenMPDeclareSimdConstruct>{}) ||
129164ab3302SCarolineConcatto             construct<OpenMPDeclarativeConstruct>(
129264ab3302SCarolineConcatto                 Parser<OpenMPDeclareTargetConstruct>{}) ||
1293c9e967afSIrina Dobrescu             construct<OpenMPDeclarativeConstruct>(
1294c9e967afSIrina Dobrescu                 Parser<OpenMPDeclarativeAllocate>{}) ||
1295d5fb5960SSergio Afonso             construct<OpenMPDeclarativeConstruct>(
1296d5fb5960SSergio Afonso                 Parser<OpenMPRequiresConstruct>{}) ||
1297779f40c0SKiran Chandramohan             construct<OpenMPDeclarativeConstruct>(
1298adeff9f6SKrzysztof Parzyszek                 Parser<OpenMPThreadprivate>{}) ||
1299adeff9f6SKrzysztof Parzyszek             construct<OpenMPDeclarativeConstruct>(
1300adeff9f6SKrzysztof Parzyszek                 Parser<OpenMPUtilityConstruct>{})) /
1301779f40c0SKiran Chandramohan             endOmpLine))
130264ab3302SCarolineConcatto 
130364ab3302SCarolineConcatto // Block Construct
130464ab3302SCarolineConcatto TYPE_PARSER(construct<OpenMPBlockConstruct>(
130564ab3302SCarolineConcatto     Parser<OmpBeginBlockDirective>{} / endOmpLine, block,
130664ab3302SCarolineConcatto     Parser<OmpEndBlockDirective>{} / endOmpLine))
130764ab3302SCarolineConcatto 
130864ab3302SCarolineConcatto // OMP SECTIONS Directive
13092ddba308SValentin Clement TYPE_PARSER(construct<OmpSectionsDirective>(first(
13102ddba308SValentin Clement     "SECTIONS" >> pure(llvm::omp::Directive::OMPD_sections),
13112ddba308SValentin Clement     "PARALLEL SECTIONS" >> pure(llvm::omp::Directive::OMPD_parallel_sections))))
131264ab3302SCarolineConcatto 
131364ab3302SCarolineConcatto // OMP BEGIN and END SECTIONS Directive
131464ab3302SCarolineConcatto TYPE_PARSER(sourced(construct<OmpBeginSectionsDirective>(
131564ab3302SCarolineConcatto     sourced(Parser<OmpSectionsDirective>{}), Parser<OmpClauseList>{})))
131664ab3302SCarolineConcatto TYPE_PARSER(
131764ab3302SCarolineConcatto     startOmpLine >> sourced(construct<OmpEndSectionsDirective>(
131864ab3302SCarolineConcatto                         sourced("END"_tok >> Parser<OmpSectionsDirective>{}),
131964ab3302SCarolineConcatto                         Parser<OmpClauseList>{})))
132064ab3302SCarolineConcatto 
132164ab3302SCarolineConcatto // OMP SECTION-BLOCK
132264ab3302SCarolineConcatto 
1323ae1623b3SShraiysh Vaishay TYPE_PARSER(construct<OpenMPSectionConstruct>(block))
1324ae1623b3SShraiysh Vaishay 
1325ae1623b3SShraiysh Vaishay TYPE_PARSER(maybe(startOmpLine >> "SECTION"_tok / endOmpLine) >>
1326ae1623b3SShraiysh Vaishay     construct<OmpSectionBlocks>(nonemptySeparated(
1327ae1623b3SShraiysh Vaishay         construct<OpenMPConstruct>(sourced(Parser<OpenMPSectionConstruct>{})),
1328ae1623b3SShraiysh Vaishay         startOmpLine >> "SECTION"_tok / endOmpLine)))
1329ae1623b3SShraiysh Vaishay 
1330ae1623b3SShraiysh Vaishay // OMP SECTIONS (OpenMP 5.0 - 2.8.1), PARALLEL SECTIONS (OpenMP 5.0 - 2.13.3)
133164ab3302SCarolineConcatto TYPE_PARSER(construct<OpenMPSectionsConstruct>(
133264ab3302SCarolineConcatto     Parser<OmpBeginSectionsDirective>{} / endOmpLine,
133364ab3302SCarolineConcatto     Parser<OmpSectionBlocks>{}, Parser<OmpEndSectionsDirective>{} / endOmpLine))
133464ab3302SCarolineConcatto 
133564ab3302SCarolineConcatto TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
133664ab3302SCarolineConcatto     startOmpLine >>
1337779f40c0SKiran Chandramohan         withMessage("expected OpenMP construct"_err_en_US,
133864ab3302SCarolineConcatto             first(construct<OpenMPConstruct>(Parser<OpenMPSectionsConstruct>{}),
133964ab3302SCarolineConcatto                 construct<OpenMPConstruct>(Parser<OpenMPLoopConstruct>{}),
134064ab3302SCarolineConcatto                 construct<OpenMPConstruct>(Parser<OpenMPBlockConstruct>{}),
134164ab3302SCarolineConcatto                 // OpenMPBlockConstruct is attempted before
134264ab3302SCarolineConcatto                 // OpenMPStandaloneConstruct to resolve !$OMP ORDERED
134364ab3302SCarolineConcatto                 construct<OpenMPConstruct>(Parser<OpenMPStandaloneConstruct>{}),
134464ab3302SCarolineConcatto                 construct<OpenMPConstruct>(Parser<OpenMPAtomicConstruct>{}),
1345df859f90SKrzysztof Parzyszek                 construct<OpenMPConstruct>(Parser<OpenMPUtilityConstruct>{}),
13468035d38dSMats Petersson                 construct<OpenMPConstruct>(Parser<OpenMPDispatchConstruct>{}),
1347c9e967afSIrina Dobrescu                 construct<OpenMPConstruct>(Parser<OpenMPExecutableAllocate>{}),
13486311ab21SEthan Luis McDonough                 construct<OpenMPConstruct>(Parser<OpenMPAllocatorsConstruct>{}),
1349c9e967afSIrina Dobrescu                 construct<OpenMPConstruct>(Parser<OpenMPDeclarativeAllocate>{}),
1350779f40c0SKiran Chandramohan                 construct<OpenMPConstruct>(Parser<OpenMPCriticalConstruct>{}))))
135164ab3302SCarolineConcatto 
135264ab3302SCarolineConcatto // END OMP Block directives
135364ab3302SCarolineConcatto TYPE_PARSER(
135464ab3302SCarolineConcatto     startOmpLine >> sourced(construct<OmpEndBlockDirective>(
135564ab3302SCarolineConcatto                         sourced("END"_tok >> Parser<OmpBlockDirective>{}),
135664ab3302SCarolineConcatto                         Parser<OmpClauseList>{})))
135764ab3302SCarolineConcatto 
135864ab3302SCarolineConcatto // END OMP Loop directives
135964ab3302SCarolineConcatto TYPE_PARSER(
136064ab3302SCarolineConcatto     startOmpLine >> sourced(construct<OmpEndLoopDirective>(
136164ab3302SCarolineConcatto                         sourced("END"_tok >> Parser<OmpLoopDirective>{}),
136264ab3302SCarolineConcatto                         Parser<OmpClauseList>{})))
136364ab3302SCarolineConcatto 
136464ab3302SCarolineConcatto TYPE_PARSER(construct<OpenMPLoopConstruct>(
136564ab3302SCarolineConcatto     Parser<OmpBeginLoopDirective>{} / endOmpLine))
13661f879005STim Keith } // namespace Fortran::parser
1367