+2018-08-17 Sandra Loosemore <sandra@codesourcery.com>
+ Chung-Lin Tang <cltang@codesourcery.com>
+ Xianmiao Qu <xianmiao_qu@c-sky.com>
+
+ C-SKY port: Testsuite
+
+ * g++.dg/Wno-frame-address.C: Adjust for C-SKY.
+ * g++.dg/torture/type-generic-1.C: Likewise.
+ * gcc.c-torture/compile/20000804-1.c: Likewise.
+ * gcc.c-torture/execute/20101011-1.c: Likewise.
+ * gcc.c-torture/execute/ieee/mul-subnormal-single-1.x: Likewise.
+ * gcc.dg/20020312-2.c: Likewise.
+ * gcc.dg/Wno-frame-address.c: Likewise.
+ * gcc.dg/c11-true_min-1.c: Likewise.
+ * gcc.dg/sibcall-10.c: Likewise.
+ * gcc.dg/sibcall-9.c: Likewise.
+ * gcc.dg/stack-usage-1.c: Likewise.
+ * gcc.dg/torture/float32-tg-3.c: Likewise.
+ * gcc.dg/torture/float32x-tg-3.c: Likewise.
+ * gcc.dg/torture/float64-tg-3.c: Likewise.
+ * gcc.dg/torture/float64x-tg-3.c: Likewise.
+ * gcc.dg/torture/type-generic-1.c: Likewise.
+ * gcc.target/csky/*: New.
+ * lib/target-supports.exp (check_profiling_available): Add
+ csky-*-elf.
+ (check_effective_target_hard_float): Handle C-SKY targets with
+ single-precision hard float only.
+ (check_effective_target_logical_op_short_circuit): Handle C-SKY.
+
2018-08-17 David Malcolm <dmalcolm@redhat.com>
* gcc.dg/format/gcc_diag-1.c: Fix typo. Add test coverage for
// { dg-do compile }
-// { dg-skip-if "Cannot access arbitrary stack frames." { arm*-*-* hppa*-*-* ia64-*-* } }
+// { dg-skip-if "Cannot access arbitrary stack frames." { arm*-*-* hppa*-*-* ia64-*-* csky*-*-* } }
// { dg-options "-Werror" }
// { dg-additional-options "-mbackchain" { target s390*-*-* } }
/* { dg-do run } */
/* { dg-add-options ieee } */
/* { dg-skip-if "No Inf/NaN support" { spu-*-* } } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
#include "../../gcc.dg/tg-tests.h"
/* { dg-skip-if "" { { i?86-*-* x86_64-*-* } && { ia32 && { ! nonpic } } } } */
/* { dg-skip-if "No 64-bit registers" { m32c-*-* } } */
/* { dg-skip-if "Not enough 64-bit registers" { pdp11-*-* } { "-O0" } { "" } } */
+/* { dg-xfail-if "Inconsistent constraint on asm" { csky-*-* } { "-O0" } { "" } } */
/* { dg-xfail-if "" { h8300-*-* } } */
/* Copyright (C) 2000, 2003 Free Software Foundation */
#elif defined (__nvptx__)
/* There isn't even a signal function. */
# define DO_TEST 0
+#elif defined (__csky__)
+ /* This presently doesn't raise SIGFPE even on csky-linux-gnu, much
+ less bare metal. See the implementation of __divsi3 in libgcc. */
+# define DO_TEST 0
#else
# define DO_TEST 1
#endif
+if {[istarget "csky-*-*"] && [check_effective_target_hard_float]} {
+ # The C-SKY hardware FPU only supports flush-to-zero mode.
+ set torture_execute_xfail "csky-*-*"
+ return 1
+}
if [istarget "epiphany-*-*"] {
# The Epiphany single-precision floating point format does not
# support subnormals.
/* No pic register. */
#elif defined (__nvptx__)
/* No pic register. */
+#elif defined (__csky__)
+/* Pic register is r28, but some cores only have r0-r15. */
+# if defined (__CK807__) || defined (__CK810__)
+# define PIC_REG "r28"
+# endif
#else
# error "Modify the test for your target."
#endif
/* { dg-do compile } */
-/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* avr-*-* hppa*-*-* ia64-*-* visium-*-* } } */
+/* { dg-skip-if "Cannot access arbitrary stack frames" { arm*-*-* avr-*-* hppa*-*-* ia64-*-* visium-*-* csky-*-* } } */
/* { dg-options "-Werror" } */
/* { dg-additional-options "-mbackchain" { target { s390*-*-* } } } */
/* { dg-do run } */
/* { dg-options "-std=c11" } */
/* { dg-xfail-run-if "PR58757 -mieee is required to compare denormals" { alpha*-*-* } } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
/* Test that the smallest positive value is not 0. This needs to be true
even when denormals are not supported, so we do not pass any flag
Copyright (C) 2002 Free Software Foundation Inc.
Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
-/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
+/* { dg-do run { xfail { { cris-*-* crisv32-*-* csky-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
/* -mlongcall disables sibcall patterns. */
/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
/* -msave-restore disables sibcall patterns. */
Copyright (C) 2002 Free Software Foundation Inc.
Contributed by Hans-Peter Nilsson <hp@bitrange.com> */
-/* { dg-do run { xfail { { cris-*-* crisv32-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* nvptx-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
+/* { dg-do run { xfail { { cris-*-* crisv32-*-* csky-*-* h8300-*-* hppa*64*-*-* m32r-*-* mcore-*-* mn10300-*-* msp430*-*-* nds32*-*-* nvptx-*-* xstormy16-*-* v850*-*-* vax-*-* xtensa*-*-* } || { arm*-*-* && { ! arm32 } } } } } */
/* -mlongcall disables sibcall patterns. */
/* { dg-skip-if "" { powerpc*-*-* } { "-mlongcall" } { "" } } */
/* -msave-restore disables sibcall patterns. */
#define SIZE 252
#elif defined (__M32R__)
#define SIZE 252
+#elif defined (__csky__)
+# define SIZE 252
#else
# define SIZE 256
#endif
/* { dg-add-options float32 } */
/* { dg-add-options ieee } */
/* { dg-require-effective-target float32_runtime } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
#define WIDTH 32
#define EXT 0
/* { dg-add-options float32x } */
/* { dg-add-options ieee } */
/* { dg-require-effective-target float32x_runtime } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
#define WIDTH 32
#define EXT 1
/* { dg-add-options float64 } */
/* { dg-add-options ieee } */
/* { dg-require-effective-target float64_runtime } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
#define WIDTH 64
#define EXT 0
/* { dg-add-options float64x } */
/* { dg-add-options ieee } */
/* { dg-require-effective-target float64x_runtime } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
#define WIDTH 64
#define EXT 1
/* { dg-do run } */
/* { dg-skip-if "No Inf/NaN support" { spu-*-* } } */
+/* { dg-skip-if "No subnormal support" { csky-*-* } { "-mhard-float" } } */
/* { dg-options "-DUNSAFE" { target tic6x*-*-* visium-*-* nvptx-*-* } } */
/* { dg-add-options ieee } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+int and1 (int x)
+{
+ return x & 0xfff7ffff;
+}
+
+/* { dg-final { scan-assembler "bclri" } } */
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+int and2 (int x)
+{
+ return x & 0xfff00000;
+}
+
+/* { dg-final { scan-assembler "lsri" } } */
+/* { dg-final { scan-assembler "lsli" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck801 -O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+int and3 (int x)
+{
+ return x & 0x000fffff;
+}
+
+/* { dg-final { scan-assembler "lsli" } } */
+/* { dg-final { scan-assembler "lsri" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck810f -O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+int and3 (int x)
+{
+ return x & 0x000fffff;
+}
+
+/* { dg-final { scan-assembler "zext" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck801 -O1 -fno-reorder-blocks" } */
+
+/* Test branch generation on CK801, which cannot rely on assembler
+ branch relaxation because long branches clobber lr. */
+
+#define nop8 asm ("nop\nnop\nnop\nnop\nnop\nnop\nnop\nnop")
+#define nop64 nop8; nop8; nop8; nop8; nop8; nop8; nop8; nop8
+#define nop512 nop64; nop64; nop64; nop64; nop64; nop64; nop64; nop64
+#define nop4k nop512; nop512; nop512; nop512; nop512; nop512; nop512; nop512
+#define nop32k nop4k; nop4k; nop4k; nop4k; nop4k; nop4k; nop4k; nop4k
+
+extern void g (int);
+int f (int x, int y, int z)
+{
+ if (x == 0) // cmpnei; jbt
+ {
+ nop64;
+ x = y;
+ }
+ if (y == 0) // cmpnei; jbf; jbr
+ {
+ nop512;
+ y = z;
+ }
+ if (z == 0) // cmpnei; jbf; bsr
+ {
+ nop32k;
+ z = x;
+ }
+ return x + y + z;
+}
+
+/* { dg-final { scan-assembler "push.*lr" } } */
+/* { dg-final { scan-assembler "pop.*lr" } } */
+/* { dg-final { scan-assembler-times "cmpnei" 3 } } */
+/* { dg-final { scan-assembler-times "jbt" 1 } } */
+/* { dg-final { scan-assembler-times "jbf" 2 } } */
+/* { dg-final { scan-assembler-times "jbr" 1 } } */
+/* { dg-final { scan-assembler-times "bsr" 1 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck801 -O1" } */
+
+/* Make sure that constant pools are emitted by the compiler for ck801.
+ If this is deferred to the assembler, the compiler will compute
+ incorrect branch offsets. */
+
+void f (unsigned int *u, long long int *l, float *f, double *d)
+{
+ *u = 0xdeadbeef;
+ *l = 0xcafef00dc0ffeeULL;
+ *f = 3.14159F;
+ *d = 2.718281828459;
+}
+
+/* { dg-final { scan-assembler-times "\\.long" 6 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck810f -O1 -mconstpool" } */
+
+/* Make sure that constant pools are emitted by the compiler when
+ -mconstpool is provided. */
+
+void f (unsigned int *u, long long int *l, float *f, double *d)
+{
+ *u = 0xdeadbeef;
+ *l = 0xcafef00dc0ffeeULL;
+ *f = 3.14159F;
+ *d = 2.718281828459;
+}
+
+/* { dg-final { scan-assembler-times "\\.long" 6 } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-mcpu=ck810f -O1 -mno-constpool" } */
+
+/* Make sure that constant pools are not emitted by the compiler when
+ -mno-constpool is provided. */
+
+void f (unsigned int *u, long long int *l, float *f, double *d)
+{
+ *u = 0xdeadbeef;
+ *l = 0xcafef00dc0ffeeULL;
+ *f = 3.14159F;
+ *d = 2.718281828459;
+}
+
+/* { dg-final { scan-assembler-not "\\.long" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O2" } */
+
+/* Test that the two comparisons are combined. This was formerly handled
+ by a no-longer-present target-specific pass and is now supposed to
+ be handled by generic CSE. */
+
+int e1, e2;
+
+void func (int a, int b, int c, int d, int f, int g)
+{
+ e1 = a > b ? f : g;
+ e2 = a > b ? c : d;
+
+ return;
+}
+
+/* { dg-final { scan-assembler-times "cmp" 1 } } */
+
--- /dev/null
+# GCC testsuite for C-SKY targets.
+# Copyright (C) 2012-2018 Free Software Foundation, Inc.
+# Contributed by C-SKY Microsystems and Mentor Graphics.
+#
+# 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/>.
+
+# Exit immediately if this isn't a C-SKY target.
+if ![istarget csky*-*-*] then {
+ return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Like dg-options, but treats certain C-SKY-specific options specially:
+#
+# -mcpu=*
+# Select the target cpu. Skip the test if the multilib flags force
+# a different cpu.
+proc dg-csky-options {args} {
+ upvar dg-extra-tool-flags extra_tool_flags
+ upvar dg-do-what do_what
+
+ set multilib_cpu ""
+ set multilib_hf ""
+ set cpu ""
+
+ foreach flag [target_info multilib_flags] {
+ regexp "^-mcpu=(.*)" $flag dummy multilib_cpu
+ regexp "^-mhard-float" $flag multilib_hf
+ }
+
+ set flags [lindex $args 1]
+
+ foreach flag $flags {
+ regexp "^-mcpu=(.*)" $flag dummy cpu
+ }
+
+ if {$cpu == ""} then {
+ set extra_tool_flags $flags
+ } elseif {$multilib_cpu == "" || $multilib_cpu == $cpu} then {
+ if { ($cpu == "ck801" || $cpu == "ck802")
+ && $multilib_hf != "" } then {
+ set do_what [list [lindex $do_what 0] "N" "P"]
+ } else {
+ set extra_tool_flags $flags
+ }
+ } else {
+ set do_what [list [lindex $do_what 0] "N" "P"]
+ }
+}
+
+# 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/*.\[cCS\]]] \
+ "" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
--- /dev/null
+/* { dg-do run } */
+
+/* Check that a structure argument passed partially in registers and
+ partially on the stack works. */
+
+#include <stdlib.h>
+#include <string.h>
+
+struct s {
+ unsigned int i;
+ double d;
+ char s[16];
+};
+
+/* Note specifically that, since there are 4 argument registers, the
+ value of ss.d is split between the last argument register and the
+ stack. */
+void
+f (struct s *sp, int j, struct s ss, int k)
+{
+ if (sp->i != ss.i
+ || sp->d != ss.d
+ || strcmp (sp->s, ss.s))
+ abort ();
+ if (j != -k)
+ abort ();
+}
+
+int
+main (void)
+{
+ struct s ss;
+ ss.i = 0xdeadbeef;
+ ss.d = 2.71828;
+ strcpy (ss.s, "shazam!");
+ f (&ss, 42, ss, -42);
+ return 0;
+}
--- /dev/null
+/* { dg-do run } */
+
+/* Check that varargs passed partially in registers and
+ partially on the stack works. */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdarg.h>
+
+struct s {
+ unsigned int i;
+ double d;
+ char s[16];
+};
+
+/* Note specifically that, as there are 4 argument registers,
+ the value of ss.d is split between the last argument register
+ and the stack. */
+void
+f (struct s *sp, ...)
+{
+ int j, k;
+ unsigned int i;
+ double d;
+ char *s;
+ va_list ap;
+ va_start (ap, sp);
+ j = va_arg (ap, int);
+ i = va_arg (ap, unsigned int);
+ d = va_arg (ap, double);
+ s = va_arg (ap, char *);
+ k = va_arg (ap, int);
+ va_end (ap);
+
+ if (sp->i != i
+ || sp->d != d
+ || strcmp (sp->s, s))
+ abort ();
+ if (j != -k)
+ abort ();
+}
+
+int
+main (void)
+{
+ struct s ss;
+ ss.i = 0xdeadbeef;
+ ss.d = 2.71828;
+ strcpy (ss.s, "shazam!");
+ f (&ss, 42, ss.i, ss.d, ss.s, -42);
+ return 0;
+}
--- /dev/null
+/* { dg-do run } */
+
+/* Check that sub-word sized elements of structures passed in in
+ registers are handled correctly with respect to the current endianness. */
+
+#include <stdlib.h>
+#include <string.h>
+
+struct s {
+ short h;
+ char s[8];
+};
+
+void
+f (struct s *sp, struct s ss)
+{
+ if (sp->h != ss.h
+ || strcmp (sp->s, ss.s))
+ abort ();
+}
+
+int
+main (void)
+{
+ struct s ss;
+ ss.h = 42;
+ strcpy (ss.s, "shazam!");
+ f (&ss, ss);
+ return 0;
+}
+
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+long long int land1 (long long int x)
+{
+ return x & 0xffffffff00000000LL;
+}
+
+/* { dg-final { scan-assembler "movi.*, 0" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+long long int land2 (long long int x)
+{
+ return x & 0x00000000ffffffffLL;
+}
+
+/* { dg-final { scan-assembler "movi.*, 0" } } */
--- /dev/null
+/* { dg-do compile } */
+/* { dg-final { scan-assembler-not "push" } } */
+/* { dg-final { scan-assembler-not "pop" } } */
+
+/* Check that there is no prologue/epilogue code emitted for a function
+ with the naked attribute. Without the attribute, this function would
+ push/pop lr. */
+
+extern void g (int);
+
+int __attribute__((naked))
+f (int x)
+{
+ g (x);
+ return 42;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-csky-options "-O1" } */
+
+/* Test special code generation patterns for bit operators. */
+
+int or1 (int x)
+{
+ return x | 0x00100000;
+}
+
+/* { dg-final { scan-assembler "bseti" } } */
|| [istarget bfin-*-*]
|| [istarget cris-*-*]
|| [istarget crisv32-*-*]
+ || [istarget csky-*-elf]
|| [istarget fido-*-elf]
|| [istarget h8300-*-*]
|| [istarget lm32-*-*]
# }]
}
+ # The generic test doesn't work for C-SKY because some cores have
+ # hard float for single precision only.
+ if { [istarget csky*-*-*] } {
+ return [check_no_compiler_messages hard_float assembly {
+ #if defined __csky_soft_float__
+ #error __csky_soft_float__
+ #endif
+ }]
+ }
+
# The generic test equates hard_float with "no call for adding doubles".
return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
double a (double b, double c) { return b + c; }
|| [istarget arc*-*-*]
|| [istarget avr*-*-*]
|| [istarget crisv32-*-*] || [istarget cris-*-*]
+ || [istarget csky*-*-*]
|| [istarget mmix-*-*]
|| [istarget s390*-*-*]
|| [istarget powerpc*-*-*]
proc check_effective_target_branch_cost {} {
if { [ istarget arm*-*-*]
|| [istarget avr*-*-*]
+ || [istarget csky*-*-*]
|| [istarget epiphany*-*-*]
|| [istarget frv*-*-*]
|| [istarget i?86-*-*] || [istarget x86_64-*-*]