diff options
Diffstat (limited to 'src/arch/neon.h')
| -rw-r--r-- | src/arch/neon.h | 74 |
1 files changed, 37 insertions, 37 deletions
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; |
