From d6fdf14d5c320bdca455f910d58d652c5a7827da Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Fri, 17 Nov 2023 19:14:26 +0100 Subject: Simplified move and transform code --- utils/gentranscode.sh | 38 ++++++++++---------------------------- 1 file changed, 10 insertions(+), 28 deletions(-) (limited to 'utils/gentranscode.sh') diff --git a/utils/gentranscode.sh b/utils/gentranscode.sh index 198ac93..b9d41b6 100755 --- a/utils/gentranscode.sh +++ b/utils/gentranscode.sh @@ -5,38 +5,20 @@ type="${1:-src}" gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type" gcc -DDEBUG invert.c ../cube.c -o invert -# Old version -genarray() { - for f in transform_??_???.txt; do - trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" - printf '[%s] = ' "$trans" - if [ "$1" = "-i" ]; then - ./invert <"$f" | ./h48_to_"$type" - else - ./h48_to_"$type" <"$f" - fi - printf ',\n' - done -} +lineavx() { printf '#define _trans_cube_%s ' "$1"; } +linesrc() { printf '_static cube_fast_t _trans_cube_%s = ' "$1"; } +sedavx() { sed '1,2s/$/ \\/ ; 3s/$/)/ ; 3q'; } +sedsrc() { sed '3s/$/ };/ ; 3q'; } -genfuncs() { +gen() { for f in transform_??_???.txt; do trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" - printf 'static inline cube_fast_t\n_trans_%s' "$trans" - printf '(cube_fast_t c)\n{\n' - printf '\tcube_fast_t ret;\n\n' - printf '\tcube_fast_t tn = ' - ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/' - printf ';\n\tcube_fast_t ti = ' - ./invert <"$f" | ./h48_to_"$type" | sed '2,4 s/^/\t/' - printf ';\n\n\tret = compose_fast(tn, c);\n' - printf '\tret = compose_fast(ret, ti);\n' - if [ -n "$(echo "$trans" | grep "m")" ]; then - printf '\tret = invertco_fast(ret);\n' - fi - printf '\n\treturn ret;\n}\n\n' + line$type "$trans" + ./h48_to_"$type" <"$f" | sed$type + line$type "${trans}_inverse" + ./invert <"$f" | ./h48_to_"$type" | sed$type done } -genfuncs +gen rm -f h48_to_"$type" invert -- cgit v1.3