1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
4 defvar EmptyList = []<string>;
5 defvar OneList = ["foo"];
6 defvar WordList = ["foo", "bar", "zoo", "foo", "snork", "snork", "quux"];
10 def pred2 : Predicate;
11 def pred3 : Predicate;
12 def pred4 : Predicate;
13 def pred5 : Predicate;
15 class DeduplicatePredList<list<Predicate> predlist, Predicate pred> {
17 !listconcat([pred], !filter(item, predlist,
18 !ne(!cast<string>(item), !cast<string>(pred))));
24 // CHECK: list3 = ["foo"];
26 // CHECK: list5 = ["foo", "bar", "zoo", "foo", "snork", "snork", "quux"];
30 list<string> list1 = !filter(item, EmptyList, true);
31 list<string> list2 = !filter(item, EmptyList, false);
32 list<string> list3 = !filter(item, OneList, true);
33 list<string> list4 = !filter(item, OneList, false);
34 list<string> list5 = !filter(item, WordList, true);
35 list<string> list6 = !filter(item, WordList, false);
39 // CHECK: list1 = ["foo", "foo"];
40 // CHECK: list2 = ["bar", "zoo", "snork", "snork", "quux"];
41 // CHECK: list3 = ["snork", "snork", "quux"];
44 list<string> list1 = !filter(item, WordList, !eq(item, "foo"));
45 list<string> list2 = !filter(item, WordList, !ne(item, "foo"));
46 list<string> list3 = !filter(item, WordList, !ge(!size(item), 4));
50 // CHECK: list1 = [4, 5, 6, 7, 8, 9, 10];
51 // CHECK: list2 = [4, 5, 6, 7, 8];
54 list<int> list1 = !filter(num, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], !gt(num, 3));
55 list<int> list2 = !filter(num, list1, !lt(num, 9));
59 // CHECK: duplist = [pred1, pred2, pred1, pred3, pred4, pred1, pred5];
60 // CHECK: deduplist = [pred1, pred2, pred3, pred4, pred5];
63 list<Predicate> duplist = [pred1, pred2, pred1, pred3, pred4, pred1, pred5];
64 list<Predicate> deduplist = DeduplicatePredList<duplist, pred1>.ret;
69 // ERROR1: could not be fully resolved
72 list<string> list1 = !filter(item, WordList, !if(true, "oops!", "wrong!"));