1 # Copyright (C) 1997, 2007, 2008 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 # If certain processor-specific extensions are not applicable to the
141 # test you can list them as !CPU in the isa or isa_rev options. For
142 # example, isa=64!octeon enforces MIPS64 while avoiding octeon. You
143 # can also use ! without an ISA value. For example
144 # isa=!octeon!loongson2e disables octeon and loongson2e if otherwise
145 # you would compile for one of them.
147 # There are also the following special pseudo-options:
150 # select a Loongson processor
152 # addressing=absolute
153 # force absolute addresses to be used
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 # isa=!CPU instead of forcing a generic ISA.
188 # Exit immediately if this isn't a MIPS target.
189 if ![istarget mips*-*-*] {
193 # Load support procs.
196 # A list of GROUP REGEXP pairs. Each GROUP represents a logical group of
197 # options from which only option should be chosen. REGEXP matches all the
198 # options in that group; it is implicitly wrapped in "^(...)$".
199 set mips_option_groups {
201 addressing "addressing=.*"
202 arch "-mips([1-5]|32.*|64.*)|-march=.*|isa(|_rev)(=|<=|>=).*"
204 endianness "-E(L|B)|-me(l|b)"
205 float "-m(hard|soft)-float"
209 mips16 "-mips16|-mno-mips16"
210 mips3d "-mips3d|-mno-mips3d"
211 optimization "-O(|[0-3s])"
212 pic "-f(no-|)(pic|PIC)"
214 small-data "-G[0-9]+"
218 # Add -mfoo/-mno-foo options to mips_option_groups.
238 lappend mips_option_groups $option "-m(no-|)$option"
241 # Add -mfoo= options to mips_option_groups.
247 lappend mips_option_groups $option "-m$option=.*"
250 # Add -ffoo/-fno-foo options to mips_option_groups.
257 lax-vector-conversions
261 lappend mips_option_groups $option "-f(no-|)$option"
264 # A list of option groups that have an impact on the ABI.
265 set mips_abi_groups {
279 # mips_option_tests(OPTION) is some assembly code that will run to completion
280 # on a target that supports OPTION.
281 set mips_option_tests(-mips16) {
293 set mips_option_tests(-mpaired-single) {
299 set mips_option_tests(-mips3d) {
309 madd.s $f4,$f2,$f2,$f4
311 set mips_option_tests(-mdsp) {
316 set mips_option_tests(-mdspr2) {
322 # Canonicalize command-line option OPTION.
323 proc mips_canonicalize_option { option } {
324 regsub {^-mips([1-5]|32*|64*)$} $option {-march=mips\1} option
326 regsub {^-mel$} $option {-EL} option
327 regsub {^-meb$} $option {-EB} option
329 regsub {^-O$} $option {-O1} option
331 # MIPS doesn't use -fpic and -fPIC to distinguish between code models.
332 regsub {^-f(no-|)PIC} $option {-f\1pic} option
337 # Return true if OPTION1 and OPTION2 represent the same command-line option.
338 proc mips_same_option_p { option1 option2 } {
339 return [string equal \
340 [mips_canonicalize_option $option1] \
341 [mips_canonicalize_option $option2]]
344 # Preprocess CODE using target_compile options OPTIONS. Return the
346 proc mips_preprocess { options code } {
350 set f [open $src "w"]
353 set output [${tool}_target_compile $src "" preprocess $options]
359 # Set the target board's command-line options to NEW_OPTIONS, storing the
360 # old values in UPVAR.
361 proc mips_push_test_options { upvar new_options } {
366 set var(name) board_info([target_info name],multilib_flags)
367 if { [info exists $var(name)] } {
368 set var(old_options) [set $var(name)]
369 set $var(name) [join $new_options " "]
373 # Undo the effects of [mips_push_test_options UPVAR ...]
374 proc mips_pop_test_options { upvar } {
378 if { [info exists var(old_options)] } {
379 set $var(name) $var(old_options)
383 # Return property PROP for architecture option ARCH (which belongs to
384 # the "arch" group in mips_option_groups). See the comment at the
385 # top of the file for the valid property names.
387 # Cache the results in mips_arch_info (which can be reused between test
389 proc mips_arch_info { arch prop } {
390 global mips_arch_info
393 set arch [mips_canonicalize_option $arch]
394 if { ![info exists mips_arch_info($arch,$prop)] } {
395 mips_push_test_options saved_options {}
396 set output [mips_preprocess [list "additional_flags=$arch -mabi=32"] {
398 #ifdef __mips_isa_rev
399 int isa_rev = __mips_isa_rev;
404 foreach lhs { isa isa_rev } {
405 regsub ".*$lhs = (\[^;\]*).*" $output {\1} rhs
406 verbose -log "Architecture $arch has $lhs $rhs"
407 set mips_arch_info($arch,$lhs) $rhs
409 mips_pop_test_options saved_options
411 return $mips_arch_info($arch,$prop)
414 # Return the option group associated with OPTION, or "" if none.
415 proc mips_option_maybe_group { option } {
416 global mips_option_groups
418 foreach { group regexp } $mips_option_groups {
419 if { [regexp -- "^($regexp)\$" $option] } {
426 # Return the option group associated with OPTION. Raise an error if
428 proc mips_option_group { option } {
429 set group [mips_option_maybe_group $option]
430 if { [string equal $group ""] } {
431 error "Unrecognised option: $option"
436 # Return the option for option group GROUP, or "" if no option in that
437 # group has been chosen. UPSTATUS describes the option status.
438 proc mips_option { upstatus group } {
439 upvar $upstatus status
441 return $status(option,$group)
444 # If the default options for this test run include an option in group GROUP,
445 # return that option, otherwise return "".
446 proc mips_original_option { group } {
447 global mips_base_options
449 return [mips_option mips_base_options $group]
452 # Return true if the test described up UPSTATUS requires a specific
453 # option in group GROUP.
454 proc mips_test_option_p { upstatus group } {
455 upvar $upstatus status
457 return $status(test_option_p,$group)
460 # If the test described by UPSTATUS requires a particular option in group
461 # GROUP, return that option, otherwise return "".
462 proc mips_test_option { upstatus group } {
463 upvar $upstatus status
465 if { [mips_test_option_p status $group] } {
466 return [mips_option status $group]
472 # Return true if the options described by UPSTATUS include OPTION.
473 proc mips_have_option_p { upstatus option } {
474 upvar $upstatus status
476 return [mips_same_option_p \
477 [mips_option status [mips_option_group $option]] \
481 # Return true if the test described by UPSTATUS requires option OPTION.
482 proc mips_have_test_option_p { upstatus option } {
483 upvar $upstatus status
485 set group [mips_option_group $option]
486 return [mips_same_option_p [mips_test_option status $group] $option]
489 # If the test described by UPSTATUS does not specify an option in
490 # OPTION's group, act as though it had specified OPTION.
492 # The first optional argument indicates whether the option should be
493 # treated as though it were wrapped in parentheses; see the comment at
494 # the top of the file for details about this convention. The default is 0.
495 proc mips_make_test_option { upstatus option args } {
496 upvar $upstatus status
498 set group [mips_option_group $option]
499 if { ![mips_test_option_p status $group] } {
500 set status(option,$group) $option
501 set status(test_option_p,$group) 1
502 if { [llength $args] == 0 || ![lindex $args 0] } {
503 set status(explicit_p,$group) 1
508 # If the test described by UPSTATUS requires option FROM, assume that
509 # it implicitly requires option TO.
510 proc mips_option_dependency { upstatus from to } {
511 upvar $upstatus status
513 if { [mips_have_test_option_p status $from] } {
514 mips_make_test_option status $to
518 # Return true if the given arch-group option specifies a 32-bit ISA.
519 proc mips_32bit_arch_p { option } {
520 set isa [mips_arch_info $option isa]
521 return [expr { $isa < 3 || $isa == 32 }]
524 # Return true if the given arch-group option specifies a 64-bit ISA.
525 proc mips_64bit_arch_p { option } {
526 return [expr { ![mips_32bit_arch_p $option] }]
529 # Return true if the given abi-group option implicitly requires -mgp32.
530 proc mips_32bit_abi_p { option } {
531 switch -glob -- $option {
539 # Return true if the given abi-group option implicitly requires -mgp64.
540 proc mips_64bit_abi_p { option } {
541 switch -glob -- $option {
551 # Check whether the current target supports all the options that the
552 # current test requires. Return "" if so, otherwise return one of
553 # the incompatible options. UPSTATUS describes the option status.
554 proc mips_first_unsupported_option { upstatus } {
555 global mips_option_tests
556 upvar $upstatus status
558 foreach { option code } [array get mips_option_tests] {
559 if { [mips_have_test_option_p status $option] } {
560 regsub -all "\n" $code "\\n\\\n" asm
561 # Use check_runtime from target-supports.exp, which caches
563 if { ![check_runtime mips_option_$option [subst {
564 __attribute__((nomips16)) int
580 # Initialize this testsuite for a new test variant.
581 proc mips-dg-init {} {
582 # Invariant information.
583 global mips_option_groups
585 # Internally-generated information about this run.
586 global mips_base_options
587 global mips_extra_options
589 # Override dg-options with our mips-dg-options routine.
590 rename dg-options mips-old-dg-options
591 rename mips-dg-options dg-options
593 # Start with a fresh option status.
594 array unset mips_base_options
595 foreach { group regexp } $mips_option_groups {
596 set mips_base_options(option,$group) ""
597 set mips_base_options(explicit_p,$group) 0
598 set mips_base_options(test_option_p,$group) 0
601 # Use preprocessor macros to work out as many implicit options as we can.
602 set output [mips_preprocess "" {
603 const char *options[] = {
604 #if !defined _MIPS_SIM
606 #elif _MIPS_SIM==_ABIO32
608 #elif _MIPS_SIM==_ABIO64
610 #elif _MIPS_SIM==_ABIN32
616 "-march=" _MIPS_ARCH,
624 #ifdef __mips_hard_float
642 #if _MIPS_SZLONG == 64
660 #ifdef __mips_paired_single_float
663 "-mno-paired-single",
672 #if __mips_dsp_rev >= 2
678 #if __mips_dsp_rev >= 1
685 "addressing=absolute",
688 #ifdef __mips_smartmips
697 foreach line [split $output "\r\n"] {
698 # Poor man's string concatenation.
699 regsub -all {" "} $line "" line
700 if { [regexp {"(.*)",} $line dummy option] } {
701 set group [mips_option_group $option]
702 set mips_base_options(option,$group) $option
706 # Process the target's multilib options, saving any unrecognized
707 # ones in mips_extra_options.
708 set mips_extra_options {}
709 foreach option [split [board_info target multilib_flags]] {
710 set group [mips_option_maybe_group $option]
711 if { ![string equal $group ""] } {
712 set mips_base_options(option,$group) $option
713 set mips_base_options(explicit_p,$group) 1
715 lappend mips_extra_options $option
720 # Finish a test run started by mips-dg-init.
721 proc mips-dg-finish {} {
722 rename dg-options mips-dg-options
723 rename mips-old-dg-options dg-options
726 # Override dg-options so that we can do some MIPS-specific processing.
727 # All options used in this testsuite must appear in mips_option_groups.
729 # Test options override multilib options. Certain test options can
730 # also imply other test options, which also override multilib options.
731 # These dependencies are ordered as follows:
735 # -mips16 -mno-mips16
737 # -mips3d -mno-mips3d
739 # -mpaired-single -mno-paired-single
743 # -mhard-float -msoft-float
749 # -mshared -mno-shared
753 # addressing=unknown addressing=absolute
755 # -mabicalls -mno-abicalls
759 # <other value> -mr10k-cache-barrier=none
761 # -mfix-r10000 -mno-fix-r10000
763 # -mbranch-likely -mno-branch-likely
765 # -msmartmips -mno-smartmips
769 # -mexplicit-relocs -mno-explicit-relocs
771 # +-- gp, abi & arch ---------+
773 # For these purposes, the "gp", "abi" & "arch" option groups are treated
775 proc mips-dg-options { args } {
777 upvar dg-extra-tool-flags extra_tool_flags
778 upvar dg-do-what do_what
780 # Invariant information.
781 global mips_option_groups
782 global mips_abi_groups
784 # Information about this run.
785 global mips_base_options
787 # Start out with the default option state.
788 array set options [array get mips_base_options]
790 # Record the options that this test explicitly needs.
791 foreach option [lindex $args 1] {
792 set all_but_p [regexp {^\((.*)\)$} $option dummy option]
793 set group [mips_option_group $option]
794 if { [mips_test_option_p options $group] } {
795 set old [mips_option options $group]
796 error "Inconsistent $group option: $old vs. $option"
798 mips_make_test_option options $option $all_but_p
802 # Handle dependencies between options on the left of the
803 # dependency diagram.
804 mips_option_dependency options "-mips3d" "-mpaired-single"
805 mips_option_dependency options "-mpaired-single" "-mfp64"
806 mips_option_dependency options "-mfp64" "-mhard-float"
807 mips_option_dependency options "-fpic" "-mshared"
808 mips_option_dependency options "-mshared" "-mno-plt"
809 mips_option_dependency options "-mno-plt" "addressing=unknown"
810 mips_option_dependency options "-mabicalls" "-G0"
811 mips_option_dependency options "-mno-gpopt" "-mexplicit-relocs"
813 # Work out information about the current ABI.
814 set abi_test_option_p [mips_test_option_p options abi]
815 set abi [mips_option options abi]
816 set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
818 # If the test forces a particular ABI, set the register size
820 if { $abi_test_option_p } {
821 if { [mips_32bit_abi_p $abi] } {
822 mips_make_test_option options "-mgp32"
823 } elseif { [mips_64bit_abi_p $abi] } {
824 mips_make_test_option options "-mgp64"
828 # Interpret the special "isa" and "isa_rev" options. If we have
829 # a choice of a 32-bit or a 64-bit architecture, prefer to keep
830 # the -mgp setting the same.
831 set spec [mips_option options arch]
832 if { [regexp {^[^-]} $spec] } {
833 set arch [mips_option mips_base_options arch]
834 if { [string equal $spec "isa=loongson"] } {
835 if { ![regexp {^-march=loongson} $arch] } {
836 set arch "-march=loongson2f"
839 # With ! and = the ISA value is optional.
840 if { ![regexp {^(isa(?:|_rev))(=|<=|>=)([0-9]*)((?:![^!]+)*)$} \
841 $spec dummy prop relation value nocpus]
844 || $nocpus eq ""))} {
845 error "Unrecognized isa specification: $spec"
847 if { $value ne "" } {
848 set current [mips_arch_info $arch $prop]
849 if { ($current < $value && ![string equal $relation "<="])
850 || ($current > $value && ![string equal $relation ">="])
851 || ([mips_have_test_option_p options "-mgp64"]
852 && [mips_32bit_arch_p $arch]) } {
853 # The current setting is out of range; it cannot
854 # possibly be used. Find a replacement that can.
855 if { [string equal $prop "isa"] } {
856 set arch "-mips$value"
857 } elseif { $value == 0 } {
860 if { [mips_have_option_p options "-mgp32"] } {
866 append arch "r$value"
871 # If we haven't switched to a generic ISA based on the
872 # isa* value, do it here if the processor-specific
873 # extension is not allowed.
875 && $arch eq [mips_option mips_base_options arch] } {
876 set cpu [regsub -- {-march=} $arch ""]
877 if { [regexp "!$cpu!" "$nocpus!"] } {
878 set isa_rev [mips_arch_info $arch isa_rev]
879 set arch "-mips[mips_arch_info $arch isa]"
880 if { $isa_rev > 1 } {
881 append arch "r$isa_rev"
886 set options(option,arch) $arch
889 # Work out information about the current architecture.
890 set arch_test_option_p [mips_test_option_p options arch]
891 set arch [mips_option options arch]
892 set isa [mips_arch_info $arch isa]
893 set isa_rev [mips_arch_info $arch isa_rev]
895 # If the test forces a 32-bit architecture, force -mgp32.
896 # Force the current -mgp setting otherwise; if we don't,
897 # some configurations would make a 64-bit architecture
899 if { $arch_test_option_p } {
900 if { [mips_32bit_arch_p $arch] } {
901 mips_make_test_option options "-mgp32"
903 mips_make_test_option options [mips_option options gp]
907 # We've now fixed the GP register size. Make it easily available.
908 set gp_size [expr { [mips_have_option_p options "-mgp32"] ? 32 : 64 }]
910 # Handle dependencies between the pre-arch options and the arch option.
911 # This should mirror the arch and post-arch code below.
912 if { !$arch_test_option_p } {
913 # We need a revision 2 or better ISA for:
915 # - the combination of -mgp32 -mfp64
918 && (($gp_size == 32 && [mips_have_test_option_p options "-mfp64"])
919 || [mips_have_test_option_p options "-mdsp"]
920 || [mips_have_test_option_p options "-mdspr2"]) } {
921 if { $gp_size == 32 } {
922 mips_make_test_option options "-mips32r2"
924 mips_make_test_option options "-mips64r2"
926 # We need a MIPS32 or MIPS64 ISA for:
928 # - paired-single instructions(*)
930 # (*) Note that we don't support MIPS V at the moment.
931 } elseif { $isa_rev < 1
932 && [mips_have_test_option_p options "-mpaired-single"] } {
933 if { $gp_size == 32 } {
934 mips_make_test_option options "-mips32"
936 mips_make_test_option options "-mips64"
938 # We need MIPS III or higher for:
940 # - the "cache" instruction
942 && ([mips_have_test_option_p options \
943 "-mr10k-cache-barrier=load-store"]
944 || [mips_have_test_option_p options \
945 "-mr10k-cache-barrier=store"]) } {
946 mips_make_test_option options "-mips3"
947 # We need MIPS II or higher for:
949 # - branch-likely instructions(*)
951 # (*) needed by both -mbranch-likely and -mfix-r10000
953 && ([mips_have_test_option_p options "-mbranch-likely"]
954 || [mips_have_test_option_p options "-mfix-r10000"]) } {
955 mips_make_test_option options "-mips2"
956 # Check whether we need to switch from a 32-bit processor to the
957 # "nearest" 64-bit processor.
958 } elseif { $gp_size == 64 && [mips_32bit_arch_p $arch] } {
959 if { $isa_rev == 0 } {
960 mips_make_test_option options "-mips3"
961 } elseif { $isa_rev == 1 } {
962 mips_make_test_option options "-mips64"
964 mips_make_test_option options "-mips64r$isa_rev"
972 # Set an appropriate ABI, handling dependencies between the pre-abi
973 # options and the abi options. This should mirror the abi and post-abi
975 if { !$abi_test_option_p } {
977 && ([mips_have_option_p options "-mabicalls"]
979 && [mips_have_option_p options "-mfp64"]))) } {
980 # EABI doesn't support -mabicalls.
981 # EABI doesn't support the combination -mgp32 -mfp64.
983 } elseif { [mips_have_option_p options "-mips16"]
984 && ![mips_same_option_p $abi "-mabi=32"]
985 && ![mips_same_option_p $abi "-mabi=o64"]
986 && (![mips_have_option_p options "addressing=absolute"]
987 || [mips_have_option_p options "-mhard-float"]) } {
988 # -mips16 -mhard-float requires o32 or o64.
989 # -mips16 PIC requires o32 or o64.
994 if { $gp_size == 32 } {
995 if { $force_abi || [mips_64bit_abi_p $abi] } {
996 mips_make_test_option options "-mabi=32"
999 if { $force_abi || [mips_32bit_abi_p $abi] } {
1000 # All configurations should have an assembler that
1001 # supports o64, since it requires the same BFD target
1002 # vector as o32. In contrast, many assembler
1003 # configurations do not have n32 or n64 support.
1004 mips_make_test_option options "-mabi=o64"
1011 # Handle dependencies between the abi options and the post-abi options.
1012 # This should mirror the abi and pre-abi code above.
1013 if { $abi_test_option_p } {
1015 mips_make_test_option options "-mno-abicalls"
1016 if { $gp_size == 32 } {
1017 mips_make_test_option options "-mfp32"
1020 if { [mips_have_option_p options "-mips16"]
1021 && ![mips_same_option_p $abi "-mabi=32"]
1022 && ![mips_same_option_p $abi "-mabi=o64"]
1023 && (![mips_have_option_p options "addressing=absolute"]
1024 || [mips_have_option_p options "-mhard-float"]) } {
1025 if { [mips_test_option_p options mips16] } {
1026 mips_make_test_option options "addressing=absolute"
1027 mips_make_test_option options "-msoft-float"
1029 mips_make_test_option options "-mno-mips16"
1036 # Handle dependencies between the arch option and the post-arch options.
1037 # This should mirror the arch and pre-arch code above.
1038 if { $arch_test_option_p } {
1040 mips_make_test_option options "-mno-branch-likely"
1041 mips_make_test_option options "-mno-fix-r10000"
1044 mips_make_test_option options "-mr10k-cache-barrier=none"
1046 if { $isa_rev < 1 } {
1047 mips_make_test_option options "-mno-paired-single"
1049 if { $isa_rev < 2 } {
1050 if { $gp_size == 32 } {
1051 mips_make_test_option options "-mfp32"
1053 mips_make_test_option options "-mno-dsp"
1054 mips_make_test_option options "-mno-dspr2"
1061 # Handle dependencies between options on the right of the diagram.
1062 mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
1063 switch -- [mips_test_option options small-data] {
1067 mips_make_test_option options "-mno-abicalls"
1070 if { [mips_have_option_p options "-mabicalls"] } {
1071 mips_option_dependency options "addressing=absolute" "-mplt"
1073 mips_option_dependency options "-mplt" "-msym32"
1074 mips_option_dependency options "-mplt" "-mno-shared"
1075 mips_option_dependency options "-mno-shared" "-fno-pic"
1076 mips_option_dependency options "-mfp32" "-mno-paired-single"
1077 mips_option_dependency options "-msoft-float" "-mno-paired-single"
1078 mips_option_dependency options "-mno-paired-single" "-mno-mips3d"
1080 # If the test requires an unsupported option, change run tests
1083 switch -- [lindex $do_what 0] {
1085 set option [mips_first_unsupported_option options]
1086 if { ![string equal $option ""] } {
1087 set do_what [lreplace $do_what 0 0 link]
1088 verbose -log "Downgraded to a 'link' test due to unsupported option '$option'"
1093 # If the test has overridden a option that changes the ABI,
1094 # downgrade a link or execution test to an assembler test.
1095 foreach group $mips_abi_groups {
1096 set old_option [mips_original_option $group]
1097 set new_option [mips_option options $group]
1098 if { ![mips_same_option_p $old_option $new_option] } {
1099 switch -- [lindex $do_what 0] {
1102 set do_what [lreplace $do_what 0 0 assemble]
1103 verbose -log "Downgraded to an 'assemble' test due to incompatible $group option ($old_option changed to $new_option)"
1110 # Add all options to the dg variable.
1111 set options(explicit_p,addressing) 0
1112 foreach { group regexp } $mips_option_groups {
1113 if { $options(explicit_p,$group) } {
1114 append extra_tool_flags " " $options(option,$group)
1118 # If the test is MIPS16-compatible, provide a counterpart to the
1119 # NOMIPS16 convenience macro.
1120 if { [mips_have_test_option_p options "-mips16"] } {
1121 append extra_tool_flags " -DMIPS16=__attribute__((mips16))"
1124 # Use our version of gcc-dg-test for this test.
1125 if { ![string equal [info procs "mips-gcc-dg-test"] ""] } {
1126 rename gcc-dg-test mips-old-gcc-dg-test
1127 rename mips-gcc-dg-test gcc-dg-test
1131 # A version of gcc-dg-test that is used by dg-options tests.
1132 proc mips-gcc-dg-test { prog do_what extra_tool_flags } {
1134 global mips_extra_options
1136 # Override the user's chosen test options with the combined test/user
1138 mips_push_test_options saved_options $mips_extra_options
1139 set result [gcc-dg-test-1 gcc_target_compile $prog \
1140 $do_what $extra_tool_flags]
1141 mips_pop_test_options saved_options
1143 # Restore the usual gcc-dg-test.
1144 rename gcc-dg-test mips-gcc-dg-test
1145 rename mips-old-gcc-dg-test gcc-dg-test
1152 # MIPS16 is defined by "-mips16" or "(-mips16)" in dg-options.
1153 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "" \
1154 "-DNOMIPS16=__attribute__((nomips16))"