diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-17 19:14:26 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2023-11-17 19:14:26 +0100 |
| commit | d6fdf14d5c320bdca455f910d58d652c5a7827da (patch) | |
| tree | 15642a013e719e81526cf02b6656ce22adb8a3cf /utils/gentranscode.sh | |
| parent | a26ae103faf8fa53b65f7757fb8b4255a37fcd22 (diff) | |
| download | nissy-core-d6fdf14d5c320bdca455f910d58d652c5a7827da.tar.gz nissy-core-d6fdf14d5c320bdca455f910d58d652c5a7827da.zip | |
Simplified move and transform code
Diffstat (limited to 'utils/gentranscode.sh')
| -rwxr-xr-x | utils/gentranscode.sh | 38 |
1 files changed, 10 insertions, 28 deletions
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}" | |||
| 5 | gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type" | 5 | gcc -DDEBUG h48_to_"$type".c ../cube.c -o h48_to_"$type" |
| 6 | gcc -DDEBUG invert.c ../cube.c -o invert | 6 | gcc -DDEBUG invert.c ../cube.c -o invert |
| 7 | 7 | ||
| 8 | # Old version | 8 | lineavx() { printf '#define _trans_cube_%s ' "$1"; } |
| 9 | genarray() { | 9 | linesrc() { printf '_static cube_fast_t _trans_cube_%s = ' "$1"; } |
| 10 | for f in transform_??_???.txt; do | 10 | sedavx() { sed '1,2s/$/ \\/ ; 3s/$/)/ ; 3q'; } |
| 11 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" | 11 | sedsrc() { sed '3s/$/ };/ ; 3q'; } |
| 12 | printf '[%s] = ' "$trans" | ||
| 13 | if [ "$1" = "-i" ]; then | ||
| 14 | ./invert <"$f" | ./h48_to_"$type" | ||
| 15 | else | ||
| 16 | ./h48_to_"$type" <"$f" | ||
| 17 | fi | ||
| 18 | printf ',\n' | ||
| 19 | done | ||
| 20 | } | ||
| 21 | 12 | ||
| 22 | genfuncs() { | 13 | gen() { |
| 23 | for f in transform_??_???.txt; do | 14 | for f in transform_??_???.txt; do |
| 24 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" | 15 | trans="$(echo $f | sed 's/.*_// ; s/\.txt//')" |
| 25 | printf 'static inline cube_fast_t\n_trans_%s' "$trans" | 16 | line$type "$trans" |
| 26 | printf '(cube_fast_t c)\n{\n' | 17 | ./h48_to_"$type" <"$f" | sed$type |
| 27 | printf '\tcube_fast_t ret;\n\n' | 18 | line$type "${trans}_inverse" |
| 28 | printf '\tcube_fast_t tn = ' | 19 | ./invert <"$f" | ./h48_to_"$type" | sed$type |
| 29 | ./h48_to_"$type" <"$f" | sed '2,4s/^/\t/' | ||
| 30 | printf ';\n\tcube_fast_t ti = ' | ||
| 31 | ./invert <"$f" | ./h48_to_"$type" | sed '2,4 s/^/\t/' | ||
| 32 | printf ';\n\n\tret = compose_fast(tn, c);\n' | ||
| 33 | printf '\tret = compose_fast(ret, ti);\n' | ||
| 34 | if [ -n "$(echo "$trans" | grep "m")" ]; then | ||
| 35 | printf '\tret = invertco_fast(ret);\n' | ||
| 36 | fi | ||
| 37 | printf '\n\treturn ret;\n}\n\n' | ||
| 38 | done | 20 | done |
| 39 | } | 21 | } |
| 40 | 22 | ||
| 41 | genfuncs | 23 | gen |
| 42 | rm -f h48_to_"$type" invert | 24 | rm -f h48_to_"$type" invert |
