diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-07-29 12:12:43 +0200 |
| commit | ea0387796a349c91032fbcb10f50c6ad8607b0f6 (patch) | |
| tree | aed484690d24c0c28c7695d4b5389f2e3c341b96 /src/arch/neon.h | |
| parent | 52c21640508c3fc668107778ae027ff4428ebd89 (diff) | |
| download | nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.tar.gz nissy-core-ea0387796a349c91032fbcb10f50c6ad8607b0f6.zip | |
All coordinates unsigned
Diffstat (limited to 'src/arch/neon.h')
| -rw-r--r-- | src/arch/neon.h | 59 |
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); | |||
| 29 | const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; | 29 | const uint8_t SOLVED_L[8] = {0, 1, 2, 3, 4, 5, 6, 7}; |
| 30 | const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; | 30 | const uint8_t SOLVED_H[8] = {8, 9, 10, 11, 0, 0, 0}; |
| 31 | 31 | ||
| 32 | STATIC_INLINE int64_t permtoindex_8x8(uint8x8_t); | 32 | STATIC_INLINE uint64_t permtoindex_8x8(uint8x8_t); |
| 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(int64_t); | 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t); |
| 34 | 34 | ||
| 35 | STATIC_INLINE int | 35 | STATIC_INLINE int |
| 36 | popcount_u32(uint32_t x) | 36 | popcount_u32(uint32_t x) |
| @@ -215,16 +215,15 @@ inverse(cube_t cube) | |||
| 215 | return ret; | 215 | return ret; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | STATIC_INLINE int64_t | 218 | STATIC_INLINE uint64_t |
| 219 | coord_co(cube_t c) | 219 | coord_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 | ||
| 234 | STATIC_INLINE cube_t | 233 | STATIC_INLINE cube_t |
| 235 | invcoord_co(int64_t coord) | 234 | invcoord_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 | ||
| 253 | STATIC_INLINE int64_t | 252 | STATIC_INLINE uint64_t |
| 254 | coord_csep(cube_t c) | 253 | coord_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 | ||
| 269 | STATIC_INLINE int64_t | 268 | STATIC_INLINE uint64_t |
| 270 | coord_cocsep(cube_t c) | 269 | coord_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 | ||
| 275 | STATIC_INLINE int64_t | 274 | STATIC_INLINE uint64_t |
| 276 | coord_eo(cube_t c) | 275 | coord_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 | ||
| 293 | STATIC_INLINE int64_t | 292 | STATIC_INLINE uint64_t |
| 294 | coord_esep(cube_t c) | 293 | coord_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 | ||
| 332 | STATIC_INLINE void | 331 | STATIC_INLINE void |
| 333 | set_eo(cube_t cube[static 1], int64_t eo) | 332 | set_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 | ||
| 353 | STATIC_INLINE cube_t | 352 | STATIC_INLINE cube_t |
| 354 | invcoord_esep(int64_t esep) | 353 | invcoord_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 | ||
| 367 | STATIC_INLINE int64_t | 366 | STATIC_INLINE uint64_t |
| 368 | permtoindex_8x8(uint8x8_t a) | 367 | permtoindex_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 | ||
| 389 | STATIC_INLINE uint8x8_t | 388 | STATIC_INLINE uint8x8_t |
| 390 | indextoperm_8x8(int64_t p) | 389 | indextoperm_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 | ||
| 411 | STATIC_INLINE int64_t | 410 | STATIC_INLINE uint64_t |
| 412 | coord_cp(cube_t cube) | 411 | coord_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 | ||
| 417 | STATIC_INLINE cube_t | 416 | STATIC_INLINE cube_t |
| 418 | invcoord_cp(int64_t i) | 417 | invcoord_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 | ||
| 426 | STATIC_INLINE int64_t | 425 | STATIC_INLINE uint64_t |
| 427 | coord_epud(cube_t cube) | 426 | coord_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 | ||
| 432 | STATIC_INLINE cube_t | 431 | STATIC_INLINE cube_t |
| 433 | invcoord_epud(int64_t i) | 432 | invcoord_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), |
