diff options
Diffstat (limited to '')
| -rwxr-xr-x | utils/gentranscode.sh | 25 | ||||
| -rw-r--r-- | utils/h48_to_avx.c | 19 |
2 files changed, 31 insertions, 13 deletions
diff --git a/utils/gentranscode.sh b/utils/gentranscode.sh index 63888c6..e874ad4 100755 --- a/utils/gentranscode.sh +++ b/utils/gentranscode.sh | |||
| @@ -1,6 +1,8 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | 2 | ||
| 3 | gcc -DDEBUG h48_to_src.c ../src/cube.c -o h48_to_src | 3 | type="${1:-src}" |
| 4 | |||
| 5 | gcc -DDEBUG h48_to_"$type".c ../src/cube.c -o h48_to_"$type" | ||
| 4 | gcc -DDEBUG invert.c ../src/cube.c -o invert | 6 | gcc -DDEBUG invert.c ../src/cube.c -o invert |
| 5 | 7 | ||
| 6 | # Old version | 8 | # Old version |
| @@ -9,9 +11,9 @@ genarray() { | |||
| 9 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" | 11 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" |
| 10 | printf '[%s] = ' "$trans" | 12 | printf '[%s] = ' "$trans" |
| 11 | if [ "$1" = "-i" ]; then | 13 | if [ "$1" = "-i" ]; then |
| 12 | ./invert <"$f" | ./h48_to_src | 14 | ./invert <"$f" | ./h48_to_"$type" |
| 13 | else | 15 | else |
| 14 | ./h48_to_src <"$f" | 16 | ./h48_to_"$type" <"$f" |
| 15 | fi | 17 | fi |
| 16 | printf ',\n' | 18 | printf ',\n' |
| 17 | done | 19 | done |
| @@ -23,15 +25,12 @@ genfuncs() { | |||
| 23 | printf 'static inline cube_t\ninline_trans_%s' "$trans" | 25 | printf 'static inline cube_t\ninline_trans_%s' "$trans" |
| 24 | [ "$1" = "-i" ] && printf '_inverse' | 26 | [ "$1" = "-i" ] && printf '_inverse' |
| 25 | printf '(cube_t c)\n{\n' | 27 | printf '(cube_t c)\n{\n' |
| 26 | printf '\tcube_t ret;\n' | 28 | printf '\tcube_t ret;\n\n' |
| 27 | printf '\tcube_t tn = {\n' | 29 | printf '\tcube_t tn = ' |
| 28 | ./h48_to_src <"$f" | sed 's/^/\t/' | \ | 30 | ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/' |
| 29 | tail -n 3 | head -n 2 | 31 | printf ';\n\tcube_t ti = ' |
| 30 | printf '\t};\n\tcube_t ti = {\n' | 32 | ./invert <"$f" | ./h48_to_"$type" | sed '2,4 s/^/\t/' |
| 31 | ./invert <"$f" | ./h48_to_src | sed 's/^/\t/' | \ | 33 | printf ';\n\n\tret = compose(tn, c);\n' |
| 32 | tail -n 3 | head -n 2 | ||
| 33 | printf '\t};\n\n' | ||
| 34 | printf '\tret = compose(tn, c);\n' | ||
| 35 | printf '\tret = compose(ret, ti);\n' | 34 | printf '\tret = compose(ret, ti);\n' |
| 36 | if [ -n "$(echo "$trans" | grep "m")" ]; then | 35 | if [ -n "$(echo "$trans" | grep "m")" ]; then |
| 37 | printf '\tret = flipallcorners(ret);\n' | 36 | printf '\tret = flipallcorners(ret);\n' |
| @@ -41,4 +40,4 @@ genfuncs() { | |||
| 41 | } | 40 | } |
| 42 | 41 | ||
| 43 | genfuncs | 42 | genfuncs |
| 44 | rm -f h48_to_src invert | 43 | rm -f h48_to_"$type" invert |
diff --git a/utils/h48_to_avx.c b/utils/h48_to_avx.c new file mode 100644 index 0000000..e1d8c2e --- /dev/null +++ b/utils/h48_to_avx.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #include <stdio.h> | ||
| 2 | #include <inttypes.h> | ||
| 3 | #include <stdbool.h> | ||
| 4 | |||
| 5 | #include "../src/cube.h" | ||
| 6 | |||
| 7 | #define STRLENMAX 1000 | ||
| 8 | |||
| 9 | int main() { | ||
| 10 | char str[STRLENMAX]; | ||
| 11 | cube_t cube; | ||
| 12 | |||
| 13 | fgets(str, STRLENMAX, stdin); | ||
| 14 | cube = readcube(H48, str); | ||
| 15 | writecube(AVX, cube, str); | ||
| 16 | fputs(str, stdout); | ||
| 17 | |||
| 18 | return 0; | ||
| 19 | } | ||
