Skip to content

Commit 6d160a4

Browse files
authored
[AMDGPU][TableGen][NFC] Combine predicates without using classes. (#82346)
Saves generating ~1200 instances of the PredConcat TableGen class. Also removes the default predicates from resulting predicate lists.
1 parent a0b3dba commit 6d160a4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

llvm/lib/Target/AMDGPU/AMDGPUPredicateControl.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,6 @@ def TruePredicate : Predicate<"">;
1111
// FIXME: Tablegen should specially supports this
1212
def FalsePredicate : Predicate<"false">;
1313

14-
// Add a predicate to the list if does not already exist to deduplicate it.
15-
class PredConcat<Predicate pred, list<Predicate> lst> {
16-
list<Predicate> ret = !listconcat(lst, !listremove([pred], lst));
17-
}
18-
1914
// Prevent using other kinds of predicates where True16 predicates are
2015
// expected by giving them their own class.
2116
class True16PredicateClass<string cond> : Predicate<cond>;
@@ -28,9 +23,8 @@ class PredicateControl {
2823
True16PredicateClass True16Predicate = NoTrue16Predicate;
2924
list<Predicate> OtherPredicates = [];
3025
list<Predicate> Predicates =
31-
PredConcat<SubtargetPredicate,
32-
PredConcat<AssemblerPredicate,
33-
PredConcat<WaveSizePredicate,
34-
PredConcat<True16Predicate,
35-
OtherPredicates>.ret>.ret>.ret>.ret;
26+
!foldl(OtherPredicates, [SubtargetPredicate, AssemblerPredicate,
27+
WaveSizePredicate, True16Predicate],
28+
preds, p,
29+
preds # !listremove([p], [TruePredicate, NoTrue16Predicate] # preds));
3630
}

0 commit comments

Comments
 (0)