summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.misc-tests
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.misc-tests
downloadcbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2
cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.misc-tests')
-rw-r--r--gcc/testsuite/gcc.misc-tests/acker1.c23
-rw-r--r--gcc/testsuite/gcc.misc-tests/acker1.exp28
-rw-r--r--gcc/testsuite/gcc.misc-tests/arm-isr.c51
-rw-r--r--gcc/testsuite/gcc.misc-tests/arm-isr.exp28
-rw-r--r--gcc/testsuite/gcc.misc-tests/bprob-1.c271
-rw-r--r--gcc/testsuite/gcc.misc-tests/bprob-2.c45
-rw-r--r--gcc/testsuite/gcc.misc-tests/bprob.exp61
-rw-r--r--gcc/testsuite/gcc.misc-tests/dectest.exp527
-rw-r--r--gcc/testsuite/gcc.misc-tests/dhry.c602
-rw-r--r--gcc/testsuite/gcc.misc-tests/dhry.exp28
-rw-r--r--gcc/testsuite/gcc.misc-tests/dhry.h433
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-1.c20
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-10.c15
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-10b.c16
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-11.c23
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-2.c22
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-3.c48
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-4.c273
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-4b.c263
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-5b.c34
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-6.c39
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-7.c87
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-8.c47
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov-9.c15
-rw-r--r--gcc/testsuite/gcc.misc-tests/gcov.exp44
-rw-r--r--gcc/testsuite/gcc.misc-tests/help.exp80
-rw-r--r--gcc/testsuite/gcc.misc-tests/i386-pf-3dnow-1.c32
-rw-r--r--gcc/testsuite/gcc.misc-tests/i386-pf-athlon-1.c32
-rw-r--r--gcc/testsuite/gcc.misc-tests/i386-pf-none-1.c29
-rw-r--r--gcc/testsuite/gcc.misc-tests/i386-pf-sse-1.c33
-rw-r--r--gcc/testsuite/gcc.misc-tests/i386-prefetch.exp114
-rw-r--r--gcc/testsuite/gcc.misc-tests/linkage-x.c3
-rw-r--r--gcc/testsuite/gcc.misc-tests/linkage-y.c8
-rw-r--r--gcc/testsuite/gcc.misc-tests/linkage.exp122
-rw-r--r--gcc/testsuite/gcc.misc-tests/matrix1.c46
-rw-r--r--gcc/testsuite/gcc.misc-tests/matrix1.exp28
-rw-r--r--gcc/testsuite/gcc.misc-tests/mg-2.c9
-rw-r--r--gcc/testsuite/gcc.misc-tests/mg-2.exp24
-rw-r--r--gcc/testsuite/gcc.misc-tests/mg.c8
-rw-r--r--gcc/testsuite/gcc.misc-tests/mg.exp24
-rw-r--r--gcc/testsuite/gcc.misc-tests/options.exp54
-rw-r--r--gcc/testsuite/gcc.misc-tests/sieve.c26
-rw-r--r--gcc/testsuite/gcc.misc-tests/sieve.exp28
-rw-r--r--gcc/testsuite/gcc.misc-tests/sort2.c54
-rw-r--r--gcc/testsuite/gcc.misc-tests/sort2.exp28
45 files changed, 3825 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.misc-tests/acker1.c b/gcc/testsuite/gcc.misc-tests/acker1.c
new file mode 100644
index 000000000..aa9d1063c
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/acker1.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+int acker(int, int);
+
+int
+main(void)
+{
+ int n = acker(3,6);
+ if (n != 509)
+ printf("acker(3,6) = %d != 509\n", n);
+ return(0);
+}
+
+int
+acker(int x,int y)
+{
+ if (x==0)
+ return(y+1);
+ else if (y==0)
+ return(acker(x-1,1));
+ else
+ return(acker(x-1, acker(x, y-1)));
+}
diff --git a/gcc/testsuite/gcc.misc-tests/acker1.exp b/gcc/testsuite/gcc.misc-tests/acker1.exp
new file mode 100644
index 000000000..58b9b1654
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/acker1.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+global PERF_TEST
+if { ![info exists PERF_TEST] || "$PERF_TEST" != "yes" } {
+ return
+}
+
+load_lib mike-gcc.exp
+
+prebase
+set actions run
+set compiler_output "^$"
+set program_output "^$"
+postbase acker1.c $run $groups
diff --git a/gcc/testsuite/gcc.misc-tests/arm-isr.c b/gcc/testsuite/gcc.misc-tests/arm-isr.c
new file mode 100644
index 000000000..737f9ffb6
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/arm-isr.c
@@ -0,0 +1,51 @@
+extern void abort ();
+extern void exit (int);
+
+#ifndef __thumb__
+/* There used to be a couple of bugs in the ARM's prologue and epilogue
+ generation for ISR routines. The wrong epilogue instruction would be
+ generated to restore the IP register if it had to be pushed onto the
+ stack, and the wrong offset was being computed for local variables if
+ r0 - r3 had to be saved. This tests for both of these cases. */
+
+int z = 9;
+
+int
+bar (void)
+{
+ return z;
+}
+
+int
+foo (int a, int b, int c, int d, int e, int f, int g, int h)
+{
+ volatile int i = (a + b) - (g + h) + bar ();
+ volatile int j = (e + f) - (c + d);
+
+ return a + b + c + d + e + f + g + h + i + j;
+}
+
+int foo1 (int a, int b, int c, int d, int e, int f, int g, int h) __attribute__ ((interrupt ("IRQ")));
+
+int
+foo1 (int a, int b, int c, int d, int e, int f, int g, int h)
+{
+ volatile int i = (a + b) - (g + h) + bar ();
+ volatile int j = (e + f) - (c + d);
+
+ return a + b + c + d + e + f + g + h + i + j;
+}
+#endif
+
+int
+main (void)
+{
+#ifndef __thumb__
+ if (foo (1, 2, 3, 4, 5, 6, 7, 8) != 32)
+ abort ();
+
+ if (foo1 (1, 2, 3, 4, 5, 6, 7, 8) != 32)
+ abort ();
+#endif
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.misc-tests/arm-isr.exp b/gcc/testsuite/gcc.misc-tests/arm-isr.exp
new file mode 100644
index 000000000..8c2d3227f
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/arm-isr.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 2001, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file is based on a bug report submitted to gcc-bugs:
+# http://gcc.gnu.org/ml/gcc-patches/2001-12/msg02158.html
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+dg-init
+if { [istarget "arm*-*-*"] } {
+ dg-runtest "$srcdir/$subdir/arm-isr.c" "" ""
+}
+dg-finish
+
diff --git a/gcc/testsuite/gcc.misc-tests/bprob-1.c b/gcc/testsuite/gcc.misc-tests/bprob-1.c
new file mode 100644
index 000000000..8c6018c56
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/bprob-1.c
@@ -0,0 +1,271 @@
+/* Check that various C constructs are handled correctly by profile-directed
+ block ordering.
+
+ This test is the same as gcov-4.c. The "count" comments are left in to
+ make comparisons easier; they are ignored for this test. */
+
+extern void abort (void);
+
+int do_something (int i)
+{
+ return i;
+}
+
+/* Check static inline functions. */
+
+int unref_val;
+
+static inline int
+unreferenced (int i, int j)
+{
+ return i - j;
+}
+
+static inline int
+uncalled (int i, int j)
+{
+ return i * j;
+}
+
+static inline int
+called (int i, int j)
+{
+ return i + j; /* count(1) */
+}
+
+void
+call_unref ()
+{
+ if (unref_val) /* count(1) */
+ unref_val = uncalled (1, 2);
+ unref_val = called (unref_val, 4); /* count(1) */
+}
+
+
+/* Check for loops. */
+
+int for_val1;
+int for_val2;
+int for_temp;
+
+int
+test_for1 (int n)
+{
+ int i;
+ for_temp = 1; /* count(3) */
+ for (i = 0; i < n; i++)
+ for_temp++; /* count(9) */
+ return for_temp; /* count(3) */
+}
+
+int
+test_for2 (int m, int n, int o)
+{
+ int i, j, k;
+ for_temp = 1; /* count(6) */
+ for (i = 0; i < n; i++)
+ for (j = 0; j < m; j++)
+ for (k = 0; k < o; k++)
+ for_temp++; /* count(81) */
+ return for_temp; /* count(6) */
+}
+
+void
+call_for ()
+{
+ for_val1 += test_for1 (0);
+ for_val1 += test_for1 (2);
+ for_val1 += test_for1 (7);
+
+ for_val2 += test_for2 (0, 0, 0);
+ for_val2 += test_for2 (1, 0, 0);
+ for_val2 += test_for2 (1, 3, 0);
+ for_val2 += test_for2 (1, 3, 1);
+ for_val2 += test_for2 (3, 1, 5);
+ for_val2 += test_for2 (3, 7, 3);
+}
+
+/* Check the use of goto. */
+
+int goto_val;
+
+int
+test_goto1 (int f)
+{
+ if (f) /* count(2) */
+ goto lab1; /* count(1) */
+ return 1; /* count(1) */
+lab1:
+ return 2; /* count(1) */
+}
+
+int
+test_goto2 (int f)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* count(15) */
+ if (i == f) goto lab2; /* count(14) */
+ return 4; /* count(1) */
+lab2:
+ return 8; /* count(1) */
+}
+
+void
+call_goto ()
+{
+ goto_val += test_goto1 (0);
+ goto_val += test_goto1 (1);
+ goto_val += test_goto2 (3);
+ goto_val += test_goto2 (30);
+}
+
+/* Check nested if-then-else statements. */
+
+int ifelse_val1;
+int ifelse_val2;
+int ifelse_val3;
+
+int
+test_ifelse1 (int i, int j)
+{
+ int result = 0;
+ if (i) /* count(5) */
+ if (j) /* count(3) */
+ result = do_something (4); /* count(3) */
+ else
+ result = do_something (1024);
+ else
+ if (j) /* count(2) */
+ result = do_something (1); /* count(1) */
+ else
+ result = do_something (2); /* count(1) */
+ if (i > j) /* count(5) */
+ result = do_something (result*2); /* count(1) */
+ if (i > 10) /* count(5) */
+ if (j > 10) /* count(1) */
+ result = do_something (result*4); /* count(1) */
+ return result; /* count(5) */
+}
+
+int
+test_ifelse2 (int i)
+{
+ int result = 0;
+ if (!i) /* count(6) */
+ result = do_something (1); /* count(1) */
+ if (i == 1) /* count(6) */
+ result = do_something (1024);
+ if (i == 2) /* count(6) */
+ result = do_something (2); /* count(3) */
+ if (i == 3) /* count(6) */
+ return do_something (8); /* count(2) */
+ if (i == 4) /* count(4) */
+ return do_something (2048);
+ return result; /* count(4) */
+}
+
+int
+test_ifelse3 (int i, int j)
+{
+ int result = 1;
+ if (i > 10 && j > i && j < 20) /* count(11) */
+ result = do_something (16); /* count(1) */
+ if (i > 20) /* count(11) */
+ if (j > i) /* count(5) */
+ if (j < 30) /* count(2) */
+ result = do_something (32); /* count(1) */
+ if (i == 3 || j == 47 || i == j) /* count(11) */
+ result = do_something (64); /* count(3) */
+ return result; /* count(11) */
+}
+
+void
+call_ifelse ()
+{
+ ifelse_val1 += test_ifelse1 (0, 2);
+ ifelse_val1 += test_ifelse1 (0, 0);
+ ifelse_val1 += test_ifelse1 (1, 2);
+ ifelse_val1 += test_ifelse1 (10, 2);
+ ifelse_val1 += test_ifelse1 (11, 11);
+
+ ifelse_val2 += test_ifelse2 (0);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (3);
+ ifelse_val2 += test_ifelse2 (3);
+
+ ifelse_val3 += test_ifelse3 (11, 19);
+ ifelse_val3 += test_ifelse3 (25, 27);
+ ifelse_val3 += test_ifelse3 (11, 22);
+ ifelse_val3 += test_ifelse3 (11, 10);
+ ifelse_val3 += test_ifelse3 (21, 32);
+ ifelse_val3 += test_ifelse3 (21, 20);
+ ifelse_val3 += test_ifelse3 (1, 2);
+ ifelse_val3 += test_ifelse3 (32, 31);
+ ifelse_val3 += test_ifelse3 (3, 0);
+ ifelse_val3 += test_ifelse3 (0, 47);
+ ifelse_val3 += test_ifelse3 (65, 65);
+}
+
+/* Check switch statements. */
+
+int switch_val, switch_m;
+
+int
+test_switch (int i, int j)
+{
+ int result = 0; /* count(5) */
+
+ switch (i) /* count(5) */
+ {
+ case 1:
+ result = do_something (2); /* count(1) */
+ break;
+ case 2:
+ result = do_something (1024);
+ break;
+ case 3:
+ case 4:
+ if (j == 2) /* count(3) */
+ return do_something (4); /* count(1) */
+ result = do_something (8); /* count(2) */
+ break;
+ default:
+ result = do_something (32); /* count(1) */
+ switch_m++; /* count(1) */
+ break;
+ }
+ return result; /* count(4) */
+}
+
+void
+call_switch ()
+{
+ switch_val += test_switch (1, 0);
+ switch_val += test_switch (3, 0);
+ switch_val += test_switch (3, 2);
+ switch_val += test_switch (4, 0);
+ switch_val += test_switch (16, 0);
+ switch_val += switch_m;
+}
+
+int
+main()
+{
+ call_for ();
+ call_goto ();
+ call_ifelse ();
+ call_switch ();
+ call_unref ();
+ if ((for_val1 != 12)
+ || (for_val2 != 87)
+ || (goto_val != 15)
+ || (ifelse_val1 != 31)
+ || (ifelse_val2 != 23)
+ || (ifelse_val3 != 246)
+ || (switch_val != 55)
+ || (unref_val != 4))
+ abort ();
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.misc-tests/bprob-2.c b/gcc/testsuite/gcc.misc-tests/bprob-2.c
new file mode 100644
index 000000000..e0931f39c
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/bprob-2.c
@@ -0,0 +1,45 @@
+/* Test profile-directed block ordering with computed gotos.
+ *
+ This is the same as test gcc.c-torture/execute/980526-1.c and
+ gcc.misc-tests/gcov-3.c */
+
+extern void abort (void);
+extern void exit (int);
+
+int expect_do1 = 1, expect_do2 = 2;
+
+static int doit(int x){
+ __label__ lbl1;
+ __label__ lbl2;
+ static int jtab_init = 0;
+ static void *jtab[2];
+
+ if(!jtab_init) {
+ jtab[0] = &&lbl1;
+ jtab[1] = &&lbl2;
+ jtab_init = 1;
+ }
+ goto *jtab[x];
+lbl1:
+ return 1;
+lbl2:
+ return 2;
+}
+
+static void do1(void) {
+ if (doit(0) != expect_do1)
+ abort ();
+}
+
+static void do2(void){
+ if (doit(1) != expect_do2)
+ abort ();
+}
+
+int main(void){
+#ifndef NO_LABEL_VALUES
+ do1();
+ do2();
+#endif
+ exit(0);
+}
diff --git a/gcc/testsuite/gcc.misc-tests/bprob.exp b/gcc/testsuite/gcc.misc-tests/bprob.exp
new file mode 100644
index 000000000..c05eced54
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/bprob.exp
@@ -0,0 +1,61 @@
+# Copyright (C) 2001, 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test the functionality of programs compiled with profile-directed block
+# ordering using -fprofile-arcs followed by -fbranch-probabilities.
+
+load_lib target-supports.exp
+
+# Some targets don't have any implementation of __bb_init_func or are
+# missing other needed machinery.
+if { ![check_profiling_available "-fprofile-arcs"] } {
+ return
+}
+
+# The procedures in profopt.exp need these parameters.
+set tool gcc
+set prof_ext "gcda"
+set perf_ext tim
+
+# Override the list defined in profopt.exp.
+set PROFOPT_OPTIONS [list \
+ { -g } \
+ { -O0 } \
+ { -O1 } \
+ { -O2 -DPERFTIME } \
+ { -O3 -DPERFTIME } \
+ { -O3 -g -DPERFTIME } \
+ { -Os } ]
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Load support procs.
+load_lib profopt.exp
+
+set profile_options "-fprofile-arcs"
+set feedback_options "-fprofile-use"
+
+foreach profile_option $profile_options feedback_option $feedback_options {
+ foreach src [lsort [glob -nocomplain $srcdir/$subdir/bprob-*.c]] {
+ # If we're only testing specific files and this isn't one of them, skip it.
+ if ![runtest_file_p $runtests $src] then {
+ continue
+ }
+ profopt-execute $src
+ }
+}
diff --git a/gcc/testsuite/gcc.misc-tests/dectest.exp b/gcc/testsuite/gcc.misc-tests/dectest.exp
new file mode 100644
index 000000000..b86f2adec
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/dectest.exp
@@ -0,0 +1,527 @@
+# Copyright 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# DejaGnu test driver around Mike Cowlishaw's testsuite for decimal
+# decimal arithmetic ("decTest"). See:
+# <http://www2.hursley.ibm.com/decimal/dectest.html>.
+#
+# Contributed by Ben Elliston <bje@au.ibm.com>.
+
+set DEC_TORTURE_OPTIONS [list {} -O1 -O2 -O3 -Os -msoft-float]
+
+proc target-specific-flags {} {
+ set result "-frounding-math "
+ return $result
+}
+
+# Load support procs (borrow these from c-torture).
+load_lib c-torture.exp
+load_lib target-supports.exp
+load_lib torture-options.exp
+
+# Skip these tests for targets that don't support this extension.
+if { ![check_effective_target_dfp] } {
+ return
+}
+
+# The list format is [coefficient, max-exponent, min-exponent].
+set properties(_Decimal32) [list 7 96 -95]
+set properties(_Decimal64) [list 16 384 -383]
+set properties(_Decimal128) [list 34 6144 -6143]
+
+# Operations implemented by the compiler.
+set operators(add) {+}
+set operators(compare) {==}
+set operators(divide) {/}
+set operators(multiply) {*}
+set operators(subtract) {-}
+set operators(minus) {-}
+set operators(plus) {+}
+set operators(apply) {}
+
+# Operations imlemented by the library.
+set libfuncs(abs) fabsl
+set libfuncs(squareroot) sqrtl
+set libfuncs(max) fmaxl
+set libfuncs(min) fminl
+set libfuncs(quantize) quantize
+set libfuncs(samequantum) samequantum
+set libfuncs(power) powl
+set libfuncs(toSci) unknown
+set libfuncs(tosci) unknown
+set libfuncs(toEng) unknown
+set libfuncs(toeng) unknown
+set libfuncs(divideint) unknown
+set libfuncs(rescale) unknown
+set libfuncs(remainder) unknown
+set libfuncs(remaindernear) unknown
+set libfuncs(normalize) unknown
+set libfuncs(tointegral) unknown
+set libfuncs(trim) unknown
+
+# Run all of the tests listed in TESTCASES by invoking df-run-test on
+# each. Skip tests that not included by the user invoking runtest
+# with the foo.exp=test.c syntax.
+
+proc dfp-run-tests { testcases } {
+ global runtests
+ foreach test $testcases {
+ # If we're only testing specific files and this isn't one of
+ # them, skip it.
+ if ![runtest_file_p $runtests $test] continue
+ dfp-run-test $test
+ }
+}
+
+# Run a single test case named by TESTCASE.
+# Called for each test by dfp-run-tests.
+
+proc dfp-run-test { testcase } {
+ set fd [open $testcase r]
+ while {[gets $fd line] != -1} {
+ switch -regexp -- $line {
+ {^[ \t]*--.*$} {
+ # Ignore comments.
+ }
+ {^[ \t]*$} {
+ # Ignore blank lines.
+ }
+ {^[ \t]*[^:]*:[^:]*} {
+ regsub -- {[ \t]*--.*$} $line {} line
+ process-directive $line
+ }
+ default {
+ process-test-case $testcase $line
+ }
+ }
+ }
+ close $fd
+}
+
+# Return the appropriate constant from <fenv.h> for MODE.
+
+proc c-rounding-mode { mode } {
+ switch [string tolower $mode] {
+ "floor" { return 0 } # FE_DEC_DOWNWARD
+ "half_even" { return 1 } # FE_DEC_TONEARESTFROMZERO
+ "half_up" { return 2 } # FE_DEC_TONEAREST
+ "down" { return 3 } # FE_DEC_TOWARDZERO
+ "ceiling" { return 4 } # FE_DEC_UPWARD
+ }
+ error "unsupported rounding mode ($mode)"
+}
+
+# Return a string of C code that forms the preamble to perform the
+# test named ID.
+
+proc c-test-preamble { id } {
+ append result "/* Machine generated test case for $id */\n"
+ append result "\n"
+ append result "\#include <assert.h>\n"
+ append result "\#include <fenv.h>\n"
+ append result "\#include <math.h>\n"
+ append result "\n"
+ append result "int main ()\n"
+ append result "\{"
+ return $result
+}
+
+# Return a string of C code that forms the postable to the test named ID.
+
+proc c-test-postamble { id } {
+ return "\}"
+}
+
+# Generate a C unary expression that applies OPERATION to OP.
+
+proc c-unary-expression {operation op} {
+ global operators
+ global libfuncs
+ if [catch {set result "$operators($operation) $op"}] {
+ # If operation isn't in the operators or libfuncs arrays,
+ # we'll throw an error. That's what we want.
+ # FIXME: append d32, etc. here.
+ set result "$libfuncs($operation) ($op)"
+ }
+ return $result
+}
+
+# Generate a C binary expression that applies OPERATION to OP1 and OP2.
+
+proc c-binary-expression {operation op1 op2} {
+ global operators
+ global libfuncs
+ if [catch {set result "$op1 $operators($operation) $op2"}] {
+ # If operation isn't in the operators or libfuncs arrays,
+ # we'll throw an error. That's what we want.
+ set result "$libfuncs($operation) ($op1, $op2)"
+ }
+ return $result
+}
+
+# Return the most appropriate C type (_Decimal32, etc) for this test.
+
+proc c-decimal-type { } {
+ global directives
+ if [catch {set precision $directives(precision)}] {
+ set precision "_Decimal128"
+ }
+ if { $precision == 7 } {
+ set result "_Decimal32"
+ } elseif {$precision == 16} {
+ set result "_Decimal64"
+ } elseif {$precision == 34} {
+ set result "_Decimal128"
+ } else {
+ error "Unsupported precision"
+ }
+ return $result
+}
+
+# Return the size of the most appropriate C type, in bytes.
+
+proc c-sizeof-decimal-type { } {
+ switch [c-decimal-type] {
+ "_Decimal32" { return 4 }
+ "_Decimal64" { return 8 }
+ "_Decimal128" { return 16 }
+ }
+ error "Unsupported precision"
+}
+
+# Return the right literal suffix for CTYPE.
+
+proc c-type-suffix { ctype } {
+ switch $ctype {
+ "_Decimal32" { return "df" }
+ "_Decimal64" { return "dd" }
+ "_Decimal128" { return "dl" }
+ "float" { return "f" }
+ "long double" { return "l" }
+ }
+ return ""
+}
+
+proc nan-p { operand } {
+ if {[string match "NaN*" $operand] || [string match "-NaN*" $operand]} {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+proc infinity-p { operand } {
+ if {[string match "Inf*" $operand] || [string match "-Inf*" $operand]} {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+proc isnan-builtin-name { } {
+ set bits [expr [c-sizeof-decimal-type] * 8]
+ return "__builtin_isnand$bits"
+}
+
+proc isinf-builtin-name { } {
+ set bits [expr [c-sizeof-decimal-type] * 8]
+ return "__builtin_isinfd$bits"
+}
+
+# Return a string that declares a C union containing the decimal type
+# and an unsigned char array of the right size.
+
+proc c-union-decl { } {
+ append result " union {\n"
+ append result " [c-decimal-type] d;\n"
+ append result " unsigned char bytes\[[c-sizeof-decimal-type]\];\n"
+ append result " } u;"
+ return $result
+}
+
+proc transform-hex-constant {value} {
+ regsub \# $value {} value
+ regsub -all (\.\.) $value {0x\1, } bytes
+ return [list $bytes]
+}
+
+# Create a C program file (named using ID) containing a test for a
+# binary OPERATION on OP1 and OP2 that expects RESULT and CONDITIONS.
+
+proc make-c-test {testcase id operation result conditions op1 {op2 "NONE"}} {
+ global directives
+ set filename ${id}.c
+ set outfd [open $filename w]
+
+ puts $outfd [c-test-preamble $id]
+ puts $outfd [c-union-decl]
+ if {[string compare $result ?] != 0} {
+ if {[string index $result 0] == "\#"} {
+ puts $outfd " static unsigned char compare\[[c-sizeof-decimal-type]\] = [transform-hex-constant $result];"
+ }
+ }
+ if {[string compare $op2 NONE] == 0} {
+ if {[string index $op1 0] == "\#"} {
+ puts $outfd " static unsigned char fill\[[c-sizeof-decimal-type]\] = [transform-hex-constant $op1];"
+ }
+ }
+
+ puts $outfd ""
+ puts $outfd " /* FIXME: Set rounding mode with fesetround() once in libc. */"
+ puts $outfd " __dfp_set_round ([c-rounding-mode $directives(rounding)]);"
+ puts $outfd ""
+
+ # Build the expression to be tested.
+ if {[string compare $op2 NONE] == 0} {
+ if {[string index $op1 0] == "\#"} {
+ puts $outfd " memcpy (u.bytes, fill, [c-sizeof-decimal-type]);"
+ } else {
+ puts $outfd " u.d = [c-unary-expression $operation [c-operand $op1]];"
+ }
+ } else {
+ puts $outfd " u.d = [c-binary-expression $operation [c-operand $op1] [c-operand $op2]];"
+ }
+
+ # Test the result.
+ if {[string compare $result ?] != 0} {
+ # Not an undefined result ..
+ if {[string index $result 0] == "\#"} {
+ # Handle hex comparisons.
+ puts $outfd " return memcmp (u.bytes, compare, [c-sizeof-decimal-type]);"
+ } elseif {[nan-p $result]} {
+ puts $outfd " return ![isnan-builtin-name] (u.d);"
+ } elseif {[infinity-p $result]} {
+ puts $outfd " return ![isinf-builtin-name] (u.d);"
+ } else {
+ # Ordinary values.
+ puts $outfd " return !(u.d == [c-operand $result]);"
+ }
+ } else {
+ puts $outfd " return 0;"
+ }
+
+ puts $outfd [c-test-postamble $id]
+ close $outfd
+ return $filename
+}
+
+# Is the test supported for this target?
+
+proc supported-p { id op } {
+ global directives
+ global libfuncs
+
+ # Ops that are unsupported. Many of these tests fail because they
+ # do not tolerate the C front-end rounding the value of floating
+ # point literals to suit the type of the constant. Otherwise, by
+ # treating the `apply' operator like C assignment, some of them do
+ # pass.
+ switch -- $op {
+ apply { return 0 }
+ }
+
+ # Ditto for the following miscellaneous tests.
+ switch $id {
+ addx1130 { return 0 }
+ addx1131 { return 0 }
+ addx1132 { return 0 }
+ addx1133 { return 0 }
+ addx1134 { return 0 }
+ addx1135 { return 0 }
+ addx1136 { return 0 }
+ addx1138 { return 0 }
+ addx1139 { return 0 }
+ addx1140 { return 0 }
+ addx1141 { return 0 }
+ addx1142 { return 0 }
+ addx1151 { return 0 }
+ addx1152 { return 0 }
+ addx1153 { return 0 }
+ addx1154 { return 0 }
+ addx1160 { return 0 }
+ addx690 { return 0 }
+ mulx263 { return 0 }
+ subx947 { return 0 }
+ }
+
+ if [info exist libfuncs($op)] {
+ # No library support for now.
+ return 0
+ }
+ if [catch {c-rounding-mode $directives(rounding)}] {
+ # Unsupported rounding mode.
+ return 0
+ }
+ if [catch {c-decimal-type}] {
+ # Unsupported precision.
+ return 0
+ }
+ return 1
+}
+
+# Break LINE into a list of tokens. Be sensitive to quoting.
+# There has to be a better way to do this :-|
+
+proc tokenize { line } {
+ set quoting 0
+ set tokens [list]
+
+ foreach char [split $line {}] {
+ if {!$quoting} {
+ if { [info exists token] && $char == " " } {
+ if {[string compare "$token" "--"] == 0} {
+ # Only comments remain.
+ return $tokens
+ }
+ lappend tokens $token
+ unset token
+ } else {
+ if {![info exists token] && $char == "'" } {
+ set quoting 1
+ } else {
+ if { $char != " " } {
+ append token $char
+ }
+ }
+ }
+ } else {
+ # Quoting.
+ if { $char == "'" } {
+ set quoting 0
+ if [info exists token] {
+ lappend tokens $token
+ unset token
+ } else {
+ lappend tokens {}
+ }
+ } else {
+ append token $char
+ }
+ }
+ }
+ # Flush any residual token.
+ if {[info exists token] && [string compare $token "--"]} {
+ lappend tokens $token
+ }
+ return $tokens
+}
+
+# Process a directive in LINE.
+
+proc process-directive { line } {
+ global directives
+ set keyword [string tolower [string trim [lindex [split $line :] 0]]]
+ set value [string tolower [string trim [lindex [split $line :] 1]]]
+ set directives($keyword) $value
+}
+
+# Produce a C99-valid floating point literal.
+
+proc c-operand {operand} {
+ set bits [expr 8 * [c-sizeof-decimal-type]]
+
+ switch -glob -- $operand {
+ "Inf*" { return "__builtin_infd${bits} ()" }
+ "-Inf*" { return "- __builtin_infd${bits} ()" }
+ "NaN*" { return "__builtin_nand${bits} (\"\")" }
+ "-NaN*" { return "- __builtin_nand${bits} (\"\")" }
+ "sNaN*" { return "__builtin_nand${bits} (\"\")" }
+ "-sNaN*" { return "- __builtin_nand${bits} (\"\")" }
+ }
+
+ if {[string first . $operand] < 0 && \
+ [string first E $operand] < 0 && \
+ [string first e $operand] < 0} {
+ append operand .
+ }
+ set suffix [c-type-suffix [c-decimal-type]]
+ return [append operand $suffix]
+}
+
+# Process an arithmetic test in LINE from TESTCASE.
+
+proc process-test-case { testcase line } {
+ set testfile [file tail $testcase]
+
+ # Compress multiple spaces down to one.
+ regsub -all { *} $line { } line
+
+ set args [tokenize $line]
+ if {[llength $args] < 5} {
+ error "Skipping invalid test: $line"
+ return
+ }
+
+ set id [string trim [lindex $args 0]]
+ set operation [string trim [lindex $args 1]]
+ set operand1 [string trim [lindex $args 2]]
+
+ if { [string compare [lindex $args 3] -> ] == 0 } {
+ # Unary operation.
+ set operand2 NONE
+ set result_index 4
+ set cond_index 5
+ } else {
+ # Binary operation.
+ set operand2 [string trim [lindex $args 3]]
+ if { [string compare [lindex $args 4] -> ] != 0 } {
+ warning "Skipping invalid test: $line"
+ return
+ }
+ set result_index 5
+ set cond_index 6
+ }
+
+ set result [string trim [lindex $args $result_index]]
+ set conditions [list]
+ for { set i $cond_index } { $i < [llength $args] } { incr i } {
+ lappend conditions [string tolower [lindex $args $i]]
+ }
+
+ # If this test is unsupported, say so.
+ if ![supported-p $id $operation] {
+ unsupported "$testfile ($id)"
+ return
+ }
+
+ if {[string compare $operand1 \#] == 0 || \
+ [string compare $operand2 \#] == 0} {
+ unsupported "$testfile ($id), null reference"
+ return
+ }
+
+ # Construct a C program and then compile/execute it on the target.
+ # Grab some stuff from the c-torture.exp test driver for this.
+
+ set cprog [make-c-test $testfile $id $operation $result $conditions $operand1 $operand2]
+ c-torture-execute $cprog [target-specific-flags]
+}
+
+### Script mainline:
+
+if [catch {set testdir $env(DECTEST)}] {
+ # If $DECTEST is unset, skip this test driver altogether.
+ return
+}
+
+torture-init
+set-torture-options $DEC_TORTURE_OPTIONS
+
+note "Using tests in $testdir"
+dfp-run-tests [lsort [glob -nocomplain $testdir/*.decTest]]
+unset testdir
+
+torture-finish
diff --git a/gcc/testsuite/gcc.misc-tests/dhry.c b/gcc/testsuite/gcc.misc-tests/dhry.c
new file mode 100644
index 000000000..ae29a6936
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/dhry.c
@@ -0,0 +1,602 @@
+/*
+ ****************************************************************************
+ *
+ * "DHRYSTONE" Benchmark Program
+ * -----------------------------
+ *
+ * Version: C, Version 2.1
+ *
+ * File: dhry_1.c (part 2 of 3)
+ *
+ * Date: May 25, 1988
+ *
+ * Author: Reinhold P. Weicker
+ *
+ ****************************************************************************
+ */
+
+#include "dhry.h"
+
+/* Global Variables: */
+
+Rec_Pointer Ptr_Glob,
+ Next_Ptr_Glob;
+int Int_Glob;
+Boolean Bool_Glob;
+char Ch_1_Glob,
+ Ch_2_Glob;
+int Arr_1_Glob [50];
+int Arr_2_Glob [50] [50];
+
+extern char *malloc ();
+Enumeration Func_1 ();
+ /* forward declaration necessary since Enumeration may not simply be int */
+
+#ifndef REG
+ Boolean Reg = false;
+#define REG
+ /* REG becomes defined as empty */
+ /* i.e. no register variables */
+#else
+ Boolean Reg = true;
+#endif
+
+/* variables for time measurement: */
+
+/*
+#ifdef TIMES
+struct tms time_info;
+extern int times ();
+#endif
+*/
+/*
+#ifdef TIME
+extern long time();
+#endif
+*/
+#define Too_Small_Time 2
+ /* Measurements should last at least 2 seconds */
+
+long Begin_Time,
+ End_Time,
+ User_Time;
+float Microseconds,
+ Dhrystones_Per_Second;
+
+/* end of variables for time measurement */
+
+
+main ()
+/*****/
+
+ /* main program, corresponds to procedures */
+ /* Main and Proc_0 in the Ada version */
+{
+ One_Fifty Int_1_Loc;
+ REG One_Fifty Int_2_Loc;
+ One_Fifty Int_3_Loc;
+ REG char Ch_Index;
+ Enumeration Enum_Loc;
+ Str_30 Str_1_Loc;
+ Str_30 Str_2_Loc;
+ REG int Run_Index;
+ REG int Number_Of_Runs;
+
+ /* Initializations */
+
+ Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
+ Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
+
+ Ptr_Glob->Ptr_Comp = Next_Ptr_Glob;
+ Ptr_Glob->Discr = Ident_1;
+ Ptr_Glob->variant.var_1.Enum_Comp = Ident_3;
+ Ptr_Glob->variant.var_1.Int_Comp = 40;
+ strcpy (Ptr_Glob->variant.var_1.Str_Comp,
+ "DHRYSTONE PROGRAM, SOME STRING");
+ strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");
+
+ Arr_2_Glob [8][7] = 10;
+ /* Was missing in published program. Without this statement, */
+ /* Arr_2_Glob [8][7] would have an undefined value. */
+ /* Warning: With 16-Bit processors and Number_Of_Runs > 32000, */
+ /* overflow may occur for this array element. */
+
+/*
+ printf ("\n");
+ printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
+ printf ("\n");
+*/
+ if (Reg)
+ {
+/*
+ printf ("Program compiled with 'register' attribute\n");
+ printf ("\n");
+*/
+ }
+ else
+ {
+/*
+ printf ("Program compiled without 'register' attribute\n");
+ printf ("\n");
+*/
+ }
+/*
+ printf ("Please give the number of runs through the benchmark: ");
+*/
+ {
+ int n;
+/*
+ scanf ("%d", &n);
+*/
+ Number_Of_Runs = n=1000;
+ }
+/*
+ printf ("\n");
+
+ printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);
+*/
+
+ /***************/
+ /* Start timer */
+ /***************/
+
+/*
+#ifdef TIMES
+ times (&time_info);
+ Begin_Time = (long) time_info.tms_utime;
+#endif
+#ifdef TIME
+ Begin_Time = time ( (long *) 0);
+#endif
+*/
+
+ for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
+ {
+
+ Proc_5();
+ Proc_4();
+ /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
+ Int_1_Loc = 2;
+ Int_2_Loc = 3;
+ strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
+ Enum_Loc = Ident_2;
+ Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
+ /* Bool_Glob == 1 */
+ while (Int_1_Loc < Int_2_Loc) /* loop body executed once */
+ {
+ Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
+ /* Int_3_Loc == 7 */
+ Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
+ /* Int_3_Loc == 7 */
+ Int_1_Loc += 1;
+ } /* while */
+ /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
+ Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
+ /* Int_Glob == 5 */
+ Proc_1 (Ptr_Glob);
+ for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
+ /* loop body executed twice */
+ {
+ if (Enum_Loc == Func_1 (Ch_Index, 'C'))
+ /* then, not executed */
+ {
+ Proc_6 (Ident_1, &Enum_Loc);
+ strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
+ Int_2_Loc = Run_Index;
+ Int_Glob = Run_Index;
+ }
+ }
+ /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
+ Int_2_Loc = Int_2_Loc * Int_1_Loc;
+ Int_1_Loc = Int_2_Loc / Int_3_Loc;
+ Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
+ /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
+ Proc_2 (&Int_1_Loc);
+ /* Int_1_Loc == 5 */
+
+ } /* loop "for Run_Index" */
+
+ /**************/
+ /* Stop timer */
+ /**************/
+
+/*
+#ifdef TIMES
+ times (&time_info);
+ End_Time = (long) time_info.tms_utime;
+#endif
+#ifdef TIME
+ End_Time = time ( (long *) 0);
+#endif
+*/
+
+/*
+ printf ("Execution ends\n");
+ printf ("\n");
+ printf ("Final values of the variables used in the benchmark:\n");
+ printf ("\n");
+ printf ("Int_Glob: %d\n", Int_Glob);
+ printf (" should be: %d\n", 5);
+ printf ("Bool_Glob: %d\n", Bool_Glob);
+ printf (" should be: %d\n", 1);
+ printf ("Ch_1_Glob: %c\n", Ch_1_Glob);
+ printf (" should be: %c\n", 'A');
+ printf ("Ch_2_Glob: %c\n", Ch_2_Glob);
+ printf (" should be: %c\n", 'B');
+ printf ("Arr_1_Glob[8]: %d\n", Arr_1_Glob[8]);
+ printf (" should be: %d\n", 7);
+ printf ("Arr_2_Glob[8][7]: %d\n", Arr_2_Glob[8][7]);
+ printf (" should be: Number_Of_Runs + 10\n");
+ printf ("Ptr_Glob->\n");
+ printf (" Ptr_Comp: %d\n", (int) Ptr_Glob->Ptr_Comp);
+ printf (" should be: (implementation-dependent)\n");
+ printf (" Discr: %d\n", Ptr_Glob->Discr);
+ printf (" should be: %d\n", 0);
+ printf (" Enum_Comp: %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
+ printf (" should be: %d\n", 2);
+ printf (" Int_Comp: %d\n", Ptr_Glob->variant.var_1.Int_Comp);
+ printf (" should be: %d\n", 17);
+ printf (" Str_Comp: %s\n", Ptr_Glob->variant.var_1.Str_Comp);
+ printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
+ printf ("Next_Ptr_Glob->\n");
+ printf (" Ptr_Comp: %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
+ printf (" should be: (implementation-dependent), same as above\n");
+ printf (" Discr: %d\n", Next_Ptr_Glob->Discr);
+ printf (" should be: %d\n", 0);
+ printf (" Enum_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
+ printf (" should be: %d\n", 1);
+ printf (" Int_Comp: %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
+ printf (" should be: %d\n", 18);
+ printf (" Str_Comp: %s\n",
+ Next_Ptr_Glob->variant.var_1.Str_Comp);
+ printf (" should be: DHRYSTONE PROGRAM, SOME STRING\n");
+ printf ("Int_1_Loc: %d\n", Int_1_Loc);
+ printf (" should be: %d\n", 5);
+ printf ("Int_2_Loc: %d\n", Int_2_Loc);
+ printf (" should be: %d\n", 13);
+ printf ("Int_3_Loc: %d\n", Int_3_Loc);
+ printf (" should be: %d\n", 7);
+ printf ("Enum_Loc: %d\n", Enum_Loc);
+ printf (" should be: %d\n", 1);
+ printf ("Str_1_Loc: %s\n", Str_1_Loc);
+ printf (" should be: DHRYSTONE PROGRAM, 1'ST STRING\n");
+ printf ("Str_2_Loc: %s\n", Str_2_Loc);
+ printf (" should be: DHRYSTONE PROGRAM, 2'ND STRING\n");
+ printf ("\n");
+*/
+
+ User_Time = End_Time - Begin_Time;
+
+ if (User_Time < Too_Small_Time)
+ {
+/*
+ printf ("Measured time too small to obtain meaningful results\n");
+ printf ("Please increase number of runs\n");
+ printf ("\n");
+*/
+ }
+ else
+ {
+#ifdef TIME
+/*
+ Microseconds = (float) User_Time * Mic_secs_Per_Second
+ / (float) Number_Of_Runs;
+ Dhrystones_Per_Second = (float) Number_Of_Runs / (float) User_Time;
+*/
+#else
+/*
+ Microseconds = (float) User_Time * Mic_secs_Per_Second
+ / ((float) HZ * ((float) Number_Of_Runs));
+ Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
+ / (float) User_Time;
+*/
+#endif
+/*
+ printf ("Microseconds for one run through Dhrystone: ");
+ printf ("%6.1f \n", Microseconds);
+ printf ("Dhrystones per Second: ");
+ printf ("%6.1f \n", Dhrystones_Per_Second);
+ printf ("\n");
+*/
+ }
+
+ exit (0);
+}
+
+
+Proc_1 (Ptr_Val_Par)
+/******************/
+
+REG Rec_Pointer Ptr_Val_Par;
+ /* executed once */
+{
+ REG Rec_Pointer Next_Record = Ptr_Val_Par->Ptr_Comp;
+ /* == Ptr_Glob_Next */
+ /* Local variable, initialized with Ptr_Val_Par->Ptr_Comp, */
+ /* corresponds to "rename" in Ada, "with" in Pascal */
+
+ structassign (*Ptr_Val_Par->Ptr_Comp, *Ptr_Glob);
+ Ptr_Val_Par->variant.var_1.Int_Comp = 5;
+ Next_Record->variant.var_1.Int_Comp
+ = Ptr_Val_Par->variant.var_1.Int_Comp;
+ Next_Record->Ptr_Comp = Ptr_Val_Par->Ptr_Comp;
+ Proc_3 (&Next_Record->Ptr_Comp);
+ /* Ptr_Val_Par->Ptr_Comp->Ptr_Comp
+ == Ptr_Glob->Ptr_Comp */
+ if (Next_Record->Discr == Ident_1)
+ /* then, executed */
+ {
+ Next_Record->variant.var_1.Int_Comp = 6;
+ Proc_6 (Ptr_Val_Par->variant.var_1.Enum_Comp,
+ &Next_Record->variant.var_1.Enum_Comp);
+ Next_Record->Ptr_Comp = Ptr_Glob->Ptr_Comp;
+ Proc_7 (Next_Record->variant.var_1.Int_Comp, 10,
+ &Next_Record->variant.var_1.Int_Comp);
+ }
+ else /* not executed */
+ structassign (*Ptr_Val_Par, *Ptr_Val_Par->Ptr_Comp);
+} /* Proc_1 */
+
+
+Proc_2 (Int_Par_Ref)
+/******************/
+ /* executed once */
+ /* *Int_Par_Ref == 1, becomes 4 */
+
+One_Fifty *Int_Par_Ref;
+{
+ One_Fifty Int_Loc;
+ Enumeration Enum_Loc;
+
+ Int_Loc = *Int_Par_Ref + 10;
+ do /* executed once */
+ if (Ch_1_Glob == 'A')
+ /* then, executed */
+ {
+ Int_Loc -= 1;
+ *Int_Par_Ref = Int_Loc - Int_Glob;
+ Enum_Loc = Ident_1;
+ } /* if */
+ while (Enum_Loc != Ident_1); /* true */
+} /* Proc_2 */
+
+
+Proc_3 (Ptr_Ref_Par)
+/******************/
+ /* executed once */
+ /* Ptr_Ref_Par becomes Ptr_Glob */
+
+Rec_Pointer *Ptr_Ref_Par;
+
+{
+ if (Ptr_Glob != Null)
+ /* then, executed */
+ *Ptr_Ref_Par = Ptr_Glob->Ptr_Comp;
+ Proc_7 (10, Int_Glob, &Ptr_Glob->variant.var_1.Int_Comp);
+} /* Proc_3 */
+
+
+Proc_4 () /* without parameters */
+/*******/
+ /* executed once */
+{
+ Boolean Bool_Loc;
+
+ Bool_Loc = Ch_1_Glob == 'A';
+ Bool_Glob = Bool_Loc | Bool_Glob;
+ Ch_2_Glob = 'B';
+} /* Proc_4 */
+
+
+Proc_5 () /* without parameters */
+/*******/
+ /* executed once */
+{
+ Ch_1_Glob = 'A';
+ Bool_Glob = false;
+} /* Proc_5 */
+
+
+ /* Procedure for the assignment of structures, */
+ /* if the C compiler doesn't support this feature */
+#ifdef NOSTRUCTASSIGN
+memcpy (d, s, l)
+register char *d;
+register char *s;
+register int l;
+{
+ while (l--) *d++ = *s++;
+}
+#endif
+
+
+/*
+ ****************************************************************************
+ *
+ * "DHRYSTONE" Benchmark Program
+ * -----------------------------
+ *
+ * Version: C, Version 2.1
+ *
+ * File: dhry_2.c (part 3 of 3)
+ *
+ * Date: May 25, 1988
+ *
+ * Author: Reinhold P. Weicker
+ *
+ ****************************************************************************
+ */
+
+#ifndef REG
+#define REG
+ /* REG becomes defined as empty */
+ /* i.e. no register variables */
+#endif
+
+extern int Int_Glob;
+extern char Ch_1_Glob;
+
+
+Proc_6 (Enum_Val_Par, Enum_Ref_Par)
+/*********************************/
+ /* executed once */
+ /* Enum_Val_Par == Ident_3, Enum_Ref_Par becomes Ident_2 */
+
+Enumeration Enum_Val_Par;
+Enumeration *Enum_Ref_Par;
+{
+ *Enum_Ref_Par = Enum_Val_Par;
+ if (! Func_3 (Enum_Val_Par))
+ /* then, not executed */
+ *Enum_Ref_Par = Ident_4;
+ switch (Enum_Val_Par)
+ {
+ case Ident_1:
+ *Enum_Ref_Par = Ident_1;
+ break;
+ case Ident_2:
+ if (Int_Glob > 100)
+ /* then */
+ *Enum_Ref_Par = Ident_1;
+ else *Enum_Ref_Par = Ident_4;
+ break;
+ case Ident_3: /* executed */
+ *Enum_Ref_Par = Ident_2;
+ break;
+ case Ident_4: break;
+ case Ident_5:
+ *Enum_Ref_Par = Ident_3;
+ break;
+ } /* switch */
+} /* Proc_6 */
+
+
+Proc_7 (Int_1_Par_Val, Int_2_Par_Val, Int_Par_Ref)
+/**********************************************/
+ /* executed three times */
+ /* first call: Int_1_Par_Val == 2, Int_2_Par_Val == 3, */
+ /* Int_Par_Ref becomes 7 */
+ /* second call: Int_1_Par_Val == 10, Int_2_Par_Val == 5, */
+ /* Int_Par_Ref becomes 17 */
+ /* third call: Int_1_Par_Val == 6, Int_2_Par_Val == 10, */
+ /* Int_Par_Ref becomes 18 */
+One_Fifty Int_1_Par_Val;
+One_Fifty Int_2_Par_Val;
+One_Fifty *Int_Par_Ref;
+{
+ One_Fifty Int_Loc;
+
+ Int_Loc = Int_1_Par_Val + 2;
+ *Int_Par_Ref = Int_2_Par_Val + Int_Loc;
+} /* Proc_7 */
+
+
+Proc_8 (Arr_1_Par_Ref, Arr_2_Par_Ref, Int_1_Par_Val, Int_2_Par_Val)
+/*********************************************************************/
+ /* executed once */
+ /* Int_Par_Val_1 == 3 */
+ /* Int_Par_Val_2 == 7 */
+Arr_1_Dim Arr_1_Par_Ref;
+Arr_2_Dim Arr_2_Par_Ref;
+int Int_1_Par_Val;
+int Int_2_Par_Val;
+{
+ REG One_Fifty Int_Index;
+ REG One_Fifty Int_Loc;
+
+ Int_Loc = Int_1_Par_Val + 5;
+ Arr_1_Par_Ref [Int_Loc] = Int_2_Par_Val;
+ Arr_1_Par_Ref [Int_Loc+1] = Arr_1_Par_Ref [Int_Loc];
+ Arr_1_Par_Ref [Int_Loc+30] = Int_Loc;
+ for (Int_Index = Int_Loc; Int_Index <= Int_Loc+1; ++Int_Index)
+ Arr_2_Par_Ref [Int_Loc] [Int_Index] = Int_Loc;
+ Arr_2_Par_Ref [Int_Loc] [Int_Loc-1] += 1;
+ Arr_2_Par_Ref [Int_Loc+20] [Int_Loc] = Arr_1_Par_Ref [Int_Loc];
+ Int_Glob = 5;
+} /* Proc_8 */
+
+
+Enumeration Func_1 (Ch_1_Par_Val, Ch_2_Par_Val)
+/*************************************************/
+ /* executed three times */
+ /* first call: Ch_1_Par_Val == 'H', Ch_2_Par_Val == 'R' */
+ /* second call: Ch_1_Par_Val == 'A', Ch_2_Par_Val == 'C' */
+ /* third call: Ch_1_Par_Val == 'B', Ch_2_Par_Val == 'C' */
+
+Capital_Letter Ch_1_Par_Val;
+Capital_Letter Ch_2_Par_Val;
+{
+ Capital_Letter Ch_1_Loc;
+ Capital_Letter Ch_2_Loc;
+
+ Ch_1_Loc = Ch_1_Par_Val;
+ Ch_2_Loc = Ch_1_Loc;
+ if (Ch_2_Loc != Ch_2_Par_Val)
+ /* then, executed */
+ return (Ident_1);
+ else /* not executed */
+ {
+ Ch_1_Glob = Ch_1_Loc;
+ return (Ident_2);
+ }
+} /* Func_1 */
+
+
+Boolean Func_2 (Str_1_Par_Ref, Str_2_Par_Ref)
+/*************************************************/
+ /* executed once */
+ /* Str_1_Par_Ref == "DHRYSTONE PROGRAM, 1'ST STRING" */
+ /* Str_2_Par_Ref == "DHRYSTONE PROGRAM, 2'ND STRING" */
+
+Str_30 Str_1_Par_Ref;
+Str_30 Str_2_Par_Ref;
+{
+ REG One_Thirty Int_Loc;
+ Capital_Letter Ch_Loc;
+
+ Int_Loc = 2;
+ while (Int_Loc <= 2) /* loop body executed once */
+ if (Func_1 (Str_1_Par_Ref[Int_Loc],
+ Str_2_Par_Ref[Int_Loc+1]) == Ident_1)
+ /* then, executed */
+ {
+ Ch_Loc = 'A';
+ Int_Loc += 1;
+ } /* if, while */
+ if (Ch_Loc >= 'W' && Ch_Loc < 'Z')
+ /* then, not executed */
+ Int_Loc = 7;
+ if (Ch_Loc == 'R')
+ /* then, not executed */
+ return (true);
+ else /* executed */
+ {
+ if (strcmp (Str_1_Par_Ref, Str_2_Par_Ref) > 0)
+ /* then, not executed */
+ {
+ Int_Loc += 7;
+ Int_Glob = Int_Loc;
+ return (true);
+ }
+ else /* executed */
+ return (false);
+ } /* if Ch_Loc */
+} /* Func_2 */
+
+
+Boolean Func_3 (Enum_Par_Val)
+/***************************/
+ /* executed once */
+ /* Enum_Par_Val == Ident_3 */
+Enumeration Enum_Par_Val;
+{
+ Enumeration Enum_Loc;
+
+ Enum_Loc = Enum_Par_Val;
+ if (Enum_Loc == Ident_3)
+ /* then, executed */
+ return (true);
+ else /* not executed */
+ return (false);
+} /* Func_3 */
+
diff --git a/gcc/testsuite/gcc.misc-tests/dhry.exp b/gcc/testsuite/gcc.misc-tests/dhry.exp
new file mode 100644
index 000000000..c913a955d
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/dhry.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+global PERF_TEST
+if { ![info exists PERF_TEST] || "$PERF_TEST" != "yes" } {
+ return
+}
+
+load_lib mike-gcc.exp
+
+prebase
+set actions run
+set compiler_output "^$"
+set program_output "^$"
+postbase dhry.c $run $groups
diff --git a/gcc/testsuite/gcc.misc-tests/dhry.h b/gcc/testsuite/gcc.misc-tests/dhry.h
new file mode 100644
index 000000000..3e04260dd
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/dhry.h
@@ -0,0 +1,433 @@
+/*
+ ****************************************************************************
+ *
+ * "DHRYSTONE" Benchmark Program
+ * -----------------------------
+ *
+ * Version: C, Version 2.1
+ *
+ * File: dhry.h (part 1 of 3)
+ *
+ * Date: May 25, 1988
+ *
+ * Author: Reinhold P. Weicker
+ * Siemens AG, AUT E 51
+ * Postfach 3220
+ * 8520 Erlangen
+ * Germany (West)
+ * Phone: [+49]-9131-7-20330
+ * (8-17 Central European Time)
+ * Usenet: ..!mcsun!unido!estevax!weicker
+ *
+ * Original Version (in Ada) published in
+ * "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
+ * pp. 1013 - 1030, together with the statistics
+ * on which the distribution of statements etc. is based.
+ *
+ * In this C version, the following C library functions are used:
+ * - strcpy, strcmp (inside the measurement loop)
+ * - printf, scanf (outside the measurement loop)
+ * In addition, Berkeley UNIX system calls "times ()" or "time ()"
+ * are used for execution time measurement. For measurements
+ * on other systems, these calls have to be changed.
+ *
+ * Collection of Results:
+ * Reinhold Weicker (address see above) and
+ *
+ * Rick Richardson
+ * PC Research. Inc.
+ * 94 Apple Orchard Drive
+ * Tinton Falls, NJ 07724
+ * Phone: (201) 389-8963 (9-17 EST)
+ * Usenet: ...!uunet!pcrat!rick
+ *
+ * Please send results to Rick Richardson and/or Reinhold Weicker.
+ * Complete information should be given on hardware and software used.
+ * Hardware information includes: Machine type, CPU, type and size
+ * of caches; for microprocessors: clock frequency, memory speed
+ * (number of wait states).
+ * Software information includes: Compiler (and runtime library)
+ * manufacturer and version, compilation switches, OS version.
+ * The Operating System version may give an indication about the
+ * compiler; Dhrystone itself performs no OS calls in the measurement loop.
+ *
+ * The complete output generated by the program should be mailed
+ * such that at least some checks for correctness can be made.
+ *
+ ***************************************************************************
+ *
+ * History: This version C/2.1 has been made for two reasons:
+ *
+ * 1) There is an obvious need for a common C version of
+ * Dhrystone, since C is at present the most popular system
+ * programming language for the class of processors
+ * (microcomputers, minicomputers) where Dhrystone is used most.
+ * There should be, as far as possible, only one C version of
+ * Dhrystone such that results can be compared without
+ * restrictions. In the past, the C versions distributed
+ * by Rick Richardson (Version 1.1) and by Reinhold Weicker
+ * had small (though not significant) differences.
+ *
+ * 2) As far as it is possible without changes to the Dhrystone
+ * statistics, optimizing compilers should be prevented from
+ * removing significant statements.
+ *
+ * This C version has been developed in cooperation with
+ * Rick Richardson (Tinton Falls, NJ), it incorporates many
+ * ideas from the "Version 1.1" distributed previously by
+ * him over the UNIX network Usenet.
+ * I also thank Chaim Benedelac (National Semiconductor),
+ * David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
+ * Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
+ * for their help with comments on earlier versions of the
+ * benchmark.
+ *
+ * Changes: In the initialization part, this version follows mostly
+ * Rick Richardson's version distributed via Usenet, not the
+ * version distributed earlier via floppy disk by Reinhold Weicker.
+ * As a concession to older compilers, names have been made
+ * unique within the first 8 characters.
+ * Inside the measurement loop, this version follows the
+ * version previously distributed by Reinhold Weicker.
+ *
+ * At several places in the benchmark, code has been added,
+ * but within the measurement loop only in branches that
+ * are not executed. The intention is that optimizing compilers
+ * should be prevented from moving code out of the measurement
+ * loop, or from removing code altogether. Since the statements
+ * that are executed within the measurement loop have NOT been
+ * changed, the numbers defining the "Dhrystone distribution"
+ * (distribution of statements, operand types and locality)
+ * still hold. Except for sophisticated optimizing compilers,
+ * execution times for this version should be the same as
+ * for previous versions.
+ *
+ * Since it has proven difficult to subtract the time for the
+ * measurement loop overhead in a correct way, the loop check
+ * has been made a part of the benchmark. This does have
+ * an impact - though a very minor one - on the distribution
+ * statistics which have been updated for this version.
+ *
+ * All changes within the measurement loop are described
+ * and discussed in the companion paper "Rationale for
+ * Dhrystone version 2".
+ *
+ * Because of the self-imposed limitation that the order and
+ * distribution of the executed statements should not be
+ * changed, there are still cases where optimizing compilers
+ * may not generate code for some statements. To a certain
+ * degree, this is unavoidable for small synthetic benchmarks.
+ * Users of the benchmark are advised to check code listings
+ * whether code is generated for all statements of Dhrystone.
+ *
+ * Version 2.1 is identical to version 2.0 distributed via
+ * the UNIX network Usenet in March 1988 except that it corrects
+ * some minor deficiencies that were found by users of version 2.0.
+ * The only change within the measurement loop is that a
+ * non-executed "else" part was added to the "if" statement in
+ * Func_3, and a non-executed "else" part removed from Proc_3.
+ *
+ ***************************************************************************
+ *
+ * Defines: The following "Defines" are possible:
+ * -DREG=register (default: Not defined)
+ * As an approximation to what an average C programmer
+ * might do, the "register" storage class is applied
+ * (if enabled by -DREG=register)
+ * - for local variables, if they are used (dynamically)
+ * five or more times
+ * - for parameters if they are used (dynamically)
+ * six or more times
+ * Note that an optimal "register" strategy is
+ * compiler-dependent, and that "register" declarations
+ * do not necessarily lead to faster execution.
+ * -DNOSTRUCTASSIGN (default: Not defined)
+ * Define if the C compiler does not support
+ * assignment of structures.
+ * -DNOENUMS (default: Not defined)
+ * Define if the C compiler does not support
+ * enumeration types.
+ * -DTIMES (default)
+ * -DTIME
+ * The "times" function of UNIX (returning process times)
+ * or the "time" function (returning wallclock time)
+ * is used for measurement.
+ * For single user machines, "time ()" is adequate. For
+ * multi-user machines where you cannot get single-user
+ * access, use the "times ()" function. If you have
+ * neither, use a stopwatch in the dead of night.
+ * "printf"s are provided marking the points "Start Timer"
+ * and "Stop Timer". DO NOT use the UNIX "time(1)"
+ * command, as this will measure the total time to
+ * run this program, which will (erroneously) include
+ * the time to allocate storage (malloc) and to perform
+ * the initialization.
+ * -DHZ=nnn
+ * In Berkeley UNIX, the function "times" returns process
+ * time in 1/HZ seconds, with HZ = 60 for most systems.
+ * CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
+ * A VALUE.
+ *
+ ***************************************************************************
+ *
+ * Compilation model and measurement (IMPORTANT):
+ *
+ * This C version of Dhrystone consists of three files:
+ * - dhry.h (this file, containing global definitions and comments)
+ * - dhry_1.c (containing the code corresponding to Ada package Pack_1)
+ * - dhry_2.c (containing the code corresponding to Ada package Pack_2)
+ *
+ * The following "ground rules" apply for measurements:
+ * - Separate compilation
+ * - No procedure merging
+ * - Otherwise, compiler optimizations are allowed but should be indicated
+ * - Default results are those without register declarations
+ * See the companion paper "Rationale for Dhrystone Version 2" for a more
+ * detailed discussion of these ground rules.
+ *
+ * For 16-Bit processors (e.g. 80186, 80286), times for all compilation
+ * models ("small", "medium", "large" etc.) should be given if possible,
+ * together with a definition of these models for the compiler system used.
+ *
+ **************************************************************************
+ *
+ * Dhrystone (C version) statistics:
+ *
+ * [Comment from the first distribution, updated for version 2.
+ * Note that because of language differences, the numbers are slightly
+ * different from the Ada version.]
+ *
+ * The following program contains statements of a high level programming
+ * language (here: C) in a distribution considered representative:
+ *
+ * assignments 52 (51.0 %)
+ * control statements 33 (32.4 %)
+ * procedure, function calls 17 (16.7 %)
+ *
+ * 103 statements are dynamically executed. The program is balanced with
+ * respect to the three aspects:
+ *
+ * - statement type
+ * - operand type
+ * - operand locality
+ * operand global, local, parameter, or constant.
+ *
+ * The combination of these three aspects is balanced only approximately.
+ *
+ * 1. Statement Type:
+ * ----------------- number
+ *
+ * V1 = V2 9
+ * (incl. V1 = F(..)
+ * V = Constant 12
+ * Assignment, 7
+ * with array element
+ * Assignment, 6
+ * with record component
+ * --
+ * 34 34
+ *
+ * X = Y +|-|"&&"|"|" Z 5
+ * X = Y +|-|"==" Constant 6
+ * X = X +|- 1 3
+ * X = Y *|/ Z 2
+ * X = Expression, 1
+ * two operators
+ * X = Expression, 1
+ * three operators
+ * --
+ * 18 18
+ *
+ * if .... 14
+ * with "else" 7
+ * without "else" 7
+ * executed 3
+ * not executed 4
+ * for ... 7 | counted every time
+ * while ... 4 | the loop condition
+ * do ... while 1 | is evaluated
+ * switch ... 1
+ * break 1
+ * declaration with 1
+ * initialization
+ * --
+ * 34 34
+ *
+ * P (...) procedure call 11
+ * user procedure 10
+ * library procedure 1
+ * X = F (...)
+ * function call 6
+ * user function 5
+ * library function 1
+ * --
+ * 17 17
+ * ---
+ * 103
+ *
+ * The average number of parameters in procedure or function calls
+ * is 1.82 (not counting the function values as implicit parameters).
+ *
+ *
+ * 2. Operators
+ * ------------
+ * number approximate
+ * percentage
+ *
+ * Arithmetic 32 50.8
+ *
+ * + 21 33.3
+ * - 7 11.1
+ * * 3 4.8
+ * / (int div) 1 1.6
+ *
+ * Comparison 27 42.8
+ *
+ * == 9 14.3
+ * /= 4 6.3
+ * > 1 1.6
+ * < 3 4.8
+ * >= 1 1.6
+ * <= 9 14.3
+ *
+ * Logic 4 6.3
+ *
+ * && (AND-THEN) 1 1.6
+ * | (OR) 1 1.6
+ * ! (NOT) 2 3.2
+ *
+ * -- -----
+ * 63 100.1
+ *
+ *
+ * 3. Operand Type (counted once per operand reference):
+ * ---------------
+ * number approximate
+ * percentage
+ *
+ * Integer 175 72.3 %
+ * Character 45 18.6 %
+ * Pointer 12 5.0 %
+ * String30 6 2.5 %
+ * Array 2 0.8 %
+ * Record 2 0.8 %
+ * --- -------
+ * 242 100.0 %
+ *
+ * When there is an access path leading to the final operand (e.g. a record
+ * component), only the final data type on the access path is counted.
+ *
+ *
+ * 4. Operand Locality:
+ * -------------------
+ * number approximate
+ * percentage
+ *
+ * local variable 114 47.1 %
+ * global variable 22 9.1 %
+ * parameter 45 18.6 %
+ * value 23 9.5 %
+ * reference 22 9.1 %
+ * function result 6 2.5 %
+ * constant 55 22.7 %
+ * --- -------
+ * 242 100.0 %
+ *
+ *
+ * The program does not compute anything meaningful, but it is syntactically
+ * and semantically correct. All variables have a value assigned to them
+ * before they are used as a source operand.
+ *
+ * There has been no explicit effort to account for the effects of a
+ * cache, or to balance the use of long or short displacements for code or
+ * data.
+ *
+ ***************************************************************************
+ */
+
+/* Compiler and system dependent definitions: */
+/*
+#ifndef TIME
+#define TIMES
+#endif
+*/ /* Use times(2) time function unless */
+ /* explicitly defined otherwise */
+
+/*
+ #ifndef HZ
+ #define HZ 60
+ #endif
+*/
+
+/*
+#ifdef TIMES
+#include <sys/types.h>
+#include <sys/times.h>
+*/ /* for "times" */
+/*
+#endif
+*/
+#define Mic_secs_Per_Second 1000000.0
+ /* Berkeley UNIX C returns process times in seconds/HZ */
+
+#ifdef NOSTRUCTASSIGN
+#define structassign(d, s) memcpy(&(d), &(s), sizeof(d))
+#else
+#define structassign(d, s) d = s
+#endif
+
+#ifdef NOENUM
+#define Ident_1 0
+#define Ident_2 1
+#define Ident_3 2
+#define Ident_4 3
+#define Ident_5 4
+ typedef int Enumeration;
+#else
+ typedef enum {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
+ Enumeration;
+#endif
+ /* for boolean and enumeration types in Ada, Pascal */
+
+/* General definitions: */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+ /* for strcpy, strcmp */
+
+#define Null 0
+ /* Value of a Null pointer */
+#define true 1
+#define false 0
+
+typedef int One_Thirty;
+typedef int One_Fifty;
+typedef char Capital_Letter;
+typedef int Boolean;
+typedef char Str_30 [31];
+typedef int Arr_1_Dim [50];
+typedef int Arr_2_Dim [50] [50];
+
+typedef struct record
+ {
+ struct record *Ptr_Comp;
+ Enumeration Discr;
+ union {
+ struct {
+ Enumeration Enum_Comp;
+ int Int_Comp;
+ char Str_Comp [31];
+ } var_1;
+ struct {
+ Enumeration E_Comp_2;
+ char Str_2_Comp [31];
+ } var_2;
+ struct {
+ char Ch_1_Comp;
+ char Ch_2_Comp;
+ } var_3;
+ } variant;
+ } Rec_Type, *Rec_Pointer;
+
+
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-1.c b/gcc/testsuite/gcc.misc-tests/gcov-1.c
new file mode 100644
index 000000000..99a02790d
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-1.c
@@ -0,0 +1,20 @@
+/* Test Gcov basics. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+void noop ()
+{
+}
+
+int main ()
+{
+ int i;
+
+ for (i = 0; i < 10; i++) /* count(11) */
+ noop (); /* count(10) */
+
+ return 0; /* count(1) */
+}
+
+/* { dg-final { run-gcov gcov-1.c } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-10.c b/gcc/testsuite/gcc.misc-tests/gcov-10.c
new file mode 100644
index 000000000..bd1d418f3
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-10.c
@@ -0,0 +1,15 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main ()
+{
+ unsigned ix, jx = 0;
+
+ for (ix = 10; ix--;) if (ix & 1) jx++; /* count(11) */
+
+ return jx != 5;
+}
+
+/* { dg-final { run-gcov { -a gcov-10.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-10b.c b/gcc/testsuite/gcc.misc-tests/gcov-10b.c
new file mode 100644
index 000000000..148d779fd
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-10b.c
@@ -0,0 +1,16 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main ()
+{
+ unsigned ix, jx = 0;
+
+ ix = 10; goto test; loop: ; if (ix & 1) jx++; test: ; if (ix--) goto loop; /* count(11) */
+
+ return jx != 5;
+}
+
+/* { dg-final { run-gcov { -a gcov-10b.c } } } */
+
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-11.c b/gcc/testsuite/gcc.misc-tests/gcov-11.c
new file mode 100644
index 000000000..a1037a552
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-11.c
@@ -0,0 +1,23 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int one = 1; /* subvert constant folder. */
+int zero = 0;
+
+int foo (int ix)
+{
+ return ix & 1 ? one : zero; /* count(10) */
+}
+
+int main ()
+{
+ unsigned ix, jx = 0;
+
+ for (ix = 10; ix--;) jx += foo (ix); /* count(11) */
+
+ return jx != 5;
+}
+
+/* { dg-final { run-gcov { -a gcov-11.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-2.c b/gcc/testsuite/gcc.misc-tests/gcov-2.c
new file mode 100644
index 000000000..aa3e4b74e
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-2.c
@@ -0,0 +1,22 @@
+/* Test Gcov basics. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -g" } */
+/* { dg-do run { target native } } */
+
+void noop ()
+{
+}
+
+int main ()
+{
+ int i;
+
+ for (i = 0; i < 10; i++) /* count(11) */
+ noop (); /* count(10) */
+
+ return 0; /* count(1) */
+}
+
+int a_variable = 0;
+
+/* { dg-final { run-gcov gcov-2.c } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-3.c b/gcc/testsuite/gcc.misc-tests/gcov-3.c
new file mode 100644
index 000000000..fcccdeeff
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-3.c
@@ -0,0 +1,48 @@
+/* Test Gcov with computed gotos.
+ This is the same as test gcc.c-torture/execute/980526-1.c */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+extern void abort (void);
+extern void exit (int);
+
+int expect_do1 = 1, expect_do2 = 2;
+
+static int doit(int x){
+ __label__ lbl1;
+ __label__ lbl2;
+ static int jtab_init = 0;
+ static void *jtab[2];
+
+ if(!jtab_init) {
+ jtab[0] = &&lbl1;
+ jtab[1] = &&lbl2;
+ jtab_init = 1;
+ }
+ goto *jtab[x];
+lbl1:
+ return 1;
+lbl2:
+ return 2;
+}
+
+static void do1(void) {
+ if (doit(0) != expect_do1)
+ abort ();
+}
+
+static void do2(void){
+ if (doit(1) != expect_do2)
+ abort ();
+}
+
+int main(void){ /* count(1) */
+#ifndef NO_LABEL_VALUES
+ do1();
+ do2();
+#endif
+ exit(0); /* count(1) */
+}
+
+/* { dg-final { run-gcov gcov-3.c } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4.c b/gcc/testsuite/gcc.misc-tests/gcov-4.c
new file mode 100644
index 000000000..9d8ab1c10
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-4.c
@@ -0,0 +1,273 @@
+/* Check that execution counts for various C constructs are reported
+ correctly by gcov. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+extern void abort (void);
+
+int do_something (int i)
+{
+ return i;
+}
+
+/* Check static inline functions. */
+
+int unref_val;
+
+static inline int
+unreferenced (int i, int j)
+{
+ return i - j;
+}
+
+static inline int
+uncalled (int i, int j)
+{
+ return i * j;
+}
+
+static inline int
+called (int i, int j)
+{
+ return i + j; /* count(1) */
+}
+
+void
+call_unref ()
+{
+ if (unref_val) /* count(1) */
+ unref_val = uncalled (1, 2);
+ unref_val = called (unref_val, 4); /* count(1) */
+}
+
+
+/* Check for loops. */
+
+int for_val1;
+int for_val2;
+int for_temp;
+
+int
+test_for1 (int n)
+{
+ int i;
+ for_temp = 1; /* count(3) */
+ for (i = 0; i < n; i++)
+ for_temp++; /* count(9) */
+ return for_temp; /* count(3) */
+}
+
+int
+test_for2 (int m, int n, int o)
+{
+ int i, j, k;
+ for_temp = 1; /* count(6) */
+ for (i = 0; i < n; i++)
+ for (j = 0; j < m; j++)
+ for (k = 0; k < o; k++)
+ for_temp++; /* count(81) */
+ return for_temp; /* count(6) */
+}
+
+void
+call_for ()
+{
+ for_val1 += test_for1 (0);
+ for_val1 += test_for1 (2);
+ for_val1 += test_for1 (7);
+
+ for_val2 += test_for2 (0, 0, 0);
+ for_val2 += test_for2 (1, 0, 0);
+ for_val2 += test_for2 (1, 3, 0);
+ for_val2 += test_for2 (1, 3, 1);
+ for_val2 += test_for2 (3, 1, 5);
+ for_val2 += test_for2 (3, 7, 3);
+}
+
+/* Check the use of goto. */
+
+int goto_val;
+
+int
+test_goto1 (int f)
+{
+ if (f) /* count(2) */
+ goto lab1; /* count(1) */
+ return 1; /* count(1) */
+lab1:
+ return 2; /* count(1) */
+}
+
+int
+test_goto2 (int f)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* count(15) */
+ if (i == f) goto lab2; /* count(14) */
+ return 4; /* count(1) */
+lab2:
+ return 8; /* count(1) */
+}
+
+void
+call_goto ()
+{
+ goto_val += test_goto1 (0);
+ goto_val += test_goto1 (1);
+ goto_val += test_goto2 (3);
+ goto_val += test_goto2 (30);
+}
+
+/* Check nested if-then-else statements. */
+
+int ifelse_val1;
+int ifelse_val2;
+int ifelse_val3;
+
+int
+test_ifelse1 (int i, int j)
+{
+ int result = 0;
+ if (i) /* count(5) */
+ if (j) /* count(3) */
+ result = do_something (4); /* count(3) */
+ else
+ result = do_something (1024);
+ else
+ if (j) /* count(2) */
+ result = do_something (1); /* count(1) */
+ else
+ result = do_something (2); /* count(1) */
+ if (i > j) /* count(5) */
+ result = do_something (result*2); /* count(1) */
+ if (i > 10) /* count(5) */
+ if (j > 10) /* count(1) */
+ result = do_something (result*4); /* count(1) */
+ return result; /* count(5) */
+}
+
+int
+test_ifelse2 (int i)
+{
+ int result = 0;
+ if (!i) /* count(6) */
+ result = do_something (1); /* count(1) */
+ if (i == 1) /* count(6) */
+ result = do_something (1024);
+ if (i == 2) /* count(6) */
+ result = do_something (2); /* count(3) */
+ if (i == 3) /* count(6) */
+ return do_something (8); /* count(2) */
+ if (i == 4) /* count(4) */
+ return do_something (2048);
+ return result; /* count(4) */
+}
+
+int
+test_ifelse3 (int i, int j)
+{
+ int result = 1;
+ if (i > 10 && j > i && j < 20) /* count(11) */
+ result = do_something (16); /* count(1) */
+ if (i > 20) /* count(11) */
+ if (j > i) /* count(5) */
+ if (j < 30) /* count(2) */
+ result = do_something (32); /* count(1) */
+ if (i == 3 || j == 47 || i == j) /* count(11) */
+ result = do_something (64); /* count(3) */
+ return result; /* count(11) */
+}
+
+void
+call_ifelse ()
+{
+ ifelse_val1 += test_ifelse1 (0, 2);
+ ifelse_val1 += test_ifelse1 (0, 0);
+ ifelse_val1 += test_ifelse1 (1, 2);
+ ifelse_val1 += test_ifelse1 (10, 2);
+ ifelse_val1 += test_ifelse1 (11, 11);
+
+ ifelse_val2 += test_ifelse2 (0);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (3);
+ ifelse_val2 += test_ifelse2 (3);
+
+ ifelse_val3 += test_ifelse3 (11, 19);
+ ifelse_val3 += test_ifelse3 (25, 27);
+ ifelse_val3 += test_ifelse3 (11, 22);
+ ifelse_val3 += test_ifelse3 (11, 10);
+ ifelse_val3 += test_ifelse3 (21, 32);
+ ifelse_val3 += test_ifelse3 (21, 20);
+ ifelse_val3 += test_ifelse3 (1, 2);
+ ifelse_val3 += test_ifelse3 (32, 31);
+ ifelse_val3 += test_ifelse3 (3, 0);
+ ifelse_val3 += test_ifelse3 (0, 47);
+ ifelse_val3 += test_ifelse3 (65, 65);
+}
+
+/* Check switch statements. */
+
+int switch_val, switch_m;
+
+int
+test_switch (int i, int j)
+{
+ int result = 0; /* count(5) */
+
+ switch (i) /* count(5) */
+ {
+ case 1:
+ result = do_something (2); /* count(1) */
+ break;
+ case 2:
+ result = do_something (1024);
+ break;
+ case 3:
+ case 4:
+ if (j == 2) /* count(3) */
+ return do_something (4); /* count(1) */
+ result = do_something (8); /* count(2) */
+ break;
+ default:
+ result = do_something (32); /* count(1) */
+ switch_m++; /* count(1) */
+ break;
+ }
+ return result; /* count(4) */
+}
+
+void
+call_switch ()
+{
+ switch_val += test_switch (1, 0);
+ switch_val += test_switch (3, 0);
+ switch_val += test_switch (3, 2);
+ switch_val += test_switch (4, 0);
+ switch_val += test_switch (16, 0);
+ switch_val += switch_m;
+}
+
+int
+main()
+{
+ call_for ();
+ call_goto ();
+ call_ifelse ();
+ call_switch ();
+ call_unref ();
+ if ((for_val1 != 12)
+ || (for_val2 != 87)
+ || (goto_val != 15)
+ || (ifelse_val1 != 31)
+ || (ifelse_val2 != 23)
+ || (ifelse_val3 != 246)
+ || (switch_val != 55)
+ || (unref_val != 4))
+ abort ();
+ return 0;
+}
+
+/* { dg-final { run-gcov gcov-4.c } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-4b.c b/gcc/testsuite/gcc.misc-tests/gcov-4b.c
new file mode 100644
index 000000000..da98749f7
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-4b.c
@@ -0,0 +1,263 @@
+/* Check that execution counts for various C constructs are reported
+ correctly by gcov. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+extern void abort (void);
+
+int do_something (int i)
+{
+ return i;
+}
+
+/* Check for loops. */
+
+int for_val1;
+int for_val2;
+int for_temp;
+
+int
+test_for1 (int n)
+{
+ int i;
+ for_temp = 1;
+ for (i = 0; i < n; i++) /* branch(25) */
+ /* branch(end) */
+ for_temp++;
+ return for_temp;
+}
+
+int
+test_for2 (int m, int n, int o)
+{
+ int i, j, k;
+ for_temp = 1;
+ for (i = 0; i < n; i++) /* branch(30) */
+ /* branch(end) */
+ for (j = 0; j < m; j++) /* branch(32) */
+ /* branch(end) */
+ for (k = 0; k < o; k++) /* branch(27) */
+ /* branch(end) */
+ for_temp++;
+ return for_temp;
+}
+
+void
+call_for ()
+{
+ for_val1 += test_for1 (0);
+ for_val1 += test_for1 (2);
+ for_val1 += test_for1 (7);
+
+ for_val2 += test_for2 (0, 0, 0);
+ for_val2 += test_for2 (1, 0, 0);
+ for_val2 += test_for2 (1, 3, 0);
+ for_val2 += test_for2 (1, 3, 1);
+ for_val2 += test_for2 (3, 1, 5);
+ for_val2 += test_for2 (3, 7, 3);
+}
+
+/* Check the use of goto. */
+
+int goto_val;
+
+int
+test_goto1 (int f)
+{
+ if (f) /* branch(50) */
+ /* branch(end) */
+ goto lab1;
+ return 1;
+lab1:
+ return 2;
+}
+
+int
+test_goto2 (int f)
+{
+ int i;
+ for (i = 0; i < 10; i++) /* branch(7) */
+ /* branch(end) */
+ if (i == f) goto lab2;
+ return 4;
+lab2:
+ return 8;
+}
+
+void
+call_goto ()
+{
+ goto_val += test_goto1 (0);
+ goto_val += test_goto1 (1);
+ goto_val += test_goto2 (3);
+ goto_val += test_goto2 (30);
+}
+
+/* Check nested if-then-else statements. */
+
+int ifelse_val1;
+int ifelse_val2;
+int ifelse_val3;
+
+int
+test_ifelse1 (int i, int j)
+{
+ int result = 0;
+ if (i) /* branch(40) */
+ /* branch(end) */
+ if (j) /* branch(0) */
+ /* branch(end) */
+ result = do_something (4);
+ else
+ result = do_something (1024);
+ else
+ if (j) /* branch(50) */
+ /* branch(end) */
+ result = do_something (1);
+ else
+ result = do_something (2);
+ if (i > j) /* branch(80) */
+ /* branch(end) */
+ result = do_something (result*2);
+ if (i > 10) /* branch(80) */
+ /* branch(end) */
+ if (j > 10) /* branch(100) */
+ result = do_something (result*4);
+ return result;
+}
+
+int
+test_ifelse2 (int i)
+{
+ int result = 0;
+ if (!i) /* branch(83) */
+ /* branch(end) */
+ result = do_something (1);
+ if (i == 1) /* branch(100) */
+ /* branch(end) */
+ result = do_something (1024);
+ if (i == 2) /* branch(50) */
+ /* branch(end) */
+ result = do_something (2);
+ if (i == 3) /* branch(67) */
+ /* branch(end) */
+ return do_something (8);
+ if (i == 4) /* branch(100) */
+ /* branch(end) */
+ return do_something (2048);
+ return result;
+}
+
+int
+test_ifelse3 (int i, int j)
+{
+ int result = 1;
+ if (i > 10 && j > i && j < 20) /* branch(27 50 75) */
+ /* branch(end) */
+ result = do_something (16);
+ if (i > 20) /* branch(55) */
+ /* branch(end) */
+ if (j > i) /* branch(60) */
+ /* branch(end) */
+ if (j < 30) /* branch(50) */
+ /* branch(end) */
+ result = do_something (32);
+ if (i == 3 || j == 47 || i == j) /* branch(9 10 89) */
+ /* branch(end) */
+ result = do_something (64);
+ return result;
+}
+
+void
+call_ifelse ()
+{
+ ifelse_val1 += test_ifelse1 (0, 2);
+ ifelse_val1 += test_ifelse1 (0, 0);
+ ifelse_val1 += test_ifelse1 (1, 2);
+ ifelse_val1 += test_ifelse1 (10, 2);
+ ifelse_val1 += test_ifelse1 (11, 11);
+
+ ifelse_val2 += test_ifelse2 (0);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (2);
+ ifelse_val2 += test_ifelse2 (3);
+ ifelse_val2 += test_ifelse2 (3);
+
+ ifelse_val3 += test_ifelse3 (11, 19);
+ ifelse_val3 += test_ifelse3 (25, 27);
+ ifelse_val3 += test_ifelse3 (11, 22);
+ ifelse_val3 += test_ifelse3 (11, 10);
+ ifelse_val3 += test_ifelse3 (21, 32);
+ ifelse_val3 += test_ifelse3 (21, 20);
+ ifelse_val3 += test_ifelse3 (1, 2);
+ ifelse_val3 += test_ifelse3 (32, 31);
+ ifelse_val3 += test_ifelse3 (3, 0);
+ ifelse_val3 += test_ifelse3 (0, 47);
+ ifelse_val3 += test_ifelse3 (65, 65);
+}
+
+/* Check switch statements. */
+
+int switch_val, switch_m;
+
+int
+test_switch (int i, int j)
+{
+ int result = 0;
+
+ switch (i) /* branch(20 0 60 20) */
+ /* branch(end) */
+ {
+ case 1:
+ result = do_something (2);
+ break;
+ case 2:
+ result = do_something (1024);
+ break;
+ case 3:
+ case 4:
+ if (j == 2) /* branch(67) */
+ /* branch(end) */
+ return do_something (4);
+ result = do_something (8);
+ break;
+ default:
+ result = do_something (32);
+ switch_m++;
+ break;
+ }
+ return result;
+}
+
+void
+call_switch ()
+{
+ switch_val += test_switch (1, 0);
+ switch_val += test_switch (3, 0);
+ switch_val += test_switch (3, 2);
+ switch_val += test_switch (4, 0);
+ switch_val += test_switch (16, 0);
+ switch_val += switch_m;
+}
+
+int
+main()
+{
+ call_for ();
+ call_goto ();
+ call_ifelse ();
+ call_switch ();
+ if ((for_val1 != 12)
+ || (for_val2 != 87)
+ || (goto_val != 15)
+ || (ifelse_val1 != 31)
+ || (ifelse_val2 != 23)
+ || (ifelse_val3 != 246)
+ || (switch_val != 55))
+ abort ();
+ return 0;
+}
+
+/* { dg-final { run-gcov branches { -b gcov-4b.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-5b.c b/gcc/testsuite/gcc.misc-tests/gcov-5b.c
new file mode 100644
index 000000000..cbd395871
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-5b.c
@@ -0,0 +1,34 @@
+/* Check that branch percentages are calculated in variables
+ that are large enough to hold the count. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+#define LIMIT1 7000
+#define LIMIT2 7000
+
+int count;
+
+void incr_count ()
+{
+ count++;
+}
+
+void doit (int i, int j)
+{
+ if (i > j)
+ incr_count ();
+}
+
+int main ()
+{
+ int i, j;
+
+ for (i = 0; i < LIMIT1; i++)
+ for (j = 0; j < LIMIT2; j++)
+ doit (i, j);
+
+ return 0;
+}
+
+/* { dg-final { run-gcov branches { -b gcov-5b.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-6.c b/gcc/testsuite/gcc.misc-tests/gcov-6.c
new file mode 100644
index 000000000..aefab3ed3
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-6.c
@@ -0,0 +1,39 @@
+/* Check that call return percentages are reported correctly by gcov,
+ along with line counts and branch percentages. This test case is
+ meant to be simple, as it was added at the same time that checking
+ for call return percentages was added. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+extern void exit (int);
+
+int val;
+
+void
+foo (int i)
+{
+ /* branch(80) */
+ if (i < 0) /* count(5) */
+ /* branch(end) */
+ /* returns(0) */
+ exit (0); /* count(1) */
+ /* returns(end) */
+ val += i; /* count(4) */
+}
+
+int
+main()
+{
+ int i;
+
+ /* returns(100) */
+ foo (100); /* count(1) */
+ /* returns(end) */
+ for (i = 2; i > -10; i--)
+ /* returns(75) */
+ foo (i); /* count(4) */
+ /* returns(end) */
+}
+
+/* { dg-final { run-gcov branches calls { -b gcov-6.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-7.c b/gcc/testsuite/gcc.misc-tests/gcov-7.c
new file mode 100644
index 000000000..2e0f6e8b0
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-7.c
@@ -0,0 +1,87 @@
+/* Check that gcov correctly reports line counts, branch percentages,
+ * and call return percentages for functions that call longjmp. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+#include <setjmp.h>
+
+extern void abort (void);
+extern void exit (int);
+
+jmp_buf env;
+int val;
+int longjmp_taken;
+int bar_enter, bar_exit;
+int foo_enter, foo_exit;
+
+void bar (int i)
+{
+ bar_enter++; /* count(3) */
+ /* branch(67) */
+ if (i == 0) {
+ /* branch(end) */
+ longjmp_taken++; /* count(1) */
+ longjmp (env, 1);
+ }
+ val += i+1;
+ bar_exit++; /* count(2) */
+}
+
+void foo (int i)
+{
+ foo_enter++; /* count(3) */
+ /* branch(67) */
+ if (i == 1) {
+ /* branch(end) */
+ longjmp_taken++; /* count(1) */
+ longjmp (env, 2);
+ }
+ /* returns(50) */
+ bar (i); /* count(2) */
+ /* returns(100) */
+ bar (7); /* count(1) */
+ /* returns(end) */
+ val += 16;
+ foo_exit++; /* count(1) */
+}
+
+int
+passed ()
+{
+ return (val == 31 &&
+ longjmp_taken == 2 &&
+ foo_enter == 3 &&
+ foo_exit == 1 &&
+ bar_enter == 3 &&
+ bar_exit == 2);
+
+}
+
+void
+leave (int i)
+{
+ if (i == 0) {
+ abort ();
+ }
+ exit (0);
+}
+
+int
+main()
+{
+ int retval;
+
+ /* branch(33) */
+ if ((retval = setjmp (env))) {
+ /* branch(end) */
+ val += retval; /* count(2) */
+ }
+ /* returns(33) */
+ foo (val); /* count(3) */
+ /* returns(0) */
+ leave (passed()); /* count(1) */
+ /* returns(end) */
+}
+
+/* { dg-final { run-gcov calls branches { -b gcov-7.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-8.c b/gcc/testsuite/gcc.misc-tests/gcov-8.c
new file mode 100644
index 000000000..7223bde83
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-8.c
@@ -0,0 +1,47 @@
+/* Check that gcov correctly rounds nearly zero to nonzero and nearly
+ 100 to not-100.
+
+ Copyright (C) 2002 Free Software Foundation, Inc.
+ Contributed by Nathan Sidwell <nathan@codesourcery.com>
+*/
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int proxy (int i)
+{
+ return i;
+}
+
+int foo (int i)
+{
+ if (i > 0) /* branch(1) */
+ return proxy (1);
+ else if (i < 0) /* branch(100) */
+ return proxy (-1);
+ else
+ return proxy (0);
+}
+
+int baz (int i)
+{
+ if (i == 0) /* branch(99) */
+ return proxy (0);
+ else if (i > 0) /* branch(0)*/
+ return proxy (1);
+ else
+ return proxy (-1);
+}
+
+int main ()
+{
+ int t = 0;
+ int ix;
+
+ for (ix = 0; ix != 1000; ix++)
+ t += foo (ix) + baz (ix);
+
+ return t == 0;
+}
+
+/* { dg-final { run-gcov branches {-b gcov-8.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov-9.c b/gcc/testsuite/gcc.misc-tests/gcov-9.c
new file mode 100644
index 000000000..6e1b4a85c
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov-9.c
@@ -0,0 +1,15 @@
+/* Test gcov block mode. */
+
+/* { dg-options "-fprofile-arcs -ftest-coverage" } */
+/* { dg-do run { target native } } */
+
+int main ()
+{
+ unsigned ix;
+
+ for (ix = 10; ix--;); /* count(11) */
+
+ return 0;
+}
+
+/* { dg-final { run-gcov { -a gcov-9.c } } } */
diff --git a/gcc/testsuite/gcc.misc-tests/gcov.exp b/gcc/testsuite/gcc.misc-tests/gcov.exp
new file mode 100644
index 000000000..d433b9963
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/gcov.exp
@@ -0,0 +1,44 @@
+# Copyright (C) 1997, 2001, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Gcov test driver.
+
+# Load support procs.
+load_lib gcc-dg.exp
+load_lib gcov.exp
+
+global GCC_UNDER_TEST
+
+# For now find gcov in the same directory as $GCC_UNDER_TEST.
+if { ![is_remote host] && [string match "*/*" [lindex $GCC_UNDER_TEST 0]] } {
+ set GCOV [file dirname [lindex $GCC_UNDER_TEST 0]]/gcov
+} else {
+ set GCOV gcov
+}
+
+# Initialize harness.
+dg-init
+
+# Delete old .gcda files.
+set files [glob -nocomplain gcov-*.gcda]
+if { $files != "" } {
+ eval "remote_file build delete $files"
+}
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/gcov-*.c]] "" ""
+
+dg-finish
diff --git a/gcc/testsuite/gcc.misc-tests/help.exp b/gcc/testsuite/gcc.misc-tests/help.exp
new file mode 100644
index 000000000..6c38c8fed
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/help.exp
@@ -0,0 +1,80 @@
+# Copyright (C) 2005, 2007, 2009 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file contains a set of test that check that gcc options are
+# documented in --help, and that the various --help* options work.
+
+load_lib options.exp
+
+# Document --version. Ideally, there should be no undocumented switches
+# in --help.
+check_for_options c "--help" "--version" "This switch lacks documentation" ""
+
+# Output from different subprocesses should not be intermingled
+# (we check for some patterns that could be seen with a missing
+# fflush in gcc.c).
+check_for_options c "-v --help" "" {
+[^\n]The following options
+-Wconversion[^\n]*lacks documentation
+" -g "
+} ""
+
+# There are still undocumented switches in -v --help.
+check_for_options c "-v --help" "" "This switch lacks documentation" "xfail"
+
+# Check whether multiline conversion in optc-gen is broken.
+check_for_options c "-v --help" "" {are likely to\n -std} ""
+
+# Try various --help= classes and qualifiers.
+check_for_options c "--help=optimizers" "-O" " -g " ""
+check_for_options c "--help=params" "maximum number of" "-Wunsafe-loop-optimizations" ""
+check_for_options c "--help=C" "-ansi" "-gnatO" ""
+check_for_options c {--help=C++} {-std=c\+\+} "-gnatO" ""
+check_for_options c "--help=common" "-dumpbase" "-gnatO" ""
+check_for_options c "--help=undocumented" "This switch lacks documentation" "" ""
+
+# Undocumented flags are not yet consistently marked as such.
+check_for_options c "--help=^undocumented" "-Wall" "This switch lacks documentation" "xfail"
+
+# Try some --help=* examples from the manual.
+check_for_options c "--help=target,undocumented" "" "" ""
+check_for_options c "--help=target,optimizers" "" "" ""
+check_for_options c "--help=warnings,^joined,^undocumented" "" "" ""
+check_for_options c "-Q -O2 --help=optimizers" {
+-O
+-ftree-vectorize[^\n]*disabled
+} " -g " ""
+check_for_options c "-Q -O3 --help=optimizers" {
+-O
+-ftree-vectorize[^\n]*enabled
+} " -g " ""
+# Try repeated --help=.
+check_for_options c "--help=params --help=optimizers" {
+maximum number of
+-O
+} "" ""
+
+# Ensure PR 37805 is fixed.
+check_for_options c "--help=joined" "Wformat=" "-fstrict-prototype" ""
+check_for_options c "--help=separate" "-MF" "-fstrict-prototype" ""
+check_for_options c "--help=warnings,joined" "Wformat=" "Wtrigraphs" ""
+check_for_options c "--help=warnings,^joined" "Wtrigraphs" "Wformat=" ""
+check_for_options c "--help=joined,separate" "-I" "" ""
+check_for_options c "--help=^joined,separate" "--param " "" ""
+check_for_options c "--help=joined,^separate" "--help=" "" ""
+check_for_options c "--help=joined,undocumented" "" "" ""
+# Listing only excludes gives empty results.
+check_for_options c "--help=^joined,^separate" "" "" ""
diff --git a/gcc/testsuite/gcc.misc-tests/i386-pf-3dnow-1.c b/gcc/testsuite/gcc.misc-tests/i386-pf-3dnow-1.c
new file mode 100644
index 000000000..ffb2e7953
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/i386-pf-3dnow-1.c
@@ -0,0 +1,32 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use 3DNow! prefetch instructions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-*} } */
+/* { dg-require-effective-target ilp32 } */
+
+extern void exit (int);
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetch" } } */
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler-not "prefetchnta" } } */
+/* { dg-final { scan-assembler-not "prefetcht" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/i386-pf-athlon-1.c b/gcc/testsuite/gcc.misc-tests/i386-pf-athlon-1.c
new file mode 100644
index 000000000..8d5ad1efe
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/i386-pf-athlon-1.c
@@ -0,0 +1,32 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use 3DNow! prefetchw or SSE prefetch instructions with
+ locality hints. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+
+extern void exit (int);
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetchw" } } */
+/* { dg-final { scan-assembler "prefetchnta" } } */
+/* { dg-final { scan-assembler "prefetcht" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/i386-pf-none-1.c b/gcc/testsuite/gcc.misc-tests/i386-pf-none-1.c
new file mode 100644
index 000000000..d87a2100d
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/i386-pf-none-1.c
@@ -0,0 +1,29 @@
+/* Test that data prefetch instructions are not generated for i386 variants
+ that do not support those instructions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+
+extern void exit (int);
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler-not "fetch" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/i386-pf-sse-1.c b/gcc/testsuite/gcc.misc-tests/i386-pf-sse-1.c
new file mode 100644
index 000000000..fb47c9dfc
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/i386-pf-sse-1.c
@@ -0,0 +1,33 @@
+/* Test that the correct data prefetch instructions are generated for i386
+ variants that use SSE prefetch instructions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+
+extern void exit (int);
+
+char *msg = "howdy there";
+
+void foo (char *p)
+{
+ __builtin_prefetch (p, 0, 0);
+ __builtin_prefetch (p, 0, 1);
+ __builtin_prefetch (p, 0, 2);
+ __builtin_prefetch (p, 0, 3);
+ __builtin_prefetch (p, 1, 0);
+ __builtin_prefetch (p, 1, 1);
+ __builtin_prefetch (p, 1, 2);
+ __builtin_prefetch (p, 1, 3);
+}
+
+int main ()
+{
+ foo (msg);
+ exit (0);
+}
+
+/* { dg-final { scan-assembler "prefetchnta" } } */
+/* { dg-final { scan-assembler "prefetcht0" } } */
+/* { dg-final { scan-assembler "prefetcht1" } } */
+/* { dg-final { scan-assembler "prefetcht2" } } */
+/* { dg-final { scan-assembler-not "prefetchw" } } */
diff --git a/gcc/testsuite/gcc.misc-tests/i386-prefetch.exp b/gcc/testsuite/gcc.misc-tests/i386-prefetch.exp
new file mode 100644
index 000000000..a9f767cde
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/i386-prefetch.exp
@@ -0,0 +1,114 @@
+# Copyright (C) 2002, 2004, 2007, 2008 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test that the correct data prefetch instructions (SSE or 3DNow! variant,
+# or none) are used for various i386 cpu-type and instruction set
+# extension options for __builtin_prefetch. When using -mtune, specify
+# the minimum supported architecture in case the compiler was configured
+# with a different default.
+
+# Failure reports do not include the compile option that was used; that
+# information can be seen in the compile line in the log file.
+
+# Do not generate prefetch instructions for the following options.
+
+set PREFETCH_NONE [list \
+ { -march=i386 -mtune=i386 } \
+ { -march=i386 -mtune=i486 } \
+ { -march=i386 -mtune=i586 } \
+ { -march=i386 -mtune=i686 } \
+ { -march=i386 -mtune=pentium2 } \
+ { -march=i386 -mtune=k6 } \
+ { -march=i386 -mtune=k6-2 } \
+ { -march=i386 -mtune=k6-3 } \
+ { -march=i386 } \
+ { -march=i486 } \
+ { -march=i586 } \
+ { -march=i686 } \
+ { -march=pentium2 } \
+ { -march=k6 } ]
+
+# For options in PREFETCH_SSE, generate SSE prefetch instructions for
+# __builtin_prefetch. This includes -mtune for targets that treat prefetch
+# instructions as nops.
+
+set PREFETCH_SSE [list \
+ { -march=i686 -mtune=pentium3 } \
+ { -march=i686 -mtune=pentium3m } \
+ { -march=i686 -mtune=pentium-m } \
+ { -march=i686 -mtune=pentium4 } \
+ { -march=i686 -mtune=pentium4m } \
+ { -march=i686 -mtune=prescott } \
+ { -march=i686 -mtune=athlon } \
+ { -march=i686 -mtune=athlon-4 } \
+ { -march=i686 -mtune=c3-2 } \
+ { -march=pentium3 } \
+ { -march=pentium3m } \
+ { -march=pentium-m } \
+ { -march=pentium4 } \
+ { -march=pentium4m } \
+ { -march=prescott } \
+ { -march=c3-2 } ]
+
+# Generate 3DNow! prefetch instructions for the following.
+
+set PREFETCH_3DNOW [list \
+ { -march=c3 } \
+ { -march=k6-2 } \
+ { -march=k6-3 } ]
+
+# Athlon supports both 3DNow! and SSE prefetch instructions. For
+# __builtin_prefetch, generate the 3DNow! instruction for write
+# prefetches but SSE prefetch instructions for read prefetches.
+
+set PREFETCH_ATHLON [list \
+ { -march=athlon } \
+ { -march=athlon-4 } ]
+
+if $tracelevel then {
+ strace $tracelevel
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+load_lib torture-options.exp
+
+# Initialize harness.
+dg-init
+torture-init
+
+if { [board_info target exists multilib_flags]
+ && [string match "* -march=*" " [board_info target multilib_flags] "] } {
+ # Multilib flags come after the -march flags we pass and override
+ # them, so skip these tests when such flags are passed.
+ return
+}
+
+set-torture-options $PREFETCH_NONE
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-none-*.c]] ""
+
+set-torture-options $PREFETCH_SSE
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-sse-*.c]] ""
+
+set-torture-options $PREFETCH_3DNOW
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-3dnow-*.c]] ""
+
+set-torture-options $PREFETCH_ATHLON
+gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/i386-pf-athlon-*.c]] ""
+
+torture-finish
+dg-finish
+
diff --git a/gcc/testsuite/gcc.misc-tests/linkage-x.c b/gcc/testsuite/gcc.misc-tests/linkage-x.c
new file mode 100644
index 000000000..07601e397
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/linkage-x.c
@@ -0,0 +1,3 @@
+/* 920717-1.c */
+
+const char s[]="foo";
diff --git a/gcc/testsuite/gcc.misc-tests/linkage-y.c b/gcc/testsuite/gcc.misc-tests/linkage-y.c
new file mode 100644
index 000000000..eaffa5e4b
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/linkage-y.c
@@ -0,0 +1,8 @@
+/* 920717-y.c */
+
+extern const char s[];
+
+main()
+{
+ puts(s);
+}
diff --git a/gcc/testsuite/gcc.misc-tests/linkage.exp b/gcc/testsuite/gcc.misc-tests/linkage.exp
new file mode 100644
index 000000000..954dc29a5
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/linkage.exp
@@ -0,0 +1,122 @@
+# Copyright (C) 1988, 90-96, 1997, 2000, 2001, 2002, 2007, 2008, 2010
+# Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# This file used to be gcc.c-torture/special/special.exp, which
+# was written by Rob Savoye. (rob@cygnus.com)
+# All the other tests driven by that file have since been moved elsewhere.
+
+if { [isnative] && ![is_remote host] } then {
+ set lines [gcc_target_compile "$srcdir/$subdir/linkage-x.c" "linkage-x.o" object {additional_flags="-w"}]
+ if ![string match "" $lines] then {
+ fail "$subdir/linkage.c compile"
+ } else {
+ # This is a completely bogus test. Sorry.
+
+ # Need to ensure ABI for native compiler matches gcc
+ set native_cflags ""
+ if [istarget "mips-sgi-irix6*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*64*" $file_string ] {
+ set native_cflags "-64"
+ }
+ if [ string match "*ELF 32*" $file_string ] {
+ set native_cflags "-32"
+ }
+ if [ string match "*N32*" $file_string ] {
+ set native_cflags "-n32"
+ }
+ }
+ if [istarget "sparc*-sun-solaris2*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*64*" $file_string ] {
+ set native_cflags "-xarch=v9"
+ }
+ }
+ if [istarget "i?86*-*-solaris2*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*64*" $file_string ] {
+ set native_cflags "-xarch=amd64"
+ }
+ }
+ if [istarget "s390*-*-linux*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*32-bit*" $file_string ] {
+ set native_cflags "-m31"
+ }
+ if [ string match "*64-bit*" $file_string ] {
+ set native_cflags "-m64"
+ }
+ } elseif {[istarget "i*86-*-linux*"] || [istarget "x86_64-*-linux*"]} {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*32-bit*" $file_string ] {
+ set native_cflags "-m32"
+ }
+ if [ string match "*64-bit*" $file_string ] {
+ set native_cflags "-m64"
+ }
+ } elseif [istarget "*-hp-hpux*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*ELF-64*" $file_string ] {
+ set native_cflags "+DD64"
+ }
+ } elseif [istarget "powerpc*-*-linux*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*64-bit*" $file_string ] {
+ set native_cflags "-m64"
+ } elseif [ string match "*32-bit*" $file_string ] {
+ set native_cflags "-m32"
+ }
+ } elseif [istarget "powerpc*-*-darwin*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*ppc64" $file_string ] {
+ set native_cflags "-m64"
+ } elseif [ string match "*ppc" $file_string ] {
+ set native_cflags "-m32"
+ }
+ } elseif [istarget "*86*-*-darwin*"] {
+ set file_string [exec file "linkage-x.o"]
+ if [ string match "*64*" $file_string ] {
+ set native_cflags "-m64"
+ } elseif [ string match "*i386" $file_string ] {
+ set native_cflags "-m32"
+ }
+ }
+
+ if [file exists "linkage-y.o"] then {
+ file delete "linkage-y.o"
+ }
+ send_log "cc -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
+ catch { exec cc -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
+ if ![file exists "linkage-y.o"] then {
+ send_log "c89 -c $native_cflags $srcdir/$subdir/linkage-y.c >&/dev/null\n"
+ catch { exec c89 -c $native_cflags "$srcdir/$subdir/linkage-y.c" >&/dev/null }
+ }
+ if [file exists "linkage-y.o"] then {
+ set lines [gcc_target_compile "linkage-y.o linkage-x.o" "linkage.exe" executable ""]
+ if [string match "" $lines] then {
+ pass "$subdir/linkage.c link"
+ file delete "linkage.exe"
+ } else {
+ fail "$subdir/linkage.c link"
+ }
+ file delete "linkage-y.o"
+ } else {
+ unsupported "$subdir/linkage.c native compile failed"
+ }
+ file delete "linkage-x.o"
+ }
+}
diff --git a/gcc/testsuite/gcc.misc-tests/matrix1.c b/gcc/testsuite/gcc.misc-tests/matrix1.c
new file mode 100644
index 000000000..f25a367fb
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/matrix1.c
@@ -0,0 +1,46 @@
+/* Matrix operations */
+
+#define BOUND 100
+
+int a[BOUND][BOUND],b[BOUND][BOUND],c[BOUND][BOUND];
+
+main()
+{
+int i,j,k;
+
+
+
+ for (i=0; i<BOUND; i++)
+ {
+ for (j=0; j<BOUND; j++)
+ {
+ a[i][j] = 1;
+ b[i][j] = 1;
+ }
+ }
+ for (i=0; i<BOUND; i++)
+ {
+ for (j=0; j<BOUND; j++)
+ {
+ c[i][j] = 0;
+ for (k=0; k<BOUND; k++)
+ {
+ c[i][j] = c[i][j] + a[i][k] * b[k][j];
+ }
+ }
+ }
+ for (i=0; i<BOUND; i++)
+ {
+ for (j=0; j<BOUND; j++)
+ {
+ if (c[i][j] != BOUND)
+ {
+ puts("ERROR");
+ return 0;
+ }
+ }
+ }
+ i=5;
+
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.misc-tests/matrix1.exp b/gcc/testsuite/gcc.misc-tests/matrix1.exp
new file mode 100644
index 000000000..d825eba80
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/matrix1.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+global PERF_TEST
+if { ![info exists PERF_TEST] || "$PERF_TEST" != "yes" } {
+ return
+}
+
+load_lib mike-gcc.exp
+
+prebase
+set actions run
+set compiler_output "^$"
+set program_output "^$"
+postbase matrix1.c $run $groups
diff --git a/gcc/testsuite/gcc.misc-tests/mg-2.c b/gcc/testsuite/gcc.misc-tests/mg-2.c
new file mode 100644
index 000000000..d88c9d01a
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/mg-2.c
@@ -0,0 +1,9 @@
+/* PR 15220 */
+
+#include <nonexist0.h>
+#include "nonexist.h"
+int
+main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.misc-tests/mg-2.exp b/gcc/testsuite/gcc.misc-tests/mg-2.exp
new file mode 100644
index 000000000..cfeeb8346
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/mg-2.exp
@@ -0,0 +1,24 @@
+# Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test the -MG flag with a system header file.
+
+load_lib mike-gcc.exp
+
+prebase
+set actions none-of-the-above
+set compiler_output "mg-2.o ?: .*mg-2.c \[ \\\\\n\]*nonexist.h"
+postbase mg-2.c "" "" "-MM -MG"
diff --git a/gcc/testsuite/gcc.misc-tests/mg.c b/gcc/testsuite/gcc.misc-tests/mg.c
new file mode 100644
index 000000000..535971457
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/mg.c
@@ -0,0 +1,8 @@
+/* PR 2981 */
+
+#include "nonexist.h"
+int
+main ()
+{
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.misc-tests/mg.exp b/gcc/testsuite/gcc.misc-tests/mg.exp
new file mode 100644
index 000000000..7ba3ae1c6
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/mg.exp
@@ -0,0 +1,24 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Test the -MG flag.
+
+load_lib mike-gcc.exp
+
+prebase
+set actions none-of-the-above
+set compiler_output "mg.o ?: .*mg.c \[ \\\\\n\]*nonexist.h"
+postbase mg.c "" "" "-MM -MG"
diff --git a/gcc/testsuite/gcc.misc-tests/options.exp b/gcc/testsuite/gcc.misc-tests/options.exp
new file mode 100644
index 000000000..a9a74e19a
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/options.exp
@@ -0,0 +1,54 @@
+# Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Run the LANGUAGE compiler with GCC_OPTIONS and inspect the compiler,
+# assembler and linker output (from gcc -v) to make sure that they
+# match the patterns COMPILER_PATTERN, AS_PATTERN and LD_PATTERN,
+# respectively.
+
+proc check_for_all_options {language gcc_options compiler_pattern as_pattern ld_pattern} {
+ set filename test-[pid]
+ set fd [open $filename.c w]
+ puts $fd "int main (void) \{ return 0; \}"
+ close $fd
+ remote_download host $filename.c
+
+ set test "compiler driver $gcc_options option(s)"
+ set gcc_options "\{additional_flags=$gcc_options -v\}"
+
+ switch "$language" {
+ "c" { set compiler cc1 }
+ default { error "unknown language" }
+ }
+ set gcc_output [gcc_target_compile $filename.c $filename.x executable $gcc_options]
+ remote_file build delete $filename.c $filename.x $filename.gcno
+
+ if {![regexp -- "/${compiler}(\\.exe)? -quiet.*$compiler_pattern" $gcc_output]} {
+ fail "$test (compiler options)"
+ return
+ }
+ if {![regexp -- " *as(\\.exe)? .*$as_pattern" $gcc_output]} {
+ fail "$test (assembler options)"
+ return
+ }
+ if {![regexp -- "/collect2(\\.exe)? .*$ld_pattern" $gcc_output]} {
+ fail "$test (linker options)"
+ return
+ }
+ pass $test
+}
+
+check_for_all_options c {--coverage} {-fprofile-arcs -ftest-coverage} {} {-lgcov}
diff --git a/gcc/testsuite/gcc.misc-tests/sieve.c b/gcc/testsuite/gcc.misc-tests/sieve.c
new file mode 100644
index 000000000..de250e8e5
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/sieve.c
@@ -0,0 +1,26 @@
+
+#define TRUE 1
+#define FALSE 0
+#define SIZE 8190
+
+char flags[SIZE+1];
+
+main()
+{
+ register int i, prime, k, count, iter;
+ for (iter=1;iter<=100;iter++) {
+ count=0;
+ for (i=0;i<=SIZE;i++)
+ flags[i]=TRUE;
+ for (i=0;i<=SIZE;i++) {
+ if (flags[i]) {
+ prime=i+i+3;
+ for (k=i+prime;k<=SIZE;k+=prime)
+ flags[k]=FALSE;
+ count++;
+ }
+ }
+ }
+ return 0;
+}
+
diff --git a/gcc/testsuite/gcc.misc-tests/sieve.exp b/gcc/testsuite/gcc.misc-tests/sieve.exp
new file mode 100644
index 000000000..3f82ca91b
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/sieve.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+global PERF_TEST
+if { ![info exists PERF_TEST] || "$PERF_TEST" != "yes" } {
+ return
+}
+
+load_lib mike-gcc.exp
+
+prebase
+set actions run
+set compiler_output "^$"
+set program_output "^$"
+postbase sieve.c $run $groups
diff --git a/gcc/testsuite/gcc.misc-tests/sort2.c b/gcc/testsuite/gcc.misc-tests/sort2.c
new file mode 100644
index 000000000..06b150b93
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/sort2.c
@@ -0,0 +1,54 @@
+/* Simple test program: bubble sort of a fixed table. */
+/* This demonstrates some of the compiler's common-subexpression*/
+/* elimination capabilities. For example, inspect the code */
+/* generated for procedure Sort_array. See the Programmer's */
+/* Guide for how to request an assembly listing on your host. */
+
+typedef unsigned char boolean;
+
+void Sort_array();
+int Tab[100];
+
+main () {
+ int I,J,K,L;
+
+for (L = 0; L < 1000; L++) {
+ /* Initialize the table that will be sorted. */
+ K = 0;
+ for (I = 9; I >= 0; I--)
+ for (J = I*10; J < (I+1)*10; J++)
+ Tab[K++] = J&1 ? J+1 : J-1;
+
+/* Print_array(); */
+ Sort_array(Tab,99); /* Sort it. */
+/* Print_array(); */
+}
+ return 0;
+}
+
+void Sort_array(Tab,Last) int Tab[]; int Last; {
+ boolean Swap;
+ int Temp,I;
+ do {
+ Swap = 0;
+ for (I = 0; I<Last; I++)
+ if (Tab[I] > Tab[I+1]) {
+ Temp = Tab[I];
+ Tab[I] = Tab[I+1];
+ Tab[I+1] = Temp;
+ Swap = 1;
+ }
+ }
+ while (Swap);
+}
+
+
+void Print_array() {
+ int I,J;
+ /*printf("\nArray Contents:\n");*/
+ for (I=0; I<=9; I++) {
+ /*printf("%5d:",10*I); */
+ for (J=0; J<=9; J++); /*printf("%5d",Tab[10*I+J]); */
+ /* printf("\n");*/
+ }
+}
diff --git a/gcc/testsuite/gcc.misc-tests/sort2.exp b/gcc/testsuite/gcc.misc-tests/sort2.exp
new file mode 100644
index 000000000..d89be7af7
--- /dev/null
+++ b/gcc/testsuite/gcc.misc-tests/sort2.exp
@@ -0,0 +1,28 @@
+# Copyright (C) 1997, 2007 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+global PERF_TEST
+if { ![info exists PERF_TEST] || "$PERF_TEST" != "yes" } {
+ return
+}
+
+load_lib mike-gcc.exp
+
+prebase
+set actions run
+set compiler_output "^$"
+set program_output "^$"
+postbase sort2.c $run $groups