1 // RUN: llvm-tblgen %s | FileCheck %s
2 // RUN: not llvm-tblgen -DERROR1 %s 2>&1 | FileCheck --check-prefix=ERROR1 %s
3 // RUN: not llvm-tblgen -DERROR2 %s 2>&1 | FileCheck --check-prefix=ERROR2 %s
4 // RUN: not llvm-tblgen -DERROR3 %s 2>&1 | FileCheck --check-prefix=ERROR3 %s
5 // RUN: not llvm-tblgen -DERROR4 %s 2>&1 | FileCheck --check-prefix=ERROR4 %s
9 // CHECK: shifted_b = 8
10 // CHECK: shifted_i = 8
14 int shifted_b = !shl(b, 2);
15 int shifted_i = !shl(i, 2);
18 class Int<int value> {
23 def int1022 : Int<1022>;
24 def int1024 : Int<1024>;
28 def v0a : Int<!sub(int1024.Value, int1024.Value)>;
32 def v0b : Int<!and(int1024.Value, 2048)>;
36 def v1 : Int<!and(1025, 1)>;
39 // CHECK: Value = 1019
40 def v1019 : Int<!sub(int1022.Value, 3)>;
43 // CHECK: Value = 1023
44 def v1023 : Int<!or(int1022.Value, 1)>;
46 def v1025 : Int<!add(int1024.Value, 1)>;
48 // CHECK: Value = 1025
52 def v12 : Int<!mul(4, 3)>;
56 def v13 : Int<!div(10, 2)>;
60 def v14 : Int<!div(11, 2)>;
64 def v15 : Int<!div(1, 1)>;
68 def v16 : Int<!div(0, 10)>;
72 def v17 : Int<!div(-8, 4)>;
75 // ERROR1: error: Illegal operation: division by zero
76 def v18 : Int<!div(4, 0)>;
80 // ERROR2: error: Illegal operation: INT64_MIN / -1
81 def v19 : Int<!div(-9223372036854775808, -1)>;
88 // CHECK: Value = 2048
89 def v2048 : Int<!add(int1024.Value, int1024.Value)>;
92 // CHECK: Value = 3072
93 def v3072 : Int<!or(int1024.Value, v2048.Value)>;
101 def v4 : Int<!add(int2.Value, 1, v1.Value)>;
102 def v7 : Int<!or(v1.Value, int2.Value, v4.Value)>;
103 def v1a : Int<!and(v7.Value, 5, v1.Value)>;
107 def v84 : Int<!mul(v12.Value, v7.Value)>;
111 def v9 : Int<!xor(v7.Value, 0x0E)>;
114 // CHECK: Value = 924
115 def v924 : Int<!mul(v84.Value, 11)>;
118 // CHECK: Value = 925
119 def v925 : Int<!sub(v924.Value, -1)>;
123 def v950: Int<!logtwo(16)>;
127 def v951 : Int<!logtwo(1024)>;
131 def v952 : Int<!logtwo(1025)>;
134 // ERROR3: error: Illegal operation: logtwo is undefined on arguments less than or equal to 0
135 def v953 : Int<!logtwo(0)>;
139 // ERROR4: error: Illegal operation: logtwo is undefined on arguments less than or equal to 0
140 def v954 : Int<!logtwo(-1)>;
145 def vneg : Int<!sub(v925.Value, 927)>;