aboutsummaryrefslogtreecommitdiff
path: root/src/arch/neon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/neon.h')
-rw-r--r--src/arch/neon.h74
1 files changed, 37 insertions, 37 deletions
diff --git a/src/arch/neon.h b/src/arch/neon.h
index b6734b7..dee0eba 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -4,8 +4,8 @@
4#define _ep_neon vcombine_u8(vdupq_n_u8(0x0F), vdupq_n_u8(0x0F)) 4#define _ep_neon vcombine_u8(vdupq_n_u8(0x0F), vdupq_n_u8(0x0F))
5#define _eo_neon vcombine_u8(vdupq_n_u8(0x10), vdupq_n_u8(0x10)) 5#define _eo_neon vcombine_u8(vdupq_n_u8(0x10), vdupq_n_u8(0x10))
6 6
7_static_inline uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); 7STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t);
8_static_inline uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t); 8STATIC_INLINE uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t);
9 9
10// static cube 10// static cube
11#define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ 11#define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
@@ -26,7 +26,7 @@ _static_inline uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t);
26#define solved static_cube( \ 26#define solved static_cube( \
27 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) 27 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
28 28
29_static void 29STATIC void
30pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 30pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
31{ 31{
32 // First 8 bytes of the corner vector are copied from the c array 32 // First 8 bytes of the corner vector are copied from the c array
@@ -39,7 +39,7 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
39 vst1_lane_u32((uint32_t *)(e + 8), vreinterpret_u32_u8(vget_high_u8(cube->edge)), 0); 39 vst1_lane_u32((uint32_t *)(e + 8), vreinterpret_u32_u8(vget_high_u8(cube->edge)), 0);
40} 40}
41 41
42_static_inline bool 42STATIC_INLINE bool
43equal(cube_t c1, cube_t c2) 43equal(cube_t c1, cube_t c2)
44{ 44{
45 uint8x16_t cmp_corner, cmp_edge; 45 uint8x16_t cmp_corner, cmp_edge;
@@ -62,7 +62,7 @@ equal(cube_t c1, cube_t c2)
62 return vgetq_lane_u64(cmp_result, 0) == ~0ULL && vgetq_lane_u64(cmp_result, 1) == ~0ULL; 62 return vgetq_lane_u64(cmp_result, 0) == ~0ULL && vgetq_lane_u64(cmp_result, 1) == ~0ULL;
63} 63}
64 64
65_static_inline cube_t 65STATIC_INLINE cube_t
66invertco(cube_t c) 66invertco(cube_t c)
67{ 67{
68 cube_t ret; 68 cube_t ret;
@@ -80,7 +80,7 @@ invertco(cube_t c)
80 return ret; 80 return ret;
81} 81}
82 82
83_static_inline cube_t 83STATIC_INLINE cube_t
84compose_edges(cube_t c1, cube_t c2) 84compose_edges(cube_t c1, cube_t c2)
85{ 85{
86 cube_t ret = {0}; 86 cube_t ret = {0};
@@ -88,7 +88,7 @@ compose_edges(cube_t c1, cube_t c2)
88 return ret; 88 return ret;
89} 89}
90 90
91_static_inline cube_t 91STATIC_INLINE cube_t
92compose_corners(cube_t c1, cube_t c2) 92compose_corners(cube_t c1, cube_t c2)
93{ 93{
94 cube_t ret = {0}; 94 cube_t ret = {0};
@@ -96,12 +96,12 @@ compose_corners(cube_t c1, cube_t c2)
96 return ret; 96 return ret;
97} 97}
98 98
99_static_inline uint8x16_t 99STATIC_INLINE uint8x16_t
100compose_edges_slim(uint8x16_t edge1, uint8x16_t edge2) 100compose_edges_slim(uint8x16_t edge1, uint8x16_t edge2)
101{ 101{
102 // Masks 102 // Masks
103 uint8x16_t p_bits = vdupq_n_u8(_pbits); 103 uint8x16_t p_bits = vdupq_n_u8(PBITS);
104 uint8x16_t eo_bit = vdupq_n_u8(_eobit); 104 uint8x16_t eo_bit = vdupq_n_u8(EOBIT);
105 105
106 // Find the index and permutation 106 // Find the index and permutation
107 uint8x16_t p = vandq_u8(edge2, p_bits); 107 uint8x16_t p = vandq_u8(edge2, p_bits);
@@ -120,14 +120,14 @@ compose_edges_slim(uint8x16_t edge1, uint8x16_t edge2)
120 return ret; 120 return ret;
121} 121}
122 122
123_static_inline uint8x16_t 123STATIC_INLINE uint8x16_t
124compose_corners_slim(uint8x16_t corner1, uint8x16_t corner2) 124compose_corners_slim(uint8x16_t corner1, uint8x16_t corner2)
125{ 125{
126 // Masks 126 // Masks
127 uint8x16_t p_bits = vdupq_n_u8(_pbits); 127 uint8x16_t p_bits = vdupq_n_u8(PBITS);
128 uint8x16_t cobits = vdupq_n_u8(_cobits); 128 uint8x16_t cobits = vdupq_n_u8(COBITS);
129 uint8x16_t cobits2 = vdupq_n_u8(_cobits2); 129 uint8x16_t cobits2 = vdupq_n_u8(COBITS_2);
130 uint8x16_t twist_cw = vdupq_n_u8(_ctwist_cw); 130 uint8x16_t twist_cw = vdupq_n_u8(CTWIST_CW);
131 131
132 // Find the index and permutation 132 // Find the index and permutation
133 uint8x16_t p = vandq_u8(corner2, p_bits); 133 uint8x16_t p = vandq_u8(corner2, p_bits);
@@ -148,7 +148,7 @@ compose_corners_slim(uint8x16_t corner1, uint8x16_t corner2)
148 return ret; 148 return ret;
149} 149}
150 150
151_static_inline cube_t 151STATIC_INLINE cube_t
152compose(cube_t c1, cube_t c2) 152compose(cube_t c1, cube_t c2)
153{ 153{
154 cube_t ret = {0}; 154 cube_t ret = {0};
@@ -159,7 +159,7 @@ compose(cube_t c1, cube_t c2)
159 return ret; 159 return ret;
160} 160}
161 161
162_static_inline cube_t 162STATIC_INLINE cube_t
163inverse(cube_t cube) 163inverse(cube_t cube)
164{ 164{
165 uint8_t i, piece, orien; 165 uint8_t i, piece, orien;
@@ -180,16 +180,16 @@ inverse(cube_t cube)
180 for (i = 0; i < 12; i++) 180 for (i = 0; i < 12; i++)
181 { 181 {
182 piece = edges[i]; 182 piece = edges[i];
183 orien = piece & _eobit; 183 orien = piece & EOBIT;
184 edge_result[piece & _pbits] = i | orien; 184 edge_result[piece & PBITS] = i | orien;
185 } 185 }
186 186
187 // Process the corners 187 // Process the corners
188 for (i = 0; i < 8; i++) 188 for (i = 0; i < 8; i++)
189 { 189 {
190 piece = corners[i]; 190 piece = corners[i];
191 orien = ((piece << 1) | (piece >> 1)) & _cobits2; 191 orien = ((piece << 1) | (piece >> 1)) & COBITS_2;
192 corner_result[piece & _pbits] = i | orien; 192 corner_result[piece & PBITS] = i | orien;
193 } 193 }
194 194
195 // Copy the results back to the NEON vectors 195 // Copy the results back to the NEON vectors
@@ -199,7 +199,7 @@ inverse(cube_t cube)
199 return ret; 199 return ret;
200} 200}
201 201
202_static_inline int64_t 202STATIC_INLINE int64_t
203coord_co(cube_t c) 203coord_co(cube_t c)
204{ 204{
205 // Temp array to store the NEON vector 205 // Temp array to store the NEON vector
@@ -210,12 +210,12 @@ coord_co(cube_t c)
210 int64_t ret; 210 int64_t ret;
211 211
212 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) 212 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3)
213 ret += p * (mem[i] >> _coshift); 213 ret += p * (mem[i] >> COSHIFT);
214 214
215 return ret; 215 return ret;
216} 216}
217 217
218_static_inline int64_t 218STATIC_INLINE int64_t
219coord_csep(cube_t c) 219coord_csep(cube_t c)
220{ 220{
221 // Temp array to store the NEON vector 221 // Temp array to store the NEON vector
@@ -225,19 +225,19 @@ coord_csep(cube_t c)
225 int64_t ret = 0; 225 int64_t ret = 0;
226 int i, p; 226 int i, p;
227 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) 227 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2)
228 ret += p * ((mem[i] & _csepbit) >> 2); 228 ret += p * ((mem[i] & CSEPBIT) >> 2);
229 229
230 return ret; 230 return ret;
231 return 0; 231 return 0;
232} 232}
233 233
234_static_inline int64_t 234STATIC_INLINE int64_t
235coord_cocsep(cube_t c) 235coord_cocsep(cube_t c)
236{ 236{
237 return (coord_co(c) << 7) + coord_csep(c); 237 return (coord_co(c) << 7) + coord_csep(c);
238} 238}
239 239
240_static_inline int64_t 240STATIC_INLINE int64_t
241coord_eo(cube_t c) 241coord_eo(cube_t c)
242{ 242{
243 int64_t ret = 0; 243 int64_t ret = 0;
@@ -249,13 +249,13 @@ coord_eo(cube_t c)
249 249
250 for (int i = 1; i < 12; i++, p *= 2) 250 for (int i = 1; i < 12; i++, p *= 2)
251 { 251 {
252 ret += p * (mem[i] >> _eoshift); 252 ret += p * (mem[i] >> EOSHIFT);
253 } 253 }
254 254
255 return ret; 255 return ret;
256} 256}
257 257
258_static_inline int64_t 258STATIC_INLINE int64_t
259coord_esep(cube_t c) 259coord_esep(cube_t c)
260{ 260{
261 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 261 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
@@ -266,8 +266,8 @@ coord_esep(cube_t c)
266 266
267 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) 267 for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++)
268 { 268 {
269 bit1 = (mem[i] & _esepbit1) >> 2; 269 bit1 = (mem[i] & ESEPBIT_1) >> 2;
270 bit2 = (mem[i] & _esepbit2) >> 3; 270 bit2 = (mem[i] & ESEPBIT_2) >> 3;
271 is1 = (1 - bit2) * bit1; 271 is1 = (1 - bit2) * bit1;
272 272
273 ret1 += bit2 * binomial[11 - i][k]; 273 ret1 += bit2 * binomial[11 - i][k];
@@ -282,19 +282,19 @@ coord_esep(cube_t c)
282 return ret1 * 70 + ret2; 282 return ret1 * 70 + ret2;
283} 283}
284 284
285_static_inline void 285STATIC_INLINE void
286copy_corners(cube_t *dst, cube_t src) 286copy_corners(cube_t *dst, cube_t src)
287{ 287{
288 dst->corner = src.corner; 288 dst->corner = src.corner;
289} 289}
290 290
291_static_inline void 291STATIC_INLINE void
292copy_edges(cube_t *dst, cube_t src) 292copy_edges(cube_t *dst, cube_t src)
293{ 293{
294 dst->edge = src.edge; 294 dst->edge = src.edge;
295} 295}
296 296
297_static_inline void 297STATIC_INLINE void
298set_eo(cube_t *cube, int64_t eo) 298set_eo(cube_t *cube, int64_t eo)
299{ 299{
300 // Temp array to store the NEON vector 300 // Temp array to store the NEON vector
@@ -306,16 +306,16 @@ set_eo(cube_t *cube, int64_t eo)
306 { 306 {
307 flip = eo % 2; 307 flip = eo % 2;
308 sum += flip; 308 sum += flip;
309 mem[i] = (mem[i] & ~_eobit) | (_eobit * flip); 309 mem[i] = (mem[i] & ~EOBIT) | (EOBIT * flip);
310 } 310 }
311 mem[0] = (mem[0] & ~_eobit) | (_eobit * (sum % 2)); 311 mem[0] = (mem[0] & ~EOBIT) | (EOBIT * (sum % 2));
312 312
313 // Copy the results back to the NEON vector 313 // Copy the results back to the NEON vector
314 cube->edge = vld1q_u8(mem); 314 cube->edge = vld1q_u8(mem);
315 return; 315 return;
316} 316}
317 317
318_static_inline cube_t 318STATIC_INLINE cube_t
319invcoord_esep(int64_t esep) 319invcoord_esep(int64_t esep)
320{ 320{
321 cube_t ret; 321 cube_t ret;

Generated with cgit - Back to sebastiano.tronto.net