[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
This commit is contained in:
Valentin Clement
2020-07-10 20:11:11 -04:00
committed by clementval
parent cd0ea03e6f
commit 943660fd15
8 changed files with 42 additions and 26 deletions
@@ -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.
@@ -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)
+1
View File
@@ -23,6 +23,7 @@ def OpenMP : DirectiveLanguage {
let clausePrefix = "OMPC_";
let makeEnumAvailableInNamespace = 1;
let enableBitmaskEnumInNamespace = 1;
let includeHeader = "llvm/Frontend/OpenMP/OMP.h.inc";
}
//===----------------------------------------------------------------------===//
+7 -2
View File
@@ -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
)
-21
View File
@@ -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"
+7 -1
View File
@@ -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);
+9 -1
View File
@@ -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)
+14
View File
@@ -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);