From 103e9a5021de5a840a624e416e1535c616081c97 Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 5 Aug 2020 14:20:26 -0400 Subject: [PATCH] [flang][NFC] Unify OpenMP and OpenACC structure checker This patch remove duplicated code between the check-omp-structure and the check-acc-structure and unify it into a check-directive-structure templated class. Reviewed By: kiranchandramohan, sscalpone, ichoyjx Differential Revision: https://reviews.llvm.org/D85104 --- test/TableGen/directive1.td | 12 ++---------- test/TableGen/directive2.td | 12 ++---------- utils/TableGen/DirectiveEmitter.cpp | 15 ++------------- 3 files changed, 6 insertions(+), 33 deletions(-) diff --git a/test/TableGen/directive1.td b/test/TableGen/directive1.td index 49df4e67b53..905d6e28c4f 100644 --- a/test/TableGen/directive1.td +++ b/test/TableGen/directive1.td @@ -161,15 +161,7 @@ def TDL_DirA : Directive<"dira"> { // GEN-NEXT: #ifdef GEN_FLANG_DIRECTIVE_CLAUSE_MAP // GEN-NEXT: #undef GEN_FLANG_DIRECTIVE_CLAUSE_MAP // GEN-EMPTY: -// GEN-NEXT: struct TdlDirectiveClauses { -// GEN-NEXT: const allowed; -// GEN-NEXT: const allowedOnce; -// GEN-NEXT: const allowedExclusive; -// GEN-NEXT: const requiredOneOf; -// GEN-NEXT: }; -// GEN-EMPTY: -// GEN-NEXT: std::unordered_map -// GEN-NEXT: directiveClausesTable = { +// GEN-NEXT: { // GEN-NEXT: {llvm::tdl::Directive::TDLD_dira, // GEN-NEXT: { // GEN-NEXT: llvm::tdl::allowedClauses_TDLD_dira, @@ -178,7 +170,7 @@ def TDL_DirA : Directive<"dira"> { // GEN-NEXT: llvm::tdl::requiredClauses_TDLD_dira, // GEN-NEXT: } // GEN-NEXT: }, -// GEN-NEXT: }; +// GEN-NEXT: } // GEN-EMPTY: // GEN-NEXT: #endif // GEN_FLANG_DIRECTIVE_CLAUSE_MAP diff --git a/test/TableGen/directive2.td b/test/TableGen/directive2.td index e585e11496e..02f9d4ec40e 100644 --- a/test/TableGen/directive2.td +++ b/test/TableGen/directive2.td @@ -152,15 +152,7 @@ def TDL_DirA : Directive<"dira"> { // GEN-NEXT: #ifdef GEN_FLANG_DIRECTIVE_CLAUSE_MAP // GEN-NEXT: #undef GEN_FLANG_DIRECTIVE_CLAUSE_MAP // GEN-EMPTY: -// GEN-NEXT: struct TdlDirectiveClauses { -// GEN-NEXT: const allowed; -// GEN-NEXT: const allowedOnce; -// GEN-NEXT: const allowedExclusive; -// GEN-NEXT: const requiredOneOf; -// GEN-NEXT: }; -// GEN-EMPTY: -// GEN-NEXT: std::unordered_map -// GEN-NEXT: directiveClausesTable = { +// GEN-NEXT: { // GEN-NEXT: {llvm::tdl::Directive::TDLD_dira, // GEN-NEXT: { // GEN-NEXT: llvm::tdl::allowedClauses_TDLD_dira, @@ -169,6 +161,6 @@ def TDL_DirA : Directive<"dira"> { // GEN-NEXT: llvm::tdl::requiredClauses_TDLD_dira, // GEN-NEXT: } // GEN-NEXT: }, -// GEN-NEXT: }; +// GEN-NEXT: } // GEN-EMPTY: // GEN-NEXT: #endif // GEN_FLANG_DIRECTIVE_CLAUSE_MAP diff --git a/utils/TableGen/DirectiveEmitter.cpp b/utils/TableGen/DirectiveEmitter.cpp index 0e7f17c3541..60c80eb09d7 100644 --- a/utils/TableGen/DirectiveEmitter.cpp +++ b/utils/TableGen/DirectiveEmitter.cpp @@ -465,18 +465,7 @@ void GenerateDirectiveClauseMap(const std::vector &Directives, IfDefScope Scope("GEN_FLANG_DIRECTIVE_CLAUSE_MAP", OS); OS << "\n"; - OS << "struct " << DirLang.getName() << "DirectiveClauses {\n"; - OS << " const " << DirLang.getClauseEnumSetClass() << " allowed;\n"; - OS << " const " << DirLang.getClauseEnumSetClass() << " allowedOnce;\n"; - OS << " const " << DirLang.getClauseEnumSetClass() << " allowedExclusive;\n"; - OS << " const " << DirLang.getClauseEnumSetClass() << " requiredOneOf;\n"; - OS << "};\n"; - - OS << "\n"; - - OS << "std::unordered_map\n"; - OS << " directiveClausesTable = {\n"; + OS << "{\n"; for (const auto &D : Directives) { Directive Dir{D}; @@ -497,7 +486,7 @@ void GenerateDirectiveClauseMap(const std::vector &Directives, OS << " },\n"; } - OS << "};\n"; + OS << "}\n"; } // Generate the implemenation section for the enumeration in the directive