1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
4 // Tests for the true and false literals.
6 defvar otherwise = true;
10 // CHECK: bit flag1 = 1;
11 // CHECK: bit flag2 = 0;
12 // CHECK: int true_int = 1;
20 // CHECK: def rec2_true
27 // CHECK: def rec3_false
35 // CHECK: int value = 52;
38 int value = !add(10, !if(!and(do_it, true), 42, 0));
42 // CHECK: string name = "snork";
45 string name = !cond(false: "foo",
51 // CHECK: bit xorFF = 0;
52 // CHECK: bit xorFT = 1;
53 // CHECK: bit xorTF = 1;
54 // CHECK: bit xorTT = 0;
57 bit xorFF = !xor(false, false);
58 bit xorFT = !xor(false, true);
59 bit xorTF = !xor(true, false);
60 bit xorTT = !xor(true, true);
64 // CHECK: bits<3> flags = { 1, 0, 1 };
67 bits<3> flags = { true, false, true };
70 // `!and` and `!or` should be short-circuit such that `!tail` on empty list will never
73 // CHECK: list<int> newSeq = [];
74 // CHECK: list<int> newSeq2 = [];
76 class Foo <list<int> seq = []> {
77 bit unresolved = !ne(!find(NAME, "BAR"), -1);
78 list<int> newSeq = !if(!and(false, unresolved), !tail(seq), seq);
79 list<int> newSeq2 = !if(!or(-1, unresolved), seq, !tail(seq));
85 // ERROR1: Record name '1' is not a string