diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.target/cris | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.target/cris')
68 files changed, 1061 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/20011127-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/20011127-1.c new file mode 100644 index 000000000..298a8b9fd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/20011127-1.c @@ -0,0 +1,29 @@ +/* Copyright (C) 2001, 2007 Free Software Foundation. + by Hans-Peter Nilsson <hp@axis.com> + + Making sure that invalid asm operand modifiers don't cause an ICE. */ + +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-message "reg:SI|const_double:DF" "prune debug_rtx output" { target *-*-* } 0 } */ + +void +foo (void) +{ + /* The first case symbolizes the default case for CRIS. */ + asm ("\n;# %w0" : : "r" (0)); /* { dg-error "modifier" } */ + + /* These are explicit cases. Luckily, a register is invalid in most of + them. */ + asm ("\n;# %b0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %v0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %p0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %z0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %H0" : : "F" (0.5)); /* { dg-error "modifier" } */ + asm ("\n;# %e0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %m0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %A0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %D0" : : "r" (0)); /* { dg-error "modifier" } */ + asm ("\n;# %T0" : : "r" (0)); /* { dg-error "modifier" } */ + /* Add more must-not-ICE asm errors here as we find them ICEing. */ +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-b-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-b-1.c new file mode 100644 index 000000000..5417c047d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-b-1.c @@ -0,0 +1,15 @@ +/* { dg-do assemble } */ +/* { dg-options "-O2" } */ + +/* Checking that the "b" constraint is accepted, for all target variants. */ + +long sys_ipc (void) +{ + long __gu_err = -14; + long dummy_for_get_user_asm_64_; + __asm__ __volatile__( "move.d [%1+],%0\n" + : "=r" (__gu_err), "=b" (dummy_for_get_user_asm_64_) + : "0" (__gu_err)); + + return __gu_err; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-other.S b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-other.S new file mode 100644 index 000000000..4fe7ebfc4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-other.S @@ -0,0 +1,15 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=0 -march=v0" { target crisv32-*-* } } */ +/* { dg-options "-DOTHER_ISA=32 -march=v32" { target cris-*-* } } */ + +/* Make sure we can assemble for the "other" variant, with the twist + that the gcc option -march=v0 isn't valid for the assembler. */ + .text +#if OTHER_ISA == 32 + addoq 42,$r1,$acr +#else +0: + move.d [$r2=$r0+42],$r1 + bwf 0b + nop +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v10.S b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v10.S new file mode 100644 index 000000000..c85ebe293 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v10.S @@ -0,0 +1,6 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=10 -march=v10" } */ + +/* Check that -march=v10 is also recognized. */ + +#include "asm-other.S" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v8.S b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v8.S new file mode 100644 index 000000000..3fba31884 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/asm-v8.S @@ -0,0 +1,6 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=8 -march=v8" } */ + +/* Check that -march=v8 is also recognized. */ + +#include "asm-other.S" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/asmreg-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/asmreg-1.c new file mode 100644 index 000000000..f430fafbe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/asmreg-1.c @@ -0,0 +1,73 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "\\\.ifnc \\\$r9-\\\$r10-\\\$r11-\\\$r12" } } */ + +/* Sanity check for asm register operands in syscall failed for + cris-axis-linux-gnu due to regmove bug. + Hans-Peter Nilsson <hp@axis.com>. */ + +extern void lseek64 (int, long long, int); +extern int *__errno_location (void); +struct dirent64 +{ + long long d_off; + unsigned short int d_reclen; + char d_name[256]; +}; +struct kernel_dirent64 +{ + long long d_off; + unsigned short d_reclen; + char d_name[256]; +}; + +static inline int __attribute__ ((__always_inline__)) +__syscall_getdents64 (int fd, char * dirp, unsigned count) +{ + register unsigned long __sys_res asm ("r10"); + register unsigned long __r10 __asm__ ("r10") = (unsigned long) fd; + register unsigned long __r11 __asm__ ("r11") = (unsigned long) dirp; + register unsigned long __r12 __asm__ ("r12") = (unsigned long) count; + register unsigned long __callno asm ("r9") = (220); + asm volatile (".ifnc %1-%0-%3-%4,$r9-$r10-$r11-$r12\n\t" + ".err\n\t" + ".endif\n\t" + "break 13" + : "=r" (__sys_res) + : "r" (__callno), "0" (__r10), "r" (__r11), "r" (__r12) + : "memory"); + if (__sys_res >= (unsigned long) -4096) + { + (*__errno_location ()) = - __sys_res; + __sys_res = -1; + } + return __sys_res; +} + +int +__getdents64 (int fd, char *buf, unsigned nbytes) +{ + struct dirent64 *dp; + long long last_offset = -1; + int retval; + struct kernel_dirent64 *skdp, *kdp; + dp = (struct dirent64 *) buf; + skdp = kdp = __builtin_alloca (nbytes); + retval = __syscall_getdents64(fd, (char *)kdp, nbytes); + if (retval == -1) + return -1; + while ((char *) kdp < (char *) skdp + retval) + { + if ((char *) dp > buf + nbytes) + { + lseek64(fd, last_offset, 0); + break; + } + last_offset = kdp->d_off; + __builtin_memcpy (dp->d_name, kdp->d_name, kdp->d_reclen - 10); + dp = (struct dirent64 *) ((char *) dp + sizeof (*dp)); + kdp = (struct kernel_dirent64 *) (((char *) kdp) + kdp->d_reclen); + } + + return (char *) dp - buf; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/biap.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/biap.c new file mode 100644 index 000000000..1f3b4368a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/biap.c @@ -0,0 +1,11 @@ +/* Make sure ADDI is combined and emitted successfully. + See also PR37939. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler "addi" } } */ +/* { dg-final { scan-assembler-not "lsl" } } */ + +int xyzzy (int r10, int r11) +{ + return r11 * 4 + r10; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v3.c new file mode 100644 index 000000000..1230d4b59 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v3.c @@ -0,0 +1,12 @@ +/* Check that we don't use the swap insn for bswap by checking assembler + output. The swap instruction was added in v8. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v3" } */ +/* { dg-final { scan-assembler-not "\[ \t\]swapwb\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_bswap32(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v8.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v8.c new file mode 100644 index 000000000..b7a8d2684 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_bswap_v8.c @@ -0,0 +1,12 @@ +/* Check that we use the swap insn for bswap by checking assembler + output. The swap instruction was added in v8. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v8" } */ +/* { dg-final { scan-assembler "\[ \t\]swapwb\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_bswap32(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v0.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v0.c new file mode 100644 index 000000000..318402faa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v0.c @@ -0,0 +1,12 @@ +/* Check that we don't use the lz insn for clz by checking assembler output. + The lz insn was implemented in CRIS v3 (ETRAX 4). */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v0" } */ +/* { dg-final { scan-assembler-not "\[ \t\]lz\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_clz(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v3.c new file mode 100644 index 000000000..ecf039048 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_clz_v3.c @@ -0,0 +1,12 @@ +/* Check that we use the lz insn for clz by checking assembler output. + The lz insn was implemented in CRIS v3 (ETRAX 4). */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v3" } */ +/* { dg-final { scan-assembler "\[ \t\]lz\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_clz(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v3.c new file mode 100644 index 000000000..8971a47a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v3.c @@ -0,0 +1,12 @@ +/* Check that we don't use the swap insn for ctz by checking + assembler output. The swap instruction was implemented in v8. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v3" } */ +/* { dg-final { scan-assembler-not "\[ \t\]swapwbr\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_ctz(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v8.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v8.c new file mode 100644 index 000000000..853b1740a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/builtin_ctz_v8.c @@ -0,0 +1,12 @@ +/* Check that we use the swap insn for ctz by checking assembler output. + The swap instruction was implemented in v8. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "cris*-*-elf" } { "-march*" } { "" } } */ +/* { dg-options "-O2 -march=v8" } */ +/* { dg-final { scan-assembler "\[ \t\]swapwbr\[ \t\]" } } */ + +int +f (int a) +{ + return __builtin_ctz(a); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/cris.exp b/gcc-4.9/gcc/testsuite/gcc.target/cris/cris.exp new file mode 100644 index 000000000..4a04d1920 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/cris.exp @@ -0,0 +1,41 @@ +# Copyright (C) 2005-2014 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/>. + +# GCC testsuite that uses the `gcc-dg.exp' driver, just a single option, no +# looping over tests. + +# Exit immediately if this isn't a CRIS target. +if { ![istarget cris-*-*] && ![istarget crisv32-*-*] } then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-other.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-other.c new file mode 100644 index 000000000..c1c043f56 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-other.c @@ -0,0 +1,23 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=0 -march=v0" { target crisv32-*-* } } */ +/* { dg-options "-DOTHER_ISA=32 -march=v32" { target cris-*-* } } */ + +/* Make sure we can (generate code and) assemble for the "other" + variant, with the twist that the gcc option -march=v0 isn't + valid for the assembler. We don't check that the generated code + is for the other variant; other tests cover that already, but they + don't *assemble* the result. We can't trust the prologue and + epilogue to contain incompatible insns (they actually deliberately + don't, usually and it'd be brittle to tweak the function signature + to make it so), so we force some with inline asm. */ + +void f(void) +{ +#if OTHER_ISA == 32 + asm volatile ("addoq 42,$r11,$acr"); +#else + asm volatile ("0: move.d [$r12=$sp+42],$r10\n\t" + "bwf 0b\n\t" + "nop"); +#endif +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v10.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v10.c new file mode 100644 index 000000000..75379b3c8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v10.c @@ -0,0 +1,6 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=10 -march=v10" } */ + +/* Check that -march=v10 is also recognized. */ + +#include "inasm-other.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v8.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v8.c new file mode 100644 index 000000000..b2fb3053c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/inasm-v8.c @@ -0,0 +1,6 @@ +/* { dg-do assemble } */ +/* { dg-options "-DOTHER_ISA=8 -march=v8" } */ + +/* Check that -march=v8 is also recognized. */ + +#include "inasm-other.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu1.c new file mode 100644 index 000000000..3b54c3295 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu1.c @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-final { scan-assembler-not "and.d " } } */ +/* { dg-final { scan-assembler-not "move.d " } } */ +/* { dg-final { scan-assembler "cLear.b" } } */ +/* { dg-final { scan-assembler "movu.b" } } */ +/* { dg-final { scan-assembler "and.b" } } */ +/* { dg-final { scan-assembler "movu.w" } } */ +/* { dg-final { scan-assembler "and.w" } } */ +/* { dg-final { scan-assembler "andq" } } */ +/* { dg-options "-O2" } */ + +/* Test the "andu" peephole2 trivially, memory operand. */ + +int +clearb (int x, int *y) +{ + return *y & 0xff00; +} + +int +andb (int x, int *y) +{ + return *y & 0x3f; +} + +int +andw (int x, int *y) +{ + return *y & 0xfff; +} + +int +andq (int x, int *y) +{ + return *y & 0xf0; +} + +int +andq2 (int x, int *y) +{ + return *y & 0xfff0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu2.c new file mode 100644 index 000000000..fd19cdd90 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-andu2.c @@ -0,0 +1,39 @@ +/* { dg-do assemble } */ +/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$|movu.w 2047," } } */ +/* { dg-final { scan-assembler "and.w 2047,\\\$|and.d \\\$r10," } } */ +/* { dg-final { scan-assembler-not "move.d \\\$r10,\\\$" } } */ +/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$|movu.b 95," } } */ +/* { dg-final { scan-assembler "and.b 95,\\\$|and.d \\\$r10," } } */ +/* { dg-final { scan-assembler "andq -2,\\\$" } } */ +/* { dg-final { scan-assembler-not "movu.b 254,\\\$" } } */ +/* { dg-options "-O2 -save-temps" } */ + +/* Originally used to test the "andu" peephole2 trivially, register operand. + Due to reload changes (r186861), the suboptimal sequence isn't + generated and the peephole2 doesn't trig for this trivial code + anymore. Another minimal sequence is generated, where the constant + is loaded to a free register first. Instead another case is exposed; + handled by the "andqu" peephole2, trigged by and_peep2_q (the andq + and scan-assembler-not-movu.b lines above). */ + +unsigned int +and_peep2_hi (unsigned int y, unsigned int *x) +{ + *x = y & 0x7ff; + return y; +} + +unsigned int +and_peep2_qi (unsigned int y, unsigned int *x) +{ + *x = y & 0x5f; + return y; +} + + +unsigned int +and_peep2_q (unsigned int y, unsigned int *x) +{ + *x = y & 0xfe; + return y; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand.c new file mode 100644 index 000000000..df0e76886 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-final { scan-assembler "and.w " } } */ +/* { dg-final { scan-assembler "and.b " } } */ +/* { dg-final { scan-assembler-not "and.d" } } */ +/* { dg-options "-O2" } */ + +/* Test the "asrandb", "asrandw", "lsrandb" and "lsrandw" peephole2:s + trivially. */ + +unsigned int +andwlsr (unsigned int x) +{ + return (x >> 17) & 0x7ff; +} + +unsigned int +andblsr (unsigned int x) +{ + return (x >> 25) & 0x5f; +} + +int +andwasr (int x) +{ + return (x >> 17) & 0x7ff; +} + +int +andbasr (int x) +{ + return (x >> 25) & 0x5f; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand2.c new file mode 100644 index 000000000..5d6ca788d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/peep2-xsrand2.c @@ -0,0 +1,34 @@ +/* { dg-do compile } */ +/* { dg-final { scan-assembler "and.w -137," } } */ +/* { dg-final { scan-assembler "and.b -64," } } */ +/* { dg-final { scan-assembler "and.w -139," } } */ +/* { dg-final { scan-assembler "and.b -63," } } */ +/* { dg-final { scan-assembler-not "and.d" } } */ +/* { dg-options "-O2" } */ + +/* PR target/17984. Test-case based on + testsuite/gcc.dg/cris-peep2-xsrand.c. */ + +unsigned int +andwlsr (unsigned int x) +{ + return (x >> 16) & 0xff77; +} + +unsigned int +andblsr (unsigned int x) +{ + return (x >> 24) & 0xc0; +} + +int +andwasr (int x) +{ + return (x >> 16) & 0xff75; +} + +int +andbasr (int x) +{ + return (x >> 24) & 0xc1; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit1.c new file mode 100644 index 000000000..53a38af2c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit1.c @@ -0,0 +1,21 @@ +/* Check that we don't get unnecessary insns due to reload using more + insns than needed due to reloading of more locations than + needed. */ +/* { dg-options -O2 } */ +/* { dg-final { scan-assembler-not "movs.w" } } */ +/* { dg-final { scan-assembler-not "move.w" } } */ + +/* As torture/pr24750-2.c, except we need to clobber R8 for thorough + testing and know we can do, since we replace the frame-pointer. */ + +int +f (short *a, char *y) +{ + __asm__ ("" : : : +#ifndef __PIC__ + "r0", +#endif + "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", + "r9", "r10", "r11", "r12", "r13"); + return y[*a]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit2.c new file mode 100644 index 000000000..0add3e2b5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/rld-legit2.c @@ -0,0 +1,16 @@ +/* A variant of rld-legit1.c only for full code coverage of the + initial version of cris_reload_address_legitimized. */ +/* { dg-options -O2 } */ + +short * +g (short *a, char *y) +{ + __asm__ ("" : : : +#ifndef __PIC__ + "r0", +#endif + "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", + "r9", "r10", "r11", "r12", "r13"); + y[*a++] = 0; + return a; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v10.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v10.c new file mode 100644 index 000000000..6c8dd1a40 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v10.c @@ -0,0 +1,5 @@ +/* Check that we can assemble both base atomic variants. */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -march=v10" } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v32.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v32.c new file mode 100644 index 000000000..3c1d076ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1-v32.c @@ -0,0 +1,5 @@ +/* Check that we can assemble both base atomic variants. */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -march=v32" } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1.c new file mode 100644 index 000000000..1bc9a674c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-1.c @@ -0,0 +1,35 @@ +/* Check that we can assemble both base atomic variants, for v0. */ +/* { dg-do assemble } */ +/* { dg-options "-O2 -march=v0" } */ + +#ifndef type +#define type char +#endif + +#if !defined(op) && !defined(xchg) +#define op 1 +#define xchg 1 +#endif + +#ifndef op +#define op 0 +#endif + +#ifndef xchg +#define xchg 0 +#endif + +#if op +int sfa (type *p, type *q, int a) +{ + return __atomic_fetch_nand (p, a, __ATOMIC_ACQ_REL) + + __atomic_fetch_add (q, a, __ATOMIC_SEQ_CST); +} +#endif + +#if xchg +void acen (type *ptr, type *val, type *ret) +{ + __atomic_exchange (ptr, val, ret, __ATOMIC_SEQ_CST); +} +#endif diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2c.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2c.c new file mode 100644 index 000000000..80e646c20 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2c.c @@ -0,0 +1,8 @@ +/* Check that we don't get alignment-checking code, char. */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */ +/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2i.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2i.c new file mode 100644 index 000000000..d491d3c08 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2i.c @@ -0,0 +1,10 @@ +/* Check that we get the expected alignment-checking code, op variant, int. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dop -Dtype=int" } */ +/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler "\tbreak 8" } } */ +/* { dg-final { scan-assembler "\tbtstq \\(2-1\\)," } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2s.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2s.c new file mode 100644 index 000000000..06ff98a27 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-2s.c @@ -0,0 +1,10 @@ +/* Check that we get the expected alignment-checking code, op variant, short. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dop -Dtype=short" } */ +/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler "\tbreak 8" } } */ +/* { dg-final { scan-assembler "\tbtstq \\(1-1\\)," } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3i.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3i.c new file mode 100644 index 000000000..9e67d61cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3i.c @@ -0,0 +1,12 @@ +/* Check that we get the expected alignment-checking code, xchg variant, int. + Unfortunately, PRE moves the "and" to a different BB, so combine doesn't + see it with the compare to make it a btstq. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dxchg -Dtype=int" } */ +/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler "\tbreak 8" } } */ +/* { dg-final { scan-assembler "\tbtstq \\(2-1\\)," { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-not "\tand" { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3s.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3s.c new file mode 100644 index 000000000..8e87a3b62 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-3s.c @@ -0,0 +1,12 @@ +/* Check that we get the expected alignment-checking code, xchg variant, short. + Unfortunately, PRE moves the "and" to a different BB, so combine doesn't + see it with the compare to make it a btstq. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dxchg -Dtype=short" } */ +/* { dg-additional-options "-mtrap-using-break8 -mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler "\tbreak 8" } } */ +/* { dg-final { scan-assembler "\tbtstq \\(1-1\\)," { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-not "\tand" { xfail *-*-* } } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4c.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4c.c new file mode 100644 index 000000000..e8cb69267 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4c.c @@ -0,0 +1,8 @@ +/* Check that we get don't alignment-checking code, xchg variant, char. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-trap-unaligned-atomic" } */ +/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */ +/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4i.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4i.c new file mode 100644 index 000000000..78a7012cc --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4i.c @@ -0,0 +1,9 @@ +/* Check that we don't get alignment-checking code, int. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dtype=int -mno-trap-unaligned-atomic" } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */ +/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4s.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4s.c new file mode 100644 index 000000000..6691a4828 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-4s.c @@ -0,0 +1,9 @@ +/* Check that we don't get alignment-checking code, short. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -Dtype=short -mno-trap-unaligned-atomic" } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +/* { dg-final { scan-assembler-not "\tbreak\[ \t\]" } } */ +/* { dg-final { scan-assembler-not "\tbtstq\[ \t\]\[^5\]" } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\t\[jb\]sr" } } */ +#include "sync-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-xchg-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-xchg-1.c new file mode 100644 index 000000000..21bb7d4ff --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/sync-xchg-1.c @@ -0,0 +1,21 @@ +/* Check that the basic library call variant is sane; no other calls, no + checks compares or branches. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -munaligned-atomic-may-use-library" } */ +/* { dg-final { scan-assembler-not "\tdi" } } */ +/* { dg-final { scan-assembler-not "\tbtstq" } } */ +/* { dg-final { scan-assembler-not "\tand" } } */ +/* { dg-final { scan-assembler-not "\tclearf" } } */ +/* { dg-final { scan-assembler-not "\tmove.d" } } */ +/* { dg-final { scan-assembler-not "\tcmp" } } */ +/* { dg-final { scan-assembler-not "\tb\[^s\]" } } */ +/* { dg-final { scan-assembler-times "\t\[JjBb\]sr" 1 } } */ + +#ifndef type +#define type int +#endif + +type svcsw (type *ptr, type oldval, type newval) +{ + return __sync_val_compare_and_swap (ptr, oldval, newval); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/cris-torture.exp b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/cris-torture.exp new file mode 100644 index 000000000..cf517fcaf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/cris-torture.exp @@ -0,0 +1,41 @@ +# Copyright (C) 2005-2014 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/>. + +# GCC testsuite that uses the `gcc-dg.exp' driver, looping over +# optimization options. + +# Exit immediately if this isn't a CRIS target. +if { ![istarget cris-*-*] && ![istarget crisv32-*-*] } then { + return +} + +# Load support procs. +load_lib gcc-dg.exp + +# If a testcase doesn't have special options, use these. +global DEFAULT_CFLAGS +if ![info exists DEFAULT_CFLAGS] then { + set DEFAULT_CFLAGS " -ansi -pedantic-errors" +} + +# Initialize `dg'. +dg-init + +# Main loop. +gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] $DEFAULT_CFLAGS + +# All done. +dg-finish diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/no-pro-epi-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/no-pro-epi-1.c new file mode 100644 index 000000000..728a34c23 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/no-pro-epi-1.c @@ -0,0 +1,4 @@ +/* { dg-options -mno-prologue-epilogue } */ +void f (void) +{ +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr24750-2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr24750-2.c new file mode 100644 index 000000000..281fb47b7 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr24750-2.c @@ -0,0 +1,20 @@ +/* As the invalid insn in this test got as far as to the target output + code and was "near enough" to output invalid assembly-code, we need + to pass it through the assembler as well. + { dg-do assemble } */ + +int +f (short *a, char *y) +{ + __asm__ ("" : : : +#ifndef __PIC__ + "r0", +#endif + "r1", "r2", "r3", "r4", "r5", "r6", "r7", + /* Register R8 is frame-pointer, and we don't have a means + to not clobber it for the test-runs that don't eliminate + it. But that's ok; we have enough general-register + pressure to repeat the bug without that. */ + "r9", "r10", "r11", "r12", "r13"); + return y[*a]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr34773.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr34773.c new file mode 100644 index 000000000..d3723e38f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/pr34773.c @@ -0,0 +1,74 @@ +/* { dg-do run } */ +union double_union +{ + double d; + int i[2]; +}; +void _dtoa_r (double) __attribute__ ((__noinline__)); +void _vfprintf_r (double) __attribute__ ((__noinline__)); +void +__sprint_r(int); +void +_vfprintf_r(double da) +{ + double ffp = da; + double value = ffp; + union double_union tmp; + + tmp.d = value; + + if ((tmp.i[1]) & ((unsigned)0x80000000L)) { + value = -value; + } + + _dtoa_r (value); + + if (ffp != 0) + __sprint_r(value == 0); + __asm__ (""); +} + + +double dd = -.012; +double ff = .012; + +void exit (int) __attribute__ ((__noreturn__)); +void abort (void) __attribute__ ((__noreturn__)); +void *memset(void *s, int c, __SIZE_TYPE__ n); +void _dtoa_r (double d) +{ + if (d != ff) + abort (); + __asm__ (""); +} + +void __sprint_r (int i) +{ + if (i != 0) + abort (); + __asm__ (""); +} + +int clearstack (void) __attribute__ ((__noinline__)); +int clearstack (void) +{ + char doodle[128]; + memset (doodle, 0, sizeof doodle); + __asm__ volatile ("" : : "g" (doodle) : "memory"); + return doodle[127]; +} + +void doit (void) __attribute__ ((__noinline__)); +void doit (void) +{ + _vfprintf_r (dd); + _vfprintf_r (ff); + __asm__ (""); +} + +int main(void) +{ + clearstack (); + doit (); + exit (0); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c new file mode 100644 index 000000000..dd8704cc9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c new file mode 100644 index 000000000..8055fd380 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1ml.c new file mode 100644 index 000000000..c8cef1841 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-1ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c new file mode 100644 index 000000000..3c162e96a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=2 -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c new file mode 100644 index 000000000..61e1c2047 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=2 -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2ml.c new file mode 100644 index 000000000..0d78e9001 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-2ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=2 -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c new file mode 100644 index 000000000..626a3d5cb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=3 -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c new file mode 100644 index 000000000..339e74cd8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=3 -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3ml.c new file mode 100644 index 000000000..17c6d34d1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-i-3ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=int -Dmisalignment=3 -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c new file mode 100644 index 000000000..f2835aa06 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1.c @@ -0,0 +1,126 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=short -mno-unaligned-atomic-may-use-library" } */ + +/* Make sure we get a SIGTRAP or equivalent when passing unaligned + but otherwise valid pointers to the atomic builtins. */ + +#include <signal.h> +#include <stdlib.h> + +#ifndef type +#error type not defined +#endif + +#ifndef op +#define op 0 +#endif + +#ifndef xchg +#define xchg 0 +#endif + +#if op +int sfa (type *p, type *q, int a); +#endif + +#if xchg +void acen (type *ptr, type *val, type *ret); +#endif + +#ifndef misalignment +#define misalignment 1 +#endif + +volatile int trap_expected = 0; + +struct { char x[misalignment]; type i; } s __attribute__ ((__aligned__ (4))) + = { {0}, (type) 0xdeadbeef }; +type x = 2; +type ret = 42; + +#ifdef TRAP_USING_ABORT +#define SYMSTR(x) STR1(__USER_LABEL_PREFIX__, x) +#define STR1(x,y) STR2(x, y) +#define STR2(x,y) #x #y +/* LTO requires marking seemingly-unused-but-used global functions. */ +void my_abort (void) __asm__ (SYMSTR (abort)) __attribute__ ((__used__)); +void my_abort (void) +#else +#ifdef __gnu_linux__ +void trap_handler(int signum) +#else +#error "can't catch break 8" +#endif +#endif +{ + if (1 +#ifndef TRAP_USING_ABORT + && signum == SIGTRAP +#endif + && trap_expected + && s.i == (type) 0xdeadbeef + && x == 2 && ret == 42) + exit (0); + +#ifdef TRAP_USING_ABORT + /* We might be able to trust the exit-value getting through, but add + a NULL-dereference SEGV just in case. Make sure gcc doesn't + understand the NULL. */ + *({ int *p; asm ("" : "=rm" (p) : "0" (0)); p; }) = 0xdead; + exit (2); +#else + abort (); +#endif +} + +int main(void) +{ + type ret; + +#ifndef TRAP_USING_ABORT +#ifdef __gnu_linux__ + if (signal (SIGTRAP, trap_handler) == SIG_ERR) + abort (); +#endif +#endif + +#ifndef mis_ok + trap_expected = 1; +#endif + +#if op + sfa (&s.i, &s.i, 42); + + /* We should have fallen into the trap now. But don't call abort + yet: if the trap is implemented as a call to abort, we have to + tell the difference. Set a global variable *and* make sure the + setting isn't eliminated by optimizers: another call to sfa + should do it. */ + trap_expected = 0; + +#ifdef mis_ok + /* We're missing a sequence point, but we shouldn't have the initial + value. */ + if (s.i == (type) 0xdeadbeef) + abort (); + exit (0); +#endif + + sfa (&x, &x, 1); +#else + acen (&s.i, &x, &ret); + +#ifdef mis_ok + if (s.i != 2 || x != 2 || ret != (type) 0xdeadbeef) + abort (); + exit (0); +#endif + + trap_expected = 0; + + acen (&x, &x, &ret); +#endif + + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c new file mode 100644 index 000000000..ba639172b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=short -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1ml.c new file mode 100644 index 000000000..3685c5047 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-op-s-1ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dop -Dtype=short -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c new file mode 100644 index 000000000..da25614e2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c new file mode 100644 index 000000000..09a7a9ea3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1ml.c new file mode 100644 index 000000000..d757a683b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-1ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c new file mode 100644 index 000000000..e8a425328 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=2 -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c new file mode 100644 index 000000000..2b97613de --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=2 -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2ml.c new file mode 100644 index 000000000..fb711e0ef --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-2ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=2 -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c new file mode 100644 index 000000000..4a3511bf2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=3 -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c new file mode 100644 index 000000000..94a25e37f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=3 -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3ml.c new file mode 100644 index 000000000..32f8ebbd9 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-i-3ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=int -Dmisalignment=3 -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c new file mode 100644 index 000000000..d8dede9c1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=short -mno-unaligned-atomic-may-use-library" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c new file mode 100644 index 000000000..6f5eb02af --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1a.c @@ -0,0 +1,6 @@ +/* { dg-do run } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=short -DTRAP_USING_ABORT -mno-trap-using-break8" } */ +/* { dg-additional-options "-mtrap-unaligned-atomic" { target cris-*-elf } } */ +/* { dg-additional-options "-mno-unaligned-atomic-may-use-library" { target cris*-*-linux* } } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1ml.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1ml.c new file mode 100644 index 000000000..a6f501c10 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/sync-mis-xchg-s-1ml.c @@ -0,0 +1,4 @@ +/* { dg-do run { target *-*-linux* } } */ +/* { dg-additional-sources "../sync-1.c" } */ +/* { dg-options "-Dxchg -Dtype=short -Dmis_ok" } */ +#include "sync-mis-op-s-1.c" diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-1.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-1.c new file mode 100644 index 000000000..48363fbb3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-1.c @@ -0,0 +1,13 @@ +/* Check that "break 8" defaults according to CPU version. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "*-*-*" } { "-march*" } { "" } } */ +/* { dg-final { scan-assembler "break 8" { target { ! cris-*-elf } } } } */ +/* { dg-final { scan-assembler-not "bsr" { target { ! cris-*-elf } } } } */ +/* { dg-final { scan-assembler-not "jsr" { target { ! cris-*-elf } } } } */ +/* { dg-final { scan-assembler-not "break\[ \t\]" { target cris-*-elf } } } */ +/* { dg-final { scan-assembler "\[jb\]sr \[_\]\?abort" { target cris-*-elf } } } */ + +void do_trap (void) +{ + __builtin_trap (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-2.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-2.c new file mode 100644 index 000000000..155d5fe42 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-2.c @@ -0,0 +1,11 @@ +/* As trap-1.c but forcing on. */ +/* { dg-do compile } */ +/* { dg-options "-mtrap-using-break8" } */ +/* { dg-final { scan-assembler "break 8" } } */ +/* { dg-final { scan-assembler-not "bsr" } } */ +/* { dg-final { scan-assembler-not "jsr" } } */ + +void do_trap (void) +{ + __builtin_trap (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-3.c new file mode 100644 index 000000000..dfa092445 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-3.c @@ -0,0 +1,10 @@ +/* Like trap-1.c and trap-2.c but force calls to abort. */ +/* { dg-do compile } */ +/* { dg-options "-mno-trap-using-break8" } */ +/* { dg-final { scan-assembler-not "break\[ \t\]" } } */ +/* { dg-final { scan-assembler "\[jb\]sr \[_\]\?abort" } } */ + +void do_trap (void) +{ + __builtin_trap (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v0.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v0.c new file mode 100644 index 000000000..084fb28d4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v0.c @@ -0,0 +1,11 @@ +/* As trap-1.c but with CPU version specified, excluding. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "*-*-*" } { "-march=*" } { "" } } */ +/* { dg-options "-march=v0" } */ +/* { dg-final { scan-assembler-not "break\[ \t\]" } } */ +/* { dg-final { scan-assembler "\[jb\]sr \[_\]\?abort" } } */ + +void do_trap (void) +{ + __builtin_trap (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v3.c b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v3.c new file mode 100644 index 000000000..e004c5bc8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.target/cris/torture/trap-v3.c @@ -0,0 +1,12 @@ +/* As trap-1.c but with CPU version specified, including. */ +/* { dg-do compile } */ +/* { dg-skip-if "" { "*-*-*" } { "-march=*" } { "" } } */ +/* { dg-options "-march=v3" } */ +/* { dg-final { scan-assembler "break 8" } } */ +/* { dg-final { scan-assembler-not "bsr" } } */ +/* { dg-final { scan-assembler-not "jsr" } } */ + +void do_trap (void) +{ + __builtin_trap (); +} |