[llvm] [LLVM][TableGen] Change X86MnemonicTables to use const RecordKeeper (PR #109053)

Rahul Joshi via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 14:16:12 PDT 2024


https://github.com/jurahul created https://github.com/llvm/llvm-project/pull/109053

Change X86MnemonicTables to use const RecordKeeper.


>From b7c3469b2536d36382f3ea7a719237d84f09bbb4 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Tue, 17 Sep 2024 14:15:02 -0700
Subject: [PATCH] [LLVM][TableGen] Change X86MnemonicTables to use const
 RecordKeeper

---
 llvm/utils/TableGen/X86MnemonicTables.cpp | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/TableGen/X86MnemonicTables.cpp b/llvm/utils/TableGen/X86MnemonicTables.cpp
index d9ceed40f7c70d..ddbfb2af9869f4 100644
--- a/llvm/utils/TableGen/X86MnemonicTables.cpp
+++ b/llvm/utils/TableGen/X86MnemonicTables.cpp
@@ -22,10 +22,10 @@ using namespace llvm;
 namespace {
 
 class X86MnemonicTablesEmitter {
-  CodeGenTarget Target;
+  const CodeGenTarget Target;
 
 public:
-  X86MnemonicTablesEmitter(RecordKeeper &R) : Target(R) {}
+  X86MnemonicTablesEmitter(const RecordKeeper &R) : Target(R) {}
 
   // Output X86 mnemonic tables.
   void run(raw_ostream &OS);
@@ -34,15 +34,13 @@ class X86MnemonicTablesEmitter {
 void X86MnemonicTablesEmitter::run(raw_ostream &OS) {
   emitSourceFileHeader("X86 Mnemonic tables", OS);
   OS << "namespace llvm {\nnamespace X86 {\n\n";
-  Record *AsmWriter = Target.getAsmWriter();
+  const Record *AsmWriter = Target.getAsmWriter();
   unsigned Variant = AsmWriter->getValueAsInt("Variant");
 
   // Hold all instructions grouped by mnemonic
   StringMap<SmallVector<const CodeGenInstruction *, 0>> MnemonicToCGInstrMap;
 
-  ArrayRef<const CodeGenInstruction *> NumberedInstructions =
-      Target.getInstructionsByEnumValue();
-  for (const CodeGenInstruction *I : NumberedInstructions) {
+  for (const CodeGenInstruction *I : Target.getInstructionsByEnumValue()) {
     const Record *Def = I->TheDef;
     // Filter non-X86 instructions.
     if (!Def->isSubClassOf("X86Inst"))



More information about the llvm-commits mailing list