[llvm] 6902734 - [X86] Simplify attributes of the generated memory folding table (NFCI)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 01:03:34 PDT 2022


Author: Shengchen Kan
Date: 2022-03-22T16:02:54+08:00
New Revision: 6902734eb38bcab90943880ae51c63eaef0f8154

URL: https://github.com/llvm/llvm-project/commit/6902734eb38bcab90943880ae51c63eaef0f8154
DIFF: https://github.com/llvm/llvm-project/commit/6902734eb38bcab90943880ae51c63eaef0f8154.diff

LOG: [X86] Simplify attributes of the generated memory folding table (NFCI)

This reduces the gaps between tables in X86GenFoldTables.inc and X86InstrFoldTables.cpp

Added: 
    

Modified: 
    llvm/utils/TableGen/X86FoldTablesEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
index 2a29331eb7e86..6b3b8ae84ba65 100644
--- a/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
+++ b/llvm/utils/TableGen/X86FoldTablesEmitter.cpp
@@ -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 {


        


More information about the llvm-commits mailing list