[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 21:29:50 +08:00
|
|
|
//===- DirectiveEmitter.cpp - Directive Language Emitter ------------------===//
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// DirectiveEmitter uses the descriptions of directives and clauses to construct
|
|
|
|
// common code declarations to be used in Frontends.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
#include "llvm/ADT/StringSet.h"
|
[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 21:29:50 +08:00
|
|
|
#include "llvm/TableGen/Error.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
#include "llvm/TableGen/TableGenBackend.h"
|
|
|
|
|
[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-07-01 02:36:37 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
namespace {
|
|
|
|
// Simple RAII helper for defining ifdef-undef-endif scopes.
|
|
|
|
class IfDefScope {
|
|
|
|
public:
|
|
|
|
IfDefScope(StringRef Name, raw_ostream &OS) : Name(Name), OS(OS) {
|
|
|
|
OS << "#ifdef " << Name << "\n"
|
|
|
|
<< "#undef " << Name << "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
~IfDefScope() { OS << "\n#endif // " << Name << "\n\n"; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
StringRef Name;
|
|
|
|
raw_ostream &OS;
|
|
|
|
};
|
|
|
|
} // end anonymous namespace
|
|
|
|
|
[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 21:29:50 +08:00
|
|
|
namespace llvm {
|
[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-07-01 02:36:37 +08:00
|
|
|
|
2020-07-07 10:19:43 +08:00
|
|
|
// Get Directive or Clause name formatted by replacing whitespaces with
|
|
|
|
// underscores.
|
|
|
|
std::string getFormattedName(StringRef Name) {
|
|
|
|
std::string N = Name.str();
|
|
|
|
std::replace(N.begin(), N.end(), ' ', '_');
|
|
|
|
return N;
|
|
|
|
}
|
|
|
|
|
[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-07-01 02:36:37 +08:00
|
|
|
// Generate enum class
|
|
|
|
void GenerateEnumClass(const std::vector<Record *> &Records, raw_ostream &OS,
|
|
|
|
StringRef Enum, StringRef Prefix, StringRef CppNamespace,
|
|
|
|
bool MakeEnumAvailableInNamespace) {
|
|
|
|
OS << "\n";
|
|
|
|
OS << "enum class " << Enum << " {\n";
|
|
|
|
for (const auto &R : Records) {
|
|
|
|
const auto Name = R->getValueAsString("name");
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << " " << Prefix << getFormattedName(Name) << ",\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
}
|
|
|
|
OS << "};\n";
|
|
|
|
OS << "\n";
|
|
|
|
OS << "static constexpr std::size_t " << Enum
|
|
|
|
<< "_enumSize = " << Records.size() << ";\n";
|
|
|
|
|
|
|
|
// Make the enum values available in the defined namespace. This allows us to
|
|
|
|
// write something like Enum_X if we have a `using namespace <CppNamespace>`.
|
|
|
|
// At the same time we do not loose the strong type guarantees of the enum
|
|
|
|
// class, that is we cannot pass an unsigned as Directive without an explicit
|
|
|
|
// cast.
|
|
|
|
if (MakeEnumAvailableInNamespace) {
|
|
|
|
OS << "\n";
|
|
|
|
for (const auto &R : Records) {
|
2020-07-07 10:19:43 +08:00
|
|
|
const auto FormattedName = getFormattedName(R->getValueAsString("name"));
|
|
|
|
OS << "constexpr auto " << Prefix << FormattedName << " = "
|
|
|
|
<< "llvm::" << CppNamespace << "::" << Enum << "::" << Prefix
|
|
|
|
<< FormattedName << ";\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the declaration section for the enumeration in the directive
|
|
|
|
// language
|
|
|
|
void EmitDirectivesDecl(RecordKeeper &Records, raw_ostream &OS) {
|
[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 21:29:50 +08:00
|
|
|
|
|
|
|
const auto &DirectiveLanguages =
|
|
|
|
Records.getAllDerivedDefinitions("DirectiveLanguage");
|
|
|
|
|
|
|
|
if (DirectiveLanguages.size() != 1) {
|
|
|
|
PrintError("A single definition of DirectiveLanguage is needed.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &DirectiveLanguage = DirectiveLanguages[0];
|
[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-07-01 02:36:37 +08:00
|
|
|
StringRef LanguageName = DirectiveLanguage->getValueAsString("name");
|
[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 21:29:50 +08:00
|
|
|
StringRef DirectivePrefix =
|
|
|
|
DirectiveLanguage->getValueAsString("directivePrefix");
|
|
|
|
StringRef ClausePrefix = DirectiveLanguage->getValueAsString("clausePrefix");
|
|
|
|
StringRef CppNamespace = DirectiveLanguage->getValueAsString("cppNamespace");
|
|
|
|
bool MakeEnumAvailableInNamespace =
|
|
|
|
DirectiveLanguage->getValueAsBit("makeEnumAvailableInNamespace");
|
|
|
|
bool EnableBitmaskEnumInNamespace =
|
|
|
|
DirectiveLanguage->getValueAsBit("enableBitmaskEnumInNamespace");
|
|
|
|
|
[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-07-01 02:36:37 +08:00
|
|
|
OS << "#ifndef LLVM_" << LanguageName << "_INC\n";
|
|
|
|
OS << "#define LLVM_" << LanguageName << "_INC\n";
|
[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 21:29:50 +08:00
|
|
|
|
|
|
|
if (EnableBitmaskEnumInNamespace)
|
[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-07-01 02:36:37 +08:00
|
|
|
OS << "\n#include \"llvm/ADT/BitmaskEnum.h\"\n";
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
OS << "\n";
|
[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 21:29:50 +08:00
|
|
|
OS << "namespace llvm {\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
OS << "class StringRef;\n";
|
[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 21:29:50 +08:00
|
|
|
|
|
|
|
// Open namespaces defined in the directive language
|
|
|
|
llvm::SmallVector<StringRef, 2> Namespaces;
|
|
|
|
llvm::SplitString(CppNamespace, Namespaces, "::");
|
|
|
|
for (auto Ns : Namespaces)
|
|
|
|
OS << "namespace " << Ns << " {\n";
|
|
|
|
|
|
|
|
if (EnableBitmaskEnumInNamespace)
|
[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-07-01 02:36:37 +08:00
|
|
|
OS << "\nLLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();\n";
|
[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 21:29:50 +08:00
|
|
|
|
|
|
|
// Emit Directive enumeration
|
|
|
|
const auto &Directives = Records.getAllDerivedDefinitions("Directive");
|
[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-07-01 02:36:37 +08:00
|
|
|
GenerateEnumClass(Directives, OS, "Directive", DirectivePrefix, CppNamespace,
|
|
|
|
MakeEnumAvailableInNamespace);
|
|
|
|
|
|
|
|
// Emit Clause enumeration
|
|
|
|
const auto &Clauses = Records.getAllDerivedDefinitions("Clause");
|
|
|
|
GenerateEnumClass(Clauses, OS, "Clause", ClausePrefix, CppNamespace,
|
|
|
|
MakeEnumAvailableInNamespace);
|
|
|
|
|
|
|
|
// Generic function signatures
|
|
|
|
OS << "\n";
|
|
|
|
OS << "// Enumeration helper functions\n";
|
|
|
|
OS << "Directive get" << LanguageName
|
|
|
|
<< "DirectiveKind(llvm::StringRef Str);\n";
|
|
|
|
OS << "\n";
|
|
|
|
OS << "llvm::StringRef get" << LanguageName
|
|
|
|
<< "DirectiveName(Directive D);\n";
|
|
|
|
OS << "\n";
|
|
|
|
OS << "Clause get" << LanguageName << "ClauseKind(llvm::StringRef Str);\n";
|
|
|
|
OS << "\n";
|
|
|
|
OS << "llvm::StringRef get" << LanguageName << "ClauseName(Clause C);\n";
|
|
|
|
OS << "\n";
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << "/// Return true if \\p C is a valid clause for \\p D in version \\p "
|
|
|
|
<< "Version.\n";
|
|
|
|
OS << "bool isAllowedClauseForDirective(Directive D, "
|
|
|
|
<< "Clause C, unsigned Version);\n";
|
|
|
|
OS << "\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
|
|
|
|
// Closing namespaces
|
|
|
|
for (auto Ns : llvm::reverse(Namespaces))
|
|
|
|
OS << "} // namespace " << Ns << "\n";
|
|
|
|
|
|
|
|
OS << "} // namespace llvm\n";
|
|
|
|
|
|
|
|
OS << "#endif // LLVM_" << LanguageName << "_INC\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate function implementation for get<Enum>Name(StringRef Str)
|
|
|
|
void GenerateGetName(const std::vector<Record *> &Records, raw_ostream &OS,
|
|
|
|
StringRef Enum, StringRef Prefix, StringRef LanguageName,
|
|
|
|
StringRef Namespace) {
|
|
|
|
OS << "\n";
|
|
|
|
OS << "llvm::StringRef llvm::" << Namespace << "::get" << LanguageName << Enum
|
|
|
|
<< "Name(" << Enum << " Kind) {\n";
|
|
|
|
OS << " switch (Kind) {\n";
|
|
|
|
for (const auto &R : Records) {
|
|
|
|
const auto Name = R->getValueAsString("name");
|
|
|
|
const auto AlternativeName = R->getValueAsString("alternativeName");
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << " case " << Prefix << getFormattedName(Name) << ":\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
OS << " return \"";
|
|
|
|
if (AlternativeName.empty())
|
|
|
|
OS << Name;
|
|
|
|
else
|
|
|
|
OS << AlternativeName;
|
|
|
|
OS << "\";\n";
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
OS << " }\n"; // switch
|
|
|
|
OS << " llvm_unreachable(\"Invalid " << LanguageName << " " << Enum
|
|
|
|
<< " kind\");\n";
|
|
|
|
OS << "}\n";
|
|
|
|
}
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
// Generate function implementation for get<Enum>Kind(StringRef Str)
|
|
|
|
void GenerateGetKind(const std::vector<Record *> &Records, raw_ostream &OS,
|
|
|
|
StringRef Enum, StringRef Prefix, StringRef LanguageName,
|
|
|
|
StringRef Namespace, bool ImplicitAsUnknown) {
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
auto DefaultIt = std::find_if(Records.begin(), Records.end(), [](Record *R) {
|
|
|
|
return R->getValueAsBit("isDefault") == true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (DefaultIt == Records.end()) {
|
|
|
|
PrintError("A least one " + Enum + " must be defined as default.");
|
|
|
|
return;
|
[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 21:29:50 +08:00
|
|
|
}
|
|
|
|
|
2020-07-07 10:19:43 +08:00
|
|
|
const auto FormattedDefaultName =
|
|
|
|
getFormattedName((*DefaultIt)->getValueAsString("name"));
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
OS << "\n";
|
|
|
|
OS << Enum << " llvm::" << Namespace << "::get" << LanguageName << Enum
|
|
|
|
<< "Kind(llvm::StringRef Str) {\n";
|
|
|
|
OS << " return llvm::StringSwitch<" << Enum << ">(Str)\n";
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
for (const auto &R : Records) {
|
|
|
|
const auto Name = R->getValueAsString("name");
|
|
|
|
if (ImplicitAsUnknown && R->getValueAsBit("isImplicit")) {
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << " .Case(\"" << Name << "\"," << Prefix << FormattedDefaultName
|
|
|
|
<< ")\n";
|
[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-07-01 02:36:37 +08:00
|
|
|
} else {
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << " .Case(\"" << Name << "\"," << Prefix << getFormattedName(Name)
|
|
|
|
<< ")\n";
|
[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 21:29:50 +08:00
|
|
|
}
|
|
|
|
}
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << " .Default(" << Prefix << FormattedDefaultName << ");\n";
|
|
|
|
OS << "}\n";
|
|
|
|
}
|
|
|
|
|
2020-07-09 07:54:34 +08:00
|
|
|
void GenerateCaseForVersionedClauses(const std::vector<Record *> &Clauses,
|
|
|
|
raw_ostream &OS, StringRef DirectiveName,
|
|
|
|
StringRef DirectivePrefix,
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
StringRef ClausePrefix,
|
|
|
|
llvm::StringSet<> &Cases) {
|
2020-07-07 10:19:43 +08:00
|
|
|
for (const auto &C : Clauses) {
|
|
|
|
const auto MinVersion = C->getValueAsInt("minVersion");
|
|
|
|
const auto MaxVersion = C->getValueAsInt("maxVersion");
|
|
|
|
const auto SpecificClause = C->getValueAsDef("clause");
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
const auto ClauseName =
|
|
|
|
getFormattedName(SpecificClause->getValueAsString("name"));
|
|
|
|
|
|
|
|
if (Cases.find(ClauseName) == Cases.end()) {
|
|
|
|
Cases.insert(ClauseName);
|
|
|
|
OS << " case " << ClausePrefix << ClauseName << ":\n";
|
|
|
|
OS << " return " << MinVersion << " <= Version && " << MaxVersion
|
|
|
|
<< " >= Version;\n";
|
|
|
|
}
|
2020-07-07 10:19:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the isAllowedClauseForDirective function implementation.
|
|
|
|
void GenerateIsAllowedClause(const std::vector<Record *> &Directives,
|
2020-07-09 07:54:34 +08:00
|
|
|
raw_ostream &OS, StringRef LanguageName,
|
|
|
|
StringRef DirectivePrefix, StringRef ClausePrefix,
|
|
|
|
StringRef CppNamespace) {
|
2020-07-07 10:19:43 +08:00
|
|
|
OS << "\n";
|
|
|
|
OS << "bool llvm::" << CppNamespace << "::isAllowedClauseForDirective("
|
|
|
|
<< "Directive D, Clause C, unsigned Version) {\n";
|
|
|
|
OS << " assert(unsigned(D) <= llvm::" << CppNamespace
|
|
|
|
<< "::Directive_enumSize);\n";
|
|
|
|
OS << " assert(unsigned(C) <= llvm::" << CppNamespace
|
|
|
|
<< "::Clause_enumSize);\n";
|
|
|
|
|
2020-07-09 07:54:34 +08:00
|
|
|
OS << " switch (D) {\n";
|
|
|
|
|
2020-07-07 10:19:43 +08:00
|
|
|
for (const auto &D : Directives) {
|
2020-07-09 07:54:34 +08:00
|
|
|
|
2020-07-07 10:19:43 +08:00
|
|
|
const auto DirectiveName = D->getValueAsString("name");
|
2020-07-11 08:57:00 +08:00
|
|
|
const auto &AllowedClauses = D->getValueAsListOfDefs("allowedClauses");
|
|
|
|
const auto &AllowedOnceClauses =
|
|
|
|
D->getValueAsListOfDefs("allowedOnceClauses");
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
const auto &AllowedExclusiveClauses =
|
|
|
|
D->getValueAsListOfDefs("allowedExclusiveClauses");
|
2020-07-11 08:57:00 +08:00
|
|
|
const auto &RequiredClauses = D->getValueAsListOfDefs("requiredClauses");
|
2020-07-07 10:19:43 +08:00
|
|
|
|
2020-07-09 07:54:34 +08:00
|
|
|
OS << " case " << DirectivePrefix << getFormattedName(DirectiveName)
|
|
|
|
<< ":\n";
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
if (AllowedClauses.size() == 0 && AllowedOnceClauses.size() == 0 &&
|
|
|
|
AllowedExclusiveClauses.size() == 0 && RequiredClauses.size() == 0) {
|
2020-07-11 08:57:00 +08:00
|
|
|
OS << " return false;\n";
|
|
|
|
} else {
|
|
|
|
OS << " switch (C) {\n";
|
2020-07-09 07:54:34 +08:00
|
|
|
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
llvm::StringSet<> Cases;
|
|
|
|
|
2020-07-11 08:57:00 +08:00
|
|
|
GenerateCaseForVersionedClauses(AllowedClauses, OS, DirectiveName,
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
DirectivePrefix, ClausePrefix, Cases);
|
2020-07-07 10:19:43 +08:00
|
|
|
|
2020-07-11 08:57:00 +08:00
|
|
|
GenerateCaseForVersionedClauses(AllowedOnceClauses, OS, DirectiveName,
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
DirectivePrefix, ClausePrefix, Cases);
|
|
|
|
|
|
|
|
GenerateCaseForVersionedClauses(AllowedExclusiveClauses, OS,
|
|
|
|
DirectiveName, DirectivePrefix,
|
|
|
|
ClausePrefix, Cases);
|
2020-07-07 10:19:43 +08:00
|
|
|
|
2020-07-11 08:57:00 +08:00
|
|
|
GenerateCaseForVersionedClauses(RequiredClauses, OS, DirectiveName,
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
DirectivePrefix, ClausePrefix, Cases);
|
2020-07-09 07:54:34 +08:00
|
|
|
|
2020-07-11 08:57:00 +08:00
|
|
|
OS << " default:\n";
|
|
|
|
OS << " return false;\n";
|
|
|
|
OS << " }\n"; // End of clauses switch
|
|
|
|
}
|
2020-07-09 07:54:34 +08:00
|
|
|
OS << " break;\n";
|
2020-07-07 10:19:43 +08:00
|
|
|
}
|
2020-07-09 07:54:34 +08:00
|
|
|
|
|
|
|
OS << " }\n"; // End of directives switch
|
|
|
|
OS << " llvm_unreachable(\"Invalid " << LanguageName
|
|
|
|
<< " Directive kind\");\n";
|
|
|
|
OS << "}\n"; // End of function isAllowedClauseForDirective
|
[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-07-01 02:36:37 +08:00
|
|
|
}
|
[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 21:29:50 +08:00
|
|
|
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
// Generate a simple enum set with the give clauses.
|
|
|
|
void GenerateClauseSet(const std::vector<Record *> &Clauses, raw_ostream &OS,
|
|
|
|
StringRef ClauseEnumSetClass, StringRef ClauseSetPrefix,
|
|
|
|
StringRef DirectiveName, StringRef DirectivePrefix,
|
|
|
|
StringRef ClausePrefix, StringRef CppNamespace) {
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
OS << " static " << ClauseEnumSetClass << " " << ClauseSetPrefix
|
|
|
|
<< DirectivePrefix << getFormattedName(DirectiveName) << " {\n";
|
|
|
|
|
|
|
|
for (const auto &C : Clauses) {
|
|
|
|
const auto SpecificClause = C->getValueAsDef("clause");
|
|
|
|
const auto ClauseName = SpecificClause->getValueAsString("name");
|
|
|
|
OS << " llvm::" << CppNamespace << "::Clause::" << ClausePrefix
|
|
|
|
<< getFormattedName(ClauseName) << ",\n";
|
|
|
|
}
|
|
|
|
OS << " };\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate an enum set for the 4 kinds of clauses linked to a directive.
|
|
|
|
void GenerateDirectiveClauseSets(const std::vector<Record *> &Directives,
|
|
|
|
raw_ostream &OS, StringRef LanguageName,
|
|
|
|
StringRef ClauseEnumSetClass,
|
|
|
|
StringRef DirectivePrefix,
|
|
|
|
StringRef ClausePrefix,
|
|
|
|
StringRef CppNamespace) {
|
|
|
|
|
|
|
|
IfDefScope Scope("GEN_FLANG_DIRECTIVE_CLAUSE_SETS", OS);
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
OS << "namespace llvm {\n";
|
|
|
|
|
|
|
|
// Open namespaces defined in the directive language.
|
|
|
|
llvm::SmallVector<StringRef, 2> Namespaces;
|
|
|
|
llvm::SplitString(CppNamespace, Namespaces, "::");
|
|
|
|
for (auto Ns : Namespaces)
|
|
|
|
OS << "namespace " << Ns << " {\n";
|
|
|
|
|
|
|
|
for (const auto &D : Directives) {
|
|
|
|
const auto DirectiveName = D->getValueAsString("name");
|
|
|
|
|
|
|
|
const auto &AllowedClauses = D->getValueAsListOfDefs("allowedClauses");
|
|
|
|
const auto &AllowedOnceClauses =
|
|
|
|
D->getValueAsListOfDefs("allowedOnceClauses");
|
|
|
|
const auto &AllowedExclusiveClauses =
|
|
|
|
D->getValueAsListOfDefs("allowedExclusiveClauses");
|
|
|
|
const auto &RequiredClauses = D->getValueAsListOfDefs("requiredClauses");
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
OS << " // Sets for " << DirectiveName << "\n";
|
|
|
|
|
|
|
|
GenerateClauseSet(AllowedClauses, OS, ClauseEnumSetClass, "allowedClauses_",
|
|
|
|
DirectiveName, DirectivePrefix, ClausePrefix,
|
|
|
|
CppNamespace);
|
|
|
|
GenerateClauseSet(AllowedOnceClauses, OS, ClauseEnumSetClass,
|
|
|
|
"allowedOnceClauses_", DirectiveName, DirectivePrefix,
|
|
|
|
ClausePrefix, CppNamespace);
|
|
|
|
GenerateClauseSet(AllowedExclusiveClauses, OS, ClauseEnumSetClass,
|
|
|
|
"allowedExclusiveClauses_", DirectiveName,
|
|
|
|
DirectivePrefix, ClausePrefix, CppNamespace);
|
|
|
|
GenerateClauseSet(RequiredClauses, OS, ClauseEnumSetClass,
|
|
|
|
"requiredClauses_", DirectiveName, DirectivePrefix,
|
|
|
|
ClausePrefix, CppNamespace);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Closing namespaces
|
|
|
|
for (auto Ns : llvm::reverse(Namespaces))
|
|
|
|
OS << "} // namespace " << Ns << "\n";
|
|
|
|
|
|
|
|
OS << "} // namespace llvm\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate a map of directive (key) with DirectiveClauses struct as values.
|
|
|
|
// The struct holds the 4 sets of enumeration for the 4 kinds of clauses
|
|
|
|
// allowances (allowed, allowed once, allowed exclusive and required).
|
|
|
|
void GenerateDirectiveClauseMap(const std::vector<Record *> &Directives,
|
|
|
|
raw_ostream &OS, StringRef LanguageName,
|
|
|
|
StringRef ClauseEnumSetClass,
|
|
|
|
StringRef DirectivePrefix,
|
|
|
|
StringRef ClausePrefix,
|
|
|
|
StringRef CppNamespace) {
|
|
|
|
|
|
|
|
IfDefScope Scope("GEN_FLANG_DIRECTIVE_CLAUSE_MAP", OS);
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
OS << "struct " << LanguageName << "DirectiveClauses {\n";
|
|
|
|
OS << " const " << ClauseEnumSetClass << " allowed;\n";
|
|
|
|
OS << " const " << ClauseEnumSetClass << " allowedOnce;\n";
|
|
|
|
OS << " const " << ClauseEnumSetClass << " allowedExclusive;\n";
|
|
|
|
OS << " const " << ClauseEnumSetClass << " requiredOneOf;\n";
|
|
|
|
OS << "};\n";
|
|
|
|
|
|
|
|
OS << "\n";
|
|
|
|
|
|
|
|
OS << "std::unordered_map<llvm::" << CppNamespace << "::Directive, "
|
|
|
|
<< LanguageName << "DirectiveClauses>\n";
|
|
|
|
OS << " directiveClausesTable = {\n";
|
|
|
|
|
|
|
|
for (const auto &D : Directives) {
|
|
|
|
const auto FormattedDirectiveName =
|
|
|
|
getFormattedName(D->getValueAsString("name"));
|
|
|
|
OS << " {llvm::" << CppNamespace << "::Directive::" << DirectivePrefix
|
|
|
|
<< FormattedDirectiveName << ",\n";
|
|
|
|
OS << " {\n";
|
|
|
|
OS << " llvm::" << CppNamespace << "::allowedClauses_"
|
|
|
|
<< DirectivePrefix << FormattedDirectiveName << ",\n";
|
|
|
|
OS << " llvm::" << CppNamespace << "::allowedOnceClauses_"
|
|
|
|
<< DirectivePrefix << FormattedDirectiveName << ",\n";
|
|
|
|
OS << " llvm::" << CppNamespace << "::allowedExclusiveClauses_"
|
|
|
|
<< DirectivePrefix << FormattedDirectiveName << ",\n";
|
|
|
|
OS << " llvm::" << CppNamespace << "::requiredClauses_"
|
|
|
|
<< DirectivePrefix << FormattedDirectiveName << ",\n";
|
|
|
|
OS << " }\n";
|
|
|
|
OS << " },\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
OS << "};\n";
|
|
|
|
}
|
|
|
|
|
[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-07-01 02:36:37 +08:00
|
|
|
// Generate the implemenation section for the enumeration in the directive
|
|
|
|
// language
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
void EmitDirectivesFlangImpl(const std::vector<Record *> &Directives,
|
|
|
|
raw_ostream &OS, StringRef LanguageName,
|
|
|
|
StringRef ClauseEnumSetClass,
|
|
|
|
StringRef DirectivePrefix, StringRef ClausePrefix,
|
|
|
|
StringRef CppNamespace) {
|
|
|
|
|
|
|
|
GenerateDirectiveClauseSets(Directives, OS, LanguageName, ClauseEnumSetClass,
|
|
|
|
DirectivePrefix, ClausePrefix, CppNamespace);
|
|
|
|
|
|
|
|
GenerateDirectiveClauseMap(Directives, OS, LanguageName, ClauseEnumSetClass,
|
|
|
|
DirectivePrefix, ClausePrefix, CppNamespace);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the implemenation section for the enumeration in the directive
|
|
|
|
// language.
|
|
|
|
void EmitDirectivesGen(RecordKeeper &Records, raw_ostream &OS) {
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
const auto &DirectiveLanguages =
|
|
|
|
Records.getAllDerivedDefinitions("DirectiveLanguage");
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
if (DirectiveLanguages.size() != 1) {
|
|
|
|
PrintError("A single definition of DirectiveLanguage is needed.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &DirectiveLanguage = DirectiveLanguages[0];
|
|
|
|
StringRef DirectivePrefix =
|
|
|
|
DirectiveLanguage->getValueAsString("directivePrefix");
|
|
|
|
StringRef LanguageName = DirectiveLanguage->getValueAsString("name");
|
|
|
|
StringRef ClausePrefix = DirectiveLanguage->getValueAsString("clausePrefix");
|
|
|
|
StringRef CppNamespace = DirectiveLanguage->getValueAsString("cppNamespace");
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
StringRef ClauseEnumSetClass =
|
|
|
|
DirectiveLanguage->getValueAsString("clauseEnumSetClass");
|
[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-07-01 02:36:37 +08:00
|
|
|
|
|
|
|
const auto &Directives = Records.getAllDerivedDefinitions("Directive");
|
|
|
|
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
EmitDirectivesFlangImpl(Directives, OS, LanguageName, ClauseEnumSetClass,
|
|
|
|
DirectivePrefix, ClausePrefix, CppNamespace);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Generate the implemenation for the enumeration in the directive
|
|
|
|
// language. This code can be included in library.
|
|
|
|
void EmitDirectivesImpl(RecordKeeper &Records, raw_ostream &OS) {
|
|
|
|
|
|
|
|
const auto &DirectiveLanguages =
|
|
|
|
Records.getAllDerivedDefinitions("DirectiveLanguage");
|
|
|
|
|
|
|
|
if (DirectiveLanguages.size() != 1) {
|
|
|
|
PrintError("A single definition of DirectiveLanguage is needed.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto &DirectiveLanguage = DirectiveLanguages[0];
|
|
|
|
StringRef DirectivePrefix =
|
|
|
|
DirectiveLanguage->getValueAsString("directivePrefix");
|
|
|
|
StringRef LanguageName = DirectiveLanguage->getValueAsString("name");
|
|
|
|
StringRef ClausePrefix = DirectiveLanguage->getValueAsString("clausePrefix");
|
|
|
|
StringRef CppNamespace = DirectiveLanguage->getValueAsString("cppNamespace");
|
|
|
|
const auto &Directives = Records.getAllDerivedDefinitions("Directive");
|
|
|
|
const auto &Clauses = Records.getAllDerivedDefinitions("Clause");
|
|
|
|
|
|
|
|
StringRef IncludeHeader =
|
|
|
|
DirectiveLanguage->getValueAsString("includeHeader");
|
|
|
|
|
2020-07-11 08:11:11 +08:00
|
|
|
if (!IncludeHeader.empty())
|
|
|
|
OS << "#include \"" << IncludeHeader << "\"\n\n";
|
|
|
|
|
|
|
|
OS << "#include \"llvm/ADT/StringRef.h\"\n";
|
|
|
|
OS << "#include \"llvm/ADT/StringSwitch.h\"\n";
|
[flang][openacc] OpenACC 3.0 parser
Summary:
This patch introduce the parser for OpenACC 3.0 in Flang. It uses the same TableGen mechanism
than OpenMP.
Reviewers: nvdatian, sscalpone, tskeith, klausler, ichoyjx, jdoerfert, DavidTruby
Reviewed By: klausler
Subscribers: MaskRay, SouraVX, mgorny, hiraditya, jfb, sstefan1, llvm-commits
Tags: #llvm, #flang
Differential Revision: https://reviews.llvm.org/D83649
2020-07-15 02:28:34 +08:00
|
|
|
OS << "#include \"llvm/Support/ErrorHandling.h\"\n";
|
2020-07-11 08:11:11 +08:00
|
|
|
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";
|
|
|
|
|
[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-07-01 02:36:37 +08:00
|
|
|
// getDirectiveKind(StringRef Str)
|
|
|
|
GenerateGetKind(Directives, OS, "Directive", DirectivePrefix, LanguageName,
|
|
|
|
CppNamespace, /*ImplicitAsUnknown=*/false);
|
|
|
|
|
|
|
|
// getDirectiveName(Directive Kind)
|
|
|
|
GenerateGetName(Directives, OS, "Directive", DirectivePrefix, LanguageName,
|
|
|
|
CppNamespace);
|
|
|
|
|
|
|
|
// getClauseKind(StringRef Str)
|
|
|
|
GenerateGetKind(Clauses, OS, "Clause", ClausePrefix, LanguageName,
|
|
|
|
CppNamespace, /*ImplicitAsUnknown=*/true);
|
|
|
|
|
|
|
|
// getClauseName(Clause Kind)
|
|
|
|
GenerateGetName(Clauses, OS, "Clause", ClausePrefix, LanguageName,
|
|
|
|
CppNamespace);
|
2020-07-07 10:19:43 +08:00
|
|
|
|
[flang][openmp] Check clauses allowed semantic with tablegen generated map
Summary:
This patch is enabling the generation of clauses enum sets for semantics check in Flang through
tablegen. Enum sets and directive - sets map is generated by the new tablegen infrsatructure for OpenMP
and other directive languages.
The semantic checks for OpenMP are modified to use this newly generated map.
Reviewers: DavidTruby, sscalpone, kiranchandramohan, ichoyjx, jdoerfert
Reviewed By: DavidTruby, ichoyjx
Subscribers: mgorny, yaxunl, hiraditya, guansong, sstefan1, aaron.ballman, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D83326
2020-07-12 00:42:05 +08:00
|
|
|
// isAllowedClauseForDirective(Directive D, Clause C, unsigned Version)
|
2020-07-09 07:54:34 +08:00
|
|
|
GenerateIsAllowedClause(Directives, OS, LanguageName, DirectivePrefix,
|
|
|
|
ClausePrefix, CppNamespace);
|
[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 21:29:50 +08: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-07-01 02:36:37 +08:00
|
|
|
|
[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 21:29:50 +08:00
|
|
|
} // namespace llvm
|