[llvm] 943660f - [openmp] Remove OMPConstants.cpp and replace it by OMP.cpp generated by tablegen
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 10 17:12:07 PDT 2020
Author: Valentin Clement
Date: 2020-07-10T20:11:57-04:00
New Revision: 943660fd15f193dc6961597c25541fee2e01ebbb
URL: https://github.com/llvm/llvm-project/commit/943660fd15f193dc6961597c25541fee2e01ebbb
DIFF: https://github.com/llvm/llvm-project/commit/943660fd15f193dc6961597c25541fee2e01ebbb.diff
LOG: [openmp] Remove OMPConstants.cpp and replace it by OMP.cpp generated by tablegen
Summary:
Diff D83176 moved the last piece of code from OMPConstants.cpp and now this file was only
useful to include the tablegen generated file. This patch replace OMPConstants.cpp with OMP.cpp
generated by tablegen.
Reviewers: sstefan1, jdoerfert, jdenny
Reviewed By: sstefan1
Subscribers: mgorny, yaxunl, hiraditya, guansong, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83583
Added:
Modified:
llvm/include/llvm/Frontend/Directive/DirectiveBase.td
llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/lib/Frontend/OpenMP/CMakeLists.txt
llvm/test/TableGen/directive1.td
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp
Removed:
llvm/lib/Frontend/OpenMP/OMPConstants.cpp
################################################################################
diff --git a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td
index 87fb88c31ed0..785a520613b9 100644
--- a/llvm/include/llvm/Frontend/Directive/DirectiveBase.td
+++ b/llvm/include/llvm/Frontend/Directive/DirectiveBase.td
@@ -39,6 +39,10 @@ class DirectiveLanguage {
// Generate include and macro to enable LLVM BitmaskEnum.
bit enableBitmaskEnumInNamespace = 0;
+
+ // Header file included in the implementation code generated. Ususally the
+ // output file of the declaration code generation. Can be left blank.
+ string includeHeader = "";
}
// Information about a specific clause.
diff --git a/llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt b/llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
index e93fa38becfc..69f503675940 100644
--- a/llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
+++ b/llvm/include/llvm/Frontend/OpenMP/CMakeLists.txt
@@ -1,4 +1,3 @@
set(LLVM_TARGET_DEFINITIONS OMP.td)
tablegen(LLVM OMP.h.inc --gen-directive-decl)
-tablegen(LLVM OMP.cpp.inc --gen-directive-impl)
add_public_tablegen_target(omp_gen)
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td
index 692bd2fb3210..bd81eeb01127 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -23,6 +23,7 @@ def OpenMP : DirectiveLanguage {
let clausePrefix = "OMPC_";
let makeEnumAvailableInNamespace = 1;
let enableBitmaskEnumInNamespace = 1;
+ let includeHeader = "llvm/Frontend/OpenMP/OMP.h.inc";
}
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Frontend/OpenMP/CMakeLists.txt b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
index d137304ddc32..f88e3ed98662 100644
--- a/llvm/lib/Frontend/OpenMP/CMakeLists.txt
+++ b/llvm/lib/Frontend/OpenMP/CMakeLists.txt
@@ -1,5 +1,9 @@
+set(LLVM_TARGET_DEFINITIONS ${LLVM_MAIN_INCLUDE_DIR}/llvm/Frontend/OpenMP/OMP.td)
+tablegen(LLVM OMP.cpp --gen-directive-impl)
+add_public_tablegen_target(omp_cpp)
+
add_llvm_component_library(LLVMFrontendOpenMP
- OMPConstants.cpp
+ OMP.cpp # Generated by tablegen above
OMPContext.cpp
OMPIRBuilder.cpp
@@ -10,4 +14,5 @@ add_llvm_component_library(LLVMFrontendOpenMP
DEPENDS
intrinsics_gen
omp_gen
- )
+ omp_cpp
+ )
\ No newline at end of file
diff --git a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp b/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
deleted file mode 100644
index fdee3c5ef658..000000000000
--- a/llvm/lib/Frontend/OpenMP/OMPConstants.cpp
+++ /dev/null
@@ -1,21 +0,0 @@
-//===- OMPConstants.cpp - Helpers related to OpenMP code generation ---===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Frontend/OpenMP/OMPConstants.h"
-
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/StringSwitch.h"
-#include "llvm/IR/Module.h"
-#include "llvm/IR/Type.h"
-
-using namespace llvm;
-using namespace omp;
-
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
diff --git a/llvm/test/TableGen/directive1.td b/llvm/test/TableGen/directive1.td
index 43b7ec399b99..8b3cc8702bd4 100644
--- a/llvm/test/TableGen/directive1.td
+++ b/llvm/test/TableGen/directive1.td
@@ -72,7 +72,13 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-NEXT: #endif // LLVM_Tdl_INC
-// IMPL: Directive llvm::tdl::getTdlDirectiveKind(llvm::StringRef Str) {
+// IMPL: #include "llvm/ADT/StringRef.h"
+// IMPL-NEXT: #include "llvm/ADT/StringSwitch.h"
+// IMPL-EMPTY:
+// IMPL-NEXT: using namespace llvm;
+// IMPL-NEXT: using namespace tdl;
+// IMPL-EMPTY:
+// IMPL-NEXT: Directive llvm::tdl::getTdlDirectiveKind(llvm::StringRef Str) {
// IMPL-NEXT: return llvm::StringSwitch<Directive>(Str)
// IMPL-NEXT: .Case("dira",TDLD_dira)
// IMPL-NEXT: .Default(TDLD_dira);
diff --git a/llvm/test/TableGen/directive2.td b/llvm/test/TableGen/directive2.td
index 10f48c2a3ceb..06c7aabcf3ad 100644
--- a/llvm/test/TableGen/directive2.td
+++ b/llvm/test/TableGen/directive2.td
@@ -9,6 +9,7 @@ def TestDirectiveLanguage : DirectiveLanguage {
let cppNamespace = "tdl";
let directivePrefix = "TDLD_";
let clausePrefix = "TDLC_";
+ let includeHeader = "tdl.h.inc";
}
def TDLC_ClauseA : Clause<"clausea"> {
@@ -62,7 +63,14 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-NEXT: } // namespace llvm
// CHECK-NEXT: #endif // LLVM_Tdl_INC
-
+// IMPL: #include "tdl.h.inc"
+// IMPL-EMPTY:
+// IMPL-NEXT: #include "llvm/ADT/StringRef.h"
+// IMPL-NEXT: #include "llvm/ADT/StringSwitch.h"
+// IMPL-EMPTY:
+// IMPL-NEXT: using namespace llvm;
+// IMPL-NEXT: using namespace tdl;
+// IMPL-EMPTY:
// IMPL: Directive llvm::tdl::getTdlDirectiveKind(llvm::StringRef Str) {
// IMPL-NEXT: return llvm::StringSwitch<Directive>(Str)
// IMPL-NEXT: .Case("dira",TDLD_dira)
diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp
index d4d2b7965420..37f1677a7a84 100644
--- a/llvm/utils/TableGen/DirectiveEmitter.cpp
+++ b/llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -284,10 +284,24 @@ void EmitDirectivesImpl(RecordKeeper &Records, raw_ostream &OS) {
StringRef LanguageName = DirectiveLanguage->getValueAsString("name");
StringRef ClausePrefix = DirectiveLanguage->getValueAsString("clausePrefix");
StringRef CppNamespace = DirectiveLanguage->getValueAsString("cppNamespace");
+ StringRef IncludeHeader =
+ DirectiveLanguage->getValueAsString("includeHeader");
const auto &Directives = Records.getAllDerivedDefinitions("Directive");
const auto &Clauses = Records.getAllDerivedDefinitions("Clause");
+ if (!IncludeHeader.empty())
+ OS << "#include \"" << IncludeHeader << "\"\n\n";
+
+ OS << "#include \"llvm/ADT/StringRef.h\"\n";
+ OS << "#include \"llvm/ADT/StringSwitch.h\"\n";
+ OS << "\n";
+ OS << "using namespace llvm;\n";
+ llvm::SmallVector<StringRef, 2> Namespaces;
+ llvm::SplitString(CppNamespace, Namespaces, "::");
+ for (auto Ns : Namespaces)
+ OS << "using namespace " << Ns << ";\n";
+
// getDirectiveKind(StringRef Str)
GenerateGetKind(Directives, OS, "Directive", DirectivePrefix, LanguageName,
CppNamespace, /*ImplicitAsUnknown=*/false);
More information about the llvm-commits
mailing list