]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.target/mips/mips.exp
Update copyright years.
[thirdparty/gcc.git] / gcc / testsuite / gcc.target / mips / mips.exp
1 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
2
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.
7 #
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.
12 #
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/>.
16
17 # A MIPS version of the GCC dg.exp driver.
18 #
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.
23 #
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
26 # specifies:
27 #
28 # { dg-options "-mips1" }
29 #
30 # and the user passes the following option to runtest:
31 #
32 # --target_board unix/-mips3
33 #
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:
37 #
38 # { dg-do compile { target can_force_mips1 } }
39 #
40 # so that the test is skipped when an option like -mips3 is passed.
41 #
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:
46 #
47 # --target_board unix{-mabi=n32,-mabi=32,-mabi=64}
48 #
49 # when testing them. But these -mabi=* options would normally prevent any
50 # EABI and o64 tests from running.
51 #
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.
55 #
56 #
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
61 # to that multilib.
62 #
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.
67 #
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.)
74 #
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.
80 #
81 #
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:
87 #
88 # dg-options "-mips3d -mpaired-single -mhard-float -mgp64 -mfp64 -mabi=n32 -march=mips64 -mips64"
89 #
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
93 # this:
94 #
95 # - It is easy to forget options.
96 #
97 # - If a new option is added, all tests that are incompatible with that
98 # option must be updated.
99 #
100 # - We want to be able to test MIPS-3D with things like -march=mips32,
101 # -march=mips64r2, -march=sb1, and so on.
102 #
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.
107 #
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.
111 #
112 #
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.
118 # For example:
119 #
120 # { dg-options "(-mips16)" }
121 #
122 # selects a MIPS16-compatible target without passing -mips16 itself.
123 #
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:
126 #
127 # PROP=VALUE PROP<=VALUE PROP>=VALUE
128 #
129 # where PROP can be:
130 #
131 # isa:
132 # the value of the __mips macro.
133 #
134 # isa_rev:
135 # the value of the __mips_isa_rev macro, or 0 if it isn't defined.
136 #
137 # For example, "isa_rev>=1" selects a MIPS32 or MIPS64 processor,
138 # "isa=4" selects a MIPS IV processor, and so on.
139 #
140 # There are also the following special pseudo-options:
141 #
142 # isa=loongson
143 # select a Loongson processor
144 #
145 # isa=p5600
146 # select a P5600 processor
147 #
148 # addressing=absolute
149 # force absolute addresses to be used
150 #
151 # forbid_cpu=REGEXP
152 # forbid processors that match the given regexp; choose a
153 # generic ISA instead.
154 #
155 #
156 # In summary:
157 #
158 # (1) Try to avoid { target ... } requirements wherever possible.
159 # Specify the requirements as dg-options instead.
160 #
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.
165 #
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,
171 # -march=sb1, etc.
172 #
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.
177 #
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".
184 #
185 # (6) If you need to disable processor-specific extensions use
186 # forbid_cpu=REGEXP instead of forcing a generic ISA.
187 #
188 #
189 # Terminology
190 #
191 # Option group or just group:
192 # See comment before mips_option_groups.
193 #
194 # Test options:
195 # The options specified in dg-options.
196 #
197 # Explicit 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.
202 #
203 # 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.
207 #
208 # Option array:
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.
216
217 # Exit immediately if this isn't a MIPS target.
218 if ![istarget mips*-*-*] {
219 return
220 }
221
222 # Load support procs.
223 load_lib gcc-dg.exp
224
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 "^(...)$".
228 #
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 {
233 abi "-mabi=.*"
234 addressing "addressing=.*"
235 arch "-mips([1-5]|32.*|64.*)|-march=.*|isa(|_rev)(=|<=|>=).*"
236 debug "-g.*"
237 dump_pattern "-dp"
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=.*"
242 fp "-mfp(32|xx|64)"
243 gp "-mgp(32|64)"
244 long "-mlong(32|64)"
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=.*"
250 profiling "-pg"
251 small-data "-G[0-9]+"
252 warnings "-w"
253 dump "-fdump-.*"
254 ins "HAS_INS"
255 dmul "NOT_HAS_DMUL"
256 ldc "HAS_LDC"
257 movn "HAS_MOVN"
258 madd "HAS_MADD"
259 madd4_ghost "HAS_MADD4"
260 maddps "HAS_MADDPS"
261 lsa "(|!)HAS_LSA"
262 lxc1 "HAS_LXC1"
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"
267 }
268
269 for { set option 0 } { $option < 32 } { incr option } {
270 lappend mips_option_groups "fixed-f$option" "-ffixed-f$option"
271 }
272
273 # Add -mfoo/-mno-foo options to mips_option_groups.
274 foreach option {
275 abicalls
276 branch-likely
277 dsp
278 dspr2
279 explicit-relocs
280 extern-sdata
281 fix-r4000
282 fix-r10000
283 fix-vr4130
284 gpopt
285 local-sdata
286 long-calls
287 lxc1-sxc1
288 madd4
289 paired-single
290 plt
291 shared
292 smartmips
293 sym32
294 synci
295 relax-pic-calls
296 mcount-ra-address
297 odd-spreg
298 msa
299 loongson-mmi
300 loongson-ext
301 loongson-ext2
302 } {
303 lappend mips_option_groups $option "-m(no-|)$option"
304 }
305
306 # Add -mfoo= options to mips_option_groups.
307 foreach option {
308 abs
309 branch-cost
310 code-readable
311 nan
312 r10k-cache-barrier
313 tune
314 } {
315 lappend mips_option_groups $option "-m$option=.*"
316 }
317
318 # Add -ffoo/-fno-foo options to mips_option_groups.
319 foreach option {
320 common
321 delayed-branch
322 expensive-optimizations
323 fast-math
324 fat-lto-objects
325 finite-math-only
326 fixed-hi
327 fixed-lo
328 lax-vector-conversions
329 omit-frame-pointer
330 optimize-sibling-calls
331 peephole2
332 schedule-insns2
333 split-wide-types
334 tree-vectorize
335 unroll-all-loops
336 unroll-loops
337 ipa-ra
338 } {
339 lappend mips_option_groups $option "-f(no-|)$option"
340 }
341
342 # A list of option groups that have an impact on the ABI.
343 set mips_abi_groups {
344 abi
345 abicalls
346 arch
347 endianness
348 float
349 fp
350 gp
351 gpopt
352 long
353 pic
354 small-data
355 }
356
357 # mips_option_tests(OPTION) is some assembly code that will run to completion
358 # on a target that supports OPTION.
359 set mips_option_tests(-mips16) {
360 move $2,$31
361 bal 1f
362 .set mips16
363 jr $31
364 .set nomips16
365 .align 2
366 1:
367 ori $3,$31,1
368 jalr $3
369 move $31,$2
370 }
371 set mips_option_tests(-mmicromips) {
372 move $2,$31
373 bal 1f
374 .set push
375 .set micromips
376 jraddiusp 0
377 .set pop
378 .align 2
379 1:
380 ori $3,$31,1
381 jalr $3
382 move $31,$2
383 }
384 set mips_option_tests(-mpaired-single) {
385 .set mips64
386 lui $2,0x3f80
387 mtc1 $2,$f0
388 cvt.ps.s $f2,$f0,$f0
389 }
390 set mips_option_tests(-mips3d) {
391 .set mips64
392 .set mips3d
393 lui $2,0x3f80
394 mtc1 $2,$f0
395 cvt.ps.s $f2,$f0,$f0
396 mulr.ps $f2,$f2,$f2
397 rsqrt1.s $f2,$f0
398 mul.s $f4,$f2,$f0
399 rsqrt2.s $f4,$f4,$f2
400 madd.s $f4,$f2,$f2,$f4
401 }
402 set mips_option_tests(-mdsp) {
403 .set mips64r2
404 .set dsp
405 addsc $2,$2,$2
406 }
407 set mips_option_tests(-mdspr2) {
408 .set mips64r2
409 .set dspr2
410 prepend $2,$3,11
411 }
412 set mips_option_tests(-mcode-readable=yes) {
413 move $2,$31
414 bal 1f
415 .set mips16
416 la $3,0f
417 lw $3,($3)
418 jr $31
419 0:
420 .word 0xfacebead
421 .set nomips16
422 .align 2
423 1:
424 ori $3,$31,1
425 jalr $3
426 li $4,0xfacebead
427 beq $3,$4,2f
428 break
429 b .
430 2:
431 move $31,$2
432 }
433
434 # Canonicalize command-line option OPTION.
435 proc mips_canonicalize_option { option } {
436 regsub {^-mips([1-5]|32*|64*)$} $option {-march=mips\1} option
437
438 regsub {^-mel$} $option {-EL} option
439 regsub {^-meb$} $option {-EB} option
440
441 regsub {^-O$} $option {-O1} option
442
443 # MIPS doesn't use -fpic and -fPIC to distinguish between code models.
444 regsub {^-f(no-|)PIC} $option {-f\1pic} option
445
446 return $option
447 }
448
449 # Return true if OPTION1 and OPTION2 represent the same command-line option.
450 proc mips_same_option_p { option1 option2 } {
451 return [string equal \
452 [mips_canonicalize_option $option1] \
453 [mips_canonicalize_option $option2]]
454 }
455
456 # Preprocess CODE using target_compile options OPTIONS. Return the
457 # compiler output.
458 proc mips_preprocess { options code ignore_output } {
459 global tool
460
461 set src dummy[pid].c
462 set f [open $src "w"]
463 puts $f $code
464 close $f
465 if { $ignore_output } {
466 set output [${tool}_target_compile $src dummy[pid].i preprocess $options]
467 file delete dummy[pid].i
468 } else {
469 set output [${tool}_target_compile $src "" preprocess $options]
470 }
471 file delete $src
472
473 return $output
474 }
475
476 # Set the target board's command-line options to NEW_OPTIONS, storing the
477 # old values in UPVAR.
478 proc mips_push_test_options { upvar new_options } {
479 upvar $upvar var
480 global board_info
481
482 array unset var
483 set var(name) board_info([target_info name],multilib_flags)
484 if { [info exists $var(name)] } {
485 set var(old_options) [set $var(name)]
486 set $var(name) [join $new_options " "]
487 }
488 }
489
490 # Undo the effects of [mips_push_test_options UPVAR ...]
491 proc mips_pop_test_options { upvar } {
492 upvar $upvar var
493 global board_info
494
495 if { [info exists var(old_options)] } {
496 set $var(name) $var(old_options)
497 }
498 }
499
500 # Return property PROP for architecture option ARCH (which belongs to
501 # the "arch" group in mips_option_groups). See the comment at the
502 # top of the file for the valid property names.
503 #
504 # Cache the results in mips_arch_info (which can be reused between test
505 # variants).
506 proc mips_arch_info { arch prop } {
507 global mips_arch_info
508 global board_info
509
510 set arch [mips_canonicalize_option $arch]
511 if { ![info exists mips_arch_info($arch,$prop)] } {
512 mips_push_test_options saved_options {}
513 set output [mips_preprocess [list "additional_flags=$arch -mabi=32"] {
514 int isa = __mips;
515 #ifdef __mips_isa_rev
516 int isa_rev = __mips_isa_rev;
517 #else
518 int isa_rev = 0;
519 #endif
520 } 0]
521 foreach lhs { isa isa_rev } {
522 regsub ".*$lhs = (\[^;\]*).*" $output {\1} rhs
523 verbose -log "Architecture $arch has $lhs $rhs"
524 set mips_arch_info($arch,$lhs) $rhs
525 }
526 mips_pop_test_options saved_options
527 }
528 return $mips_arch_info($arch,$prop)
529 }
530
531 # Return the option group associated with OPTION, or "" if none.
532 proc mips_option_maybe_group { option } {
533 global mips_option_groups
534
535 foreach { group regexp } $mips_option_groups {
536 if { [regexp -- "^($regexp)\$" $option] } {
537 return $group
538 }
539 }
540 return ""
541 }
542
543 # Return the option group associated with OPTION. Raise an error if
544 # there is none.
545 proc mips_option_group { option } {
546 set group [mips_option_maybe_group $option]
547 if { [string equal $group ""] } {
548 error "Unrecognised option: $option"
549 }
550 return $group
551 }
552
553 # Return the option for option group GROUP, or "" if no option in that
554 # group has been chosen. UPSTATUS describes the option status.
555 proc mips_option { upstatus group } {
556 upvar $upstatus status
557
558 return $status(option,$group)
559 }
560
561 # If the base options for this test run include an option in group GROUP,
562 # return that option, otherwise return "".
563 proc mips_original_option { group } {
564 global mips_base_options
565
566 return [mips_option mips_base_options $group]
567 }
568
569 # Return true if the test described by UPSTATUS requires a specific
570 # option in group GROUP. UPSTATUS describes the option status.
571 proc mips_test_option_p { upstatus group } {
572 upvar $upstatus status
573
574 return $status(test_option_p,$group)
575 }
576
577 # If the test described by UPSTATUS requires a particular option in group
578 # GROUP, return that option, otherwise return "".
579 proc mips_test_option { upstatus group } {
580 upvar $upstatus status
581
582 if { [mips_test_option_p status $group] } {
583 return [mips_option status $group]
584 } else {
585 return ""
586 }
587 }
588
589 # Return true if the options described by UPSTATUS include OPTION.
590 proc mips_have_option_p { upstatus option } {
591 upvar $upstatus status
592
593 return [mips_same_option_p \
594 [mips_option status [mips_option_group $option]] \
595 $option]
596 }
597
598 # Return true if the options described by UPSTATUS require MIPS16 support.
599 proc mips_using_mips16_p { upstatus } {
600 upvar $upstatus status
601
602 return [expr { [mips_have_option_p status "-mips16"]
603 || [mips_have_option_p status "-mflip-mips16"] }]
604 }
605
606 # Return true if the test described by UPSTATUS requires option OPTION.
607 proc mips_have_test_option_p { upstatus option } {
608 upvar $upstatus status
609
610 set group [mips_option_group $option]
611 return [mips_same_option_p [mips_test_option status $group] $option]
612 }
613
614 # If the test described by UPSTATUS does not specify an option in
615 # OPTION's group, act as though it had specified OPTION.
616 #
617 # The first optional argument indicates whether the option should be
618 # treated as though it were wrapped in parentheses; see the comment at
619 # the top of the file for details about this convention. The default is 0.
620 proc mips_make_test_option { upstatus option args } {
621 upvar $upstatus status
622
623 set group [mips_option_group $option]
624 if { ![mips_test_option_p status $group] } {
625 set status(option,$group) $option
626 set status(test_option_p,$group) 1
627 if { [llength $args] == 0 || ![lindex $args 0] } {
628 set status(explicit_p,$group) 1
629 }
630 }
631 }
632
633 # If the test described by UPSTATUS requires option FROM, assume that
634 # it implicitly requires option TO.
635 proc mips_option_dependency { upstatus from to } {
636 upvar $upstatus status
637
638 if { [mips_have_test_option_p status $from] } {
639 mips_make_test_option status $to
640 }
641 }
642
643 # Return true if the given arch-group option specifies a 32-bit ISA.
644 proc mips_32bit_arch_p { option } {
645 set isa [mips_arch_info $option isa]
646 return [expr { $isa < 3 || $isa == 32 }]
647 }
648
649 # Return true if the given arch-group option specifies a 64-bit ISA.
650 proc mips_64bit_arch_p { option } {
651 return [expr { ![mips_32bit_arch_p $option] }]
652 }
653
654 # Return true if the given abi-group option implicitly requires -mgp32.
655 proc mips_32bit_abi_p { option } {
656 switch -glob -- $option {
657 -mabi=32 {
658 return 1
659 }
660 }
661 return 0
662 }
663
664 # Return true if the given abi-group option implicitly requires -mgp64.
665 proc mips_64bit_abi_p { option } {
666 switch -glob -- $option {
667 -mabi=o64 -
668 -mabi=n32 -
669 -mabi=64 {
670 return 1
671 }
672 }
673 return 0
674 }
675
676 # Return true if the given abi-group option implicitly requires -mlong32.
677 # o64 requires this for -mabicalls, but not otherwise; pick the conservative
678 # case for simplicity.
679 proc mips_long32_abi_p { option } {
680 switch -glob -- $option {
681 -mabi=o64 -
682 -mabi=n32 -
683 -mabi=32 {
684 return 1
685 }
686 }
687 return 0
688 }
689
690 # Return true if the given abi-group option implicitly requires -mlong64.
691 proc mips_long64_abi_p { option } {
692 switch -glob -- $option {
693 -mabi=64 {
694 return 1
695 }
696 }
697 return 0
698 }
699
700 # Check whether the current target supports all the options that the
701 # current test requires. Return "" if so, otherwise return one of
702 # the incompatible options. UPSTATUS describes the option status.
703 proc mips_first_unsupported_option { upstatus } {
704 global mips_option_tests
705 upvar $upstatus status
706
707 foreach { option code } [array get mips_option_tests] {
708 if { [mips_have_test_option_p status $option] } {
709 regsub -all "\n" $code "\\n\\\n" asm
710 # Use check_runtime from target-supports.exp, which caches
711 # the result for us.
712 if { ![check_runtime mips_option_$option [subst {
713 __attribute__((nomips16)) int
714 main (void)
715 {
716 asm (".set push\
717 $asm\
718 .set pop");
719 return 0;
720 }
721 }]] } {
722 return $option
723 }
724 }
725 }
726 return ""
727 }
728
729 # Initialize this testsuite for a new test variant.
730 proc mips-dg-init {} {
731 # Invariant information.
732 global mips_option_groups
733
734 # Internally-generated information about this run.
735 global mips_base_options
736 global mips_extra_options
737
738 # Override dg-options with our mips-dg-options routine.
739 rename dg-options mips-old-dg-options
740 rename mips-dg-options dg-options
741
742 # Start with a fresh option status.
743 array unset mips_base_options
744 foreach { group regexp } $mips_option_groups {
745 set mips_base_options(option,$group) ""
746 set mips_base_options(explicit_p,$group) 0
747 set mips_base_options(test_option_p,$group) 0
748 }
749
750 # Use preprocessor macros to work out as many implicit options as we can.
751 set output [mips_preprocess "" {
752 const char *options[] = {
753 #if !defined _MIPS_SIM
754 "-mabi=eabi",
755 #elif _MIPS_SIM==_ABIO32
756 "-mabi=32",
757 #elif _MIPS_SIM==_ABIO64
758 "-mabi=o64",
759 #elif _MIPS_SIM==_ABIN32
760 "-mabi=n32",
761 #else
762 "-mabi=64",
763 #endif
764
765 "-march=" _MIPS_ARCH,
766
767 #ifdef _MIPSEB
768 "-EB",
769 #else
770 "-EL",
771 #endif
772
773 #ifdef __mips_hard_float
774 "-mhard-float",
775 #else
776 "-msoft-float",
777 #endif
778
779 #ifdef __mips_abs2008
780 "-mabs=2008",
781 #else
782 "-mabs=legacy",
783 #endif
784
785 #ifdef __mips_nan2008
786 "-mnan=2008",
787 #else
788 "-mnan=legacy",
789 #endif
790
791 #if __mips_fpr == 64
792 "-mfp64",
793 #else
794 #if __mips_fpr == 0
795 "-mfpxx",
796 #else
797 "-mfp32",
798 #endif
799 #endif
800
801 #ifdef __mips64
802 "-mgp64",
803 #else
804 "-mgp32",
805 #endif
806
807 #if _MIPS_SZLONG == 64
808 "-mlong64",
809 #else
810 "-mlong32",
811 #endif
812
813 #ifdef __mips16
814 "-mips16",
815 #else
816 "-mno-mips16",
817 #endif
818
819 #ifdef __mips3d
820 "-mips3d",
821 #else
822 "-mno-mips3d",
823 #endif
824
825 #ifdef __mips_paired_single_float
826 "-mpaired-single",
827 #else
828 "-mno-paired-single",
829 #endif
830
831 #if _MIPS_SPFPSET == 32
832 "-modd-spreg",
833 #else
834 "-mno-odd-spreg",
835 #endif
836
837 #if __mips_abicalls
838 "-mabicalls",
839 #else
840 "-mno-abicalls",
841 #endif
842
843 #if __mips_dsp_rev >= 2
844 "-mdspr2",
845 #else
846 "-mno-dspr2",
847 #endif
848
849 #if __mips_dsp_rev >= 1
850 "-mdsp",
851 #else
852 "-mno-dsp",
853 #endif
854
855 #ifndef __PIC__
856 "addressing=absolute",
857 #endif
858
859 #ifdef __mips_smartmips
860 "-msmartmips",
861 #else
862 "-mno-smartmips",
863 #endif
864
865 #ifdef __mips_no_lxc1_sxc1
866 "-mno-lxc1-sxc1",
867 #else
868 "-mlxc1-sxc1"
869 #endif
870
871 #ifdef __mips_no_madd4
872 "-mno-madd4"
873 #else
874 "-mmadd4"
875 #endif
876
877 #ifdef __mips_synci
878 "-msynci",
879 #else
880 "-mno-synci",
881 #endif
882
883 #ifdef __mips_msa
884 "-mmsa"
885 #else
886 "-mno-msa"
887 #endif
888
889 #ifdef __mips_loongson_mmi
890 "-mloongson-mmi"
891 #else
892 "-mno-loongson-mmi"
893 #endif
894
895 0
896 };
897 } 0]
898 foreach line [split $output "\r\n"] {
899 # Poor man's string concatenation.
900 regsub -all {" "} $line "" line
901 if { [regexp {"(.*)",} $line dummy option] } {
902 set group [mips_option_group $option]
903 set mips_base_options(option,$group) $option
904 }
905 }
906
907 # Process the target's multilib options, saving any unrecognized
908 # ones in mips_extra_options.
909 set mips_extra_options {}
910 foreach option [split [board_info target multilib_flags]] {
911 set group [mips_option_maybe_group $option]
912 if { ![string equal $group ""] } {
913 set mips_base_options(option,$group) $option
914 set mips_base_options(explicit_p,$group) 1
915 } else {
916 lappend mips_extra_options $option
917 }
918 }
919 }
920
921 # Finish a test run started by mips-dg-init.
922 proc mips-dg-finish {} {
923 rename dg-options mips-dg-options
924 rename mips-old-dg-options dg-options
925 }
926
927 # Override dg-options so that we can do some MIPS-specific processing.
928 # All options used in this testsuite must appear in mips_option_groups.
929 #
930 # Test options override multilib options. Certain test options can
931 # also imply other test options, which also override multilib options.
932 # These dependencies are ordered as follows:
933 #
934 # START END
935 # | |
936 # -mips16/-mflip-mips16 -mno-mips16
937 # | |
938 # -micromips -mno-micromips
939 # | |
940 # -mips3d -mno-mips3d
941 # | |
942 # -mpaired-single -mno-paired-single
943 # | |
944 # -mfp64 -mfp32
945 # | |
946 # -modd-spreg -mno-odd-spreg
947 # | |
948 # -mdouble-float -msingle-float
949 # | |
950 # -mabs=2008/-mabs=legacy <no option>
951 # | |
952 # -mhard-float -msoft-float
953 # | |
954 # -mno-sym32 -msym32
955 # | |
956 # -mrelax-pic-calls -mno-relax-pic-calls
957 # | |
958 # -fpic -fno-pic
959 # | |
960 # -mshared -mno-shared
961 # | |
962 # -mno-plt -mplt
963 # | |
964 # addressing=unknown addressing=absolute
965 # | |
966 # -mabicalls -mno-abicalls
967 # | |
968 # -G0 <other value>
969 # | |
970 # <other value> -mr10k-cache-barrier=none
971 # | |
972 # -mfix-r10000 -mno-fix-r10000
973 # | |
974 # -mbranch-likely -mno-branch-likely
975 # | |
976 # -msmartmips -mno-smartmips
977 # | |
978 # -mno-gpopt -mgpopt
979 # | |
980 # -mexplicit-relocs -mno-explicit-relocs
981 # | |
982 # -mdspr2 -mno-dspr2
983 # | |
984 # -mdsp -mno-dsp
985 # | |
986 # -msynci -mno-synci
987 # | |
988 # +-- gp, abi & arch ---------+
989 #
990 # For these purposes, the "gp", "abi" & "arch" option groups are treated
991 # as a single node.
992 proc mips-dg-options { args } {
993 # dg.exp variables.
994 upvar dg-extra-tool-flags extra_tool_flags
995 upvar dg-do-what do_what
996
997 # Invariant information.
998 global mips_option_groups
999 global mips_abi_groups
1000
1001 # Information about this run.
1002 global mips_base_options
1003
1004 if { [llength $args] >= 3 } {
1005 switch { [dg-process-target [lindex $args 2]] } {
1006 "S" { }
1007 "N" { return }
1008 "F" { error "[lindex $args 0]: `xfail' not allowed here" }
1009 "P" { error "[lindex $args 0]: `xfail' not allowed here" }
1010 }
1011 }
1012
1013 # Start out with the default option state.
1014 array set options [array get mips_base_options]
1015
1016 # Record the options that this test explicitly needs.
1017 foreach option [lindex $args 1] {
1018 set all_but_p [regexp {^\((.*)\)$} $option dummy option]
1019 set group [mips_option_group $option]
1020 if { [mips_test_option_p options $group] } {
1021 set old [mips_option options $group]
1022 error "Inconsistent $group option: $old vs. $option"
1023 } else {
1024 mips_make_test_option options $option $all_but_p
1025 }
1026 }
1027
1028 # Handle dependencies between the test options and the optimization ones.
1029 mips_option_dependency options "-fno-unroll-loops" "-fno-unroll-all-loops"
1030 mips_option_dependency options "-pg" "-fno-omit-frame-pointer"
1031
1032 # Handle dependencies between options on the left of the
1033 # dependency diagram.
1034 mips_option_dependency options "-mips16" "-mno-micromips"
1035 mips_option_dependency options "-mmicromips" "-mno-mips16"
1036 mips_option_dependency options "-mips3d" "-mpaired-single"
1037 mips_option_dependency options "-mips3d" "-mno-micromips"
1038 mips_option_dependency options "-mpaired-single" "-mfp64"
1039 mips_option_dependency options "-mfp64" "-mhard-float"
1040 mips_option_dependency options "-mfp32" "-mhard-float"
1041 mips_option_dependency options "-mfpxx" "-mhard-float"
1042 mips_option_dependency options "-mfp64" "-modd-spreg"
1043 mips_option_dependency options "-mfp64" "-mdouble-float"
1044 mips_option_dependency options "-mfp32" "-mdouble-float"
1045 mips_option_dependency options "-mfpxx" "-mdouble-float"
1046 mips_option_dependency options "-mabs=2008" "-mhard-float"
1047 mips_option_dependency options "-mabs=legacy" "-mhard-float"
1048 mips_option_dependency options "-mrelax-pic-calls" "-mno-plt"
1049 mips_option_dependency options "-mrelax-pic-calls" "-mabicalls"
1050 mips_option_dependency options "-mrelax-pic-calls" "-mexplicit-relocs"
1051 mips_option_dependency options "-fpic" "-mshared"
1052 mips_option_dependency options "-mshared" "-mno-plt"
1053 mips_option_dependency options "-mshared" "-mabicalls"
1054 mips_option_dependency options "-mno-plt" "addressing=unknown"
1055 mips_option_dependency options "-mabicalls" "-G0"
1056 mips_option_dependency options "-mno-gpopt" "-mexplicit-relocs"
1057
1058 if { [check_configured_with "with-arch=loongson3a"]
1059 || [check_configured_with "with-arch=gs464"]
1060 || [check_configured_with "with-arch=gs464e"]
1061 || [check_configured_with "with-arch=gs264e"] } {
1062 mips_option_dependency options "-msoft-float" "-mno-loongson-mmi"
1063 mips_option_dependency options "-mips16" "-mno-loongson-mmi"
1064 mips_option_dependency options "-mips16" "-mno-loongson-ext"
1065 mips_option_dependency options "-mips16" "-mno-loongson-ext2"
1066 mips_option_dependency options "-mmicromips" "-mno-loongson-mmi"
1067 mips_option_dependency options "-mmicromips" "-mno-loongson-ext"
1068 mips_option_dependency options "-mmicromips" "-mno-loongson-ext2"
1069 }
1070
1071 # Work out information about the current ABI.
1072 set abi_test_option_p [mips_test_option_p options abi]
1073 set abi [mips_option options abi]
1074 set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
1075
1076 # If the test forces a particular ABI, set the register size
1077 # accordingly.
1078 if { $abi_test_option_p } {
1079 if { [mips_32bit_abi_p $abi] } {
1080 mips_make_test_option options "-mgp32"
1081 } elseif { [mips_64bit_abi_p $abi] } {
1082 mips_make_test_option options "-mgp64"
1083 }
1084 }
1085
1086 # See whether forbid_cpu forces us to choose a new architecture.
1087 set arch [mips_option mips_base_options arch]
1088 set force_generic_isa_p [expr {
1089 [regexp "forbid_cpu=(.*)" [mips_option options forbid_cpu] dummy spec]
1090 && [regexp -- "^-march=$spec\$" $arch]
1091 }]
1092
1093 # Interpret the special "isa" and "isa_rev" options. If we have
1094 # a choice of a 32-bit or a 64-bit architecture, prefer to keep
1095 # the -mgp setting the same.
1096 set spec [mips_option options arch]
1097 if { [regexp {^[^-]} $spec] } {
1098 if { [string equal $spec "isa=loongson"] } {
1099 if { ![regexp {^-march=loongson} $arch] } {
1100 set arch "-march=loongson2f"
1101 }
1102 } elseif { [string equal $spec "isa=p5600"] } {
1103 if { ![regexp {^-march=p5600} $arch] } {
1104 set arch "-march=p5600"
1105 }
1106 } else {
1107 if { ![regexp {^(isa(?:|_rev))(=|<=|>=)([0-9]*)$} \
1108 $spec dummy prop relation value nocpus] } {
1109 error "Unrecognized isa specification: $spec"
1110 }
1111 set current [mips_arch_info $arch $prop]
1112 if { $force_generic_isa_p
1113 || ($current < $value && ![string equal $relation "<="])
1114 || ($current > $value && ![string equal $relation ">="])
1115 || ([mips_have_test_option_p options "-mgp64"]
1116 && [mips_32bit_arch_p $arch]) } {
1117 # The current setting is out of range; it cannot
1118 # possibly be used. Find a replacement that can.
1119 if { [string equal $prop "isa"] } {
1120 set arch "-mips$value"
1121 } elseif { $value == 0 } {
1122 set arch "-mips4"
1123 } else {
1124 if { [mips_have_option_p options "-mgp32"] } {
1125 set arch "-mips32"
1126 } else {
1127 set arch "-mips64"
1128 }
1129 if { $value > 1 } {
1130 append arch "r$value"
1131 }
1132 }
1133 }
1134 }
1135 set options(option,arch) $arch
1136 }
1137
1138 # Work out information about the current architecture.
1139 set arch_test_option_p [mips_test_option_p options arch]
1140 set arch [mips_option options arch]
1141 set isa [mips_arch_info $arch isa]
1142 set isa_rev [mips_arch_info $arch isa_rev]
1143 set orig_isa_rev $isa_rev
1144
1145 # If the test forces a 32-bit architecture, force -mgp32.
1146 # Force the current -mgp setting otherwise; if we don't,
1147 # some configurations would make a 64-bit architecture
1148 # imply -mgp64.
1149 if { $arch_test_option_p } {
1150 if { [mips_32bit_arch_p $arch] } {
1151 mips_make_test_option options "-mgp32"
1152 } else {
1153 mips_make_test_option options [mips_option options gp]
1154 }
1155 }
1156
1157 # We've now fixed the GP register size. Make it easily available.
1158 set gp_size [expr { [mips_have_option_p options "-mgp32"] ? 32 : 64 }]
1159
1160 # Handle dependencies between the pre-arch options and the arch option.
1161 # This should mirror the arch and post-arch code below.
1162 if { !$arch_test_option_p } {
1163 # We need a revision 6 or better ISA for:
1164 #
1165 # - When the LSA instruction is required
1166 # - When only using compact branches
1167 if { $isa_rev < 6
1168 && ([mips_have_test_option_p options "HAS_LSA"]
1169 || [mips_have_test_option_p options "-mcompact-branches=always"]) } {
1170 if { $gp_size == 32 } {
1171 mips_make_test_option options "-mips32r6"
1172 } else {
1173 mips_make_test_option options "-mips64r6"
1174 }
1175 # We need a revision 2 or better ISA for:
1176 #
1177 # - the combination of -mgp32 -mfp64
1178 # - the DSP ASE
1179 } elseif { $isa_rev < 2
1180 && (($gp_size == 32 && [mips_have_test_option_p options "-mfp64"])
1181 || [mips_have_test_option_p options "-msynci"]
1182 || [mips_have_test_option_p options "-mdsp"]
1183 || [mips_have_test_option_p options "HAS_INS"]
1184 || [mips_have_test_option_p options "HAS_MADD"]
1185 || [mips_have_test_option_p options "HAS_MADDPS"]
1186 || [mips_have_test_option_p options "-mdspr2"]
1187 || [mips_have_test_option_p options "-mnan=2008"]
1188 || [mips_have_test_option_p options "-mabs=2008"]
1189 || [mips_have_test_option_p options "-mmicromips"]) } {
1190 if { $gp_size == 32 } {
1191 mips_make_test_option options "-mips32r2"
1192 } else {
1193 mips_make_test_option options "-mips64r2"
1194 }
1195 # We need a MIPS32 or MIPS64 ISA for:
1196 #
1197 # - paired-single instructions(*)
1198 # - odd numbered single precision registers
1199 #
1200 # (*) Note that we don't support MIPS V at the moment.
1201 } elseif { $isa_rev < 1
1202 && ([mips_have_test_option_p options "-mpaired-single"]
1203 || ([mips_have_test_option_p options "-modd-spreg"]
1204 && ![mips_have_test_option_p options "-mfp64"]))} {
1205 if { $gp_size == 32 } {
1206 mips_make_test_option options "-mips32"
1207 } else {
1208 mips_make_test_option options "-mips64"
1209 }
1210 # We need MIPS IV or higher for:
1211 #
1212 #
1213 } elseif { $isa < 4
1214 && ([mips_have_test_option_p options "HAS_LXC1"]
1215 || [mips_have_test_option_p options "HAS_MADD4"]
1216 || [mips_have_test_option_p options "HAS_MOVN"]) } {
1217 mips_make_test_option options "-mips4"
1218 # We need MIPS III or higher for:
1219 #
1220 # - the "cache" instruction
1221 } elseif { $isa < 3
1222 && ([mips_have_test_option_p options \
1223 "-mr10k-cache-barrier=load-store"]
1224 || [mips_have_test_option_p options \
1225 "-mr10k-cache-barrier=store"]) } {
1226 mips_make_test_option options "-mips3"
1227 # We need MIPS II or higher for:
1228 #
1229 # - branch-likely instructions(*)
1230 #
1231 # (*) needed by both -mbranch-likely and -mfix-r10000
1232 } elseif { $isa < 2
1233 && ([mips_have_test_option_p options "-mbranch-likely"]
1234 || [mips_have_test_option_p options "-mfix-r10000"]
1235 || ($gp_size == 32
1236 && ([mips_have_test_option_p options "-mfpxx"]
1237 || [mips_have_test_option_p options "HAS_LDC"]))) } {
1238 mips_make_test_option options "-mips2"
1239 # We need to use octeon's base ISA if a test must not run with an
1240 # architecture that supports dmul.
1241 } elseif { [regexp -- "^-march=octeon.*\$" $arch]
1242 && [mips_have_test_option_p options "NOT_HAS_DMUL"] } {
1243 mips_make_test_option options "-mips${isa}r${isa_rev}"
1244 # Check whether we need to switch from mips*r6 down to mips*r5 due
1245 # to options that are incompatible with mips*r6. If we do, use
1246 # -mnan=2008 because r6 is nan2008 by default and without this flag
1247 # tests that include stdlib.h will fail due to not finding
1248 # stubs-o32_hard.h (r6 compilers only have stubs-o32_hard_2008.h)
1249 } elseif { $isa_rev > 5
1250 && ([mips_have_test_option_p options "-mdsp"]
1251 || [mips_have_test_option_p options "-mdspr2"]
1252 || [mips_have_test_option_p options "-mips16"]
1253 || [mips_have_test_option_p options "-mmicromips"]
1254 || [mips_have_test_option_p options "-mfp32"]
1255 || [mips_have_test_option_p options "-mfix-r10000"]
1256 || [mips_have_test_option_p options "NOT_HAS_DMUL"]
1257 || [mips_have_test_option_p options "HAS_LXC1"]
1258 || [mips_have_test_option_p options "HAS_MADD"]
1259 || [mips_have_test_option_p options "HAS_MADD4"]
1260 || [mips_have_test_option_p options "HAS_MOVN"]
1261 || [mips_have_test_option_p options "-mpaired-single"]
1262 || [mips_have_test_option_p options "-mnan=legacy"]
1263 || [mips_have_test_option_p options "-mabs=legacy"]
1264 || [mips_have_test_option_p options "!HAS_LSA"]
1265 || [mips_have_test_option_p options "-mbranch-likely"]) } {
1266 if { $gp_size == 32 } {
1267 mips_make_test_option options "-mips32r5"
1268 } else {
1269 mips_make_test_option options "-mips64r5"
1270 }
1271 mips_make_test_option options "-mnan=2008"
1272 if { [mips_have_option_p options "-mcompact-branches=always"] } {
1273 mips_make_test_option options "-mcompact-branches=optimal"
1274 }
1275 # Check whether we need to switch from a 32-bit processor to the
1276 # "nearest" 64-bit processor.
1277 } elseif { $gp_size == 64 && [mips_32bit_arch_p $arch] } {
1278 if { $isa_rev == 0 } {
1279 mips_make_test_option options "-mips3"
1280 } elseif { $isa_rev == 1 } {
1281 mips_make_test_option options "-mips64"
1282 } else {
1283 mips_make_test_option options "-mips64r$isa_rev"
1284 }
1285 # Otherwise, if the current choice of architecture is unacceptable,
1286 # choose the equivalent generic architecture.
1287 } elseif { $force_generic_isa_p } {
1288 set arch "-mips[mips_arch_info $arch isa]"
1289 if { $isa_rev > 1 } {
1290 append arch "r$isa_rev"
1291 }
1292 mips_make_test_option options $arch
1293 }
1294 unset arch
1295 unset isa
1296 unset isa_rev
1297 }
1298
1299 # Re-calculate the isa_rev for use in the abi handling code below
1300 set arch [mips_option options arch]
1301 set isa [mips_arch_info $arch isa]
1302 set isa_rev [mips_arch_info $arch isa_rev]
1303
1304 # Set an appropriate ABI, handling dependencies between the pre-abi
1305 # options and the abi options. This should mirror the abi and post-abi
1306 # code below.
1307 if { !$abi_test_option_p } {
1308 if { ($eabi_p
1309 && ([mips_have_option_p options "-mabicalls"]
1310 || ($gp_size == 32
1311 && [mips_have_option_p options "-mfp64"]))) } {
1312 # EABI doesn't support -mabicalls.
1313 # EABI doesn't support the combination -mgp32 -mfp64.
1314 set force_abi 1
1315 } elseif { [mips_using_mips16_p options]
1316 && ![mips_same_option_p $abi "-mabi=32"]
1317 && ![mips_same_option_p $abi "-mabi=o64"]
1318 && (![mips_have_option_p options "addressing=absolute"]
1319 || [mips_have_option_p options "-mhard-float"]) } {
1320 # -mips16 -mhard-float requires o32 or o64.
1321 # -mips16 PIC requires o32 or o64.
1322 set force_abi 1
1323 } elseif { [mips_have_test_option_p options "-mlong32"]
1324 && [mips_long64_abi_p $abi] } {
1325 set force_abi 1
1326 } elseif { [mips_have_test_option_p options "-mlong64"]
1327 && [mips_long32_abi_p $abi] } {
1328 set force_abi 1
1329 } elseif { [mips_have_test_option_p options "-mfpxx"]
1330 && ![mips_same_option_p $abi "-mabi=32"] } {
1331 set force_abi 1
1332 } else {
1333 set force_abi 0
1334 }
1335 if { $gp_size == 32 } {
1336 if { $force_abi || [mips_64bit_abi_p $abi] } {
1337 if { [mips_have_test_option_p options "-mlong64"] } {
1338 mips_make_test_option options "-mabi=eabi"
1339 mips_make_test_option options "-mgp32"
1340 } else {
1341 mips_make_test_option options "-mabi=32"
1342 }
1343 }
1344 } else {
1345 if { $force_abi || [mips_32bit_abi_p $abi] } {
1346 if { [mips_have_test_option_p options "-mlong64"] } {
1347 mips_make_test_option options "-mabi=eabi"
1348 mips_make_test_option options "-mgp64"
1349 } else {
1350 # All configurations should have an assembler that
1351 # supports o64, since it requires the same BFD target
1352 # vector as o32. In contrast, many assembler
1353 # configurations do not have n32 or n64 support.
1354 mips_make_test_option options "-mabi=o64"
1355 }
1356 }
1357 }
1358 set abi_test_option_p [mips_test_option_p options abi]
1359 set abi [mips_option options abi]
1360 set eabi_p [mips_same_option_p $abi "-mabi=eabi"]
1361 }
1362
1363 # Handle dependencies between the abi options and the post-abi options.
1364 # This should mirror the abi and pre-abi code above.
1365 if { $abi_test_option_p } {
1366 if { $eabi_p } {
1367 mips_make_test_option options "-mno-abicalls"
1368 if { $isa_rev < 6 && $gp_size == 32 } {
1369 mips_make_test_option options "-mfp32"
1370 }
1371 }
1372 if { [mips_using_mips16_p options]
1373 && ![mips_same_option_p $abi "-mabi=32"]
1374 && ![mips_same_option_p $abi "-mabi=o64"]
1375 && ([mips_have_option_p options "-mabicalls"]
1376 || [mips_have_option_p options "-mhard-float"]) } {
1377 if { [mips_test_option_p options mips16] } {
1378 mips_make_test_option options "addressing=absolute"
1379 mips_make_test_option options "-msoft-float"
1380 } else {
1381 mips_make_test_option options "-mno-mips16"
1382 }
1383 }
1384 if { [mips_long32_abi_p $abi] } {
1385 mips_make_test_option options "-mlong32"
1386 } elseif { [mips_long64_abi_p $abi] } {
1387 mips_make_test_option options "-mlong64"
1388 }
1389 }
1390
1391 # Handle dependencies between the arch option and the post-arch options.
1392 # This should mirror the arch and pre-arch code above. For pre-r6
1393 # architectures this only needs to be done when we've moved down
1394 # to a lower architecture and might need to turn features off,
1395 # but moving up from pre-r6 to r6 can remove features too.
1396 if { $arch_test_option_p || ($orig_isa_rev < 6 && $isa_rev >= 6) } {
1397 if { $isa < 2 } {
1398 mips_make_test_option options "-mno-branch-likely"
1399 mips_make_test_option options "-mno-fix-r10000"
1400 }
1401 if { $isa < 3 } {
1402 mips_make_test_option options "-mr10k-cache-barrier=none"
1403 }
1404 if { $isa_rev < 1 } {
1405 mips_make_test_option options "-mno-paired-single"
1406 if { ![mips_have_test_option_p options "-mgp64"] } {
1407 mips_make_test_option options "-mno-odd-spreg"
1408 }
1409 }
1410 if { $isa_rev < 2 } {
1411 if { $gp_size == 32 } {
1412 mips_make_test_option options "-mfp32"
1413 }
1414 mips_make_test_option options "-mno-dsp"
1415 mips_make_test_option options "-mno-synci"
1416 mips_make_test_option options "-mno-micromips"
1417 mips_make_test_option options "-mnan=legacy"
1418 }
1419 if { $isa_rev < 6 } {
1420 if { [mips_have_option_p options "-mcompact-branches=always"] } {
1421 mips_make_test_option options "-mcompact-branches=optimal"
1422 }
1423 }
1424 if { $isa_rev > 5 } {
1425 mips_make_test_option options "-mno-dsp"
1426 mips_make_test_option options "-mno-mips16"
1427 if { [mips_have_test_option_p options "-mdsp"] } {
1428 mips_make_test_option options "-mfp64"
1429 }
1430 mips_make_test_option options "-mno-fix-r10000"
1431 mips_make_test_option options "-mno-paired-single"
1432 mips_make_test_option options "-mnan=2008"
1433 mips_make_test_option options "-mabs=2008"
1434 mips_make_test_option options "-mno-branch-likely"
1435 }
1436 if { [regexp {^-march=(octeon|loongson)} $arch] } {
1437 mips_make_test_option options "-mno-micromips"
1438 }
1439
1440 unset arch
1441 unset isa
1442 unset isa_rev
1443 }
1444
1445 # Handle dependencies between options on the right of the diagram.
1446 mips_option_dependency options "-mno-dsp" "-mno-dspr2"
1447 mips_option_dependency options "-mno-explicit-relocs" "-mgpopt"
1448 switch -- [mips_test_option options small-data] {
1449 "" -
1450 -G0 {}
1451 default {
1452 mips_make_test_option options "-mno-abicalls"
1453 }
1454 }
1455 if { [mips_have_option_p options "-mabicalls"] } {
1456 mips_option_dependency options "addressing=absolute" "-mplt"
1457 }
1458 mips_option_dependency options "-mplt" "-msym32"
1459 mips_option_dependency options "-mplt" "-mno-shared"
1460 mips_option_dependency options "-mno-shared" "-fno-pic"
1461 mips_option_dependency options "-mfp32" "-mno-paired-single"
1462 mips_option_dependency options "-mfpxx" "-mno-paired-single"
1463 mips_option_dependency options "-msoft-float" "-mno-paired-single"
1464 mips_option_dependency options "-mno-paired-single" "-mno-mips3d"
1465 mips_option_dependency options "-mmsa" "-mno-mips16"
1466
1467 # If the test requires an unsupported option, change run tests
1468 # to link tests.
1469
1470 switch -- [lindex $do_what 0] {
1471 run {
1472 set option [mips_first_unsupported_option options]
1473 if { ![string equal $option ""] } {
1474 set do_what [lreplace $do_what 0 0 link]
1475 verbose -log "Downgraded to a 'link' test due to unsupported option '$option'"
1476 }
1477 }
1478 }
1479
1480 # If the test has overridden a option that changes the ABI,
1481 # downgrade a link or execution test to an assembler test.
1482 foreach group $mips_abi_groups {
1483 set old_option [mips_original_option $group]
1484 set new_option [mips_option options $group]
1485 if { ![mips_same_option_p $old_option $new_option]
1486 && ![mips_same_option_p $old_option "-mfpxx"]
1487 && ![mips_same_option_p $new_option "-mfpxx"] } {
1488 switch -- [lindex $do_what 0] {
1489 link -
1490 run {
1491 set do_what [lreplace $do_what 0 0 assemble]
1492 verbose -log "Downgraded to an 'assemble' test due to incompatible $group option ($old_option changed to $new_option)"
1493 }
1494 }
1495 break
1496 }
1497 }
1498
1499 # Add all options to the dg variable.
1500 set options(explicit_p,addressing) 0
1501 set options(explicit_p,forbid_cpu) 0
1502 foreach { group regexp } $mips_option_groups {
1503 if { $options(explicit_p,$group) } {
1504 append extra_tool_flags " " $options(option,$group)
1505 }
1506 }
1507
1508 # If the test is marked as requiring standard libraries check
1509 # that the sysroot has support for the current set of test options.
1510 if { [mips_have_test_option_p options "REQUIRES_STDLIB"] } {
1511 mips_push_test_options saved_options $extra_tool_flags
1512 set output [mips_preprocess "" {
1513 #include <stdlib.h>
1514 } 1]
1515 mips_pop_test_options saved_options
1516
1517 # If the preprocessing of the stdlib.h file produced errors,
1518 # mark the test as unsupported by changing the second element of
1519 # do_what to "N".
1520 # The second element of do_what holds information about test selection
1521 # and it can have one of two values:
1522 # "S" - the test is selected and will be run
1523 # "N" - the test is not selected and will not be run
1524 # This mirrors the format of dg-do-what from lib/dg.exp in DejaGNU.
1525 if { ![string equal $output ""] } {
1526 set do_what [lreplace $do_what 1 1 "N"]
1527 }
1528 }
1529
1530 # If the test is MIPS16-compatible, provide a counterpart to the
1531 # NOMIPS16 convenience macro.
1532 if { [mips_have_test_option_p options "-mips16"] } {
1533 append extra_tool_flags " -DMIPS16=__attribute__((mips16))"
1534 }
1535
1536 if { [mips_have_test_option_p options "-mmicromips"] } {
1537 append extra_tool_flags " -DMICROMIPS=__attribute__((micromips))"
1538 }
1539
1540 # Use our version of gcc-dg-test for this test.
1541 if { ![string equal [info procs "mips-gcc-dg-test"] ""] } {
1542 rename gcc-dg-test mips-old-gcc-dg-test
1543 rename mips-gcc-dg-test gcc-dg-test
1544 }
1545 }
1546
1547 # A version of gcc-dg-test that is used by dg-options tests.
1548 proc mips-gcc-dg-test { prog do_what extra_tool_flags } {
1549 global board_info
1550 global mips_extra_options
1551
1552 # Override the user's chosen test options with the combined test/user
1553 # version.
1554 mips_push_test_options saved_options $mips_extra_options
1555 set result [gcc-dg-test-1 gcc_target_compile $prog \
1556 $do_what $extra_tool_flags]
1557 mips_pop_test_options saved_options
1558
1559 # Restore the usual gcc-dg-test.
1560 rename gcc-dg-test mips-gcc-dg-test
1561 rename mips-old-gcc-dg-test gcc-dg-test
1562
1563 return $result
1564 }
1565
1566 dg-init
1567 mips-dg-init
1568 gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] \
1569 "" "-DNOMIPS16=__attribute__((nomips16)) -DNOMICROMIPS=__attribute__((nomicromips)) -DNOCOMPRESSION=__attribute__((nocompression))"
1570 mips-dg-finish
1571 dg-finish