Skip to content

Conversation

@jurahul
Copy link
Contributor

@jurahul jurahul commented Nov 18, 2025

Adopt IfDefEmitter and NamespaceEmitter in CodeGenMapTable.cpp

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

🐧 Linux x64 Test Results

  • 186344 tests passed
  • 4854 tests skipped

@jurahul jurahul marked this pull request as ready for review November 18, 2025 23:18
@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2025

@llvm/pr-subscribers-tablegen

Author: Rahul Joshi (jurahul)

Changes

Adopt IfDefEmitter and NamespaceEmitter in CodeGenMapTable.cpp


Full diff: https://github.com/llvm/llvm-project/pull/168592.diff

1 Files Affected:

  • (modified) llvm/utils/TableGen/CodeGenMapTable.cpp (+3-5)
diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp
index e5025784d304d..35ec495b93ba2 100644
--- a/llvm/utils/TableGen/CodeGenMapTable.cpp
+++ b/llvm/utils/TableGen/CodeGenMapTable.cpp
@@ -80,6 +80,7 @@
 #include "TableGenBackends.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/TableGen/CodeGenHelpers.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 
@@ -549,9 +550,8 @@ void llvm::EmitMapTable(const RecordKeeper &Records, raw_ostream &OS) {
   if (InstrMapVec.empty())
     return;
 
-  OS << "#ifdef GET_INSTRMAP_INFO\n";
-  OS << "#undef GET_INSTRMAP_INFO\n";
-  OS << "namespace llvm::" << NameSpace << " {\n\n";
+  IfDefEmitter IfDef(OS, "GET_INSTRMAP_INFO");
+  NamespaceEmitter NS(OS, ("llvm::" + NameSpace).str());
 
   // Emit coulumn field names and their values as enums.
   emitEnums(OS, Records);
@@ -574,6 +574,4 @@ void llvm::EmitMapTable(const RecordKeeper &Records, raw_ostream &OS) {
     // Emit map tables and the functions to query them.
     IMap.emitTablesWithFunc(OS);
   }
-  OS << "} // end namespace llvm::" << NameSpace << '\n';
-  OS << "#endif // GET_INSTRMAP_INFO\n\n";
 }

Copy link
Contributor

@s-barannikov s-barannikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jurahul jurahul merged commit c32d2ee into llvm:main Nov 19, 2025
11 of 12 checks passed
@jurahul jurahul deleted the nfc_adopt_cg_helpers_cgmaptable branch November 19, 2025 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants