[llvm] [TableGen] Add a field to filter out GenericTable entries (PR #65458)

Michael Maitland via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 6 08:55:41 PDT 2023


================
@@ -734,22 +738,25 @@ irrelevant.
 
   def ATable : GenericTable {
     let FilterClass = "AEntry";
+    let FilterClassField = "IsNeeded";
     let Fields = ["Str", "Val1", "Val2"];
     let PrimaryKey = ["Val1", "Val2"];
     let PrimaryKeyName = "lookupATableByValues";
   }
 
-  class AEntry<string str, int val1, int val2> {
+  class AEntry<string str, int val1, int val2, bit isNeeded> {
     string Str = str;
     bits<8> Val1 = val1;
     bits<10> Val2 = val2;
+    bit IsNeeded = isNeeded;
   }
 
-  def : AEntry<"Bob",   5, 3>;
-  def : AEntry<"Carol", 2, 6>;
-  def : AEntry<"Ted",   4, 4>;
-  def : AEntry<"Alice", 4, 5>;
-  def : AEntry<"Costa", 2, 1>;
+  def : AEntry<"Bob",   5, 3, 1>;
+  def : AEntry<"Carol", 2, 6, 1>;
+  def : AEntry<"Ted",   4, 4, 1>;
+  def : AEntry<"Alice", 4, 5, 1>;
+  def : AEntry<"Costa", 2, 1, 1>;
+  def : AEntry<"Dale",  2, 1, 0>;
----------------
michaelmaitland wrote:

My concern is that we are generating `AEntry`s with data that isn't needed after the table is built. Once ATable is built, its `IsNeeded` field is no longer needed by the compiler.

I can imagine a scenario where you generate a table of Pseudo instructions and we would need to incur an extra bit per pseudo, per table cost. The reason why it is per table is because if we had two tables we would need `IsNeededForTableA` and `IsNeededForTableB`.

Can we solve this problem without generating "dead" data?

https://github.com/llvm/llvm-project/pull/65458


More information about the llvm-commits mailing list