aboutsummaryrefslogtreecommitdiff
path: root/src/arch
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2024-10-04 12:15:37 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2024-10-04 12:15:37 +0200
commit0de1530f4cea21f2bc0a0e0f1cbf9da016c7bda5 (patch)
treea0a64424190588e5f734c257dd312e1f89fcd1eb /src/arch
parent80b065f757240af7920862b3e09f32a6dc06d392 (diff)
downloadnissy-core-0de1530f4cea21f2bc0a0e0f1cbf9da016c7bda5.tar.gz
nissy-core-0de1530f4cea21f2bc0a0e0f1cbf9da016c7bda5.zip
Revert table-based transformations
Long live the giant switch!
Diffstat (limited to '')
-rw-r--r--src/arch/avx2.h42
-rw-r--r--src/arch/common.h7
-rw-r--r--src/arch/neon.h57
-rw-r--r--src/arch/portable.h49
4 files changed, 40 insertions, 115 deletions
diff --git a/src/arch/avx2.h b/src/arch/avx2.h
index 557ab49..2c3371e 100644
--- a/src/arch/avx2.h
+++ b/src/arch/avx2.h
@@ -6,6 +6,16 @@
6#define EO_AVX2 \ 6#define EO_AVX2 \
7 _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0) 7 _mm256_set_epi64x(INT64_C(0x10101010), INT64_C(0x1010101010101010), 0, 0)
8 8
9#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
10 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \
11 _mm256_set_epi8(0, 0, 0, 0, e_br, e_bl, e_fl, e_fr, \
12 e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf, \
13 0, 0, 0, 0, 0, 0, 0, 0, \
14 c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr)
15#define ZERO_CUBE _mm256_set_epi64x(0, 0, 0, 0)
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)
18
9STATIC void 19STATIC void
10pieces(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])
11{ 21{
@@ -16,38 +26,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
16 memcpy(e, aux+16, 12); 26 memcpy(e, aux+16, 12);
17} 27}
18 28
19STATIC_INLINE cube_t
20cubefrompieces(
21 uint8_t c_ufr,
22 uint8_t c_ubl,
23 uint8_t c_dfl,
24 uint8_t c_dbr,
25 uint8_t c_ufl,
26 uint8_t c_ubr,
27 uint8_t c_dfr,
28 uint8_t c_dbl,
29
30 uint8_t e_uf,
31 uint8_t e_ub,
32 uint8_t e_db,
33 uint8_t e_df,
34 uint8_t e_ur,
35 uint8_t e_ul,
36 uint8_t e_dl,
37 uint8_t e_dr,
38 uint8_t e_fr,
39 uint8_t e_fl,
40 uint8_t e_bl,
41 uint8_t e_br
42) {
43 return _mm256_set_epi8(
44 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr,
45 e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf,
46 0, 0, 0, 0, 0, 0, 0, 0,
47 c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr
48 );
49}
50
51STATIC_INLINE bool 29STATIC_INLINE bool
52equal(cube_t c1, cube_t c2) 30equal(cube_t c1, cube_t c2)
53{ 31{
diff --git a/src/arch/common.h b/src/arch/common.h
index 1469b30..346403b 100644
--- a/src/arch/common.h
+++ b/src/arch/common.h
@@ -1,11 +1,4 @@
1#define ZERO_CUBE cubefrompieces( \
2 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
3#define SOLVED_CUBE cubefrompieces( \
4 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)
5STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]); 1STATIC void pieces(cube_t *, uint8_t [static 8], uint8_t [static 12]);
6STATIC_INLINE cube_t cubefrompieces(uint8_t, uint8_t, uint8_t, uint8_t,
7 uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t,
8 uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t, uint8_t);
9STATIC_INLINE bool equal(cube_t, cube_t); 2STATIC_INLINE bool equal(cube_t, cube_t);
10STATIC_INLINE cube_t invertco(cube_t); 3STATIC_INLINE cube_t invertco(cube_t);
11STATIC_INLINE cube_t compose_epcpeo(cube_t, cube_t); 4STATIC_INLINE cube_t compose_epcpeo(cube_t, cube_t);
diff --git a/src/arch/neon.h b/src/arch/neon.h
index 9061422..acb75c3 100644
--- a/src/arch/neon.h
+++ b/src/arch/neon.h
@@ -7,6 +7,25 @@
7STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t); 7STATIC_INLINE uint8x16_t compose_edges_slim(uint8x16_t, uint8x16_t);
8STATIC_INLINE uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t); 8STATIC_INLINE uint8x16_t compose_corners_slim(uint8x16_t, uint8x16_t);
9 9
10// static cube
11#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
12 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br) \
13 ((cube_t){ \
14 .corner = {c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, 0, 0, 0, 0, 0, 0, 0, 0}, \
15 .edge = {e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr, e_fl, e_bl, e_br, 0, 0, 0, 0}})
16
17// zero cube
18#define ZERO_CUBE \
19 (cube_t) \
20 { \
21 .corner = vdupq_n_u8(0), \
22 .edge = vdupq_n_u8(0) \
23 }
24
25// solved 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)
28
10STATIC void 29STATIC void
11pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12]) 30pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
12{ 31{
@@ -20,44 +39,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
20 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);
21} 40}
22 41
23STATIC_INLINE cube_t
24cubefrompieces(
25 uint8_t c_ufr,
26 uint8_t c_ubl,
27 uint8_t c_dfl,
28 uint8_t c_dbr,
29 uint8_t c_ufl,
30 uint8_t c_ubr,
31 uint8_t c_dfr,
32 uint8_t c_dbl,
33
34 uint8_t e_uf,
35 uint8_t e_ub,
36 uint8_t e_db,
37 uint8_t e_df,
38 uint8_t e_ur,
39 uint8_t e_ul,
40 uint8_t e_dl,
41 uint8_t e_dr,
42 uint8_t e_fr,
43 uint8_t e_fl,
44 uint8_t e_bl,
45 uint8_t e_br
46) {
47 cube_t ret = {
48 .corner = {
49 c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl,
50 0, 0, 0, 0, 0, 0, 0, 0
51 },
52 .edge = {
53 e_uf, e_ub, e_db, e_df, e_ur, e_ul, e_dl, e_dr, e_fr,
54 e_fl, e_bl, e_br, 0, 0, 0, 0
55 }
56 };
57
58 return ret;
59}
60
61STATIC_INLINE bool 42STATIC_INLINE bool
62equal(cube_t c1, cube_t c2) 43equal(cube_t c1, cube_t c2)
63{ 44{
diff --git a/src/arch/portable.h b/src/arch/portable.h
index 3776c90..e9a8dd0 100644
--- a/src/arch/portable.h
+++ b/src/arch/portable.h
@@ -1,3 +1,14 @@
1#define STATIC_CUBE(c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl, \
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) \
3 ((cube_t) { \
4 .corner = { c_ufr, c_ubl, c_dfl, c_dbr, c_ufl, c_ubr, c_dfr, c_dbl }, \
5 .edge = { e_uf, e_ub, e_db, e_df, e_ur, e_ul, \
6 e_dl, e_dr, e_fr, e_fl, e_bl, e_br } })
7#define ZERO_CUBE STATIC_CUBE( \
8 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
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)
11
1STATIC void 12STATIC void
2pieces(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])
3{ 14{
@@ -5,44 +16,6 @@ pieces(cube_t *cube, uint8_t c[static 8], uint8_t e[static 12])
5 memcpy(e, cube->edge, 12); 16 memcpy(e, cube->edge, 12);
6} 17}
7 18
8STATIC_INLINE cube_t
9cubefrompieces(
10 uint8_t c_ufr,
11 uint8_t c_ubl,
12 uint8_t c_dfl,
13 uint8_t c_dbr,
14 uint8_t c_ufl,
15 uint8_t c_ubr,
16 uint8_t c_dfr,
17 uint8_t c_dbl,
18
19 uint8_t e_uf,
20 uint8_t e_ub,
21 uint8_t e_db,
22 uint8_t e_df,
23 uint8_t e_ur,
24 uint8_t e_ul,
25 uint8_t e_dl,
26 uint8_t e_dr,
27 uint8_t e_fr,
28 uint8_t e_fl,
29 uint8_t e_bl,
30 uint8_t e_br
31) {
32 cube_t ret = {
33 .corner = {
34 0, 0, 0, 0, 0, 0, 0, 0,
35 c_dbl, c_dfr, c_ubr, c_ufl, c_dbr, c_dfl, c_ubl, c_ufr
36 },
37 .edge = {
38 0, 0, 0, 0, e_br, e_bl, e_fl, e_fr,
39 e_dr, e_dl, e_ul, e_ur, e_df, e_db, e_ub, e_uf
40 }
41 };
42
43 return ret;
44}
45
46STATIC_INLINE bool 19STATIC_INLINE bool
47equal(cube_t c1, cube_t c2) 20equal(cube_t c1, cube_t c2)
48{ 21{

Generated with cgit - Back to sebastiano.tronto.net