Branch: Tag:

1997-01-27

1997-01-27 08:11:44 by Per Hedbor <ph@opera.com>

configure.in: Added support for a number of optimization options
to gcc and other cc compilers.
With gcc:
On all CPUs:
-O2 and -funroll-loops are tried

On sparclite (sun4c): -msparclite
On microsparc (sun4m): -mv8
On supersparcs and ultrasparcs (sun4d and sun4u): -msupersparc

This is more or less equivavalent to the -native option in
many cc compilers.

The generated binary will work on all sparcs, but it will be
optimized for the sparc it was compiled on. -mv8 gives an
speed improvment of about 200% in the image module on a Sparc
Station 4, and -msupersparc gives almost 300% on an ultra.

There is no support in gcc for ultrasparc native code.

If GCC had had v8 as a default sparc-instruction set, this
hazzle would not really have been neccesary. It currently uses
the v7 set, but there are not all that many v7's out there today.

With other compilers:
On all CPUs:
-O, -fast and -native
(for apcc): -XO=5, -Xcallmod=2
sun4m: -Xpipe=micro
sun4d and sun4u: -Xpipe=super

There is probably a need for more optimization options for other
CPUs than sparc.

Rev: src/configure.in:1.49

1: - AC_REVISION("$Id: configure.in,v 1.48 1997/01/27 01:10:29 hubbe Exp $") + AC_REVISION("$Id: configure.in,v 1.49 1997/01/27 08:11:44 per Exp $")   AC_INIT(interpret.c)   AC_CONFIG_HEADER(machine.h)   
21:   fi      AC_PROG_CC + AC_ISC_POSIX + AC_MINIX    -  +    AC_ARG_WITH(gdbm, [ --without-gdbm no GNU database manager support ])   AC_ARG_WITH(gmp, [ --without-gmp no Support bignums])   AC_ARG_WITH(readline,[ --without-readline no support for command line editing])
59:   #############################################################################       +  + AC_DEFUN(AC_SYS_COMPILER_FLAG, + [ +  AC_MSG_CHECKING($1) +  AC_CACHE_VAL(pike_cv_option_$2, +  [ +  CFLAGS="[$]OLD_CFLAGS $1" +  AC_TRY_COMPILE([],[],pike_cv_option_$2=yes,pike_cv_option_$2=no) +  ]) +  +  CFLAGS="[$]OLD_CFLAGS" +  +  if test x"[$]pike_cv_option_$2" = "xyes" ; then +  OPTIMIZE="[$]OPTIMIZE $1" +  AC_MSG_RESULT(yes) +  else +  AC_MSG_RESULT(no) +  fi + ]) +  + AC_DEFUN(AC_SYS_CPU_COMPILER_FLAG, + [ +  if test "`uname -m 2>/dev/null`" = "$1" ; then +  AC_SYS_COMPILER_FLAG($2,$3) +  fi + ]) +    WARN=""   OPTIMIZE="" -  +    if test $cflags_is_set = no; then    if test "x${GCC-}" = xyes ; then    WARN="-W -Wformat" -  + ### Optimize for different SUN machines. If there is no working 'uname' + ### no extra optimization will be done, but nothing should break either. +  AC_SYS_CPU_COMPILER_FLAG(sun4c,-msparclite,sparclite) +  AC_SYS_CPU_COMPILER_FLAG(sun4m,-mv8,microsparc) +  AC_SYS_CPU_COMPILER_FLAG(sun4d,-msupersparc,supersparc) +  AC_SYS_CPU_COMPILER_FLAG(sun4u,-msupersparc,ultrasparc) +  + ### Generic GCC options. O2 and -funroll-loops makes some code _much_ faster, + ### especially the image module. +  AC_SYS_COMPILER_FLAG(-O2,O2) +  AC_SYS_COMPILER_FLAG(-funroll-loops,unroll_loops)    else -  OLD_CFLAGS="$CFLAGS" -  OPTIMIZE=""; +     -  AC_MSG_CHECKING(-fast) -  AC_CACHE_VAL(pike_cv_option_fast, -  [ -  CFLAGS="$OLD_CFLAGS -fast" -  AC_TRY_COMPILE([],[],pike_cv_option_fast=yes,pike_cv_option_fast=no) -  ]) + ### Non-gcc thingies. This should probably be enhanced... +  AC_SYS_COMPILER_FLAG(-fast,fast) +  AC_SYS_COMPILER_FLAG(-native,native)    -  CFLAGS="$OLD_CFLAGS" + ### Ok. This is for apcc... +  AC_SYS_COMPILER_FLAG(-XO=5,apcc_opt) +  AC_SYS_COMPILER_FLAG(-Xcallmod=2,apcc_opt_2)    -  if test "$pike_cv_option_fast" = "yes" ; then -  OPTIMIZE="$OPTIMIZE -fast" -  AC_MSG_RESULT(-fast found) -  else -  AC_MSG_RESULT(-fast not found) +     -  +  AC_SYS_CPU_COMPILER_FLAG(sun4m,-Xpipe=micro,microsparc) +  AC_SYS_CPU_COMPILER_FLAG(sun4d,-Xpipe=super,supersparc) +  AC_SYS_CPU_COMPILER_FLAG(sun4u,-Xpipe=super,ultrasparc) +     case "${CFLAGS-}" in    *-O*) ;;    *) -  AC_MSG_CHECKING(-O) -  AC_CACHE_VAL(pike_cv_option_opt, -  [ -  CFLAGS="$OLD_CFLAGS -O" -  AC_TRY_COMPILE([],[],pike_cv_option_opt=yes,pike_cv_option_opt=no) -  ]) -  -  if test "$pike_cv_option_opt" = "yes" ; then -  CFLAGS="$OLD_CFLAGS -O" -  OPTIMIZE="$OPTIMIZE -O" -  AC_MSG_RESULT(-O found) -  else -  AC_MSG_RESULT(-O not found) -  fi -  -  CFLAGS="$OLD_CFLAGS" +  AC_SYS_COMPILER_FLAG(-O,O)    ;;    esac    fi   fi - fi +