diff options
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/avx2.h | 6 | ||||
| -rw-r--r-- | src/arch/common.h | 17 | ||||
| -rw-r--r-- | src/arch/neon.h | 11 | ||||
| -rw-r--r-- | src/arch/portable.h | 12 |
4 files changed, 46 insertions, 0 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 2c3371e..b6ff510 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -16,6 +16,12 @@ | |||
| 16 | #define SOLVED_CUBE STATIC_CUBE( \ | 16 | #define SOLVED_CUBE STATIC_CUBE( \ |
| 17 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | 17 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) |
| 18 | 18 | ||
| 19 | STATIC_INLINE int | ||
| 20 | popcount_u32(uint32_t x) | ||
| 21 | { | ||
| 22 | return _mm_popcnt_u32(x); | ||
| 23 | } | ||
| 24 | |||
| 19 | STATIC void | 25 | STATIC void |
| 20 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 26 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 21 | { | 27 | { |
diff --git a/src/arch/common.h b/src/arch/common.h index 802790c..52e0fc7 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -1,3 +1,5 @@ | |||
| 1 | STATIC_INLINE int popcount_u32(uint32_t); | ||
| 2 | |||
| 1 | STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 3 | STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 2 | STATIC_INLINE bool equal(cube_t, cube_t); | 4 | STATIC_INLINE bool equal(cube_t, cube_t); |
| 3 | STATIC_INLINE cube_t invertco(cube_t); | 5 | STATIC_INLINE cube_t invertco(cube_t); |
| @@ -18,6 +20,7 @@ STATIC_INLINE void set_eo(cube_t *, int64_t); | |||
| 18 | STATIC_INLINE cube_t invcoord_esep(int64_t); | 20 | STATIC_INLINE cube_t invcoord_esep(int64_t); |
| 19 | 21 | ||
| 20 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); | 22 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); |
| 23 | STATIC_INLINE cube_t invcoord_eoesep(int64_t); | ||
| 21 | 24 | ||
| 22 | STATIC_INLINE void | 25 | STATIC_INLINE void |
| 23 | invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) | 26 | invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) |
| @@ -44,3 +47,17 @@ invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) | |||
| 44 | mem[i] = (slice[s]++) | (uint8_t)(s << 2); | 47 | mem[i] = (slice[s]++) | (uint8_t)(s << 2); |
| 45 | } | 48 | } |
| 46 | } | 49 | } |
| 50 | |||
| 51 | STATIC_INLINE cube_t | ||
| 52 | invcoord_eoesep(int64_t i) | ||
| 53 | { | ||
| 54 | cube_t c; | ||
| 55 | int64_t esep, eo; | ||
| 56 | |||
| 57 | esep = i >> INT64_C(11); | ||
| 58 | eo = i % POW_2_11; | ||
| 59 | c = invcoord_esep(esep); | ||
| 60 | set_eo(&c, eo); | ||
| 61 | |||
| 62 | return c; | ||
| 63 | } | ||
diff --git a/src/arch/neon.h b/src/arch/neon.h index c31c8f9..47dc147 100644 --- a/src/arch/neon.h +++ b/src/arch/neon.h | |||
| @@ -26,6 +26,17 @@ STATIC_INLINE uint8x8_t compose_corners_slim(uint8x8_t, uint8x8_t); | |||
| 26 | #define SOLVED_CUBE STATIC_CUBE( \ | 26 | #define SOLVED_CUBE 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 | /* TODO: optimize this (use intrinsics?) */ | ||
| 30 | STATIC_INLINE int | ||
| 31 | { | ||
| 32 | int ret; | ||
| 33 | |||
| 34 | for (ret = 0; x != 0; x >>= 1) | ||
| 35 | ret += x & 1; | ||
| 36 | |||
| 37 | return ret; | ||
| 38 | } | ||
| 39 | |||
| 29 | STATIC void | 40 | STATIC void |
| 30 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 41 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 31 | { | 42 | { |
diff --git a/src/arch/portable.h b/src/arch/portable.h index e9a8dd0..b8c5211 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -9,6 +9,18 @@ | |||
| 9 | #define SOLVED_CUBE STATIC_CUBE( \ | 9 | #define SOLVED_CUBE STATIC_CUBE( \ |
| 10 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) | 10 | 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) |
| 11 | 11 | ||
| 12 | /* TODO: optimize this (use bit tricks?) */ | ||
| 13 | STATIC_INLINE int | ||
| 14 | popcount_u32(uint32_t x) | ||
| 15 | { | ||
| 16 | int ret; | ||
| 17 | |||
| 18 | for (ret = 0; x != 0; x >>= 1) | ||
| 19 | ret += x & 1; | ||
| 20 | |||
| 21 | return ret; | ||
| 22 | } | ||
| 23 | |||
| 12 | STATIC void | 24 | STATIC void |
| 13 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 25 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 14 | { | 26 | { |
