+2007-08-23 Uros Bizjak <ubizjak@gmail.com>
+
+ * gcc.dg/arm-eabi1.c, gcc.dg/symbian1.c, cc.dg/symbian2.c,
+ gcc.dg/symbian3.c, gcc.dg/symbian4.c, gcc.dg/symbian5.c,
+ gcc.dg/20051215-1.c: Move to gcc.target/arm directory.
+ * gcc.dg/const-compare.c, gcc.dg/non-lazy-ptr-test.c,
+ gcc.dg/unsigned-long-compare.c, gcc.dg/rs6000-leaf.c: Move to
+ gcc.target/powerpc directory.
+ * gcc.dg/m68k-pic-1.c, gcc.dg/m68k-slp-ice.c: Move to
+ gcc.target/m68k directory.
+ * gcc.dg/i386-darwin-fpmath.c: Move to gcc.target/i386 directory.
+ * gcc.dg/cris-peep2-andu1.c, gcc.dg/cris-peep2-andu2.c,
+ gcc.dg/cris-peep2-xsrand.c, gcc.dg/cris-peep2-xsrand2.c: Move to
+ gcc.target/cris directory.
+ * gcc.dg/20020620-1.c: Move to gcc.target/mips directory.
+ * gcc.dg/bfin-longcall-1.c, gcc.dg/bfin-longcall-2.c: Move to
+ gcc.target/bfin directory.
+
+ * gcc.target/sh: New directory.
+ * gcc.target/sh/sh.exp: New file.
+ * gcc.dg/pr21255-1.c, gcc.dg/pr21255-2-mb.c, gcc.dg/pr21255-2-ml.c,
+ gcc.dg/pr21255-3.c, gcc.dg/pr21255-4.c, gcc.dg/sh4a-bitmovua.c,
+ gcc.dg/sh4a-cos.c, gcc.dg/sh4a-cosf.c, gcc.dg/sh4a-fprun.c,
+ gcc.dg/sh4a-fsrra.c, gcc.dg/sh4a-memmovua.c, gcc.dg/sh4a-sin.c,
+ gcc.dg/sh4a-sincosf.c, gcc.dg/sh4a-sinf.c gcc.dg/sh-relax.c,
+ gcc.dg/sh-relax-vxworks.c: Move to gcc.target/sh directory.
+
2007-08-23 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/pow-1.c: Fix scan-assembler-not.
+++ /dev/null
-/* 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 { target cris-*-* } } */
-/* { dg-options "-O2" } */
-/* { dg-message "reg:SI|const_double:DF" "prune debug_rtx output" { target cris-*-* } 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;# %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. */
-}
+++ /dev/null
-/* { dg-do compile { target mips64*-*-* mipsisa64*-*-* } } */
-/* { dg-options "-O2 -mlong64" } */
-int foo (int *x, int i)
-{
- return x[i] + i;
-}
-/* { dg-final { scan-assembler-not "move" } } */
+++ /dev/null
-/* ARM's load-and-call patterns used to allow automodified addresses.
- This was wrong, because if the modified register were spilled,
- the call would need an output reload. */
-/* { dg-do run { target arm*-*-* } } */
-/* { dg-options "-O2 -fno-omit-frame-pointer" } */
-extern void abort (void);
-typedef void (*callback) (void);
-
-static void
-foo (callback *first, callback *p)
-{
- while (p > first)
- {
- (*--p) ();
-#ifndef __thumb__
- asm ("" : "=r" (p) : "0" (p)
- : "r4", "r5", "r6", "r7", "r8", "r9", "r10");
-#endif
- }
-}
-
-static void
-dummy (void)
-{
- static int count;
- if (count++ == 1)
- abort ();
-}
-
-int
-main (void)
-{
- callback list[1] = { dummy };
- foo (&list[0], &list[1]);
- return 0;
-}
+++ /dev/null
-/* { dg-do run { target arm*-*-symbianelf* arm*-*-eabi* } } */
-/* { dg-options "" } */
-
-/* This file tests most of the non-C++ run-time helper functions
- described in Section 4 of the "Run-Time ABI for the ARM
- Architecture". These are basic tests; they do not try to validate
- all of the corner cases in these routines.
-
- The functions not tested here are:
-
- __aeabi_cdcmpeq
- __aeabi_cdcmple
- __aeabi_cdrcmple
- __aeabi_cfcmpeq
- __aeabi_cfcmple
- __aeabi_cfrcmple
- __aeabi_ldivmod
- __aeabi_uldivmod
- __aeabi_idivmod
- __aeabi_uidivmod
-
- These functions have non-standard calling conventions that would
- require the use of inline assembly to test. It would be good to
- add such tests, but they have not yet been implemented.
-
- There are also no tests for the "division by zero", "memory copying,
- clearing, and setting" functions. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#define decl_float(code, type) \
- extern type __aeabi_ ## code ## add (type, type); \
- extern type __aeabi_ ## code ## div (type, type); \
- extern type __aeabi_ ## code ## mul (type, type); \
- extern type __aeabi_ ## code ## neg (type); \
- extern type __aeabi_ ## code ## rsub (type, type); \
- extern type __aeabi_ ## code ## sub (type, type); \
- extern int __aeabi_ ## code ## cmpeq (type, type); \
- extern int __aeabi_ ## code ## cmplt (type, type); \
- extern int __aeabi_ ## code ## cmple (type, type); \
- extern int __aeabi_ ## code ## cmpge (type, type); \
- extern int __aeabi_ ## code ## cmpgt (type, type); \
- extern int __aeabi_ ## code ## cmpun (type, type); \
- extern int __aeabi_ ## code ## 2iz (type); \
- extern unsigned int __aeabi_ ## code ## 2uiz (type); \
- extern long long __aeabi_ ## code ## 2lz (type); \
- extern unsigned long long __aeabi_ ## code ## 2ulz (type); \
- extern type __aeabi_i2 ## code (int); \
- extern type __aeabi_ui2 ## code (int); \
- extern type __aeabi_l2 ## code (long long); \
- extern type __aeabi_ul2 ## code (unsigned long long); \
- \
- type code ## zero = 0.0; \
- type code ## one = 1.0; \
- type code ## two = 2.0; \
- type code ## four = 4.0; \
- type code ## minus_one = -1.0; \
- type code ## minus_two = -2.0; \
- type code ## minus_four = -4.0; \
- type code ## epsilon = 1E-32; \
- type code ## NaN = 0.0 / 0.0;
-
-decl_float (d, double)
-decl_float (f, float)
-
-extern float __aeabi_d2f (double);
-extern double __aeabi_f2d (float);
-extern long long __aeabi_lmul (long long, long long);
-extern long long __aeabi_llsl (long long, int);
-extern long long __aeabi_llsr (long long, int);
-extern long long __aeabi_lasr (long long, int);
-extern int __aeabi_lcmp (long long, long long);
-extern int __aeabi_ulcmp (unsigned long long, unsigned long long);
-extern int __aeabi_idiv (int, int);
-extern unsigned int __aeabi_uidiv (unsigned int, unsigned int);
-extern int __eabi_uread4 (void *);
-extern int __eabi_uwrite4 (int, void *);
-extern long long __eabi_uread8 (void *);
-extern long long __eabi_uwrite8 (long long, void *);
-
-#define eq(a, b, type, abs, epsilon, format) \
- { \
- type a1; \
- type b1; \
- \
- a1 = a; \
- b1 = b; \
- if (abs (a1 - b1) > epsilon) \
- { \
- fprintf (stderr, "%d: Test %s == %s\n", __LINE__, #a, #b); \
- fprintf (stderr, "%d: " format " != " format "\n", \
- __LINE__, a1, b1); \
- abort (); \
- } \
- }
-
-#define ieq(a, b) eq (a, b, int, abs, 0, "%d")
-#define ueq(a, b) eq (a, b, unsigned int, abs, 0, "%u")
-#define leq(a, b) eq (a, b, long long, abs, 0, "%lld")
-#define uleq(a, b) eq (a, b, unsigned long long, abs, 0, "%llu")
-#define feq(a, b) eq (a, b, float, fabs, fepsilon, "%f")
-#define deq(a, b) eq (a, b, double, fabs, depsilon, "%g")
-
-#define NUM_CMP_VALUES 6
-
-/* Values picked to cover a range of small, large, positive and negative. */
-static unsigned int cmp_val[NUM_CMP_VALUES] =
-{
- 0,
- 1,
- 0x40000000,
- 0x80000000,
- 0xc0000000,
- 0xffffffff
-};
-
-/* All combinations for each of the above values. */
-#define ulcmp(l, s, m) \
- s, l, l, l, l, l, m, s, l, l, l, l, \
- m, m, s, l, l, l, m, m, m, s, l, l, \
- m, m, m, m, s, l, m, m, m, m, m, s
-
-#define lcmp(l, s, m) \
- s, l, l, m, m, m, m, s, l, m, m, m, \
- m, m, s, m, m, m, l, l, l, s, l, l, \
- l, l, l, m, s, l, l, l, l, m, m, s
-
-/* All combinations of the above for high/low words. */
-static int lcmp_results[] =
-{
- lcmp(ulcmp(-1, -1, -1), ulcmp(-1, 0, 1), ulcmp(1, 1, 1))
-};
-
-static int ulcmp_results[] =
-{
- ulcmp(ulcmp(-1, -1, -1), ulcmp(-1, 0, 1), ulcmp(1, 1, 1))
-};
-
-static int signof(int i)
-{
- if (i < 0)
- return -1;
-
- if (i == 0)
- return 0;
-
- return 1;
-}
-
-int main () {
- unsigned char bytes[256];
- int i, j, k, n;
- int *result;
-
- /* Table 2. Double-precision floating-point arithmetic. */
- deq (__aeabi_dadd (dzero, done), done);
- deq (__aeabi_dadd (done, done), dtwo);
- deq (__aeabi_ddiv (dminus_four, dminus_two), dtwo);
- deq (__aeabi_ddiv (dminus_two, dtwo), dminus_one);
- deq (__aeabi_dmul (dtwo, dtwo), dfour);
- deq (__aeabi_dmul (dminus_one, dminus_two), dtwo);
- deq (__aeabi_dneg (dminus_one), done);
- deq (__aeabi_dneg (dfour), dminus_four);
- deq (__aeabi_drsub (done, dzero), dminus_one);
- deq (__aeabi_drsub (dtwo, dminus_two), dminus_four);
- deq (__aeabi_dsub (dzero, done), dminus_one);
- deq (__aeabi_dsub (dminus_two, dtwo), dminus_four);
-
- /* Table 3. Double-precision floating-point comparisons. */
- ieq (__aeabi_dcmpeq (done, done), 1);
- ieq (__aeabi_dcmpeq (done, dzero), 0);
- ieq (__aeabi_dcmpeq (dNaN, dzero), 0);
- ieq (__aeabi_dcmpeq (dNaN, dNaN), 0);
-
- ieq (__aeabi_dcmplt (dzero, done), 1);
- ieq (__aeabi_dcmplt (done, dzero), 0);
- ieq (__aeabi_dcmplt (dzero, dzero), 0);
- ieq (__aeabi_dcmplt (dzero, dNaN), 0);
- ieq (__aeabi_dcmplt (dNaN, dNaN), 0);
-
- ieq (__aeabi_dcmple (dzero, done), 1);
- ieq (__aeabi_dcmple (done, dzero), 0);
- ieq (__aeabi_dcmple (dzero, dzero), 1);
- ieq (__aeabi_dcmple (dzero, dNaN), 0);
- ieq (__aeabi_dcmple (dNaN, dNaN), 0);
-
- ieq (__aeabi_dcmpge (dzero, done), 0);
- ieq (__aeabi_dcmpge (done, dzero), 1);
- ieq (__aeabi_dcmpge (dzero, dzero), 1);
- ieq (__aeabi_dcmpge (dzero, dNaN), 0);
- ieq (__aeabi_dcmpge (dNaN, dNaN), 0);
-
- ieq (__aeabi_dcmpgt (dzero, done), 0);
- ieq (__aeabi_dcmpgt (done, dzero), 1);
- ieq (__aeabi_dcmplt (dzero, dzero), 0);
- ieq (__aeabi_dcmpgt (dzero, dNaN), 0);
- ieq (__aeabi_dcmpgt (dNaN, dNaN), 0);
-
- ieq (__aeabi_dcmpun (done, done), 0);
- ieq (__aeabi_dcmpun (done, dzero), 0);
- ieq (__aeabi_dcmpun (dNaN, dzero), 1);
- ieq (__aeabi_dcmpun (dNaN, dNaN), 1);
-
- /* Table 4. Single-precision floating-point arithmetic. */
- feq (__aeabi_fadd (fzero, fone), fone);
- feq (__aeabi_fadd (fone, fone), ftwo);
- feq (__aeabi_fdiv (fminus_four, fminus_two), ftwo);
- feq (__aeabi_fdiv (fminus_two, ftwo), fminus_one);
- feq (__aeabi_fmul (ftwo, ftwo), ffour);
- feq (__aeabi_fmul (fminus_one, fminus_two), ftwo);
- feq (__aeabi_fneg (fminus_one), fone);
- feq (__aeabi_fneg (ffour), fminus_four);
- feq (__aeabi_frsub (fone, fzero), fminus_one);
- feq (__aeabi_frsub (ftwo, fminus_two), fminus_four);
- feq (__aeabi_fsub (fzero, fone), fminus_one);
- feq (__aeabi_fsub (fminus_two, ftwo), fminus_four);
-
- /* Table 5. Single-precision floating-point comparisons. */
- ieq (__aeabi_fcmpeq (fone, fone), 1);
- ieq (__aeabi_fcmpeq (fone, fzero), 0);
- ieq (__aeabi_fcmpeq (fNaN, fzero), 0);
- ieq (__aeabi_fcmpeq (fNaN, fNaN), 0);
-
- ieq (__aeabi_fcmplt (fzero, fone), 1);
- ieq (__aeabi_fcmplt (fone, fzero), 0);
- ieq (__aeabi_fcmplt (fzero, fzero), 0);
- ieq (__aeabi_fcmplt (fzero, fNaN), 0);
- ieq (__aeabi_fcmplt (fNaN, fNaN), 0);
-
- ieq (__aeabi_fcmple (fzero, fone), 1);
- ieq (__aeabi_fcmple (fone, fzero), 0);
- ieq (__aeabi_fcmple (fzero, fzero), 1);
- ieq (__aeabi_fcmple (fzero, fNaN), 0);
- ieq (__aeabi_fcmple (fNaN, fNaN), 0);
-
- ieq (__aeabi_fcmpge (fzero, fone), 0);
- ieq (__aeabi_fcmpge (fone, fzero), 1);
- ieq (__aeabi_fcmpge (fzero, fzero), 1);
- ieq (__aeabi_fcmpge (fzero, fNaN), 0);
- ieq (__aeabi_fcmpge (fNaN, fNaN), 0);
-
- ieq (__aeabi_fcmpgt (fzero, fone), 0);
- ieq (__aeabi_fcmpgt (fone, fzero), 1);
- ieq (__aeabi_fcmplt (fzero, fzero), 0);
- ieq (__aeabi_fcmpgt (fzero, fNaN), 0);
- ieq (__aeabi_fcmpgt (fNaN, fNaN), 0);
-
- ieq (__aeabi_fcmpun (fone, fone), 0);
- ieq (__aeabi_fcmpun (fone, fzero), 0);
- ieq (__aeabi_fcmpun (fNaN, fzero), 1);
- ieq (__aeabi_fcmpun (fNaN, fNaN), 1);
-
- /* Table 6. Floating-point to integer conversions. */
- ieq (__aeabi_d2iz (dminus_one), -1);
- ueq (__aeabi_d2uiz (done), 1);
- leq (__aeabi_d2lz (dminus_two), -2LL);
- uleq (__aeabi_d2ulz (dfour), 4LL);
- ieq (__aeabi_f2iz (fminus_one), -1);
- ueq (__aeabi_f2uiz (fone), 1);
- leq (__aeabi_f2lz (fminus_two), -2LL);
- uleq (__aeabi_f2ulz (ffour), 4LL);
-
- /* Table 7. Conversions between floating types. */
- feq (__aeabi_d2f (dtwo), ftwo);
- deq (__aeabi_f2d (fminus_four), dminus_four);
-
- /* Table 8. Integer to floating-point conversions. */
- deq (__aeabi_i2d (-1), dminus_one);
- deq (__aeabi_ui2d (2), dtwo);
- deq (__aeabi_l2d (-1), dminus_one);
- deq (__aeabi_ul2d (2ULL), dtwo);
- feq (__aeabi_i2f (-1), fminus_one);
- feq (__aeabi_ui2f (2), ftwo);
- feq (__aeabi_l2f (-1), fminus_one);
- feq (__aeabi_ul2f (2ULL), ftwo);
-
- /* Table 9. Long long functions. */
- leq (__aeabi_lmul (4LL, -1LL), -4LL);
- leq (__aeabi_llsl (2LL, 1), 4LL);
- leq (__aeabi_llsr (-1LL, 63), 1);
- leq (__aeabi_lasr (-1LL, 63), -1);
-
- result = lcmp_results;
- for (i = 0; i < NUM_CMP_VALUES; i++)
- for (j = 0; j < NUM_CMP_VALUES; j++)
- for (k = 0; k < NUM_CMP_VALUES; k++)
- for (n = 0; n < NUM_CMP_VALUES; n++)
- {
- ieq (signof (__aeabi_lcmp
- (((long long)cmp_val[i] << 32) | cmp_val[k],
- ((long long)cmp_val[j] << 32) | cmp_val[n])),
- *result);
- result++;
- }
- result = ulcmp_results;
- for (i = 0; i < NUM_CMP_VALUES; i++)
- for (j = 0; j < NUM_CMP_VALUES; j++)
- for (k = 0; k < NUM_CMP_VALUES; k++)
- for (n = 0; n < NUM_CMP_VALUES; n++)
- {
- ieq (signof (__aeabi_ulcmp
- (((long long)cmp_val[i] << 32) | cmp_val[k],
- ((long long)cmp_val[j] << 32) | cmp_val[n])),
- *result);
- result++;
- }
-
- ieq (__aeabi_idiv (-550, 11), -50);
- ueq (__aeabi_uidiv (4000000000U, 1000000U), 4000U);
-
- for (i = 0; i < 256; i++)
- bytes[i] = i;
-
-#ifdef __ARMEB__
- ieq (__aeabi_uread4 (bytes + 1), 0x01020304U);
- leq (__aeabi_uread8 (bytes + 3), 0x030405060708090aLL);
- ieq (__aeabi_uwrite4 (0x66778899U, bytes + 5), 0x66778899U);
- leq (__aeabi_uwrite8 (0x2030405060708090LL, bytes + 15),
- 0x2030405060708090LL);
-#else
- ieq (__aeabi_uread4 (bytes + 1), 0x04030201U);
- leq (__aeabi_uread8 (bytes + 3), 0x0a09080706050403LL);
- ieq (__aeabi_uwrite4 (0x99887766U, bytes + 5), 0x99887766U);
- leq (__aeabi_uwrite8 (0x9080706050403020LL, bytes + 15),
- 0x9080706050403020LL);
-#endif
-
- for (i = 0; i < 4; i++)
- ieq (bytes[5 + i], (6 + i) * 0x11);
-
- for (i = 0; i < 8; i++)
- ieq (bytes[15 + i], (2 + i) * 0x10);
-
- exit (0);
-}
+++ /dev/null
-/* { dg-do compile { target cris-*-* } } */
-/* { 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;
-}
+++ /dev/null
-/* { dg-do compile { target bfin-*-* } } */
-/* { dg-options "-O2" } */
-/* { dg-final { scan-assembler-not "call\[^\\n\]*foo" } } */
-/* { dg-final { scan-assembler-not "jump\[^\\n\]*foo" } } */
-/* { dg-final { scan-assembler "call\[^\\n\]*baz" } } */
-/* { dg-final { scan-assembler "jump\[^\\n\]*baz" } } */
-/* { dg-final { scan-assembler "call\[^\\n\]*bar" } } */
-/* { dg-final { scan-assembler "jump\[^\\n\]*bar" } } */
-
-extern void foo () __attribute__((longcall));
-extern void bar () __attribute__((shortcall));
-extern void baz ();
-
-int t1 ()
-{
- foo ();
- bar ();
- baz ();
- return 4;
-}
-
-void t2 ()
-{
- foo ();
-}
-void t3 ()
-{
- bar ();
-}
-void t4 ()
-{
- baz ();
-}
+++ /dev/null
-/* { dg-do compile { target bfin-*-* } } */
-/* { dg-options "-O2 -mlong-calls" } */
-/* { dg-final { scan-assembler-not "call\[^\\n\]*foo" } } */
-/* { dg-final { scan-assembler-not "jump\[^\\n\]*foo" } } */
-/* { dg-final { scan-assembler-not "call\[^\\n\]*baz" } } */
-/* { dg-final { scan-assembler-not "jump\[^\\n\]*baz" } } */
-/* { dg-final { scan-assembler "call\[^\\n\]*bar" } } */
-/* { dg-final { scan-assembler "jump\[^\\n\]*bar" } } */
-
-extern void foo () __attribute__((longcall));
-extern void bar () __attribute__((shortcall));
-extern void baz ();
-
-int t1 ()
-{
- foo ();
- bar ();
- baz ();
- return 4;
-}
-
-void t2 ()
-{
- foo ();
-}
-void t3 ()
-{
- bar ();
-}
-void t4 ()
-{
- baz ();
-}
+++ /dev/null
-/* { dg-do compile { target powerpc*-*-darwin* } } */
-/* { dg-options "-m64 -O1 -static" } */
-typedef unsigned long long uint64_t;
-
-static int
-match(name, pat)
- uint64_t *name, *pat;
-{
- int ok=0, negate_range;
- uint64_t c, k;
-
- c = *pat++;
- switch (c & 0xffffffffffULL) {
- case ((uint64_t)(('[')|0x8000000000ULL)):
- if ((negate_range = ((*pat & 0xffffffffffULL) == ((uint64_t)(('!')|0x8000000000ULL)) )) != '\0')
- ++pat;
- while (((c = *pat++) & 0xffffffffffULL) )
- if ((*pat & 0xffffffffffULL) == ((uint64_t)(('-')|0x8000000000ULL)))
- {
- pat += 2;
- }
-
- if (ok == negate_range)
- return(0);
- break;
- }
- return(*name == '\0');
-}
-
+++ /dev/null
-/* { dg-do compile { target cris-*-* } } */
-/* { 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;
-}
+++ /dev/null
-/* { dg-do compile { target cris-*-* } } */
-/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$r" } } */
-/* { dg-final { scan-assembler "and.w 2047,\\\$r" } } */
-/* { dg-final { scan-assembler-not "move.d \\\$r10,\\\$r" } } */
-/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$r" } } */
-/* { dg-final { scan-assembler "and.b 95,\\\$r" } } */
-/* { dg-final { scan-assembler "andq -2,\\\$r" } } */
-/* { dg-options "-O2" } */
-
-/* Test the "andu" peephole2 trivially, register operand. */
-
-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;
-}
+++ /dev/null
-/* { dg-do compile { target cris-*-* } } */
-/* { 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;
-}
+++ /dev/null
-/* { dg-do compile { target cris-*-* } } */
-/* { 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;
-}
+++ /dev/null
-/* { dg-do compile { target i?86-*-darwin* } } */
-/* { dg-final { scan-assembler "addsd" } } */
-/* Do not add -msse or -msse2 or -mfpmath=sse to the options. GCC is
- supposed to use SSE math on Darwin by default, and libm won't work
- right if it doesn't. */
-double foo(double x, double y)
-{
- return x + y;
-}
+++ /dev/null
-/* { dg-do compile { target m68k-*-* fido-*-* } } */
-/* { dg-options "-O2 -fpic" } */
-
-extern void Foo (void *);
-
-char *ary[] = {"a", "b", "c", "d", "e"};
-
-void Bar (void)
-{
- int cnt = 0;
-
- for (cnt = 0; cnt < 4; ++cnt)
- {
- char *ptr = ary[cnt];
-
- Foo (&ptr);
- }
-}
+++ /dev/null
-/* From PR 7872, test for optabs segfault when strict low part is present. */
-/* { dg-do compile { target m68k-*-* } } */
-/* { dg-options "-O0" } */
-extern void (**table)(void);
-
-typedef unsigned short uw16;
-typedef unsigned int gshort;
-
-register uw16 *pc asm("%a4");
-register gshort code asm("%d6");
-
-void QMExecuteLoop(uw16 *oldPC)
-{
- table[code=(*(uw16*)(pc++))]();
-}
+++ /dev/null
-/* { dg-do compile { target powerpc*-apple-darwin* } } */
-/* { dg-options "-S" } */
-
-typedef void PF (void);
-
-static void f(void) {
-}
-
-void f1(void) {
-}
-
-extern void f2(void) {
-}
-
-static void f3(void);
-
-void pe(void)
-{
-}
-
-PF* g (void) { f(); return f; }
-PF* x (void) { return f1; }
-PF* y (void) { f2(); return f2; }
-PF* z (void) { return f3; }
-PF* w (void) { pe(); return pe; }
-
-int main()
-{
- (*g())();
- (*x())();
- (*y())();
- (*z())();
- (*w())();
- return 0;
-}
-
-void f3(void) {
-}
-
-/* { dg-final { scan-assembler-not "non_lazy_ptr" } } */
+++ /dev/null
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O2 -fomit-frame-pointer" } */
-/* { dg-final { scan-assembler "mov fr4,fr.; mov fr5,fr." { target sh-*-* } } } */
-/* { dg-final { scan-assembler "mov fr4,fr.; mov fr5,fr." { target sh[1234lb]*-*-* } } } */
-/* { dg-final { scan-assembler "mov fr0,fr.; mov fr1,fr." { target sh[56]*-*-* } } } */
-double
-f (double d)
-{
- double r;
-
-#if defined (__SH_FPU_DOUBLE__)
- asm ("mov %S1,%S0; mov %R1,%R0" : "=f" (r) : "f" (d));
-#else
- asm ("mov fr4,fr4; mov fr5,fr5");
-#endif
- return r;
-}
+++ /dev/null
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-mb -O2 -fomit-frame-pointer" } */
-/* { dg-final { scan-assembler "mov @r.,r.; mov @\\(4,r.\\),r." } } */
-double d;
-
-double
-f (void)
-{
- double r;
-
-/* If -ml from the target options is passed after -mb from dg-options, we
- end up with th reverse endianness. */
-#if TARGET_SHMEDIA || defined (__LITTLE_ENDIAN__)
- asm ("mov @r1,r3; mov @(4,r1),r4");
-#else
- asm ("mov %S1,%S0; mov %R1,%R0" : "=&r" (r) : "m" (d));
-#endif
- return r;
-}
+++ /dev/null
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-ml -O2 -fomit-frame-pointer" } */
-/* { dg-final { scan-assembler "mov @\\(4,r.\\),r.; mov @r.,r." } } */
-double d;
-
-double
-f (void)
-{
- double r;
-
-/* If -mb from the target options is passed after -ml from dg-options, we
- end up with th reverse endianness. */
-#if TARGET_SHMEDIA || defined (__BIG_ENDIAN__)
- asm ("mov @(4,r1),r4; mov @r1,r3");
-#else
- asm ("mov %S1,%S0; mov %R1,%R0" : "=&r" (r) : "m" (d));
-#endif
- return r;
-}
+++ /dev/null
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O2 -fomit-frame-pointer" } */
-/* { dg-final { scan-assembler "mov #?0,r.*; mov #?20,r" } } */
-/* { dg-final { scan-assembler "mov #?1077149696,r.*; mov #?0,r" } } */
-double
-f ()
-{
- double r;
-
- asm ("mov %S1,%S0; mov %R1,%R0" : "=r" (r) : "i" (20));
- asm ("mov %S1,%S0; mov %R1,%R0" : "+r" (r) : "i" (20.));
- return r;
-}
+++ /dev/null
-/* { dg-do compile { target { sh*-*-* && nonpic } } } */
-/* { dg-options "-O2 -fomit-frame-pointer" } */
-
-double
-f ()
-{
- double r;
-
- asm ("mov %S1,%S0; mov %R1,%R0" : "=r" (r) : "i" (f));
-/* { dg-error "invalid operand to %S" "" {target "sh*-*-*" } 9 } */
-/* { dg-error "invalid operand to %R" "" {target "sh*-*-*" } 9 } */
- return r;
-}
+++ /dev/null
-/* { dg-do compile { target rs6000-*-* } } */
-/* { dg-options "-O2" } */
-/* { dg-final { scan-assembler-not "\tstwu 1,-\[0-9\]*(1)\n" } } */
-
-int Leaf (int i)
-{
- return i + 1;
-}
+++ /dev/null
-/* Check that -mrelax produces the correct error message. */
-/* { dg-do compile { target { sh-*-vxworks* && nonpic } } } */
-/* { dg-error "-mrelax is only supported for RTP PIC" "" { target *-*-* } 0 } */
-/* { dg-options "-O1 -mrelax" } */
-int x;
+++ /dev/null
-/* Check that -mrelax works. */
-/* { dg-do run { target { { sh-*-* sh?-*-* } && { ! { sh*-*-vxworks* && nonpic } } } } } */
-/* { dg-options "-O1 -mrelax" } */
-
-extern void abort (void);
-extern int qwerty (int);
-
-int
-f (int i)
-{
- return qwerty (i) + 1;
-}
-
-int
-qwerty (int i)
-{
- switch (i)
- {
- case 1:
- return 'q';
- case 2:
- return 'w';
- case 3:
- return 'e';
- case 4:
- return 'r';
- case 5:
- return 't';
- case 6:
- return 'y';
- }
-}
-
-int
-main ()
-{
- if (f (1) != 'q' + 1 || f (2) != 'w' + 1 || f (3) != 'e' + 1
- || f(4) != 'r' + 1 || f (5) != 't' + 1 || f (6) != 'y' + 1)
- abort ();
- return 0;
-}
+++ /dev/null
-/* Verify that we generate movua to load unaligned 32-bit values. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O" } */
-/* { dg-final { scan-assembler-times "\tmovua\\.l\t" 6 } } */
-
-#ifdef __SH4A__
-/* Aligned. */
-struct s0 { long long d : 32; } x0;
-long long f0() {
- return x0.d;
-}
-
-/* Unaligned load. */
-struct s1 { long long c : 8; long long d : 32; } x1;
-long long f1() {
- return x1.d;
-}
-
-/* Unaligned load. */
-struct s2 { long long c : 16; long long d : 32; } x2;
-long long f2() {
- return x2.d;
-}
-
-/* Unaligned load. */
-struct s3 { long long c : 24; long long d : 32; } x3;
-long long f3() {
- return x3.d;
-}
-
-/* Aligned. */
-struct s4 { long long c : 32; long long d : 32; } x4;
-long long f4() {
- return x4.d;
-}
-
-/* Aligned. */
-struct u0 { unsigned long long d : 32; } y0;
-unsigned long long g0() {
- return y0.d;
-}
-
-/* Unaligned load. */
-struct u1 { long long c : 8; unsigned long long d : 32; } y1;
-unsigned long long g1() {
- return y1.d;
-}
-
-/* Unaligned load. */
-struct u2 { long long c : 16; unsigned long long d : 32; } y2;
-unsigned long long g2() {
- return y2.d;
-}
-
-/* Unaligned load. */
-struct u3 { long long c : 24; unsigned long long d : 32; } y3;
-unsigned long long g3() {
- return y3.d;
-}
-
-/* Aligned. */
-struct u4 { long long c : 32; unsigned long long d : 32; } y4;
-unsigned long long g4() {
- return y4.d;
-}
-#else
-asm ("movua.l\t");
-asm ("movua.l\t");
-asm ("movua.l\t");
-asm ("movua.l\t");
-asm ("movua.l\t");
-asm ("movua.l\t");
-#endif
+++ /dev/null
-/* Verify that we generate single-precision sine and cosine approximate
- (fsca) in fast math mode. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler "\tfsca\t" } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-double test(double f) { return cos(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* Verify that we generate single-precision sine and cosine approximate
- (fsca) in fast math mode. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler "\tfsca\t" } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-float test(float f) { return cosf(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* Verify that fsca and fssra yield reasonable results. */
-/* This test calls the sinf and cosf library functions for targets other
- than sh4a, but the VxWorks kernel doesn't have those functions. */
-/* { dg-do run { target { "sh*-*-*" && { ! vxworks_kernel } } } } */
-/* { dg-options "-O -ffast-math" } */
-
-#include <math.h>
-#include <stdlib.h>
-
-float sqrt_arg = 4.0f, sqrt_res = 2.0f;
-float dg2rad_f;
-double dg2rad_d;
-
-void check_f (float res, float expected) {
- if (res >= expected - 0.001f && res <= expected + 0.001f)
- return;
-
- abort ();
-}
-
-void check_d (double res, double expected) {
- if (res >= expected - 0.001 && res <= expected + 0.001)
- return;
-
- abort ();
-}
-
-int main() {
- check_f (sqrtf(sqrt_arg), sqrt_res);
- dg2rad_f = dg2rad_d = atan(1) / 45;
- check_f (sinf(90*dg2rad_f), 1);
- check_f (cosf(90*dg2rad_f), 0);
- check_d (sin(-90*dg2rad_d), -1);
- check_d (cos(180*dg2rad_d), -1);
- check_d (sin(-45*dg2rad_d) * cosf(135*dg2rad_f), 0.5);
- exit (0);
-}
+++ /dev/null
-/* Verify that we generate single-precision square root reciprocal
- approximate (fsrra) in fast math mode. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler "\tfsrra\t" } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-float test(float f) { return 1 / sqrtf(f); }
-#else
-asm ("fsrra\t");
-#endif
+++ /dev/null
-/* Verify that we generate movua to copy unaligned memory regions to
- 32-bit-aligned addresses. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O" } */
-/* { dg-final { scan-assembler-times "\tmovua\\.l\t(.*)+" 2 } } */
-
-#ifdef __SH4A__
-#include <stdlib.h>
-
-struct s { int i; char a[10], b[10]; } x;
-int f() {
- memcpy(x.a, x.b, 10);
-}
-#else
-asm ("movua.l\t+");
-asm ("movua.l\t+");
-#endif
+++ /dev/null
-/* Verify that we generate single-precision sine and cosine approximate
- (fsca) in fast math mode. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler "\tfsca\t" } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-double test(double f) { return sin(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* Verify that we generate a single single-precision sine and cosine
- approximate (fsca) in fast math mode when a function computes both
- sine and cosine. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler-times "\tfsca\t" 1 } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-double test(double f) { return sin(f) + cos(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* Verify that we generate a single single-precision sine and cosine
- approximate (fsca) in fast math mode when a function computes both
- sine and cosine. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler-times "\tfsca\t" 1 } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-float test(float f) { return sinf(f) + cosf(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* Verify that we generate single-precision sine and cosine approximate
- (fsca) in fast math mode. */
-/* { dg-do compile { target "sh*-*-*" } } */
-/* { dg-options "-O -ffast-math" } */
-/* { dg-final { scan-assembler "\tfsca\t" } } */
-
-#if defined __SH4A__ && ! defined __SH4_NOFPU__
-#include <math.h>
-
-float test(float f) { return sinf(f); }
-#else
-asm ("fsca\t");
-#endif
+++ /dev/null
-/* { dg-do compile { target arm*-*-symbianelf* } } */
-/* Symbian OS requires that all defined symbols with external linkage
- have the ELF STV_HIDDEN attribute set by default. */
-/* { dg-final { scan-assembler ".hidden.*i" } } */
-/* { dg-final { scan-assembler ".hidden.*j" } } */
-/* { dg-final { scan-assembler ".hidden.*f" } } */
-
-int i;
-int j = 3;
-void f() {}
-
+++ /dev/null
-/* { dg-do compile { target arm*-*-symbianelf* } } */
-/* { dg-options "-O2" } */
-
-/* Symbian OS requires that builtins not be expanded by default. Make
- sure that a reference to "strlen" is emitted. */
-/* { dg-final { scan-assembler "strlen" } } */
-
-int f() {
- return strlen("abc");
-}
+++ /dev/null
-/* { dg-do compile { target arm*-*-symbianelf* } } */
-/* Check that enumeration types are 4-byte types. */
-
-enum e { e_1 };
-
-extern int i[sizeof (enum e)];
-int i[4];
+++ /dev/null
-/* { dg-do compile { target arm*-*-symbianelf* } } */
-/* Check that wchar_t is a 2-byte type. */
-
-extern int i[sizeof (L'a')];
-int i[2];
+++ /dev/null
-/* { dg-do compile { target arm*-*-symbianelf* } } */
-/* { dg-options "-fno-short-wchar" } */
-/* Check that wchar_t is a 4-byte type when -fno-short-wchar is
- used. */
-
-extern int i[sizeof (L'a')];
-int i[4];
-
+++ /dev/null
-/* Copyright (C) 2006 Free Software Foundation, Inc. */
-/* Contributed by Carlos O'Donell on 2006-01-30 */
-
-/* Test a division corner case where the expression simplifies
- to a comparison, and the optab expansion is wrong. The optab
- expansion emits a function whose return is unbiased and needs
- adjustment. */
-/* Origin: Carlos O'Donell <carlos@codesourcery.com> */
-/* { dg-do run { target arm-*-*eabi* } } */
-/* { dg-options "" } */
-#include <stdlib.h>
-
-#define BIG_CONSTANT 0xFFFFFFFF80000000ULL
-
-int main (void)
-{
- unsigned long long OneULL = 1ULL;
- unsigned long long result;
-
- result = OneULL / BIG_CONSTANT;
- if (result)
- abort ();
- exit (0);
-}
--- /dev/null
+/* ARM's load-and-call patterns used to allow automodified addresses.
+ This was wrong, because if the modified register were spilled,
+ the call would need an output reload. */
+/* { dg-do run { target arm*-*-* } } */
+/* { dg-options "-O2 -fno-omit-frame-pointer" } */
+extern void abort (void);
+typedef void (*callback) (void);
+
+static void
+foo (callback *first, callback *p)
+{
+ while (p > first)
+ {
+ (*--p) ();
+#ifndef __thumb__
+ asm ("" : "=r" (p) : "0" (p)
+ : "r4", "r5", "r6", "r7", "r8", "r9", "r10");
+#endif
+ }
+}
+
+static void
+dummy (void)
+{
+ static int count;
+ if (count++ == 1)
+ abort ();
+}
+
+int
+main (void)
+{
+ callback list[1] = { dummy };
+ foo (&list[0], &list[1]);
+ return 0;
+}
--- /dev/null
+/* { dg-do run { target arm*-*-symbianelf* arm*-*-eabi* } } */
+/* { dg-options "" } */
+
+/* This file tests most of the non-C++ run-time helper functions
+ described in Section 4 of the "Run-Time ABI for the ARM
+ Architecture". These are basic tests; they do not try to validate
+ all of the corner cases in these routines.
+
+ The functions not tested here are:
+
+ __aeabi_cdcmpeq
+ __aeabi_cdcmple
+ __aeabi_cdrcmple
+ __aeabi_cfcmpeq
+ __aeabi_cfcmple
+ __aeabi_cfrcmple
+ __aeabi_ldivmod
+ __aeabi_uldivmod
+ __aeabi_idivmod
+ __aeabi_uidivmod
+
+ These functions have non-standard calling conventions that would
+ require the use of inline assembly to test. It would be good to
+ add such tests, but they have not yet been implemented.
+
+ There are also no tests for the "division by zero", "memory copying,
+ clearing, and setting" functions. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define decl_float(code, type) \
+ extern type __aeabi_ ## code ## add (type, type); \
+ extern type __aeabi_ ## code ## div (type, type); \
+ extern type __aeabi_ ## code ## mul (type, type); \
+ extern type __aeabi_ ## code ## neg (type); \
+ extern type __aeabi_ ## code ## rsub (type, type); \
+ extern type __aeabi_ ## code ## sub (type, type); \
+ extern int __aeabi_ ## code ## cmpeq (type, type); \
+ extern int __aeabi_ ## code ## cmplt (type, type); \
+ extern int __aeabi_ ## code ## cmple (type, type); \
+ extern int __aeabi_ ## code ## cmpge (type, type); \
+ extern int __aeabi_ ## code ## cmpgt (type, type); \
+ extern int __aeabi_ ## code ## cmpun (type, type); \
+ extern int __aeabi_ ## code ## 2iz (type); \
+ extern unsigned int __aeabi_ ## code ## 2uiz (type); \
+ extern long long __aeabi_ ## code ## 2lz (type); \
+ extern unsigned long long __aeabi_ ## code ## 2ulz (type); \
+ extern type __aeabi_i2 ## code (int); \
+ extern type __aeabi_ui2 ## code (int); \
+ extern type __aeabi_l2 ## code (long long); \
+ extern type __aeabi_ul2 ## code (unsigned long long); \
+ \
+ type code ## zero = 0.0; \
+ type code ## one = 1.0; \
+ type code ## two = 2.0; \
+ type code ## four = 4.0; \
+ type code ## minus_one = -1.0; \
+ type code ## minus_two = -2.0; \
+ type code ## minus_four = -4.0; \
+ type code ## epsilon = 1E-32; \
+ type code ## NaN = 0.0 / 0.0;
+
+decl_float (d, double)
+decl_float (f, float)
+
+extern float __aeabi_d2f (double);
+extern double __aeabi_f2d (float);
+extern long long __aeabi_lmul (long long, long long);
+extern long long __aeabi_llsl (long long, int);
+extern long long __aeabi_llsr (long long, int);
+extern long long __aeabi_lasr (long long, int);
+extern int __aeabi_lcmp (long long, long long);
+extern int __aeabi_ulcmp (unsigned long long, unsigned long long);
+extern int __aeabi_idiv (int, int);
+extern unsigned int __aeabi_uidiv (unsigned int, unsigned int);
+extern int __eabi_uread4 (void *);
+extern int __eabi_uwrite4 (int, void *);
+extern long long __eabi_uread8 (void *);
+extern long long __eabi_uwrite8 (long long, void *);
+
+#define eq(a, b, type, abs, epsilon, format) \
+ { \
+ type a1; \
+ type b1; \
+ \
+ a1 = a; \
+ b1 = b; \
+ if (abs (a1 - b1) > epsilon) \
+ { \
+ fprintf (stderr, "%d: Test %s == %s\n", __LINE__, #a, #b); \
+ fprintf (stderr, "%d: " format " != " format "\n", \
+ __LINE__, a1, b1); \
+ abort (); \
+ } \
+ }
+
+#define ieq(a, b) eq (a, b, int, abs, 0, "%d")
+#define ueq(a, b) eq (a, b, unsigned int, abs, 0, "%u")
+#define leq(a, b) eq (a, b, long long, abs, 0, "%lld")
+#define uleq(a, b) eq (a, b, unsigned long long, abs, 0, "%llu")
+#define feq(a, b) eq (a, b, float, fabs, fepsilon, "%f")
+#define deq(a, b) eq (a, b, double, fabs, depsilon, "%g")
+
+#define NUM_CMP_VALUES 6
+
+/* Values picked to cover a range of small, large, positive and negative. */
+static unsigned int cmp_val[NUM_CMP_VALUES] =
+{
+ 0,
+ 1,
+ 0x40000000,
+ 0x80000000,
+ 0xc0000000,
+ 0xffffffff
+};
+
+/* All combinations for each of the above values. */
+#define ulcmp(l, s, m) \
+ s, l, l, l, l, l, m, s, l, l, l, l, \
+ m, m, s, l, l, l, m, m, m, s, l, l, \
+ m, m, m, m, s, l, m, m, m, m, m, s
+
+#define lcmp(l, s, m) \
+ s, l, l, m, m, m, m, s, l, m, m, m, \
+ m, m, s, m, m, m, l, l, l, s, l, l, \
+ l, l, l, m, s, l, l, l, l, m, m, s
+
+/* All combinations of the above for high/low words. */
+static int lcmp_results[] =
+{
+ lcmp(ulcmp(-1, -1, -1), ulcmp(-1, 0, 1), ulcmp(1, 1, 1))
+};
+
+static int ulcmp_results[] =
+{
+ ulcmp(ulcmp(-1, -1, -1), ulcmp(-1, 0, 1), ulcmp(1, 1, 1))
+};
+
+static int signof(int i)
+{
+ if (i < 0)
+ return -1;
+
+ if (i == 0)
+ return 0;
+
+ return 1;
+}
+
+int main () {
+ unsigned char bytes[256];
+ int i, j, k, n;
+ int *result;
+
+ /* Table 2. Double-precision floating-point arithmetic. */
+ deq (__aeabi_dadd (dzero, done), done);
+ deq (__aeabi_dadd (done, done), dtwo);
+ deq (__aeabi_ddiv (dminus_four, dminus_two), dtwo);
+ deq (__aeabi_ddiv (dminus_two, dtwo), dminus_one);
+ deq (__aeabi_dmul (dtwo, dtwo), dfour);
+ deq (__aeabi_dmul (dminus_one, dminus_two), dtwo);
+ deq (__aeabi_dneg (dminus_one), done);
+ deq (__aeabi_dneg (dfour), dminus_four);
+ deq (__aeabi_drsub (done, dzero), dminus_one);
+ deq (__aeabi_drsub (dtwo, dminus_two), dminus_four);
+ deq (__aeabi_dsub (dzero, done), dminus_one);
+ deq (__aeabi_dsub (dminus_two, dtwo), dminus_four);
+
+ /* Table 3. Double-precision floating-point comparisons. */
+ ieq (__aeabi_dcmpeq (done, done), 1);
+ ieq (__aeabi_dcmpeq (done, dzero), 0);
+ ieq (__aeabi_dcmpeq (dNaN, dzero), 0);
+ ieq (__aeabi_dcmpeq (dNaN, dNaN), 0);
+
+ ieq (__aeabi_dcmplt (dzero, done), 1);
+ ieq (__aeabi_dcmplt (done, dzero), 0);
+ ieq (__aeabi_dcmplt (dzero, dzero), 0);
+ ieq (__aeabi_dcmplt (dzero, dNaN), 0);
+ ieq (__aeabi_dcmplt (dNaN, dNaN), 0);
+
+ ieq (__aeabi_dcmple (dzero, done), 1);
+ ieq (__aeabi_dcmple (done, dzero), 0);
+ ieq (__aeabi_dcmple (dzero, dzero), 1);
+ ieq (__aeabi_dcmple (dzero, dNaN), 0);
+ ieq (__aeabi_dcmple (dNaN, dNaN), 0);
+
+ ieq (__aeabi_dcmpge (dzero, done), 0);
+ ieq (__aeabi_dcmpge (done, dzero), 1);
+ ieq (__aeabi_dcmpge (dzero, dzero), 1);
+ ieq (__aeabi_dcmpge (dzero, dNaN), 0);
+ ieq (__aeabi_dcmpge (dNaN, dNaN), 0);
+
+ ieq (__aeabi_dcmpgt (dzero, done), 0);
+ ieq (__aeabi_dcmpgt (done, dzero), 1);
+ ieq (__aeabi_dcmplt (dzero, dzero), 0);
+ ieq (__aeabi_dcmpgt (dzero, dNaN), 0);
+ ieq (__aeabi_dcmpgt (dNaN, dNaN), 0);
+
+ ieq (__aeabi_dcmpun (done, done), 0);
+ ieq (__aeabi_dcmpun (done, dzero), 0);
+ ieq (__aeabi_dcmpun (dNaN, dzero), 1);
+ ieq (__aeabi_dcmpun (dNaN, dNaN), 1);
+
+ /* Table 4. Single-precision floating-point arithmetic. */
+ feq (__aeabi_fadd (fzero, fone), fone);
+ feq (__aeabi_fadd (fone, fone), ftwo);
+ feq (__aeabi_fdiv (fminus_four, fminus_two), ftwo);
+ feq (__aeabi_fdiv (fminus_two, ftwo), fminus_one);
+ feq (__aeabi_fmul (ftwo, ftwo), ffour);
+ feq (__aeabi_fmul (fminus_one, fminus_two), ftwo);
+ feq (__aeabi_fneg (fminus_one), fone);
+ feq (__aeabi_fneg (ffour), fminus_four);
+ feq (__aeabi_frsub (fone, fzero), fminus_one);
+ feq (__aeabi_frsub (ftwo, fminus_two), fminus_four);
+ feq (__aeabi_fsub (fzero, fone), fminus_one);
+ feq (__aeabi_fsub (fminus_two, ftwo), fminus_four);
+
+ /* Table 5. Single-precision floating-point comparisons. */
+ ieq (__aeabi_fcmpeq (fone, fone), 1);
+ ieq (__aeabi_fcmpeq (fone, fzero), 0);
+ ieq (__aeabi_fcmpeq (fNaN, fzero), 0);
+ ieq (__aeabi_fcmpeq (fNaN, fNaN), 0);
+
+ ieq (__aeabi_fcmplt (fzero, fone), 1);
+ ieq (__aeabi_fcmplt (fone, fzero), 0);
+ ieq (__aeabi_fcmplt (fzero, fzero), 0);
+ ieq (__aeabi_fcmplt (fzero, fNaN), 0);
+ ieq (__aeabi_fcmplt (fNaN, fNaN), 0);
+
+ ieq (__aeabi_fcmple (fzero, fone), 1);
+ ieq (__aeabi_fcmple (fone, fzero), 0);
+ ieq (__aeabi_fcmple (fzero, fzero), 1);
+ ieq (__aeabi_fcmple (fzero, fNaN), 0);
+ ieq (__aeabi_fcmple (fNaN, fNaN), 0);
+
+ ieq (__aeabi_fcmpge (fzero, fone), 0);
+ ieq (__aeabi_fcmpge (fone, fzero), 1);
+ ieq (__aeabi_fcmpge (fzero, fzero), 1);
+ ieq (__aeabi_fcmpge (fzero, fNaN), 0);
+ ieq (__aeabi_fcmpge (fNaN, fNaN), 0);
+
+ ieq (__aeabi_fcmpgt (fzero, fone), 0);
+ ieq (__aeabi_fcmpgt (fone, fzero), 1);
+ ieq (__aeabi_fcmplt (fzero, fzero), 0);
+ ieq (__aeabi_fcmpgt (fzero, fNaN), 0);
+ ieq (__aeabi_fcmpgt (fNaN, fNaN), 0);
+
+ ieq (__aeabi_fcmpun (fone, fone), 0);
+ ieq (__aeabi_fcmpun (fone, fzero), 0);
+ ieq (__aeabi_fcmpun (fNaN, fzero), 1);
+ ieq (__aeabi_fcmpun (fNaN, fNaN), 1);
+
+ /* Table 6. Floating-point to integer conversions. */
+ ieq (__aeabi_d2iz (dminus_one), -1);
+ ueq (__aeabi_d2uiz (done), 1);
+ leq (__aeabi_d2lz (dminus_two), -2LL);
+ uleq (__aeabi_d2ulz (dfour), 4LL);
+ ieq (__aeabi_f2iz (fminus_one), -1);
+ ueq (__aeabi_f2uiz (fone), 1);
+ leq (__aeabi_f2lz (fminus_two), -2LL);
+ uleq (__aeabi_f2ulz (ffour), 4LL);
+
+ /* Table 7. Conversions between floating types. */
+ feq (__aeabi_d2f (dtwo), ftwo);
+ deq (__aeabi_f2d (fminus_four), dminus_four);
+
+ /* Table 8. Integer to floating-point conversions. */
+ deq (__aeabi_i2d (-1), dminus_one);
+ deq (__aeabi_ui2d (2), dtwo);
+ deq (__aeabi_l2d (-1), dminus_one);
+ deq (__aeabi_ul2d (2ULL), dtwo);
+ feq (__aeabi_i2f (-1), fminus_one);
+ feq (__aeabi_ui2f (2), ftwo);
+ feq (__aeabi_l2f (-1), fminus_one);
+ feq (__aeabi_ul2f (2ULL), ftwo);
+
+ /* Table 9. Long long functions. */
+ leq (__aeabi_lmul (4LL, -1LL), -4LL);
+ leq (__aeabi_llsl (2LL, 1), 4LL);
+ leq (__aeabi_llsr (-1LL, 63), 1);
+ leq (__aeabi_lasr (-1LL, 63), -1);
+
+ result = lcmp_results;
+ for (i = 0; i < NUM_CMP_VALUES; i++)
+ for (j = 0; j < NUM_CMP_VALUES; j++)
+ for (k = 0; k < NUM_CMP_VALUES; k++)
+ for (n = 0; n < NUM_CMP_VALUES; n++)
+ {
+ ieq (signof (__aeabi_lcmp
+ (((long long)cmp_val[i] << 32) | cmp_val[k],
+ ((long long)cmp_val[j] << 32) | cmp_val[n])),
+ *result);
+ result++;
+ }
+ result = ulcmp_results;
+ for (i = 0; i < NUM_CMP_VALUES; i++)
+ for (j = 0; j < NUM_CMP_VALUES; j++)
+ for (k = 0; k < NUM_CMP_VALUES; k++)
+ for (n = 0; n < NUM_CMP_VALUES; n++)
+ {
+ ieq (signof (__aeabi_ulcmp
+ (((long long)cmp_val[i] << 32) | cmp_val[k],
+ ((long long)cmp_val[j] << 32) | cmp_val[n])),
+ *result);
+ result++;
+ }
+
+ ieq (__aeabi_idiv (-550, 11), -50);
+ ueq (__aeabi_uidiv (4000000000U, 1000000U), 4000U);
+
+ for (i = 0; i < 256; i++)
+ bytes[i] = i;
+
+#ifdef __ARMEB__
+ ieq (__aeabi_uread4 (bytes + 1), 0x01020304U);
+ leq (__aeabi_uread8 (bytes + 3), 0x030405060708090aLL);
+ ieq (__aeabi_uwrite4 (0x66778899U, bytes + 5), 0x66778899U);
+ leq (__aeabi_uwrite8 (0x2030405060708090LL, bytes + 15),
+ 0x2030405060708090LL);
+#else
+ ieq (__aeabi_uread4 (bytes + 1), 0x04030201U);
+ leq (__aeabi_uread8 (bytes + 3), 0x0a09080706050403LL);
+ ieq (__aeabi_uwrite4 (0x99887766U, bytes + 5), 0x99887766U);
+ leq (__aeabi_uwrite8 (0x9080706050403020LL, bytes + 15),
+ 0x9080706050403020LL);
+#endif
+
+ for (i = 0; i < 4; i++)
+ ieq (bytes[5 + i], (6 + i) * 0x11);
+
+ for (i = 0; i < 8; i++)
+ ieq (bytes[15 + i], (2 + i) * 0x10);
+
+ exit (0);
+}
--- /dev/null
+/* { dg-do compile { target arm*-*-symbianelf* } } */
+/* Symbian OS requires that all defined symbols with external linkage
+ have the ELF STV_HIDDEN attribute set by default. */
+/* { dg-final { scan-assembler ".hidden.*i" } } */
+/* { dg-final { scan-assembler ".hidden.*j" } } */
+/* { dg-final { scan-assembler ".hidden.*f" } } */
+
+int i;
+int j = 3;
+void f() {}
+
--- /dev/null
+/* { dg-do compile { target arm*-*-symbianelf* } } */
+/* { dg-options "-O2" } */
+
+/* Symbian OS requires that builtins not be expanded by default. Make
+ sure that a reference to "strlen" is emitted. */
+/* { dg-final { scan-assembler "strlen" } } */
+
+int f() {
+ return strlen("abc");
+}
--- /dev/null
+/* { dg-do compile { target arm*-*-symbianelf* } } */
+/* Check that enumeration types are 4-byte types. */
+
+enum e { e_1 };
+
+extern int i[sizeof (enum e)];
+int i[4];
--- /dev/null
+/* { dg-do compile { target arm*-*-symbianelf* } } */
+/* Check that wchar_t is a 2-byte type. */
+
+extern int i[sizeof (L'a')];
+int i[2];
--- /dev/null
+/* { dg-do compile { target arm*-*-symbianelf* } } */
+/* { dg-options "-fno-short-wchar" } */
+/* Check that wchar_t is a 4-byte type when -fno-short-wchar is
+ used. */
+
+extern int i[sizeof (L'a')];
+int i[4];
+
--- /dev/null
+/* { dg-do compile { target bfin-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "call\[^\\n\]*foo" } } */
+/* { dg-final { scan-assembler-not "jump\[^\\n\]*foo" } } */
+/* { dg-final { scan-assembler "call\[^\\n\]*baz" } } */
+/* { dg-final { scan-assembler "jump\[^\\n\]*baz" } } */
+/* { dg-final { scan-assembler "call\[^\\n\]*bar" } } */
+/* { dg-final { scan-assembler "jump\[^\\n\]*bar" } } */
+
+extern void foo () __attribute__((longcall));
+extern void bar () __attribute__((shortcall));
+extern void baz ();
+
+int t1 ()
+{
+ foo ();
+ bar ();
+ baz ();
+ return 4;
+}
+
+void t2 ()
+{
+ foo ();
+}
+void t3 ()
+{
+ bar ();
+}
+void t4 ()
+{
+ baz ();
+}
--- /dev/null
+/* { dg-do compile { target bfin-*-* } } */
+/* { dg-options "-O2 -mlong-calls" } */
+/* { dg-final { scan-assembler-not "call\[^\\n\]*foo" } } */
+/* { dg-final { scan-assembler-not "jump\[^\\n\]*foo" } } */
+/* { dg-final { scan-assembler-not "call\[^\\n\]*baz" } } */
+/* { dg-final { scan-assembler-not "jump\[^\\n\]*baz" } } */
+/* { dg-final { scan-assembler "call\[^\\n\]*bar" } } */
+/* { dg-final { scan-assembler "jump\[^\\n\]*bar" } } */
+
+extern void foo () __attribute__((longcall));
+extern void bar () __attribute__((shortcall));
+extern void baz ();
+
+int t1 ()
+{
+ foo ();
+ bar ();
+ baz ();
+ return 4;
+}
+
+void t2 ()
+{
+ foo ();
+}
+void t3 ()
+{
+ bar ();
+}
+void t4 ()
+{
+ baz ();
+}
--- /dev/null
+/* 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 { target cris-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-message "reg:SI|const_double:DF" "prune debug_rtx output" { target cris-*-* } 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;# %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. */
+}
--- /dev/null
+/* { dg-do compile { target cris-*-* } } */
+/* { 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;
+}
--- /dev/null
+/* { dg-do compile { target cris-*-* } } */
+/* { 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;
+}
--- /dev/null
+/* { dg-do compile { target cris-*-* } } */
+/* { dg-final { scan-assembler "movu.w \\\$r10,\\\$r" } } */
+/* { dg-final { scan-assembler "and.w 2047,\\\$r" } } */
+/* { dg-final { scan-assembler-not "move.d \\\$r10,\\\$r" } } */
+/* { dg-final { scan-assembler "movu.b \\\$r10,\\\$r" } } */
+/* { dg-final { scan-assembler "and.b 95,\\\$r" } } */
+/* { dg-final { scan-assembler "andq -2,\\\$r" } } */
+/* { dg-options "-O2" } */
+
+/* Test the "andu" peephole2 trivially, register operand. */
+
+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;
+}
--- /dev/null
+/* { dg-do compile { target cris-*-* } } */
+/* { 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;
+}
--- /dev/null
+/* { dg-do compile { target cris-*-* } } */
+/* { 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;
+}
--- /dev/null
+/* { dg-do compile { target i?86-*-darwin* } } */
+/* { dg-final { scan-assembler "addsd" } } */
+/* Do not add -msse or -msse2 or -mfpmath=sse to the options. GCC is
+ supposed to use SSE math on Darwin by default, and libm won't work
+ right if it doesn't. */
+double foo(double x, double y)
+{
+ return x + y;
+}
--- /dev/null
+/* { dg-do compile { target m68k-*-* fido-*-* } } */
+/* { dg-options "-O2 -fpic" } */
+
+extern void Foo (void *);
+
+char *ary[] = {"a", "b", "c", "d", "e"};
+
+void Bar (void)
+{
+ int cnt = 0;
+
+ for (cnt = 0; cnt < 4; ++cnt)
+ {
+ char *ptr = ary[cnt];
+
+ Foo (&ptr);
+ }
+}
--- /dev/null
+/* From PR 7872, test for optabs segfault when strict low part is present. */
+/* { dg-do compile { target m68k-*-* } } */
+/* { dg-options "-O0" } */
+extern void (**table)(void);
+
+typedef unsigned short uw16;
+typedef unsigned int gshort;
+
+register uw16 *pc asm("%a4");
+register gshort code asm("%d6");
+
+void QMExecuteLoop(uw16 *oldPC)
+{
+ table[code=(*(uw16*)(pc++))]();
+}
--- /dev/null
+/* { dg-do compile { target mips64*-*-* mipsisa64*-*-* } } */
+/* { dg-options "-O2 -mlong64" } */
+int foo (int *x, int i)
+{
+ return x[i] + i;
+}
+/* { dg-final { scan-assembler-not "move" } } */
--- /dev/null
+/* { dg-do compile { target powerpc*-*-darwin* } } */
+/* { dg-options "-m64 -O1 -static" } */
+typedef unsigned long long uint64_t;
+
+static int
+match(name, pat)
+ uint64_t *name, *pat;
+{
+ int ok=0, negate_range;
+ uint64_t c, k;
+
+ c = *pat++;
+ switch (c & 0xffffffffffULL) {
+ case ((uint64_t)(('[')|0x8000000000ULL)):
+ if ((negate_range = ((*pat & 0xffffffffffULL) == ((uint64_t)(('!')|0x8000000000ULL)) )) != '\0')
+ ++pat;
+ while (((c = *pat++) & 0xffffffffffULL) )
+ if ((*pat & 0xffffffffffULL) == ((uint64_t)(('-')|0x8000000000ULL)))
+ {
+ pat += 2;
+ }
+
+ if (ok == negate_range)
+ return(0);
+ break;
+ }
+ return(*name == '\0');
+}
+
--- /dev/null
+/* { dg-do compile { target rs6000-*-* } } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "\tstwu 1,-\[0-9\]*(1)\n" } } */
+
+int Leaf (int i)
+{
+ return i + 1;
+}
--- /dev/null
+/* { dg-do compile { target powerpc*-apple-darwin* } } */
+/* { dg-options "-S" } */
+
+typedef void PF (void);
+
+static void f(void) {
+}
+
+void f1(void) {
+}
+
+extern void f2(void) {
+}
+
+static void f3(void);
+
+void pe(void)
+{
+}
+
+PF* g (void) { f(); return f; }
+PF* x (void) { return f1; }
+PF* y (void) { f2(); return f2; }
+PF* z (void) { return f3; }
+PF* w (void) { pe(); return pe; }
+
+int main()
+{
+ (*g())();
+ (*x())();
+ (*y())();
+ (*z())();
+ (*w())();
+ return 0;
+}
+
+void f3(void) {
+}
+
+/* { dg-final { scan-assembler-not "non_lazy_ptr" } } */
--- /dev/null
+/* Copyright (C) 2006 Free Software Foundation, Inc. */
+/* Contributed by Carlos O'Donell on 2006-01-30 */
+
+/* Test a division corner case where the expression simplifies
+ to a comparison, and the optab expansion is wrong. The optab
+ expansion emits a function whose return is unbiased and needs
+ adjustment. */
+/* Origin: Carlos O'Donell <carlos@codesourcery.com> */
+/* { dg-do run { target arm-*-*eabi* } } */
+/* { dg-options "" } */
+#include <stdlib.h>
+
+#define BIG_CONSTANT 0xFFFFFFFF80000000ULL
+
+int main (void)
+{
+ unsigned long long OneULL = 1ULL;
+ unsigned long long result;
+
+ result = OneULL / BIG_CONSTANT;
+ if (result)
+ abort ();
+ exit (0);
+}
--- /dev/null
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O2 -fomit-frame-pointer" } */
+/* { dg-final { scan-assembler "mov fr4,fr.; mov fr5,fr." { target sh-*-* } } } */
+/* { dg-final { scan-assembler "mov fr4,fr.; mov fr5,fr." { target sh[1234lb]*-*-* } } } */
+/* { dg-final { scan-assembler "mov fr0,fr.; mov fr1,fr." { target sh[56]*-*-* } } } */
+double
+f (double d)
+{
+ double r;
+
+#if defined (__SH_FPU_DOUBLE__)
+ asm ("mov %S1,%S0; mov %R1,%R0" : "=f" (r) : "f" (d));
+#else
+ asm ("mov fr4,fr4; mov fr5,fr5");
+#endif
+ return r;
+}
--- /dev/null
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-mb -O2 -fomit-frame-pointer" } */
+/* { dg-final { scan-assembler "mov @r.,r.; mov @\\(4,r.\\),r." } } */
+double d;
+
+double
+f (void)
+{
+ double r;
+
+/* If -ml from the target options is passed after -mb from dg-options, we
+ end up with th reverse endianness. */
+#if TARGET_SHMEDIA || defined (__LITTLE_ENDIAN__)
+ asm ("mov @r1,r3; mov @(4,r1),r4");
+#else
+ asm ("mov %S1,%S0; mov %R1,%R0" : "=&r" (r) : "m" (d));
+#endif
+ return r;
+}
--- /dev/null
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-ml -O2 -fomit-frame-pointer" } */
+/* { dg-final { scan-assembler "mov @\\(4,r.\\),r.; mov @r.,r." } } */
+double d;
+
+double
+f (void)
+{
+ double r;
+
+/* If -mb from the target options is passed after -ml from dg-options, we
+ end up with th reverse endianness. */
+#if TARGET_SHMEDIA || defined (__BIG_ENDIAN__)
+ asm ("mov @(4,r1),r4; mov @r1,r3");
+#else
+ asm ("mov %S1,%S0; mov %R1,%R0" : "=&r" (r) : "m" (d));
+#endif
+ return r;
+}
--- /dev/null
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O2 -fomit-frame-pointer" } */
+/* { dg-final { scan-assembler "mov #?0,r.*; mov #?20,r" } } */
+/* { dg-final { scan-assembler "mov #?1077149696,r.*; mov #?0,r" } } */
+double
+f ()
+{
+ double r;
+
+ asm ("mov %S1,%S0; mov %R1,%R0" : "=r" (r) : "i" (20));
+ asm ("mov %S1,%S0; mov %R1,%R0" : "+r" (r) : "i" (20.));
+ return r;
+}
--- /dev/null
+/* { dg-do compile { target { sh*-*-* && nonpic } } } */
+/* { dg-options "-O2 -fomit-frame-pointer" } */
+
+double
+f ()
+{
+ double r;
+
+ asm ("mov %S1,%S0; mov %R1,%R0" : "=r" (r) : "i" (f));
+/* { dg-error "invalid operand to %S" "" {target "sh*-*-*" } 9 } */
+/* { dg-error "invalid operand to %R" "" {target "sh*-*-*" } 9 } */
+ return r;
+}
--- /dev/null
+/* Check that -mrelax produces the correct error message. */
+/* { dg-do compile { target { sh-*-vxworks* && nonpic } } } */
+/* { dg-error "-mrelax is only supported for RTP PIC" "" { target *-*-* } 0 } */
+/* { dg-options "-O1 -mrelax" } */
+int x;
--- /dev/null
+/* Check that -mrelax works. */
+/* { dg-do run { target { { sh-*-* sh?-*-* } && { ! { sh*-*-vxworks* && nonpic } } } } } */
+/* { dg-options "-O1 -mrelax" } */
+
+extern void abort (void);
+extern int qwerty (int);
+
+int
+f (int i)
+{
+ return qwerty (i) + 1;
+}
+
+int
+qwerty (int i)
+{
+ switch (i)
+ {
+ case 1:
+ return 'q';
+ case 2:
+ return 'w';
+ case 3:
+ return 'e';
+ case 4:
+ return 'r';
+ case 5:
+ return 't';
+ case 6:
+ return 'y';
+ }
+}
+
+int
+main ()
+{
+ if (f (1) != 'q' + 1 || f (2) != 'w' + 1 || f (3) != 'e' + 1
+ || f(4) != 'r' + 1 || f (5) != 't' + 1 || f (6) != 'y' + 1)
+ abort ();
+ return 0;
+}
--- /dev/null
+# Copyright (C) 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/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a sh target.
+if ![istarget sh*-*-*] 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
--- /dev/null
+/* Verify that we generate movua to load unaligned 32-bit values. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler-times "\tmovua\\.l\t" 6 } } */
+
+#ifdef __SH4A__
+/* Aligned. */
+struct s0 { long long d : 32; } x0;
+long long f0() {
+ return x0.d;
+}
+
+/* Unaligned load. */
+struct s1 { long long c : 8; long long d : 32; } x1;
+long long f1() {
+ return x1.d;
+}
+
+/* Unaligned load. */
+struct s2 { long long c : 16; long long d : 32; } x2;
+long long f2() {
+ return x2.d;
+}
+
+/* Unaligned load. */
+struct s3 { long long c : 24; long long d : 32; } x3;
+long long f3() {
+ return x3.d;
+}
+
+/* Aligned. */
+struct s4 { long long c : 32; long long d : 32; } x4;
+long long f4() {
+ return x4.d;
+}
+
+/* Aligned. */
+struct u0 { unsigned long long d : 32; } y0;
+unsigned long long g0() {
+ return y0.d;
+}
+
+/* Unaligned load. */
+struct u1 { long long c : 8; unsigned long long d : 32; } y1;
+unsigned long long g1() {
+ return y1.d;
+}
+
+/* Unaligned load. */
+struct u2 { long long c : 16; unsigned long long d : 32; } y2;
+unsigned long long g2() {
+ return y2.d;
+}
+
+/* Unaligned load. */
+struct u3 { long long c : 24; unsigned long long d : 32; } y3;
+unsigned long long g3() {
+ return y3.d;
+}
+
+/* Aligned. */
+struct u4 { long long c : 32; unsigned long long d : 32; } y4;
+unsigned long long g4() {
+ return y4.d;
+}
+#else
+asm ("movua.l\t");
+asm ("movua.l\t");
+asm ("movua.l\t");
+asm ("movua.l\t");
+asm ("movua.l\t");
+asm ("movua.l\t");
+#endif
--- /dev/null
+/* Verify that we generate single-precision sine and cosine approximate
+ (fsca) in fast math mode. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler "\tfsca\t" } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+double test(double f) { return cos(f); }
+#else
+asm ("fsca\t");
+#endif
--- /dev/null
+/* Verify that we generate single-precision sine and cosine approximate
+ (fsca) in fast math mode. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler "\tfsca\t" } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+float test(float f) { return cosf(f); }
+#else
+asm ("fsca\t");
+#endif
--- /dev/null
+/* Verify that fsca and fssra yield reasonable results. */
+/* This test calls the sinf and cosf library functions for targets other
+ than sh4a, but the VxWorks kernel doesn't have those functions. */
+/* { dg-do run { target { "sh*-*-*" && { ! vxworks_kernel } } } } */
+/* { dg-options "-O -ffast-math" } */
+
+#include <math.h>
+#include <stdlib.h>
+
+float sqrt_arg = 4.0f, sqrt_res = 2.0f;
+float dg2rad_f;
+double dg2rad_d;
+
+void check_f (float res, float expected) {
+ if (res >= expected - 0.001f && res <= expected + 0.001f)
+ return;
+
+ abort ();
+}
+
+void check_d (double res, double expected) {
+ if (res >= expected - 0.001 && res <= expected + 0.001)
+ return;
+
+ abort ();
+}
+
+int main() {
+ check_f (sqrtf(sqrt_arg), sqrt_res);
+ dg2rad_f = dg2rad_d = atan(1) / 45;
+ check_f (sinf(90*dg2rad_f), 1);
+ check_f (cosf(90*dg2rad_f), 0);
+ check_d (sin(-90*dg2rad_d), -1);
+ check_d (cos(180*dg2rad_d), -1);
+ check_d (sin(-45*dg2rad_d) * cosf(135*dg2rad_f), 0.5);
+ exit (0);
+}
--- /dev/null
+/* Verify that we generate single-precision square root reciprocal
+ approximate (fsrra) in fast math mode. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler "\tfsrra\t" } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+float test(float f) { return 1 / sqrtf(f); }
+#else
+asm ("fsrra\t");
+#endif
--- /dev/null
+/* Verify that we generate movua to copy unaligned memory regions to
+ 32-bit-aligned addresses. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler-times "\tmovua\\.l\t(.*)+" 2 } } */
+
+#ifdef __SH4A__
+#include <stdlib.h>
+
+struct s { int i; char a[10], b[10]; } x;
+int f() {
+ memcpy(x.a, x.b, 10);
+}
+#else
+asm ("movua.l\t+");
+asm ("movua.l\t+");
+#endif
--- /dev/null
+/* Verify that we generate single-precision sine and cosine approximate
+ (fsca) in fast math mode. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler "\tfsca\t" } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+double test(double f) { return sin(f); }
+#else
+asm ("fsca\t");
+#endif
--- /dev/null
+/* Verify that we generate a single single-precision sine and cosine
+ approximate (fsca) in fast math mode when a function computes both
+ sine and cosine. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler-times "\tfsca\t" 1 } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+double test(double f) { return sin(f) + cos(f); }
+#else
+asm ("fsca\t");
+#endif
--- /dev/null
+/* Verify that we generate a single single-precision sine and cosine
+ approximate (fsca) in fast math mode when a function computes both
+ sine and cosine. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler-times "\tfsca\t" 1 } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+float test(float f) { return sinf(f) + cosf(f); }
+#else
+asm ("fsca\t");
+#endif
--- /dev/null
+/* Verify that we generate single-precision sine and cosine approximate
+ (fsca) in fast math mode. */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O -ffast-math" } */
+/* { dg-final { scan-assembler "\tfsca\t" } } */
+
+#if defined __SH4A__ && ! defined __SH4_NOFPU__
+#include <math.h>
+
+float test(float f) { return sinf(f); }
+#else
+asm ("fsca\t");
+#endif