1 # Copyright
(C
) 1997-2015 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 # A MIPS version of the GCC dg.exp driver.
19 # There are many MIPS features that we want to test
, and many of those
20 # features are specific to certain architectures
, certain ABIs and so
on.
21 # There are therefore many cases in which we want to test something that
22 # is incompatible with the user
's chosen test options.
24 # In most dg testsuites, the options added by dg-options have a lower
25 # priority than the options chosen by the user. For example, if a test
28 # { dg-options "-mips1" }
30 # and the user passes the following option to runtest:
32 # --target_board unix/-mips3
34 # the test would be compiled as MIPS III rather than MIPS I. If the
35 # test really wouldn't work with
-mips3
, normal practice would be to
36 # have something like
:
38 #
{ dg
-do compile { target can_force_mips1
} }
40 # so that the test is skipped when an option like
-mips3 is passed.
42 # Sticking to the same approach here would cause us to skip many tests
,
43 # even though the toolchain can generate the required code.
For example
,
44 # there are
6 MIPS ABIs
, plus variants. Some configurations support
45 # more than one ABI
, so it is natural to use something like
:
47 #
--target_board unix
{-mabi
=n32
,-mabi
=32,-mabi
=64}
49 # when testing them. But these
-mabi
=* options would normally prevent
any
50 # EABI and o64 tests from running.
52 # This testsuite therefore defines a local version of dg
-options that
53 # overrides
any user options that are incompatible with the test options.
54 # It tries to keep the other user options intact.
57 # Most of the tests in this testsuite are scan
-assembler tests
, but
58 # sometimes we need a link test instead. In these cases
, we must not
59 # try to link code with options that are incompatible with the current
60 # multilib
, because xgcc is passed
-L and
-B options that are specific
63 #
Normal GCC practice would be to skip incompatible link tests as
64 # unsupported
, but in this particular case
, it seems better to downgrade
65 # them to an assemble test instead. At least that way we
get some
66 # test
-for-ICE and code
-sanity coverage.
68 # The same problem applies to run tests.
If a test requires runtime
69 # support
for a particular feature
, and
if the current target does not
70 # provide that support
, normal practice would be to skip the test.
71 # But in this case it seems better to downgrade it to a link test instead.
72 #
(We might
then have to downgrade it to an assembler test according to
73 # the constraints just mentioned.
)
75 # The local dg
-options therefore checks whether the new options are
76 # link
-compatiable with the user
's options. If not, it automatically
77 # downgrades link tests to assemble tests. It does the same for run
78 # tests, but in addition, it downgrades run tests to link tests if the
79 # target does not provide runtime support for a required feature or ASE.
82 # Another problem is that many of the options we want to test require
83 # certain other features. For example, -mips3d requires both 64-bit
84 # FPRs and a MIPS32 or MIPS64 target; -mfix-r10000 requires branch-
85 # likely instructions; and so on. We could handle this by specifying
86 # a set of options that are guaranteed to give us what we want, such as:
88 # dg-options "-mips3d -mpaired-single -mhard-float -mgp64 -mfp64 -mabi=n32 -march=mips64 -mips64"
90 # With the new dg-options semantics, this would override any troublesome
91 # user options like -mips3, -march=vr4100, -mfp32, -mgp32, -msoft-float,
92 # -mno-paired-single and so on. But there are three major problems with
95 # - It is easy to forget options.
97 # - If a new option is added, all tests that are incompatible with that
98 # option must be updated.
100 # - We want to be able to test MIPS-3D with things like -march=mips32,
101 # -march=mips64r2, -march=sb1, and so on.
103 # The local version of dg-options therefore works out the requirements
104 # of each test option. As with the test options themselves, the local
105 # dg-options overrides any user options that incompatible with these
106 # requirements, but it keeps the other user options the same.
108 # For example, if the user passes -mips3, a MIPS-3D test will choose
109 # a different architecture like -mips64 instead. But if the user
110 # passes -march=sb1, MIPS-3D tests will be run with that option.
113 # Sometimes it is useful to say "I want an environment that is compatible
114 # with option X, but I don't want to pass option X itself
". The main example
115 # of this is
-mips16
: we want to be able to test __attribute__
((mips16
))
116 # without requiring the test itself to be compiled as
-mips16. The local
117 # version of dg
-options lets you
do this by putting X in parentheses.
120 #
{ dg
-options
"(-mips16)" }
122 # selects a MIPS16
-compatible target without passing
-mips16 itself.
124 # It is also useful to say
"any architecture within this ISA range is fine".
125 # This can be done using special pseudo
-options of the form
:
127 # PROP
=VALUE PROP
<=VALUE PROP
>=VALUE
132 # the value of the __mips macro.
135 # the value of the __mips_isa_rev macro
, or
0 if it isn
't defined.
137 # For example, "isa_rev>=1" selects a MIPS32 or MIPS64 processor,
138 # "isa=4" selects a MIPS IV processor, and so on.
140 # There are also the following special pseudo-options:
143 # select a Loongson processor
145 # addressing=absolute
146 # force absolute addresses to be used
149 # forbid processors that match the given regexp; choose a
150 # generic ISA instead.
155 # (1) Try to avoid { target ... } requirements wherever possible.
156 # Specify the requirements as dg-options instead.
158 # (2) Don't worry about the consequences of
(1) for link and run tests.
159 #
If the test uses
{ dg
-do link
} or
{ dg
-do run
}, and its
160 # dg
-options are incompatible with the current target
, the
161 # testsuite will downgrade them where necessary.
163 #
(3) Try to use the bare minimum of options and leave dg
-options
164 # to work out the dependencies.
For example
, if you want
165 # a MIPS
-3D test
, you should generally just specify
-mips3d.
166 # Don
't specify an architecture option like -mips64 unless
167 # the test really doesn't work with
-mips32r2
, -mips64r2
,
170 #
(4) If you want something compatible with a particular option
,
171 # but don
't want to pass the option itself, wrap that option
172 # in parentheses. In particular, pass '(-mips16
)' if you
173 # want to use "mips16" attributes.
175 # (5) When testing a feature of a generic ISA (as opposed to a
176 # processor-specific extension), try to use the "isa" and
177 # "isa_rev" pseudo-options instead of specific architecture
178 # options. For example, if the feature is present on revision 2
179 # processors and above, try to use "isa_rev>=2" instead of
180 # "-mips32r2" or "-mips64r2".
182 # (6) If you need to disable processor-specific extensions use
183 # forbid_cpu=REGEXP instead of forcing a generic ISA.
188 # Option group or just group:
189 # See comment before mips_option_groups.
192 # The options specified in dg-options.
195 # The options that were either passed to runtest as "multilib" options
196 # (e.g. -mips4 in --target_board=mips-sim-idt/-mips4) or specified as
197 # test options. Note that options in parenthesis (i.e. (-mips16)) are
198 # not explicit and can be omitted depending on the base options.
201 # Options that are on by default without being specified in dg-options,
202 # e.g. -march=mips64r2 for mipsisa64r2-elf or because they've been
203 # passed to runtest as
"multilib" options.
206 # Many functions in this file work with option arrays. These are
207 # two
-dimensional Tcl arrays where the first
dimension can have three
208 #
values: option
, explicit_p or test_option_p. The second
dimension is
209 # the
name of the option group.
"option" contains the name of the
210 # option that is in effect from this group.
If no option is active it
211 # contains the empty string. The flags
"explicit_p" and "test_option_p"
212 # are
set for explicit and test options.
214 # Exit immediately
if this isn
't a MIPS target.
215 if ![istarget mips*-*-*] {
219 # Load support procs.
222 # A list of GROUP REGEXP pairs. Each GROUP represents a logical group of
223 # options from which only one option should be chosen. REGEXP matches all
224 # the options in that group; it is implicitly wrapped in "^(...)$".
226 # Note that -O* is deliberately omitted from this list. Tests in this
227 # directory are run at various optimisation levels and should use
228 # dg-skip-if to skip any incompatible levels.
229 set mips_option_groups {
231 addressing "addressing=.*"
232 arch "-mips([1-5]|32.*|64.*)|-march=.*|isa(|_rev)(=|<=|>=).*"
235 endianness "-E(L|B)|-me(l|b)"
236 float "-m(hard|soft)-float"
237 fpu "-m(double|single)-float"
238 forbid_cpu "forbid_cpu=.*"
242 micromips "-mmicromips|-mno-micromips"
243 mips16 "-mips16|-mno-mips16|-mflip-mips16"
244 mips3d "-mips3d|-mno-mips3d"
245 pic "-f(no-|)(pic|PIC)"
246 cb "-mcompact-branches=.*"
248 small-data "-G[0-9]+"
258 section_start "-Wl,--section-start=.*"
261 for { set option 0 } { $option < 32 } { incr option } {
262 lappend mips_option_groups "fixed-f$option" "-ffixed-f$option"
265 # Add -mfoo/-mno-foo options to mips_option_groups.
289 lappend mips_option_groups $option "-m(no-|)$option"
292 # Add -mfoo= options to mips_option_groups.
301 lappend mips_option_groups $option "-m$option=.*"
304 # Add -ffoo/-fno-foo options to mips_option_groups.
308 expensive-optimizations
314 lax-vector-conversions
316 optimize-sibling-calls
325 lappend mips_option_groups $option "-f(no-|)$option"
328 # A list of option groups that have an impact on the ABI.
329 set mips_abi_groups {
343 # mips_option_tests(OPTION) is some assembly code that will run to completion
344 # on a target that supports OPTION.
345 set mips_option_tests(-mips16) {
357 set mips_option_tests(-mpaired-single) {
363 set mips_option_tests(-mips3d) {
373 madd.s $f4,$f2,$f2,$f4
375 set mips_option_tests(-mdsp) {
380 set mips_option_tests(-mdspr2) {
386 # Canonicalize command-line option OPTION.
387 proc mips_canonicalize_option { option } {
388 regsub {^-mips([1-5]|32*|64*)$} $option {-march=mips\1} option
390 regsub {^-mel$} $option {-EL} option
391 regsub {^-meb$} $option {-EB} option
393 regsub {^-O$} $option {-O1} option
395 # MIPS doesn't use
-fpic and
-fPIC to distinguish between code models.
396 regsub
{^
-f
(no
-|
)PIC
} $option
{-f\
1pic
} option
401 #
Return true
if OPTION1 and OPTION2 represent the same command
-line option.
402 proc mips_same_option_p
{ option1 option2
} {
403 return [string equal \
404 [mips_canonicalize_option $option1
] \
405 [mips_canonicalize_option $option2
]]
408 # Preprocess CODE using target_compile options OPTIONS.
Return the
410 proc mips_preprocess
{ options code
} {
414 set f
[open $src
"w"]
417 set output
[$
{tool
}_target_compile $src
"" preprocess $options]
423 #
Set the target board
's command-line options to NEW_OPTIONS, storing the
424 # old values in UPVAR.
425 proc mips_push_test_options { upvar new_options } {
430 set var(name) board_info([target_info name],multilib_flags)
431 if { [info exists $var(name)] } {
432 set var(old_options) [set $var(name)]
433 set $var(name) [join $new_options " "]
437 # Undo the effects of [mips_push_test_options UPVAR ...]
438 proc mips_pop_test_options { upvar } {
442 if { [info exists var(old_options)] } {
443 set $var(name) $var(old_options)
447 # Return property PROP for architecture option ARCH (which belongs to
448 # the "arch" group in mips_option_groups). See the comment at the
449 # top of the file for the valid property names.
451 # Cache the results in mips_arch_info (which can be reused between test
453 proc mips_arch_info { arch prop } {
454 global mips_arch_info
457 set arch [mips_canonicalize_option $arch]
458 if { ![info exists mips_arch_info($arch,$prop)] } {
459 mips_push_test_options saved_options {}
460 set output [mips_preprocess [list "additional_flags=$arch -mabi=32"] {
462 #ifdef __mips_isa_rev
463 int isa_rev = __mips_isa_rev;
468 foreach lhs { isa isa_rev } {
469 regsub ".*$lhs = (\[^;\]*).*" $output {\1} rhs
470 verbose -log "Architecture $arch has $lhs $rhs"
471 set mips_arch_info($arch,$lhs) $rhs
473 mips_pop_test_options saved_options
475 return $mips_arch_info($arch,$prop)
478 # Return the option group associated with OPTION, or "" if none.
479 proc mips_option_maybe_group { option } {
480 global mips_option_groups
482 foreach { group regexp } $mips_option_groups {
483 if { [regexp -- "^($regexp)\$" $option] } {
490 # Return the option group associated with OPTION. Raise an error if
492 proc mips_option_group { option } {
493 set group [mips_option_maybe_group $option]
494 if { [string equal $group ""] } {
495 error "Unrecognised option: $option"
500 # Return the option for option group GROUP, or "" if no option in that
501 # group has been chosen. UPSTATUS describes the option status.
502 proc mips_option { upstatus group } {
503 upvar $upstatus status
505 return $status(option,$group)
508 # If the base options for this test run include an option in group GROUP,
509 # return that option, otherwise return "".
510 proc mips_original_option { group } {
511 global mips_base_options
513 return [mips_option mips_base_options $group]
516 # Return true if the test described by UPSTATUS requires a specific
517 # option in group GROUP. UPSTATUS describes the option status.
518 proc mips_test_option_p { upstatus group } {
519 upvar $upstatus status
521 return $status(test_option_p,$group)
524 # If the test described by UPSTATUS requires a particular option in group
525 # GROUP, return that option, otherwise return "".
526 proc mips_test_option { upstatus group } {
527 upvar $upstatus status
529 if { [mips_test_option_p status $group] } {
530 return [mips_option status $group]
536 # Return true if the options described by UPSTATUS include OPTION.
537 proc mips_have_option_p { upstatus option } {
538 upvar $upstatus status
540 return [mips_same_option_p \
541 [mips_option status [mips_option_group $option]] \
545 # Return true if the options described by UPSTATUS require MIPS16 support.
546 proc mips_using_mips16_p { upstatus } {
547 upvar $upstatus status
549 return [expr { [mips_have_option_p status "-mips16"]
550 || [mips_have_option_p status "-mflip-mips16"] }]
553 # Return true if the test described by UPSTATUS requires option OPTION.
554 proc mips_have_test_option_p { upstatus option } {
555 upvar $upstatus status
557 set group [mips_option_group $option]
558 return [mips_same_option_p [mips_test_option status $group] $option]
561 # If the test described by UPSTATUS does not specify an option in
562 # OPTION's group
, act as though it had specified OPTION.
564 # The first optional
argument indicates whether the option should be
565 # treated as though it were wrapped in parentheses
; see the comment at
566 # the top of the file
for details about this convention. The default is
0.
567 proc mips_make_test_option
{ upstatus option
args } {
568 upvar $upstatus
status
570 set group
[mips_option_group $option
]
571 if { ![mips_test_option_p
status $group
] } {
572 set status(option
,$group
) $option
573 set status(test_option_p
,$group
) 1
574 if { [llength $
args] == 0 ||
![lindex $
args 0] } {
575 set status(explicit_p
,$group
) 1
580 #
If the test described by UPSTATUS requires option FROM
, assume that
581 # it implicitly requires option TO.
582 proc mips_option_dependency
{ upstatus from to
} {
583 upvar $upstatus
status
585 if { [mips_have_test_option_p
status $from
] } {
586 mips_make_test_option
status $to
590 #
Return true
if the given arch
-group option specifies a
32-bit ISA.
591 proc mips_32bit_arch_p
{ option
} {
592 set isa
[mips_arch_info $option isa
]
593 return [expr
{ $isa
< 3 || $isa
== 32 }]
596 #
Return true
if the given arch
-group option specifies a
64-bit ISA.
597 proc mips_64bit_arch_p
{ option
} {
598 return [expr
{ ![mips_32bit_arch_p $option
] }]
601 #
Return true
if the given abi
-group option implicitly requires
-mgp32.
602 proc mips_32bit_abi_p
{ option
} {
603 switch -glob
-- $option
{
611 #
Return true
if the given abi
-group option implicitly requires
-mgp64.
612 proc mips_64bit_abi_p
{ option
} {
613 switch -glob
-- $option
{
623 #
Return true
if the given abi
-group option implicitly requires
-mlong32.
624 # o64 requires this
for -mabicalls
, but not otherwise
; pick the conservative
625 # case
for simplicity.
626 proc mips_long32_abi_p
{ option
} {
627 switch -glob
-- $option
{
637 #
Return true
if the given abi
-group option implicitly requires
-mlong64.
638 proc mips_long64_abi_p
{ option
} {
639 switch -glob
-- $option
{
647 # Check whether the current target supports all the options that the
648 # current test requires.
Return "" if so, otherwise return one of
649 # the incompatible options. UPSTATUS describes the option
status.
650 proc mips_first_unsupported_option
{ upstatus
} {
651 global mips_option_tests
652 upvar $upstatus
status
654 foreach
{ option code
} [array
get mips_option_tests
] {
655 if { [mips_have_test_option_p
status $option
] } {
656 regsub
-all
"\n" $code "\\n\\\n" asm
657 # Use check_runtime from target
-supports.exp
, which caches
659 if { ![check_runtime mips_option_$option
[subst
{
660 __attribute__
((nomips16
)) int
676 # Initialize this testsuite
for a new test variant.
677 proc mips
-dg
-init
{} {
678 # Invariant information.
679 global mips_option_groups
681 # Internally
-generated information about this run.
682 global mips_base_options
683 global mips_extra_options
685 # Override dg
-options with our mips
-dg
-options routine.
686 rename dg
-options mips
-old
-dg
-options
687 rename mips
-dg
-options dg
-options
689 # Start with a fresh option
status.
690 array unset mips_base_options
691 foreach
{ group regexp
} $mips_option_groups
{
692 set mips_base_options
(option
,$group
) ""
693 set mips_base_options
(explicit_p
,$group
) 0
694 set mips_base_options
(test_option_p
,$group
) 0
697 # Use preprocessor macros to work out as many implicit options as we can.
698 set output
[mips_preprocess
"" {
699 const char
*options
[] = {
700 #
if !defined _MIPS_SIM
702 #elif _MIPS_SIM
==_ABIO32
704 #elif _MIPS_SIM
==_ABIO64
706 #elif _MIPS_SIM
==_ABIN32
712 "-march=" _MIPS_ARCH,
720 #ifdef __mips_hard_float
726 #ifdef __mips_abs2008
732 #ifdef __mips_nan2008
754 #
if _MIPS_SZLONG
== 64
772 #ifdef __mips_paired_single_float
775 "-mno-paired-single",
778 #
if _MIPS_SPFPSET
== 32
790 #
if __mips_dsp_rev
>= 2
796 #
if __mips_dsp_rev
>= 1
803 "addressing=absolute",
806 #ifdef __mips_smartmips
821 foreach line
[split $output
"\r\n"] {
822 # Poor man
's string concatenation.
823 regsub -all {" "} $line "" line
824 if { [regexp {"(.*)",} $line dummy option] } {
825 set group [mips_option_group $option]
826 set mips_base_options(option,$group) $option
830 # Process the target's multilib options
, saving
any unrecognized
831 # ones in mips_extra_options.
832 set mips_extra_options
{}
833 foreach option
[split
[board_info target multilib_flags
]] {
834 set group
[mips_option_maybe_group $option
]
835 if { ![string equal $group
""] } {
836 set mips_base_options
(option
,$group
) $option
837 set mips_base_options
(explicit_p
,$group
) 1
839 lappend mips_extra_options $option
844 # Finish a test run started by mips
-dg
-init.
845 proc mips
-dg
-finish
{} {
846 rename dg
-options mips
-dg
-options
847 rename mips
-old
-dg
-options dg
-options
850 # Override dg
-options so that we can
do some MIPS
-specific processing.
851 # All options used in this testsuite must appear in mips_option_groups.
853 # Test options override multilib options. Certain test options can
854 # also imply other test options
, which also override multilib options.
855 # These dependencies are ordered as follows
:
859 #
-mips16
/-mflip
-mips16
-mno
-mips16
861 #
-micromips
-mno
-micromips
863 #
-mips3d
-mno
-mips3d
865 #
-mpaired
-single
-mno
-paired
-single
869 #
-modd
-spreg
-mno
-odd
-spreg
871 #
-mdouble
-float
-msingle
-float
873 #
-mabs
=2008/-mabs
=legacy
<no option
>
875 #
-mhard
-float
-msoft
-float
879 #
-mrelax
-pic
-calls
-mno
-relax
-pic
-calls
883 #
-mshared
-mno
-shared
887 # addressing
=unknown addressing
=absolute
889 #
-mabicalls
-mno
-abicalls
893 #
<other value
> -mr10k
-cache-barrier
=none
895 #
-mfix
-r10000
-mno
-fix
-r10000
897 #
-mbranch
-likely
-mno
-branch
-likely
899 #
-msmartmips
-mno
-smartmips
903 #
-mexplicit
-relocs
-mno
-explicit
-relocs
911 #
+-- gp
, abi
& arch
---------+
913 #
For these purposes
, the
"gp", "abi" & "arch" option groups are treated
915 proc mips
-dg
-options
{ args } {
917 upvar dg
-extra
-tool
-flags extra_tool_flags
918 upvar dg
-do-what do_what
920 # Invariant information.
921 global mips_option_groups
922 global mips_abi_groups
924 # Information about this run.
925 global mips_base_options
927 if { [llength $
args] >= 3 } {
928 switch { [dg
-process
-target
[lindex $
args 2]] } {
931 "F" { error "[lindex $args 0]: `xfail' not allowed here" }
932 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
936 # Start out with the default option state.
937 array
set options
[array
get mips_base_options
]
939 # Record the options that this test explicitly needs.
940 foreach option
[lindex $
args 1] {
941 set all_but_p
[regexp
{^\
((.
*)\
)$
} $option dummy option
]
942 set group
[mips_option_group $option
]
943 if { [mips_test_option_p options $group
] } {
944 set old
[mips_option options $group
]
945 error
"Inconsistent $group option: $old vs. $option"
947 mips_make_test_option options $option $all_but_p
951 # Handle dependencies between the test options and the optimization ones.
952 mips_option_dependency options
"-fno-unroll-loops" "-fno-unroll-all-loops"
953 mips_option_dependency options
"-pg" "-fno-omit-frame-pointer"
955 # Handle dependencies between options
on the left of the
956 # dependency diagram.
957 mips_option_dependency options
"-mips16" "-mno-micromips"
958 mips_option_dependency options
"-mmicromips" "-mno-mips16"
959 mips_option_dependency options
"-mips3d" "-mpaired-single"
960 mips_option_dependency options
"-mips3d" "-mno-micromips"
961 mips_option_dependency options
"-mpaired-single" "-mfp64"
962 mips_option_dependency options
"-mfp64" "-mhard-float"
963 mips_option_dependency options
"-mfp32" "-mhard-float"
964 mips_option_dependency options
"-mfpxx" "-mhard-float"
965 mips_option_dependency options
"-mfp64" "-modd-spreg"
966 mips_option_dependency options
"-mfp64" "-mdouble-float"
967 mips_option_dependency options
"-mfp32" "-mdouble-float"
968 mips_option_dependency options
"-mfpxx" "-mdouble-float"
969 mips_option_dependency options
"-mabs=2008" "-mhard-float"
970 mips_option_dependency options
"-mabs=legacy" "-mhard-float"
971 mips_option_dependency options
"-mrelax-pic-calls" "-mno-plt"
972 mips_option_dependency options
"-mrelax-pic-calls" "-mabicalls"
973 mips_option_dependency options
"-mrelax-pic-calls" "-mexplicit-relocs"
974 mips_option_dependency options
"-fpic" "-mshared"
975 mips_option_dependency options
"-mshared" "-mno-plt"
976 mips_option_dependency options
"-mshared" "-mabicalls"
977 mips_option_dependency options
"-mno-plt" "addressing=unknown"
978 mips_option_dependency options
"-mabicalls" "-G0"
979 mips_option_dependency options
"-mno-gpopt" "-mexplicit-relocs"
981 # Work out information about the current ABI.
982 set abi_test_option_p
[mips_test_option_p options abi
]
983 set abi
[mips_option options abi
]
984 set eabi_p
[mips_same_option_p $abi
"-mabi=eabi"]
986 #
If the test forces a particular ABI
, set the register size
988 if { $abi_test_option_p
} {
989 if { [mips_32bit_abi_p $abi
] } {
990 mips_make_test_option options
"-mgp32"
991 } elseif
{ [mips_64bit_abi_p $abi
] } {
992 mips_make_test_option options
"-mgp64"
996 # See whether forbid_cpu forces us to choose a new architecture.
997 set arch
[mips_option mips_base_options arch
]
998 set force_generic_isa_p
[expr
{
999 [regexp
"forbid_cpu=(.*)" [mips_option options forbid_cpu] dummy spec]
1000 && [regexp
-- "^-march=$spec\$" $arch]
1003 # Interpret the special
"isa" and "isa_rev" options. If we have
1004 # a choice of a
32-bit or a
64-bit architecture
, prefer to keep
1005 # the
-mgp setting the same.
1006 set spec
[mips_option options arch
]
1007 if { [regexp
{^
[^
-]} $spec
] } {
1008 if { [string equal $spec
"isa=loongson"] } {
1009 if { ![regexp
{^
-march
=loongson
} $arch
] } {
1010 set arch
"-march=loongson2f"
1013 if { ![regexp
{^
(isa
(?
:|_rev
))(=|
<=|
>=)([0-9]*)$
} \
1014 $spec dummy prop
relation value nocpus
] } {
1015 error
"Unrecognized isa specification: $spec"
1017 set current
[mips_arch_info $arch $prop
]
1018 if { $force_generic_isa_p
1019 ||
($current
< $value
&& ![string equal $
relation "<="])
1020 ||
($current
> $value
&& ![string equal $
relation ">="])
1021 ||
([mips_have_test_option_p options
"-mgp64"]
1022 && [mips_32bit_arch_p $arch
]) } {
1023 # The current setting is out of range
; it cannot
1024 # possibly be used. Find a replacement that can.
1025 if { [string equal $prop
"isa"] } {
1026 set arch
"-mips$value"
1027 } elseif
{ $value
== 0 } {
1030 if { [mips_have_option_p options
"-mgp32"] } {
1036 append arch
"r$value"
1041 set options
(option
,arch
) $arch
1044 # Work out information about the current architecture.
1045 set arch_test_option_p
[mips_test_option_p options arch
]
1046 set arch
[mips_option options arch
]
1047 set isa
[mips_arch_info $arch isa
]
1048 set isa_rev
[mips_arch_info $arch isa_rev
]
1049 set orig_isa_rev $isa_rev
1051 #
If the test forces a
32-bit architecture
, force
-mgp32.
1052 # Force the current
-mgp setting otherwise
; if we don
't,
1053 # some configurations would make a 64-bit architecture
1055 if { $arch_test_option_p } {
1056 if { [mips_32bit_arch_p $arch] } {
1057 mips_make_test_option options "-mgp32"
1059 mips_make_test_option options [mips_option options gp]
1063 # We've now fixed the GP register size. Make it easily available.
1064 set gp_size
[expr
{ [mips_have_option_p options
"-mgp32"] ? 32 : 64 }]
1066 # Handle dependencies between the pre
-arch options and the arch option.
1067 # This should mirror the arch and post
-arch code below.
1068 if { !$arch_test_option_p
} {
1069 # We need a revision
6 or better ISA
for:
1071 #
- When the LSA instruction is required
1072 #
- When only using compact branches
1074 && ([mips_have_test_option_p options
"HAS_LSA"]
1075 ||
[mips_have_test_option_p options
"-mcompact-branches=always"]) } {
1076 if { $gp_size
== 32 } {
1077 mips_make_test_option options
"-mips32r6"
1079 mips_make_test_option options
"-mips64r6"
1081 # We need a revision
2 or better ISA
for:
1083 #
- the combination of
-mgp32
-mfp64
1085 } elseif
{ $isa_rev
< 2
1086 && (($gp_size
== 32 && [mips_have_test_option_p options
"-mfp64"])
1087 ||
[mips_have_test_option_p options
"-msynci"]
1088 ||
[mips_have_test_option_p options
"-mdsp"]
1089 ||
[mips_have_test_option_p options
"HAS_INS"]
1090 ||
[mips_have_test_option_p options
"HAS_MADD"]
1091 ||
[mips_have_test_option_p options
"HAS_MADDPS"]
1092 ||
[mips_have_test_option_p options
"-mdspr2"]) } {
1093 if { $gp_size
== 32 } {
1094 mips_make_test_option options
"-mips32r2"
1096 mips_make_test_option options
"-mips64r2"
1098 # We need a MIPS32 or MIPS64 ISA
for:
1100 #
- paired
-single instructions
(*)
1101 #
- odd numbered single precision registers
1103 #
(*) Note that we don
't support MIPS V at the moment.
1104 } elseif { $isa_rev < 1
1105 && ([mips_have_test_option_p options "-mpaired-single"]
1106 || ([mips_have_test_option_p options "-modd-spreg"]
1107 && ![mips_have_test_option_p options "-mfp64"]))} {
1108 if { $gp_size == 32 } {
1109 mips_make_test_option options "-mips32"
1111 mips_make_test_option options "-mips64"
1113 # We need MIPS IV or higher for:
1117 && [mips_have_test_option_p options "HAS_MOVN"] } {
1118 mips_make_test_option options "-mips4"
1119 # We need MIPS III or higher for:
1121 # - the "cache" instruction
1123 && ([mips_have_test_option_p options \
1124 "-mr10k-cache-barrier=load-store"]
1125 || [mips_have_test_option_p options \
1126 "-mr10k-cache-barrier=store"]) } {
1127 mips_make_test_option options "-mips3"
1128 # We need MIPS II or higher for:
1130 # - branch-likely instructions(*)
1132 # (*) needed by both -mbranch-likely and -mfix-r10000
1134 && ([mips_have_test_option_p options "-mbranch-likely"]
1135 || [mips_have_test_option_p options "-mfix-r10000"]
1137 && ([mips_have_test_option_p options "-mfpxx"]
1138 || [mips_have_test_option_p options "HAS_LDC"]))) } {
1139 mips_make_test_option options "-mips2"
1140 # We need to use octeon's base ISA
if a test must not run with an
1141 # architecture that supports dmul.
1142 } elseif
{ [regexp
-- "^-march=octeon.*\$" $arch]
1143 && [mips_have_test_option_p options
"NOT_HAS_DMUL"] } {
1144 mips_make_test_option options
"-mips${isa}r${isa_rev}"
1145 # Check whether we need to
switch from mips
*r6 down to mips
*r5 due
1146 # to options that are incompatible with mips
*r6.
If we
do, use
1147 #
-mnan
=2008 because r6 is nan2008 by default and without this flag
1148 # tests that
include stdlib.h will fail due to not finding
1149 # stubs
-o32_hard.h
(r6 compilers only have stubs
-o32_hard_2008.h
)
1150 } elseif
{ $isa_rev
> 5
1151 && ([mips_have_test_option_p options
"-mdsp"]
1152 ||
[mips_have_test_option_p options
"-mdspr2"]
1153 ||
[mips_have_test_option_p options
"-mips16"]
1154 ||
[mips_have_test_option_p options
"-mmicromips"]
1155 ||
[mips_have_test_option_p options
"-mfp32"]
1156 ||
[mips_have_test_option_p options
"-mfix-r10000"]
1157 ||
[mips_have_test_option_p options
"NOT_HAS_DMUL"]
1158 ||
[mips_have_test_option_p options
"HAS_MOVN"]
1159 ||
[mips_have_test_option_p options
"HAS_MADD"]
1160 ||
[mips_have_test_option_p options
"-mpaired-single"]
1161 ||
[mips_have_test_option_p options
"-mnan=legacy"]
1162 ||
[mips_have_test_option_p options
"-mabs=legacy"]
1163 ||
[mips_have_test_option_p options
"!HAS_LSA"]) } {
1164 if { $gp_size
== 32 } {
1165 mips_make_test_option options
"-mips32r5"
1167 mips_make_test_option options
"-mips64r5"
1169 mips_make_test_option options
"-mnan=2008"
1170 if { [mips_have_option_p options
"-mcompact-branches=always"] } {
1171 mips_make_test_option options
"-mcompact-branches=optimal"
1173 # Check whether we need to
switch from a
32-bit processor to the
1174 #
"nearest" 64-bit processor.
1175 } elseif
{ $gp_size
== 64 && [mips_32bit_arch_p $arch
] } {
1176 if { $isa_rev
== 0 } {
1177 mips_make_test_option options
"-mips3"
1178 } elseif
{ $isa_rev
== 1 } {
1179 mips_make_test_option options
"-mips64"
1181 mips_make_test_option options
"-mips64r$isa_rev"
1183 # Otherwise
, if the current choice of architecture is unacceptable
,
1184 # choose the equivalent generic architecture.
1185 } elseif
{ $force_generic_isa_p
} {
1186 set arch
"-mips[mips_arch_info $arch isa]"
1187 if { $isa_rev
> 1 } {
1188 append arch
"r$isa_rev"
1190 mips_make_test_option options $arch
1197 # Re
-calculate the isa_rev
for use in the abi handling code below
1198 set arch
[mips_option options arch
]
1199 set isa
[mips_arch_info $arch isa
]
1200 set isa_rev
[mips_arch_info $arch isa_rev
]
1202 #
Set an appropriate ABI
, handling dependencies between the pre
-abi
1203 # options and the abi options. This should mirror the abi and post
-abi
1205 if { !$abi_test_option_p
} {
1207 && ([mips_have_option_p options
"-mabicalls"]
1209 && [mips_have_option_p options
"-mfp64"]))) } {
1210 # EABI doesn
't support -mabicalls.
1211 # EABI doesn't support the combination
-mgp32
-mfp64.
1213 } elseif
{ [mips_using_mips16_p options
]
1214 && ![mips_same_option_p $abi
"-mabi=32"]
1215 && ![mips_same_option_p $abi
"-mabi=o64"]
1216 && (![mips_have_option_p options
"addressing=absolute"]
1217 ||
[mips_have_option_p options
"-mhard-float"]) } {
1218 #
-mips16
-mhard
-float requires o32 or o64.
1219 #
-mips16 PIC requires o32 or o64.
1221 } elseif
{ [mips_have_test_option_p options
"-mlong32"]
1222 && [mips_long64_abi_p $abi
] } {
1224 } elseif
{ [mips_have_test_option_p options
"-mlong64"]
1225 && [mips_long32_abi_p $abi
] } {
1227 } elseif
{ [mips_have_test_option_p options
"-mfpxx"]
1228 && ![mips_same_option_p $abi
"-mabi=32"] } {
1233 if { $gp_size
== 32 } {
1234 if { $force_abi ||
[mips_64bit_abi_p $abi
] } {
1235 if { [mips_have_test_option_p options
"-mlong64"] } {
1236 mips_make_test_option options
"-mabi=eabi"
1237 mips_make_test_option options
"-mgp32"
1239 mips_make_test_option options
"-mabi=32"
1243 if { $force_abi ||
[mips_32bit_abi_p $abi
] } {
1244 if { [mips_have_test_option_p options
"-mlong64"] } {
1245 mips_make_test_option options
"-mabi=eabi"
1246 mips_make_test_option options
"-mgp64"
1248 # All configurations should have an assembler that
1249 # supports o64
, since it requires the same BFD target
1250 # vector as o32. In contrast
, many assembler
1251 # configurations
do not have n32 or n64 support.
1252 mips_make_test_option options
"-mabi=o64"
1256 set abi_test_option_p
[mips_test_option_p options abi
]
1257 set abi
[mips_option options abi
]
1258 set eabi_p
[mips_same_option_p $abi
"-mabi=eabi"]
1261 # Handle dependencies between the abi options and the post
-abi options.
1262 # This should mirror the abi and pre
-abi code above.
1263 if { $abi_test_option_p
} {
1265 mips_make_test_option options
"-mno-abicalls"
1266 if { $isa_rev
< 6 && $gp_size
== 32 } {
1267 mips_make_test_option options
"-mfp32"
1270 if { [mips_using_mips16_p options
]
1271 && ![mips_same_option_p $abi
"-mabi=32"]
1272 && ![mips_same_option_p $abi
"-mabi=o64"]
1273 && ([mips_have_option_p options
"-mabicalls"]
1274 ||
[mips_have_option_p options
"-mhard-float"]) } {
1275 if { [mips_test_option_p options mips16
] } {
1276 mips_make_test_option options
"addressing=absolute"
1277 mips_make_test_option options
"-msoft-float"
1279 mips_make_test_option options
"-mno-mips16"
1282 if { [mips_long32_abi_p $abi
] } {
1283 mips_make_test_option options
"-mlong32"
1284 } elseif
{ [mips_long64_abi_p $abi
] } {
1285 mips_make_test_option options
"-mlong64"
1289 # Handle dependencies between the arch option and the post
-arch options.
1290 # This should mirror the arch and pre
-arch code above.
For pre
-r6
1291 # architectures this only needs to be done when we
've moved down
1292 # to a lower architecture and might need to turn features off,
1293 # but moving up from pre-r6 to r6 can remove features too.
1294 if { $arch_test_option_p || ($orig_isa_rev < 6 && $isa_rev >= 6) } {
1296 mips_make_test_option options "-mno-branch-likely"
1297 mips_make_test_option options "-mno-fix-r10000"
1300 mips_make_test_option options "-mr10k-cache-barrier=none"
1302 if { $isa_rev < 1 } {
1303 mips_make_test_option options "-mno-paired-single"
1304 if { ![mips_have_test_option_p options "-mgp64"] } {
1305 mips_make_test_option options "-mno-odd-spreg"
1308 if { $isa_rev < 2 } {
1309 if { $gp_size == 32 } {
1310 mips_make_test_option options "-mfp32"
1312 mips_make_test_option options "-mno-dsp"
1313 mips_make_test_option options "-mno-synci"
1314 mips_make_test_option options "-mno-micromips"
1315 mips_make_test_option options "-mnan=legacy"
1317 if { $isa_rev < 6 } {
1318 if { [mips_have_option_p options "-mcompact-branches=always"] } {
1319 mips_make_test_option options "-mcompact-branches=optimal"
1322 if { $isa_rev > 5 } {
1323 mips_make_test_option options "-mno-dsp"
1324 mips_make_test_option options "-mno-mips16"
1325 if { [mips_have_test_option_p options "-mdsp"] } {
1326 mips_make_test_option options "-mfp64"
1328 mips_make_test_option options "-mno-fix-r10000"
1329 mips_make_test_option options "-mno-paired-single"
1330 mips_make_test_option options "-mnan=2008"
1331 mips_make_test_option options "-mabs=2008"
1333 if { [regexp {^-march=(octeon|loongson)} $arch] } {
1334 mips_make_test_option options "-mno-micromips"
1342 # Handle dependencies between options on the right of the diagram.
1343 mips_option_dependency options "-mno-dsp" "-mno-dspr2"
1344 mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
1345 switch -- [mips_test_option options small-data] {
1349 mips_make_test_option options "-mno-abicalls"
1352 if { [mips_have_option_p options "-mabicalls"] } {
1353 mips_option_dependency options "addressing=absolute" "-mplt"
1355 mips_option_dependency options "-mplt" "-msym32"
1356 mips_option_dependency options "-mplt" "-mno-shared"
1357 mips_option_dependency options "-mno-shared" "-fno-pic"
1358 mips_option_dependency options "-mfp32" "-mno-paired-single"
1359 mips_option_dependency options "-mfpxx" "-mno-paired-single"
1360 mips_option_dependency options "-msoft-float" "-mno-paired-single"
1361 mips_option_dependency options "-mno-paired-single" "-mno-mips3d"
1363 # If the test requires an unsupported option, change run tests
1366 switch -- [lindex $do_what 0] {
1368 set option [mips_first_unsupported_option options]
1369 if { ![string equal $option ""] } {
1370 set do_what [lreplace $do_what 0 0 link]
1371 verbose -log "Downgraded to a 'link
' test due to unsupported option '$option
'"
1376 # If the test has overridden a option that changes the ABI,
1377 # downgrade a link or execution test to an assembler test.
1378 foreach group $mips_abi_groups {
1379 set old_option [mips_original_option $group]
1380 set new_option [mips_option options $group]
1381 if { ![mips_same_option_p $old_option $new_option]
1382 && ![mips_same_option_p $old_option "-mfpxx"]
1383 && ![mips_same_option_p $new_option "-mfpxx"] } {
1384 switch -- [lindex $do_what 0] {
1387 set do_what [lreplace $do_what 0 0 assemble]
1388 verbose -log "Downgraded to an 'assemble
' test due to incompatible $group option ($old_option changed to $new_option)"
1395 # Add all options to the dg variable.
1396 set options(explicit_p,addressing) 0
1397 set options(explicit_p,forbid_cpu) 0
1398 foreach { group regexp } $mips_option_groups {
1399 if { $options(explicit_p,$group) } {
1400 append extra_tool_flags " " $options(option,$group)
1404 # If the test is MIPS16-compatible, provide a counterpart to the
1405 # NOMIPS16 convenience macro.
1406 if { [mips_have_test_option_p options "-mips16"] } {
1407 append extra_tool_flags " -DMIPS16=__attribute__((mips16))"
1410 if { [mips_have_test_option_p options "-mmicromips"] } {
1411 append extra_tool_flags " -DMICROMIPS=__attribute__((micromips))"
1414 # Use our version of gcc-dg-test for this test.
1415 if { ![string equal [info procs "mips-gcc-dg-test"] ""] } {
1416 rename gcc-dg-test mips-old-gcc-dg-test
1417 rename mips-gcc-dg-test gcc-dg-test
1421 # A version of gcc-dg-test that is used by dg-options tests.
1422 proc mips-gcc-dg-test { prog do_what extra_tool_flags } {
1424 global mips_extra_options
1426 # Override the user's chosen test options with the combined test
/user
1428 mips_push_test_options saved_options $mips_extra_options
1429 set result
[gcc
-dg
-test
-1 gcc_target_compile $prog \
1430 $do_what $extra_tool_flags
]
1431 mips_pop_test_options saved_options
1433 # Restore the usual gcc
-dg
-test.
1434 rename gcc
-dg
-test mips
-gcc
-dg
-test
1435 rename mips
-old
-gcc
-dg
-test gcc
-dg
-test
1442 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/*.c
]] \
1443 "" "-DNOMIPS16=__attribute__((nomips16)) -DNOMICROMIPS=__attribute__((nomicromips)) -DNOCOMPRESSION=__attribute__((nocompression))"