diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:53:38 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-09-05 08:55:25 +0200 |
| commit | fd5ddb3db9f50411ca579d84f225f265ca35b56a (patch) | |
| tree | b659112cc0e2abd6c7edb08b0938c0d2de4ca066 /src/arch | |
| parent | c9e2d6466e42d6b779ac9ffa7c5ee9a9c7558df8 (diff) | |
| download | nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.tar.gz nissy-core-fd5ddb3db9f50411ca579d84f225f265ca35b56a.zip | |
Rename constants from _underscore to CAPS
Diffstat (limited to 'src/arch')
| -rw-r--r-- | src/arch/avx2.h | 40 | ||||
| -rw-r--r-- | src/arch/common.h | 38 | ||||
| -rw-r--r-- | src/arch/neon.h | 74 | ||||
| -rw-r--r-- | src/arch/portable.h | 80 |
4 files changed, 116 insertions, 116 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h index b1a7ab7..8d53f8f 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #define solved static_cube( \ | 16 | #define solved 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 void | 19 | STATIC void |
| 20 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 20 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 21 | { | 21 | { |
| 22 | uint8_t aux[32]; | 22 | uint8_t aux[32]; |
| @@ -26,7 +26,7 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | |||
| 26 | memcpy(e, aux+16, 12); | 26 | memcpy(e, aux+16, 12); |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | _static_inline bool | 29 | STATIC_INLINE bool |
| 30 | equal(cube_t c1, cube_t c2) | 30 | equal(cube_t c1, cube_t c2) |
| 31 | { | 31 | { |
| 32 | int32_t mask; | 32 | int32_t mask; |
| @@ -38,7 +38,7 @@ equal(cube_t c1, cube_t c2) | |||
| 38 | return mask == ~0; | 38 | return mask == ~0; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | _static_inline cube_t | 41 | STATIC_INLINE cube_t |
| 42 | invertco(cube_t c) | 42 | invertco(cube_t c) |
| 43 | { | 43 | { |
| 44 | cube_t co, shleft, shright, summed, newco, cleanco, ret; | 44 | cube_t co, shleft, shright, summed, newco, cleanco, ret; |
| @@ -54,7 +54,7 @@ invertco(cube_t c) | |||
| 54 | return ret; | 54 | return ret; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | _static_inline cube_t | 57 | STATIC_INLINE cube_t |
| 58 | compose_epcpeo(cube_t c1, cube_t c2) | 58 | compose_epcpeo(cube_t c1, cube_t c2) |
| 59 | { | 59 | { |
| 60 | cube_t b, s, eo2; | 60 | cube_t b, s, eo2; |
| @@ -74,13 +74,13 @@ compose_epcpeo(cube_t c1, cube_t c2) | |||
| 74 | return s; | 74 | return s; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | _static_inline cube_t | 77 | STATIC_INLINE cube_t |
| 78 | compose_edges(cube_t c1, cube_t c2) | 78 | compose_edges(cube_t c1, cube_t c2) |
| 79 | { | 79 | { |
| 80 | return compose_epcpeo(c1, c2); | 80 | return compose_epcpeo(c1, c2); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | _static_inline cube_t | 83 | STATIC_INLINE cube_t |
| 84 | compose_corners(cube_t c1, cube_t c2) | 84 | compose_corners(cube_t c1, cube_t c2) |
| 85 | { | 85 | { |
| 86 | /* | 86 | /* |
| @@ -91,7 +91,7 @@ compose_corners(cube_t c1, cube_t c2) | |||
| 91 | return compose(c1, c2); | 91 | return compose(c1, c2); |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | _static_inline cube_t | 94 | STATIC_INLINE cube_t |
| 95 | compose(cube_t c1, cube_t c2) | 95 | compose(cube_t c1, cube_t c2) |
| 96 | { | 96 | { |
| 97 | cube_t s, co1, co2, aux, auy1, auy2, auz1, auz2; | 97 | cube_t s, co1, co2, aux, auy1, auy2, auz1, auz2; |
| @@ -114,7 +114,7 @@ compose(cube_t c1, cube_t c2) | |||
| 114 | return s; | 114 | return s; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | _static_inline cube_t | 117 | STATIC_INLINE cube_t |
| 118 | cleanaftershuffle(cube_t c) | 118 | cleanaftershuffle(cube_t c) |
| 119 | { | 119 | { |
| 120 | __m256i b; | 120 | __m256i b; |
| @@ -127,7 +127,7 @@ cleanaftershuffle(cube_t c) | |||
| 127 | return _mm256_andnot_si256(b, c); | 127 | return _mm256_andnot_si256(b, c); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | _static_inline cube_t | 130 | STATIC_INLINE cube_t |
| 131 | inverse(cube_t c) | 131 | inverse(cube_t c) |
| 132 | { | 132 | { |
| 133 | /* Method taken from Andrew Skalski's vcube[1]. The addition sequence | 133 | /* Method taken from Andrew Skalski's vcube[1]. The addition sequence |
| @@ -166,7 +166,7 @@ inverse(cube_t c) | |||
| 166 | return invertco(ret); | 166 | return invertco(ret); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | _static_inline int64_t | 169 | STATIC_INLINE int64_t |
| 170 | coord_co(cube_t c) | 170 | coord_co(cube_t c) |
| 171 | { | 171 | { |
| 172 | cube_t co; | 172 | cube_t co; |
| @@ -182,7 +182,7 @@ coord_co(cube_t c) | |||
| 182 | return ret; | 182 | return ret; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | _static_inline int64_t | 185 | STATIC_INLINE int64_t |
| 186 | coord_csep(cube_t c) | 186 | coord_csep(cube_t c) |
| 187 | { | 187 | { |
| 188 | cube_t cp, shifted; | 188 | cube_t cp, shifted; |
| @@ -195,13 +195,13 @@ coord_csep(cube_t c) | |||
| 195 | return mask & 0x7F; | 195 | return mask & 0x7F; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | _static_inline int64_t | 198 | STATIC_INLINE int64_t |
| 199 | coord_cocsep(cube_t c) | 199 | coord_cocsep(cube_t c) |
| 200 | { | 200 | { |
| 201 | return (coord_co(c) << 7) + coord_csep(c); | 201 | return (coord_co(c) << 7) + coord_csep(c); |
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | _static_inline int64_t | 204 | STATIC_INLINE int64_t |
| 205 | coord_eo(cube_t c) | 205 | coord_eo(cube_t c) |
| 206 | { | 206 | { |
| 207 | cube_t eo, shifted; | 207 | cube_t eo, shifted; |
| @@ -214,7 +214,7 @@ coord_eo(cube_t c) | |||
| 214 | return mask >> 17; | 214 | return mask >> 17; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | _static_inline int64_t | 217 | STATIC_INLINE int64_t |
| 218 | coord_esep(cube_t c) | 218 | coord_esep(cube_t c) |
| 219 | { | 219 | { |
| 220 | cube_t ep; | 220 | cube_t ep; |
| @@ -229,8 +229,8 @@ coord_esep(cube_t c) | |||
| 229 | for (i = 0, j = 0; i < 12; i++, mem[i/8 + 2] >>= 8) { | 229 | for (i = 0, j = 0; i < 12; i++, mem[i/8 + 2] >>= 8) { |
| 230 | e = mem[i/8 + 2]; | 230 | e = mem[i/8 + 2]; |
| 231 | 231 | ||
| 232 | bit1 = (e & _esepbit1) >> 2; | 232 | bit1 = (e & ESEPBIT_1) >> 2; |
| 233 | bit2 = (e & _esepbit2) >> 3; | 233 | bit2 = (e & ESEPBIT_2) >> 3; |
| 234 | is1 = (1 - bit2) * bit1; | 234 | is1 = (1 - bit2) * bit1; |
| 235 | 235 | ||
| 236 | ret1 += bit2 * binomial[11-i][k]; | 236 | ret1 += bit2 * binomial[11-i][k]; |
| @@ -245,19 +245,19 @@ coord_esep(cube_t c) | |||
| 245 | return ret1 * 70 + ret2; | 245 | return ret1 * 70 + ret2; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | _static_inline void | 248 | STATIC_INLINE void |
| 249 | copy_corners(cube_t *dest, cube_t src) | 249 | copy_corners(cube_t *dest, cube_t src) |
| 250 | { | 250 | { |
| 251 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); | 251 | *dest = _mm256_blend_epi32(*dest, src, 0x0F); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | _static_inline void | 254 | STATIC_INLINE void |
| 255 | copy_edges(cube_t *dest, cube_t src) | 255 | copy_edges(cube_t *dest, cube_t src) |
| 256 | { | 256 | { |
| 257 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); | 257 | *dest = _mm256_blend_epi32(*dest, src, 0xF0); |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | _static_inline void | 260 | STATIC_INLINE void |
| 261 | set_eo(cube_t *cube, int64_t eo) | 261 | set_eo(cube_t *cube, int64_t eo) |
| 262 | { | 262 | { |
| 263 | int64_t eo12, eotop, eobot; | 263 | int64_t eo12, eotop, eobot; |
| @@ -282,7 +282,7 @@ set_eo(cube_t *cube, int64_t eo) | |||
| 282 | *cube = _mm256_or_si256(*cube, veo); | 282 | *cube = _mm256_or_si256(*cube, veo); |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | _static_inline cube_t | 285 | STATIC_INLINE cube_t |
| 286 | invcoord_esep(int64_t esep) | 286 | invcoord_esep(int64_t esep) |
| 287 | { | 287 | { |
| 288 | cube_t eee, ret; | 288 | cube_t eee, ret; |
diff --git a/src/arch/common.h b/src/arch/common.h index d8d2305..346403b 100644 --- a/src/arch/common.h +++ b/src/arch/common.h | |||
| @@ -1,26 +1,26 @@ | |||
| 1 | _static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); | 1 | STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); |
| 2 | _static_inline bool equal(cube_t, cube_t); | 2 | STATIC_INLINE bool equal(cube_t, cube_t); |
| 3 | _static_inline cube_t invertco(cube_t); | 3 | STATIC_INLINE cube_t invertco(cube_t); |
| 4 | _static_inline cube_t compose_epcpeo(cube_t, cube_t); | 4 | STATIC_INLINE cube_t compose_epcpeo(cube_t, cube_t); |
| 5 | _static_inline cube_t compose_edges(cube_t, cube_t); | 5 | STATIC_INLINE cube_t compose_edges(cube_t, cube_t); |
| 6 | _static_inline cube_t compose_corners(cube_t, cube_t); | 6 | STATIC_INLINE cube_t compose_corners(cube_t, cube_t); |
| 7 | _static_inline cube_t compose(cube_t, cube_t); | 7 | STATIC_INLINE cube_t compose(cube_t, cube_t); |
| 8 | _static_inline cube_t inverse(cube_t); | 8 | STATIC_INLINE cube_t inverse(cube_t); |
| 9 | 9 | ||
| 10 | _static_inline int64_t coord_co(cube_t); | 10 | STATIC_INLINE int64_t coord_co(cube_t); |
| 11 | _static_inline int64_t coord_csep(cube_t); | 11 | STATIC_INLINE int64_t coord_csep(cube_t); |
| 12 | _static_inline int64_t coord_cocsep(cube_t); | 12 | STATIC_INLINE int64_t coord_cocsep(cube_t); |
| 13 | _static_inline int64_t coord_eo(cube_t); | 13 | STATIC_INLINE int64_t coord_eo(cube_t); |
| 14 | _static_inline int64_t coord_esep(cube_t); | 14 | STATIC_INLINE int64_t coord_esep(cube_t); |
| 15 | 15 | ||
| 16 | _static_inline void copy_corners(cube_t *, cube_t); | 16 | STATIC_INLINE void copy_corners(cube_t *, cube_t); |
| 17 | _static_inline void copy_edges(cube_t *, cube_t); | 17 | STATIC_INLINE void copy_edges(cube_t *, cube_t); |
| 18 | _static_inline void set_eo(cube_t *, int64_t); | 18 | STATIC_INLINE void set_eo(cube_t *, int64_t); |
| 19 | _static_inline cube_t invcoord_esep(int64_t); | 19 | STATIC_INLINE cube_t invcoord_esep(int64_t); |
| 20 | 20 | ||
| 21 | _static_inline void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); | 21 | STATIC_INLINE void invcoord_esep_array(int64_t, int64_t, uint8_t[static 12]); |
| 22 | 22 | ||
| 23 | _static_inline void | 23 | STATIC_INLINE void |
| 24 | invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) | 24 | invcoord_esep_array(int64_t set1, int64_t set2, uint8_t mem[static 12]) |
| 25 | { | 25 | { |
| 26 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; | 26 | int64_t bit1, bit2, i, j, jj, k, l, s, v, w, is1; |
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); | 7 | STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); |
| 8 | _static_inline uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t); | 8 | STATIC_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 | 29 | STATIC void |
| 30 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 30 | pieces(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 | 42 | STATIC_INLINE bool |
| 43 | equal(cube_t c1, cube_t c2) | 43 | equal(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 | 65 | STATIC_INLINE cube_t |
| 66 | invertco(cube_t c) | 66 | invertco(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 | 83 | STATIC_INLINE cube_t |
| 84 | compose_edges(cube_t c1, cube_t c2) | 84 | compose_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 | 91 | STATIC_INLINE cube_t |
| 92 | compose_corners(cube_t c1, cube_t c2) | 92 | compose_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 | 99 | STATIC_INLINE uint8x16_t |
| 100 | compose_edges_slim(uint8x16_t edge1, uint8x16_t edge2) | 100 | compose_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 | 123 | STATIC_INLINE uint8x16_t |
| 124 | compose_corners_slim(uint8x16_t corner1, uint8x16_t corner2) | 124 | compose_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 | 151 | STATIC_INLINE cube_t |
| 152 | compose(cube_t c1, cube_t c2) | 152 | compose(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 | 162 | STATIC_INLINE cube_t |
| 163 | inverse(cube_t cube) | 163 | inverse(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 | 202 | STATIC_INLINE int64_t |
| 203 | coord_co(cube_t c) | 203 | coord_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 | 218 | STATIC_INLINE int64_t |
| 219 | coord_csep(cube_t c) | 219 | coord_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 | 234 | STATIC_INLINE int64_t |
| 235 | coord_cocsep(cube_t c) | 235 | coord_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 | 240 | STATIC_INLINE int64_t |
| 241 | coord_eo(cube_t c) | 241 | coord_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 | 258 | STATIC_INLINE int64_t |
| 259 | coord_esep(cube_t c) | 259 | coord_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 | 285 | STATIC_INLINE void |
| 286 | copy_corners(cube_t *dst, cube_t src) | 286 | copy_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 | 291 | STATIC_INLINE void |
| 292 | copy_edges(cube_t *dst, cube_t src) | 292 | copy_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 | 297 | STATIC_INLINE void |
| 298 | set_eo(cube_t *cube, int64_t eo) | 298 | set_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 | 318 | STATIC_INLINE cube_t |
| 319 | invcoord_esep(int64_t esep) | 319 | invcoord_esep(int64_t esep) |
| 320 | { | 320 | { |
| 321 | cube_t ret; | 321 | cube_t ret; |
diff --git a/src/arch/portable.h b/src/arch/portable.h index f6e5301..fdadb02 100644 --- a/src/arch/portable.h +++ b/src/arch/portable.h | |||
| @@ -9,14 +9,14 @@ | |||
| 9 | #define solved static_cube( \ | 9 | #define solved 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 | _static void | 12 | STATIC void |
| 13 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) | 13 | pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) |
| 14 | { | 14 | { |
| 15 | memcpy(c, cube->corner, 8); | 15 | memcpy(c, cube->corner, 8); |
| 16 | memcpy(e, cube->edge, 12); | 16 | memcpy(e, cube->edge, 12); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | _static_inline bool | 19 | STATIC_INLINE bool |
| 20 | equal(cube_t c1, cube_t c2) | 20 | equal(cube_t c1, cube_t c2) |
| 21 | { | 21 | { |
| 22 | uint8_t i; | 22 | uint8_t i; |
| @@ -31,7 +31,7 @@ equal(cube_t c1, cube_t c2) | |||
| 31 | return ret; | 31 | return ret; |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | _static_inline cube_t | 34 | STATIC_INLINE cube_t |
| 35 | invertco(cube_t c) | 35 | invertco(cube_t c) |
| 36 | { | 36 | { |
| 37 | uint8_t i, piece, orien; | 37 | uint8_t i, piece, orien; |
| @@ -40,44 +40,44 @@ invertco(cube_t c) | |||
| 40 | ret = c; | 40 | ret = c; |
| 41 | for (i = 0; i < 8; i++) { | 41 | for (i = 0; i < 8; i++) { |
| 42 | piece = c.corner[i]; | 42 | piece = c.corner[i]; |
| 43 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; | 43 | orien = ((piece << 1) | (piece >> 1)) & COBITS_2; |
| 44 | ret.corner[i] = (piece & _pbits) | orien; | 44 | ret.corner[i] = (piece & PBITS) | orien; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | return ret; | 47 | return ret; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | _static_inline void | 50 | STATIC_INLINE void |
| 51 | compose_edges_inplace(cube_t c1, cube_t c2, cube_t *ret) | 51 | compose_edges_inplace(cube_t c1, cube_t c2, cube_t *ret) |
| 52 | { | 52 | { |
| 53 | uint8_t i, piece1, piece2, p, orien; | 53 | uint8_t i, piece1, piece2, p, orien; |
| 54 | 54 | ||
| 55 | for (i = 0; i < 12; i++) { | 55 | for (i = 0; i < 12; i++) { |
| 56 | piece2 = c2.edge[i]; | 56 | piece2 = c2.edge[i]; |
| 57 | p = piece2 & _pbits; | 57 | p = piece2 & PBITS; |
| 58 | piece1 = c1.edge[p]; | 58 | piece1 = c1.edge[p]; |
| 59 | orien = (piece2 ^ piece1) & _eobit; | 59 | orien = (piece2 ^ piece1) & EOBIT; |
| 60 | ret->edge[i] = (piece1 & _pbits) | orien; | 60 | ret->edge[i] = (piece1 & PBITS) | orien; |
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | _static_inline void | 64 | STATIC_INLINE void |
| 65 | compose_corners_inplace(cube_t c1, cube_t c2, cube_t *ret) | 65 | compose_corners_inplace(cube_t c1, cube_t c2, cube_t *ret) |
| 66 | { | 66 | { |
| 67 | uint8_t i, piece1, piece2, p, orien, aux, auy; | 67 | uint8_t i, piece1, piece2, p, orien, aux, auy; |
| 68 | 68 | ||
| 69 | for (i = 0; i < 8; i++) { | 69 | for (i = 0; i < 8; i++) { |
| 70 | piece2 = c2.corner[i]; | 70 | piece2 = c2.corner[i]; |
| 71 | p = piece2 & _pbits; | 71 | p = piece2 & PBITS; |
| 72 | piece1 = c1.corner[p]; | 72 | piece1 = c1.corner[p]; |
| 73 | aux = (piece2 & _cobits) + (piece1 & _cobits); | 73 | aux = (piece2 & COBITS) + (piece1 & COBITS); |
| 74 | auy = (aux + _ctwist_cw) >> 2; | 74 | auy = (aux + CTWIST_CW) >> 2; |
| 75 | orien = (aux + auy) & _cobits2; | 75 | orien = (aux + auy) & COBITS_2; |
| 76 | ret->corner[i] = (piece1 & _pbits) | orien; | 76 | ret->corner[i] = (piece1 & PBITS) | orien; |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | _static_inline cube_t | 80 | STATIC_INLINE cube_t |
| 81 | compose_edges(cube_t c1, cube_t c2) | 81 | compose_edges(cube_t c1, cube_t c2) |
| 82 | { | 82 | { |
| 83 | cube_t ret = zero; | 83 | cube_t ret = zero; |
| @@ -87,7 +87,7 @@ compose_edges(cube_t c1, cube_t c2) | |||
| 87 | return ret; | 87 | return ret; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | _static_inline cube_t | 90 | STATIC_INLINE cube_t |
| 91 | compose_corners(cube_t c1, cube_t c2) | 91 | compose_corners(cube_t c1, cube_t c2) |
| 92 | { | 92 | { |
| 93 | cube_t ret = zero; | 93 | cube_t ret = zero; |
| @@ -97,7 +97,7 @@ compose_corners(cube_t c1, cube_t c2) | |||
| 97 | return ret; | 97 | return ret; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | _static_inline cube_t | 100 | STATIC_INLINE cube_t |
| 101 | compose(cube_t c1, cube_t c2) | 101 | compose(cube_t c1, cube_t c2) |
| 102 | { | 102 | { |
| 103 | cube_t ret = zero; | 103 | cube_t ret = zero; |
| @@ -116,27 +116,27 @@ inverse(cube_t cube) | |||
| 116 | 116 | ||
| 117 | for (i = 0; i < 12; i++) { | 117 | for (i = 0; i < 12; i++) { |
| 118 | piece = cube.edge[i]; | 118 | piece = cube.edge[i]; |
| 119 | orien = piece & _eobit; | 119 | orien = piece & EOBIT; |
| 120 | ret.edge[piece & _pbits] = i | orien; | 120 | ret.edge[piece & PBITS] = i | orien; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | for (i = 0; i < 8; i++) { | 123 | for (i = 0; i < 8; i++) { |
| 124 | piece = cube.corner[i]; | 124 | piece = cube.corner[i]; |
| 125 | orien = ((piece << 1) | (piece >> 1)) & _cobits2; | 125 | orien = ((piece << 1) | (piece >> 1)) & COBITS_2; |
| 126 | ret.corner[piece & _pbits] = i | orien; | 126 | ret.corner[piece & PBITS] = i | orien; |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | return ret; | 129 | return ret; |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | _static_inline int64_t | 132 | STATIC_INLINE int64_t |
| 133 | coord_co(cube_t c) | 133 | coord_co(cube_t c) |
| 134 | { | 134 | { |
| 135 | int i, p; | 135 | int i, p; |
| 136 | int64_t ret; | 136 | int64_t ret; |
| 137 | 137 | ||
| 138 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) | 138 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 3) |
| 139 | ret += p * (c.corner[i] >> _coshift); | 139 | ret += p * (c.corner[i] >> COSHIFT); |
| 140 | 140 | ||
| 141 | return ret; | 141 | return ret; |
| 142 | } | 142 | } |
| @@ -148,32 +148,32 @@ Ignoring the last bit, we have a value up to 2^7, but not all values are | |||
| 148 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% | 148 | possible. Encoding this as a number from 0 to C(8,4) would save about 40% |
| 149 | of space, but we are not going to use this coordinate in large tables. | 149 | of space, but we are not going to use this coordinate in large tables. |
| 150 | */ | 150 | */ |
| 151 | _static_inline int64_t | 151 | STATIC_INLINE int64_t |
| 152 | coord_csep(cube_t c) | 152 | coord_csep(cube_t c) |
| 153 | { | 153 | { |
| 154 | int i, p; | 154 | int i, p; |
| 155 | int64_t ret; | 155 | int64_t ret; |
| 156 | 156 | ||
| 157 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) | 157 | for (ret = 0, i = 0, p = 1; i < 7; i++, p *= 2) |
| 158 | ret += p * ((c.corner[i] & _csepbit) >> 2); | 158 | ret += p * ((c.corner[i] & CSEPBIT) >> 2); |
| 159 | 159 | ||
| 160 | return ret; | 160 | return ret; |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | _static_inline int64_t | 163 | STATIC_INLINE int64_t |
| 164 | coord_cocsep(cube_t c) | 164 | coord_cocsep(cube_t c) |
| 165 | { | 165 | { |
| 166 | return (coord_co(c) << 7) + coord_csep(c); | 166 | return (coord_co(c) << 7) + coord_csep(c); |
| 167 | } | 167 | } |
| 168 | 168 | ||
| 169 | _static_inline int64_t | 169 | STATIC_INLINE int64_t |
| 170 | coord_eo(cube_t c) | 170 | coord_eo(cube_t c) |
| 171 | { | 171 | { |
| 172 | int i, p; | 172 | int i, p; |
| 173 | int64_t ret; | 173 | int64_t ret; |
| 174 | 174 | ||
| 175 | for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) | 175 | for (ret = 0, i = 1, p = 1; i < 12; i++, p *= 2) |
| 176 | ret += p * (c.edge[i] >> _eoshift); | 176 | ret += p * (c.edge[i] >> EOSHIFT); |
| 177 | 177 | ||
| 178 | return ret; | 178 | return ret; |
| 179 | } | 179 | } |
| @@ -182,24 +182,24 @@ coord_eo(cube_t c) | |||
| 182 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). | 182 | We encode the edge separation as a number from 0 to C(12,4)*C(8,4). |
| 183 | It can be seen as the composition of two "subset index" coordinates. | 183 | It can be seen as the composition of two "subset index" coordinates. |
| 184 | */ | 184 | */ |
| 185 | _static_inline int64_t | 185 | STATIC_INLINE int64_t |
| 186 | coord_esep(cube_t c) | 186 | coord_esep(cube_t c) |
| 187 | { | 187 | { |
| 188 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; | 188 | int64_t i, j, jj, k, l, ret1, ret2, bit1, bit2, is1; |
| 189 | 189 | ||
| 190 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { | 190 | for (i = 0, j = 0, k = 4, l = 4, ret1 = 0, ret2 = 0; i < 12; i++) { |
| 191 | /* Simple version: | 191 | /* Simple version: |
| 192 | if (c.edge[i] & _esepbit2) { | 192 | if (c.edge[i] & ESEPBIT_2) { |
| 193 | ret1 += binomial[11-i][k--]; | 193 | ret1 += binomial[11-i][k--]; |
| 194 | } else { | 194 | } else { |
| 195 | if (c.edge[i] & _esepbit1) | 195 | if (c.edge[i] & ESEPBIT_1) |
| 196 | ret2 += binomial[7-j][l--]; | 196 | ret2 += binomial[7-j][l--]; |
| 197 | j++; | 197 | j++; |
| 198 | } | 198 | } |
| 199 | */ | 199 | */ |
| 200 | 200 | ||
| 201 | bit1 = (c.edge[i] & _esepbit1) >> 2; | 201 | bit1 = (c.edge[i] & ESEPBIT_1) >> 2; |
| 202 | bit2 = (c.edge[i] & _esepbit2) >> 3; | 202 | bit2 = (c.edge[i] & ESEPBIT_2) >> 3; |
| 203 | is1 = (1 - bit2) * bit1; | 203 | is1 = (1 - bit2) * bit1; |
| 204 | 204 | ||
| 205 | ret1 += bit2 * binomial[11-i][k]; | 205 | ret1 += bit2 * binomial[11-i][k]; |
| @@ -214,19 +214,19 @@ coord_esep(cube_t c) | |||
| 214 | return ret1 * 70 + ret2; | 214 | return ret1 * 70 + ret2; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | _static_inline void | 217 | STATIC_INLINE void |
| 218 | copy_corners(cube_t *dest, cube_t src) | 218 | copy_corners(cube_t *dest, cube_t src) |
| 219 | { | 219 | { |
| 220 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); | 220 | memcpy(&dest->corner, src.corner, sizeof(src.corner)); |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | _static_inline void | 223 | STATIC_INLINE void |
| 224 | copy_edges(cube_t *dest, cube_t src) | 224 | copy_edges(cube_t *dest, cube_t src) |
| 225 | { | 225 | { |
| 226 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); | 226 | memcpy(&dest->edge, src.edge, sizeof(src.edge)); |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | _static_inline void | 229 | STATIC_INLINE void |
| 230 | set_eo(cube_t *cube, int64_t eo) | 230 | set_eo(cube_t *cube, int64_t eo) |
| 231 | { | 231 | { |
| 232 | uint8_t i, sum, flip; | 232 | uint8_t i, sum, flip; |
| @@ -234,12 +234,12 @@ set_eo(cube_t *cube, int64_t eo) | |||
| 234 | for (sum = 0, i = 1; i < 12; i++, eo >>= 1) { | 234 | for (sum = 0, i = 1; i < 12; i++, eo >>= 1) { |
| 235 | flip = eo % 2; | 235 | flip = eo % 2; |
| 236 | sum += flip; | 236 | sum += flip; |
| 237 | cube->edge[i] = (cube->edge[i] & ~_eobit) | (_eobit * flip); | 237 | cube->edge[i] = (cube->edge[i] & ~EOBIT) | (EOBIT * flip); |
| 238 | } | 238 | } |
| 239 | cube->edge[0] = (cube->edge[0] & ~_eobit) | (_eobit * (sum % 2)); | 239 | cube->edge[0] = (cube->edge[0] & ~EOBIT) | (EOBIT * (sum % 2)); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | _static_inline cube_t | 242 | STATIC_INLINE cube_t |
| 243 | invcoord_esep(int64_t esep) | 243 | invcoord_esep(int64_t esep) |
| 244 | { | 244 | { |
| 245 | cube_t ret; | 245 | cube_t ret; |
