Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AMDGPU][TableGen][NFC] Combine predicates without using classes. #82346

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

kosarev
Copy link
Collaborator

@kosarev kosarev commented Feb 20, 2024

Saves generating ~1200 instances of the PredConcat TableGen class.

Also removes the default predicates from resulting predicate lists.

Saves generating ~1200 instances of the PredConcat TableGen class.

Also removes the default predicates from resulting predicate lists.
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 20, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Ivan Kosarev (kosarev)

Changes

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 --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));
 }

Copy link
Contributor

@jayfoad jayfoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@kosarev kosarev merged commit 6d160a4 into llvm:main Feb 21, 2024
6 checks passed
@kosarev kosarev deleted the t16-predicates branch February 21, 2024 11:45
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Mar 21, 2024
…00611d382

Local branch amd-gfx 7120061 Merged main:96b17043507caec02a2ef440b369506122bdeb11 into amd-gfx:d4bdcbc628f2
Remote branch main 6d160a4 [AMDGPU][TableGen][NFC] Combine predicates without using classes. (llvm#82346)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants