aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard@codesourcery.com>2007-09-10 15:21:18 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2007-09-10 15:21:18 +0000
commit04910611bd80c3cf5b96405c58942b6f80f96fc3 (patch)
tree84b52cb4914fe1d57662b286e0ad66d3b56a337f /gcc
parent7d8bed7be6a13f1c25743a1bc45361d9f4f3a662 (diff)
downloadgcc-04910611bd80c3cf5b96405c58942b6f80f96fc3.zip
gcc-04910611bd80c3cf5b96405c58942b6f80f96fc3.tar.gz
gcc-04910611bd80c3cf5b96405c58942b6f80f96fc3.tar.bz2
mips.c (mips_global_pointer): Check call_really_used_regs instead of call_used_regs.
gcc/ * config/mips/mips.c (mips_global_pointer): Check call_really_used_regs instead of call_used_regs. (mips_save_reg_p): Likewise. Save all call-saved registers if current_function_saves_all_registers. Fix indentation. No longer treat $18 as a special case. (compute_frame_size): Guard FPR loop with TARGET_HARD_FLOAT. gcc/testsuite/ * gcc.target/mips/call-saved-1.c: New test. * gcc.target/mips/call-saved-2.c: Likewise. * gcc.target/mips/call-saved-3.c: Likewise. * gcc.target/mips/mips.exp (setup_mips_tests): Set mips_gp64 instead of mips_mips64. Set mips_fp64 too. (is_gp32_flag): Return true for -mips1 and -mips2. (dg-mips-options): Use mips_gp64 instead of mips_mips64. From-SVN: r128347
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/config/mips/mips.c55
-rw-r--r--gcc/testsuite/ChangeLog10
-rw-r--r--gcc/testsuite/gcc.target/mips/call-saved-1.c20
-rw-r--r--gcc/testsuite/gcc.target/mips/call-saved-2.c18
-rw-r--r--gcc/testsuite/gcc.target/mips/call-saved-3.c21
-rw-r--r--gcc/testsuite/gcc.target/mips/mips.exp24
7 files changed, 117 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4a5dc46..b5a55a3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,14 @@
2007-09-10 Richard Sandiford <richard@codesourcery.com>
+ * config/mips/mips.c (mips_global_pointer): Check
+ call_really_used_regs instead of call_used_regs.
+ (mips_save_reg_p): Likewise. Save all call-saved registers
+ if current_function_saves_all_registers. Fix indentation.
+ No longer treat $18 as a special case.
+ (compute_frame_size): Guard FPR loop with TARGET_HARD_FLOAT.
+
+2007-09-10 Richard Sandiford <richard@codesourcery.com>
+
* config/mips/mips.h (MIPS_ARCH_FLOAT_SPEC): New macro.
* config/mips/mips.c (mips_cpu_info_table): Mention it in the
the introductory comment.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 5ff9073..4a180da 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -6852,7 +6852,7 @@ mips_global_pointer (void)
if (TARGET_CALL_SAVED_GP && current_function_is_leaf)
for (regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++)
if (!df_regs_ever_live_p (regno)
- && call_used_regs[regno]
+ && call_really_used_regs[regno]
&& !fixed_regs[regno]
&& regno != PIC_FUNCTION_ADDR_REGNUM)
return regno;
@@ -6918,43 +6918,33 @@ mips_save_reg_p (unsigned int regno)
return TARGET_CALL_SAVED_GP && cfun->machine->global_pointer == regno;
/* Check call-saved registers. */
- if (df_regs_ever_live_p (regno) && !call_used_regs[regno])
+ if ((current_function_saves_all_registers || df_regs_ever_live_p (regno))
+ && !call_really_used_regs[regno])
return true;
- /* Save both registers in an FPR pair if either one is used. This is
- needed for the case when MIN_FPRS_PER_FMT == 1, which allows the odd
- register to be used without the even register. */
- if (FP_REG_P (regno)
- && MAX_FPRS_PER_FMT == 2
- && df_regs_ever_live_p (regno + 1)
- && !call_used_regs[regno + 1])
- return true;
+ /* Save both registers in an FPR pair if either one is used. This is
+ needed for the case when MIN_FPRS_PER_FMT == 1, which allows the odd
+ register to be used without the even register. */
+ if (FP_REG_P (regno)
+ && MAX_FPRS_PER_FMT == 2
+ && df_regs_ever_live_p (regno + 1)
+ && !call_really_used_regs[regno + 1])
+ return true;
/* We need to save the old frame pointer before setting up a new one. */
if (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed)
return true;
/* We need to save the incoming return address if it is ever clobbered
- within the function. */
- if (regno == GP_REG_FIRST + 31 && df_regs_ever_live_p (regno))
+ within the function, if __builtin_eh_return is being used to set a
+ different return address, or if a stub is being used to return a
+ value in FPRs. */
+ if (regno == GP_REG_FIRST + 31
+ && (df_regs_ever_live_p (regno)
+ || current_function_calls_eh_return
+ || mips16_cfun_returns_in_fpr_p ()))
return true;
- if (TARGET_MIPS16)
- {
- /* $18 is a special case in mips16 code. It may be used to call
- a function which returns a floating point value, but it is
- marked in call_used_regs. */
- if (regno == GP_REG_FIRST + 18 && df_regs_ever_live_p (regno))
- return true;
-
- /* $31 is also a special case. It will be used to copy a return
- value into the floating point registers if the return value is
- floating point. */
- if (regno == GP_REG_FIRST + 31
- && mips16_cfun_returns_in_fpr_p ())
- return true;
- }
-
return false;
}
@@ -7124,16 +7114,15 @@ compute_frame_size (HOST_WIDE_INT size)
/* This loop must iterate over the same space as its companion in
mips_for_each_saved_reg. */
- for (regno = (FP_REG_LAST - MAX_FPRS_PER_FMT + 1);
- regno >= FP_REG_FIRST;
- regno -= MAX_FPRS_PER_FMT)
- {
+ if (TARGET_HARD_FLOAT)
+ for (regno = (FP_REG_LAST - MAX_FPRS_PER_FMT + 1);
+ regno >= FP_REG_FIRST;
+ regno -= MAX_FPRS_PER_FMT)
if (mips_save_reg_p (regno))
{
fp_reg_size += MAX_FPRS_PER_FMT * UNITS_PER_FPREG;
fmask |= ((1 << MAX_FPRS_PER_FMT) - 1) << (regno - FP_REG_FIRST);
}
- }
gp_reg_rounded = MIPS_STACK_ALIGN (gp_reg_size);
total_size += gp_reg_rounded + MIPS_STACK_ALIGN (fp_reg_size);
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a5693ac..792984e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2007-09-10 Richard Sandiford <richard@codesourcery.com>
+
+ * gcc.target/mips/call-saved-1.c: New test.
+ * gcc.target/mips/call-saved-2.c: Likewise.
+ * gcc.target/mips/call-saved-3.c: Likewise.
+ * gcc.target/mips/mips.exp (setup_mips_tests): Set mips_gp64
+ instead of mips_mips64. Set mips_fp64 too.
+ (is_gp32_flag): Return true for -mips1 and -mips2.
+ (dg-mips-options): Use mips_gp64 instead of mips_mips64.
+
2007-09-10 Jakub Jelinek <jakub@redhat.com>
* g++.dg/ext/va-arg-pack-1.C: New test.
diff --git a/gcc/testsuite/gcc.target/mips/call-saved-1.c b/gcc/testsuite/gcc.target/mips/call-saved-1.c
new file mode 100644
index 0000000..957b0c5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-saved-1.c
@@ -0,0 +1,20 @@
+/* Check that we save all call-saved GPRs in a MIPS16 __builtin_eh_return
+ function. */
+/* { dg-mips-options "-mips2 -mips16 -mno-abicalls" } */
+
+void bar (void);
+void
+foo (int x)
+{
+ __builtin_unwind_init ();
+ __builtin_eh_return (x, bar);
+}
+/* { dg-final { scan-assembler "\\\$16" } } */
+/* { dg-final { scan-assembler "\\\$17" } } */
+/* { dg-final { scan-assembler "\\\$18" } } */
+/* { dg-final { scan-assembler "\\\$19" } } */
+/* { dg-final { scan-assembler "\\\$20" } } */
+/* { dg-final { scan-assembler "\\\$21" } } */
+/* { dg-final { scan-assembler "\\\$22" } } */
+/* { dg-final { scan-assembler "\\\$23" } } */
+/* { dg-final { scan-assembler "\\\$(30|fp)" } } */
diff --git a/gcc/testsuite/gcc.target/mips/call-saved-2.c b/gcc/testsuite/gcc.target/mips/call-saved-2.c
new file mode 100644
index 0000000..8928896
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-saved-2.c
@@ -0,0 +1,18 @@
+/* Check that we save non-MIPS16 GPRs if they are explicitly clobbered. */
+/* { dg-mips-options "-mips2 -mips16 -mno-abicalls -O2" } */
+
+void
+foo (void)
+{
+ asm volatile ("" ::: "$19", "$23", "$24", "$30");
+}
+/* { dg-final { scan-assembler-not "\\\$16" } } */
+/* { dg-final { scan-assembler-not "\\\$17" } } */
+/* { dg-final { scan-assembler-not "\\\$18" } } */
+/* { dg-final { scan-assembler "\\\$19" } } */
+/* { dg-final { scan-assembler-not "\\\$20" } } */
+/* { dg-final { scan-assembler-not "\\\$21" } } */
+/* { dg-final { scan-assembler-not "\\\$22" } } */
+/* { dg-final { scan-assembler "\\\$23" } } */
+/* { dg-final { scan-assembler-not "\\\$24" } } */
+/* { dg-final { scan-assembler "\\\$(30|fp)" } } */
diff --git a/gcc/testsuite/gcc.target/mips/call-saved-3.c b/gcc/testsuite/gcc.target/mips/call-saved-3.c
new file mode 100644
index 0000000..f1d9379
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/call-saved-3.c
@@ -0,0 +1,21 @@
+/* Check that we save all call-saved GPRs in a MIPS16 __builtin_setjmp
+ function. */
+/* { dg-mips-options "-mips2 -mips16 -mno-abicalls -O2" } */
+
+void bar (void);
+extern int buf[];
+void
+foo (int x)
+{
+ if (__builtin_setjmp (buf) == 0)
+ bar();
+}
+/* { dg-final { scan-assembler "\\\$16" } } */
+/* { dg-final { scan-assembler "\\\$17" } } */
+/* { dg-final { scan-assembler "\\\$18" } } */
+/* { dg-final { scan-assembler "\\\$19" } } */
+/* { dg-final { scan-assembler "\\\$20" } } */
+/* { dg-final { scan-assembler "\\\$21" } } */
+/* { dg-final { scan-assembler "\\\$22" } } */
+/* { dg-final { scan-assembler "\\\$23" } } */
+/* { dg-final { scan-assembler "\\\$(30|fp)" } } */
diff --git a/gcc/testsuite/gcc.target/mips/mips.exp b/gcc/testsuite/gcc.target/mips/mips.exp
index fef5097..c88edc0 100644
--- a/gcc/testsuite/gcc.target/mips/mips.exp
+++ b/gcc/testsuite/gcc.target/mips/mips.exp
@@ -31,7 +31,8 @@ load_lib gcc-dg.exp
# $mips_isa: the ISA level specified by __mips
# $mips_arch: the architecture specified by _MIPS_ARCH
# $mips_mips16: true if MIPS16 mode is selected
-# $mips_mips64: true if 64-bit output is selected
+# $mips_gp64: true if 64-bit output is selected
+# $mips_fp64: true if 64-bit FPRs are selected
# $mips_float: "hard" or "soft"
#
# $mips_forced_isa: true if the command line uses -march=* or -mips*
@@ -44,7 +45,8 @@ proc setup_mips_tests {} {
global mips_isa
global mips_arch
global mips_mips16
- global mips_mips64
+ global mips_gp64
+ global mips_fp64
global mips_float
global mips_forced_isa
@@ -66,7 +68,10 @@ proc setup_mips_tests {} {
int mips16 = 1;
#endif
#ifdef __mips64
- int mips64 = 1;
+ int gp64 = 1;
+ #endif
+ #if __mips_fpr==64
+ int fp64 = 1;
#endif
#ifdef __mips_hard_float
const char *float = "hard";
@@ -81,7 +86,8 @@ proc setup_mips_tests {} {
regexp {isa = ([^;]*)} $output dummy mips_isa
regexp {arch = "([^"]*)} $output dummy mips_arch
set mips_mips16 [regexp {mips16 = 1} $output]
- set mips_mips64 [regexp {mips64 = 1} $output]
+ set mips_gp64 [regexp {gp64 = 1} $output]
+ set mips_fp64 [regexp {fp64 = 1} $output]
regexp {float = "([^"]*)} $output dummy mips_float
set mips_forced_isa [regexp -- {(-mips|-march)} $compiler_flags]
@@ -96,6 +102,7 @@ proc setup_mips_tests {} {
proc is_gp32_flag {flag} {
switch -glob -- $flag {
-msmartmips -
+ -mips[12] -
-march=mips32* -
-mgp32 { return 1 }
default { return 0 }
@@ -149,7 +156,8 @@ proc dg-mips-options {args} {
global mips_isa
global mips_arch
global mips_mips16
- global mips_mips64
+ global mips_gp64
+ global mips_fp64
global mips_float
global mips_forced_isa
@@ -164,13 +172,15 @@ proc dg-mips-options {args} {
# First handle the -mgp* options. Add an architecture option if necessary.
foreach flag $flags {
- if {[is_gp32_flag $flag] && $mips_mips64} {
+ if {[is_gp32_flag $flag]
+ && ($mips_gp64
+ || ($mips_fp64 && [lsearch $flags -mfp64] < 0)) } {
if {$mips_forced_abi} {
set matches 0
} else {
append flags " -mabi=32"
}
- } elseif {$flag == "-mgp64" && !$mips_mips64} {
+ } elseif {$flag == "-mgp64" && !$mips_gp64} {
if {$mips_forced_abi} {
set matches 0
} else {