diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-01 16:52:44 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-08-01 16:52:44 +0200 |
| commit | 1bd4691d9cc46ec75adbe899b289a1ebc5460721 (patch) | |
| tree | ea71166e05d399e57a13d6e3d7d96d4737f8f7bd /src/arch/neon.h | |
| parent | 0844b0ecd00bd6d68a7bafaeae0ee3d420db8ff6 (diff) | |
| download | nissy-core-1bd4691d9cc46ec75adbe899b289a1ebc5460721.tar.gz nissy-core-1bd4691d9cc46ec75adbe899b289a1ebc5460721.zip | |
Added CPEPE coordinate in preparation of full DRFIN solver
Diffstat (limited to 'src/arch/neon.h')
| -rw-r--r-- | src/arch/neon.h | 79 |
1 files changed, 72 insertions, 7 deletions
diff --git a/src/arch/neon.h b/src/arch/neon.h index fef6220..5723b60 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | #define CO2_NEON vdup_n_u8(0x60) | 1 | #define CO2_NEON vdup_n_u8(0x60) |
| 2 | #define COCW_NEON vdup_n_u8(0x20) | 2 | #define COCW_NEON vdup_n_u8(0x20) |
| 3 | #define PBITS8_NEON vdup_n_u8(0x07) | 3 | #define PBITS8_NEON vdup_n_u8(PBITS) |
| 4 | 4 | ||
| 5 | STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); | 5 | STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); |
| 6 | STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t); | 6 | STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t); |
| @@ -29,8 +29,9 @@ 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 uint64_t permtoindex_8x8(uint8x8_t); | 32 | STATIC_INLINE uint64_t permtoindex_Nx8(uint64_t, uint8x8_t); |
| 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t); | 33 | STATIC_INLINE uint8x8_t indextoperm_8x8(uint64_t); |
| 34 | STATIC_INLINE uint8x8_t indextoperm_4x8(uint64_t); | ||
| 34 | 35 | ||
| 35 | STATIC_INLINE int | 36 | STATIC_INLINE int |
| 36 | popcount_u32(uint32_t x) | 37 | popcount_u32(uint32_t x) |
| @@ -364,14 +365,14 @@ invcoord_esep(uint64_t esep) | |||
| 364 | } | 365 | } |
| 365 | 366 | ||
| 366 | STATIC_INLINE uint64_t | 367 | STATIC_INLINE uint64_t |
| 367 | permtoindex_8x8(uint8x8_t a) | 368 | permtoindex_Nx8(uint64_t n, uint8x8_t a) |
| 368 | { | 369 | { |
| 369 | uint64_t i, c, ret; | 370 | uint64_t i, c, ret; |
| 370 | uint8x8_t cmp; | 371 | uint8x8_t cmp; |
| 371 | uint64x1_t anum; | 372 | uint64x1_t anum; |
| 372 | uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; | 373 | uint8_t or[8] = {0, 0, 0, 0, 0, 0, 0, 0x0F}; |
| 373 | 374 | ||
| 374 | for (i = 0, ret = 0; i < 8; i++) { | 375 | for (i = 0, ret = 0; i < n; i++) { |
| 375 | cmp = vdup_lane_u8(a, 0); | 376 | cmp = vdup_lane_u8(a, 0); |
| 376 | anum = vreinterpret_u64_u8(a); | 377 | anum = vreinterpret_u64_u8(a); |
| 377 | anum = vshr_n_u64(anum, 8); | 378 | anum = vshr_n_u64(anum, 8); |
| @@ -379,7 +380,7 @@ permtoindex_8x8(uint8x8_t a) | |||
| 379 | a = vorr_u8(a, vld1_u8(or)); | 380 | a = vorr_u8(a, vld1_u8(or)); |
| 380 | cmp = vcgt_u8(cmp, a); | 381 | cmp = vcgt_u8(cmp, a); |
| 381 | c = vaddv_u8(vshr_n_u8(cmp, 7)); | 382 | c = vaddv_u8(vshr_n_u8(cmp, 7)); |
| 382 | ret += c * factorial[7-i]; | 383 | ret += c * factorial[n-1-i]; |
| 383 | } | 384 | } |
| 384 | 385 | ||
| 385 | return ret; | 386 | return ret; |
| @@ -407,10 +408,43 @@ indextoperm_8x8(uint64_t p) | |||
| 407 | return vld1_u8(ret); | 408 | return vld1_u8(ret); |
| 408 | } | 409 | } |
| 409 | 410 | ||
| 411 | STATIC_INLINE uint8x8_t | ||
| 412 | indextoperm_4x8(uint64_t p) | ||
| 413 | { | ||
| 414 | static const int64_t A[FACT_4] = { | ||
| 415 | [0] = UINT64_C(0x03020100), | ||
| 416 | [1] = UINT64_C(0x02030100), | ||
| 417 | [2] = UINT64_C(0x03010200), | ||
| 418 | [3] = UINT64_C(0x01030200), | ||
| 419 | [4] = UINT64_C(0x02010300), | ||
| 420 | [5] = UINT64_C(0x01020300), | ||
| 421 | [6] = UINT64_C(0x03020001), | ||
| 422 | [7] = UINT64_C(0x02030001), | ||
| 423 | [8] = UINT64_C(0x03000201), | ||
| 424 | [9] = UINT64_C(0x00030201), | ||
| 425 | [10] = UINT64_C(0x02000301), | ||
| 426 | [11] = UINT64_C(0x00020301), | ||
| 427 | [12] = UINT64_C(0x03010002), | ||
| 428 | [13] = UINT64_C(0x01030002), | ||
| 429 | [14] = UINT64_C(0x03000102), | ||
| 430 | [15] = UINT64_C(0x00030102), | ||
| 431 | [16] = UINT64_C(0x01000302), | ||
| 432 | [17] = UINT64_C(0x00010302), | ||
| 433 | [18] = UINT64_C(0x02010003), | ||
| 434 | [19] = UINT64_C(0x01020003), | ||
| 435 | [20] = UINT64_C(0x02000103), | ||
| 436 | [21] = UINT64_C(0x00020103), | ||
| 437 | [22] = UINT64_C(0x01000203), | ||
| 438 | [23] = UINT64_C(0x00010203), | ||
| 439 | }; | ||
| 440 | |||
| 441 | return vreinterpret_u8_u64(vdup_n_u64(A[p])); | ||
| 442 | } | ||
| 443 | |||
| 410 | STATIC_INLINE uint64_t | 444 | STATIC_INLINE uint64_t |
| 411 | coord_cp(cube_t cube) | 445 | coord_cp(cube_t cube) |
| 412 | { | 446 | { |
| 413 | return permtoindex_8x8(vand_u8(cube.corner, PBITS8_NEON)); | 447 | return permtoindex_Nx8(8, vand_u8(cube.corner, PBITS8_NEON)); |
| 414 | } | 448 | } |
| 415 | 449 | ||
| 416 | STATIC_INLINE cube_t | 450 | STATIC_INLINE cube_t |
| @@ -425,7 +459,12 @@ invcoord_cp(uint64_t i) | |||
| 425 | STATIC_INLINE uint64_t | 459 | STATIC_INLINE uint64_t |
| 426 | coord_epud(cube_t cube) | 460 | coord_epud(cube_t cube) |
| 427 | { | 461 | { |
| 428 | return permtoindex_8x8(vand_u8(vget_low_u8(cube.edge), PBITS8_NEON)); | 462 | uint8x8_t a; |
| 463 | |||
| 464 | a = vget_low_u8(cube.edge); | ||
| 465 | a = vand_u8(a, PBITS8_NEON); | ||
| 466 | |||
| 467 | return permtoindex_Nx8(8, a); | ||
| 429 | } | 468 | } |
| 430 | 469 | ||
| 431 | STATIC_INLINE cube_t | 470 | STATIC_INLINE cube_t |
| @@ -436,3 +475,29 @@ invcoord_epud(uint64_t i) | |||
| 436 | .edge = vcombine_u8(indextoperm_8x8(i), vld1_u8(SOLVED_H)) | 475 | .edge = vcombine_u8(indextoperm_8x8(i), vld1_u8(SOLVED_H)) |
| 437 | }; | 476 | }; |
| 438 | } | 477 | } |
| 478 | |||
| 479 | STATIC_INLINE uint64_t | ||
| 480 | coord_epe(cube_t cube) | ||
| 481 | { | ||
| 482 | uint8x8_t a; | ||
| 483 | |||
| 484 | a = vget_high_u8(cube.edge); | ||
| 485 | a = vand_u8(a, PBITS8_NEON); | ||
| 486 | a = veor_u8(a, vdup_n_u8(8)); | ||
| 487 | |||
| 488 | return permtoindex_Nx8(4, a); | ||
| 489 | } | ||
| 490 | |||
| 491 | STATIC_INLINE cube_t | ||
| 492 | invcoord_epe(uint64_t i) | ||
| 493 | { | ||
| 494 | uint8x8_t a; | ||
| 495 | |||
| 496 | a = indextoperm_4x8(i); | ||
| 497 | a = vadd_u8(a, vreinterpret_u8_u64(vdup_n_u64(UINT64_C(0x08080808)))); | ||
| 498 | |||
| 499 | return (cube_t) { | ||
| 500 | .corner = vld1_u8(SOLVED_L), | ||
| 501 | .edge = vcombine_u8(vld1_u8(SOLVED_L), a) | ||
| 502 | }; | ||
| 503 | } | ||
