From a6676439bfc194d6fa85e669027aaf96bce67ff8 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 11 Oct 2017 00:46:09 +0000 Subject: [PATCH] [X86] Remove temporary std::string creation from shuffle comment printing. We can just write directly to the raw_ostream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315399 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/InstPrinter/X86InstComments.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Target/X86/InstPrinter/X86InstComments.cpp b/lib/Target/X86/InstPrinter/X86InstComments.cpp index df2fc33486b..2890fd6156e 100644 --- a/lib/Target/X86/InstPrinter/X86InstComments.cpp +++ b/lib/Target/X86/InstPrinter/X86InstComments.cpp @@ -205,16 +205,14 @@ static MVT getZeroExtensionResultType(const MCInst *MI) { } /// Wraps the destination register name with AVX512 mask/maskz filtering. -static std::string getMaskName(const MCInst *MI, const char *DestName, - const char *(*getRegName)(unsigned)) { - std::string OpMaskName(DestName); - +static void printMasking(raw_ostream &OS, const MCInst *MI, + const char *(*getRegName)(unsigned)) { bool MaskWithZero = false; const char *MaskRegName = nullptr; switch (MI->getOpcode()) { default: - return OpMaskName; + return; CASE_MASKZ_MOVDUP(MOVDDUP, m) CASE_MASKZ_MOVDUP(MOVDDUP, r) CASE_MASKZ_MOVDUP(MOVSHDUP, m) @@ -399,15 +397,11 @@ static std::string getMaskName(const MCInst *MI, const char *DestName, } // MASK: zmmX {%kY} - OpMaskName += " {%"; - OpMaskName += MaskRegName; - OpMaskName += "}"; + OS << " {%" << MaskRegName << "}"; // MASKZ: zmmX {%kY} {z} if (MaskWithZero) - OpMaskName += " {z}"; - - return OpMaskName; + OS << " {z}"; } //===----------------------------------------------------------------------===// @@ -1160,7 +1154,13 @@ bool llvm::EmitAnyX86InstComments(const MCInst *MI, raw_ostream &OS, return false; if (!DestName) DestName = Src1Name; - OS << (DestName ? getMaskName(MI, DestName, getRegName) : "mem") << " = "; + if (DestName) { + OS << DestName; + printMasking(OS, MI, getRegName); + } else + OS << "mem"; + + OS << " = "; // If the two sources are the same, canonicalize the input elements to be // from the first src so that we get larger element spans. -- 2.11.0