[X86] Simplify attributes of the generated memory folding table (NFCI)
authorShengchen Kan <shengchen.kan@intel.com>
Tue, 22 Mar 2022 07:58:52 +0000 (15:58 +0800)
committerShengchen Kan <shengchen.kan@intel.com>
Tue, 22 Mar 2022 08:02:54 +0000 (16:02 +0800)
This reduces the gaps between tables in X86GenFoldTables.inc and X86InstrFoldTables.cpp

llvm/utils/TableGen/X86FoldTablesEmitter.cpp

index 2a29331..6b3b8ae 100644 (file)
@@ -114,16 +114,21 @@ class X86FoldTablesEmitter {
       OS  << "X86::" << MemInst->TheDef->getName() << ",";
       OS.PadToColumn(75);
 
+      std::string Attrs;
       if (IsLoad)
-        OS << "TB_FOLDED_LOAD | ";
+        Attrs += "TB_FOLDED_LOAD | ";
       if (IsStore)
-        OS << "TB_FOLDED_STORE | ";
+        Attrs += "TB_FOLDED_STORE | ";
       if (CannotUnfold)
-        OS << "TB_NO_REVERSE | ";
+        Attrs += "TB_NO_REVERSE | ";
       if (IsAligned)
-        OS << "TB_ALIGN_" << Alignment << " | ";
+        Attrs += "TB_ALIGN_" + std::to_string(Alignment) + " | ";
 
-      OS << "0 },\n";
+      StringRef SimplifiedAttrs = StringRef(Attrs).rtrim("| ");
+      if (SimplifiedAttrs.empty())
+        SimplifiedAttrs = "0";
+
+      OS << SimplifiedAttrs << " },\n";
     }
 
     bool operator<(const X86FoldTableEntry &RHS) const {