[llvm] [NFC][TableGen] Adopt CodeGenHelpers in X86MnemonicEmitter (PR #179324)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 21:50:14 PST 2026
================
@@ -58,30 +58,30 @@ void X86MnemonicTablesEmitter::run(raw_ostream &OS) {
MnemonicToCGInstrMap[Mnemonic].push_back(I);
}
- OS << "#ifdef GET_X86_MNEMONIC_TABLES_H\n";
- OS << "#undef GET_X86_MNEMONIC_TABLES_H\n\n";
- for (StringRef Mnemonic : MnemonicToCGInstrMap.keys())
- OS << "bool is" << Mnemonic << "(unsigned Opcode);\n";
- OS << "#endif // GET_X86_MNEMONIC_TABLES_H\n\n";
+ {
+ IfDefEmitter IfDef(OS, "GET_X86_MNEMONIC_TABLES_H");
+ NamespaceEmitter NS(OS, "llvm::X86");
+ for (StringRef Mnemonic : MnemonicToCGInstrMap.keys())
+ OS << "bool is" << Mnemonic << "(unsigned Opcode);\n";
+ }
- OS << "#ifdef GET_X86_MNEMONIC_TABLES_CPP\n";
- OS << "#undef GET_X86_MNEMONIC_TABLES_CPP\n\n";
- for (StringRef Mnemonic : MnemonicToCGInstrMap.keys()) {
- OS << "bool is" << Mnemonic << "(unsigned Opcode) {\n";
- auto Mnemonics = MnemonicToCGInstrMap[Mnemonic];
- if (Mnemonics.size() == 1) {
- const CodeGenInstruction *CGI = *Mnemonics.begin();
- OS << "\treturn Opcode == " << CGI->getName() << ";\n}\n\n";
- } else {
- OS << "\tswitch (Opcode) {\n";
- for (const CodeGenInstruction *CGI : Mnemonics) {
- OS << "\tcase " << CGI->getName() << ":\n";
+ {
+ IfDefEmitter IfDef(OS, "GET_X86_MNEMONIC_TABLES_CPP");
+ NamespaceEmitter NS(OS, "llvm::X86");
+ for (StringRef Mnemonic : MnemonicToCGInstrMap.keys()) {
+ OS << "bool is" << Mnemonic << "(unsigned Opcode) {\n";
+ auto Mnemonics = MnemonicToCGInstrMap[Mnemonic];
----------------
topperc wrote:
I know it was here before, but is this a copy?
https://github.com/llvm/llvm-project/pull/179324
More information about the llvm-commits
mailing list