gcc/
* doc/sourcebuild.texi: Document dg-add-options mips16_attribute.
gcc/testsuite/
* lib/target-supports.exp (add_options_for_mips16_attribute)
(check_effective_target_mips16_attribute): New functions.
* gcc.target/mips/mips.exp: Define MIPS16 and NOMIPS16 on the
command line.
(dg-mips-options) Remove -mno-mips16 handling. Add options to
extra_test_flags.
* gcc.target/mips/asm-1.c (NOMIPS16): Delete.
* gcc.target/mips/atomic-memory-1.c (NOMIPS16): Likewise.
* gcc.target/mips/atomic-memory-2.c (NOMIPS16): Likewise.
* gcc.target/mips/branch-1.c (NOMIPS16): Likewise.
* gcc.target/mips/dspr2-MULT.c (NOMIPS16): Likewise.
* gcc.target/mips/dspr2-MULTU.c (NOMIPS16): Likewise.
* gcc.target/mips/fpcmp-1.c (NOMIPS16): Likewise.
* gcc.target/mips/fpcmp-2.c (NOMIPS16): Likewise.
* gcc.target/mips/ins-1.c (NOMIPS16): Likewise.
* gcc.target/mips/madd-3.c (NOMIPS16): Likewise.
* gcc.target/mips/maddu-3.c (NOMIPS16): Likewise.
* gcc.target/mips/mips32-dsp-run.c (NOMIPS16): Likewise.
* gcc.target/mips/mips32-dspr2-type.c (NOMIPS16): Likewise.
* gcc.target/mips/msub-3.c (NOMIPS16): Likewise.
* gcc.target/mips/msubu-3.c (NOMIPS16): Likewise.
* gcc.target/mips/near-far-3.c (NOMIPS16): Likewise.
* gcc.target/mips/near-far-4.c (NOMIPS16): Likewise.
* gcc.target/mips/neg-abs-1.c (NOMIPS16): Likewise.
* gcc.target/mips/smartmips-lwxs.c (NOMIPS16): Likewise.
* gcc.target/mips/smartmips-ror-1.c (NOMIPS16): Likewise.
* gcc.target/mips/smartmips-ror-2.c (NOMIPS16): Likewise.
* gcc.target/mips/smartmips-ror-3.c (NOMIPS16): Likewise.
* gcc.target/mips/smartmips-ror-4.c (NOMIPS16): Likewise.
* gcc.target/mips/pr26765.c: Use dg-mips-options instead of dg-options.
(NOMIPS16): Delete.
* gcc.target/mips/
20020620-1.c: Use dg-mips-options instead
of dg-options.
* gcc.target/mips/call-saved-1.c: Remove -mips16 and -mno-abicalls
options. Require { target mips16_attribute } and use dg-add-options
to add the associated options.
(foo): Use MIPS16.
* gcc.target/mips/call-saved-2.c: As for call-saved-1.c.
* gcc.target/mips/call-saved-3.c: Likewise.
* gcc.target/mips/code-readable-1.c: Require { target
mips16_attribute } and use dg-add-options to add the associated
options. Remove trailing whitespace.
(NOMIPS16): Delete.
* gcc.target/mips/code-readable-2.c: Likewise.
* gcc.target/mips/code-readable-3.c: Likewise.
* gcc.target/mips/mips16-attributes-2.c: Likewise.
* gcc.target/mips/mips16e-extends.c: Remove -mips16 option.
Require { target mips16_attribute } and use dg-add-options to
add the associated options.
(cksum16, cksum8): Use MIPS16.
* gcc.target/mips/save-restore-1.c: Remove -mips16 option.
Require { target mips16_attribute } and use dg-add-options to
add the associated options.
(foo): Use MIPS16.
* gcc.target/mips/save-restore-2.c: Likewise.
* gcc.target/mips/save-restore-3.c: Likewise.
* gcc.target/mips/save-restore-4.c: Likewise.
* gcc.target/mips/save-restore-5.c: Likewise. Also remove
-mno-abicalls.
* gcc.target/mips/mips-sched-madd.c: Remove -mno-mips16.
(foo): Use NOMIPS16.
From-SVN: r128674
+2007-09-22 Richard Sandiford <rsandifo@nildram.co.uk>
+
+ * doc/sourcebuild.texi: Document dg-add-options mips16_attribute.
+
2007-09-22 Eric Botcazou <ebotcazou@adacore.com>
* tree-inline.c (remap_type_1): Correctly chain variants.
@table @code
@item c99_runtime
The target's C99 runtime (both headers and libraries).
+
+@item mips16_attribute
+@code{mips16} function attributes. Only MIPS targets support this feature,
+and only then in certain modes.
@end table
@item @{ dg-skip-if @var{comment} @{ @var{selector} @} @{ @var{include-opts} @} @{ @var{exclude-opts} @} @}
+2007-09-22 Richard Sandiford <rsandifo@nildram.co.uk>
+
+ * lib/target-supports.exp (add_options_for_mips16_attribute)
+ (check_effective_target_mips16_attribute): New functions.
+ * gcc.target/mips/mips.exp: Define MIPS16 and NOMIPS16 on the
+ command line.
+ (dg-mips-options) Remove -mno-mips16 handling. Add options to
+ extra_test_flags.
+ * gcc.target/mips/asm-1.c (NOMIPS16): Delete.
+ * gcc.target/mips/atomic-memory-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/atomic-memory-2.c (NOMIPS16): Likewise.
+ * gcc.target/mips/branch-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/dspr2-MULT.c (NOMIPS16): Likewise.
+ * gcc.target/mips/dspr2-MULTU.c (NOMIPS16): Likewise.
+ * gcc.target/mips/fpcmp-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/fpcmp-2.c (NOMIPS16): Likewise.
+ * gcc.target/mips/ins-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/madd-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/maddu-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/mips32-dsp-run.c (NOMIPS16): Likewise.
+ * gcc.target/mips/mips32-dspr2-type.c (NOMIPS16): Likewise.
+ * gcc.target/mips/msub-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/msubu-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/near-far-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/near-far-4.c (NOMIPS16): Likewise.
+ * gcc.target/mips/neg-abs-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/smartmips-lwxs.c (NOMIPS16): Likewise.
+ * gcc.target/mips/smartmips-ror-1.c (NOMIPS16): Likewise.
+ * gcc.target/mips/smartmips-ror-2.c (NOMIPS16): Likewise.
+ * gcc.target/mips/smartmips-ror-3.c (NOMIPS16): Likewise.
+ * gcc.target/mips/smartmips-ror-4.c (NOMIPS16): Likewise.
+ * gcc.target/mips/pr26765.c: Use dg-mips-options instead of dg-options.
+ (NOMIPS16): Delete.
+ * gcc.target/mips/20020620-1.c: Use dg-mips-options instead
+ of dg-options.
+ * gcc.target/mips/call-saved-1.c: Remove -mips16 and -mno-abicalls
+ options. Require { target mips16_attribute } and use dg-add-options
+ to add the associated options.
+ (foo): Use MIPS16.
+ * gcc.target/mips/call-saved-2.c: As for call-saved-1.c.
+ * gcc.target/mips/call-saved-3.c: Likewise.
+ * gcc.target/mips/code-readable-1.c: Require { target
+ mips16_attribute } and use dg-add-options to add the associated
+ options. Remove trailing whitespace.
+ (NOMIPS16): Delete.
+ * gcc.target/mips/code-readable-2.c: Likewise.
+ * gcc.target/mips/code-readable-3.c: Likewise.
+ * gcc.target/mips/mips16-attributes-2.c: Likewise.
+ * gcc.target/mips/mips16e-extends.c: Remove -mips16 option.
+ Require { target mips16_attribute } and use dg-add-options to
+ add the associated options.
+ (cksum16, cksum8): Use MIPS16.
+ * gcc.target/mips/save-restore-1.c: Remove -mips16 option.
+ Require { target mips16_attribute } and use dg-add-options to
+ add the associated options.
+ (foo): Use MIPS16.
+ * gcc.target/mips/save-restore-2.c: Likewise.
+ * gcc.target/mips/save-restore-3.c: Likewise.
+ * gcc.target/mips/save-restore-4.c: Likewise.
+ * gcc.target/mips/save-restore-5.c: Likewise. Also remove
+ -mno-abicalls.
+ * gcc.target/mips/mips-sched-madd.c: Remove -mno-mips16.
+ (foo): Use NOMIPS16.
+
2007-09-22 Paul Thomas <pault@gcc.gnu.org>
PR fortran/33337
/* { dg-do compile { target mips64*-*-* mipsisa64*-*-* } } */
-/* { dg-options "-O2 -mlong64" } */
+/* { dg-mips-options "-O2 -mlong64" } */
int foo (int *x, int i)
{
return x[i] + i;
/* { dg-do assemble } */
/* { dg-mips-options "-O" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int foo (int n)
{
register int k asm ("$16") = n;
extern void abort (void);
extern void exit (int);
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int main ()
{
#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
/* { dg-final { scan-assembler "addiu" } } */
/* { dg-final { scan-assembler-not "subu" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 unsigned long
f(unsigned long *p)
{
followed by a branch on zero. */
/* { dg-mips-options "-O2" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
void bar (void);
NOMIPS16 void f1 (int x) { if (x & 4) bar (); }
NOMIPS16 void f2 (int x) { if ((x >> 2) & 1) bar (); }
/* Check that we save all call-saved GPRs in a MIPS16 __builtin_eh_return
function. */
-/* { dg-mips-options "-mips2 -mips16 -mno-abicalls" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips2" } */
+/* { dg-add-options mips16_attribute } */
void bar (void);
-void
+
+MIPS16 void
foo (int x)
{
__builtin_unwind_init ();
/* Check that we save non-MIPS16 GPRs if they are explicitly clobbered. */
-/* { dg-mips-options "-mips2 -mips16 -mno-abicalls -O2" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips2 -O2" } */
+/* { dg-add-options mips16_attribute } */
-void
+MIPS16 void
foo (void)
{
asm volatile ("" ::: "$19", "$23", "$24", "$30");
/* Check that we save all call-saved GPRs in a MIPS16 __builtin_setjmp
function. */
-/* { dg-mips-options "-mips2 -mips16 -mno-abicalls -O2" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips2 -O2" } */
+/* { dg-add-options mips16_attribute } */
void bar (void);
extern int buf[];
-void
+
+MIPS16 void
foo (int x)
{
if (__builtin_setjmp (buf) == 0)
+/* { dg-do compile { target mips16_attribute } } */
/* { dg-mips-options "-mcode-readable=yes -mgp32" } */
+/* { dg-add-options mips16_attribute } */
-#define MIPS16 __attribute__ ((mips16))
-
-MIPS16 int
+MIPS16 int
foo (int i)
{
switch (i)
+/* { dg-do compile { target mips16_attribute } } */
/* { dg-mips-options "-mcode-readable=pcrel -mgp32" } */
-
-#define MIPS16 __attribute__ ((mips16))
+/* { dg-add-options mips16_attribute } */
MIPS16 int
foo (int i)
+/* { dg-do compile { target mips16_attribute } } */
/* { dg-mips-options "-mcode-readable=no -mgp32" } */
-
-#define MIPS16 __attribute__ ((mips16))
+/* { dg-add-options mips16_attribute } */
MIPS16 int
foo (int i)
/* { dg-final { scan-assembler "ac2" } } */
/* { dg-final { scan-assembler "ac3" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
typedef long long a64;
a64 a[4];
int b[4], c[4];
/* { dg-final { scan-assembler "ac2" } } */
/* { dg-final { scan-assembler "ac3" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
typedef long long a64;
a64 a[4];
unsigned int b[4], c[4];
/* We used to use c.lt.fmt instead of c.ule.fmt here. */
/* { dg-mips-options "-mhard-float -O2" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int f1 (float x, float y) { return __builtin_isless (x, y); }
NOMIPS16 int f2 (double x, double y) { return __builtin_isless (x, y); }
/* { dg-final { scan-assembler "c\\.ule\\.s" } } */
/* We used to use c.le.fmt instead of c.ult.fmt here. */
/* { dg-mips-options "-mhard-float -O2" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int f1 (float x, float y) { return __builtin_islessequal (x, y); }
NOMIPS16 int f2 (double x, double y) { return __builtin_islessequal (x, y); }
/* { dg-final { scan-assembler "c\\.ult\\.s" } } */
/* { dg-mips-options "-O -march=mips32r2" } */
/* { dg-final { scan-assembler "\tins\t" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
struct
{
unsigned int i : 2;
/* { dg-mips-options "-O2 -mips32 -mgp32" } */
/* { dg-final { scan-assembler-times "\tmadd\t" 3 } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 long long
f1 (int x, int y, long long z)
{
/* { dg-mips-options "-O2 -mips32 -mgp32" } */
/* { dg-final { scan-assembler-times "\tmaddu\t" 3 } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
typedef unsigned int ui;
typedef unsigned long long ull;
/* Test for case where another independent multiply insn may interfere
with a macc chain. */
/* { dg-do compile } */
-/* { dg-mips-options "-Os -march=24kf -mno-mips16" } */
+/* { dg-mips-options "-Os -march=24kf" } */
-int foo (int a, int b, int c, int d, int e, int f, int g)
+NOMIPS16 int foo (int a, int b, int c, int d, int e, int f, int g)
{
int temp;
int acc;
# if the other flags don't do so. Skip the test if the multilib
# flags force a 32-bit ABI or a 32-bit architecture.
#
-# -mno-mips16
-# Skip the test for MIPS16 targets.
-#
# -march=*
# -mips*
# Select the target architecture. Skip the test for MIPS16 targets
}
# Handle the other options.
foreach flag $flags {
- if {$flag == "-mno-mips16"} {
- if {$mips_mips16} {
- set matches 0
- }
- } elseif {$flag == "-mfp64"} {
+ if {$flag == "-mfp64"} {
if {$mips_isa < 33 || $mips_float != "hard"} {
set matches 0
}
}
}
if {$matches} {
- set extra_tool_flags $flags
+ append extra_tool_flags " " $flags
} else {
set do_what [list [lindex $do_what 0] "N" "P"]
}
setup_mips_tests
dg-init
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" ""
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" \
+ "-DMIPS16=__attribute__((mips16)) -DNOMIPS16=__attribute__((nomips16))"
dg-finish
+/* { dg-do compile { target mips16_attribute } } */
/* { dg-skip-if "" { *-*-* } { "-mflip-mips16" } { "" } } */
+/* { dg-add-options mips16_attribute } */
void f1 (void);
void __attribute__((mips16)) f1 (void) {} /* { dg-error "conflicting" } */
-/* { dg-do compile } */
-/* { dg-mips-options "-Os -march=mips32 -mips16" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-Os -march=mips32" } */
+/* { dg-add-options mips16_attribute } */
-short cksum16 (unsigned long n)
+MIPS16 short cksum16 (unsigned long n)
{
unsigned long l;
l = validate (n, (n >> 16) + (n & 0xffff));
return l;
}
-signed char cksum8 (unsigned long n)
+MIPS16 signed char cksum8 (unsigned long n)
{
unsigned long l;
l = validate (n, (n >> 8) + (n & 0xff));
/* { dg-do run { target mipsisa32r2*-*-* } } */
/* { dg-mips-options "-march=mips32r2 -mdsp -O2" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
#include <stdlib.h>
#include <stdio.h>
/* { dg-mips-options "-march=mips32r2 -mdspr2" } */
/* { dg-final { scan-assembler "\tmul.ph\t" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
typedef short v2hi __attribute__ ((vector_size(4)));
NOMIPS16 v2hi mul_v2hi (v2hi a, v2hi b)
/* { dg-mips-options "-O2 -mips32 -mgp32" } */
/* { dg-final { scan-assembler-times "\tmsub\t" 2 } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 long long
f1 (int x, int y, long long z)
{
/* { dg-mips-options "-O2 -mips32 -mgp32" } */
/* { dg-final { scan-assembler-times "\tmsubu\t" 2 } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
typedef unsigned int ui;
typedef unsigned long long ull;
/* { dg-mips-options "-mlong-calls -O2" } */
/* { dg-require-effective-target nonpic } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 extern int long_call_func () __attribute__((long_call));
NOMIPS16 extern int far_func () __attribute__((far));
NOMIPS16 extern int near_func () __attribute__((near));
/* { dg-mips-options "-mno-long-calls -O2" } */
/* { dg-require-effective-target nonpic } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 extern int long_call_func () __attribute__((long_call));
NOMIPS16 extern int far_func () __attribute__((far));
NOMIPS16 extern int near_func () __attribute__((near));
/* { dg-final { scan-assembler "abs.s" } } */
/* { dg-final { scan-assembler "abs.d" } } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 float f1 (float f) { return -f; }
NOMIPS16 float f2 (float f) { return __builtin_fabsf (f); }
NOMIPS16 double d1 (double d) { return -d; }
This testcase used to trigger an unrecognizable insn. */
/* { dg-do compile } */
-/* { dg-options "-O2 -w" } */
+/* { dg-mips-options "-O2 -w" } */
__thread int *a = 0;
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 void foo (void)
{
extern int *b;
/* Check that we can use the save instruction to save varargs. */
-/* { dg-mips-options "-mips32r2 -mgp32 -mips16 -O2" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-add-options mips16_attribute } */
+
#include <stdarg.h>
int bar (int, va_list ap);
-int
+MIPS16 int
foo (int n, ...)
{
va_list ap;
/* Check that we can use the save instruction to save spilled arguments. */
-/* { dg-mips-options "-mips32r2 -mgp32 -mips16 -O2" } */
-void
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-add-options mips16_attribute } */
+
+MIPS16 void
foo (int *a, int b, int c)
{
asm volatile ("" ::: "$2", "$3", "$4", "$5", "$6", "$7", "$8",
/* Check that we can use the save instruction to save spilled arguments
when the argument save area is out of range of a direct load or store. */
-/* { dg-mips-options "-mips32r2 -mgp32 -mips16 -O2" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-add-options mips16_attribute } */
+
void bar (int *);
-void
+MIPS16 void
foo (int *a, int b, int c)
{
int x[0x4000];
/* Check that we can use the save instruction to save $16, $17 and $31. */
-/* { dg-mips-options "-mips32r2 -mgp32 -mips16 -O2" } */
+/* { dg-do compile { target mips16_attribute } } */
+/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-add-options mips16_attribute } */
+
void bar (void);
-void
+
+MIPS16 void
foo (void)
{
bar ();
/* Check that we don't try to save the same register twice. */
-/* { dg-do assemble } */
-/* { dg-mips-options "-mips32r2 -mgp32 -mips16 -mno-abicalls -O2" } */
+/* { dg-do assemble { target mips16_attribute } } */
+/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-add-options mips16_attribute } */
int bar (int, int, int, int);
void frob (void);
-void
+MIPS16 void
foo (int a1, int a2, int a3, int a4)
{
asm volatile ("" ::: "$2", "$3", "$4", "$5", "$6", "$7", "$8",
/* { dg-do compile } */
/* { dg-mips-options "-O -msmartmips" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int scaled_indexed_word_load (int a[], int b)
{
return a[b];
/* { dg-do compile } */
/* { dg-mips-options "-O -msmartmips" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int rotate_left (unsigned a, unsigned s)
{
return (a << s) | (a >> (32 - s));
/* { dg-do compile } */
/* { dg-mips-options "-O -msmartmips" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
NOMIPS16 int rotate_right (unsigned a, unsigned s)
{
return (a >> s) | (a << (32 - s));
/* { dg-do compile } */
/* { dg-mips-options "-O -msmartmips" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
#define S 13
NOMIPS16 int rotate_left_constant (unsigned a)
/* { dg-do compile } */
/* { dg-mips-options "-O -msmartmips" } */
-#define NOMIPS16 __attribute__ ((nomips16))
-
#define S 13
NOMIPS16 int rotate_right_constant (unsigned a)
}]
}
+# Add the options needed for MIPS16 function attributes. At the moment,
+# we don't support MIPS16 PIC.
+
+proc add_options_for_mips16_attribute { flags } {
+ return "$flags -mno-abicalls -fno-pic"
+}
+
+# Return true if we can force a mode that allows MIPS16 code generation.
+
+proc check_effective_target_mips16_attribute { } {
+ return [check_no_compiler_messages mips16_attribute assembly {
+ #if __PIC__
+ #error FOO
+ #endif
+ } [add_options_for_mips16_attribute ""]]
+}
+
# Return 1 if the current multilib does not generate PIC by default.
proc check_effective_target_nonpic { } {