[llvm] 283c2c8 - [TableGen] Add explicit symbol visibility macros to code generated (#107873)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 12:42:50 PDT 2024
Author: Thomas Fransham
Date: 2024-09-19T12:42:46-07:00
New Revision: 283c2c8800de4991730be20c327f94fc72ff21a2
URL: https://github.com/llvm/llvm-project/commit/283c2c8800de4991730be20c327f94fc72ff21a2
DIFF: https://github.com/llvm/llvm-project/commit/283c2c8800de4991730be20c327f94fc72ff21a2.diff
LOG: [TableGen] Add explicit symbol visibility macros to code generated (#107873)
Update llvm's TableGen to emit new explicit symbol visibility macros I
added in https://github.com/llvm/llvm-project/pull/96630 to the function
declarations it creates
The generated functions need to be exported from llvm's shared library
for Clang and some OpenMP tests. @compnerd
Added:
Modified:
llvm/test/TableGen/directive1.td
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/test/TableGen/directive1.td b/llvm/test/TableGen/directive1.td
index 3af3b04dc00939..2f877029c83962 100644
--- a/llvm/test/TableGen/directive1.td
+++ b/llvm/test/TableGen/directive1.td
@@ -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 {
@@ -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
diff --git a/llvm/test/TableGen/directive2.td b/llvm/test/TableGen/directive2.td
index 209901bb616f4e..3f1a44cfdd4f96 100644
--- a/llvm/test/TableGen/directive2.td
+++ b/llvm/test/TableGen/directive2.td
@@ -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 {
@@ -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
diff --git a/llvm/utils/TableGen/DirectiveEmitter.cpp b/llvm/utils/TableGen/DirectiveEmitter.cpp
index aaad0fc861529f..fafdfa0db89af2 100644
--- a/llvm/utils/TableGen/DirectiveEmitter.cpp
+++ b/llvm/utils/TableGen/DirectiveEmitter.cpp
@@ -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();
}
@@ -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";
@@ -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";
More information about the llvm-commits
mailing list