diff options
author | Tom de Vries <tom@codesourcery.com> | 2011-04-07 09:28:11 +0000 |
---|---|---|
committer | Tom de Vries <vries@gcc.gnu.org> | 2011-04-07 09:28:11 +0000 |
commit | c7a69ce198cb28d64bfb2864fb6d3a1d57df5a7d (patch) | |
tree | 1c3164608f71336e857b8505a86236c9e809154c /gcc | |
parent | 823918aef31c377e62be41dc4712aea11d82ef69 (diff) | |
download | gcc-c7a69ce198cb28d64bfb2864fb6d3a1d57df5a7d.zip gcc-c7a69ce198cb28d64bfb2864fb6d3a1d57df5a7d.tar.gz gcc-c7a69ce198cb28d64bfb2864fb6d3a1d57df5a7d.tar.bz2 |
re PR target/43920 (Choosing conditional execution over conditional branches for code size in some cases.)
2011-04-07 Tom de Vries <tom@codesourcery.com>
PR target/43920
* lib/scanasm.exp (object-size): New proc.
* gcc.target/arm/pr43920-2.c: New test.
From-SVN: r172093
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arm/pr43920-2.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/lib/scanasm.exp | 86 |
3 files changed, 122 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e3de373..6c4b6b3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-04-07 Tom de Vries <tom@codesourcery.com> + + PR target/43920 + * lib/scanasm.exp (object-size): New proc. + * gcc.target/arm/pr43920-2.c: New test. + 2011-04-06 Tobias Burnus <burnus@net-b.de> PR fortran/18918 diff --git a/gcc/testsuite/gcc.target/arm/pr43920-2.c b/gcc/testsuite/gcc.target/arm/pr43920-2.c new file mode 100644 index 0000000..f647165 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pr43920-2.c @@ -0,0 +1,30 @@ +/* { dg-do assemble } */ +/* { dg-options "-mthumb -Os -save-temps" } */ +/* { dg-require-effective-target arm_thumb2_ok } */ + +#include <stdio.h> + +int getFileStartAndLength (int fd, int *start_, size_t *length_) +{ + int start, end; + size_t length; + + start = lseek (fd, 0L, SEEK_CUR); + end = lseek (fd, 0L, SEEK_END); + + if (start == -1 || end == -1) + return -1; + + length = end - start; + if (length == 0) + return -1; + + *start_ = start; + *length_ = length; + + return 0; +} + +/* { dg-final { scan-assembler-times "pop" 2 } } */ +/* { dg-final { scan-assembler-times "beq" 3 } } */ +/* { dg-final { object-size text <= 54 } } */ diff --git a/gcc/testsuite/lib/scanasm.exp b/gcc/testsuite/lib/scanasm.exp index a490854..fe66264 100644 --- a/gcc/testsuite/lib/scanasm.exp +++ b/gcc/testsuite/lib/scanasm.exp @@ -315,6 +315,92 @@ proc scan-assembler-dem-not { args } { } } +# Call pass if object size is ok, otherwise fail. +# example: /* { dg-final { object-size text <= 54 } } */ +proc object-size { args } { + global size + global base_dir + + if { [llength $args] < 3 } { + error "object-size: too few arguments" + return + } + if { [llength $args] > 4 } { + error "object-size: too many arguments" + return + } + if { [llength $args] >= 4 } { + switch [dg-process-target [lindex $args 1]] { + "S" { } + "N" { return } + "F" { setup_xfail "*-*-*" } + "P" { } + } + } + + # Find size like we find g++ in g++.exp. + if ![info exists size] { + set size [findfile $base_dir/../../../binutils/size \ + $base_dir/../../../binutils/size \ + [findfile $base_dir/../../size $base_dir/../../size \ + [findfile $base_dir/size $base_dir/size \ + [transform size]]]] + verbose -log "size is $size" + } + + upvar 2 name testcase + set testcase [lindex $testcase 0] + set output_file "[file rootname [file tail $testcase]].o" + set output [remote_exec host "$size" "$output_file"] + set status [lindex $output 0] + if { $status != 0 } { + error "object-size: $size failed" + return + } + + set text [lindex $output 1] + set lines [split $text "\n"] + + set line0 [lindex $lines 0] + if ![regexp {^\s*text\s+data\s+bss\s+dec\s+hex\s+filename\s*$} $line0] { + error "object-size: $size did not produce expected first line: $line0" + return + } + + set line1 [lindex $lines 1] + if ![regexp {^\s*\d+\s+\d+\s+\d+\s+\d+\s+[\da-fA-F]+\s+} $line1] { + error "object-size: $size did not produce expected second line: $line1" + return + } + + set what [lindex $args 0] + set where [lsearch { text data bss total } $what] + if { $where == -1 } { + error "object-size: illegal argument: $what" + return + } + set actual [lindex $line1 $where] + verbose -log "$what size is $actual" + + set cmp [lindex $args 1] + if { [lsearch { < > <= >= == != } $cmp] == -1 } { + error "object-size: illegal argument: $cmp" + return + } + + set with [lindex $args 2] + if ![string is integer $with ] { + error "object-size: illegal argument: $with" + return + } + + if [expr $actual $cmp $with] { + pass "$testcase object-size $what $cmp $with" + } else { + fail "$testcase object-size $what $cmp $with" + } +} + # Utility for testing that a function is defined on the current line. # Call pass if so, otherwise fail. Invoked directly; the file must # have been compiled with -g -dA. |