This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Require -mabi=32 for gcc.target/mips/save-restore-[1-4].c


gcc.target/mips/save-restore-[1-4].c specify -mgp32, but they really
need -mabi=32 rather than EABI32.  (The save and restore instructions
are tailed specifically towards o32.)  The patch below fixes this and
adds -mabi=* support to dg-mips-options.

Having dg-mips-options support -mabi=* removes the need for the -mips3
option in pr33256.c, so the patch removes that too.  Not forcing an
architecture means we can run the test for more test flags, giving
greater coverage.

Tested on mipsisa32-elf and mipsisa64-elfoabi.  Applied.

Richard


gcc/testsuite/
	* gcc.target/mips/mips.exp (setup_mips_tests): Set mips_abi to the
	default ABI.  Split mips_forced_abi into mips_forced_abi and
	mips_forced_regs.
	(is_gp32_flag): Return true for -mabi=32.
	(is_gp64_flag): New function.  Handle 64-bit -mabi options.
	(dg-mips-options): Use is_gp64_flag instead of checking specifically
	for -mgp64.  Update after the mips_forced_abi split.  Handle -mabi=*.
	Don't force an ABI for -mgp32 or -mfp32 if the flags contain -mabi=*.
	* gcc.target/mips/pr33256.c: Remove -mips3 requirement.
	* gcc.target/mips/save-restore-1.c: Use -mabi=32 instead of -mgp32.
	* gcc.target/mips/save-restore-2.c: Likewise.
	* gcc.target/mips/save-restore-3.c: Likewise.
	* gcc.target/mips/save-restore-4.c: Likewise.

Index: gcc/testsuite/gcc.target/mips/mips.exp
===================================================================
--- gcc/testsuite/gcc.target/mips/mips.exp	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/mips.exp	2007-10-02 21:51:39.000000000 +0100
@@ -33,9 +33,11 @@ load_lib gcc-dg.exp
 #    $mips_gp64:	 true if 64-bit output is selected
 #    $mips_fp64:	 true if 64-bit FPRs are selected
 #    $mips_float:	 "hard" or "soft"
+#    $mips_abi:		 the ABI specified by _MIPS_SIM
 #
 #    $mips_forced_isa:	 true if the command line uses -march=* or -mips*
-#    $mips_forced_abi:	 true if the command line uses -mabi=* or -mgp*
+#    $mips_forced_abi:	 true if the command line uses -mabi=*
+#    $mips_forced_regs:  true if the command line uses -mgp* or -mfp*
 #    $mips_forced_float: true if the command line uses -mhard/soft-float
 #    $mips_forced_le	 true if the command line uses -EL or -mel
 #    $mips_forced_gp	 true if the command line forces a particular GP mode
@@ -46,6 +48,7 @@ proc setup_mips_tests {} {
     global mips_gp64
     global mips_fp64
     global mips_float
+    global mips_abi
 
     global mips_forced_isa
     global mips_forced_abi
@@ -53,6 +56,7 @@ proc setup_mips_tests {} {
     global mips_forced_le
     global mips_forced_gp
     global mips_forced_no_er
+    global mips_forced_regs
 
     global compiler_flags
     global tool
@@ -73,6 +77,17 @@ proc setup_mips_tests {} {
 	#else
 	const char *float = "soft";
 	#endif
+	#if !defined _MIPS_SIM
+	const char *abi = "eabi";
+	#elif _MIPS_SIM=_ABIO32
+	const char *abi = "32";
+	#elif _MIPS_SIM=_ABIO64
+	const char *abi = "o64";
+	#elif _MIPS_SIM=_ABIN32
+	const char *abi = "n32";
+	#else
+	const char *abi = "64";
+	#endif
     }
     close $f
     set output [${tool}_target_compile $src "" preprocess ""]
@@ -83,9 +98,11 @@ proc setup_mips_tests {} {
     set mips_gp64 [regexp {gp64 = 1} $output]
     set mips_fp64 [regexp {fp64 = 1} $output]
     regexp {float = "([^"]*)} $output dummy mips_float
+    regexp {abi = "([^"]*)} $output dummy mips_abi
 
     set mips_forced_isa [regexp -- {(-mips[1-5][[:>:]]|-mips32*|-mips64*|-march)} $compiler_flags]
-    set mips_forced_abi [regexp -- {(-mgp|-mfp|-mabi)} $compiler_flags]
+    set mips_forced_abi [regexp -- {-mabi} $compiler_flags]
+    set mips_forced_regs [regexp -- {(-mgp|-mfp)} $compiler_flags]
     set mips_forced_float [regexp -- {-m(hard|soft)-float} $compiler_flags]
     set mips_forced_le [regexp -- {-(EL|mel)[[:>:]]} $compiler_flags]
     set mips_forced_gp [regexp -- {-(G|m(|no-)((extern|local)-sdata|gpopt)|mabicalls|mrtp)} $compiler_flags]
@@ -99,11 +116,23 @@ proc is_gp32_flag {flag} {
 	-mips[12] -
 	-mips32* -
 	-march=mips32* -
+	-mabi=32 -
 	-mgp32 { return 1 }
 	default { return 0 }
     }
 }
 
+# Return true if command-line option FLAG forces 64-bit code.
+proc is_gp64_flag {flag} {
+    switch -glob -- $flag {
+	-mabi=64 -
+	-mabi=o64 -
+	-mabi=n32 -
+	-mgp64 { return 1 }
+	default { return 0 }
+    }
+}
+
 # Like dg-options, but treats certain MIPS-specific options specially:
 #
 #    -mgp32
@@ -116,6 +145,10 @@ proc is_gp32_flag {flag} {
 #	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.
 #
+#    -mabi=*
+#	Force a particular ABI.  Skip the test if the multilib flags
+#	force a specific ABI or a different register size.
+#
 #    -march=*
 #    -mips*
 #	Select the target architecture.  Skip the test if the multilib
@@ -150,9 +183,11 @@ proc dg-mips-options {args} {
     global mips_gp64
     global mips_fp64
     global mips_float
+    global mips_abi
 
     global mips_forced_isa
     global mips_forced_abi
+    global mips_forced_regs
     global mips_forced_float
     global mips_forced_le
     global mips_forced_gp
@@ -166,16 +201,18 @@ proc dg-mips-options {args} {
 	if {[is_gp32_flag $flag]
 	    && ($mips_gp64
 		|| ($mips_fp64 && [lsearch $flags -mfp64] < 0)) } {
-	    if {$mips_forced_abi} {
+	    if {$mips_forced_regs || $mips_forced_abi} {
 		set matches 0
-	    } else {
+	    } elseif {[lsearch $flags "-mabi=*"] < 0} {
 		append flags " -mabi=32"
 	    }
-	} elseif {$flag == "-mgp64" && !$mips_gp64} {
-	    if {$mips_forced_abi} {
+	} elseif {[is_gp64_flag $flag] && !$mips_gp64} {
+	    if {$mips_forced_regs || $mips_forced_abi} {
 		set matches 0
 	    } else {
-		append flags " -mabi=o64"
+	    	if {[lsearch $flags "-mabi=*"] < 0} {
+		    append flags " -mabi=o64"
+		}
 		if {[lsearch -regexp $flags {^(-mips|-march)}] < 0} {
 		    append flags " -mips3"
 		}
@@ -188,6 +225,10 @@ proc dg-mips-options {args} {
 	    if {$mips_isa < 33 || $mips_float != "hard"} {
 		set matches 0
 	    }
+	} elseif {[regexp -- {^-mabi=(.*)} $flag dummy abi]} {
+	    if {$abi != $mips_abi && $mips_forced_abi} {
+		set matches 0
+	    }
 	} elseif {[regexp -- {^-march=(.*)} $flag dummy arch]} {
 	    if {$arch != $mips_arch && $mips_forced_isa} {
 		set matches 0
Index: gcc/testsuite/gcc.target/mips/pr33256.c
===================================================================
--- gcc/testsuite/gcc.target/mips/pr33256.c	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/pr33256.c	2007-10-02 21:51:39.000000000 +0100
@@ -1,6 +1,6 @@
 /* GCC used to report an ICE for this test because we generated a LO_SUM
    for an illegitimate constant.  */
-/* { dg-mips-options "-mabi=64 -mips3 -msym32 -O2 -EB -mno-abicalls" } */
+/* { dg-mips-options "-mabi=64 -msym32 -O2 -EB -mno-abicalls" } */
 extern unsigned long a[];
 int b (int);
 
Index: gcc/testsuite/gcc.target/mips/save-restore-1.c
===================================================================
--- gcc/testsuite/gcc.target/mips/save-restore-1.c	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/save-restore-1.c	2007-10-02 21:51:39.000000000 +0100
@@ -1,6 +1,6 @@
 /* Check that we can use the save instruction to save varargs.  */
 /* { dg-do compile { target mips16_attribute } } */
-/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-mips-options "-mips32r2 -mabi=32 -O2" } */
 /* { dg-add-options mips16_attribute } */
 
 #include <stdarg.h>
Index: gcc/testsuite/gcc.target/mips/save-restore-2.c
===================================================================
--- gcc/testsuite/gcc.target/mips/save-restore-2.c	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/save-restore-2.c	2007-10-02 21:51:39.000000000 +0100
@@ -1,6 +1,6 @@
 /* Check that we can use the save instruction to save spilled arguments.  */
 /* { dg-do compile { target mips16_attribute } } */
-/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-mips-options "-mips32r2 -mabi=32 -O2" } */
 /* { dg-add-options mips16_attribute } */
 
 MIPS16 void
Index: gcc/testsuite/gcc.target/mips/save-restore-3.c
===================================================================
--- gcc/testsuite/gcc.target/mips/save-restore-3.c	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/save-restore-3.c	2007-10-02 21:51:39.000000000 +0100
@@ -1,7 +1,7 @@
 /* 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-do compile { target mips16_attribute } } */
-/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-mips-options "-mips32r2 -mabi=32 -O2" } */
 /* { dg-add-options mips16_attribute } */
 
 void bar (int *);
Index: gcc/testsuite/gcc.target/mips/save-restore-4.c
===================================================================
--- gcc/testsuite/gcc.target/mips/save-restore-4.c	2007-10-02 21:46:28.000000000 +0100
+++ gcc/testsuite/gcc.target/mips/save-restore-4.c	2007-10-02 21:51:39.000000000 +0100
@@ -1,6 +1,6 @@
 /* Check that we can use the save instruction to save $16, $17 and $31.  */
 /* { dg-do compile { target mips16_attribute } } */
-/* { dg-mips-options "-mips32r2 -mgp32 -O2" } */
+/* { dg-mips-options "-mips32r2 -mabi=32 -O2" } */
 /* { dg-add-options mips16_attribute } */
 
 void bar (void);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]