[openmp] Move Directive and Clause helper function to tablegen
Summary:
Follow up to D81736. Move getOpenMPDirectiveKind, getOpenMPClauseKind, getOpenMPDirectiveName and
getOpenMPClauseName to the new tablegen code generation. The code is generated in a new file named OMP.cpp.inc
Reviewers: jdoerfert, jdenny, thakis
Reviewed By: jdoerfert, jdenny
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, llvm-commits, thakis
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82405
2020-06-30 20:36:37 +02:00
|
|
|
// RUN: llvm-tblgen -gen-directive-decl -I %p/../../include %s | FileCheck -match-full-lines %s
|
|
|
|
// RUN: llvm-tblgen -gen-directive-impl -I %p/../../include %s | FileCheck -match-full-lines %s -check-prefix=IMPL
|
[openmp] Base of tablegen generated OpenMP common declaration
Summary:
As discussed previously when landing patch for OpenMP in Flang, the idea is
to share common part of the OpenMP declaration between the different Frontend.
While doing this it was thought that moving to tablegen instead of Macros will also
give a cleaner and more powerful way of generating these declaration.
This first part of a future series of patches is setting up the base .td file for
DirectiveLanguage as well as the OpenMP version of it. The base file is meant to
be used by other directive language such as OpenACC.
In this first patch, the Directive and Clause enums are generated with tablegen
instead of the macros on OMPConstants.h. The next pacth will extend this
to other enum and move the Flang frontend to use it.
Reviewers: jdoerfert, DavidTruby, fghanim, ABataev, jdenny, hfinkel, jhuber6, kiranchandramohan, kiranktp
Reviewed By: jdoerfert, jdenny
Subscribers: arphaman, martong, cfe-commits, mgorny, yaxunl, hiraditya, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #openmp, #clang
Differential Revision: https://reviews.llvm.org/D81736
2020-06-23 15:29:50 +02:00
|
|
|
|
|
|
|
include "llvm/Frontend/Directive/DirectiveBase.td"
|
|
|
|
|
|
|
|
def TestDirectiveLanguage : DirectiveLanguage {
|
[openmp] Move Directive and Clause helper function to tablegen
Summary:
Follow up to D81736. Move getOpenMPDirectiveKind, getOpenMPClauseKind, getOpenMPDirectiveName and
getOpenMPClauseName to the new tablegen code generation. The code is generated in a new file named OMP.cpp.inc
Reviewers: jdoerfert, jdenny, thakis
Reviewed By: jdoerfert, jdenny
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, llvm-commits, thakis
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82405
2020-06-30 20:36:37 +02:00
|
|
|
let name = "Tdl";
|
[openmp] Base of tablegen generated OpenMP common declaration
Summary:
As discussed previously when landing patch for OpenMP in Flang, the idea is
to share common part of the OpenMP declaration between the different Frontend.
While doing this it was thought that moving to tablegen instead of Macros will also
give a cleaner and more powerful way of generating these declaration.
This first part of a future series of patches is setting up the base .td file for
DirectiveLanguage as well as the OpenMP version of it. The base file is meant to
be used by other directive language such as OpenACC.
In this first patch, the Directive and Clause enums are generated with tablegen
instead of the macros on OMPConstants.h. The next pacth will extend this
to other enum and move the Flang frontend to use it.
Reviewers: jdoerfert, DavidTruby, fghanim, ABataev, jdenny, hfinkel, jhuber6, kiranchandramohan, kiranktp
Reviewed By: jdoerfert, jdenny
Subscribers: arphaman, martong, cfe-commits, mgorny, yaxunl, hiraditya, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #openmp, #clang
Differential Revision: https://reviews.llvm.org/D81736
2020-06-23 15:29:50 +02:00
|
|
|
|
|
|
|
let cppNamespace = "tdl";
|
|
|
|
let directivePrefix = "TDLD_";
|
|
|
|
let clausePrefix = "TDLC_";
|
|
|
|
let makeEnumAvailableInNamespace = 1;
|
|
|
|
let enableBitmaskEnumInNamespace = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
def TDLC_ClauseA : Clause<"clausea"> {}
|
[openmp] Move Directive and Clause helper function to tablegen
Summary:
Follow up to D81736. Move getOpenMPDirectiveKind, getOpenMPClauseKind, getOpenMPDirectiveName and
getOpenMPClauseName to the new tablegen code generation. The code is generated in a new file named OMP.cpp.inc
Reviewers: jdoerfert, jdenny, thakis
Reviewed By: jdoerfert, jdenny
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, llvm-commits, thakis
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82405
2020-06-30 20:36:37 +02:00
|
|
|
def TDLC_ClauseB : Clause<"clauseb"> {
|
|
|
|
let isDefault = 1;
|
|
|
|
}
|
[openmp] Base of tablegen generated OpenMP common declaration
Summary:
As discussed previously when landing patch for OpenMP in Flang, the idea is
to share common part of the OpenMP declaration between the different Frontend.
While doing this it was thought that moving to tablegen instead of Macros will also
give a cleaner and more powerful way of generating these declaration.
This first part of a future series of patches is setting up the base .td file for
DirectiveLanguage as well as the OpenMP version of it. The base file is meant to
be used by other directive language such as OpenACC.
In this first patch, the Directive and Clause enums are generated with tablegen
instead of the macros on OMPConstants.h. The next pacth will extend this
to other enum and move the Flang frontend to use it.
Reviewers: jdoerfert, DavidTruby, fghanim, ABataev, jdenny, hfinkel, jhuber6, kiranchandramohan, kiranktp
Reviewed By: jdoerfert, jdenny
Subscribers: arphaman, martong, cfe-commits, mgorny, yaxunl, hiraditya, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #openmp, #clang
Differential Revision: https://reviews.llvm.org/D81736
2020-06-23 15:29:50 +02:00
|
|
|
|
|
|
|
def TDL_DirA : Directive<"dira"> {
|
|
|
|
let allowedClauses = [TDLC_ClauseA, TDLC_ClauseB];
|
[openmp] Move Directive and Clause helper function to tablegen
Summary:
Follow up to D81736. Move getOpenMPDirectiveKind, getOpenMPClauseKind, getOpenMPDirectiveName and
getOpenMPClauseName to the new tablegen code generation. The code is generated in a new file named OMP.cpp.inc
Reviewers: jdoerfert, jdenny, thakis
Reviewed By: jdoerfert, jdenny
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, llvm-commits, thakis
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82405
2020-06-30 20:36:37 +02:00
|
|
|
let isDefault = 1;
|
[openmp] Base of tablegen generated OpenMP common declaration
Summary:
As discussed previously when landing patch for OpenMP in Flang, the idea is
to share common part of the OpenMP declaration between the different Frontend.
While doing this it was thought that moving to tablegen instead of Macros will also
give a cleaner and more powerful way of generating these declaration.
This first part of a future series of patches is setting up the base .td file for
DirectiveLanguage as well as the OpenMP version of it. The base file is meant to
be used by other directive language such as OpenACC.
In this first patch, the Directive and Clause enums are generated with tablegen
instead of the macros on OMPConstants.h. The next pacth will extend this
to other enum and move the Flang frontend to use it.
Reviewers: jdoerfert, DavidTruby, fghanim, ABataev, jdenny, hfinkel, jhuber6, kiranchandramohan, kiranktp
Reviewed By: jdoerfert, jdenny
Subscribers: arphaman, martong, cfe-commits, mgorny, yaxunl, hiraditya, guansong, jfb, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm, #openmp, #clang
Differential Revision: https://reviews.llvm.org/D81736
2020-06-23 15:29:50 +02:00
|
|
|
}
|
|
|
|
|
[openmp] Move Directive and Clause helper function to tablegen
Summary:
Follow up to D81736. Move getOpenMPDirectiveKind, getOpenMPClauseKind, getOpenMPDirectiveName and
getOpenMPClauseName to the new tablegen code generation. The code is generated in a new file named OMP.cpp.inc
Reviewers: jdoerfert, jdenny, thakis
Reviewed By: jdoerfert, jdenny
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, llvm-commits, thakis
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82405
2020-06-30 20:36:37 +02:00
|
|
|
// CHECK: #ifndef LLVM_Tdl_INC
|
|
|
|
// CHECK-NEXT: #define LLVM_Tdl_INC
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: #include "llvm/ADT/BitmaskEnum.h"
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: namespace llvm {
|
|
|
|
// CHECK-NEXT: class StringRef;
|
|
|
|
// CHECK-NEXT: namespace tdl {
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: enum class Directive {
|
|
|
|
// CHECK-NEXT: TDLD_dira,
|
|
|
|
// CHECK-NEXT: };
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: static constexpr std::size_t Directive_enumSize = 1;
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: constexpr auto TDLD_dira = llvm::tdl::Directive::TDLD_dira;
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: enum class Clause {
|
|
|
|
// CHECK-NEXT: TDLC_clausea,
|
|
|
|
// CHECK-NEXT: TDLC_clauseb,
|
|
|
|
// CHECK-NEXT: };
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: static constexpr std::size_t Clause_enumSize = 2;
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: constexpr auto TDLC_clausea = llvm::tdl::Clause::TDLC_clausea;
|
|
|
|
// CHECK-NEXT: constexpr auto TDLC_clauseb = llvm::tdl::Clause::TDLC_clauseb;
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: // Enumeration helper functions
|
|
|
|
// CHECK-NEXT: Directive getTdlDirectiveKind(llvm::StringRef Str);
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: llvm::StringRef getTdlDirectiveName(Directive D);
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: Clause getTdlClauseKind(llvm::StringRef Str);
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: llvm::StringRef getTdlClauseName(Clause C);
|
|
|
|
// CHECK-EMPTY:
|
|
|
|
// CHECK-NEXT: } // namespace tdl
|
|
|
|
// CHECK-NEXT: } // namespace llvm
|
|
|
|
// CHECK-NEXT: #endif // LLVM_Tdl_INC
|
|
|
|
|
|
|
|
|
|
|
|
// IMPL: 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);
|
|
|
|
// IMPL-NEXT: }
|
|
|
|
// IMPL-EMPTY:
|
|
|
|
// IMPL-NEXT: llvm::StringRef llvm::tdl::getTdlDirectiveName(Directive Kind) {
|
|
|
|
// IMPL-NEXT: switch (Kind) {
|
|
|
|
// IMPL-NEXT: case TDLD_dira:
|
|
|
|
// IMPL-NEXT: return "dira";
|
|
|
|
// IMPL-NEXT: }
|
|
|
|
// IMPL-NEXT: llvm_unreachable("Invalid Tdl Directive kind");
|
|
|
|
// IMPL-NEXT: }
|
|
|
|
// IMPL-EMPTY:
|
|
|
|
// IMPL-NEXT: Clause llvm::tdl::getTdlClauseKind(llvm::StringRef Str) {
|
|
|
|
// IMPL-NEXT: return llvm::StringSwitch<Clause>(Str)
|
|
|
|
// IMPL-NEXT: .Case("clausea",TDLC_clausea)
|
|
|
|
// IMPL-NEXT: .Case("clauseb",TDLC_clauseb)
|
|
|
|
// IMPL-NEXT: .Default(TDLC_clauseb);
|
|
|
|
// IMPL-NEXT: }
|
|
|
|
// IMPL-EMPTY:
|
|
|
|
// IMPL-NEXT: llvm::StringRef llvm::tdl::getTdlClauseName(Clause Kind) {
|
|
|
|
// IMPL-NEXT: switch (Kind) {
|
|
|
|
// IMPL-NEXT: case TDLC_clausea:
|
|
|
|
// IMPL-NEXT: return "clausea";
|
|
|
|
// IMPL-NEXT: case TDLC_clauseb:
|
|
|
|
// IMPL-NEXT: return "clauseb";
|
|
|
|
// IMPL-NEXT: }
|
|
|
|
// IMPL-NEXT: llvm_unreachable("Invalid Tdl Clause kind");
|
|
|
|
// IMPL-NEXT: }
|