add a thp-based huge page alloc fallback
[pcsx_rearmed.git] / deps / lightning / check / carry.tst
1
2 #define ix0             0
3 #define lx0             0
4 #define ix1             1
5 #define lx1             1
6 #define ix2             2
7 #define lx2             2
8 #define ix4             4
9 #define lx4             4
10 #if __WORDSIZE == 32
11 #  define ix7fe         0x7ffffffe
12 #  define ix7f          0x7fffffff
13 #  define ix80          0x80000000
14 #  define iff           0xffffffff
15 #  define ife           0xfffffffe
16 #  define ifd           0xfffffffd
17 #  define ifc           0xfffffffc
18 #else
19 #  define ix7fe         0x7ffffffffffffffe
20 #  define ix7f          0x7fffffffffffffff
21 #  define ix80          0x8000000000000000
22 #  define iff           0xffffffffffffffff
23 #  define ife           0xfffffffffffffffe
24 #  define ifd           0xfffffffffffffffd
25 #  define ifc           0xfffffffffffffffc
26 #endif
27
28 /* check jumps are taken and result value is correct */
29 #define bopr_t(l, u, op, r0, r1, il, ir, iv)                    \
30         movi %r0 il                                             \
31         movi %r1 ir                                             \
32         b##op##r##u op##u##r##l##r0##r1 %r0 %r1                 \
33         /* validate did jump */                                 \
34         movi %r0 0x5a5a5a5a                                     \
35 op##u##r##l##r0##r1:                                            \
36         beqi op##u##r##l##ok##r0##r1 %r0 iv                     \
37         calli @abort                                            \
38 op##u##r##l##ok##r0##r1:
39 #define bopi_t(l, u, op, r0, il, ir, iv)                        \
40         movi %r0 il                                             \
41         b##op##i##u op##u##i##l##r0##r1 %r0 ir                  \
42         /* validate did jump */                                 \
43         movi %r0 0x5a5a5a5a                                     \
44 op##u##i##l##r0##r1:                                            \
45         beqi op##u##i##l##ok##r0##r1 %r0 iv                     \
46         calli @abort                                            \
47 op##u##i##l##ok##r0##r1:
48 #define bopr_f(l, u, op, r0, r1, il, ir, iv)                    \
49         movi %r0 il                                             \
50         movi %r1 ir                                             \
51         b##op##r##u op##u##r##l##r0##r1 %r0 %r1                 \
52         beqi op##u##r##l##ok##r0##r1 %r0 iv                     \
53 op##u##r##l##r0##r1:                                            \
54         calli @abort                                            \
55 op##u##r##l##ok##r0##r1:
56 #define bopi_f(l, u, op, r0, il, ir, iv)                        \
57         movi %r0 il                                             \
58         b##op##i##u op##u##i##l##r0##r1 %r0 ir                  \
59         beqi op##u##i##l##ok##r0##r1 %r0 iv                     \
60 op##u##i##l##r0##r1:                                            \
61         calli @abort                                            \
62 op##u##i##l##ok##r0##r1:
63 #define ccop(cc, l, u, op, r0, r1, il, ir, iv)                  \
64         bopr##cc(l, u, op, r0, r1, i##il, i##ir, i##iv)         \
65         bopi##cc(l, u, op, r0, i##il, i##ir, i##iv)
66 #define tadd(l, u, r0, r1, il, ir, iv)                          \
67         ccop(_t, l, u, oadd, r0, r1, il, ir, iv)                \
68         ccop(_f, l, u, xadd, r0, r1, il, ir, iv)
69 #define fadd(l, u, r0, r1, il, ir, iv)                          \
70         ccop(_f, l, u, oadd, r0, r1, il, ir, iv)                \
71         ccop(_t, l, u, xadd, r0, r1, il, ir, iv)
72 #define tsub(l, u, r0, r1, il, ir, iv)                          \
73         ccop(_t, l, u, osub, r0, r1, il, ir, iv)                \
74         ccop(_f, l, u, xsub, r0, r1, il, ir, iv)
75 #define fsub(l, u, r0, r1, il, ir, iv)                          \
76         ccop(_f, l, u, osub, r0, r1, il, ir, iv)                \
77         ccop(_t, l, u, xsub, r0, r1, il, ir, iv)
78
79 #define xopr6(l,op,r0,r1,r2,r3,r4,r5,llo,lhi,rlo,rhi,vlo,vhi)   \
80         movi %r1 llo                                            \
81         movi %r2 lhi                                            \
82         movi %r4 rlo                                            \
83         movi %r5 rhi                                            \
84         op##cr %r0 %r1 %r4                                      \
85         op##xr %r3 %r2 %r5                                      \
86         beqi op##l##L##r0##r1##r2##r3##r4##r5 %r0 vlo           \
87         calli @abort                                            \
88 op##l##L##r0##r1##r2##r3##r4##r5:                               \
89         beqi op##l##H##r0##r1##r2##r3##r4##r5 %r3 vhi           \
90         calli @abort                                            \
91 op##l##H##r0##r1##r2##r3##r4##r5:
92 #define xopr4_(l,op,r0,r1,r2,r3,llo,lhi,rlo,rhi,vlo,vhi)        \
93         movi %r0 llo                                            \
94         movi %r1 lhi                                            \
95         movi %r2 rlo                                            \
96         movi %r3 rhi                                            \
97         op##cr %r0 %r0 %r2                                      \
98         op##xr %r1 %r1 %r3                                      \
99         beqi op##l##L_##r0##r1##r2##r3 %r0 vlo                  \
100         calli @abort                                            \
101 op##l##L_##r0##r1##r2##r3:                                      \
102         beqi op##l##H_##r0##r1##r2##r3 %r1 vhi                  \
103         calli @abort                                            \
104 op##l##H_##r0##r1##r2##r3:
105 #define xopr_4(l,op,r0,r1,r2,r3,llo,lhi,rlo,rhi,vlo,vhi)        \
106         movi %r0 rlo                                            \
107         movi %r1 rhi                                            \
108         movi %r2 llo                                            \
109         movi %r3 lhi                                            \
110         op##cr %r0 %r2 %r0                                      \
111         op##xr %r1 %r3 %r1                                      \
112         beqi op##l##_L##r0##r1##r2##r3 %r0 vlo                  \
113         calli @abort                                            \
114 op##l##_L##r0##r1##r2##r3:                                      \
115         beqi op##l##_H##r0##r1##r2##r3 %r1 vhi                  \
116         calli @abort                                            \
117 op##l##_H##r0##r1##r2##r3:
118
119 #define xaddr(l,llo,lhi,rlo,rhi,vlo,vhi)                                                \
120         xopr6(l,add,r0,r1,r2,v0,v1,v2,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)        \
121         xopr4_(l,add,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)             \
122         xopr_4(l,add,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)
123 #define xsubr(l,llo,lhi,rlo,rhi,vlo,vhi)                                                \
124         xopr6(l,sub,r0,r1,r2,v0,v1,v2,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)        \
125         xopr4_(l,sub,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)             \
126         xopr_4(l,sub,r0,r1,r2,v0,i##llo,i##lhi,i##rlo,i##rhi,i##vlo,i##vhi)
127
128 .data   16
129 ok:
130 .c      "ok\n"
131
132 .code
133         prolog
134
135         tadd(__LINE__,   , r0, r1, x7f,  x1, x80)
136         fadd(__LINE__,   , r0, r1, x7fe, x1, x7f)
137         tsub(__LINE__,   , r0, r1, x80,  x1, x7f)
138         fsub(__LINE__,   , r0, r1, x7f,  x1, x7fe)
139         tadd(__LINE__, _u, r0, r1, ff,   x1, x0)
140         fadd(__LINE__, _u, r0, r1, x7f,  x1, x80)
141         tsub(__LINE__, _u, r0, r1, x0,   x1, ff)
142         fsub(__LINE__, _u, r0, r1, x80,  x1, x7f)
143
144         /* 0xffffffffffffffff + 1 = 0x10000000000000000 */
145         xaddr(__LINE__, ff, ff, x1, x0, x0, x0)
146
147         /* 1 + 0xffffffffffffffff = 0x10000000000000000 */
148         xaddr(__LINE__, x1, x0, ff, ff, x0, x0)
149
150         /* 0xfffffffeffffffff + 1 = 0xffffffff00000000 */
151         xaddr(__LINE__, ff, fe, x1, x0, x0, ff)
152
153         /* 1 + 0xfffffffeffffffff = 0xffffffff00000000 */
154         xaddr(__LINE__, x1, x0, ff, fe, x0, ff)
155
156         /* 0xfffffffefffffffe + 2 = 0xffffffff00000000 */
157         xaddr(__LINE__, fe, fe, x2, x0, x0, ff)
158
159         /* 2 + 0xfffffffefffffffe = 0xffffffff00000000 */
160         xaddr(__LINE__, x2, x0, fe, fe, x0, ff)
161
162         /* 0xffffffffffffffff - 1 = 0xfffffffffffffffe */
163         xsubr(__LINE__, ff, ff, x1, x0, fe, ff)
164
165         /* 1 - 0xffffffffffffffff = -0xfffffffffffffffe */
166         xsubr(__LINE__, x1, x0, ff, ff, x2, x0)
167
168         /* 0xfffffffeffffffff - 1 = 0xfffffffefffffffe */
169         xsubr(__LINE__, ff, fe, x1, x0, fe, fe)
170
171         /* 1 - 0xfffffffeffffffff = -0xfffffffefffffffe */
172         xsubr(__LINE__, x1, x0, ff, fe, x2, x1)
173
174         /* 0xfffffffefffffffe - 2 = 0xfffffffefffffffc */
175         xsubr(__LINE__, fe, fe, x2, x0, fc, fe)
176
177         /* 2 + 0xfffffffefffffffe = -0xfffffffefffffffc */
178         xsubr(__LINE__, x2, x0, fe, fe, x4, x1)
179
180         prepare
181                 pushargi ok
182                 ellipsis
183         finishi @printf
184
185         ret
186         epilog