Skip to content

[TableGen] Add explicit symbol visibility macros to code generated #107873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions llvm/test/TableGen/directive1.td
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-EMPTY:
// CHECK-NEXT: #include "llvm/ADT/ArrayRef.h"
// CHECK-NEXT: #include "llvm/ADT/BitmaskEnum.h"
// CHECK-NEXT: #include "llvm/Support/Compiler.h"
// CHECK-NEXT: #include <cstddef>
// CHECK-EMPTY:
// CHECK-NEXT: namespace llvm {
Expand Down Expand Up @@ -114,22 +115,22 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-NEXT: constexpr auto TDLCV_valc = llvm::tdl::AKind::TDLCV_valc;
// CHECK-EMPTY:
// CHECK-NEXT: // Enumeration helper functions
// CHECK-NEXT: Directive getTdlDirectiveKind(llvm::StringRef Str);
// CHECK-NEXT: LLVM_ABI Directive getTdlDirectiveKind(llvm::StringRef Str);
// CHECK-EMPTY:
// CHECK-NEXT: llvm::StringRef getTdlDirectiveName(Directive D);
// CHECK-NEXT: LLVM_ABI llvm::StringRef getTdlDirectiveName(Directive D);
// CHECK-EMPTY:
// CHECK-NEXT: Clause getTdlClauseKind(llvm::StringRef Str);
// CHECK-NEXT: LLVM_ABI Clause getTdlClauseKind(llvm::StringRef Str);
// CHECK-EMPTY:
// CHECK-NEXT: llvm::StringRef getTdlClauseName(Clause C);
// CHECK-NEXT: LLVM_ABI llvm::StringRef getTdlClauseName(Clause C);
// CHECK-EMPTY:
// CHECK-NEXT: /// Return true if \p C is a valid clause for \p D in version \p Version.
// CHECK-NEXT: bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version);
// CHECK-NEXT: LLVM_ABI bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version);
// CHECK-EMPTY:
// CHECK-NEXT: constexpr std::size_t getMaxLeafCount() { return 0; }
// CHECK-NEXT: Association getDirectiveAssociation(Directive D);
// CHECK-NEXT: Category getDirectiveCategory(Directive D);
// CHECK-NEXT: AKind getAKind(StringRef);
// CHECK-NEXT: llvm::StringRef getTdlAKindName(AKind);
// CHECK-NEXT: LLVM_ABI Association getDirectiveAssociation(Directive D);
// CHECK-NEXT: LLVM_ABI Category getDirectiveCategory(Directive D);
// CHECK-NEXT: LLVM_ABI AKind getAKind(StringRef);
// CHECK-NEXT: LLVM_ABI llvm::StringRef getTdlAKindName(AKind);
// CHECK-EMPTY:
// CHECK-NEXT: } // namespace tdl
// CHECK-NEXT: } // namespace llvm
Expand Down
15 changes: 8 additions & 7 deletions llvm/test/TableGen/directive2.td
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-NEXT: #define LLVM_Tdl_INC
// CHECK-EMPTY:
// CHECK-NEXT: #include "llvm/ADT/ArrayRef.h"
// CHECK-NEXT: #include "llvm/Support/Compiler.h"
// CHECK-NEXT: #include <cstddef>
// CHECK-EMPTY:
// CHECK-NEXT: namespace llvm {
Expand Down Expand Up @@ -90,20 +91,20 @@ def TDL_DirA : Directive<"dira"> {
// CHECK-NEXT: static constexpr std::size_t Clause_enumSize = 4;
// CHECK-EMPTY:
// CHECK-NEXT: // Enumeration helper functions
// CHECK-NEXT: Directive getTdlDirectiveKind(llvm::StringRef Str);
// CHECK-NEXT: LLVM_ABI Directive getTdlDirectiveKind(llvm::StringRef Str);
// CHECK-EMPTY:
// CHECK-NEXT: llvm::StringRef getTdlDirectiveName(Directive D);
// CHECK-NEXT: LLVM_ABI llvm::StringRef getTdlDirectiveName(Directive D);
// CHECK-EMPTY:
// CHECK-NEXT: Clause getTdlClauseKind(llvm::StringRef Str);
// CHECK-NEXT: LLVM_ABI Clause getTdlClauseKind(llvm::StringRef Str);
// CHECK-EMPTY:
// CHECK-NEXT: llvm::StringRef getTdlClauseName(Clause C);
// CHECK-NEXT: LLVM_ABI llvm::StringRef getTdlClauseName(Clause C);
// CHECK-EMPTY:
// CHECK-NEXT: /// Return true if \p C is a valid clause for \p D in version \p Version.
// CHECK-NEXT: bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version);
// CHECK-NEXT: LLVM_ABI bool isAllowedClauseForDirective(Directive D, Clause C, unsigned Version);
// CHECK-EMPTY:
// CHECK-NEXT: constexpr std::size_t getMaxLeafCount() { return 0; }
// CHECK-NEXT: Association getDirectiveAssociation(Directive D);
// CHECK-NEXT: Category getDirectiveCategory(Directive D);
// CHECK-NEXT: LLVM_ABI Association getDirectiveAssociation(Directive D);
// CHECK-NEXT: LLVM_ABI Category getDirectiveCategory(Directive D);
// CHECK-NEXT: } // namespace tdl
// CHECK-NEXT: } // namespace llvm
// CHECK-NEXT: #endif // LLVM_Tdl_INC
Expand Down
22 changes: 12 additions & 10 deletions llvm/utils/TableGen/DirectiveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ static void GenerateEnumClauseVal(ArrayRef<const Record *> Records,
<< "llvm::" << DirLang.getCppNamespace() << "::" << EnumName
<< "::" << CV->getName() << ";\n";
}
EnumHelperFuncs += (Twine(EnumName) + Twine(" get") + Twine(EnumName) +
Twine("(StringRef);\n"))
EnumHelperFuncs += (Twine("LLVM_ABI ") + Twine(EnumName) + Twine(" get") +
Twine(EnumName) + Twine("(StringRef);\n"))
.str();

EnumHelperFuncs +=
(Twine("llvm::StringRef get") + Twine(DirLang.getName()) +
(Twine("LLVM_ABI llvm::StringRef get") + Twine(DirLang.getName()) +
Twine(EnumName) + Twine("Name(") + Twine(EnumName) + Twine(");\n"))
.str();
}
Expand Down Expand Up @@ -200,6 +200,7 @@ static void EmitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
if (DirLang.hasEnableBitmaskEnumInNamespace())
OS << "#include \"llvm/ADT/BitmaskEnum.h\"\n";

OS << "#include \"llvm/Support/Compiler.h\"\n";
OS << "#include <cstddef>\n"; // for size_t
OS << "\n";
OS << "namespace llvm {\n";
Expand Down Expand Up @@ -242,26 +243,27 @@ static void EmitDirectivesDecl(const RecordKeeper &Records, raw_ostream &OS) {
// Generic function signatures
OS << "\n";
OS << "// Enumeration helper functions\n";
OS << "Directive get" << DirLang.getName()
OS << "LLVM_ABI Directive get" << DirLang.getName()
<< "DirectiveKind(llvm::StringRef Str);\n";
OS << "\n";
OS << "llvm::StringRef get" << DirLang.getName()
OS << "LLVM_ABI llvm::StringRef get" << DirLang.getName()
<< "DirectiveName(Directive D);\n";
OS << "\n";
OS << "Clause get" << DirLang.getName()
OS << "LLVM_ABI Clause get" << DirLang.getName()
<< "ClauseKind(llvm::StringRef Str);\n";
OS << "\n";
OS << "llvm::StringRef get" << DirLang.getName() << "ClauseName(Clause C);\n";
OS << "LLVM_ABI llvm::StringRef get" << DirLang.getName()
<< "ClauseName(Clause C);\n";
OS << "\n";
OS << "/// Return true if \\p C is a valid clause for \\p D in version \\p "
<< "Version.\n";
OS << "bool isAllowedClauseForDirective(Directive D, "
OS << "LLVM_ABI bool isAllowedClauseForDirective(Directive D, "
<< "Clause C, unsigned Version);\n";
OS << "\n";
OS << "constexpr std::size_t getMaxLeafCount() { return "
<< GetMaxLeafCount(DirLang) << "; }\n";
OS << "Association getDirectiveAssociation(Directive D);\n";
OS << "Category getDirectiveCategory(Directive D);\n";
OS << "LLVM_ABI Association getDirectiveAssociation(Directive D);\n";
OS << "LLVM_ABI Category getDirectiveCategory(Directive D);\n";
if (EnumHelperFuncs.length() > 0) {
OS << EnumHelperFuncs;
OS << "\n";
Expand Down
Loading