[llvm] [AMDGPU][TableGen][NFC] Combine predicates without using classes. (PR #82346)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 03:41:40 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-amdgpu

Author: Ivan Kosarev (kosarev)

<details>
<summary>Changes</summary>

Saves generating ~1200 instances of the PredConcat TableGen class.

Also removes the default predicates from resulting predicate lists.

---
Full diff: https://github.com/llvm/llvm-project/pull/82346.diff


1 Files Affected:

- (modified) llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td (+4-10) 


``````````diff
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td b/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td
index 6c7c91ef464dfd..7c990aa6b2eb60 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td
@@ -11,11 +11,6 @@ def TruePredicate : Predicate<"">;
 // FIXME: Tablegen should specially supports this
 def FalsePredicate : Predicate<"false">;
 
-// Add a predicate to the list if does not already exist to deduplicate it.
-class PredConcat<Predicate pred, list<Predicate> lst> {
-  list<Predicate> ret = !listconcat(lst, !listremove([pred], lst));
-}
-
 // Prevent using other kinds of predicates where True16 predicates are
 // expected by giving them their own class.
 class True16PredicateClass<string cond> : Predicate<cond>;
@@ -28,9 +23,8 @@ class PredicateControl {
   True16PredicateClass True16Predicate = NoTrue16Predicate;
   list<Predicate> OtherPredicates = [];
   list<Predicate> Predicates =
-      PredConcat<SubtargetPredicate,
-      PredConcat<AssemblerPredicate,
-      PredConcat<WaveSizePredicate,
-      PredConcat<True16Predicate,
-      OtherPredicates>.ret>.ret>.ret>.ret;
+      !foldl(OtherPredicates, [SubtargetPredicate, AssemblerPredicate,
+                               WaveSizePredicate, True16Predicate],
+             preds, p,
+             preds # !listremove([p], [TruePredicate, NoTrue16Predicate] # preds));
 }

``````````

</details>


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


More information about the llvm-commits mailing list