--- tme/ic/ieee754/ieee754-ops-auto.sh 2018/04/24 16:40:26 1.1 +++ tme/ic/ieee754/ieee754-ops-auto.sh 2018/04/24 16:42:03 1.1.1.2 @@ -1,6 +1,6 @@ #! /bin/sh -# $Id: ieee754-ops-auto.sh,v 1.1 2018/04/24 16:40:26 root Exp $ +# $Id: ieee754-ops-auto.sh,v 1.1.1.2 2018/04/24 16:42:03 root Exp $ # ic/ieee754/ieee754-misc-auto.sh - automatically generates C code # for IEEE 754 emulation operations: @@ -49,7 +49,7 @@ PROG=`basename $0` cat < -_TME_RCSID("\$Id: ieee754-ops-auto.sh,v 1.1 2018/04/24 16:40:26 root Exp $"); +_TME_RCSID("\$Id: ieee754-ops-auto.sh,v 1.1.1.2 2018/04/24 16:42:03 root Exp $"); EOF if $header; then @@ -136,6 +136,7 @@ for level in ${levels}; do getexp getman scale \ pow \ from_single from_double from_extended80 from_quad \ + from_int32 from_int64 \ to_int32 to_int64 \ ; do @@ -148,8 +149,11 @@ for level in ${levels}; do monadic=false ;; esac + src_type="struct tme_float *" dst_type="struct tme_float" case "${name}" in + from_int32) src_type="tme_int32_t " ;; + from_int64) src_type="tme_int64_t " ;; to_int32) dst_type="tme_int32_t" ;; esac @@ -180,7 +184,7 @@ for level in ${levels}; do if $monadic; then :; else echo -n "_tme_const struct tme_float *, " fi - echo "_tme_const struct tme_float *, ${dst_type} *));" + echo "_tme_const ${src_type}, ${dst_type} *));" fi continue @@ -214,6 +218,8 @@ for level in ${levels}; do # the function type. it can be overridden: # cond= + cond_int64= + cond_builtin_match= # assume that we will use the operands as passed # in. the precisions will later default to the @@ -248,8 +254,8 @@ for level in ${levels}; do *-div) op_builtin='/' ;; *-sqrt) func_libm=sqrt ;; partial-abs | unknown-abs) func_libm=fabs ;; - strict-neg) op0=0 ; func_softfloat=sub ; op1=src0 ;; - partial-neg | unknown-neg) op0=0 ; op_builtin='-'; op1=src0 ;; + strict-neg) op0=-1 ; func_softfloat=mul ; op1=src0 ;; + partial-neg | unknown-neg) op0=-1 ; op_builtin='*'; op1=src0 ;; strict-move) func_softfloat=add ; op1=0 ;; *-move) type="${level_stricter}-move" ; src0_buffer=false ;; strict-rint) func_softfloat=round_to_int ;; @@ -281,6 +287,11 @@ for level in ${levels}; do # whether or not the function can be emitted: # if test "x${cond}" = x; then + + # assume that this function can be unconditionally emitted: + # + cond=1 + case "${precision}-${level_stricter}-${type}" in # a function with a none type can't be emitted: @@ -291,19 +302,25 @@ for level in ${levels}; do # functions are conditional on a 64-bit # integral type: # - extended80-*-softfloat | quad-*-softfloat) cond="defined(TME_HAVE_INT64_T)" ;; + extended80-*-softfloat | quad-*-softfloat) cond_int64=true ;; # partial compliance functions are conditional # on the builtin type being an exact match for # the IEEE 754 type: # - *-partial-*) cond="(TME_FLOAT_FORMAT_IEEE754_${capprecision}_BUILTIN == TME_FLOAT_FORMAT_IEEE754_${capprecision})" ;; - - # assume that anything else can be unconditionally emitted: - # - *) cond=1 ;; + *-partial-*) cond_builtin_match=true ;; esac fi + case "${src_type}" in tme_int64_t*) cond_int64=true ;; esac + case "${dst_type}" in tme_int64_t*) cond_int64=true ;; esac + if test "x${cond_int64}" != x; then + cond="${cond} && defined(TME_HAVE_INT64_T)" + fi + if test "x${cond_builtin_match}" != x; then + cond="${cond} && (TME_FLOAT_FORMAT_IEEE754_${capprecision}_BUILTIN == TME_FLOAT_FORMAT_IEEE754_${capprecision})" + fi + eval "cond=\`echo '${cond}' | sed -e 's%^1 && %%'\`" + case "${cond}" in 0*) cond=0 ;; esac # finish the operands: # @@ -316,6 +333,13 @@ for level in ${levels}; do if test "x${opn_precision}" = x; then opn_precision="${precision}" fi + case "${opn_precision}" in + int32 | int64) + check_nan=false + eval "op${_opn}_precision_sf=\$opn_precision" + continue + ;; + esac eval `sh ${ieee754_precision_sh} ${opn_precision} opn_` case "${opn}" in src[01]) @@ -334,7 +358,7 @@ for level in ${levels}; do opn="tme_ieee754_${opn_precision}_value_builtin_get(${opn})" fi ;; - [0-9]) + [0-9] | -[0-9]) if test "x${func_softfloat}" != x; then opn="int32_to_${opn_precision_sf}(${opn})" fi @@ -394,7 +418,7 @@ for level in ${levels}; do echo "" echo "/* this does a ${level} compliance ${precision}-precision "`echo ${name} | tr _ -`": */" echo "static void" - echo -n "${func}(struct tme_ieee754_ctl *ieee754_ctl, const struct tme_float *src0, " + echo -n "${func}(struct tme_ieee754_ctl *ieee754_ctl, const ${src_type}src0, " if $monadic; then :; else echo -n "const struct tme_float *src1, " fi @@ -515,7 +539,7 @@ for level in ${levels}; do echo " _tme_ieee754_${precision}_value_set(dst, ${precision_sf}," func_softfloat_raw="${func_softfloat}" func_softfloat=`echo ${func_softfloat} | sed -e "s/OP0_PRECISION_SF/${op0_precision_sf}/g"` - func_softfloat=`echo ${func_softfloat} | sed -e "s/OP1_PRECISION_SF/${op0_precision_sf}/g"` + func_softfloat=`echo ${func_softfloat} | sed -e "s/OP1_PRECISION_SF/${op1_precision_sf}/g"` if test "${func_softfloat}" = "${func_softfloat_raw}"; then func_softfloat="${precision_sf}_${func_softfloat}" fi