gpu_neon: fix some missing ebuf updates
[pcsx_rearmed.git] / deps / lightning / check / rbit.tst
CommitLineData
ba86ff93
PC
1.data 4096
2swap_tab:
3.c 0 128 64 192 32 160 96 224 16 144 80 208 48 176 112 240 8 136 72 200 40 168 104 232 24 152 88 216 56 184 120 248 4 132 68 196 36 164 100 228 20 148 84 212 52 180 116 244 12 140 76 204 44 172 108 236 28 156 92 220 60 188 124 252 2 130 66 194 34 162 98 226 18 146 82 210 50 178 114 242 10 138 74 202 42 170 106 234 26 154 90 218 58 186 122 250 6 134 70 198 38 166 102 230 22 150 86 214 54 182 118 246 14 142 78 206 46 174 110 238 30 158 94 222 62 190 126 254 1 129 65 193 33 161 97 225 17 145 81 209 49 177 113 241 9 137 73 201 41 169 105 233 25 153 89 217 57 185 121 249 5 133 69 197 37 165 101 229 21 149 85 213 53 181 117 245 13 141 77 205 45 173 109 237 29 157 93 221 61 189 125 253 3 131 67 195 35 163 99 227 19 147 83 211 51 179 115 243 11 139 75 203 43 171 107 235 27 155 91 219 59 187 123 251 7 135 71 199 39 167 103 231 23 151 87 215 55 183 119 247 15 143 79 207 47 175 111 239 31 159 95 223 63 191 127 255
4ok:
5.c "ok\n"
6fmt:
7#if __WORDSIZE == 32
8.c "0x%08lx = 0x%08lx\n"
9#else
10.c "0x%016lx = 0x%016lx\n"
11#endif
12
13#define BIT2(OP, ARG, RES, R0, R1) \
14 movi %R1 ARG \
15 OP##r %R0 %R1 \
16 beqi OP##R0##R1##ARG %R0 RES \
17 calli @abort \
18OP##R0##R1##ARG:
19
20#define BIT1(OP, ARG, RES, V0, V1, V2, R0, R1, R2) \
21 BIT2(OP, ARG, RES, V0, V0) \
22 BIT2(OP, ARG, RES, V0, V1) \
23 BIT2(OP, ARG, RES, V0, V2) \
24 BIT2(OP, ARG, RES, V0, R0) \
25 BIT2(OP, ARG, RES, V0, R1) \
26 BIT2(OP, ARG, RES, V0, R2)
27
28#define BIT(OP, ARG, RES, V0, V1, V2, R0, R1, R2) \
29 BIT1(OP, ARG, RES, V1, V2, R0, R1, R2, V0) \
30 BIT1(OP, ARG, RES, V2, R0, R1, R2, V0, V1) \
31 BIT1(OP, ARG, RES, R0, R1, R2, V0, V1, V2) \
32 BIT1(OP, ARG, RES, R1, R2, V0, V1, V2, R0) \
33 BIT1(OP, ARG, RES, R2, V0, V1, V2, R0, R1)
34
35#define RBIT(ARG, RES) \
36 BIT(rbit, ARG, RES, v0, v1, v2, r0, r1, r2)
37
38.code
39 jmpi main
40 name rbit_table
41rbit_table:
42 prolog
43 arg $in
44 getarg %r1 $in
45 extr_uc %r2 %r1
46 movi %v0 swap_tab
47 ldxr_uc %r0 %v0 %r2
48 movi %v1 8
49rbit_table_loop:
50 rshr %r2 %r1 %v1
51 extr_uc %r2 %r2
52 lshi %r0 %r0 8
53 ldxr_uc %r2 %v0 %r2
54 orr %r0 %r0 %r2
55 addi %v1 %v1 8
56 blti rbit_table_loop %v1 __WORDSIZE
57 retr %r0
58 epilog
59
60 name rbit_unrolled
61rbit_unrolled:
62 prolog
63 arg $in
64 getarg %r0 $in
65#if __WORDSIZE == 32
66 movi %r1 0x55555555
67#else
68 movi %r1 0x5555555555555555
69#endif
70 rshi_u %r2 %r0 1 // r2 = r0 >> 1
71 andr %r2 %r2 %r1 // r2 &= r1
72 andr %v0 %r0 %r1 // v0 = r0 & r1
73 lshi %v0 %v0 1 // v0 <<= 1
74 orr %r0 %r2 %v0 // r0 = r2 | v0
75#if __WORDSIZE == 32
76 movi %r1 0x33333333
77#else
78 movi %r1 0x3333333333333333
79#endif
80 rshi_u %r2 %r0 2 // r2 = r0 >> 2
81 andr %r2 %r2 %r1 // r2 &= r1
82 andr %v0 %r0 %r1 // v0 = r0 & r1
83 lshi %v0 %v0 2 // v0 <<= 2
84 orr %r0 %r2 %v0 // r0 = r2 | v0
85#if __WORDSIZE == 32
86 movi %r1 0x0f0f0f0f
87#else
88 movi %r1 0x0f0f0f0f0f0f0f0f
89#endif
90 rshi_u %r2 %r0 4 // r2 = r0 >> 4
91 andr %r2 %r2 %r1 // r2 &= r1
92 andr %v0 %r0 %r1 // v0 = r0 & r1
93 lshi %v0 %v0 4 // v0 <<= 4
94 orr %r0 %r2 %v0 // r0 = r2 | v0
95#if __WORDSIZE == 32
96 movi %r1 0x00ff00ff
97#else
98 movi %r1 0x00ff00ff00ff00ff
99#endif
100 rshi_u %r2 %r0 8 // r2 = r0 >> 8
101 andr %r2 %r2 %r1 // r2 &= r1
102 andr %v0 %r0 %r1 // v0 = r0 & r1
103 lshi %v0 %v0 8 // v0 <<= 8
104 orr %r0 %r2 %v0 // r0 = r2 | v0
105#if __WORDSIZE == 32
106 rshi_u %r2 %r0 16 // r2 = r0 >> 16
107 lshi %v0 %r0 16 // v0 = r0 << 16
108 orr %r0 %r2 %v0 // r0 = r2 | v0
109#else
110 movi %r1 0x0000ffff0000ffff
111 rshi_u %r2 %r0 16 // r2 = r0 >> 16
112 andr %r2 %r2 %r1 // r2 &= r1
113 andr %v0 %r0 %r1 // v0 = r0 & r1
114 lshi %v0 %v0 16 // v0 <<= 16
115 orr %r0 %r2 %v0 // r0 = r2 | v0
116 rshi_u %r2 %r0 32 // r2 = r0 >> 32
117 lshi %v0 %r0 32 // v0 = r0 << 32
118 orr %r0 %r2 %v0 // r0 = r2 | v0
119#endif
120 retr %r0
121 epilog
122
123 name rbit_loop
124rbit_loop:
125 prolog
126 arg $in
127 getarg %r0 $in
128 movi %r1 __WORDSIZE
129 movi %r2 $(~0)
130rbit_loop_loop: // while (%r1 >>= 1) > 0
131 rshi %r1 %r1 1 // %r1 >>= 1
132 blei rbit_loop_done %r1 0 // no loop if %r1 <= 0
133 lshr %v0 %r2 %r1 // %v0 = %r2 << %r1
134 xorr %r2 %r2 %v0 // %r2 ^= %v0
135 rshr %v0 %r0 %r1 // %v0 = %r0 >> %r1
136 andr %v0 %v0 %r2 // %r2 = %v0 & %r2
137 lshr %v1 %r0 %r1 // %v1 = %r0 << %r1
138 comr %r0 %r2 // %r0 = ~%r2
139 andr %v1 %r0 %v1 // %v1 &= %r0
140 orr %r0 %v0 %v1 // %r0 = %v0 | %v1
141 jmpi rbit_loop_loop
142rbit_loop_done:
143 retr %r0
144 epilog
145
146#if 0
147 name main
148main:
149 prolog
150 arg $argc
151 arg $argv
152 getarg %r0 $argc
153 bnei default %r0 2
154 getarg %v0 $argv
155 ldxi %r0 %v0 $(__WORDSIZE >> 3)
156 prepare
157 pushargr %r0
158 pushargi 0
159 pushargi 0
160 finishi @strtoul
161 retval %v0
162 jmpi main_do
163default:
164#if __WORDSIZE == 32
165 movi %v0 0x8a13c851
166#else
167 movi %v0 0x984a137ffec85219
168#endif
169main_do:
170 prepare
171 pushargr %v0
172 finishi rbit_table
173 retval %r0
174 prepare
175 pushargi fmt
176 ellipsis
177 pushargr %v0
178 pushargr %r0
179 finishi @printf
180
181 prepare
182 pushargr %v0
183 finishi rbit_unrolled
184 retval %r0
185 prepare
186 pushargi fmt
187 ellipsis
188 pushargr %v0
189 pushargr %r0
190 finishi @printf
191
192 prepare
193 pushargr %v0
194 finishi rbit_loop
195 retval %r0
196 prepare
197 pushargi fmt
198 ellipsis
199 pushargr %v0
200 pushargr %r0
201 finishi @printf
202
203 rbitr %r0 %v0
204 prepare
205 pushargi fmt
206 ellipsis
207 pushargr %v0
208 pushargr %r0
209 finishi @printf
210
211 ret
212 epilog
213#else
214
215 name main
216main:
217 prolog
218#if __WORDSIZE == 32
219 RBIT(0x8a13c851, 0x8a13c851)
220 RBIT(0x12345678, 0x1e6a2c48)
221 RBIT(0x02468ace, 0x73516240)
222#else
223 RBIT(0x984a137ffec85219, 0x984a137ffec85219)
224 RBIT(0x123456789abcdef0, 0x0f7b3d591e6a2c48)
225 RBIT(0x02468ace013579bd, 0xbd9eac8073516240)
226#endif
227 prepare
228 pushargi ok
229 finishi @printf
230 reti 0
231 epilog
232#endif