This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 0/3] cond-optab merge


> If you happened to have written any scripts that could ease
> future similar testing (building/comparing assembly output for a
> regtest across the line), I suggest just sending them here.

Sure.  I had started writing some text about how to use it, then I
decided to stick it at the top of the file, so that it may even be
suitable for contrib:

# Compare the assembly language output for all the gcc tests.
# Copyright (C) 2009 Free Software Foundation, Inc.
# Contributed by Paolo Bonzini.
#
# Invoke it as "bash compare-all-tests arch1 arch2 ... archN".
# Assumptions are:
#
# 1) that the base and patched compilers reside respectively in
# base-$arch-build and $arch-build, where $arch is the commandline
# parameter and it should match the variables in the script itself.
# They both should be fully built (including target libraries).
#
# 2) that the testsuite has been run on the base compiler (since it's
# just compilation testing, using RUNTESTFLAGS=--target_board=basic-sim
# usually suffices).
#
# Tests that fail to compile on the base compiler are not compared.

I have a couple of other scripts that I attach and should not be hard to
understand, but those are too simple to be contributed.  They're called
*-fc because their input is in f.c :-) and they assume the same setup as
compare-all-tests.

Paolo
#! /bin/bash

# Compare the assembly language output for all the gcc tests.
# Copyright (C) 2009 Free Software Foundation, Inc.
# Contributed by Paolo Bonzini.
#
# Invoke it as "bash compare-all-tests arch1 arch2 ... archN".  Assumptions
# are:
#
# 1) that the base and patched compilers reside respectively in
# base-$arch-build and $arch-build, where $arch is the commandline parameter
# and it should match the variables in the script itself.  They both
# should be fully built (including target libraries).
# 
# 2) that the testsuite has been run on the base compiler (since it's
# just compilation testing, using RUNTESTFLAGS=--target_board=basic-sim
# usually suffices).
# 
# Tests that fail to compile on the base compiler are not compared.

test_one_file ()
{
  local bdir pdir opts bline pline
  bdir=base-$1-gcc-build
  pdir=$1-gcc-build
  bline=$2
  pline=${2//$bdir/$pdir}
  opts=${3//\// }
  echo "$pline $opts"
  $bline $opts 2>/dev/null >/dev/null || return 0
  diff -L "$bdir/gcc/cc1 $opts" -L "$pdir/gcc/cc1 $opts" -u \
    <( $bline $opts 2>&1 ) <( $pline $opts 2>&1 ) || { echo -n . >&2; return 1; }
}
  
test_all_opts ()
{
  eval opts=\$${1}_opts
  if test -z "$opts"; then
    test_one_file $1 "$2"
  else
    for opt in $opts; do
      test_one_file $1 "$2" $opt
    done
  fi
}

alpha_opts='-mlong-double-64/-mieee -mlong-double-64 -mlong-double-128/-mieee -mlong-double-128'
cris_opts='-march=v32 -march=v1'
m32c_opts='-mcpu=r8c -mcpu=m16c -mcpu=m32c'
m68k_opts='-m68000 -m68020 -m68020/-m68881 -m68040/-m68881 -m68060/-m68881 -mcfv4e'
sparc_opts='-mcpu=v8/-m32 -mcpu=v9/-m32'
sparc64_opts='-m64'
arm_opts='-mthumb/-march=armv5t -mthumb/-march=armv6t2 -march=armv5'
i386_opts='-m32 -m64 -m32/-msse/-msse2/-mfpmath=sse'
pa_opts='-march=2.0 -march=1.0 -march=1.1'
h8300_opts='/ -mh/-mn -ms/-mn -ms -msx -mint32 -mh/-mint32 -mh/-mn/-mint32 -ms/-mint32 -ms/-mn/-mint32 -msx/-mint32'
ppc_opts='-m32 -m64'
s390_opts='-m31 -m31/-mzarch -m64'
mn10300_opts='-mam33 -mam33-2'
score_opts='-mscore3 -mscore7'
sh_opts='-m3 -m3e -m4 -m4a -m4al -m4/-mieee -m1 -m1/-mno-cbranchdi -m2a -m2a/-mieee -m2e -m2e/-mieee'
sh64_opts='-m5-32media -m5-32media-nofpu -m5-64media -m5-64media-nofpu -m5-compact -m5-compact-nofpu'
mips64_opts='-msoft-float/-mgp32/-mips16 -mabi=32/-mfp32/-mgp32/-mips16 -mabi=o64/-mfp64/-mgp64/-mips16 -msoft-float/-mgp32 -mfp32/-mgp32 -march=mips64r2/-mabi=32/-mfp64/-mgp32 -msoft-float/-mgp64 -msingle-float/-mfp32/-mgp64 -mfp64/-mgp64'

all_archs='iq2000 m32c m32r m68hc11 mcore mmix picochip sh spu xstormy16 v850 xtensa cris crisv32 h8300 mips64 mn10300 crx ppc sparc sparc64 pdp11 vax avr score bfin ia64 m68k alpha pa sh64' # arm crx e500 fr30 frv

for arch in ${*-$all_archs}; do
  mkdir -p $arch-gcc-build/gcc/testsuite/gcc
  cp -R base-$arch-gcc-build/gcc/testsuite/gcc/gcc.dg-struct-layout-1 \
    $arch-gcc-build/gcc/testsuite/gcc/gcc.dg-struct-layout-1 

  # Provide targ-include files for newlib
  # for newlib_path in `echo base-$arch-gcc-build/*/newlib`; do
  #   test -d $newlib_path && ln -sf ../../$newlib_path ${newlib_path/base-}
  # done

  echo -n Testing $arch >&2
  sed '/^Executing on host: /!d
    /xgcc -B/!d
    / -E /d
    / -g/d
    / -print-prog-name=/d
    s/^Executing on host: //
    s/   *(timeout.*//
    s/ -fverbose-asm / /
    s/ -frtl-abstract-sequences / /
    s/ -fdump[-a-z0-9]* / /g
    s/ -da / /g
    s/ -\{1,2\}save-temps / /
    s/ -c / -S /
    / -S /! s/ -o / -S -o /
    s/ -o [^ ]*/ -frandom-seed=0 -o -/' base-$arch-gcc-build/gcc/testsuite/gcc/gcc.log | while read line; do
    case "$line" in
      *" -m"*) test_one_file $arch "$line" "" ;;
      *) test_all_opts $arch "$line" ;;
    esac
  done > compare-$arch.log
  echo >&2
done
bdir=base-$1-gcc-build
pdir=$1-gcc-build
shift

rm -rf new f.c.* f.s
mkdir new

if test -d old && test -f old/opts && test "`cat old/opts`" = "$pdir $*"; then
  :
else
  rm -rf old
  mkdir old
  echo $bdir/gcc/cc1 -quiet -fdump-noaddr "$@" f.c -da -o old/f.s
  $bdir/gcc/cc1 -quiet -fdump-noaddr "$@" f.c -da -o old/f.s
  mv f.c.* old
  echo "$pdir $*" > old/opts
fi

echo $pdir/gcc/cc1 -quiet -fdump-noaddr "$@" f.c -da -o new/f.s
$pdir/gcc/cc1 -quiet -fdump-noaddr "$@" f.c -da -o new/f.s
mv f.c.* new
echo "$pdir $*" > new/opts
diff -up old/f.s new/f.s
test_one_file ()
{
  local bdir pdir opts
  bdir=$1
  pdir=$2
  opts=`echo $3 | sed 's,/, ,g' `
  echo "$pdir/gcc/cc1 $opts"
  $bdir/gcc/cc1 -quiet $opts f.c 2>&1 || return 1
  diff -L "$bdir/gcc/cc1 $opts" -L "$pdir/gcc/cc1 $opts" -u \
    <( $bdir/gcc/cc1 -quiet $opts f.c -o $bdir-f.s 2>&1 ) \
    <( $pdir/gcc/cc1 -quiet $opts f.c -o $pdir-f.s 2>&1 ) || return 1
  diff -L "$bdir/gcc/cc1 $opts" -L "$pdir/gcc/cc1 $opts" -u $bdir-f.s $pdir-f.s
}
  
test_all_opts ()
{
  local bdir pdir opt
  bdir=base-$1-gcc-build
  pdir=$1-gcc-build
  eval opts=\$${1}_opts
  if test -z "$opts"; then
    test_one_file $bdir $pdir $2
  else
    for opt in $opts; do
      test_one_file $bdir $pdir $2/$opt
    done
  fi
  rm $bdir-f.s $pdir-f.s
}

alpha_opts='-mlong-double-64/-mieee -mlong-double-64 -mlong-double-128/-mieee -mlong-double-128'
cris_opts='-march=v32 -march=v1'
m32c_opts='-mcpu=r8c -mcpu=m16c -mcpu=m32c'
m68k_opts='-m68000 -m68020 -m68020/-m68881 -m68040/-m68881 -m68060/-m68881 -mcfv4e'
sparc_opts='-mcpu=v8/-m32 -mcpu=v9/-m32'
sparc64_opts='-m64'
arm_opts='-mthumb/-march=armv5t -mthumb/-march=armv6t2 -march=armv5'
i386_opts='-m32 -m64 -m32/-msse/-msse2/-mfpmath=sse'
pa_opts='-march=2.0 -march=1.0 -march=1.1'
h8300_opts='/ -mh/-mn -ms/-mn -ms -msx -mint32 -mh/-mint32 -mh/-mn/-mint32 -ms/-mint32 -ms/-mn/-mint32 -msx/-mint32'
ppc_opts='-m32 -m64'
s390_opts='-m31 -m31/-mzarch -m64'
mn10300_opts='-mam33 -mam33-2'
score_opts='-mscore3 -mscore7'
sh_opts='-m3 -m3e -m4 -m4a -m4al -m4/-mieee -m1 -m1/-mno-cbranchdi -m2a -m2a/-mieee -m2e -m2e/-mieee'
sh64_opts='-m5-32media -m5-32media-nofpu -m5-64media -m5-64media-nofpu -m5-compact -m5-compact-nofpu'
mips64_opts='-msoft-float/-mgp32/-mips16 -mabi=32/-mfp32/-mgp32/-mips16 -mabi=o64/-mfp64/-mgp64/-mips16 -msoft-float/-mgp32 -mfp32/-mgp32 -march=mips64r2/-mabi=32/-mfp64/-mgp32 -msoft-float/-mgp64 -msingle-float/-mfp32/-mgp64 -mfp64/-mgp64'

all_archs='m32c crx mmix xstormy16 fr30 arc pdp11 vax v850 xtensa m32r iq2000 picochip mn10300 mcore avr score bfin cris spu h8300 mips64 ia64 m68hc11 m68k sparc alpha frv pa arm ppc e500 i386 s390 sh sh64'

for arch in ${*-$all_archs}; do
  for Oopt in -O0 -O1 -O2 -O3 -Os; do
    test_all_opts $arch $Oopt
  done
done

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]