From: Valentin Clement Date: Tue, 19 Jan 2021 15:28:09 +0000 (-0500) Subject: [flang][directive] Get rid of flangClassValue in TableGen X-Git-Tag: llvmorg-13-init~821 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6bd0a4451ccd4a5cbab1f735052edbcafcb856ea;p=platform%2Fupstream%2Fllvm.git [flang][directive] Get rid of flangClassValue in TableGen The TableGen emitter for directives has two slots for flangClass information and this was mainly to be able to keep up with the legacy openmp parser at the time. Now that all clauses are encapsulated in AccClause or OmpClause, these two strings are not necessary anymore and were the the source of couple of problem while working with the generic structure checker for OpenMP. This patch remove the flangClassValue string from DirectiveBase.td and use the string flangClass as the placeholder for the encapsulated class. Reviewed By: sameeranjoshi Differential Revision: https://reviews.llvm.org/D94821 --- diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index f765723..c16b1be 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -148,8 +148,9 @@ genOMP(Fortran::lower::AbstractConverter &converter, 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 index 4588a95..93f70e1 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -155,8 +155,8 @@ TYPE_PARSER( 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 @@ TYPE_PARSER( (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 @@ TYPE_PARSER( 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 @@ TYPE_PARSER( "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 index 5bf8db8..8adcc32 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -1974,43 +1974,33 @@ public: } 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 @@ public: 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 index a906449..16f851a 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -389,15 +389,15 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) { 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 index 164559d..e40f40f 100644 --- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td +++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td @@ -77,15 +77,8 @@ class Clause { // 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 index 58bb73f..6045a9a 100644 --- a/llvm/include/llvm/Frontend/OpenACC/ACC.td +++ b/llvm/include/llvm/Frontend/OpenACC/ACC.td @@ -34,7 +34,7 @@ def OpenACC : DirectiveLanguage { // 2.16.1 def ACCC_Async : Clause<"async"> { - let flangClassValue = "ScalarIntExpr"; + let flangClass = "ScalarIntExpr"; let isValueOptional = true; } @@ -43,12 +43,12 @@ def ACCC_Auto : Clause<"auto"> {} // 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 @@ def ACCC_Capture : Clause<"capture"> { // 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_none : ClauseVal<"none", 1, 1> { let isDefault = 1; } 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 @@ def ACCC_Default : Clause<"default"> { // 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 @@ def ACCC_Finalize : Clause<"finalize"> {} // 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 @@ def ACCC_Independent : Clause<"independent"> {} // 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 @@ def ACCC_NoHost : Clause<"nohost"> {} // 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 @@ def ACCC_Read : Clause<"read"> {} // 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 @@ def ACCC_Seq : Clause<"seq"> {} // 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 index b5b5bb2..10fa5a3 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -34,7 +34,7 @@ def OpenMP : DirectiveLanguage { 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_If : Clause<"if"> { } 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_Aligned : Clause<"aligned"> { } 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_default : ClauseVal<"default",5,0> {} 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_Schedule : Clause<"schedule"> { 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_Depend : Clause<"depend"> { } 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_Map : Clause<"map"> { } 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_DefaultMap : Clause<"defaultmap"> { } 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_AtomicDefaultMemOrder : Clause<"atomic_default_mem_order"> { } 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 @@ def OMPC_UseDeviceAddr : Clause<"use_device_addr"> { 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 @@ def OMPC_Unknown : Clause<"unknown"> { 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 index 41258ad..27ad0665a 100644 --- a/llvm/include/llvm/TableGen/DirectiveEmitter.h +++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h @@ -138,11 +138,6 @@ public: 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 index a63b406..dbf9b6c 100644 --- a/llvm/test/TableGen/directive1.td +++ b/llvm/test/TableGen/directive1.td @@ -20,7 +20,6 @@ def TDLCV_valb : ClauseVal<"valb",2,1> {} 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_ClauseA : Clause<"clausea"> { } def TDLC_ClauseB : Clause<"clauseb"> { - let flangClassValue = "IntExpr"; + let flangClass = "IntExpr"; let isValueOptional = 1; let isDefault = 1; } @@ -226,6 +225,7 @@ def TDL_DirA : Directive<"dira"> { // 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 @@ def TDL_DirA : Directive<"dira"> { // 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 @@ def TDL_DirA : Directive<"dira"> { // 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 @@ def TDL_DirA : Directive<"dira"> { // 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 index f7b1e73..1e02cbd 100644 --- a/llvm/test/TableGen/directive2.td +++ b/llvm/test/TableGen/directive2.td @@ -19,12 +19,12 @@ def TDLC_ClauseA : Clause<"clausea"> { } 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 index 590fedb..c9daa9b 100644 --- a/llvm/utils/TableGen/DirectiveEmitter.cpp +++ b/llvm/utils/TableGen/DirectiveEmitter.cpp @@ -535,20 +535,16 @@ void GenerateFlangClauseParserClass(const DirectiveLanguage &DirLang, 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 @@ void GenerateFlangClauseParserClassList(const DirectiveLanguage &DirLang, 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 @@ void GenerateFlangClauseDump(const DirectiveLanguage &DirLang, 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 @@ void GenerateFlangClauseUnparse(const DirectiveLanguage &DirLang, 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";