]> granicus.if.org Git - llvm/commitdiff
[X86] Remove temporary std::string creation from shuffle comment printing. We can...
authorCraig Topper <craig.topper@intel.com>
Wed, 11 Oct 2017 00:46:09 +0000 (00:46 +0000)
committerCraig Topper <craig.topper@intel.com>
Wed, 11 Oct 2017 00:46:09 +0000 (00:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315399 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/InstPrinter/X86InstComments.cpp

index df2fc33486b3795f44769823f8fcff046362a5de..2890fd6156e1165ff3bbe2166738fc77bb616884 100644 (file)
@@ -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.