diff --git a/llvm/test/TableGen/directive1.td b/llvm/test/TableGen/directive1.td index bc36b5f09ef9b..b249f2bf5fc68 100644 --- a/llvm/test/TableGen/directive1.td +++ b/llvm/test/TableGen/directive1.td @@ -33,6 +33,11 @@ def TDLC_ClauseB : Clause<"clauseb"> { let isDefault = 1; } +def TDLC_ClauseC : Clause<"clausec"> { + let flangClass = "IntExpr"; + let isValueList = 1; +} + def TDL_DirA : Directive<"dira"> { let allowedClauses = [ VersionedClause, @@ -63,12 +68,14 @@ def TDL_DirA : Directive<"dira"> { // CHECK-NEXT: enum class Clause { // CHECK-NEXT: TDLC_clausea, // CHECK-NEXT: TDLC_clauseb, +// CHECK-NEXT: TDLC_clausec, // CHECK-NEXT: }; // CHECK-EMPTY: -// CHECK-NEXT: static constexpr std::size_t Clause_enumSize = 2; +// CHECK-NEXT: static constexpr std::size_t Clause_enumSize = 3; // CHECK-EMPTY: // CHECK-NEXT: constexpr auto TDLC_clausea = llvm::tdl::Clause::TDLC_clausea; // CHECK-NEXT: constexpr auto TDLC_clauseb = llvm::tdl::Clause::TDLC_clauseb; +// CHECK-NEXT: constexpr auto TDLC_clausec = llvm::tdl::Clause::TDLC_clausec; // CHECK-EMPTY: // CHECK-NEXT: enum class AKind { // CHECK-NEXT: TDLCV_vala=1, @@ -147,6 +154,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-EMPTY: // IMPL-NEXT: EMPTY_CLASS(Clausea); // IMPL-NEXT: WRAPPER_CLASS(Clauseb, std::optional); +// IMPL-NEXT: WRAPPER_CLASS(Clausec, std::list); // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_CLAUSE_PARSER_CLASSES // IMPL-EMPTY: @@ -155,6 +163,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-EMPTY: // IMPL-NEXT: Clausea // IMPL-NEXT: , Clauseb +// IMPL-NEXT: , Clausec // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST // IMPL-EMPTY: @@ -163,6 +172,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-EMPTY: // IMPL-NEXT: NODE(TdlClause, Clausea) // IMPL-NEXT: NODE(TdlClause, Clauseb) +// IMPL-NEXT: NODE(TdlClause, Clausec) // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_DUMP_PARSE_TREE_CLAUSES // IMPL-EMPTY: @@ -174,6 +184,12 @@ def TDL_DirA : Directive<"dira"> { // IMPL-NEXT: Word("CLAUSEB"); // IMPL-NEXT: Walk("(", x.v, ")"); // IMPL-NEXT: } +// IMPL-NEXT: void Unparse(const TdlClause::Clausec &x) { +// IMPL-NEXT: Word("CLAUSEC"); +// IMPL-NEXT: Put("("); +// IMPL-NEXT: Walk(x.v, ","); +// IMPL-NEXT: Put(")"); +// IMPL-NEXT: } // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_CLAUSE_UNPARSE // IMPL-EMPTY: @@ -182,6 +198,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-EMPTY: // IMPL-NEXT: void Enter(const parser::TdlClause::Clausea &); // IMPL-NEXT: void Enter(const parser::TdlClause::Clauseb &); +// IMPL-NEXT: void Enter(const parser::TdlClause::Clausec &); // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_CLAUSE_CHECK_ENTER // IMPL-EMPTY: @@ -192,6 +209,8 @@ def TDL_DirA : Directive<"dira"> { // IMPL-NEXT: return llvm::tdl::Clause::TDLC_clausea; // IMPL-NEXT: if constexpr (std::is_same_v) // IMPL-NEXT: return llvm::tdl::Clause::TDLC_clauseb; +// IMPL-NEXT: if constexpr (std::is_same_v) +// IMPL-NEXT: return llvm::tdl::Clause::TDLC_clausec; // IMPL-NEXT: llvm_unreachable("Invalid Tdl Parser clause"); // IMPL-EMPTY: // IMPL-NEXT: #endif // GEN_FLANG_CLAUSE_PARSER_KIND_MAP @@ -200,6 +219,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-NEXT: #undef GEN_FLANG_CLAUSES_PARSER // IMPL-EMPTY: // IMPL-NEXT: TYPE_PARSER( +// IMPL-NEXT: "clausec" >> construct(construct(parenthesized(nonemptyList(Parser{})))) || // IMPL-NEXT: "clauseb" >> construct(construct(maybe(parenthesized(Parser{})))) || // IMPL-NEXT: "clausea" >> construct(construct()) // IMPL-NEXT: ) @@ -234,6 +254,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-EMPTY: // IMPL-NEXT: __CLAUSE_NO_CLASS(clausea) // IMPL-NEXT: __CLAUSE_NO_CLASS(clauseb) +// IMPL-NEXT: __CLAUSE_NO_CLASS(clausec) // IMPL-EMPTY: // IMPL-NEXT: #undef __IMPLICIT_CLAUSE_NO_CLASS // IMPL-NEXT: #undef __IMPLICIT_CLAUSE_CLASS @@ -266,6 +287,7 @@ def TDL_DirA : Directive<"dira"> { // IMPL-NEXT: return llvm::StringSwitch(Str) // IMPL-NEXT: .Case("clausea",TDLC_clausea) // IMPL-NEXT: .Case("clauseb",TDLC_clauseb) +// IMPL-NEXT: .Case("clausec",TDLC_clausec) // IMPL-NEXT: .Default(TDLC_clauseb); // IMPL-NEXT: } // IMPL-EMPTY: @@ -275,6 +297,8 @@ def TDL_DirA : Directive<"dira"> { // IMPL-NEXT: return "clausea"; // IMPL-NEXT: case TDLC_clauseb: // IMPL-NEXT: return "clauseb"; +// IMPL-NEXT: case TDLC_clausec: +// IMPL-NEXT: return "clausec"; // IMPL-NEXT: } // IMPL-NEXT: llvm_unreachable("Invalid Tdl Clause kind"); // IMPL-NEXT: } diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp index 9d2860743308f..67033c6290ca0 100644 --- a/llvm/utils/TableGen/DirectiveEmitter.cpp +++ b/llvm/utils/TableGen/DirectiveEmitter.cpp @@ -720,6 +720,8 @@ static void GenerateFlangClausesParser(const DirectiveLanguage &DirLang, if (Clause.isValueOptional()) OS << "maybe("; OS << "parenthesized("; + if (Clause.isValueList()) + OS << "nonemptyList("; if (!Clause.getPrefix().empty()) OS << "\"" << Clause.getPrefix() << ":\" >> "; @@ -740,6 +742,8 @@ static void GenerateFlangClausesParser(const DirectiveLanguage &DirLang, OS << Parser; if (!Clause.getPrefix().empty() && Clause.isPrefixOptional()) OS << " || " << Parser; + if (Clause.isValueList()) // close nonemptyList(. + OS << ")"; OS << ")"; // close parenthesized(. if (Clause.isValueOptional()) // close maybe(.