[flang-commits] [flang] 6bd0a44 - [flang][directive] Get rid of flangClassValue in TableGen
via flang-commits
flang-commits at lists.llvm.org
Tue Jan 19 07:28:58 PST 2021
Author: Valentin Clement
Date: 2021-01-19T10:28:46-05:00
New Revision: 6bd0a4451ccd4a5cbab1f735052edbcafcb856ea
URL: https://github.com/llvm/llvm-project/commit/6bd0a4451ccd4a5cbab1f735052edbcafcb856ea
DIFF: https://github.com/llvm/llvm-project/commit/6bd0a4451ccd4a5cbab1f735052edbcafcb856ea.diff
LOG: [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
Added:
Modified:
flang/lib/Lower/OpenMP.cpp
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/Directive/DirectiveBase.td
llvm/include/llvm/Frontend/OpenACC/ACC.td
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive1.td
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp
Removed:
################################################################################
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index f765723bb9ae..c16b1beeb4a7 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -148,8 +148,9 @@ genOMP(Fortran::lower::AbstractConverter &converter,
std::get<Fortran::parser::OmpClauseList>(beginBlockDirective.t);
for (const auto &clause : parallelOpClauseList.v) {
if (const auto &ifClause =
- std::get_if<Fortran::parser::OmpIfClause>(&clause.u)) {
- auto &expr = std::get<Fortran::parser::ScalarLogicalExpr>(ifClause->t);
+ std::get_if<Fortran::parser::OmpClause::If>(&clause.u)) {
+ auto &expr =
+ std::get<Fortran::parser::ScalarLogicalExpr>(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 4588a95f2938..93f70e165f6b 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<OmpClause>(construct<OmpClause::Acquire>()) ||
"ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) ||
- "ALIGNED" >>
- construct<OmpClause>(parenthesized(Parser<OmpAlignedClause>{})) ||
+ "ALIGNED" >> construct<OmpClause>(construct<OmpClause::Aligned>(
+ parenthesized(Parser<OmpAlignedClause>{}))) ||
"ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>(
parenthesized(Parser<OmpAllocateClause>{}))) ||
"ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>(
@@ -169,10 +169,10 @@ TYPE_PARSER(
(parenthesized(Parser<OmpObjectList>{})))) ||
"DEFAULT"_id >> construct<OmpClause>(construct<OmpClause::Default>(
parenthesized(Parser<OmpDefaultClause>{}))) ||
- "DEFAULTMAP" >>
- construct<OmpClause>(parenthesized(Parser<OmpDefaultmapClause>{})) ||
- "DEPEND" >>
- construct<OmpClause>(parenthesized(Parser<OmpDependClause>{})) ||
+ "DEFAULTMAP" >> construct<OmpClause>(construct<OmpClause::Defaultmap>(
+ parenthesized(Parser<OmpDefaultmapClause>{}))) ||
+ "DEPEND" >> construct<OmpClause>(construct<OmpClause::Depend>(
+ parenthesized(Parser<OmpDependClause>{}))) ||
"DEVICE" >> construct<OmpClause>(construct<OmpClause::Device>(
parenthesized(scalarIntExpr))) ||
"DIST_SCHEDULE" >>
@@ -188,17 +188,19 @@ TYPE_PARSER(
parenthesized(scalarIntExpr))) ||
"HINT" >> construct<OmpClause>(
construct<OmpClause::Hint>(parenthesized(constantExpr))) ||
- "IF" >> construct<OmpClause>(parenthesized(Parser<OmpIfClause>{})) ||
+ "IF" >> construct<OmpClause>(construct<OmpClause::If>(
+ parenthesized(Parser<OmpIfClause>{}))) ||
"INBRANCH" >> construct<OmpClause>(construct<OmpClause::Inbranch>()) ||
"IS_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::IsDevicePtr>(
parenthesized(nonemptyList(name)))) ||
"LASTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Lastprivate>(
parenthesized(Parser<OmpObjectList>{}))) ||
- "LINEAR" >>
- construct<OmpClause>(parenthesized(Parser<OmpLinearClause>{})) ||
+ "LINEAR" >> construct<OmpClause>(construct<OmpClause::Linear>(
+ parenthesized(Parser<OmpLinearClause>{}))) ||
"LINK" >> construct<OmpClause>(construct<OmpClause::Link>(
parenthesized(Parser<OmpObjectList>{}))) ||
- "MAP" >> construct<OmpClause>(parenthesized(Parser<OmpMapClause>{})) ||
+ "MAP" >> construct<OmpClause>(construct<OmpClause::Map>(
+ parenthesized(Parser<OmpMapClause>{}))) ||
"MERGEABLE" >> construct<OmpClause>(construct<OmpClause::Mergeable>()) ||
"NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) ||
"NOTINBRANCH" >>
@@ -227,8 +229,8 @@ TYPE_PARSER(
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
"SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>(
parenthesized(scalarIntConstantExpr))) ||
- "SCHEDULE" >>
- construct<OmpClause>(parenthesized(Parser<OmpScheduleClause>{})) ||
+ "SCHEDULE" >> construct<OmpClause>(construct<OmpClause::Schedule>(
+ parenthesized(Parser<OmpScheduleClause>{}))) ||
"SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) ||
"SHARED" >> construct<OmpClause>(construct<OmpClause::Shared>(
parenthesized(Parser<OmpObjectList>{}))) ||
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index 5bf8db8bf0a1..8adcc32b87af 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -1974,43 +1974,33 @@ class UnparseVisitor {
}
void Unparse(const OmpMapType::Always &) { Word("ALWAYS,"); }
void Unparse(const OmpMapClause &x) {
- Word("MAP(");
Walk(std::get<std::optional<OmpMapType>>(x.t), ":");
Walk(std::get<OmpObjectList>(x.t));
- Put(") ");
}
void Unparse(const OmpScheduleModifier &x) {
Walk(std::get<OmpScheduleModifier::Modifier1>(x.t));
Walk(",", std::get<std::optional<OmpScheduleModifier::Modifier2>>(x.t));
}
void Unparse(const OmpScheduleClause &x) {
- Word("SCHEDULE(");
Walk(std::get<std::optional<OmpScheduleModifier>>(x.t), ":");
Walk(std::get<OmpScheduleClause::ScheduleType>(x.t));
Walk(",", std::get<std::optional<ScalarIntExpr>>(x.t));
- Put(")");
}
void Unparse(const OmpAlignedClause &x) {
- Word("ALIGNED("), Walk(std::get<std::list<Name>>(x.t), ",");
+ Walk(std::get<std::list<Name>>(x.t), ",");
Walk(std::get<std::optional<ScalarIntConstantExpr>>(x.t));
- Put(") ");
}
void Unparse(const OmpIfClause &x) {
- Word("IF("),
- Walk(std::get<std::optional<OmpIfClause::DirectiveNameModifier>>(x.t),
- ":");
+ Walk(std::get<std::optional<OmpIfClause::DirectiveNameModifier>>(x.t), ":");
Walk(std::get<ScalarLogicalExpr>(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<OmpReductionOperator>(x.t));
@@ -2040,28 +2030,23 @@ class UnparseVisitor {
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<OmpDefaultmapClause::ImplicitBehavior>(x.t));
Walk(":",
std::get<std::optional<OmpDefaultmapClause::VariableCategory>>(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 a9064490c352..16f851a1a1d0 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<parser::OmpScheduleClause>(clause->u)};
- if (ScheduleModifierHasType(schedClause,
+ const auto &schedClause{std::get<parser::OmpClause::Schedule>(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 164559d59aa7..e40f40f74c73 100644
--- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td
+++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td
@@ -77,15 +77,8 @@ class Clause<string c> {
// 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 58bb73fb6402..6045a9ac2af0 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 b5b5bb238bae..10fa5a37b891 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 41258ade8963..27ad0665a0e8 100644
--- a/llvm/include/llvm/TableGen/DirectiveEmitter.h
+++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h
@@ -138,11 +138,6 @@ class Clause : public BaseRecord {
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 a63b4065f86a..dbf9b6c03d3a 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<IntExpr>);
// 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 f7b1e7365b1e..1e02cbd01dad 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 590fedbb02c5..c9daa9b24155 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<std::list<" << Clause.getFlangClassValue()
- << ">>";
+ OS << "std::optional<std::list<" << Clause.getFlangClass() << ">>";
} 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";
More information about the flang-commits
mailing list