================ @@ -3474,6 +3477,138 @@ WRAPPER_CLASS(OmpObjectList, std::list<OmpObject>); #define MODIFIERS() std::optional<std::list<Modifier>> +inline namespace traits { +// trait-property-name -> +// identifier | string-literal +struct OmpTraitPropertyName { + CharBlock source; + WRAPPER_CLASS_BOILERPLATE(OmpTraitPropertyName, std::string); +}; + +// trait-score -> +// SCORE(non-negative-const-integer-expression) +struct OmpTraitScore { + CharBlock source; + WRAPPER_CLASS_BOILERPLATE(OmpTraitScore, ScalarIntExpr); +}; + +// trait-property-extension -> +// trait-property-name (trait-property-value, ...) +// trait-property-value -> +// trait-property-name | +// scalar-integer-expression | +// trait-property-extension +// +// The grammar in OpenMP 5.2+ spec is ambiguous, the above is a different +// version (but equivalent) that doesn't have ambiguities. +// The ambiguity is in +// trait-property: +// trait-property-name <- (a) +// trait-property-clause +// trait-property-expression <- (b) +// trait-property-extension <- this conflicts with (a) and (b) +// trait-property-extension: +// trait-property-name <- conflict with (a) +// identifier(trait-property-extension[, trait-property-extension[, ...]]) +// constant integer expression <- conflict with (b) +// +struct OmpTraitPropertyExtension { + CharBlock source; + TUPLE_CLASS_BOILERPLATE(OmpTraitPropertyExtension); + struct ExtensionValue { + CharBlock source; + UNION_CLASS_BOILERPLATE(ExtensionValue); + std::variant<OmpTraitPropertyName, ScalarExpr, + common::Indirection<OmpTraitPropertyExtension>> + u; + }; + using ExtensionList = std::list<ExtensionValue>; + std::tuple<OmpTraitPropertyName, ExtensionList> t; +}; + +// trait-property -> +// trait-property-name | OmpClause | +// trait-property-expression | trait-property-extension +// trait-property-expression -> +// scalar-logical-expression | scalar-integer-expression +// +// The parser for a logical expression will accept an integer expression, +// and if it's not logical, it will flag an error later. The same thing +// will happen if the scalar integer expression sees a logical expresion. +// To avoid this, parse all expressions as scalar expressions. +struct OmpTraitProperty { + CharBlock source; + UNION_CLASS_BOILERPLATE(OmpTraitProperty); + std::variant<OmpTraitPropertyName, common::Indirection<OmpClause>, + ScalarExpr, // trait-property-expresion + OmpTraitPropertyExtension> + u; +}; + +// trait-selector-name -> +// KIND | DT // name-list (host, nohost, +/add-def-doc) +// ISA | DT // name-list (isa_name, ... /impl-defined) +// ARCH | DT // name-list (arch_name, ... /impl-defined) +// directive-name | C // no properties +// SIMD | C // clause-list (from declare_simd) +// // (at least simdlen, inbranch/notinbranch) +// DEVICE_NUM | T // device-number +// UID | T // unique-string-id /impl-defined +// VENDOR | I // name-list (vendor-id /add-def-doc) +// EXTENSION | I // name-list (ext_name /impl-defined) +// ATOMIC_DEFAULT_MEM_ORDER I | // value of admo +// REQUIRES | I // clause-list (from requires) +// CONDITION U // logical-expr +// +// Trait-set-selectors: +// [D]evice, [T]arget_device, [C]onstruct, [I]mplementation, [U]ser. +struct OmpTraitSelectorName { + CharBlock source; + UNION_CLASS_BOILERPLATE(OmpTraitSelectorName); + ENUM_CLASS(Value, Arch, Atomic_Default_Mem_Order, Condition, Device_Num, + Extension, Isa, Kind, Requires, Simd, Uid, Vendor) + std::variant<Value, llvm::omp::Directive> u; +}; + +// trait-selector -> +// trait-selector-name | +// trait-selector-name ([trait-score:] trait-property, ...) +struct OmpTraitSelector { + CharBlock source; + TUPLE_CLASS_BOILERPLATE(OmpTraitSelector); + struct Properties { + TUPLE_CLASS_BOILERPLATE(Properties); + std::tuple<std::optional<OmpTraitScore>, std::list<OmpTraitProperty>> t; + }; + std::tuple<OmpTraitSelectorName, std::optional<Properties>> t; +}; + +// trait-set-selector-name -> +// CONSTRUCT | DEVICE | IMPLEMENTATION | USER | // since 5.0 +// TARGET_DEVICE // since 5.1 +struct OmpTraitSetSelectorName { + CharBlock source; + ENUM_CLASS(Value, Construct, Device, Implementation, Target_Device, User) ---------------- kiranchandramohan wrote:
Same question as above. https://github.com/llvm/llvm-project/pull/121815 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits