[llvm] [TableGen][GlobalISel] Emit Comment with MatchTable Size (PR #74701)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 00:41:24 PST 2023


https://github.com/Pierre-vh updated https://github.com/llvm/llvm-project/pull/74701

>From b774a87cff933f443d55e5dc7eb61ae221896cad Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Thu, 7 Dec 2023 09:05:33 +0100
Subject: [PATCH 1/3] [TableGen][GlobalISel] Emit Comment with MatchTable Size

---
 llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td | 2 +-
 llvm/test/TableGen/GlobalISelEmitter.td                     | 4 ++--
 llvm/utils/TableGen/GlobalISelMatchTable.cpp                | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td
index a74f7fbbe1cce..3b0f656924322 100644
--- a/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td
+++ b/llvm/test/TableGen/GlobalISelCombinerEmitter/match-table.td
@@ -251,6 +251,6 @@ def MyCombiner: GICombiner<"GenMyCombiner", [
 // CHECK-NEXT:     GIM_Reject,
 // CHECK-NEXT:     // Label 6: @267
 // CHECK-NEXT:     GIM_Reject,
-// CHECK-NEXT:     };
+// CHECK-NEXT:     }; // Size: 2144 bytes
 // CHECK-NEXT:   return MatchTable0;
 // CHECK-NEXT: }
diff --git a/llvm/test/TableGen/GlobalISelEmitter.td b/llvm/test/TableGen/GlobalISelEmitter.td
index b7a81894f6442..176db59a1f412 100644
--- a/llvm/test/TableGen/GlobalISelEmitter.td
+++ b/llvm/test/TableGen/GlobalISelEmitter.td
@@ -517,7 +517,7 @@ def : Pat<(frag GPR32:$src1, complex:$src2, complex:$src3),
 // R00O-NEXT:  GIM_Reject,
 // R00O:       // Label [[DEFAULT_NUM]]: @[[DEFAULT]]
 // R00O-NEXT:  GIM_Reject,
-// R00O-NEXT:  };
+// R00O-NEXT:  }; // Size: 9784 bytes
 
 def INSNBOB : I<(outs GPR32:$dst), (ins GPR32:$src1, GPR32:$src2, GPR32:$src3, GPR32:$src4),
                  [(set GPR32:$dst,
@@ -1169,5 +1169,5 @@ def BR : I<(outs), (ins unknown:$target),
             [(br bb:$target)]>;
 
 // NOOPT-NEXT:    GIM_Reject,
-// NOOPT-NEXT:  };
+// NOOPT-NEXT:  }; // Size: 11160 bytes
 // NOOPT-NEXT:  return MatchTable0;
diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
index 5a4d32a34e2bc..eb72c84e57c91 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
@@ -243,7 +243,7 @@ void MatchTable::emitDeclaration(raw_ostream &OS) const {
     if (I->Flags & MatchTableRecord::MTRF_Outdent)
       Indentation -= 2;
   }
-  OS << "};\n";
+  OS << "}; // Size: " << (CurrentSize * 8) << " bytes\n";;
 }
 
 MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage,

>From df3f798c642368b5924655fda0f5b301e6c076c0 Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Thu, 7 Dec 2023 09:24:42 +0100
Subject: [PATCH 2/3] clang-format

---
 llvm/utils/TableGen/GlobalISelMatchTable.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
index eb72c84e57c91..bdd985c8801c5 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
@@ -243,7 +243,8 @@ void MatchTable::emitDeclaration(raw_ostream &OS) const {
     if (I->Flags & MatchTableRecord::MTRF_Outdent)
       Indentation -= 2;
   }
-  OS << "}; // Size: " << (CurrentSize * 8) << " bytes\n";;
+  OS << "}; // Size: " << (CurrentSize * 8) << " bytes\n";
+  ;
 }
 
 MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage,

>From 37f2c8fdc12f847f431b94e8d15cb611f3ca49a7 Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Thu, 7 Dec 2023 09:41:07 +0100
Subject: [PATCH 3/3] remove extra semi

---
 llvm/utils/TableGen/GlobalISelMatchTable.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/utils/TableGen/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
index bdd985c8801c5..481f3f16e0136 100644
--- a/llvm/utils/TableGen/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/GlobalISelMatchTable.cpp
@@ -244,7 +244,6 @@ void MatchTable::emitDeclaration(raw_ostream &OS) const {
       Indentation -= 2;
   }
   OS << "}; // Size: " << (CurrentSize * 8) << " bytes\n";
-  ;
 }
 
 MatchTable MatchTable::buildTable(ArrayRef<Matcher *> Rules, bool WithCoverage,



More information about the llvm-commits mailing list