From 3ac0842f29dd05e1265377108335ac5e7c1b0692 Mon Sep 17 00:00:00 2001 From: chaoyingfu Date: Mon, 17 Sep 2007 22:18:13 +0000 Subject: [PATCH] * fixed-obj.mk: New file to support fine-grain fixed-point functions. * Makefile.in (fixed_point): Define. Check if fixed_point is yes to build support functions. * configure.ac: Check for fixed_point support. * configure: Regenerated. * gen-fixed.sh: New file to generate lists of fixed-point labels, funcs, modes, from, to. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128557 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgcc/ChangeLog | 11 ++++++ libgcc/Makefile.in | 43 +++++++++++++++++++++ libgcc/configure | 48 +++++++++++++++++++++++- libgcc/configure.ac | 7 ++++ libgcc/fixed-obj.mk | 31 ++++++++++++++++ libgcc/gen-fixed.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 libgcc/fixed-obj.mk create mode 100644 libgcc/gen-fixed.sh diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index cc5d41c632b..59ccf6a7934 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,14 @@ +2007-09-17 Chao-ying Fu + Nigel Stephens + + * fixed-obj.mk: New file to support fine-grain fixed-point functions. + * Makefile.in (fixed_point): Define. + Check if fixed_point is yes to build support functions. + * configure.ac: Check for fixed_point support. + * configure: Regenerated. + * gen-fixed.sh: New file to generate lists of fixed-point labels, + funcs, modes, from, to. + 2007-09-11 Janis Johnson &5 +echo $ECHO_N "checking whether fixed-point is supported... $ECHO_C" >&6 +if test "${libgcc_cv_fixed_point+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +_Sat _Fract x; +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + libgcc_cv_fixed_point=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +libgcc_cv_fixed_point=no +fi +rm -f conftest.err conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $libgcc_cv_fixed_point" >&5 +echo "${ECHO_T}$libgcc_cv_fixed_point" >&6 +fixed_point=$libgcc_cv_fixed_point + + # Collect host-machine-specific information. . ${srcdir}/config.host @@ -4152,6 +4197,7 @@ s,@OBJEXT@,$OBJEXT,;t t s,@CPP@,$CPP,;t t s,@decimal_float@,$decimal_float,;t t s,@enable_decimal_float@,$enable_decimal_float,;t t +s,@fixed_point@,$fixed_point,;t t s,@vis_hide@,$vis_hide,;t t s,@set_have_cc_tls@,$set_have_cc_tls,;t t s,@tmake_file@,$tmake_file,;t t diff --git a/libgcc/configure.ac b/libgcc/configure.ac index 0a8d235a744..6ab7ebf3948 100644 --- a/libgcc/configure.ac +++ b/libgcc/configure.ac @@ -145,6 +145,13 @@ if test x$enable_decimal_float = xyes; then fi AC_SUBST(enable_decimal_float) +# Check for fixed-point support. +AC_CACHE_CHECK([whether fixed-point is supported], [libgcc_cv_fixed_point], + [AC_COMPILE_IFELSE([_Sat _Fract x;], [libgcc_cv_fixed_point=yes], + [libgcc_cv_fixed_point=no])]) +fixed_point=$libgcc_cv_fixed_point +AC_SUBST(fixed_point) + # Collect host-machine-specific information. . ${srcdir}/config.host diff --git a/libgcc/fixed-obj.mk b/libgcc/fixed-obj.mk new file mode 100644 index 00000000000..3c7c2f3173e --- /dev/null +++ b/libgcc/fixed-obj.mk @@ -0,0 +1,31 @@ +# This file is included several times in a row, once for each element of +# $(iter-items). On each inclusion, we advance $o to the next element. +# $(iter-labels) and $(iter-from) and $(iter-to) are also advanced. + +o := $(firstword $(iter-items)) +iter-items := $(filter-out $o,$(iter-items)) + +$o-label := $(firstword $(iter-labels)) +iter-labels := $(wordlist 2,$(words $(iter-labels)),$(iter-labels)) + +$o-from := $(firstword $(iter-from)) +iter-from := $(wordlist 2,$(words $(iter-from)),$(iter-from)) + +$o-to := $(firstword $(iter-to)) +iter-to := $(wordlist 2,$(words $(iter-to)),$(iter-to)) + +ifeq ($($o-from),$($o-to)) +$o-opt := -D$($o-from)_MODE +else +$o-opt := -DFROM_$($o-from) -DTO_$($o-to) +endif + +#$(info $o$(objext): -DL$($o-label) $($o-opt)) + +$o$(objext): %$(objext): $(gcc_srcdir)/config/fixed-bit.c + $(gcc_compile) -DL$($*-label) $($*-opt) -c $(gcc_srcdir)/config/fixed-bit.c $(vis_hide) + +ifeq ($(enable_shared),yes) +$(o)_s$(objext): %_s$(objext): $(gcc_srcdir)/config/fixed-bit.c + $(gcc_s_compile) -DL$($*-label) $($*-opt) -c $(gcc_srcdir)/config/fixed-bit.c +endif diff --git a/libgcc/gen-fixed.sh b/libgcc/gen-fixed.sh new file mode 100644 index 00000000000..77499611070 --- /dev/null +++ b/libgcc/gen-fixed.sh @@ -0,0 +1,105 @@ +#!/bin/sh + +# Worker script for libgcc/Makefile.in +# Generate lists of fixed-point labels, funcs, modes, from, to. +# Usage: +# gen-fixed.sh arith labels +# gen-fixed.sh arith funcs +# gen-fixed.sh arith modes +# gen-fixed.sh conv labels +# gen-fixed.sh conv funcs +# gen-fixed.sh conv from +# gen-fixed.sh conv to + +fixed_sfract_modes="QQ HQ SQ DQ TQ HA SA DA TA" +fixed_ufract_modes="UQQ UHQ USQ UDQ UTQ UHA USA UDA UTA" +fixed_fract_modes="$fixed_sfract_modes $fixed_ufract_modes" + +fixed_signed_modes="QI HI SI DI TI SF DF" +fixed_unsigned_modes="UQI UHI USI UDI UTI" + +fixed_func_names="_add _sub _neg _mul _mulhelper _divhelper _ashl _ashlhelper _cmp _saturate1 _saturate2" +fixed_sfunc_names="_ssadd _sssub _ssneg _ssmul _ssdiv _div _ssashl _ashr" +fixed_ufunc_names="_usadd _ussub _usneg _usmul _usdiv _udiv _usashl _lshr" + +# emit the function information +# $1 = output type selector +# $2 = base function name +# $3 = from mode +# $4 = to mode +emit () +{ + if [ "$3" != "$4" ]; then + case "$1" in + labels) + echo $2 ;; + from | modes) + echo $3 ;; + to) + echo $4 ;; + funcs) + echo $2$3$4 ;; + esac + fi +} + +case "$1" in + arith) + for n in $fixed_func_names; do + for m in $fixed_fract_modes; do + emit $2 $n $m + done + done + + for n in $fixed_sfunc_names; do + for m in $fixed_sfract_modes; do + emit $2 $n $m + done + done + + for n in $fixed_ufunc_names; do + for m in $fixed_ufract_modes; do + emit $2 $n $m + done + done + ;; + + conv) + for f in $fixed_fract_modes; do + for t in $fixed_fract_modes $fixed_signed_modes; do + emit $2 _fract $f $t + done + done + + for f in $fixed_signed_modes; do + for t in $fixed_fract_modes; do + emit $2 _fract $f $t + done + done + + for f in $fixed_fract_modes $fixed_signed_modes; do + for t in $fixed_fract_modes; do + emit $2 _satfract $f $t + done + done + + for f in $fixed_fract_modes; do + for t in $fixed_unsigned_modes; do + emit $2 _fractuns $f $t + done + done + + for f in $fixed_unsigned_modes; do + for t in $fixed_fract_modes; do + emit $2 _fractuns $f $t + done + done + + for f in $fixed_unsigned_modes; do + for t in $fixed_fract_modes; do + emit $2 _satfractuns $f $t + done + done + ;; + +esac -- 2.11.0