[llvm] Switch the intrinsic names to a string table (PR #118929)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 7 13:28:24 PST 2024


================
@@ -239,13 +239,37 @@ static constexpr IntrinsicTargetInfo TargetInfos[] = {
 
 void IntrinsicEmitter::EmitIntrinsicToNameTable(
     const CodeGenIntrinsicTable &Ints, raw_ostream &OS) {
+  // Built up a table of the intrinsic names.
+  constexpr StringLiteral NotIntrinsic = "not_intrinsic";
+  StringToOffsetTable Table;
+  Table.GetOrAddStringOffset(NotIntrinsic);
+  for (const auto &Int : Ints)
+    Table.GetOrAddStringOffset(Int.Name);
+
   OS << R"(// Intrinsic ID to name table.
 #ifdef GET_INTRINSIC_NAME_TABLE
 // Note that entry #0 is the invalid intrinsic!
+
+)";
+
+  Table.EmitStringLiteralDef(OS, "static constexpr char IntrinsicNameTable[]",
+                             /*Indent=*/"");
+
+  OS << R"(
+static constexpr int IntrinsicNameOffsetTable[] = {
----------------
nikic wrote:

```suggestion
static constexpr unsigned IntrinsicNameOffsetTable[] = {
```
Or `uint32_t` -- or can these offset be negative?

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


More information about the llvm-commits mailing list