1 # Copyright
(C
) 1997-2018 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
146 # select a P5600 processor
148 # addressing=absolute
149 # force absolute addresses to be used
152 # forbid processors that match the given regexp; choose a
153 # generic ISA instead.
158 # (1) Try to avoid { target ... } requirements wherever possible.
159 # Specify the requirements as dg-options instead.
161 # (2) Don't worry about the consequences of
(1) for link and run tests.
162 #
If the test uses
{ dg
-do link
} or
{ dg
-do run
}, and its
163 # dg
-options are incompatible with the current target
, the
164 # testsuite will downgrade them where necessary.
166 #
(3) Try to use the bare minimum of options and leave dg
-options
167 # to work out the dependencies.
For example
, if you want
168 # a MIPS
-3D test
, you should generally just specify
-mips3d.
169 # Don
't specify an architecture option like -mips64 unless
170 # the test really doesn't work with
-mips32r2
, -mips64r2
,
173 #
(4) If you want something compatible with a particular option
,
174 # but don
't want to pass the option itself, wrap that option
175 # in parentheses. In particular, pass '(-mips16
)' if you
176 # want to use "mips16" attributes.
178 # (5) When testing a feature of a generic ISA (as opposed to a
179 # processor-specific extension), try to use the "isa" and
180 # "isa_rev" pseudo-options instead of specific architecture
181 # options. For example, if the feature is present on revision 2
182 # processors and above, try to use "isa_rev>=2" instead of
183 # "-mips32r2" or "-mips64r2".
185 # (6) If you need to disable processor-specific extensions use
186 # forbid_cpu=REGEXP instead of forcing a generic ISA.
191 # Option group or just group:
192 # See comment before mips_option_groups.
195 # The options specified in dg-options.
198 # The options that were either passed to runtest as "multilib" options
199 # (e.g. -mips4 in --target_board=mips-sim-idt/-mips4) or specified as
200 # test options. Note that options in parenthesis (i.e. (-mips16)) are
201 # not explicit and can be omitted depending on the base options.
204 # Options that are on by default without being specified in dg-options,
205 # e.g. -march=mips64r2 for mipsisa64r2-elf or because they've been
206 # passed to runtest as
"multilib" options.
209 # Many functions in this file work with option arrays. These are
210 # two
-dimensional Tcl arrays where the first
dimension can have three
211 #
values: option
, explicit_p or test_option_p. The second
dimension is
212 # the
name of the option group.
"option" contains the name of the
213 # option that is in effect from this group.
If no option is active it
214 # contains the empty string. The flags
"explicit_p" and "test_option_p"
215 # are
set for explicit and test options.
217 # Exit immediately
if this isn
't a MIPS target.
218 if ![istarget mips*-*-*] {
222 # Load support procs.
225 # A list of GROUP REGEXP pairs. Each GROUP represents a logical group of
226 # options from which only one option should be chosen. REGEXP matches all
227 # the options in that group; it is implicitly wrapped in "^(...)$".
229 # Note that -O* is deliberately omitted from this list. Tests in this
230 # directory are run at various optimisation levels and should use
231 # dg-skip-if to skip any incompatible levels.
232 set mips_option_groups {
234 addressing "addressing=.*"
235 arch "-mips([1-5]|32.*|64.*)|-march=.*|isa(|_rev)(=|<=|>=).*"
238 endianness "-E(L|B)|-me(l|b)"
239 float "-m(hard|soft)-float"
240 fpu "-m(double|single)-float"
241 forbid_cpu "forbid_cpu=.*"
245 micromips "-mmicromips|-mno-micromips"
246 mips16 "-mips16|-mno-mips16|-mflip-mips16"
247 mips3d "-mips3d|-mno-mips3d"
248 pic "-f(no-|)(pic|PIC)"
249 cb "-mcompact-branches=.*"
251 small-data "-G[0-9]+"
259 madd4_ghost "HAS_MADD4"
263 section_start "-Wl,--section-start=.*"
264 frame-header "-mframe-header-opt|-mno-frame-header-opt"
265 stack-protector "-fstack-protector"
266 stdlib "REQUIRES_STDLIB"
269 for { set option 0 } { $option < 32 } { incr option } {
270 lappend mips_option_groups "fixed-f$option" "-ffixed-f$option"
273 # Add -mfoo/-mno-foo options to mips_option_groups.
300 lappend mips_option_groups $option "-m(no-|)$option"
303 # Add -mfoo= options to mips_option_groups.
312 lappend mips_option_groups $option "-m$option=.*"
315 # Add -ffoo/-fno-foo options to mips_option_groups.
319 expensive-optimizations
325 lax-vector-conversions
327 optimize-sibling-calls
336 lappend mips_option_groups $option "-f(no-|)$option"
339 # A list of option groups that have an impact on the ABI.
340 set mips_abi_groups {
354 # mips_option_tests(OPTION) is some assembly code that will run to completion
355 # on a target that supports OPTION.
356 set mips_option_tests(-mips16) {
368 set mips_option_tests(-mmicromips) {
381 set mips_option_tests(-mpaired-single) {
387 set mips_option_tests(-mips3d) {
397 madd.s $f4,$f2,$f2,$f4
399 set mips_option_tests(-mdsp) {
404 set mips_option_tests(-mdspr2) {
409 set mips_option_tests(-mcode-readable=yes) {
431 # Canonicalize command-line option OPTION.
432 proc mips_canonicalize_option { option } {
433 regsub {^-mips([1-5]|32*|64*)$} $option {-march=mips\1} option
435 regsub {^-mel$} $option {-EL} option
436 regsub {^-meb$} $option {-EB} option
438 regsub {^-O$} $option {-O1} option
440 # MIPS doesn't use
-fpic and
-fPIC to distinguish between code models.
441 regsub
{^
-f
(no
-|
)PIC
} $option
{-f\
1pic
} option
446 #
Return true
if OPTION1 and OPTION2 represent the same command
-line option.
447 proc mips_same_option_p
{ option1 option2
} {
448 return [string equal \
449 [mips_canonicalize_option $option1
] \
450 [mips_canonicalize_option $option2
]]
453 # Preprocess CODE using target_compile options OPTIONS.
Return the
455 proc mips_preprocess
{ options code ignore_output
} {
459 set f
[open $src
"w"]
462 if { $ignore_output
} {
463 set output
[$
{tool
}_target_compile $src dummy
[pid
].i preprocess $options
]
464 file
delete dummy
[pid
].i
466 set output
[$
{tool
}_target_compile $src
"" preprocess $options]
473 #
Set the target board
's command-line options to NEW_OPTIONS, storing the
474 # old values in UPVAR.
475 proc mips_push_test_options { upvar new_options } {
480 set var(name) board_info([target_info name],multilib_flags)
481 if { [info exists $var(name)] } {
482 set var(old_options) [set $var(name)]
483 set $var(name) [join $new_options " "]
487 # Undo the effects of [mips_push_test_options UPVAR ...]
488 proc mips_pop_test_options { upvar } {
492 if { [info exists var(old_options)] } {
493 set $var(name) $var(old_options)
497 # Return property PROP for architecture option ARCH (which belongs to
498 # the "arch" group in mips_option_groups). See the comment at the
499 # top of the file for the valid property names.
501 # Cache the results in mips_arch_info (which can be reused between test
503 proc mips_arch_info { arch prop } {
504 global mips_arch_info
507 set arch [mips_canonicalize_option $arch]
508 if { ![info exists mips_arch_info($arch,$prop)] } {
509 mips_push_test_options saved_options {}
510 set output [mips_preprocess [list "additional_flags=$arch -mabi=32"] {
512 #ifdef __mips_isa_rev
513 int isa_rev = __mips_isa_rev;
518 foreach lhs { isa isa_rev } {
519 regsub ".*$lhs = (\[^;\]*).*" $output {\1} rhs
520 verbose -log "Architecture $arch has $lhs $rhs"
521 set mips_arch_info($arch,$lhs) $rhs
523 mips_pop_test_options saved_options
525 return $mips_arch_info($arch,$prop)
528 # Return the option group associated with OPTION, or "" if none.
529 proc mips_option_maybe_group { option } {
530 global mips_option_groups
532 foreach { group regexp } $mips_option_groups {
533 if { [regexp -- "^($regexp)\$" $option] } {
540 # Return the option group associated with OPTION. Raise an error if
542 proc mips_option_group { option } {
543 set group [mips_option_maybe_group $option]
544 if { [string equal $group ""] } {
545 error "Unrecognised option: $option"
550 # Return the option for option group GROUP, or "" if no option in that
551 # group has been chosen. UPSTATUS describes the option status.
552 proc mips_option { upstatus group } {
553 upvar $upstatus status
555 return $status(option,$group)
558 # If the base options for this test run include an option in group GROUP,
559 # return that option, otherwise return "".
560 proc mips_original_option { group } {
561 global mips_base_options
563 return [mips_option mips_base_options $group]
566 # Return true if the test described by UPSTATUS requires a specific
567 # option in group GROUP. UPSTATUS describes the option status.
568 proc mips_test_option_p { upstatus group } {
569 upvar $upstatus status
571 return $status(test_option_p,$group)
574 # If the test described by UPSTATUS requires a particular option in group
575 # GROUP, return that option, otherwise return "".
576 proc mips_test_option { upstatus group } {
577 upvar $upstatus status
579 if { [mips_test_option_p status $group] } {
580 return [mips_option status $group]
586 # Return true if the options described by UPSTATUS include OPTION.
587 proc mips_have_option_p { upstatus option } {
588 upvar $upstatus status
590 return [mips_same_option_p \
591 [mips_option status [mips_option_group $option]] \
595 # Return true if the options described by UPSTATUS require MIPS16 support.
596 proc mips_using_mips16_p { upstatus } {
597 upvar $upstatus status
599 return [expr { [mips_have_option_p status "-mips16"]
600 || [mips_have_option_p status "-mflip-mips16"] }]
603 # Return true if the test described by UPSTATUS requires option OPTION.
604 proc mips_have_test_option_p { upstatus option } {
605 upvar $upstatus status
607 set group [mips_option_group $option]
608 return [mips_same_option_p [mips_test_option status $group] $option]
611 # If the test described by UPSTATUS does not specify an option in
612 # OPTION's group
, act as though it had specified OPTION.
614 # The first optional
argument indicates whether the option should be
615 # treated as though it were wrapped in parentheses
; see the comment at
616 # the top of the file
for details about this convention. The default is
0.
617 proc mips_make_test_option
{ upstatus option
args } {
618 upvar $upstatus
status
620 set group
[mips_option_group $option
]
621 if { ![mips_test_option_p
status $group
] } {
622 set status(option
,$group
) $option
623 set status(test_option_p
,$group
) 1
624 if { [llength $
args] == 0 ||
![lindex $
args 0] } {
625 set status(explicit_p
,$group
) 1
630 #
If the test described by UPSTATUS requires option FROM
, assume that
631 # it implicitly requires option TO.
632 proc mips_option_dependency
{ upstatus from to
} {
633 upvar $upstatus
status
635 if { [mips_have_test_option_p
status $from
] } {
636 mips_make_test_option
status $to
640 #
Return true
if the given arch
-group option specifies a
32-bit ISA.
641 proc mips_32bit_arch_p
{ option
} {
642 set isa
[mips_arch_info $option isa
]
643 return [expr
{ $isa
< 3 || $isa
== 32 }]
646 #
Return true
if the given arch
-group option specifies a
64-bit ISA.
647 proc mips_64bit_arch_p
{ option
} {
648 return [expr
{ ![mips_32bit_arch_p $option
] }]
651 #
Return true
if the given abi
-group option implicitly requires
-mgp32.
652 proc mips_32bit_abi_p
{ option
} {
653 switch -glob
-- $option
{
661 #
Return true
if the given abi
-group option implicitly requires
-mgp64.
662 proc mips_64bit_abi_p
{ option
} {
663 switch -glob
-- $option
{
673 #
Return true
if the given abi
-group option implicitly requires
-mlong32.
674 # o64 requires this
for -mabicalls
, but not otherwise
; pick the conservative
675 # case
for simplicity.
676 proc mips_long32_abi_p
{ option
} {
677 switch -glob
-- $option
{
687 #
Return true
if the given abi
-group option implicitly requires
-mlong64.
688 proc mips_long64_abi_p
{ option
} {
689 switch -glob
-- $option
{
697 # Check whether the current target supports all the options that the
698 # current test requires.
Return "" if so, otherwise return one of
699 # the incompatible options. UPSTATUS describes the option
status.
700 proc mips_first_unsupported_option
{ upstatus
} {
701 global mips_option_tests
702 upvar $upstatus
status
704 foreach
{ option code
} [array
get mips_option_tests
] {
705 if { [mips_have_test_option_p
status $option
] } {
706 regsub
-all
"\n" $code "\\n\\\n" asm
707 # Use check_runtime from target
-supports.exp
, which caches
709 if { ![check_runtime mips_option_$option
[subst
{
710 __attribute__
((nomips16
)) int
726 # Initialize this testsuite
for a new test variant.
727 proc mips
-dg
-init
{} {
728 # Invariant information.
729 global mips_option_groups
731 # Internally
-generated information about this run.
732 global mips_base_options
733 global mips_extra_options
735 # Override dg
-options with our mips
-dg
-options routine.
736 rename dg
-options mips
-old
-dg
-options
737 rename mips
-dg
-options dg
-options
739 # Start with a fresh option
status.
740 array unset mips_base_options
741 foreach
{ group regexp
} $mips_option_groups
{
742 set mips_base_options
(option
,$group
) ""
743 set mips_base_options
(explicit_p
,$group
) 0
744 set mips_base_options
(test_option_p
,$group
) 0
747 # Use preprocessor macros to work out as many implicit options as we can.
748 set output
[mips_preprocess
"" {
749 const char
*options
[] = {
750 #
if !defined _MIPS_SIM
752 #elif _MIPS_SIM
==_ABIO32
754 #elif _MIPS_SIM
==_ABIO64
756 #elif _MIPS_SIM
==_ABIN32
762 "-march=" _MIPS_ARCH,
770 #ifdef __mips_hard_float
776 #ifdef __mips_abs2008
782 #ifdef __mips_nan2008
804 #
if _MIPS_SZLONG
== 64
822 #ifdef __mips_paired_single_float
825 "-mno-paired-single",
828 #
if _MIPS_SPFPSET
== 32
840 #
if __mips_dsp_rev
>= 2
846 #
if __mips_dsp_rev
>= 1
853 "addressing=absolute",
856 #ifdef __mips_smartmips
862 #ifdef __mips_no_lxc1_sxc1
868 #ifdef __mips_no_madd4
889 foreach line
[split $output
"\r\n"] {
890 # Poor man
's string concatenation.
891 regsub -all {" "} $line "" line
892 if { [regexp {"(.*)",} $line dummy option] } {
893 set group [mips_option_group $option]
894 set mips_base_options(option,$group) $option
898 # Process the target's multilib options
, saving
any unrecognized
899 # ones in mips_extra_options.
900 set mips_extra_options
{}
901 foreach option
[split
[board_info target multilib_flags
]] {
902 set group
[mips_option_maybe_group $option
]
903 if { ![string equal $group
""] } {
904 set mips_base_options
(option
,$group
) $option
905 set mips_base_options
(explicit_p
,$group
) 1
907 lappend mips_extra_options $option
912 # Finish a test run started by mips
-dg
-init.
913 proc mips
-dg
-finish
{} {
914 rename dg
-options mips
-dg
-options
915 rename mips
-old
-dg
-options dg
-options
918 # Override dg
-options so that we can
do some MIPS
-specific processing.
919 # All options used in this testsuite must appear in mips_option_groups.
921 # Test options override multilib options. Certain test options can
922 # also imply other test options
, which also override multilib options.
923 # These dependencies are ordered as follows
:
927 #
-mips16
/-mflip
-mips16
-mno
-mips16
929 #
-micromips
-mno
-micromips
931 #
-mips3d
-mno
-mips3d
933 #
-mpaired
-single
-mno
-paired
-single
937 #
-modd
-spreg
-mno
-odd
-spreg
939 #
-mdouble
-float
-msingle
-float
941 #
-mabs
=2008/-mabs
=legacy
<no option
>
943 #
-mhard
-float
-msoft
-float
947 #
-mrelax
-pic
-calls
-mno
-relax
-pic
-calls
951 #
-mshared
-mno
-shared
955 # addressing
=unknown addressing
=absolute
957 #
-mabicalls
-mno
-abicalls
961 #
<other value
> -mr10k
-cache-barrier
=none
963 #
-mfix
-r10000
-mno
-fix
-r10000
965 #
-mbranch
-likely
-mno
-branch
-likely
967 #
-msmartmips
-mno
-smartmips
971 #
-mexplicit
-relocs
-mno
-explicit
-relocs
979 #
+-- gp
, abi
& arch
---------+
981 #
For these purposes
, the
"gp", "abi" & "arch" option groups are treated
983 proc mips
-dg
-options
{ args } {
985 upvar dg
-extra
-tool
-flags extra_tool_flags
986 upvar dg
-do-what do_what
988 # Invariant information.
989 global mips_option_groups
990 global mips_abi_groups
992 # Information about this run.
993 global mips_base_options
995 if { [llength $
args] >= 3 } {
996 switch { [dg
-process
-target
[lindex $
args 2]] } {
999 "F" { error "[lindex $args 0]: `xfail' not allowed here" }
1000 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
1004 # Start out with the default option state.
1005 array
set options
[array
get mips_base_options
]
1007 # Record the options that this test explicitly needs.
1008 foreach option
[lindex $
args 1] {
1009 set all_but_p
[regexp
{^\
((.
*)\
)$
} $option dummy option
]
1010 set group
[mips_option_group $option
]
1011 if { [mips_test_option_p options $group
] } {
1012 set old
[mips_option options $group
]
1013 error
"Inconsistent $group option: $old vs. $option"
1015 mips_make_test_option options $option $all_but_p
1019 # Handle dependencies between the test options and the optimization ones.
1020 mips_option_dependency options
"-fno-unroll-loops" "-fno-unroll-all-loops"
1021 mips_option_dependency options
"-pg" "-fno-omit-frame-pointer"
1023 # Handle dependencies between options
on the left of the
1024 # dependency diagram.
1025 mips_option_dependency options
"-mips16" "-mno-micromips"
1026 mips_option_dependency options
"-mmicromips" "-mno-mips16"
1027 mips_option_dependency options
"-mips3d" "-mpaired-single"
1028 mips_option_dependency options
"-mips3d" "-mno-micromips"
1029 mips_option_dependency options
"-mpaired-single" "-mfp64"
1030 mips_option_dependency options
"-mfp64" "-mhard-float"
1031 mips_option_dependency options
"-mfp32" "-mhard-float"
1032 mips_option_dependency options
"-mfpxx" "-mhard-float"
1033 mips_option_dependency options
"-mfp64" "-modd-spreg"
1034 mips_option_dependency options
"-mfp64" "-mdouble-float"
1035 mips_option_dependency options
"-mfp32" "-mdouble-float"
1036 mips_option_dependency options
"-mfpxx" "-mdouble-float"
1037 mips_option_dependency options
"-mabs=2008" "-mhard-float"
1038 mips_option_dependency options
"-mabs=legacy" "-mhard-float"
1039 mips_option_dependency options
"-mrelax-pic-calls" "-mno-plt"
1040 mips_option_dependency options
"-mrelax-pic-calls" "-mabicalls"
1041 mips_option_dependency options
"-mrelax-pic-calls" "-mexplicit-relocs"
1042 mips_option_dependency options
"-fpic" "-mshared"
1043 mips_option_dependency options
"-mshared" "-mno-plt"
1044 mips_option_dependency options
"-mshared" "-mabicalls"
1045 mips_option_dependency options
"-mno-plt" "addressing=unknown"
1046 mips_option_dependency options
"-mabicalls" "-G0"
1047 mips_option_dependency options
"-mno-gpopt" "-mexplicit-relocs"
1049 # Work out information about the current ABI.
1050 set abi_test_option_p
[mips_test_option_p options abi
]
1051 set abi
[mips_option options abi
]
1052 set eabi_p
[mips_same_option_p $abi
"-mabi=eabi"]
1054 #
If the test forces a particular ABI
, set the register size
1056 if { $abi_test_option_p
} {
1057 if { [mips_32bit_abi_p $abi
] } {
1058 mips_make_test_option options
"-mgp32"
1059 } elseif
{ [mips_64bit_abi_p $abi
] } {
1060 mips_make_test_option options
"-mgp64"
1064 # See whether forbid_cpu forces us to choose a new architecture.
1065 set arch
[mips_option mips_base_options arch
]
1066 set force_generic_isa_p
[expr
{
1067 [regexp
"forbid_cpu=(.*)" [mips_option options forbid_cpu] dummy spec]
1068 && [regexp
-- "^-march=$spec\$" $arch]
1071 # Interpret the special
"isa" and "isa_rev" options. If we have
1072 # a choice of a
32-bit or a
64-bit architecture
, prefer to keep
1073 # the
-mgp setting the same.
1074 set spec
[mips_option options arch
]
1075 if { [regexp
{^
[^
-]} $spec
] } {
1076 if { [string equal $spec
"isa=loongson"] } {
1077 if { ![regexp
{^
-march
=loongson
} $arch
] } {
1078 set arch
"-march=loongson2f"
1080 } elseif
{ [string equal $spec
"isa=p5600"] } {
1081 if { ![regexp
{^
-march
=p5600
} $arch
] } {
1082 set arch
"-march=p5600"
1085 if { ![regexp
{^
(isa
(?
:|_rev
))(=|
<=|
>=)([0-9]*)$
} \
1086 $spec dummy prop
relation value nocpus
] } {
1087 error
"Unrecognized isa specification: $spec"
1089 set current
[mips_arch_info $arch $prop
]
1090 if { $force_generic_isa_p
1091 ||
($current
< $value
&& ![string equal $
relation "<="])
1092 ||
($current
> $value
&& ![string equal $
relation ">="])
1093 ||
([mips_have_test_option_p options
"-mgp64"]
1094 && [mips_32bit_arch_p $arch
]) } {
1095 # The current setting is out of range
; it cannot
1096 # possibly be used. Find a replacement that can.
1097 if { [string equal $prop
"isa"] } {
1098 set arch
"-mips$value"
1099 } elseif
{ $value
== 0 } {
1102 if { [mips_have_option_p options
"-mgp32"] } {
1108 append arch
"r$value"
1113 set options
(option
,arch
) $arch
1116 # Work out information about the current architecture.
1117 set arch_test_option_p
[mips_test_option_p options arch
]
1118 set arch
[mips_option options arch
]
1119 set isa
[mips_arch_info $arch isa
]
1120 set isa_rev
[mips_arch_info $arch isa_rev
]
1121 set orig_isa_rev $isa_rev
1123 #
If the test forces a
32-bit architecture
, force
-mgp32.
1124 # Force the current
-mgp setting otherwise
; if we don
't,
1125 # some configurations would make a 64-bit architecture
1127 if { $arch_test_option_p } {
1128 if { [mips_32bit_arch_p $arch] } {
1129 mips_make_test_option options "-mgp32"
1131 mips_make_test_option options [mips_option options gp]
1135 # We've now fixed the GP register size. Make it easily available.
1136 set gp_size
[expr
{ [mips_have_option_p options
"-mgp32"] ? 32 : 64 }]
1138 # Handle dependencies between the pre
-arch options and the arch option.
1139 # This should mirror the arch and post
-arch code below.
1140 if { !$arch_test_option_p
} {
1141 # We need a revision
6 or better ISA
for:
1143 #
- When the LSA instruction is required
1144 #
- When only using compact branches
1146 && ([mips_have_test_option_p options
"HAS_LSA"]
1147 ||
[mips_have_test_option_p options
"-mcompact-branches=always"]) } {
1148 if { $gp_size
== 32 } {
1149 mips_make_test_option options
"-mips32r6"
1151 mips_make_test_option options
"-mips64r6"
1153 # We need a revision
2 or better ISA
for:
1155 #
- the combination of
-mgp32
-mfp64
1157 } elseif
{ $isa_rev
< 2
1158 && (($gp_size
== 32 && [mips_have_test_option_p options
"-mfp64"])
1159 ||
[mips_have_test_option_p options
"-msynci"]
1160 ||
[mips_have_test_option_p options
"-mdsp"]
1161 ||
[mips_have_test_option_p options
"HAS_INS"]
1162 ||
[mips_have_test_option_p options
"HAS_MADD"]
1163 ||
[mips_have_test_option_p options
"HAS_MADDPS"]
1164 ||
[mips_have_test_option_p options
"-mdspr2"]
1165 ||
[mips_have_test_option_p options
"-mnan=2008"]
1166 ||
[mips_have_test_option_p options
"-mabs=2008"]
1167 ||
[mips_have_test_option_p options
"-mmicromips"]) } {
1168 if { $gp_size
== 32 } {
1169 mips_make_test_option options
"-mips32r2"
1171 mips_make_test_option options
"-mips64r2"
1173 # We need a MIPS32 or MIPS64 ISA
for:
1175 #
- paired
-single instructions
(*)
1176 #
- odd numbered single precision registers
1178 #
(*) Note that we don
't support MIPS V at the moment.
1179 } elseif { $isa_rev < 1
1180 && ([mips_have_test_option_p options "-mpaired-single"]
1181 || ([mips_have_test_option_p options "-modd-spreg"]
1182 && ![mips_have_test_option_p options "-mfp64"]))} {
1183 if { $gp_size == 32 } {
1184 mips_make_test_option options "-mips32"
1186 mips_make_test_option options "-mips64"
1188 # We need MIPS IV or higher for:
1192 && ([mips_have_test_option_p options "HAS_LXC1"]
1193 || [mips_have_test_option_p options "HAS_MADD4"]
1194 || [mips_have_test_option_p options "HAS_MOVN"]) } {
1195 mips_make_test_option options "-mips4"
1196 # We need MIPS III or higher for:
1198 # - the "cache" instruction
1200 && ([mips_have_test_option_p options \
1201 "-mr10k-cache-barrier=load-store"]
1202 || [mips_have_test_option_p options \
1203 "-mr10k-cache-barrier=store"]) } {
1204 mips_make_test_option options "-mips3"
1205 # We need MIPS II or higher for:
1207 # - branch-likely instructions(*)
1209 # (*) needed by both -mbranch-likely and -mfix-r10000
1211 && ([mips_have_test_option_p options "-mbranch-likely"]
1212 || [mips_have_test_option_p options "-mfix-r10000"]
1214 && ([mips_have_test_option_p options "-mfpxx"]
1215 || [mips_have_test_option_p options "HAS_LDC"]))) } {
1216 mips_make_test_option options "-mips2"
1217 # We need to use octeon's base ISA
if a test must not run with an
1218 # architecture that supports dmul.
1219 } elseif
{ [regexp
-- "^-march=octeon.*\$" $arch]
1220 && [mips_have_test_option_p options
"NOT_HAS_DMUL"] } {
1221 mips_make_test_option options
"-mips${isa}r${isa_rev}"
1222 # Check whether we need to
switch from mips
*r6 down to mips
*r5 due
1223 # to options that are incompatible with mips
*r6.
If we
do, use
1224 #
-mnan
=2008 because r6 is nan2008 by default and without this flag
1225 # tests that
include stdlib.h will fail due to not finding
1226 # stubs
-o32_hard.h
(r6 compilers only have stubs
-o32_hard_2008.h
)
1227 } elseif
{ $isa_rev
> 5
1228 && ([mips_have_test_option_p options
"-mdsp"]
1229 ||
[mips_have_test_option_p options
"-mdspr2"]
1230 ||
[mips_have_test_option_p options
"-mips16"]
1231 ||
[mips_have_test_option_p options
"-mmicromips"]
1232 ||
[mips_have_test_option_p options
"-mfp32"]
1233 ||
[mips_have_test_option_p options
"-mfix-r10000"]
1234 ||
[mips_have_test_option_p options
"NOT_HAS_DMUL"]
1235 ||
[mips_have_test_option_p options
"HAS_LXC1"]
1236 ||
[mips_have_test_option_p options
"HAS_MADD"]
1237 ||
[mips_have_test_option_p options
"HAS_MADD4"]
1238 ||
[mips_have_test_option_p options
"HAS_MOVN"]
1239 ||
[mips_have_test_option_p options
"-mpaired-single"]
1240 ||
[mips_have_test_option_p options
"-mnan=legacy"]
1241 ||
[mips_have_test_option_p options
"-mabs=legacy"]
1242 ||
[mips_have_test_option_p options
"!HAS_LSA"]
1243 ||
[mips_have_test_option_p options
"-mbranch-likely"]) } {
1244 if { $gp_size
== 32 } {
1245 mips_make_test_option options
"-mips32r5"
1247 mips_make_test_option options
"-mips64r5"
1249 mips_make_test_option options
"-mnan=2008"
1250 if { [mips_have_option_p options
"-mcompact-branches=always"] } {
1251 mips_make_test_option options
"-mcompact-branches=optimal"
1253 # Check whether we need to
switch from a
32-bit processor to the
1254 #
"nearest" 64-bit processor.
1255 } elseif
{ $gp_size
== 64 && [mips_32bit_arch_p $arch
] } {
1256 if { $isa_rev
== 0 } {
1257 mips_make_test_option options
"-mips3"
1258 } elseif
{ $isa_rev
== 1 } {
1259 mips_make_test_option options
"-mips64"
1261 mips_make_test_option options
"-mips64r$isa_rev"
1263 # Otherwise
, if the current choice of architecture is unacceptable
,
1264 # choose the equivalent generic architecture.
1265 } elseif
{ $force_generic_isa_p
} {
1266 set arch
"-mips[mips_arch_info $arch isa]"
1267 if { $isa_rev
> 1 } {
1268 append arch
"r$isa_rev"
1270 mips_make_test_option options $arch
1277 # Re
-calculate the isa_rev
for use in the abi handling code below
1278 set arch
[mips_option options arch
]
1279 set isa
[mips_arch_info $arch isa
]
1280 set isa_rev
[mips_arch_info $arch isa_rev
]
1282 #
Set an appropriate ABI
, handling dependencies between the pre
-abi
1283 # options and the abi options. This should mirror the abi and post
-abi
1285 if { !$abi_test_option_p
} {
1287 && ([mips_have_option_p options
"-mabicalls"]
1289 && [mips_have_option_p options
"-mfp64"]))) } {
1290 # EABI doesn
't support -mabicalls.
1291 # EABI doesn't support the combination
-mgp32
-mfp64.
1293 } elseif
{ [mips_using_mips16_p options
]
1294 && ![mips_same_option_p $abi
"-mabi=32"]
1295 && ![mips_same_option_p $abi
"-mabi=o64"]
1296 && (![mips_have_option_p options
"addressing=absolute"]
1297 ||
[mips_have_option_p options
"-mhard-float"]) } {
1298 #
-mips16
-mhard
-float requires o32 or o64.
1299 #
-mips16 PIC requires o32 or o64.
1301 } elseif
{ [mips_have_test_option_p options
"-mlong32"]
1302 && [mips_long64_abi_p $abi
] } {
1304 } elseif
{ [mips_have_test_option_p options
"-mlong64"]
1305 && [mips_long32_abi_p $abi
] } {
1307 } elseif
{ [mips_have_test_option_p options
"-mfpxx"]
1308 && ![mips_same_option_p $abi
"-mabi=32"] } {
1313 if { $gp_size
== 32 } {
1314 if { $force_abi ||
[mips_64bit_abi_p $abi
] } {
1315 if { [mips_have_test_option_p options
"-mlong64"] } {
1316 mips_make_test_option options
"-mabi=eabi"
1317 mips_make_test_option options
"-mgp32"
1319 mips_make_test_option options
"-mabi=32"
1323 if { $force_abi ||
[mips_32bit_abi_p $abi
] } {
1324 if { [mips_have_test_option_p options
"-mlong64"] } {
1325 mips_make_test_option options
"-mabi=eabi"
1326 mips_make_test_option options
"-mgp64"
1328 # All configurations should have an assembler that
1329 # supports o64
, since it requires the same BFD target
1330 # vector as o32. In contrast
, many assembler
1331 # configurations
do not have n32 or n64 support.
1332 mips_make_test_option options
"-mabi=o64"
1336 set abi_test_option_p
[mips_test_option_p options abi
]
1337 set abi
[mips_option options abi
]
1338 set eabi_p
[mips_same_option_p $abi
"-mabi=eabi"]
1341 # Handle dependencies between the abi options and the post
-abi options.
1342 # This should mirror the abi and pre
-abi code above.
1343 if { $abi_test_option_p
} {
1345 mips_make_test_option options
"-mno-abicalls"
1346 if { $isa_rev
< 6 && $gp_size
== 32 } {
1347 mips_make_test_option options
"-mfp32"
1350 if { [mips_using_mips16_p options
]
1351 && ![mips_same_option_p $abi
"-mabi=32"]
1352 && ![mips_same_option_p $abi
"-mabi=o64"]
1353 && ([mips_have_option_p options
"-mabicalls"]
1354 ||
[mips_have_option_p options
"-mhard-float"]) } {
1355 if { [mips_test_option_p options mips16
] } {
1356 mips_make_test_option options
"addressing=absolute"
1357 mips_make_test_option options
"-msoft-float"
1359 mips_make_test_option options
"-mno-mips16"
1362 if { [mips_long32_abi_p $abi
] } {
1363 mips_make_test_option options
"-mlong32"
1364 } elseif
{ [mips_long64_abi_p $abi
] } {
1365 mips_make_test_option options
"-mlong64"
1369 # Handle dependencies between the arch option and the post
-arch options.
1370 # This should mirror the arch and pre
-arch code above.
For pre
-r6
1371 # architectures this only needs to be done when we
've moved down
1372 # to a lower architecture and might need to turn features off,
1373 # but moving up from pre-r6 to r6 can remove features too.
1374 if { $arch_test_option_p || ($orig_isa_rev < 6 && $isa_rev >= 6) } {
1376 mips_make_test_option options "-mno-branch-likely"
1377 mips_make_test_option options "-mno-fix-r10000"
1380 mips_make_test_option options "-mr10k-cache-barrier=none"
1382 if { $isa_rev < 1 } {
1383 mips_make_test_option options "-mno-paired-single"
1384 if { ![mips_have_test_option_p options "-mgp64"] } {
1385 mips_make_test_option options "-mno-odd-spreg"
1388 if { $isa_rev < 2 } {
1389 if { $gp_size == 32 } {
1390 mips_make_test_option options "-mfp32"
1392 mips_make_test_option options "-mno-dsp"
1393 mips_make_test_option options "-mno-synci"
1394 mips_make_test_option options "-mno-micromips"
1395 mips_make_test_option options "-mnan=legacy"
1397 if { $isa_rev < 6 } {
1398 if { [mips_have_option_p options "-mcompact-branches=always"] } {
1399 mips_make_test_option options "-mcompact-branches=optimal"
1402 if { $isa_rev > 5 } {
1403 mips_make_test_option options "-mno-dsp"
1404 mips_make_test_option options "-mno-mips16"
1405 if { [mips_have_test_option_p options "-mdsp"] } {
1406 mips_make_test_option options "-mfp64"
1408 mips_make_test_option options "-mno-fix-r10000"
1409 mips_make_test_option options "-mno-paired-single"
1410 mips_make_test_option options "-mnan=2008"
1411 mips_make_test_option options "-mabs=2008"
1412 mips_make_test_option options "-mno-branch-likely"
1414 if { [regexp {^-march=(octeon|loongson)} $arch] } {
1415 mips_make_test_option options "-mno-micromips"
1423 # Handle dependencies between options on the right of the diagram.
1424 mips_option_dependency options "-mno-dsp" "-mno-dspr2"
1425 mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
1426 switch -- [mips_test_option options small-data] {
1430 mips_make_test_option options "-mno-abicalls"
1433 if { [mips_have_option_p options "-mabicalls"] } {
1434 mips_option_dependency options "addressing=absolute" "-mplt"
1436 mips_option_dependency options "-mplt" "-msym32"
1437 mips_option_dependency options "-mplt" "-mno-shared"
1438 mips_option_dependency options "-mno-shared" "-fno-pic"
1439 mips_option_dependency options "-mfp32" "-mno-paired-single"
1440 mips_option_dependency options "-mfpxx" "-mno-paired-single"
1441 mips_option_dependency options "-msoft-float" "-mno-paired-single"
1442 mips_option_dependency options "-mno-paired-single" "-mno-mips3d"
1443 mips_option_dependency options "-mmsa" "-mno-mips16"
1445 # If the test requires an unsupported option, change run tests
1448 switch -- [lindex $do_what 0] {
1450 set option [mips_first_unsupported_option options]
1451 if { ![string equal $option ""] } {
1452 set do_what [lreplace $do_what 0 0 link]
1453 verbose -log "Downgraded to a 'link
' test due to unsupported option '$option
'"
1458 # If the test has overridden a option that changes the ABI,
1459 # downgrade a link or execution test to an assembler test.
1460 foreach group $mips_abi_groups {
1461 set old_option [mips_original_option $group]
1462 set new_option [mips_option options $group]
1463 if { ![mips_same_option_p $old_option $new_option]
1464 && ![mips_same_option_p $old_option "-mfpxx"]
1465 && ![mips_same_option_p $new_option "-mfpxx"] } {
1466 switch -- [lindex $do_what 0] {
1469 set do_what [lreplace $do_what 0 0 assemble]
1470 verbose -log "Downgraded to an 'assemble
' test due to incompatible $group option ($old_option changed to $new_option)"
1477 # Add all options to the dg variable.
1478 set options(explicit_p,addressing) 0
1479 set options(explicit_p,forbid_cpu) 0
1480 foreach { group regexp } $mips_option_groups {
1481 if { $options(explicit_p,$group) } {
1482 append extra_tool_flags " " $options(option,$group)
1486 # If the test is marked as requiring standard libraries check
1487 # that the sysroot has support for the current set of test options.
1488 if { [mips_have_test_option_p options "REQUIRES_STDLIB"] } {
1489 mips_push_test_options saved_options $extra_tool_flags
1490 set output [mips_preprocess "" {
1493 mips_pop_test_options saved_options
1495 # If the preprocessing of the stdlib.h file produced errors,
1496 # mark the test as unsupported by changing the second element of
1498 # The second element of do_what holds information about test selection
1499 # and it can have one of two values:
1500 # "S" - the test is selected and will be run
1501 # "N" - the test is not selected and will not be run
1502 # This mirrors the format of dg-do-what from lib/dg.exp in DejaGNU.
1503 if { ![string equal $output ""] } {
1504 set do_what [lreplace $do_what 1 1 "N"]
1508 # If the test is MIPS16-compatible, provide a counterpart to the
1509 # NOMIPS16 convenience macro.
1510 if { [mips_have_test_option_p options "-mips16"] } {
1511 append extra_tool_flags " -DMIPS16=__attribute__((mips16))"
1514 if { [mips_have_test_option_p options "-mmicromips"] } {
1515 append extra_tool_flags " -DMICROMIPS=__attribute__((micromips))"
1518 # Use our version of gcc-dg-test for this test.
1519 if { ![string equal [info procs "mips-gcc-dg-test"] ""] } {
1520 rename gcc-dg-test mips-old-gcc-dg-test
1521 rename mips-gcc-dg-test gcc-dg-test
1525 # A version of gcc-dg-test that is used by dg-options tests.
1526 proc mips-gcc-dg-test { prog do_what extra_tool_flags } {
1528 global mips_extra_options
1530 # Override the user's chosen test options with the combined test
/user
1532 mips_push_test_options saved_options $mips_extra_options
1533 set result
[gcc
-dg
-test
-1 gcc_target_compile $prog \
1534 $do_what $extra_tool_flags
]
1535 mips_pop_test_options saved_options
1537 # Restore the usual gcc
-dg
-test.
1538 rename gcc
-dg
-test mips
-gcc
-dg
-test
1539 rename mips
-old
-gcc
-dg
-test gcc
-dg
-test
1546 gcc
-dg
-runtest
[lsort
[glob
-nocomplain $srcdir
/$subdir
/*.c
]] \
1547 "" "-DNOMIPS16=__attribute__((nomips16)) -DNOMICROMIPS=__attribute__((nomicromips)) -DNOCOMPRESSION=__attribute__((nocompression))"