[llvm-branch-commits] [llvm] TableGen: Generate enum for runtime libcall implementations (PR #144973)

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jun 27 00:32:21 PDT 2025


================
@@ -235,29 +247,57 @@ void RuntimeLibcallEmitter::emitGetInitRuntimeLibcallNames(
   // TODO: Emit libcall names as string offset table.
 
   OS << "#ifdef GET_INIT_RUNTIME_LIBCALL_NAMES\n"
-        "const char *const "
+        "const RTLIB::LibcallImpl "
         "llvm::RTLIB::RuntimeLibcallsInfo::"
-        "DefaultLibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1] = {\n";
+        "DefaultLibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {\n";
 
   for (const RuntimeLibcall &LibCall : RuntimeLibcallDefList) {
     auto I = LibCallToDefaultImpl.find(&LibCall);
-    if (I == LibCallToDefaultImpl.end())
-      OS << "  nullptr,";
-    else {
+    if (I == LibCallToDefaultImpl.end()) {
+      OS << "  RTLIB::Unsupported,";
+    } else {
       const RuntimeLibcallImpl *LibCallImpl = I->second;
       OS << "  ";
-      LibCallImpl->emitQuotedLibcallFuncName(OS);
-      OS << ',';
+      LibCallImpl->emitEnumEntry(OS);
+      OS << ",";
     }
 
     OS << " // ";
     LibCall.emitEnumEntry(OS);
     OS << '\n';
   }
 
-  OS << "  nullptr // RTLIB::UNKNOWN_LIBCALL\n"
+  OS << "  RTLIB::Unsupported\n"
         "};\n\n";
 
+  // Emit the implementation names
+  OS << "const char *const llvm::RTLIB::RuntimeLibcallsInfo::"
+        "LibCallImplNames[RTLIB::NumLibcallImpls] = {\n"
+        "  nullptr, // RTLIB::Unsupported\n";
+
+  for (const RuntimeLibcallImpl &LibCallImpl : RuntimeLibcallImplDefList) {
+    OS << "  \"" << LibCallImpl.getLibcallFuncName() << "\", // ";
+    LibCallImpl.emitEnumEntry(OS);
+    OS << '\n';
+  }
+
+  OS << "};\n\n";
----------------
nikic wrote:

Yes, all string literals cause dynamic relocations.

https://github.com/llvm/llvm-project/pull/144973


More information about the llvm-branch-commits mailing list