Skip to content

Commit eeb987f

Browse files
authored
[MC] Make generated MCInstPrinter::getMnemonic const (NFC) (llvm#114682)
The value returned from the function depends only on the instruction opcode. As a drive-by, change the type of the argument to const-reference.
1 parent 89b948d commit eeb987f

File tree

34 files changed

+70
-39
lines changed

34 files changed

+70
-39
lines changed

bolt/lib/Core/HashUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ std::string hashBlockLoose(BinaryContext &BC, const BinaryBasicBlock &BB) {
145145
continue;
146146
}
147147

148-
std::string Mnemonic = BC.InstPrinter->getMnemonic(&Inst).first;
148+
std::string Mnemonic = BC.InstPrinter->getMnemonic(Inst).first;
149149
llvm::erase_if(Mnemonic, [](unsigned char ch) { return std::isspace(ch); });
150150
Opcodes.insert(Mnemonic);
151151
}

llvm/include/llvm/MC/MCInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ class MCInstPrinter {
131131

132132
/// Returns a pair containing the mnemonic for \p MI and the number of bits
133133
/// left for further processing by printInstruction (generated by tablegen).
134-
virtual std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) = 0;
134+
virtual std::pair<const char *, uint64_t>
135+
getMnemonic(const MCInst &MI) const = 0;
135136

136137
/// Print the specified MCInst to the specified raw_ostream.
137138
///

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ class MCStreamer {
441441

442442
/// Returns the mnemonic for \p MI, if the streamer has access to a
443443
/// instruction printer and returns an empty string otherwise.
444-
virtual StringRef getMnemonic(MCInst &MI) { return ""; }
444+
virtual StringRef getMnemonic(const MCInst &MI) const { return ""; }
445445

446446
/// Emit a label for \p Symbol into the current section.
447447
///

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ class MCAsmStreamer final : public MCStreamer {
169169

170170
void emitGNUAttribute(unsigned Tag, unsigned Value) override;
171171

172-
StringRef getMnemonic(MCInst &MI) override {
173-
auto [Ptr, Bits] = InstPrinter->getMnemonic(&MI);
172+
StringRef getMnemonic(const MCInst &MI) const override {
173+
auto [Ptr, Bits] = InstPrinter->getMnemonic(MI);
174174
assert((Bits != 0 || Ptr == nullptr) &&
175175
"Invalid char pointer for instruction with no mnemonic");
176176
return Ptr;

llvm/lib/Target/AArch64/MCTargetDesc/AArch64InstPrinter.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class AArch64InstPrinter : public MCInstPrinter {
3333
void printRegName(raw_ostream &OS, MCRegister Reg, unsigned AltIdx);
3434

3535
// Autogenerated by tblgen.
36-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
36+
std::pair<const char *, uint64_t>
37+
getMnemonic(const MCInst &MI) const override;
3738
virtual void printInstruction(const MCInst *MI, uint64_t Address,
3839
const MCSubtargetInfo &STI, raw_ostream &O);
3940
virtual bool printAliasInstr(const MCInst *MI, uint64_t Address,
@@ -248,7 +249,8 @@ class AArch64AppleInstPrinter : public AArch64InstPrinter {
248249
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
249250
const MCSubtargetInfo &STI, raw_ostream &O) override;
250251

251-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
252+
std::pair<const char *, uint64_t>
253+
getMnemonic(const MCInst &MI) const override;
252254
void printInstruction(const MCInst *MI, uint64_t Address,
253255
const MCSubtargetInfo &STI, raw_ostream &O) override;
254256
bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class AMDGPUInstPrinter : public MCInstPrinter {
2424
: MCInstPrinter(MAI, MII, MRI) {}
2525

2626
// Autogenerated by tblgen
27-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
27+
std::pair<const char *, uint64_t>
28+
getMnemonic(const MCInst &MI) const override;
2829
void printInstruction(const MCInst *MI, uint64_t Address,
2930
const MCSubtargetInfo &STI, raw_ostream &O);
3031
static const char *getRegisterName(MCRegister Reg);

llvm/lib/Target/AMDGPU/MCTargetDesc/R600InstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ class R600InstPrinter : public MCInstPrinter {
2121

2222
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
2323
const MCSubtargetInfo &STI, raw_ostream &O) override;
24-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
24+
std::pair<const char *, uint64_t>
25+
getMnemonic(const MCInst &MI) const override;
2526
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
2627
static const char *getRegisterName(MCRegister Reg);
2728

llvm/lib/Target/ARC/MCTargetDesc/ARCInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class ARCInstPrinter : public MCInstPrinter {
2626
: MCInstPrinter(MAI, MII, MRI) {}
2727

2828
// Autogenerated by tblgen.
29-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
29+
std::pair<const char *, uint64_t>
30+
getMnemonic(const MCInst &MI) const override;
3031
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3132
static const char *getRegisterName(MCRegister Reg);
3233

llvm/lib/Target/ARM/MCTargetDesc/ARMInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class ARMInstPrinter : public MCInstPrinter {
3030
void printRegName(raw_ostream &OS, MCRegister Reg) override;
3131

3232
// Autogenerated by tblgen.
33-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
33+
std::pair<const char *, uint64_t>
34+
getMnemonic(const MCInst &MI) const override;
3435
void printInstruction(const MCInst *MI, uint64_t Address,
3536
const MCSubtargetInfo &STI, raw_ostream &O);
3637
virtual bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/AVR/MCTargetDesc/AVRInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class AVRInstPrinter : public MCInstPrinter {
4848
}
4949

5050
// Autogenerated by TableGen.
51-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
51+
std::pair<const char *, uint64_t>
52+
getMnemonic(const MCInst &MI) const override;
5253
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
5354
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O);
5455
void printCustomAliasOperand(const MCInst *MI, uint64_t Address,

llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class BPFInstPrinter : public MCInstPrinter {
3232
void printBrTargetOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
3333

3434
// Autogenerated by tblgen.
35-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
35+
std::pair<const char *, uint64_t>
36+
getMnemonic(const MCInst &MI) const override;
3637
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3738
static const char *getRegisterName(MCRegister Reg);
3839
};

llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class CSKYInstPrinter : public MCInstPrinter {
3939
void printFPRRegName(raw_ostream &O, unsigned RegNo) const;
4040

4141
// Autogenerated by tblgen.
42-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
42+
std::pair<const char *, uint64_t>
43+
getMnemonic(const MCInst &MI) const override;
4344
void printInstruction(const MCInst *MI, uint64_t Address,
4445
const MCSubtargetInfo &STI, raw_ostream &O);
4546
bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/DirectX/MCTargetDesc/DirectXMCTargetDesc.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ class DXILInstPrinter : public MCInstPrinter {
5353
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot,
5454
const MCSubtargetInfo &STI, raw_ostream &O) override {}
5555

56-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override {
56+
std::pair<const char *, uint64_t>
57+
getMnemonic(const MCInst &MI) const override {
5758
return std::make_pair<const char *, uint64_t>("", 0ull);
5859
}
5960

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class HexagonInstPrinter : public MCInstPrinter {
3434

3535
static char const *getRegisterName(MCRegister Reg);
3636

37-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
37+
std::pair<const char *, uint64_t>
38+
getMnemonic(const MCInst &MI) const override;
3839
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3940
void printOperand(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;
4041
void printBrtarget(MCInst const *MI, unsigned OpNo, raw_ostream &O) const;

llvm/lib/Target/Lanai/MCTargetDesc/LanaiInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class LanaiInstPrinter : public MCInstPrinter {
4242
void printMemImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
4343

4444
// Autogenerated by tblgen.
45-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
45+
std::pair<const char *, uint64_t>
46+
getMnemonic(const MCInst &MI) const override;
4647
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
4748
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &OS);
4849
void printCustomAliasOperand(const MCInst *MI, uint64_t Address,

llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class LoongArchInstPrinter : public MCInstPrinter {
3333
const MCSubtargetInfo &STI, raw_ostream &O);
3434

3535
// Autogenerated by tblgen.
36-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
36+
std::pair<const char *, uint64_t>
37+
getMnemonic(const MCInst &MI) const override;
3738
void printInstruction(const MCInst *MI, uint64_t Address,
3839
const MCSubtargetInfo &STI, raw_ostream &O);
3940
bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/M68k/MCTargetDesc/M68kInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class M68kInstPrinter : public MCInstPrinter,
4242
void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
4343
unsigned PrintMethodIdx, raw_ostream &O);
4444

45-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
45+
std::pair<const char *, uint64_t>
46+
getMnemonic(const MCInst &MI) const override;
4647

4748
private:
4849
void printOperand(const MCInst *MI, unsigned opNum, raw_ostream &O);

llvm/lib/Target/MSP430/MCTargetDesc/MSP430InstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ namespace llvm {
2828
const MCSubtargetInfo &STI, raw_ostream &O) override;
2929

3030
// Autogenerated by tblgen.
31-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
31+
std::pair<const char *, uint64_t>
32+
getMnemonic(const MCInst &MI) const override;
3233
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3334
bool printAliasInstr(const MCInst *MI, uint64_t Address, raw_ostream &O);
3435
void printCustomAliasOperand(const MCInst *MI, uint64_t Address,

llvm/lib/Target/Mips/MCTargetDesc/MipsInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class MipsInstPrinter : public MCInstPrinter {
7979
: MCInstPrinter(MAI, MII, MRI) {}
8080

8181
// Autogenerated by tblgen.
82-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
82+
std::pair<const char *, uint64_t>
83+
getMnemonic(const MCInst &MI) const override;
8384
void printInstruction(const MCInst *MI, uint64_t Address,
8485
const MCSubtargetInfo &STI, raw_ostream &O);
8586
static const char *getRegisterName(MCRegister Reg);

llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class NVPTXInstPrinter : public MCInstPrinter {
2929
const MCSubtargetInfo &STI, raw_ostream &OS) override;
3030

3131
// Autogenerated by tblgen.
32-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
32+
std::pair<const char *, uint64_t>
33+
getMnemonic(const MCInst &MI) const override;
3334
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3435
static const char *getRegisterName(MCRegister Reg);
3536
// End

llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class PPCInstPrinter : public MCInstPrinter {
3636
const MCSubtargetInfo &STI, raw_ostream &O) override;
3737

3838
// Autogenerated by tblgen.
39-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
39+
std::pair<const char *, uint64_t>
40+
getMnemonic(const MCInst &MI) const override;
4041
void printInstruction(const MCInst *MI, uint64_t Address,
4142
const MCSubtargetInfo &STI, raw_ostream &O);
4243
static const char *getRegisterName(MCRegister Reg);

llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class RISCVInstPrinter : public MCInstPrinter {
6262
void printRegReg(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
6363
raw_ostream &O);
6464
// Autogenerated by tblgen.
65-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
65+
std::pair<const char *, uint64_t>
66+
getMnemonic(const MCInst &MI) const override;
6667
void printInstruction(const MCInst *MI, uint64_t Address,
6768
const MCSubtargetInfo &STI, raw_ostream &O);
6869
bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/SPIRV/MCTargetDesc/SPIRVInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class SPIRVInstPrinter : public MCInstPrinter {
4646
void printSymbolicOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
4747

4848
// Autogenerated by tblgen.
49-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
49+
std::pair<const char *, uint64_t>
50+
getMnemonic(const MCInst &MI) const override;
5051
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
5152
static const char *getRegisterName(MCRegister Reg);
5253
};

llvm/lib/Target/Sparc/MCTargetDesc/SparcInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ class SparcInstPrinter : public MCInstPrinter {
3333
bool isV9(const MCSubtargetInfo &STI) const;
3434

3535
// Autogenerated by tblgen.
36-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
36+
std::pair<const char *, uint64_t>
37+
getMnemonic(const MCInst &MI) const override;
3738
void printInstruction(const MCInst *MI, uint64_t Address,
3839
const MCSubtargetInfo &STI, raw_ostream &O);
3940
bool printAliasInstr(const MCInst *MI, uint64_t Address,

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZGNUInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class SystemZGNUInstPrinter : public SystemZInstPrinterCommon {
2828
: SystemZInstPrinterCommon(MAI, MII, MRI) {}
2929

3030
// Automatically generated by tblgen.
31-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
31+
std::pair<const char *, uint64_t>
32+
getMnemonic(const MCInst &MI) const override;
3233
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3334
static const char *getRegisterName(MCRegister Reg);
3435

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class SystemZHLASMInstPrinter : public SystemZInstPrinterCommon {
2828
: SystemZInstPrinterCommon(MAI, MII, MRI) {}
2929

3030
// Automatically generated by tblgen.
31-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
31+
std::pair<const char *, uint64_t>
32+
getMnemonic(const MCInst &MI) const override;
3233
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3334
static const char *getRegisterName(MCRegister Reg);
3435

llvm/lib/Target/VE/MCTargetDesc/VEInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class VEInstPrinter : public MCInstPrinter {
2929
const MCSubtargetInfo &STI, raw_ostream &OS) override;
3030

3131
// Autogenerated by tblgen.
32-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
32+
std::pair<const char *, uint64_t>
33+
getMnemonic(const MCInst &MI) const override;
3334
bool printAliasInstr(const MCInst *, uint64_t Address,
3435
const MCSubtargetInfo &, raw_ostream &);
3536
void printInstruction(const MCInst *, uint64_t, const MCSubtargetInfo &,

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, uint64_t Address,
5757
// operand isn't a symbol, then we have an MVP compilation unit, and the
5858
// table shouldn't appear in the output.
5959
OS << "\t";
60-
OS << getMnemonic(MI).first;
60+
OS << getMnemonic(*MI).first;
6161
OS << " ";
6262

6363
assert(MI->getNumOperands() == 2);

llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ class WebAssemblyInstPrinter final : public MCInstPrinter {
5050
void printCatchList(const MCInst *MI, unsigned OpNo, raw_ostream &O);
5151

5252
// Autogenerated by tblgen.
53-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
53+
std::pair<const char *, uint64_t>
54+
getMnemonic(const MCInst &MI) const override;
5455
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
5556
static const char *getRegisterName(MCRegister Reg);
5657
};

llvm/lib/Target/X86/MCTargetDesc/X86ATTInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class X86ATTInstPrinter final : public X86InstPrinterCommon {
3636
raw_ostream &O);
3737

3838
// Autogenerated by tblgen.
39-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
39+
std::pair<const char *, uint64_t>
40+
getMnemonic(const MCInst &MI) const override;
4041
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &OS);
4142
static const char *getRegisterName(MCRegister Reg);
4243

llvm/lib/Target/X86/MCTargetDesc/X86IntelInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class X86IntelInstPrinter final : public X86InstPrinterCommon {
3737
raw_ostream &O);
3838

3939
// Autogenerated by tblgen.
40-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
40+
std::pair<const char *, uint64_t>
41+
getMnemonic(const MCInst &MI) const override;
4142
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
4243
static const char *getRegisterName(MCRegister Reg);
4344

llvm/lib/Target/XCore/MCTargetDesc/XCoreInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ class XCoreInstPrinter : public MCInstPrinter {
2727
: MCInstPrinter(MAI, MII, MRI) {}
2828

2929
// Autogenerated by tblgen.
30-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
30+
std::pair<const char *, uint64_t>
31+
getMnemonic(const MCInst &MI) const override;
3132
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3233
static const char *getRegisterName(MCRegister Reg);
3334

llvm/lib/Target/Xtensa/MCTargetDesc/XtensaInstPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class XtensaInstPrinter : public MCInstPrinter {
2828
: MCInstPrinter(MAI, MII, MRI) {}
2929

3030
// Automatically generated by tblgen.
31-
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override;
31+
std::pair<const char *, uint64_t>
32+
getMnemonic(const MCInst &MI) const override;
3233
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O);
3334
static const char *getRegisterName(MCRegister Reg);
3435

llvm/utils/TableGen/AsmWriterEmitter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,9 @@ void AsmWriterEmitter::EmitGetMnemonic(
333333
O << "/// getMnemonic - This method is automatically generated by "
334334
"tablegen\n"
335335
"/// from the instruction set description.\n"
336-
"std::pair<const char *, uint64_t> "
337-
<< Target.getName() << ClassName << "::getMnemonic(const MCInst *MI) {\n";
336+
"std::pair<const char *, uint64_t>\n"
337+
<< Target.getName() << ClassName
338+
<< "::getMnemonic(const MCInst &MI) const {\n";
338339

339340
// Build an aggregate string, and build a table of offsets into it.
340341
SequenceToOffsetTable<std::string> StringTable;
@@ -458,7 +459,7 @@ void AsmWriterEmitter::EmitGetMnemonic(
458459
// If the total bits is more than 32-bits we need to use a 64-bit type.
459460
if (BitsLeft < (OpcodeInfoBits - 32))
460461
BitsOS << "(uint64_t)";
461-
BitsOS << "OpInfo" << Table << "[MI->getOpcode()] << " << Shift << ";\n";
462+
BitsOS << "OpInfo" << Table << "[MI.getOpcode()] << " << Shift << ";\n";
462463
// Prepare the shift for the next iteration and increment the table count.
463464
Shift += TableSize;
464465
++Table;
@@ -508,7 +509,7 @@ void AsmWriterEmitter::EmitPrintInstruction(
508509
O << " O << \"\\t\";\n\n";
509510

510511
// Emit the starting string.
511-
O << " auto MnemonicInfo = getMnemonic(MI);\n\n";
512+
O << " auto MnemonicInfo = getMnemonic(*MI);\n\n";
512513
O << " O << MnemonicInfo.first;\n\n";
513514

514515
O << " uint" << ((BitsLeft < (OpcodeInfoBits - 32)) ? 64 : 32)

0 commit comments

Comments
 (0)