aboutsummaryrefslogtreecommitdiff
path: root/src/arch/neon.h
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-07-29 12:12:43 +0200
commitea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch)
treeaed484690d24c0c28c7695d4b5389f2e3c341b96 /src/arch/neon.h
parent52c21640508c3fc668107778ae027ff4428ebd89 (diff)
downloadnissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz
nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip
All coordinates unsigned
Diffstat (limited to 'src/arch/neon.h')
-rw-r--r--src/arch/neon.h59
1 files changed, 29 insertions, 30 deletions
diff --git a/src/arch/neon.h b/src/arch/neon.h
index a378cf9..fef6220 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -29,8 +29,8 @@ STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t);
29const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; 29const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7};
30const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; 30const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0};
31 31
32STATIC_INLINE int64_t permtoindex_8x8(uint8x8_t); 32STATIC_INLINE uint64_t permtoindex_8x8(uint8x8_t);
33STATIC_INLINE uint8x8_t indextoperm_8x8(int64_t); 33STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t);
34 34
35STATIC_INLINE int 35STATIC_INLINE int
36popcount_u32(uint32_t x) 36popcount_u32(uint32_t x)
@@ -215,16 +215,15 @@ inverse(cube_t cube)
215 return ret; 215 return ret;
216} 216}
217 217
218STATIC_INLINE int64_t 218STATIC_INLINE uint64_t
219coord_co(cube_t c) 219coord_co(cube_t c)
220{ 220{
221 uint64_t i, p, ret;
222
221 // Temp array to store the NEON vector 223 // Temp array to store the NEON vector
222 uint8_t mem[8]; 224 uint8_t mem[8];
223 vst1_u8(mem, c.corner); 225 vst1_u8(mem, c.corner);
224 226
225 int i, p;
226 int64_t ret;
227
228 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) 227 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3)
229 ret += p * (mem[i] >> COSHIFT); 228 ret += p * (mem[i] >> COSHIFT);
230 229
@@ -232,9 +231,9 @@ coord_co(cube_t c)
232} 231}
233 232
234STATIC_INLINE cube_t 233STATIC_INLINE cube_t
235invcoord_co(int64_t coord) 234invcoord_co(uint64_t coord)
236{ 235{
237 int64_t co, c, i, p; 236 uint64_t co, c, i, p;
238 uint8_t mem[8]; 237 uint8_t mem[8];
239 cube_t cube; 238 cube_t cube;
240 239
@@ -250,15 +249,15 @@ invcoord_co(int64_t coord)
250 return cube; 249 return cube;
251} 250}
252 251
253STATIC_INLINE int64_t 252STATIC_INLINE uint64_t
254coord_csep(cube_t c) 253coord_csep(cube_t c)
255{ 254{
255 uint64_t ret, i, p;
256
256 // Temp array to store the NEON vector 257 // Temp array to store the NEON vector
257 uint8_t mem[8]; 258 uint8_t mem[8];
258 vst1_u8(mem, c.corner); 259 vst1_u8(mem, c.corner);
259 260
260 int64_t ret = 0;
261 int i, p;
262 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) 261 for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2)
263 ret += p * ((mem[i] & CSEPBIT) >> 2); 262 ret += p * ((mem[i] & CSEPBIT) >> 2);
264 263
@@ -266,23 +265,23 @@ coord_csep(cube_t c)
266 return 0; 265 return 0;
267} 266}
268 267
269STATIC_INLINE int64_t 268STATIC_INLINE uint64_t
270coord_cocsep(cube_t c) 269coord_cocsep(cube_t c)
271{ 270{
272 return (coord_co(c) << 7) + coord_csep(c); 271 return (coord_co(c) << UINT64_C(7)) + coord_csep(c);
273} 272}
274 273
275STATIC_INLINE int64_t 274STATIC_INLINE uint64_t
276coord_eo(cube_t c) 275coord_eo(cube_t c)
277{ 276{
278 int64_t ret = 0; 277 uint64_t ret, p;
279 int64_t p = 1; 278 int i;
280 279
281 // Temp array to store the NEON vector 280 // Temp array to store the NEON vector
282 uint8_t mem[16]; 281 uint8_t mem[16];
283 vst1q_u8(mem, c.edge); 282 vst1q_u8(mem, c.edge);
284 283
285 for (int i = 1; i < 12; i++, p *= 2) 284 for (i = 1, ret = 0, p = 1; i < 12; i++, p *= 2)
286 { 285 {
287 ret += p * (mem[i] >> EOSHIFT); 286 ret += p * (mem[i] >> EOSHIFT);
288 } 287 }
@@ -290,10 +289,10 @@ coord_eo(cube_t c)
290 return ret; 289 return ret;
291} 290}
292 291
293STATIC_INLINE int64_t 292STATIC_INLINE uint64_t
294coord_esep(cube_t c) 293coord_esep(cube_t c)
295{ 294{
296 int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; 295 uint64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1;
297 296
298 // Temp array to store the NEON vector 297 // Temp array to store the NEON vector
299 uint8_t mem[16]; 298 uint8_t mem[16];
@@ -330,7 +329,7 @@ copy_edges(cube_t dst[static 1], cube_t src)
330} 329}
331 330
332STATIC_INLINE void 331STATIC_INLINE void
333set_eo(cube_t cube[static 1], int64_t eo) 332set_eo(cube_t cube[static 1], uint64_t eo)
334{ 333{
335 // Temp array to store the NEON vector 334 // Temp array to store the NEON vector
336 uint8_t mem[16]; 335 uint8_t mem[16];
@@ -351,12 +350,12 @@ set_eo(cube_t cube[static 1], int64_t eo)
351} 350}
352 351
353STATIC_INLINE cube_t 352STATIC_INLINE cube_t
354invcoord_esep(int64_t esep) 353invcoord_esep(uint64_t esep)
355{ 354{
356 cube_t ret; 355 cube_t ret;
357 uint8_t mem[16] = {0}; 356 uint8_t mem[16] = {0};
358 357
359 invcoord_esep_array(esep % 70, esep / 70, mem); 358 invcoord_esep_array(esep % UINT64_C(70), esep / UINT64_C(70), mem);
360 359
361 ret = SOLVED_CUBE; 360 ret = SOLVED_CUBE;
362 ret.edge = vld1q_u8(mem); 361 ret.edge = vld1q_u8(mem);
@@ -364,10 +363,10 @@ invcoord_esep(int64_t esep)
364 return ret; 363 return ret;
365} 364}
366 365
367STATIC_INLINE int64_t 366STATIC_INLINE uint64_t
368permtoindex_8x8(uint8x8_t a) 367permtoindex_8x8(uint8x8_t a)
369{ 368{
370 int64_t i, c, ret; 369 uint64_t i, c, ret;
371 uint8x8_t cmp; 370 uint8x8_t cmp;
372 uint64x1_t anum; 371 uint64x1_t anum;
373 uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; 372 uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F};
@@ -387,10 +386,10 @@ permtoindex_8x8(uint8x8_t a)
387} 386}
388 387
389STATIC_INLINE uint8x8_t 388STATIC_INLINE uint8x8_t
390indextoperm_8x8(int64_t p) 389indextoperm_8x8(uint64_t p)
391{ 390{
392 int used; 391 int used;
393 int64_t c, k, i, j; 392 uint64_t c, k, i, j;
394 uint8_t ret[8]; 393 uint8_t ret[8];
395 394
396 for (i = 0, used = 0; i < 8; i++) { 395 for (i = 0, used = 0; i < 8; i++) {
@@ -408,14 +407,14 @@ indextoperm_8x8(int64_t p)
408 return vld1_u8(ret); 407 return vld1_u8(ret);
409} 408}
410 409
411STATIC_INLINE int64_t 410STATIC_INLINE uint64_t
412coord_cp(cube_t cube) 411coord_cp(cube_t cube)
413{ 412{
414 return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON)); 413 return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON));
415} 414}
416 415
417STATIC_INLINE cube_t 416STATIC_INLINE cube_t
418invcoord_cp(int64_t i) 417invcoord_cp(uint64_t i)
419{ 418{
420 return (cube_t) { 419 return (cube_t) {
421 .corner = indextoperm_8x8(i), 420 .corner = indextoperm_8x8(i),
@@ -423,14 +422,14 @@ invcoord_cp(int64_t i)
423 }; 422 };
424} 423}
425 424
426STATIC_INLINE int64_t 425STATIC_INLINE uint64_t
427coord_epud(cube_t cube) 426coord_epud(cube_t cube)
428{ 427{
429 return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON)); 428 return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON));
430} 429}
431 430
432STATIC_INLINE cube_t 431STATIC_INLINE cube_t
433invcoord_epud(int64_t i) 432invcoord_epud(uint64_t i)
434{ 433{
435 return (cube_t) { 434 return (cube_t) {
436 .corner = vld1_u8(SOLVED_L), 435 .corner = vld1_u8(SOLVED_L),

Generated with cgit - Back to sebastiano.tronto.net