diff --git a/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp b/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp index 5941e06d76cd..dbc2570160e5 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp +++ b/llvm/lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp @@ -47,8 +47,7 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, // If verbose assembly is enabled, we can print some informative comments. if (CommentStream) - HasCustomInstComment = - EmitAnyX86InstComments(MI, *CommentStream, MII, getRegisterName); + HasCustomInstComment = EmitAnyX86InstComments(MI, *CommentStream, MII); unsigned Flags = MI->getFlags(); if ((TSFlags & X86II::LOCK) || (Flags & X86::IP_HAS_LOCK)) diff --git a/llvm/lib/Target/X86/InstPrinter/X86InstComments.cpp b/llvm/lib/Target/X86/InstPrinter/X86InstComments.cpp index 72117cd231dc..37bed37b0994 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86InstComments.cpp +++ b/llvm/lib/Target/X86/InstPrinter/X86InstComments.cpp @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "X86InstComments.h" +#include "X86ATTInstPrinter.h" #include "MCTargetDesc/X86BaseInfo.h" #include "MCTargetDesc/X86MCTargetDesc.h" #include "Utils/X86ShuffleDecode.h" @@ -218,10 +219,13 @@ static unsigned getRegOperandNumElts(const MCInst *MI, unsigned ScalarSize, return getVectorRegSize(OpReg) / ScalarSize; } +static const char *getRegName(unsigned Reg) { + return X86ATTInstPrinter::getRegisterName(Reg); +} + /// Wraps the destination register name with AVX512 mask/maskz filtering. static void printMasking(raw_ostream &OS, const MCInst *MI, - const MCInstrInfo &MCII, - const char *(*getRegName)(unsigned)) { + const MCInstrInfo &MCII) { const MCInstrDesc &Desc = MCII.get(MI->getOpcode()); uint64_t TSFlags = Desc.TSFlags; @@ -244,8 +248,7 @@ static void printMasking(raw_ostream &OS, const MCInst *MI, OS << " {z}"; } -static bool printFMA3Comments(const MCInst *MI, raw_ostream &OS, - const char *(*getRegName)(unsigned)) { +static bool printFMA3Comments(const MCInst *MI, raw_ostream &OS) { const char *Mul1Name = nullptr, *Mul2Name = nullptr, *AccName = nullptr; unsigned NumOperands = MI->getNumOperands(); bool RegForm = false; @@ -495,15 +498,14 @@ static bool printFMA3Comments(const MCInst *MI, raw_ostream &OS, /// newline terminated strings to the specified string if desired. This /// information is shown in disassembly dumps when verbose assembly is enabled. bool llvm::EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, - const MCInstrInfo &MCII, - const char *(*getRegName)(unsigned)) { + const MCInstrInfo &MCII) { // If this is a shuffle operation, the switch should fill in this state. SmallVector ShuffleMask; const char *DestName = nullptr, *Src1Name = nullptr, *Src2Name = nullptr; unsigned NumOperands = MI->getNumOperands(); bool RegForm = false; - if (printFMA3Comments(MI, OS, getRegName)) + if (printFMA3Comments(MI, OS)) return true; switch (MI->getOpcode()) { @@ -1254,7 +1256,7 @@ bool llvm::EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, if (!DestName) DestName = Src1Name; if (DestName) { OS << DestName; - printMasking(OS, MI, MCII, getRegName); + printMasking(OS, MI, MCII); } else OS << "mem"; diff --git a/llvm/lib/Target/X86/InstPrinter/X86InstComments.h b/llvm/lib/Target/X86/InstPrinter/X86InstComments.h index 0ba3e7401b36..40dffa5fbb8a 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86InstComments.h +++ b/llvm/lib/Target/X86/InstPrinter/X86InstComments.h @@ -21,8 +21,7 @@ namespace llvm { class MCInstrInfo; class raw_ostream; bool EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, - const MCInstrInfo &MCII, - const char *(*getRegName)(unsigned)); + const MCInstrInfo &MCII); } #endif diff --git a/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp b/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp index 0e0a02b150a5..0e0697518213 100644 --- a/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp +++ b/llvm/lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp @@ -59,7 +59,7 @@ void X86IntelInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, // If verbose assembly is enabled, we can print some informative comments. if (CommentStream) - EmitAnyX86InstComments(MI, *CommentStream, MII, getRegisterName); + EmitAnyX86InstComments(MI, *CommentStream, MII); } void X86IntelInstPrinter::printSSEAVXCC(const MCInst *MI, unsigned Op,