1 # Copyright
(C
) 1997, 2007 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC
; see the file COPYING3.
If not see
15 #
<http
://www.gnu.org
/licenses
/>.
17 # GCC testsuite that uses the `dg.exp
' driver.
19 # Exit immediately if this isn't a MIPS target.
20 if ![istarget mips
*-*-*] {
27 # Find out which target is selected by the default compiler flags.
28 # Also remember which aspects of the target are forced
on the command
29 # line
(as opposed to being overridable defaults
).
31 # $mips_isa
: the ISA level specified by __mips
32 # $mips_isa_rev
: the ISA revision specified by __mips_isa_rev
33 # $mips_arch
: the architecture specified by _MIPS_ARCH
34 # $mips_mips16
: true
if MIPS16 output is selected
35 # $mips_gp
: the number of bytes in a general register
36 # $mips_fp
: the number of bytes in a floating
-point register
37 # $mips_float
: "hard" or "soft"
38 # $mips_abi
: the ABI specified by _MIPS_SIM
40 # $mips_forced_isa
: true
if the command line uses
-march
=* or
-mips
*
41 # $mips_forced_abi
: true
if the command line uses
-mabi
=*
42 # $mips_forced_regs
: true
if the command line uses
-mgp
* or
-mfp
*
43 # $mips_forced_float
: true
if the command line uses
-mhard
/soft
-float
44 # $mips_forced_be true
if the command line uses
-EB or
-meb
45 # $mips_forced_le true
if the command line uses
-EL or
-mel
46 # $mips_forced_gp true
if the command line forces a particular GP
mode
47 # $mips_forced_no_abicalls
48 # true
if the command line contains
-mno
-abicalls
49 # $mips_forced_no_shared
50 # true
if the command line contains
-mno
-shared
51 # $mips_forced_no_er true
if the command line contains
-mno
-explicit
-relocs
52 proc setup_mips_tests
{} {
62 global mips_forced_isa
63 global mips_forced_abi
64 global mips_forced_float
68 global mips_forced_no_abicalls
69 global mips_forced_no_shared
70 global mips_forced_no_er
71 global mips_forced_regs
81 int isa_rev
= __mips_isa_rev
;
85 const char
*arch
= _MIPS_ARCH
;
95 #ifdef __mips_hard_float
96 const char
*float
= "hard";
98 const char
*float
= "soft";
100 #
if !defined _MIPS_SIM
101 const char
*abi
= "eabi";
102 #elif _MIPS_SIM
==_ABIO32
103 const char
*abi
= "32";
104 #elif _MIPS_SIM
==_ABIO64
105 const char
*abi
= "o64";
106 #elif _MIPS_SIM
==_ABIN32
107 const char
*abi
= "n32";
109 const char
*abi
= "64";
113 set output
[$
{tool
}_target_compile $src
"" preprocess ""]
116 regexp
{isa
= ([^
;]*)} $output dummy mips_isa
117 regexp
{isa_rev
= ([^
;]*)} $output dummy mips_isa_rev
118 regexp
{arch
= "([^"]*)} $output dummy mips_arch
119 set mips_mips16
[regexp
{mips16
= 1} $output
]
120 regexp
{gp
= ([^
;]*)} $output dummy mips_gp
121 regexp
{fp
= ([^
;]*)} $output dummy mips_fp
122 regexp
{float
= "([^"]*)} $output dummy mips_float
123 regexp
{abi
= "([^"]*)} $output dummy mips_abi
125 set mips_forced_isa
[regexp
-- {(-mips
[1-5][[:>:]]|
-mips32
*|
-mips64
*|
-march
)} $compiler_flags
]
126 set mips_forced_abi
[regexp
-- {-mabi
} $compiler_flags
]
127 set mips_forced_regs
[regexp
-- {(-mgp|
-mfp
)} $compiler_flags
]
128 set mips_forced_float
[regexp
-- {-m
(hard|soft
)-float
} $compiler_flags
]
129 set mips_forced_be
[regexp
-- {-(EB|meb
)[[:>:]]} $compiler_flags
]
130 set mips_forced_le
[regexp
-- {-(EL|mel
)[[:>:]]} $compiler_flags
]
131 set mips_forced_gp
[regexp
-- {-(G|m
(|no
-)((extern|local
)-sdata|gpopt
)|mabicalls|mrtp
)} $compiler_flags
]
132 set mips_forced_no_abicalls
[regexp
-- {-mno
-abicalls
} $compiler_flags
]
133 set mips_forced_no_shared
[regexp
-- {-mno
-shared
} $compiler_flags
]
134 set mips_forced_no_er
[regexp
-- {-mno
-explicit
-relocs
} $compiler_flags
]
136 if {$mips_forced_regs
&& $mips_gp
== 32 && $mips_fp
== 64} {
137 set mips_forced_abi
1
138 set mips_forced_isa
1
142 # Like dg
-options
, but treats certain MIPS
-specific options specially
:
146 # Force
32-bit code. Skip the test
if the multilib flags force
150 # Force
64-bit code. Also force a
64-bit target architecture
151 #
if the other flags don
't do so. Skip the test if the multilib
152 # flags force a 32-bit ABI or a 32-bit architecture.
155 # Force the use of 64-bit floating-point registers, even on a
156 # 32-bit target. Also force -mhard-float and an architecture that
157 # supports such a combination, unless these things are already
158 # specified by other parts of the given flags.
161 # Force a particular ABI. Skip the test if the multilib flags
162 # force a specific ABI or a different register size. If testing
163 # MIPS16 multilibs, try to force -msoft-float for ABIs other than
164 # o32 and o64, and skip the test if this is not possible.
168 # Select the target architecture. Skip the test if the multilib
169 # flags force a different architecture.
173 # Select the given floating-point mode. Skip the test if the
174 # multilib flags force a different selection.
178 # Select the given endianness. Skip the test if the multilib flags
179 # force the opposite endianness.
182 # -m(no-)extern-sdata
185 # Select the small-data mode, and -mno-abcialls. Skip the test if
186 # the multilib flags already contain such an option, or specify
187 # something that might be incompatible with them.
191 # Select the form of SVR4 PIC. Skip the test if the multilib flags
192 # conflict with the required setting.
195 # Select explicit relocations. Skip the test if the multilib flags
196 # force -mno-explicit-relocs.
199 # Select paired-single instructions. Also behave as for -mfp64.
200 proc dg-mips-options {args} {
201 upvar dg-extra-tool-flags extra_tool_flags
202 upvar dg-do-what do_what
213 global mips_forced_isa
214 global mips_forced_abi
215 global mips_forced_regs
216 global mips_forced_float
217 global mips_forced_be
218 global mips_forced_le
219 global mips_forced_gp
220 global mips_forced_no_abicalls
221 global mips_forced_no_shared
222 global mips_forced_no_er
224 set flags [lindex $args 1]
228 foreach flag $flags {
229 if {[string match -mpaired-single $flag]
230 && [lsearch $flags -mfp*] < 0} {
231 append flags " -mfp64"
232 } elseif {[regexp -- {^-mabi=(.*)} $flag dummy abi]
236 if {[lsearch $flags -mhard-float] >= 0} {
239 append flags " -msoft-float"
243 foreach flag $flags {
244 if {[string match -mfp* $flag]
245 && [lsearch -regexp $flags {^-m(hard|soft)-float$}] < 0} {
246 append flags " -mhard-float"
250 # Handle options that force a particular register size. Add
251 # architecture and ABI options if necessary.
252 set mips_new_gp $mips_gp
253 set mips_new_fp $mips_fp
254 foreach flag $flags {
255 switch -glob -- $flag {
277 if {$mips_new_gp != $mips_gp || $mips_new_fp != $mips_fp} {
278 if {$mips_forced_regs} {
281 # Select an appropriate ABI.
282 if {[lsearch $flags "-mabi=*"] < 0} {
283 if {$mips_new_gp == 32} {
284 append flags " -mabi=32"
286 append flags " -mabi=o64"
289 # And an appropriate architecture.
290 if {[lsearch -regexp $flags {^(-mips|-march)}] < 0} {
291 if {$mips_new_gp == 64 && $mips_gp == 32} {
292 append flags " -mips3"
293 } elseif {$mips_new_gp == 32 && $mips_new_fp == 64} {
294 append flags " -mips32r2"
299 foreach flag $flags {
300 if {[string match -mabicalls $flag]} {
301 # EABI has no SVR4-style PIC mode, so try to force another ABI.
302 if {$mips_abi == "eabi" && [lsearch $flags "-mabi=*"] < 0} {
303 if {$mips_new_gp == 32} {
304 append flags " -mabi=32"
306 append flags " -mabi=n32"
309 # Turn off small data, if on by default.
314 # Handle the other options.
315 foreach flag $flags {
316 if {[regexp -- {^-mabi=(.*)} $flag dummy abi]} {
317 if {$abi != $mips_abi && $mips_forced_abi} {
320 } elseif {[regexp -- {^-mips(.*)} $flag dummy isa]
321 || [regexp -- {^-march=mips(.*)} $flag dummy isa]} {
322 if {![regexp {(.*)r(.*)} $isa dummy isa isa_rev]} {
325 if {($isa != $mips_isa || $isa_rev != $mips_isa_rev)
326 && $mips_forced_isa} {
329 } elseif {[regexp -- {^-march=(.*)} $flag dummy arch]} {
330 if {$arch != $mips_arch && $mips_forced_isa} {
333 } elseif {[regexp -- {^-m(hard|soft)-float} $flag dummy float]} {
334 if {$mips_float != $float && $mips_forced_float} {
337 } elseif {[regexp -- {^-(EB|meb)$} $flag]} {
338 if {$mips_forced_le} {
341 } elseif {[regexp -- {^-(EL|mel)$} $flag]} {
342 if {$mips_forced_be} {
345 } elseif {[regexp -- {^-(G|m(|no-)((extern|local)-sdata|gpopt))} $flag]} {
346 if {$flag != "-G0"} {
347 append flags " -mno-abicalls"
349 if {$mips_forced_gp} {
352 } elseif {[regexp -- {^-mabicalls$} $flag]} {
353 if {$mips_forced_no_abicalls} {
356 } elseif {[regexp -- {^-mshared$} $flag]} {
357 if {$mips_forced_no_shared} {
360 } elseif {[regexp -- {^-mexplicit-relocs$} $flag]} {
361 if {$mips_forced_no_er} {
367 append extra_tool_flags " " $flags
369 set do_what [list [lindex $do_what 0] "N" "P"]
376 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" \
377 "-DMIPS16=__attribute__((mips16)) -DNOMIPS16=__attribute__((nomips16))"