| 1 | #! /bin/sh |
| 2 | |
| 3 | # Utility to change the number of GVM registers. |
| 4 | # |
| 5 | # Usage: change-gvm-regs nb-gvm-regs nb-arg-regs |
| 6 | # |
| 7 | # The setting nb-gvm-regs=5 and nb-arg-regs=3 has been used |
| 8 | # for many years, but the best setting depends on the processor. |
| 9 | |
| 10 | NB_GVM_REGS=$1 |
| 11 | NB_ARG_REGS=$2 |
| 12 | CONFIGURE_OPTIONS=$3 |
| 13 | |
| 14 | if [ "$NB_GVM_REGS" == "" ] |
| 15 | then |
| 16 | NB_GVM_REGS=5 |
| 17 | fi |
| 18 | |
| 19 | if [ $NB_GVM_REGS -lt 3 -o $NB_GVM_REGS -gt 25 ] |
| 20 | then |
| 21 | echo "usage: change-gvm-regs nb-gvm-regs nb-arg-regs" |
| 22 | echo "nb-gvm-regs must be between 3 and 25" |
| 23 | exit 1 |
| 24 | fi |
| 25 | |
| 26 | if [ "$NB_ARG_REGS" == "" ] |
| 27 | then |
| 28 | NB_ARG_REGS=`eval expr $NB_GVM_REGS - 2` |
| 29 | fi |
| 30 | |
| 31 | if [ $NB_ARG_REGS -lt 1 -o $NB_ARG_REGS -gt 12 -o $NB_ARG_REGS -gt `eval expr $NB_GVM_REGS - 2` ] |
| 32 | then |
| 33 | echo "usage: change-gvm-regs nb-gvm-regs nb-arg-regs" |
| 34 | echo "nb-arg-regs must be between 1 and min(12, nb-gvm-regs - 2)" |
| 35 | exit 1 |
| 36 | fi |
| 37 | |
| 38 | echo "***************************** new settings: nb-gvm-regs=$NB_GVM_REGS nb-arg-regs=$NB_ARG_REGS" |
| 39 | |
| 40 | if ! make bootclean > /dev/null 2>&1 |
| 41 | then |
| 42 | echo "***************************** 'make bootclean' failed" |
| 43 | exit 1 |
| 44 | fi |
| 45 | |
| 46 | echo "***************************** updating include/gambit.h.in and gsc/_t-c-1.scm" |
| 47 | |
| 48 | sed -e "s/#define ___NB_GVM_REGS .*/#define ___NB_GVM_REGS $NB_GVM_REGS/g" -e "s/#define ___NB_ARG_REGS .*/#define ___NB_ARG_REGS $NB_ARG_REGS/g" include/gambit.h.in > gambit.h.in-new |
| 49 | |
| 50 | diff include/gambit.h.in gambit.h.in-new |
| 51 | |
| 52 | sed -e "s/(define targ-default-nb-gvm-regs [0-9]*)/(define targ-default-nb-gvm-regs $NB_GVM_REGS)/g" -e "s/(define targ-default-nb-arg-regs [0-9]*)/(define targ-default-nb-arg-regs $NB_ARG_REGS)/g" gsc/_t-c-1.scm > _t-c-1.scm-new |
| 53 | |
| 54 | diff gsc/_t-c-1.scm _t-c-1.scm-new |
| 55 | |
| 56 | mv gambit.h.in-new include/gambit.h.in |
| 57 | mv _t-c-1.scm-new gsc/_t-c-1.scm |
| 58 | |
| 59 | echo "***************************** configuring new settings for bootstrap" |
| 60 | |
| 61 | if ! ./configure --enable-single-host $CONFIGURE_OPTIONS COMPILATION_OPTIONS="-nb-gvm-regs $NB_GVM_REGS -nb-arg-regs $NB_ARG_REGS" |
| 62 | then |
| 63 | echo "***************************** './configure --enable-single-host $CONFIGURE_OPTIONS COMPILATION_OPTIONS=\"-nb-gvm-regs $NB_GVM_REGS -nb-arg-regs $NB_ARG_REGS\"' failed" |
| 64 | exit 1 |
| 65 | fi |
| 66 | |
| 67 | echo "***************************** generating .c from .scm using new settings" |
| 68 | |
| 69 | if ! make -j |
| 70 | then |
| 71 | echo "***************************** 'make -j' failed" |
| 72 | exit 1 |
| 73 | fi |
| 74 | |
| 75 | echo "***************************** checking that the new settings work" |
| 76 | |
| 77 | if ! make check |
| 78 | then |
| 79 | echo "***************************** 'make check' failed" |
| 80 | exit 1 |
| 81 | fi |
| 82 | |
| 83 | echo "***************************** it appears that the new settings work" |
| 84 | echo "***************************** and that it is safe to do a 'make bootstrap' now" |