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