git subrepo pull --force deps/lightrec
[pcsx_rearmed.git] / deps / lightning / check / imm.tst
1 .data           4096
2 #if __WORDSIZE == 32
3 fmt_i:
4 .c              "%s 0x%x = 0x%x (expected 0x%x)\n"
5 fmt_ext:
6 .c              "%s 0x%x %d %d = 0x%x (expected 0x%x)\n"
7 fmt_dep:
8 .c              "depi 0x%x 0x%x %d %d = 0x%x (expected 0x%x)\n"
9 #else
10 fmt_i:
11 .c              "%s 0x%lx = 0x%lx (expected 0x%lx)\n"
12 fmt_ext:
13 .c              "%s 0x%lx %ld %ld = 0x%lx (expected 0x%lx)\n"
14 fmt_dep:
15 .c              "depi 0x%lx 0x%lx %ld %ld = 0x%lx (expected 0x%lx)\n"
16 #endif
17 fmt_d:
18 .c              "%s %.12f = %.12f (expected %.12f)\n"
19 #define DEF(str)                                                        \
20 S##str:                                                                 \
21 .c              #str
22 DEF(negi)
23 DEF(comi)
24 DEF(exti_c)
25 DEF(exti_uc)
26 DEF(exti_s)
27 DEF(exti_us)
28 DEF(exti_i)
29 DEF(exti_ui)
30 DEF(htoni_us)
31 DEF(ntohi_us)
32 DEF(htoni_ui)
33 DEF(ntohi_ui)
34 DEF(htoni_ul)
35 DEF(ntohi_ul)
36 DEF(htoni)
37 DEF(ntohi)
38 DEF(bswapi_us)
39 DEF(bswapi_ui)
40 DEF(bswapi_ul)
41 DEF(bswapi)
42 DEF(cloi)
43 DEF(clzi)
44 DEF(ctoi)
45 DEF(ctzi)
46 DEF(rbiti)
47 DEF(popcnti)
48 DEF(exti)
49 DEF(exti_u)
50 DEF(negi_f)
51 DEF(absi_f)
52 DEF(sqrti_f)
53 DEF(negi_d)
54 DEF(absi_d)
55 DEF(sqrti_d)
56 ok:
57 .c      "ok"
58
59 #define CHECKI(OP, I0, I1)                                              \
60         OP %r0 I0                                                       \
61         beqi OP##_ok %r0 I1                                             \
62         prepare                                                         \
63                 pushargi fmt_i                                          \
64                 ellipsis                                                \
65                 pushargi S##OP                                          \
66                 pushargi I0                                             \
67                 pushargr %r0                                            \
68                 pushargi I1                                             \
69         finishi @printf                                                 \
70         calli @abort                                                    \
71 OP##_ok:
72 #define CHECKEXT(OP, I0, I1, I2, I3)                                    \
73         OP %r0 I0 I1 I2                                                 \
74         beqi OP##_ok %r0 I3                                             \
75         prepare                                                         \
76                 pushargi fmt_ext                                        \
77                 ellipsis                                                \
78                 pushargi S##OP                                          \
79                 pushargi I0                                             \
80                 pushargi I1                                             \
81                 pushargi I2                                             \
82                 pushargr %r0                                            \
83                 pushargi I3                                             \
84         finishi @printf                                                 \
85         calli @abort                                                    \
86 OP##_ok:
87 #define CHECKDEP(I0, I1, I2, I3, I4)                                    \
88         movi %r0 I0                                                     \
89         depi %r0 I1 I2 I3                                               \
90         beqi dep_ok %r0 I4                                              \
91         prepare                                                         \
92                 pushargi fmt_dep                                        \
93                 ellipsis                                                \
94                 pushargi I0                                             \
95                 pushargi I1                                             \
96                 pushargi I2                                             \
97                 pushargi I3                                             \
98                 pushargr %r0                                            \
99                 pushargi I4                                             \
100         finishi @printf                                                 \
101         calli @abort                                                    \
102 dep_ok:
103 #define CHECKD(OP, I0, I1)                                              \
104         OP %f0 I0                                                       \
105         beqi_d OP##_ok %f0 I1                                           \
106         prepare                                                         \
107                 pushargi fmt_d                                          \
108                 ellipsis                                                \
109                 pushargi S##OP                                          \
110                 pushargi_d I0                                           \
111                 pushargr_d %f0                                          \
112                 pushargi_d I1                                           \
113         finishi @printf                                                 \
114         calli @abort                                                    \
115 OP##_ok:
116 #define CHECKF(OP, I0, I1)                                              \
117         OP %f0 I0                                                       \
118         beqi_f OP##_ok %f0 I1                                           \
119         extr_f_d %f0 %f0                                                \
120         prepare                                                         \
121                 pushargi fmt_d                                          \
122                 ellipsis                                                \
123                 pushargi S##OP                                          \
124                 pushargi_d I0                                           \
125                 pushargr_d %f0                                          \
126                 pushargi_d I1                                           \
127         finishi @printf                                                 \
128         calli @abort                                                    \
129 OP##_ok:
130
131 .code
132         prolog
133
134         CHECKI(negi, 1, -1)
135         CHECKI(comi, 0, -1)
136         CHECKI(exti_c, 0xfff, -1)
137         CHECKI(exti_uc, 0xfff, 0xff)
138         CHECKI(exti_s, 0xfffff, -1)
139         CHECKI(exti_us, 0xfffff, 0xffff)
140 #if __BYTE_ORDER == __BIG_ENDIAN
141         CHECKI(htoni_us, 0xff1234, 0x1234)
142         CHECKI(ntohi_us, 0x7ffff, 0xffff)
143 #else
144         CHECKI(htoni_us, 0xff1234, 0x3412)
145         CHECKI(ntohi_us, 0x7ffff, 0xffff)
146 #endif
147 #if __BYTE_ORDER == __BIG_ENDIAN
148 #  if __WORDSIZE == 32
149         CHECKI(htoni_ui, 0x12345678, 0x12345678)
150         CHECKI(ntohi_ui, 0x78563412, 0x78563412)
151 #  else
152         CHECKI(htoni_ui, 0x7f12345678, 0x12345678)
153         CHECKI(ntohi_ui, 0xf778563412, 0x78563412)
154 #  endif
155 #else
156 #  if __WORDSIZE == 32
157         CHECKI(htoni_ui, 0x12345678, 0x78563412)
158         CHECKI(ntohi_ui, 0x78563412, 0x12345678)
159 #  else
160         CHECKI(htoni_ui, 0x7f12345678, 0x78563412)
161         CHECKI(ntohi_ui, 0xf778563412, 0x12345678)
162 #  endif
163 #endif
164         CHECKI(bswapi_us, 0x1234, 0x3412)
165         CHECKI(bswapi_ui, 0x12345678, 0x78563412)
166 #if __WORDSIZE == 32
167 #  if __BYTE_ORDER == __BIG_ENDIAN
168         CHECKI(htoni, 0x78563412, 0x78563412)
169         CHECKI(ntohi, 0x12345678, 0x12345678)
170 #  else
171         CHECKI(htoni, 0x78563412, 0x12345678)
172         CHECKI(ntohi, 0x12345678, 0x78563412)
173 #  endif
174         CHECKI(bswapi, 0x78563412, 0x12345678)
175 #else
176 #  if __BYTE_ORDER == __BIG_ENDIAN
177         CHECKI(htoni_ul, 0xf0debc9a78563412, 0xf0debc9a78563412)
178         CHECKI(ntohi_ul, 0x123456789abcdef0, 0x123456789abcdef0)
179         CHECKI(htoni, 0x123456789abcdef0, 0x123456789abcdef0)
180         CHECKI(ntohi, 0xf0debc9a78563412, 0xf0debc9a78563412)
181 #  else
182         CHECKI(htoni_ul, 0x123456789abcdef0, 0xf0debc9a78563412)
183         CHECKI(ntohi_ul, 0xf0debc9a78563412, 0x123456789abcdef0)
184         CHECKI(htoni, 0xf0debc9a78563412, 0x123456789abcdef0)
185         CHECKI(ntohi, 0x123456789abcdef0, 0xf0debc9a78563412)
186 #  endif
187         CHECKI(exti_i, 0x80000000, 0xffffffff80000000)
188         CHECKI(exti_ui, 0x80000000, 0x80000000)
189         CHECKI(bswapi_ul, 0x123456789abcdef0, 0xf0debc9a78563412)
190         CHECKI(bswapi, 0xf0debc9a78563412, 0x123456789abcdef0)
191 #endif
192 #if __WORDSIZE == 32
193         CHECKI(cloi, 0xfffffffe, 31)
194         CHECKI(clzi, 1, 31)
195         CHECKI(ctoi, 0x7fffffff, 31)
196         CHECKI(ctzi, 0x80000000, 31)
197         CHECKI(rbiti, 0x02468ace, 0x73516240)
198         CHECKI(popcnti, 0x8a13c851, 12)
199 #else
200         CHECKI(cloi, 0xfffffffffffffffe, 63)
201         CHECKI(clzi, 1, 63)
202         CHECKI(ctoi, 0x7fffffffffffffff, 63)
203         CHECKI(ctzi, 0x8000000000000000, 63)
204         CHECKI(rbiti, 0x02468ace013579bd, 0xbd9eac8073516240)
205         CHECKI(popcnti, 0x02468ace013579bd, 28)
206 #endif
207 #if __WORDSIZE == 32
208 #  if __BYTE_ORDER == __LITTLE_ENDIAN
209         CHECKEXT(exti, 0xa5a5a584, 1, 2, 0xfffffffe)
210         CHECKEXT(exti_u, 0xa5a5a584, 1, 2, 0x00000002)
211         CHECKDEP(0xa5a5a584, 1, 1, 2, 0xa5a5a582)
212 #  else
213         CHECKEXT(exti, 0xa5a5a3b7, 29, 1, 0xffffffff)
214         CHECKEXT(exti_u, 0xa5a5a3b7, 29, 1, 0x00000001)
215         CHECKDEP(0xa5a5a3b7, 0, 29, 1, 0xa5a5a3b3)
216 #  endif
217 #else
218 #  if __BYTE_ORDER == __LITTLE_ENDIAN
219         CHECKEXT(exti, 0xa5a5a5a5a5a5a564, 1, 2, 0xfffffffffffffffe)
220         CHECKEXT(exti_u, 0xa5a5a5a5a5a5a564, 1, 2, 0x0000000000000002)
221         CHECKDEP(0xa5a5a5a5a5a5a564, 1, 1, 2, 0xa5a5a5a5a5a5a562)
222 #  else
223         CHECKEXT(exti, 0xa5a5a5a5a5a59dc8, 60, 3, 0xfffffffffffffffc)
224         CHECKEXT(exti_u, 0xa5a5a5a5a5a59dc6, 61, 2, 0x0000000000000002)
225         CHECKDEP(0xa5a5a5a5a5a59dc6, 1, 61, 2, 0xa5a5a5a5a5a59dc2)
226 #  endif
227 #endif
228         CHECKF(negi_f, 2.0, -2.0)
229         CHECKF(absi_f, -3.0, 3.0)
230         CHECKF(sqrti_f, 81.0, 9.0)
231         CHECKD(negi_d, -2.0, 2.0)
232         CHECKD(absi_d, -1.0, 1.0)
233         CHECKD(sqrti_d, 9.0, 3.0)
234
235         prepare
236                 pushargi ok
237         finishi @puts
238         ret
239         epilog