aboutsummaryrefslogtreecommitdiff
path: root/extract-function.sh
diff options
context:
space:
mode:
authorGravatar Jason Gross <jgross@mit.edu>2017-09-12 15:28:20 -0400
committerGravatar Jason Gross <jgross@mit.edu>2017-09-12 15:28:20 -0400
commit284a3d5aa23aa17f9fcdcccc378c350ea3a88a24 (patch)
tree7c0986093b2ee9b5da5ba793f69dc4152db11e59 /extract-function.sh
parentf3fc04880bfdacfb6744355851c559d0b954c61b (diff)
Update extract-function.sh for inline asm
It needs to use printf rather than echo to not interpret \n, \t, and it needs to not insert { and } everywhere.
Diffstat (limited to 'extract-function.sh')
-rwxr-xr-xextract-function.sh13
1 files changed, 9 insertions, 4 deletions
diff --git a/extract-function.sh b/extract-function.sh
index b99862405..b19adcd76 100755
--- a/extract-function.sh
+++ b/extract-function.sh
@@ -36,6 +36,12 @@ EOF
lines=0
show=false
+brace='{ '
+close_brace='}'
+if [ ! -z "${FIAT_CRYPTO_EXTRACT_FUNCTION_IS_ASM}" ]; then
+ brace=''
+ close_brace=''
+fi
while IFS= read -r line; do
case "$line" in
*"λ '"*)
@@ -57,7 +63,7 @@ while IFS= read -r line; do
i=$((i+1))
done;
seq 2 "$lines" | while IFS= read -r _; do
- echo -n "}"
+ echo -n "${close_brace}"
done
echo "}"
echo "// caller: uint64_t out[$i];" )
@@ -68,14 +74,13 @@ while IFS= read -r line; do
case "$show" in
true)
lines=$((lines+1))
- line="$(echo "$line" | \
+ line="$(printf "%s" "$line" | \
sed s':^\([^,]*\),\(\s*\)\([^ ]*\) \([^ ]*\)\(.*\)\(mulx.*\))\([; ]*\)$: \3 \4;\2\1\5_\6, \&\4)\7:' | \
sed s':^\([^,]*\) \([^, ]*\)\(\s*\),\(.*\)\(addcarryx.*\))\([; ]*\)$:\1 \2\3;\4_\5, \&\2)\6:' | \
sed s':^\([^,]*\) \([^, ]*\)\(\s*\),\(.*\)\(subborrow.*\))\([; ]*\)$:\1 \2\3;\4_\5, \&\2)\6:')"
- echo "{ $line"
+ printf "%s%s\n" "${brace}" "${line}"
;;
esac
;;
esac
done
-