aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/arch/arch.h41
-rw-r--r--src/arch/avx2.h (renamed from src/cube_avx2.h)22
-rw-r--r--src/arch/common.h19
-rw-r--r--src/arch/neon.h (renamed from src/cube_neon.h)29
-rw-r--r--src/arch/portable.h (renamed from src/cube_portable.h)26
5 files changed, 60 insertions, 77 deletions
diff --git a/src/arch/arch.h b/src/arch/arch.h
new file mode 100644
index 0000000..d5e0218
--- /dev/null
+++ b/src/arch/arch.h
@@ -0,0 +1,41 @@
1#if defined(CUBE_AVX2)
2
3#include <immintrin.h>
4
5typedef __m256i cube_t;
6
7#if !defined(TEST_H)
8#include "common.h"
9#include "avx2.h"
10#endif
11
12#elif defined(CUBE_NEON)
13
14#include <stdlib.h>
15#include <arm_neon.h>
16
17typedef struct {
18 uint8x16_t corner;
19 uint8x16_t edge;
20} cube_t;
21
22#if !defined(TEST_H)
23#include "common.h"
24#include "neon.h"
25#endif
26
27#else
28
29#include <stdlib.h>
30
31typedef struct {
32 uint8_t corner[8];
33 uint8_t edge[12];
34} cube_t;
35
36#if !defined(TEST_H)
37#include "common.h"
38#include "portable.h"
39#endif
40
41#endif
diff --git a/src/cube_avx2.h b/src/arch/avx2.h
index b189023..59a0d6c 100644
--- a/src/cube_avx2.h
+++ b/src/arch/avx2.h
@@ -1,5 +1,3 @@
1typedef __m256i cube_t;
2
3#define _co2_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060)) 1#define _co2_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x6060606060606060))
4#define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020)) 2#define _cocw_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x2020202020202020))
5#define _cp_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707)) 3#define _cp_avx2 _mm256_set_epi64x(0, 0, 0, INT64_C(0x0707070707070707))
@@ -18,26 +16,6 @@ typedef __m256i cube_t;
18#define solved static_cube( \ 16#define solved static_cube( \
19 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)
20 18
21_static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
22_static_inline bool equal(cube_t, cube_t);
23_static_inline cube_t invertco(cube_t);
24_static_inline cube_t compose_epcpeo(cube_t, cube_t);
25_static_inline cube_t compose_edges(cube_t, cube_t);
26_static_inline cube_t compose_corners(cube_t, cube_t);
27_static_inline cube_t compose(cube_t, cube_t);
28_static_inline cube_t inverse(cube_t);
29
30_static_inline int64_t coord_co(cube_t);
31_static_inline int64_t coord_csep(cube_t);
32_static_inline int64_t coord_cocsep(cube_t);
33_static_inline int64_t coord_eo(cube_t);
34_static_inline int64_t coord_esep(cube_t);
35
36_static_inline void copy_corners(cube_t *, cube_t);
37_static_inline void copy_edges(cube_t *, cube_t);
38_static_inline void set_eo(cube_t *, int64_t);
39_static_inline cube_t invcoord_esep(int64_t);
40
41_static void 19_static void
42pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 20pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
43{ 21{
diff --git a/src/arch/common.h b/src/arch/common.h
new file mode 100644
index 0000000..cd2d36e
--- /dev/null
+++ b/src/arch/common.h
@@ -0,0 +1,19 @@
1_static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
2_static_inline bool equal(cube_t, cube_t);
3_static_inline cube_t invertco(cube_t);
4_static_inline cube_t compose_epcpeo(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);
7_static_inline cube_t compose(cube_t, cube_t);
8_static_inline cube_t inverse(cube_t);
9
10_static_inline int64_t coord_co(cube_t);
11_static_inline int64_t coord_csep(cube_t);
12_static_inline int64_t coord_cocsep(cube_t);
13_static_inline int64_t coord_eo(cube_t);
14_static_inline int64_t coord_esep(cube_t);
15
16_static_inline void copy_corners(cube_t *, cube_t);
17_static_inline void copy_edges(cube_t *, cube_t);
18_static_inline void set_eo(cube_t *, int64_t);
19_static_inline cube_t invcoord_esep(int64_t);
diff --git a/src/cube_neon.h b/src/arch/neon.h
index 23e5565..a75f86d 100644
--- a/src/cube_neon.h
+++ b/src/arch/neon.h
@@ -1,10 +1,3 @@
1// cube_t
2typedef struct
3{
4 uint8x16_t corner;
5 uint8x16_t edge;
6} cube_t;
7
8#define _co2_neon vdupq_n_u8(0x60) 1#define _co2_neon vdupq_n_u8(0x60)
9#define _cocw_neon vdupq_n_u8(0x20) 2#define _cocw_neon vdupq_n_u8(0x20)
10#define _cp_neon vdupq_n_u8(0x07) 3#define _cp_neon vdupq_n_u8(0x07)
@@ -30,28 +23,6 @@ typedef struct
30#define solved static_cube( \ 23#define solved static_cube( \
31 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) 24 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
32 25
33// Functions
34_static void pieces(cube_t *, uint8_t[static 8], uint8_t[static 12]);
35_static_inline bool equal(cube_t, cube_t);
36_static_inline cube_t invertco(cube_t);
37_static_inline cube_t compose_edges(cube_t, cube_t);
38_static_inline cube_t compose_corners(cube_t, cube_t);
39_static_inline uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t);
40_static_inline uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t);
41_static_inline cube_t compose(cube_t, cube_t);
42_static_inline cube_t inverse(cube_t);
43
44_static_inline int64_t coord_co(cube_t);
45_static_inline int64_t coord_csep(cube_t);
46_static_inline int64_t coord_cocsep(cube_t);
47_static_inline int64_t coord_eo(cube_t);
48_static_inline int64_t coord_esep(cube_t);
49
50_static_inline void copy_corners(cube_t *, cube_t);
51_static_inline void copy_edges(cube_t *, cube_t);
52_static_inline void set_eo(cube_t *, int64_t);
53_static_inline cube_t invcoord_esep(int64_t);
54
55_static void 26_static void
56pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 27pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
57{ 28{
diff --git a/src/cube_portable.h b/src/arch/portable.h
index 77e803b..b8330af 100644
--- a/src/cube_portable.h
+++ b/src/arch/portable.h
@@ -1,8 +1,3 @@
1typedef struct {
2 uint8_t corner[8];
3 uint8_t edge[12];
4} cube_t;
5
6#define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \ 1#define static_cube(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
7 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \ 2 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \
8 ((cube_t) { \ 3 ((cube_t) { \
@@ -14,27 +9,6 @@ typedef struct {
14#define solved static_cube( \ 9#define solved static_cube( \
15 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)
16 11
17_static void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
18_static_inline bool equal(cube_t, cube_t);
19_static_inline cube_t invertco(cube_t);
20_static_inline void compose_edges_inplace(cube_t, cube_t, cube_t *);
21_static_inline void compose_corners_inplace(cube_t, cube_t, cube_t *);
22_static_inline cube_t compose_edges(cube_t, cube_t);
23_static_inline cube_t compose_corners(cube_t, cube_t);
24_static_inline cube_t compose(cube_t, cube_t);
25_static_inline cube_t inverse(cube_t);
26
27_static_inline int64_t coord_co(cube_t);
28_static_inline int64_t coord_csep(cube_t);
29_static_inline int64_t coord_cocsep(cube_t);
30_static_inline int64_t coord_eo(cube_t);
31_static_inline int64_t coord_esep(cube_t);
32
33_static_inline void copy_corners(cube_t *, cube_t);
34_static_inline void copy_edges(cube_t *, cube_t);
35_static_inline void set_eo(cube_t *, int64_t);
36_static_inline cube_t invcoord_esep(int64_t);
37
38_static void 12_static void
39pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 13pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
40{ 14{

Generated with cgit - Back to sebastiano.tronto.net