target/arm: Fix PAuth sbox functions
[qemu/ar7.git] / tests / tcg / xtensa / test_fp0_conv.S
blob147e3d5062df3dcc4524f27cbc2d042ba229bcf8
1 #include "macros.inc"
3 test_suite fp0_conv
5 #if XCHAL_HAVE_FP
7 .macro movfp fr, v
8     movi    a2, \v
9     wfr     \fr, a2
10 .endm
12 .macro test_ftoi_ex op, r0, fr0, v, c, r
13     movi    a2, 0
14     wur     a2, fsr
15     movfp   \fr0, \v
16     \op     \r0, \fr0, \c
17     dump    \r0
18     movi    a3, \r
19     assert  eq, \r0, a3
20     rur     a2, fsr
21     assert  eqi, a2, 0
22 .endm
24 .macro test_ftoi op, r0, fr0, v, c, r
25     movi    a2, 0
26     wur     a2, fcr
27     test_ftoi_ex \op, \r0, \fr0, \v, \c, \r
28     movi    a2, 0x7c
29     wur     a2, fcr
30     test_ftoi_ex \op, \r0, \fr0, \v, \c, \r
31 .endm
34 .macro test_itof_ex op, fr0, ar0, v, c, r
35     movi    a2, 0
36     wur     a2, fsr
37     movi    \ar0, \v
38     \op     \fr0, \ar0, \c
40     rfr     a2, \fr0
41     dump    a2
42     movi    a3, \r
43     assert  eq, a2, a3
44     rur     a2, fsr
45     assert  eqi, a2, 0
46 .endm
48 .macro test_itof_rm op, fr0, ar0, v, c, rm, r
49     movi    a2, \rm
50     wur     a2, fcr
51     test_itof_ex \op, \fr0, \ar0, \v, \c, \r
52     movi    a2, (\rm) | 0x7c
53     wur     a2, fcr
54     test_itof_ex \op, \fr0, \ar0, \v, \c, \r
55 .endm
57 .macro test_itof op, fr0, ar0, v, c, r0, r1, r2, r3
58     test_itof_rm \op, \fr0, \ar0, \v, \c, 0, \r0
59     test_itof_rm \op, \fr0, \ar0, \v, \c, 1, \r1
60     test_itof_rm \op, \fr0, \ar0, \v, \c, 2, \r2
61     test_itof_rm \op, \fr0, \ar0, \v, \c, 3, \r3
62 .endm
64 test round_s
65     movi    a2, 1
66     wsr     a2, cpenable
68     /* NaN */
69     test_ftoi round.s, a2, f0, 0xffc00001, 0, 0x7fffffff
70     test_ftoi round.s, a2, f0, 0xff800001, 0, 0x7fffffff
72     /* -inf */
73     test_ftoi round.s, a2, f0, 0xff800000, 0, 0x80000000
75     /* negative overflow */
76     test_ftoi round.s, a2, f0, 0xceffffff, 1, 0x80000000
77     test_ftoi round.s, a2, f0, 0xcf000000, 0, 0x80000000
78     test_ftoi round.s, a2, f0, 0xceffffff, 0, 0x80000080
80     /* negative */
81     test_ftoi round.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
82     test_ftoi round.s, a2, f0, 0xbfc00000, 0, -2 /* -1.5 */
83     test_ftoi round.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
84     test_ftoi round.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
85     test_ftoi round.s, a2, f0, 0xbf400000, 0, -1 /* -0.75 */
86     test_ftoi round.s, a2, f0, 0xbf000000, 0, 0  /* -0.5 */
88     /* positive */
89     test_ftoi round.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
90     test_ftoi round.s, a2, f0, 0x3f400000, 0, 1 /* 0.75 */
91     test_ftoi round.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
92     test_ftoi round.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
93     test_ftoi round.s, a2, f0, 0x3fc00000, 0, 2 /* 1.5 */
94     test_ftoi round.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
96     /* positive overflow */
97     test_ftoi round.s, a2, f0, 0x4effffff, 0, 0x7fffff80
98     test_ftoi round.s, a2, f0, 0x4f000000, 0, 0x7fffffff
99     test_ftoi round.s, a2, f0, 0x4effffff, 1, 0x7fffffff
101     /* +inf */
102     test_ftoi round.s, a2, f0, 0x7f800000, 0, 0x7fffffff
104     /* NaN */
105     test_ftoi round.s, a2, f0, 0x7f800001, 0, 0x7fffffff
106     test_ftoi round.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
107 test_end
109 test trunc_s
110     /* NaN */
111     test_ftoi trunc.s, a2, f0, 0xffc00001, 0, 0x7fffffff
112     test_ftoi trunc.s, a2, f0, 0xff800001, 0, 0x7fffffff
114     /* -inf */
115     test_ftoi trunc.s, a2, f0, 0xff800000, 0, 0x80000000
117     /* negative overflow */
118     test_ftoi trunc.s, a2, f0, 0xceffffff, 1, 0x80000000
119     test_ftoi trunc.s, a2, f0, 0xcf000000, 0, 0x80000000
120     test_ftoi trunc.s, a2, f0, 0xceffffff, 0, 0x80000080
122     /* negative */
123     test_ftoi trunc.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
124     test_ftoi trunc.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
125     test_ftoi trunc.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
126     test_ftoi trunc.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
127     test_ftoi trunc.s, a2, f0, 0xbf400000, 0, 0  /* -0.75 */
128     test_ftoi trunc.s, a2, f0, 0xbf000000, 0, 0  /* -0.5 */
130     /* positive */
131     test_ftoi trunc.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
132     test_ftoi trunc.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
133     test_ftoi trunc.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
134     test_ftoi trunc.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
135     test_ftoi trunc.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
136     test_ftoi trunc.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
138     /* positive overflow */
139     test_ftoi trunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80
140     test_ftoi trunc.s, a2, f0, 0x4f000000, 0, 0x7fffffff
141     test_ftoi trunc.s, a2, f0, 0x4effffff, 1, 0x7fffffff
143     /* +inf */
144     test_ftoi trunc.s, a2, f0, 0x7f800000, 0, 0x7fffffff
146     /* NaN */
147     test_ftoi trunc.s, a2, f0, 0x7f800001, 0, 0x7fffffff
148     test_ftoi trunc.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
149 test_end
151 test floor_s
152     /* NaN */
153     test_ftoi floor.s, a2, f0, 0xffc00001, 0, 0x7fffffff
154     test_ftoi floor.s, a2, f0, 0xff800001, 0, 0x7fffffff
156     /* -inf */
157     test_ftoi floor.s, a2, f0, 0xff800000, 0, 0x80000000
159     /* negative overflow */
160     test_ftoi floor.s, a2, f0, 0xceffffff, 1, 0x80000000
161     test_ftoi floor.s, a2, f0, 0xcf000000, 0, 0x80000000
162     test_ftoi floor.s, a2, f0, 0xceffffff, 0, 0x80000080
164     /* negative */
165     test_ftoi floor.s, a2, f0, 0xbfa00000, 1, -3 /* -1.25 * 2 */
166     test_ftoi floor.s, a2, f0, 0xbfc00000, 0, -2 /* -1.5 */
167     test_ftoi floor.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
168     test_ftoi floor.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
169     test_ftoi floor.s, a2, f0, 0xbf400000, 0, -1 /* -0.75 */
170     test_ftoi floor.s, a2, f0, 0xbf000000, 0, -1 /* -0.5 */
172     /* positive */
173     test_ftoi floor.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
174     test_ftoi floor.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
175     test_ftoi floor.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
176     test_ftoi floor.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
177     test_ftoi floor.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
178     test_ftoi floor.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
180     /* positive overflow */
181     test_ftoi floor.s, a2, f0, 0x4effffff, 0, 0x7fffff80
182     test_ftoi floor.s, a2, f0, 0x4f000000, 0, 0x7fffffff
183     test_ftoi floor.s, a2, f0, 0x4effffff, 1, 0x7fffffff
185     /* +inf */
186     test_ftoi floor.s, a2, f0, 0x7f800000, 0, 0x7fffffff
188     /* NaN */
189     test_ftoi floor.s, a2, f0, 0x7f800001, 0, 0x7fffffff
190     test_ftoi floor.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
191 test_end
193 test ceil_s
194     /* NaN */
195     test_ftoi ceil.s, a2, f0, 0xffc00001, 0, 0x7fffffff
196     test_ftoi ceil.s, a2, f0, 0xff800001, 0, 0x7fffffff
198     /* -inf */
199     test_ftoi ceil.s, a2, f0, 0xff800000, 0, 0x80000000
201     /* negative overflow */
202     test_ftoi ceil.s, a2, f0, 0xceffffff, 1, 0x80000000
203     test_ftoi ceil.s, a2, f0, 0xcf000000, 0, 0x80000000
204     test_ftoi ceil.s, a2, f0, 0xceffffff, 0, 0x80000080
206     /* negative */
207     test_ftoi ceil.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
208     test_ftoi ceil.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
209     test_ftoi ceil.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
210     test_ftoi ceil.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
211     test_ftoi ceil.s, a2, f0, 0xbf400000, 0, 0  /* -0.75 */
212     test_ftoi ceil.s, a2, f0, 0xbf000000, 0, 0  /* -0.5 */
214     /* positive */
215     test_ftoi ceil.s, a2, f0, 0x3f000000, 0, 1 /* 0.5 */
216     test_ftoi ceil.s, a2, f0, 0x3f400000, 0, 1 /* 0.75 */
217     test_ftoi ceil.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
218     test_ftoi ceil.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
219     test_ftoi ceil.s, a2, f0, 0x3fc00000, 0, 2 /* 1.5 */
220     test_ftoi ceil.s, a2, f0, 0x3fa00000, 1, 3 /* 1.25 * 2 */
222     /* positive overflow */
223     test_ftoi ceil.s, a2, f0, 0x4effffff, 0, 0x7fffff80
224     test_ftoi ceil.s, a2, f0, 0x4f000000, 0, 0x7fffffff
225     test_ftoi ceil.s, a2, f0, 0x4effffff, 1, 0x7fffffff
227     /* +inf */
228     test_ftoi ceil.s, a2, f0, 0x7f800000, 0, 0x7fffffff
230     /* NaN */
231     test_ftoi ceil.s, a2, f0, 0x7f800001, 0, 0x7fffffff
232     test_ftoi ceil.s, a2, f0, 0x7fc00000, 0, 0x7fffffff
233 test_end
235 test utrunc_s
236     /* NaN */
237     test_ftoi utrunc.s, a2, f0, 0xffc00001, 0, 0xffffffff
238     test_ftoi utrunc.s, a2, f0, 0xff800001, 0, 0xffffffff
240     /* -inf */
241     test_ftoi utrunc.s, a2, f0, 0xff800000, 0, 0x80000000
243     /* negative overflow */
244     test_ftoi utrunc.s, a2, f0, 0xceffffff, 1, 0x80000000
245     test_ftoi utrunc.s, a2, f0, 0xcf000000, 0, 0x80000000
246     test_ftoi utrunc.s, a2, f0, 0xceffffff, 0, 0x80000080
248     /* negative */
249     test_ftoi utrunc.s, a2, f0, 0xbfa00000, 1, -2 /* -1.25 * 2 */
250     test_ftoi utrunc.s, a2, f0, 0xbfc00000, 0, -1 /* -1.5 */
251     test_ftoi utrunc.s, a2, f0, 0xbf800000, 1, -2 /* -1 * 2 */
252     test_ftoi utrunc.s, a2, f0, 0xbf800000, 0, -1 /* -1 */
253     test_ftoi utrunc.s, a2, f0, 0xbf400000, 0, 0  /* -0.75 */
254     test_ftoi utrunc.s, a2, f0, 0xbf000000, 0, 0  /* -0.5 */
256     /* positive */
257     test_ftoi utrunc.s, a2, f0, 0x3f000000, 0, 0 /* 0.5 */
258     test_ftoi utrunc.s, a2, f0, 0x3f400000, 0, 0 /* 0.75 */
259     test_ftoi utrunc.s, a2, f0, 0x3f800000, 0, 1 /* 1 */
260     test_ftoi utrunc.s, a2, f0, 0x3f800000, 1, 2 /* 1 * 2 */
261     test_ftoi utrunc.s, a2, f0, 0x3fc00000, 0, 1 /* 1.5 */
262     test_ftoi utrunc.s, a2, f0, 0x3fa00000, 1, 2 /* 1.25 * 2 */
264     /* positive overflow */
265     test_ftoi utrunc.s, a2, f0, 0x4effffff, 0, 0x7fffff80
266     test_ftoi utrunc.s, a2, f0, 0x4f000000, 0, 0x80000000
267     test_ftoi utrunc.s, a2, f0, 0x4effffff, 1, 0xffffff00
268     test_ftoi utrunc.s, a2, f0, 0x4f800000, 1, 0xffffffff
270     /* +inf */
271     test_ftoi utrunc.s, a2, f0, 0x7f800000, 0, 0xffffffff
273     /* NaN */
274     test_ftoi utrunc.s, a2, f0, 0x7f800001, 0, 0xffffffff
275     test_ftoi utrunc.s, a2, f0, 0x7fc00000, 0, 0xffffffff
276 test_end
278 test float_s
279     test_itof float.s, f0, a2, -1, 0, \
280         0xbf800000, 0xbf800000, 0xbf800000, 0xbf800000
281     test_itof float.s, f0, a2, 0, 0, 0, 0, 0, 0
282     test_itof float.s, f0, a2, 1, 1, \
283         0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000
284     test_itof float.s, f0, a2, 1, 0, \
285         0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000
286     test_itof float.s, f0, a2, 0x7fffffff, 0, \
287         0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff
288 test_end
290 test ufloat_s
291     test_itof ufloat.s, f0, a2, 0, 0, 0, 0, 0, 0
292     test_itof ufloat.s, f0, a2, 1, 1, \
293         0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000
294     test_itof ufloat.s, f0, a2, 1, 0, \
295         0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000
296     test_itof ufloat.s, f0, a2, 0x7fffffff, 0, \
297         0x4f000000, 0x4effffff, 0x4f000000, 0x4effffff
298     test_itof ufloat.s, f0, a2, 0xffffffff, 0, \
299         0x4f800000, 0x4f7fffff, 0x4f800000, 0x4f7fffff
300 test_end
302 #endif
304 test_suite_end