1 # Copyright
(C
) 1997-2013 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 forbid_cpu "forbid_cpu=.*"
241 micromips "-mmicromips|-mno-micromips"
242 mips16 "-mips16|-mno-mips16|-mflip-mips16"
243 mips3d "-mips3d|-mno-mips3d"
244 pic "-f(no-|)(pic|PIC)"
246 small-data "-G[0-9]+"
251 # Add -mfoo/-mno-foo options to mips_option_groups.
274 lappend mips_option_groups $option "-m(no-|)$option"
277 # Add -mfoo= options to mips_option_groups.
286 lappend mips_option_groups $option "-m$option=.*"
289 # Add -ffoo/-fno-foo options to mips_option_groups.
293 expensive-optimizations
299 lax-vector-conversions
301 optimize-sibling-calls
309 lappend mips_option_groups $option "-f(no-|)$option"
312 # A list of option groups that have an impact on the ABI.
313 set mips_abi_groups {
327 # mips_option_tests(OPTION) is some assembly code that will run to completion
328 # on a target that supports OPTION.
329 set mips_option_tests(-mips16) {
341 set mips_option_tests(-mpaired-single) {
347 set mips_option_tests(-mips3d) {
357 madd.s $f4,$f2,$f2,$f4
359 set mips_option_tests(-mdsp) {
364 set mips_option_tests(-mdspr2) {
370 # Canonicalize command-line option OPTION.
371 proc mips_canonicalize_option { option } {
372 regsub {^-mips([1-5]|32*|64*)$} $option {-march=mips\1} option
374 regsub {^-mel$} $option {-EL} option
375 regsub {^-meb$} $option {-EB} option
377 regsub {^-O$} $option {-O1} option
379 # MIPS doesn't use
-fpic and
-fPIC to distinguish between code models.
380 regsub
{^
-f
(no
-|
)PIC
} $option
{-f\
1pic
} option
385 #
Return true
if OPTION1 and OPTION2 represent the same command
-line option.
386 proc mips_same_option_p
{ option1 option2
} {
387 return [string equal \
388 [mips_canonicalize_option $option1
] \
389 [mips_canonicalize_option $option2
]]
392 # Preprocess CODE using target_compile options OPTIONS.
Return the
394 proc mips_preprocess
{ options code
} {
398 set f
[open $src
"w"]
401 set output
[$
{tool
}_target_compile $src
"" preprocess $options]
407 #
Set the target board
's command-line options to NEW_OPTIONS, storing the
408 # old values in UPVAR.
409 proc mips_push_test_options { upvar new_options } {
414 set var(name) board_info([target_info name],multilib_flags)
415 if { [info exists $var(name)] } {
416 set var(old_options) [set $var(name)]
417 set $var(name) [join $new_options " "]
421 # Undo the effects of [mips_push_test_options UPVAR ...]
422 proc mips_pop_test_options { upvar } {
426 if { [info exists var(old_options)] } {
427 set $var(name) $var(old_options)
431 # Return property PROP for architecture option ARCH (which belongs to
432 # the "arch" group in mips_option_groups). See the comment at the
433 # top of the file for the valid property names.
435 # Cache the results in mips_arch_info (which can be reused between test
437 proc mips_arch_info { arch prop } {
438 global mips_arch_info
441 set arch [mips_canonicalize_option $arch]
442 if { ![info exists mips_arch_info($arch,$prop)] } {
443 mips_push_test_options saved_options {}
444 set output [mips_preprocess [list "additional_flags=$arch -mabi=32"] {
446 #ifdef __mips_isa_rev
447 int isa_rev = __mips_isa_rev;
452 foreach lhs { isa isa_rev } {
453 regsub ".*$lhs = (\[^;\]*).*" $output {\1} rhs
454 verbose -log "Architecture $arch has $lhs $rhs"
455 set mips_arch_info($arch,$lhs) $rhs
457 mips_pop_test_options saved_options
459 return $mips_arch_info($arch,$prop)
462 # Return the option group associated with OPTION, or "" if none.
463 proc mips_option_maybe_group { option } {
464 global mips_option_groups
466 foreach { group regexp } $mips_option_groups {
467 if { [regexp -- "^($regexp)\$" $option] } {
474 # Return the option group associated with OPTION. Raise an error if
476 proc mips_option_group { option } {
477 set group [mips_option_maybe_group $option]
478 if { [string equal $group ""] } {
479 error "Unrecognised option: $option"
484 # Return the option for option group GROUP, or "" if no option in that
485 # group has been chosen. UPSTATUS describes the option status.
486 proc mips_option { upstatus group } {
487 upvar $upstatus status
489 return $status(option,$group)
492 # If the base options for this test run include an option in group GROUP,
493 # return that option, otherwise return "".
494 proc mips_original_option { group } {
495 global mips_base_options
497 return [mips_option mips_base_options $group]
500 # Return true if the test described by UPSTATUS requires a specific
501 # option in group GROUP. UPSTATUS describes the option status.
502 proc mips_test_option_p { upstatus group } {
503 upvar $upstatus status
505 return $status(test_option_p,$group)
508 # If the test described by UPSTATUS requires a particular option in group
509 # GROUP, return that option, otherwise return "".
510 proc mips_test_option { upstatus group } {
511 upvar $upstatus status
513 if { [mips_test_option_p status $group] } {
514 return [mips_option status $group]
520 # Return true if the options described by UPSTATUS include OPTION.
521 proc mips_have_option_p { upstatus option } {
522 upvar $upstatus status
524 return [mips_same_option_p \
525 [mips_option status [mips_option_group $option]] \
529 # Return true if the options described by UPSTATUS require MIPS16 support.
530 proc mips_using_mips16_p { upstatus } {
531 upvar $upstatus status
533 return [expr { [mips_have_option_p status "-mips16"]
534 || [mips_have_option_p status "-mflip-mips16"] }]
537 # Return true if the test described by UPSTATUS requires option OPTION.
538 proc mips_have_test_option_p { upstatus option } {
539 upvar $upstatus status
541 set group [mips_option_group $option]
542 return [mips_same_option_p [mips_test_option status $group] $option]
545 # If the test described by UPSTATUS does not specify an option in
546 # OPTION's group
, act as though it had specified OPTION.
548 # The first optional
argument indicates whether the option should be
549 # treated as though it were wrapped in parentheses
; see the comment at
550 # the top of the file
for details about this convention. The default is
0.
551 proc mips_make_test_option
{ upstatus option
args } {
552 upvar $upstatus
status
554 set group
[mips_option_group $option
]
555 if { ![mips_test_option_p
status $group
] } {
556 set status(option
,$group
) $option
557 set status(test_option_p
,$group
) 1
558 if { [llength $
args] == 0 ||
![lindex $
args 0] } {
559 set status(explicit_p
,$group
) 1
564 #
If the test described by UPSTATUS requires option FROM
, assume that
565 # it implicitly requires option TO.
566 proc mips_option_dependency
{ upstatus from to
} {
567 upvar $upstatus
status
569 if { [mips_have_test_option_p
status $from
] } {
570 mips_make_test_option
status $to
574 #
Return true
if the given arch
-group option specifies a
32-bit ISA.
575 proc mips_32bit_arch_p
{ option
} {
576 set isa
[mips_arch_info $option isa
]
577 return [expr
{ $isa
< 3 || $isa
== 32 }]
580 #
Return true
if the given arch
-group option specifies a
64-bit ISA.
581 proc mips_64bit_arch_p
{ option
} {
582 return [expr
{ ![mips_32bit_arch_p $option
] }]
585 #
Return true
if the given abi
-group option implicitly requires
-mgp32.
586 proc mips_32bit_abi_p
{ option
} {
587 switch -glob
-- $option
{
595 #
Return true
if the given abi
-group option implicitly requires
-mgp64.
596 proc mips_64bit_abi_p
{ option
} {
597 switch -glob
-- $option
{
607 #
Return true
if the given abi
-group option implicitly requires
-mlong32.
608 # o64 requires this
for -mabicalls
, but not otherwise
; pick the conservative
609 # case
for simplicity.
610 proc mips_long32_abi_p
{ option
} {
611 switch -glob
-- $option
{
621 #
Return true
if the given abi
-group option implicitly requires
-mlong64.
622 proc mips_long64_abi_p
{ option
} {
623 switch -glob
-- $option
{
631 # Check whether the current target supports all the options that the
632 # current test requires.
Return "" if so, otherwise return one of
633 # the incompatible options. UPSTATUS describes the option
status.
634 proc mips_first_unsupported_option
{ upstatus
} {
635 global mips_option_tests
636 upvar $upstatus
status
638 foreach
{ option code
} [array
get mips_option_tests
] {
639 if { [mips_have_test_option_p
status $option
] } {
640 regsub
-all
"\n" $code "\\n\\\n" asm
641 # Use check_runtime from target
-supports.exp
, which caches
643 if { ![check_runtime mips_option_$option
[subst
{
644 __attribute__
((nomips16
)) int
660 # Initialize this testsuite
for a new test variant.
661 proc mips
-dg
-init
{} {
662 # Invariant information.
663 global mips_option_groups
665 # Internally
-generated information about this run.
666 global mips_base_options
667 global mips_extra_options
669 # Override dg
-options with our mips
-dg
-options routine.
670 rename dg
-options mips
-old
-dg
-options
671 rename mips
-dg
-options dg
-options
673 # Start with a fresh option
status.
674 array unset mips_base_options
675 foreach
{ group regexp
} $mips_option_groups
{
676 set mips_base_options
(option
,$group
) ""
677 set mips_base_options
(explicit_p
,$group
) 0
678 set mips_base_options
(test_option_p
,$group
) 0
681 # Use preprocessor macros to work out as many implicit options as we can.
682 set output
[mips_preprocess
"" {
683 const char
*options
[] = {
684 #
if !defined _MIPS_SIM
686 #elif _MIPS_SIM
==_ABIO32
688 #elif _MIPS_SIM
==_ABIO64
690 #elif _MIPS_SIM
==_ABIN32
696 "-march=" _MIPS_ARCH,
704 #ifdef __mips_hard_float
710 #ifdef __mips_abs2008
716 #ifdef __mips_nan2008
734 #
if _MIPS_SZLONG
== 64
752 #ifdef __mips_paired_single_float
755 "-mno-paired-single",
764 #
if __mips_dsp_rev
>= 2
770 #
if __mips_dsp_rev
>= 1
777 "addressing=absolute",
780 #ifdef __mips_smartmips
795 foreach line
[split $output
"\r\n"] {
796 # Poor man
's string concatenation.
797 regsub -all {" "} $line "" line
798 if { [regexp {"(.*)",} $line dummy option] } {
799 set group [mips_option_group $option]
800 set mips_base_options(option,$group) $option
804 # Process the target's multilib options
, saving
any unrecognized
805 # ones in mips_extra_options.
806 set mips_extra_options
{}
807 foreach option
[split
[board_info target multilib_flags
]] {
808 set group
[mips_option_maybe_group $option
]
809 if { ![string equal $group
""] } {
810 set mips_base_options
(option
,$group
) $option
811 set mips_base_options
(explicit_p
,$group
) 1
813 lappend mips_extra_options $option
818 # Finish a test run started by mips
-dg
-init.
819 proc mips
-dg
-finish
{} {
820 rename dg
-options mips
-dg
-options
821 rename mips
-old
-dg
-options dg
-options
824 # Override dg
-options so that we can
do some MIPS
-specific processing.
825 # All options used in this testsuite must appear in mips_option_groups.
827 # Test options override multilib options. Certain test options can
828 # also imply other test options
, which also override multilib options.
829 # These dependencies are ordered as follows
:
833 #
-mips16
/-mflip
-mips16
-mno
-mips16
835 #
-micromips
-mno
-micromips
837 #
-mips3d
-mno
-mips3d
839 #
-mpaired
-single
-mno
-paired
-single
843 #
-mabs
=2008/-mabs
=legacy
<no option
>
845 #
-mhard
-float
-msoft
-float
849 #
-mrelax
-pic
-calls
-mno
-relax
-pic
-calls
853 #
-mshared
-mno
-shared
857 # addressing
=unknown addressing
=absolute
859 #
-mabicalls
-mno
-abicalls
863 #
<other value
> -mr10k
-cache-barrier
=none
865 #
-mfix
-r10000
-mno
-fix
-r10000
867 #
-mbranch
-likely
-mno
-branch
-likely
869 #
-msmartmips
-mno
-smartmips
873 #
-mexplicit
-relocs
-mno
-explicit
-relocs
881 #
+-- gp
, abi
& arch
---------+
883 #
For these purposes
, the
"gp", "abi" & "arch" option groups are treated
885 proc mips
-dg
-options
{ args } {
887 upvar dg
-extra
-tool
-flags extra_tool_flags
888 upvar dg
-do-what do_what
890 # Invariant information.
891 global mips_option_groups
892 global mips_abi_groups
894 # Information about this run.
895 global mips_base_options
897 if { [llength $
args] >= 3 } {
898 switch { [dg
-process
-target
[lindex $
args 2]] } {
901 "F" { error "[lindex $args 0]: `xfail' not allowed here" }
902 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
906 # Start out with the default option state.
907 array
set options
[array
get mips_base_options
]
909 # Record the options that this test explicitly needs.
910 foreach option
[lindex $
args 1] {
911 set all_but_p
[regexp
{^\
((.
*)\
)$
} $option dummy option
]
912 set group
[mips_option_group $option
]
913 if { [mips_test_option_p options $group
] } {
914 set old
[mips_option options $group
]
915 error
"Inconsistent $group option: $old vs. $option"
917 mips_make_test_option options $option $all_but_p
921 # Handle dependencies between the test options and the optimization ones.
922 mips_option_dependency options
"-fno-unroll-loops" "-fno-unroll-all-loops"
923 mips_option_dependency options
"-pg" "-fno-omit-frame-pointer"
925 # Handle dependencies between options
on the left of the
926 # dependency diagram.
927 mips_option_dependency options
"-mips16" "-mno-micromips"
928 mips_option_dependency options
"-mmicromips" "-mno-mips16"
929 mips_option_dependency options
"-mips3d" "-mpaired-single"
930 mips_option_dependency options
"-mpaired-single" "-mfp64"
931 mips_option_dependency options
"-mfp64" "-mhard-float"
932 mips_option_dependency options
"-mabs=2008" "-mhard-float"
933 mips_option_dependency options
"-mabs=legacy" "-mhard-float"
934 mips_option_dependency options
"-mrelax-pic-calls" "-mno-plt"
935 mips_option_dependency options
"-mrelax-pic-calls" "-mabicalls"
936 mips_option_dependency options
"-mrelax-pic-calls" "-mexplicit-relocs"
937 mips_option_dependency options
"-fpic" "-mshared"
938 mips_option_dependency options
"-mshared" "-mno-plt"
939 mips_option_dependency options
"-mshared" "-mabicalls"
940 mips_option_dependency options
"-mno-plt" "addressing=unknown"
941 mips_option_dependency options
"-mabicalls" "-G0"
942 mips_option_dependency options
"-mno-gpopt" "-mexplicit-relocs"
944 # Work out information about the current ABI.
945 set abi_test_option_p
[mips_test_option_p options abi
]
946 set abi
[mips_option options abi
]
947 set eabi_p
[mips_same_option_p $abi
"-mabi=eabi"]
949 #
If the test forces a particular ABI
, set the register size
951 if { $abi_test_option_p
} {
952 if { [mips_32bit_abi_p $abi
] } {
953 mips_make_test_option options
"-mgp32"
954 } elseif
{ [mips_64bit_abi_p $abi
] } {
955 mips_make_test_option options
"-mgp64"
959 # See whether forbid_cpu forces us to choose a new architecture.
960 set arch
[mips_option mips_base_options arch
]
961 set force_generic_isa_p
[expr
{
962 [regexp
"forbid_cpu=(.*)" [mips_option options forbid_cpu] dummy spec]
963 && [regexp
-- "^-march=$spec\$" $arch]
966 # Interpret the special
"isa" and "isa_rev" options. If we have
967 # a choice of a
32-bit or a
64-bit architecture
, prefer to keep
968 # the
-mgp setting the same.
969 set spec
[mips_option options arch
]
970 if { [regexp
{^
[^
-]} $spec
] } {
971 if { [string equal $spec
"isa=loongson"] } {
972 if { ![regexp
{^
-march
=loongson
} $arch
] } {
973 set arch
"-march=loongson2f"
976 if { ![regexp
{^
(isa
(?
:|_rev
))(=|
<=|
>=)([0-9]*)$
} \
977 $spec dummy prop
relation value nocpus
] } {
978 error
"Unrecognized isa specification: $spec"
980 set current
[mips_arch_info $arch $prop
]
981 if { $force_generic_isa_p
982 ||
($current
< $value
&& ![string equal $
relation "<="])
983 ||
($current
> $value
&& ![string equal $
relation ">="])
984 ||
([mips_have_test_option_p options
"-mgp64"]
985 && [mips_32bit_arch_p $arch
]) } {
986 # The current setting is out of range
; it cannot
987 # possibly be used. Find a replacement that can.
988 if { [string equal $prop
"isa"] } {
989 set arch
"-mips$value"
990 } elseif
{ $value
== 0 } {
993 if { [mips_have_option_p options
"-mgp32"] } {
999 append arch
"r$value"
1004 set options
(option
,arch
) $arch
1007 # Work out information about the current architecture.
1008 set arch_test_option_p
[mips_test_option_p options arch
]
1009 set arch
[mips_option options arch
]
1010 set isa
[mips_arch_info $arch isa
]
1011 set isa_rev
[mips_arch_info $arch isa_rev
]
1013 #
If the test forces a
32-bit architecture
, force
-mgp32.
1014 # Force the current
-mgp setting otherwise
; if we don
't,
1015 # some configurations would make a 64-bit architecture
1017 if { $arch_test_option_p } {
1018 if { [mips_32bit_arch_p $arch] } {
1019 mips_make_test_option options "-mgp32"
1021 mips_make_test_option options [mips_option options gp]
1025 # We've now fixed the GP register size. Make it easily available.
1026 set gp_size
[expr
{ [mips_have_option_p options
"-mgp32"] ? 32 : 64 }]
1028 # Handle dependencies between the pre
-arch options and the arch option.
1029 # This should mirror the arch and post
-arch code below.
1030 if { !$arch_test_option_p
} {
1031 # We need a revision
2 or better ISA
for:
1033 #
- the combination of
-mgp32
-mfp64
1036 && (($gp_size
== 32 && [mips_have_test_option_p options
"-mfp64"])
1037 ||
[mips_have_test_option_p options
"-msynci"]
1038 ||
[mips_have_test_option_p options
"-mdsp"]
1039 ||
[mips_have_test_option_p options
"-mdspr2"]) } {
1040 if { $gp_size
== 32 } {
1041 mips_make_test_option options
"-mips32r2"
1043 mips_make_test_option options
"-mips64r2"
1045 # We need a MIPS32 or MIPS64 ISA
for:
1047 #
- paired
-single instructions
(*)
1049 #
(*) Note that we don
't support MIPS V at the moment.
1050 } elseif { $isa_rev < 1
1051 && [mips_have_test_option_p options "-mpaired-single"] } {
1052 if { $gp_size == 32 } {
1053 mips_make_test_option options "-mips32"
1055 mips_make_test_option options "-mips64"
1057 # We need MIPS III or higher for:
1059 # - the "cache" instruction
1061 && ([mips_have_test_option_p options \
1062 "-mr10k-cache-barrier=load-store"]
1063 || [mips_have_test_option_p options \
1064 "-mr10k-cache-barrier=store"]) } {
1065 mips_make_test_option options "-mips3"
1066 # We need MIPS II or higher for:
1068 # - branch-likely instructions(*)
1070 # (*) needed by both -mbranch-likely and -mfix-r10000
1072 && ([mips_have_test_option_p options "-mbranch-likely"]
1073 || [mips_have_test_option_p options "-mfix-r10000"]) } {
1074 mips_make_test_option options "-mips2"
1075 # Check whether we need to switch from a 32-bit processor to the
1076 # "nearest" 64-bit processor.
1077 } elseif { $gp_size == 64 && [mips_32bit_arch_p $arch] } {
1078 if { $isa_rev == 0 } {
1079 mips_make_test_option options "-mips3"
1080 } elseif { $isa_rev == 1 } {
1081 mips_make_test_option options "-mips64"
1083 mips_make_test_option options "-mips64r$isa_rev"
1085 # Otherwise, if the current choice of architecture is unacceptable,
1086 # choose the equivalent generic architecture.
1087 } elseif { $force_generic_isa_p } {
1088 set arch "-mips[mips_arch_info $arch isa]"
1089 if { $isa_rev > 1 } {
1090 append arch "r$isa_rev"
1092 mips_make_test_option options $arch
1099 # Set an appropriate ABI, handling dependencies between the pre-abi
1100 # options and the abi options. This should mirror the abi and post-abi
1102 if { !$abi_test_option_p } {
1104 && ([mips_have_option_p options "-mabicalls"]
1106 && [mips_have_option_p options "-mfp64"]))) } {
1107 # EABI doesn't support
-mabicalls.
1108 # EABI doesn
't support the combination -mgp32 -mfp64.
1110 } elseif { [mips_using_mips16_p options]
1111 && ![mips_same_option_p $abi "-mabi=32"]
1112 && ![mips_same_option_p $abi "-mabi=o64"]
1113 && (![mips_have_option_p options "addressing=absolute"]
1114 || [mips_have_option_p options "-mhard-float"]) } {
1115 # -mips16 -mhard-float requires o32 or o64.
1116 # -mips16 PIC requires o32 or o64.
1118 } elseif { [mips_have_test_option_p options "-mlong32"]
1119 && [mips_long64_abi_p $abi] } {
1121 } elseif { [mips_have_test_option_p options "-mlong64"]
1122 && [mips_long32_abi_p $abi] } {
1127 if { $gp_size == 32 } {
1128 if { $force_abi || [mips_64bit_abi_p $abi] } {
1129 if { [mips_have_test_option_p options "-mlong64"] } {
1130 mips_make_test_option options "-mabi=eabi"
1131 mips_make_test_option options "-mgp32"
1133 mips_make_test_option options "-mabi=32"
1137 if { $force_abi || [mips_32bit_abi_p $abi] } {
1138 if { [mips_have_test_option_p options "-mlong64"] } {
1139 mips_make_test_option options "-mabi=eabi"
1140 mips_make_test_option options "-mgp64"
1142 # All configurations should have an assembler that
1143 # supports o64, since it requires the same BFD target
1144 # vector as o32. In contrast, many assembler
1145 # configurations do not have n32 or n64 support.
1146 mips_make_test_option options "-mabi=o64"
1150 set abi_test_option_p [mips_test_option_p options abi]
1151 set abi [mips_option options abi]
1152 set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
1155 # Handle dependencies between the abi options and the post-abi options.
1156 # This should mirror the abi and pre-abi code above.
1157 if { $abi_test_option_p } {
1159 mips_make_test_option options "-mno-abicalls"
1160 if { $gp_size == 32 } {
1161 mips_make_test_option options "-mfp32"
1164 if { [mips_using_mips16_p options]
1165 && ![mips_same_option_p $abi "-mabi=32"]
1166 && ![mips_same_option_p $abi "-mabi=o64"]
1167 && (![mips_have_option_p options "addressing=absolute"]
1168 || [mips_have_option_p options "-mhard-float"]) } {
1169 if { [mips_test_option_p options mips16] } {
1170 mips_make_test_option options "addressing=absolute"
1171 mips_make_test_option options "-msoft-float"
1173 mips_make_test_option options "-mno-mips16"
1176 if { [mips_long32_abi_p $abi] } {
1177 mips_make_test_option options "-mlong32"
1178 } elseif { [mips_long64_abi_p $abi] } {
1179 mips_make_test_option options "-mlong64"
1183 # Handle dependencies between the arch option and the post-arch options.
1184 # This should mirror the arch and pre-arch code above.
1185 if { $arch_test_option_p } {
1187 mips_make_test_option options "-mno-branch-likely"
1188 mips_make_test_option options "-mno-fix-r10000"
1191 mips_make_test_option options "-mr10k-cache-barrier=none"
1193 if { $isa_rev < 1 } {
1194 mips_make_test_option options "-mno-paired-single"
1196 if { $isa_rev < 2 } {
1197 if { $gp_size == 32 } {
1198 mips_make_test_option options "-mfp32"
1200 mips_make_test_option options "-mno-dsp"
1201 mips_make_test_option options "-mno-synci"
1208 # Handle dependencies between options on the right of the diagram.
1209 mips_option_dependency options "-mno-dsp" "-mno-dspr2"
1210 mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
1211 switch -- [mips_test_option options small-data] {
1215 mips_make_test_option options "-mno-abicalls"
1218 if { [mips_have_option_p options "-mabicalls"] } {
1219 mips_option_dependency options "addressing=absolute" "-mplt"
1221 mips_option_dependency options "-mplt" "-msym32"
1222 mips_option_dependency options "-mplt" "-mno-shared"
1223 mips_option_dependency options "-mno-shared" "-fno-pic"
1224 mips_option_dependency options "-mfp32" "-mno-paired-single"
1225 mips_option_dependency options "-msoft-float" "-mno-paired-single"
1226 mips_option_dependency options "-mno-paired-single" "-mno-mips3d"
1228 # If the test requires an unsupported option, change run tests
1231 switch -- [lindex $do_what 0] {
1233 set option [mips_first_unsupported_option options]
1234 if { ![string equal $option ""] } {
1235 set do_what [lreplace $do_what 0 0 link]
1236 verbose -log "Downgraded to a 'link
' test due to unsupported option '$option
'"
1241 # If the test has overridden a option that changes the ABI,
1242 # downgrade a link or execution test to an assembler test.
1243 foreach group $mips_abi_groups {
1244 set old_option [mips_original_option $group]
1245 set new_option [mips_option options $group]
1246 if { ![mips_same_option_p $old_option $new_option] } {
1247 switch -- [lindex $do_what 0] {
1250 set do_what [lreplace $do_what 0 0 assemble]
1251 verbose -log "Downgraded to an 'assemble
' test due to incompatible $group option ($old_option changed to $new_option)"
1258 # Add all options to the dg variable.
1259 set options(explicit_p,addressing) 0
1260 set options(explicit_p,forbid_cpu) 0
1261 foreach { group regexp } $mips_option_groups {
1262 if { $options(explicit_p,$group) } {
1263 append extra_tool_flags " " $options(option,$group)
1267 # If the test is MIPS16-compatible, provide a counterpart to the
1268 # NOMIPS16 convenience macro.
1269 if { [mips_have_test_option_p options "-mips16"] } {
1270 append extra_tool_flags " -DMIPS16=__attribute__((mips16))"
1273 if { [mips_have_test_option_p options "-mmicromips"] } {
1274 append extra_tool_flags " -DMICROMIPS=__attribute__((micromips))"
1277 # Use our version of gcc-dg-test for this test.
1278 if { ![string equal [info procs "mips-gcc-dg-test"] ""] } {
1279 rename gcc-dg-test mips-old-gcc-dg-test
1280 rename mips-gcc-dg-test gcc-dg-test
1284 # A version of gcc-dg-test that is used by dg-options tests.
1285 proc mips-gcc-dg-test { prog do_what extra_tool_flags } {
1287 global mips_extra_options
1289 # Override the user's chosen test options with the combined test
/user
1291 mips_push_test_options saved_options $mips_extra_options
1292 set result
[gcc
-dg
-test
-1 gcc_target_compile $prog \
1293 $do_what $extra_tool_flags
]
1294 mips_pop_test_options saved_options
1296 # Restore the usual gcc
-dg
-test.
1297 rename gcc
-dg
-test mips
-gcc
-dg
-test
1298 rename mips
-old
-gcc
-dg
-test gcc
-dg
-test
1305 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/*.c
]] \
1306 "-DNOMIPS16=__attribute__((nomips16)) -DNOMICROMIPS=__attribute__((nomicromips)) -DNOCOMPRESSION=__attribute__((nocompression))"