diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -148,8 +148,9 @@ std::get(beginBlockDirective.t); for (const auto &clause : parallelOpClauseList.v) { if (const auto &ifClause = - std::get_if(&clause.u)) { - auto &expr = std::get(ifClause->t); + std::get_if(&clause.u)) { + auto &expr = + std::get(ifClause->v.t); ifClauseOperand = fir::getBase( converter.genExprValue(*Fortran::semantics::GetExpr(expr))); } else if (const auto &numThreadsClause = diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -155,8 +155,8 @@ TYPE_PARSER( "ACQUIRE" >> construct(construct()) || "ACQ_REL" >> construct(construct()) || - "ALIGNED" >> - construct(parenthesized(Parser{})) || + "ALIGNED" >> construct(construct( + parenthesized(Parser{}))) || "ALLOCATE" >> construct(construct( parenthesized(Parser{}))) || "ALLOCATOR" >> construct(construct( @@ -169,10 +169,10 @@ (parenthesized(Parser{})))) || "DEFAULT"_id >> construct(construct( parenthesized(Parser{}))) || - "DEFAULTMAP" >> - construct(parenthesized(Parser{})) || - "DEPEND" >> - construct(parenthesized(Parser{})) || + "DEFAULTMAP" >> construct(construct( + parenthesized(Parser{}))) || + "DEPEND" >> construct(construct( + parenthesized(Parser{}))) || "DEVICE" >> construct(construct( parenthesized(scalarIntExpr))) || "DIST_SCHEDULE" >> @@ -188,17 +188,19 @@ parenthesized(scalarIntExpr))) || "HINT" >> construct( construct(parenthesized(constantExpr))) || - "IF" >> construct(parenthesized(Parser{})) || + "IF" >> construct(construct( + parenthesized(Parser{}))) || "INBRANCH" >> construct(construct()) || "IS_DEVICE_PTR" >> construct(construct( parenthesized(nonemptyList(name)))) || "LASTPRIVATE" >> construct(construct( parenthesized(Parser{}))) || - "LINEAR" >> - construct(parenthesized(Parser{})) || + "LINEAR" >> construct(construct( + parenthesized(Parser{}))) || "LINK" >> construct(construct( parenthesized(Parser{}))) || - "MAP" >> construct(parenthesized(Parser{})) || + "MAP" >> construct(construct( + parenthesized(Parser{}))) || "MERGEABLE" >> construct(construct()) || "NOGROUP" >> construct(construct()) || "NOTINBRANCH" >> @@ -227,8 +229,8 @@ "RELEASE" >> construct(construct()) || "SAFELEN" >> construct(construct( parenthesized(scalarIntConstantExpr))) || - "SCHEDULE" >> - construct(parenthesized(Parser{})) || + "SCHEDULE" >> construct(construct( + parenthesized(Parser{}))) || "SEQ_CST" >> construct(construct()) || "SHARED" >> construct(construct( parenthesized(Parser{}))) || diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -1974,43 +1974,33 @@ } void Unparse(const OmpMapType::Always &) { Word("ALWAYS,"); } void Unparse(const OmpMapClause &x) { - Word("MAP("); Walk(std::get>(x.t), ":"); Walk(std::get(x.t)); - Put(") "); } void Unparse(const OmpScheduleModifier &x) { Walk(std::get(x.t)); Walk(",", std::get>(x.t)); } void Unparse(const OmpScheduleClause &x) { - Word("SCHEDULE("); Walk(std::get>(x.t), ":"); Walk(std::get(x.t)); Walk(",", std::get>(x.t)); - Put(")"); } void Unparse(const OmpAlignedClause &x) { - Word("ALIGNED("), Walk(std::get>(x.t), ","); + Walk(std::get>(x.t), ","); Walk(std::get>(x.t)); - Put(") "); } void Unparse(const OmpIfClause &x) { - Word("IF("), - Walk(std::get>(x.t), - ":"); + Walk(std::get>(x.t), ":"); Walk(std::get(x.t)); - Put(") "); } void Unparse(const OmpLinearClause::WithoutModifier &x) { - Word("LINEAR("), Walk(x.names, ", "); + Walk(x.names, ", "); Walk(":", x.step); - Put(")"); } void Unparse(const OmpLinearClause::WithModifier &x) { - Word("LINEAR("), Walk(x.modifier), Put("("), Walk(x.names, ","), Put(")"); + Walk(x.modifier), Put("("), Walk(x.names, ","), Put(")"); Walk(":", x.step); - Put(")"); } void Unparse(const OmpReductionClause &x) { Walk(std::get(x.t)); @@ -2040,28 +2030,23 @@ bool Pre(const OmpDependClause &x) { return std::visit(common::visitors{ [&](const OmpDependClause::Source &) { - Word("DEPEND(SOURCE)"); + Word("SOURCE"); return false; }, [&](const OmpDependClause::Sink &y) { - Word("DEPEND(SINK:"); + Word("SINK:"); Walk(y.v); Put(")"); return false; }, - [&](const OmpDependClause::InOut &) { - Word("DEPEND"); - return true; - }, + [&](const OmpDependClause::InOut &) { return true; }, }, x.u); } void Unparse(const OmpDefaultmapClause &x) { - Word("DEFAULTMAP("); Walk(std::get(x.t)); Walk(":", std::get>(x.t)); - Word(")"); } #define GEN_FLANG_CLAUSE_UNPARSE #include "llvm/Frontend/OpenMP/OMP.inc" diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -389,15 +389,15 @@ if (llvm::omp::doSet.test(GetContext().directive)) { if (auto *clause{FindClause(llvm::omp::Clause::OMPC_schedule)}) { // only one schedule clause is allowed - const auto &schedClause{std::get(clause->u)}; - if (ScheduleModifierHasType(schedClause, + const auto &schedClause{std::get(clause->u)}; + if (ScheduleModifierHasType(schedClause.v, parser::OmpScheduleModifierType::ModType::Nonmonotonic)) { if (FindClause(llvm::omp::Clause::OMPC_ordered)) { context_.Say(clause->source, "The NONMONOTONIC modifier cannot be specified " "if an ORDERED clause is specified"_err_en_US); } - if (ScheduleModifierHasType(schedClause, + if (ScheduleModifierHasType(schedClause.v, parser::OmpScheduleModifierType::ModType::Monotonic)) { context_.Say(clause->source, "The MONOTONIC and NONMONOTONIC modifiers " diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -77,15 +77,8 @@ // Optional class holding value of the clause in clang AST. string clangClass = ""; - // Optional class holding the clause in flang AST. If left blank, the class - // is assumed to be the name of the clause with capitalized word and - // underscores removed. - // ex: async -> Async - // num_threads -> NumThreads - string flangClass = ""; - // Optional class holding value of the clause in flang AST. - string flangClassValue = ""; + string flangClass = ""; // If set to true, value is optional. Not optional by default. bit isValueOptional = false; diff --git a/llvm/include/llvm/Frontend/OpenACC/ACC.td b/llvm/include/llvm/Frontend/OpenACC/ACC.td --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -34,7 +34,7 @@ // 2.16.1 def ACCC_Async : Clause<"async"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let isValueOptional = true; } @@ -43,12 +43,12 @@ // 2.7.12 def ACCC_Attach : Clause<"attach"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.15.1 def ACCC_Bind : Clause<"bind"> { - let flangClassValue = "AccBindClause"; + let flangClass = "AccBindClause"; } // 2.12 @@ -57,26 +57,26 @@ // 2.9.1 def ACCC_Collapse : Clause<"collapse"> { - let flangClassValue = "ScalarIntConstantExpr"; + let flangClass = "ScalarIntConstantExpr"; } // 2.7.6 def ACCC_Copy : Clause<"copy"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.7.7 def ACCC_Copyin : Clause<"copyin"> { - let flangClassValue = "AccObjectListWithModifier"; + let flangClass = "AccObjectListWithModifier"; } // 2.7.8 def ACCC_Copyout : Clause<"copyout"> { - let flangClassValue = "AccObjectListWithModifier"; + let flangClass = "AccObjectListWithModifier"; } // 2.7.9 def ACCC_Create : Clause<"create"> { - let flangClassValue = "AccObjectListWithModifier"; + let flangClass = "AccObjectListWithModifier"; } // 2.5.15 @@ -84,7 +84,7 @@ def ACC_Default_present : ClauseVal<"present", 0, 1> {} def ACCC_Default : Clause<"default"> { - let flangClassValue = "AccDefaultClause"; + let flangClass = "AccDefaultClause"; let enumClauseValue = "DefaultValue"; let allowedClauseValues = [ ACC_Default_present, @@ -94,42 +94,42 @@ // 2.14.3 def ACCC_DefaultAsync : Clause<"default_async"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } // 2.7.11 def ACCC_Delete : Clause<"delete"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.7.13 def ACCC_Detach : Clause<"detach"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.14.4 def ACCC_Device : Clause<"device"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.14.1 - 2.14.2 def ACCC_DeviceNum : Clause<"device_num"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } // 2.7.4 def ACCC_DevicePtr : Clause<"deviceptr"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.13.1 def ACCC_DeviceResident : Clause<"device_resident"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.4 def ACCC_DeviceType : Clause<"device_type"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let defaultValue = "*"; let isValueOptional = true; let isValueList = true; @@ -140,23 +140,23 @@ // 2.5.13 def ACCC_FirstPrivate : Clause<"firstprivate"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.9.2 def ACCC_Gang : Clause<"gang"> { - let flangClassValue = "AccGangArgument"; + let flangClass = "AccGangArgument"; let isValueOptional = true; } // 2.14.4 def ACCC_Host : Clause<"host"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.5.5 def ACCC_If : Clause <"if"> { - let flangClassValue = "ScalarLogicalExpr"; + let flangClass = "ScalarLogicalExpr"; } // 2.14.4 @@ -167,12 +167,12 @@ // 2.13.3 def ACCC_Link : Clause<"link"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.7.10 def ACCC_NoCreate : Clause<"no_create"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.15.1 @@ -180,32 +180,32 @@ // 2.5.9 def ACCC_NumGangs : Clause<"num_gangs"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } // 2.5.10 def ACCC_NumWorkers : Clause<"num_workers"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } // 2.7.5 def ACCC_Present : Clause<"present"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.5.12 def ACCC_Private : Clause<"private"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.9.8 def ACCC_Tile : Clause <"tile"> { - let flangClassValue = "AccTileExprList"; + let flangClass = "AccTileExprList"; } // 2.8.1 def ACCC_UseDevice : Clause <"use_device"> { - let flangClassValue = "AccObjectList"; + let flangClass = "AccObjectList"; } // 2.12 @@ -213,12 +213,12 @@ // 2.5.14 def ACCC_Reduction : Clause<"reduction"> { - let flangClassValue = "AccObjectListWithReduction"; + let flangClass = "AccObjectListWithReduction"; } // 2.5.6 def ACCC_Self : Clause<"self"> { - let flangClassValue = "AccSelfClause"; + let flangClass = "AccSelfClause"; } // 2.9.5 @@ -226,24 +226,24 @@ // 2.9.4 def ACCC_Vector : Clause<"vector"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let isValueOptional = true; } // 2.5.11 def ACCC_VectorLength : Clause<"vector_length"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } // 2.16.2 def ACCC_Wait : Clause<"wait"> { - let flangClassValue = "AccWaitArgument"; + let flangClass = "AccWaitArgument"; let isValueOptional = true; } // 2.9.3 def ACCC_Worker: Clause<"worker"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let isValueOptional = true; } diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -34,7 +34,7 @@ def OMPC_Allocator : Clause<"allocator"> { let clangClass = "OMPAllocatorClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_If : Clause<"if"> { let clangClass = "OMPIfClause"; @@ -42,47 +42,47 @@ } def OMPC_Final : Clause<"final"> { let clangClass = "OMPFinalClause"; - let flangClassValue = "ScalarLogicalExpr"; + let flangClass = "ScalarLogicalExpr"; } def OMPC_NumThreads : Clause<"num_threads"> { let clangClass = "OMPNumThreadsClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_SafeLen : Clause<"safelen"> { let clangClass = "OMPSafelenClause"; - let flangClassValue = "ScalarIntConstantExpr"; + let flangClass = "ScalarIntConstantExpr"; } def OMPC_SimdLen : Clause<"simdlen"> { let clangClass = "OMPSimdlenClause"; - let flangClassValue = "ScalarIntConstantExpr"; + let flangClass = "ScalarIntConstantExpr"; } def OMPC_Collapse : Clause<"collapse"> { let clangClass = "OMPCollapseClause"; - let flangClassValue = "ScalarIntConstantExpr"; + let flangClass = "ScalarIntConstantExpr"; } def OMPC_Default : Clause<"default"> { let clangClass = "OMPDefaultClause"; - let flangClassValue = "OmpDefaultClause"; + let flangClass = "OmpDefaultClause"; } def OMPC_Private : Clause<"private"> { let clangClass = "OMPPrivateClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_FirstPrivate : Clause<"firstprivate"> { let clangClass = "OMPFirstprivateClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_LastPrivate : Clause<"lastprivate"> { let clangClass = "OMPLastprivateClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_Shared : Clause<"shared"> { let clangClass = "OMPSharedClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_Reduction : Clause<"reduction"> { let clangClass = "OMPReductionClause"; - let flangClassValue = "OmpReductionClause"; + let flangClass = "OmpReductionClause"; } def OMPC_Linear : Clause<"linear"> { let clangClass = "OMPLinearClause"; @@ -94,11 +94,11 @@ } def OMPC_Copyin : Clause<"copyin"> { let clangClass = "OMPCopyinClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_CopyPrivate : Clause<"copyprivate"> { let clangClass = "OMPCopyprivateClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMP_PROC_BIND_master : ClauseVal<"master",2,1> {} def OMP_PROC_BIND_close : ClauseVal<"close",3,1> {} @@ -107,7 +107,7 @@ def OMP_PROC_BIND_unknown : ClauseVal<"unknown",6,0> { let isDefault = true; } def OMPC_ProcBind : Clause<"proc_bind"> { let clangClass = "OMPProcBindClause"; - let flangClassValue = "OmpProcBindClause"; + let flangClass = "OmpProcBindClause"; let enumClauseValue = "ProcBindKind"; let allowedClauseValues = [ OMP_PROC_BIND_master, @@ -142,7 +142,7 @@ def OMPC_Ordered : Clause<"ordered"> { let clangClass = "OMPOrderedClause"; - let flangClassValue = "ScalarIntConstantExpr"; + let flangClass = "ScalarIntConstantExpr"; let isValueOptional = true; } def OMPC_NoWait : Clause<"nowait"> { @@ -167,7 +167,7 @@ } def OMPC_Device : Clause<"device"> { let clangClass = "OMPDeviceClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_Threads : Clause<"threads"> { let clangClass = "OMPThreadsClause"; } def OMPC_Simd : Clause<"simd"> { let clangClass = "OMPSIMDClause"; } @@ -177,34 +177,34 @@ } def OMPC_NumTeams : Clause<"num_teams"> { let clangClass = "OMPNumTeamsClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_ThreadLimit : Clause<"thread_limit"> { let clangClass = "OMPThreadLimitClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_Priority : Clause<"priority"> { let clangClass = "OMPPriorityClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_GrainSize : Clause<"grainsize"> { let clangClass = "OMPGrainsizeClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_NoGroup : Clause<"nogroup"> { let clangClass = "OMPNogroupClause"; } def OMPC_NumTasks : Clause<"num_tasks"> { let clangClass = "OMPNumTasksClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; } def OMPC_Hint : Clause<"hint"> { let clangClass = "OMPHintClause"; - let flangClassValue = "ConstantExpr"; + let flangClass = "ConstantExpr"; } def OMPC_DistSchedule : Clause<"dist_schedule"> { let clangClass = "OMPDistScheduleClause"; - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let isValueOptional = true; } def OMPC_DefaultMap : Clause<"defaultmap"> { @@ -213,25 +213,25 @@ } def OMPC_To : Clause<"to"> { let clangClass = "OMPToClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_From : Clause<"from"> { let clangClass = "OMPFromClause"; - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_UseDevicePtr : Clause<"use_device_ptr"> { let clangClass = "OMPUseDevicePtrClause"; - let flangClassValue = "Name"; + let flangClass = "Name"; let isValueList = true; } def OMPC_IsDevicePtr : Clause<"is_device_ptr"> { let clangClass = "OMPIsDevicePtrClause"; - let flangClassValue = "Name"; + let flangClass = "Name"; let isValueList = true; } def OMPC_TaskReduction : Clause<"task_reduction"> { let clangClass = "OMPTaskReductionClause"; - let flangClassValue = "OmpReductionClause"; + let flangClass = "OmpReductionClause"; } def OMPC_InReduction : Clause<"in_reduction"> { let clangClass = "OMPInReductionClause"; @@ -253,7 +253,7 @@ } def OMPC_Allocate : Clause<"allocate"> { let clangClass = "OMPAllocateClause"; - let flangClassValue = "OmpAllocateClause"; + let flangClass = "OmpAllocateClause"; } def OMPC_NonTemporal : Clause<"nontemporal"> { let clangClass = "OMPNontemporalClause"; @@ -289,7 +289,7 @@ let clangClass = "OMPUseDeviceAddrClause"; } def OMPC_Uniform : Clause<"uniform"> { - let flangClassValue = "Name"; + let flangClass = "Name"; let isValueList = true; } def OMPC_DeviceType : Clause<"device_type"> {} @@ -311,7 +311,7 @@ let isDefault = true; } def OMPC_Link : Clause<"link"> { - let flangClassValue = "OmpObjectList"; + let flangClass = "OmpObjectList"; } def OMPC_Inbranch : Clause<"inbranch"> {} def OMPC_Notinbranch : Clause<"notinbranch"> {} diff --git a/llvm/include/llvm/TableGen/DirectiveEmitter.h b/llvm/include/llvm/TableGen/DirectiveEmitter.h --- a/llvm/include/llvm/TableGen/DirectiveEmitter.h +++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h @@ -138,11 +138,6 @@ return Def->getValueAsString("flangClass"); } - // Optional field. - StringRef getFlangClassValue() const { - return Def->getValueAsString("flangClassValue"); - } - // Get the formatted name for Flang parser class. The generic formatted class // name is constructed from the name were the first letter of each word is // captitalized and the underscores are removed. diff --git a/llvm/test/TableGen/directive1.td b/llvm/test/TableGen/directive1.td --- a/llvm/test/TableGen/directive1.td +++ b/llvm/test/TableGen/directive1.td @@ -20,7 +20,6 @@ def TDLCV_valc : ClauseVal<"valc",3,0> { let isDefault = 1; } def TDLC_ClauseA : Clause<"clausea"> { - let flangClass = "TdlClauseA"; let enumClauseValue = "AKind"; let allowedClauseValues = [ TDLCV_vala, @@ -30,7 +29,7 @@ } def TDLC_ClauseB : Clause<"clauseb"> { - let flangClassValue = "IntExpr"; + let flangClass = "IntExpr"; let isValueOptional = 1; let isDefault = 1; } @@ -226,6 +225,7 @@ // GEN-NEXT: #ifdef GEN_FLANG_CLAUSE_PARSER_CLASSES // GEN-NEXT: #undef GEN_FLANG_CLAUSE_PARSER_CLASSES // GEN-EMPTY: +// GEN-NEXT: EMPTY_CLASS(Clausea); // GEN-NEXT: WRAPPER_CLASS(Clauseb, std::optional); // GEN-EMPTY: // GEN-NEXT: #endif // GEN_FLANG_CLAUSE_PARSER_CLASSES @@ -233,7 +233,7 @@ // GEN-NEXT: #ifdef GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST // GEN-NEXT: #undef GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST // GEN-EMPTY: -// GEN-NEXT: TdlClauseA +// GEN-NEXT: Clausea // GEN-NEXT: , Clauseb // GEN-EMPTY: // GEN-NEXT: #endif // GEN_FLANG_CLAUSE_PARSER_CLASSES_LIST @@ -241,6 +241,7 @@ // GEN-NEXT: #ifdef GEN_FLANG_DUMP_PARSE_TREE_CLAUSES // GEN-NEXT: #undef GEN_FLANG_DUMP_PARSE_TREE_CLAUSES // GEN-EMPTY: +// GEN-NEXT: NODE(TdlClause, Clausea) // GEN-NEXT: NODE(TdlClause, Clauseb) // GEN-EMPTY: // GEN-NEXT: #endif // GEN_FLANG_DUMP_PARSE_TREE_CLAUSES @@ -248,6 +249,7 @@ // GEN-NEXT: #ifdef GEN_FLANG_CLAUSE_UNPARSE // GEN-NEXT: #undef GEN_FLANG_CLAUSE_UNPARSE // GEN-EMPTY: +// GEN-NEXT: void Before(const TdlClause::Clausea &) { Word("CLAUSEA"); } // GEN-NEXT: void Unparse(const TdlClause::Clauseb &x) { // GEN-NEXT: Word("CLAUSEB"); // GEN-NEXT: Walk("(", x.v, ")"); diff --git a/llvm/test/TableGen/directive2.td b/llvm/test/TableGen/directive2.td --- a/llvm/test/TableGen/directive2.td +++ b/llvm/test/TableGen/directive2.td @@ -19,12 +19,12 @@ } def TDLC_ClauseB : Clause<"clauseb"> { let isDefault = 1; - let flangClassValue = "IntExpr"; + let flangClass = "IntExpr"; let isValueList = 1; } def TDLC_ClauseC : Clause<"clausec"> { let clangClass = "ClauseC"; - let flangClassValue = "Name"; + let flangClass = "Name"; let defaultValue = "*"; let isValueOptional = 1; } diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp --- a/llvm/utils/TableGen/DirectiveEmitter.cpp +++ b/llvm/utils/TableGen/DirectiveEmitter.cpp @@ -535,20 +535,16 @@ for (const auto &C : DirLang.getClauses()) { Clause Clause{C}; - // Clause has a non generic class. - if (!Clause.getFlangClass().empty()) - continue; - if (!Clause.getFlangClassValue().empty()) { + if (!Clause.getFlangClass().empty()) { OS << "WRAPPER_CLASS(" << Clause.getFormattedParserClassName() << ", "; if (Clause.isValueOptional() && Clause.isValueList()) { - OS << "std::optional>"; + OS << "std::optional>"; } else if (Clause.isValueOptional()) { - OS << "std::optional<" << Clause.getFlangClassValue() << ">"; + OS << "std::optional<" << Clause.getFlangClass() << ">"; } else if (Clause.isValueList()) { - OS << "std::list<" << Clause.getFlangClassValue() << ">"; + OS << "std::list<" << Clause.getFlangClass() << ">"; } else { - OS << Clause.getFlangClassValue(); + OS << Clause.getFlangClass(); } } else { OS << "EMPTY_CLASS(" << Clause.getFormattedParserClassName(); @@ -566,10 +562,7 @@ OS << "\n"; llvm::interleaveComma(DirLang.getClauses(), OS, [&](Record *C) { Clause Clause{C}; - if (Clause.getFlangClass().empty()) - OS << Clause.getFormattedParserClassName() << "\n"; - else - OS << Clause.getFlangClass() << "\n"; + OS << Clause.getFormattedParserClassName() << "\n"; }); } @@ -582,10 +575,6 @@ OS << "\n"; for (const auto &C : DirLang.getClauses()) { Clause Clause{C}; - // Clause has a non generic class. - if (!Clause.getFlangClass().empty()) - continue; - OS << "NODE(" << DirLang.getFlangClauseBaseClass() << ", " << Clause.getFormattedParserClassName() << ")\n"; } @@ -602,10 +591,7 @@ for (const auto &C : DirLang.getClauses()) { Clause Clause{C}; - // Clause has a non generic class. - if (!Clause.getFlangClass().empty()) - continue; - if (!Clause.getFlangClassValue().empty()) { + if (!Clause.getFlangClass().empty()) { if (Clause.isValueOptional() && Clause.getDefaultValue().empty()) { OS << "void Unparse(const " << DirLang.getFlangClauseBaseClass() << "::" << Clause.getFormattedParserClassName() << " &x) {\n";