]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/lib/target-supports.exp
gcc/testsuite/
[thirdparty/gcc.git] / gcc / testsuite / lib / target-supports.exp
CommitLineData
624168de 1# Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
265e7d50 2# Free Software Foundation, Inc.
71152e6d
NC
3
4# This program is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
21526606 8#
71152e6d
NC
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
21526606 13#
71152e6d
NC
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
f115b653 16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
71152e6d
NC
17
18# Please email any bugs, comments, and/or additions to this file to:
19# gcc-patches@gcc.gnu.org
20
21# This file defines procs for determining features supported by the target.
22
19450f2b
DJ
23# Try to compile some code and return the messages printed by the compiler,
24# and optionally the contents for assembly files. Either a string or
25# a list of two strings are returned, depending on WANT_OUTPUT.
b6dc500c
JJ
26#
27# BASENAME is a basename to use for temporary files.
19450f2b
DJ
28# WANT_OUTPUT is a flag which is 0 to request returning just the
29# compiler messages, or 1 to return the messages and the contents
30# of the assembly file. TYPE should be "assembly" if WANT_OUTPUT
31# is set.
b6dc500c
JJ
32# TYPE is the type of compilation to perform (see target_compile).
33# CONTENTS gives the contents of the input file.
b6e3f572
HPN
34# The rest is optional:
35# OPTIONS: additional compiler options to use.
19450f2b 36proc get_compiler_messages {basename want_output type contents args} {
b6dc500c
JJ
37 global tool
38
b6e3f572 39 if { [llength $args] > 0 } {
c03b9206 40 set options [list "additional_flags=[lindex $args 0]"]
b6e3f572
HPN
41 } else {
42 set options ""
43 }
44
b6dc500c
JJ
45 set src ${basename}[pid].c
46 switch $type {
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
49 }
50 set f [open $src "w"]
51 puts $f $contents
52 close $f
b6e3f572 53 set lines [${tool}_target_compile $src $output $type "$options"]
b6dc500c 54 file delete $src
b6dc500c 55
19450f2b
DJ
56 if { $want_output } {
57 if { $type != "assembly" } {
58 error "WANT_OUTPUT can only be used with assembly output"
59 } elseif { ![string match "" $lines] } {
60 # An error occurred.
61 set result [list $lines ""]
62 } else {
63 set text ""
64 set chan [open "$output"]
65 while {[gets $chan line] >= 0} {
66 append text "$line\n"
67 }
68 close $chan
69 set result [list $lines $text]
70 }
71 } else {
72 set result $lines
73 }
74
75 remote_file build delete $output
76 return $result
b6dc500c
JJ
77}
78
635b0f2a
JJ
79proc current_target_name { } {
80 global target_info
81 if [info exists target_info(target,name)] {
82 set answer $target_info(target,name)
83 } else {
84 set answer ""
85 }
86 return $answer
87}
88
8ce1ac69
RS
89# Implement an effective-target check for property PROP by invoking
90# the compiler and seeing if it prints any messages. Assume that the
91# property holds if the compiler doesn't print anything. The other
92# arguments are as for get_compiler_messages, starting with TYPE.
93proc check_no_compiler_messages {prop args} {
94 global et_cache
95
96 set target [current_target_name]
97 if {![info exists et_cache($prop,target)]
98 || $et_cache($prop,target) != $target} {
19450f2b
DJ
99 verbose "check_no_compiler_messages $prop: compiling source for $target" 2
100 set et_cache($prop,target) $target
101 set et_cache($prop,value) \
102 [string match "" [eval get_compiler_messages $prop 0 $args]]
103 }
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
106 return $value
107}
108
109# Similar to check_no_compiler_messages, but also verify that the regular
110# expression PATTERN matches the compiler's output.
111proc check_no_messages_and_pattern {prop pattern args} {
112 global et_cache
113
114 set target [current_target_name]
115 if {![info exists et_cache($prop,target)]
116 || $et_cache($prop,target) != $target} {
117 verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
8ce1ac69 118 set et_cache($prop,target) $target
19450f2b 119 set results [eval get_compiler_messages $prop 1 $args]
8ce1ac69 120 set et_cache($prop,value) \
19450f2b
DJ
121 [expr [string match "" [lindex $results 0]] \
122 && [regexp $pattern [lindex $results 1]]]
8ce1ac69
RS
123 }
124 set value $et_cache($prop,value)
19450f2b 125 verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
8ce1ac69
RS
126 return $value
127}
128
71152e6d
NC
129###############################
130# proc check_weak_available { }
131###############################
132
133# weak symbols are only supported in some configs/object formats
134# this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
135
136proc check_weak_available { } {
432fa9f2 137 global target_triplet
71152e6d
NC
138 global target_cpu
139
140 # All mips targets should support it
21526606 141
71152e6d
NC
142 if { [ string first "mips" $target_cpu ] >= 0 } {
143 return 1
144 }
145
fa4211cb 146 # All solaris2 targets should support it
21526606 147
fa4211cb
KG
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
149 return 1
150 }
151
432fa9f2
RO
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
153
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
155 return 1
156 }
157
c37780f5
AL
158 # Windows targets Cygwin and MingW32 support it
159
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
161 return 1
162 }
163
6731e86d
JDA
164 # HP-UX 10.X doesn't support it
165
60784de8 166 if { [istarget "hppa*-*-hpux10*"] } {
6731e86d
JDA
167 return 0
168 }
169
71152e6d
NC
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
172
173 set objformat [gcc_target_object_format]
174
175 switch $objformat {
176 elf { return 1 }
177 ecoff { return 1 }
178 a.out { return 1 }
98f61f57 179 mach-o { return 1 }
6731e86d 180 som { return 1 }
71152e6d
NC
181 unknown { return -1 }
182 default { return 0 }
183 }
184}
185
facef326 186###############################
d3d9a67f 187# proc check_visibility_available { what_kind }
facef326
MA
188###############################
189
190# The visibility attribute is only support in some object formats
79c70e5a 191# This proc returns 1 if it is supported, 0 if not.
d3d9a67f 192# The argument is the kind of visibility, default/protected/hidden/internal.
facef326 193
d3d9a67f 194proc check_visibility_available { what_kind } {
79c70e5a 195 global tool
facef326 196 global target_triplet
facef326 197
61fec9ff 198 # On NetWare, support makes no sense.
345f13fe 199 if { [istarget *-*-netware*] } {
61fec9ff
JB
200 return 0
201 }
202
d3d9a67f
GK
203 if [string match "" $what_kind] { set what_kind "hidden" }
204
8ce1ac69 205 return [check_no_compiler_messages visibility_available_$what_kind object "
d3d9a67f
GK
206 void f() __attribute__((visibility(\"$what_kind\")));
207 void f() {}
208 "]
facef326
MA
209}
210
71152e6d
NC
211###############################
212# proc check_alias_available { }
213###############################
214
215# Determine if the target toolchain supports the alias attribute.
71152e6d 216
b4e0fcc3
MM
217# Returns 2 if the target supports aliases. Returns 1 if the target
218# only supports weak aliased. Returns 0 if the target does not
219# support aliases at all. Returns -1 if support for aliases could not
220# be determined.
221
222proc check_alias_available { } {
71152e6d 223 global alias_available_saved
bfa21a28
MM
224 global tool
225
71152e6d
NC
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
228 } else {
8dc84ef1
JJ
229 set src alias[pid].c
230 set obj alias[pid].o
231 verbose "check_alias_available compiling testfile $src" 2
232 set f [open $src "w"]
3348ded5
MM
233 # Compile a small test program. The definition of "g" is
234 # necessary to keep the Solaris assembler from complaining
235 # about the program.
54a47870 236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
3348ded5 237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
b4e0fcc3 238 close $f
8dc84ef1
JJ
239 set lines [${tool}_target_compile $src $obj object ""]
240 file delete $src
241 remote_file build delete $obj
b4e0fcc3 242
71152e6d
NC
243 if [string match "" $lines] then {
244 # No error messages, everything is OK.
b4e0fcc3 245 set alias_available_saved 2
71152e6d
NC
246 } else {
247 if [regexp "alias definitions not supported" $lines] {
248 verbose "check_alias_available target does not support aliases" 2
249
250 set objformat [gcc_target_object_format]
251
252 if { $objformat == "elf" } {
253 verbose "check_alias_available but target uses ELF format, so it ought to" 2
b4e0fcc3 254 set alias_available_saved -1
71152e6d 255 } else {
b4e0fcc3 256 set alias_available_saved 0
71152e6d
NC
257 }
258 } else {
9ef6d39a
JO
259 if [regexp "only weak aliases are supported" $lines] {
260 verbose "check_alias_available target supports only weak aliases" 2
b4e0fcc3 261 set alias_available_saved 1
9ef6d39a 262 } else {
b4e0fcc3 263 set alias_available_saved -1
9ef6d39a 264 }
71152e6d
NC
265 }
266 }
21526606 267
71152e6d
NC
268 verbose "check_alias_available returning $alias_available_saved" 2
269 }
270
271 return $alias_available_saved
272}
b4e0fcc3
MM
273
274# Returns true if --gc-sections is supported on the target.
275
276proc check_gc_sections_available { } {
277 global gc_sections_available_saved
bfa21a28 278 global tool
b4e0fcc3 279
4293f7cb 280 if {![info exists gc_sections_available_saved]} {
8138dfe4
RH
281 # Some targets don't support gc-sections despite whatever's
282 # advertised by ld's options.
283 if { [istarget alpha*-*-*]
284 || [istarget ia64-*-*] } {
285 set gc_sections_available_saved 0
286 return 0
287 }
288
b4e0fcc3 289 # Check if the ld used by gcc supports --gc-sections.
61fec9ff
JB
290 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
291 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
292 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
b4e0fcc3
MM
293 set ld_output [remote_exec host "$gcc_ld" "--help"]
294 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
295 set gc_sections_available_saved 1
296 } else {
297 set gc_sections_available_saved 0
298 }
299 }
300 return $gc_sections_available_saved
301}
b8ee7f02
MM
302
303# Return true if profiling is supported on the target.
304
0d856ba2 305proc check_profiling_available { test_what } {
b8ee7f02
MM
306 global profiling_available_saved
307
0d856ba2
KG
308 verbose "Profiling argument is <$test_what>" 1
309
310 # These conditions depend on the argument so examine them before
311 # looking at the cache variable.
312
313 # Support for -p on solaris2 relies on mcrt1.o which comes with the
314 # vendor compiler. We cannot reliably predict the directory where the
315 # vendor compiler (and thus mcrt1.o) is installed so we can't
316 # necessarily find mcrt1.o even if we have it.
317 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
318 return 0
319 }
320
321 # Support for -p on irix relies on libprof1.a which doesn't appear to
322 # exist on any irix6 system currently posting testsuite results.
323 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
324 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
21526606 325 if { [istarget mips*-*-irix*]
0d856ba2
KG
326 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
327 return 0
328 }
329
345f13fe
JB
330 # At present, there is no profiling support on NetWare.
331 if { [istarget *-*-netware*] } {
332 return 0
333 }
334
0d856ba2 335 # Now examine the cache variable.
b8ee7f02
MM
336 if {![info exists profiling_available_saved]} {
337 # Some targets don't have any implementation of __bb_init_func or are
338 # missing other needed machinery.
339 if { [istarget mmix-*-*]
2e32707b 340 || [istarget arm*-*-eabi*]
b8ee7f02 341 || [istarget arm*-*-elf]
2e32707b 342 || [istarget arm*-*-symbianelf*]
9aba2a72 343 || [istarget powerpc-*-eabi*]
b8ee7f02
MM
344 || [istarget strongarm*-*-elf]
345 || [istarget xscale*-*-elf]
346 || [istarget cris-*-*]
21526606 347 || [istarget h8300-*-*]
a239aa95 348 || [istarget m32c-*-elf]
e3860a7d 349 || [istarget m68k-*-elf]
a49877d8 350 || [istarget mips*-*-elf]
dd2778f3 351 || [istarget xtensa-*-elf]
b8ee7f02
MM
352 || [istarget *-*-windiss] } {
353 set profiling_available_saved 0
354 } else {
355 set profiling_available_saved 1
356 }
357 }
21526606 358
b8ee7f02
MM
359 return $profiling_available_saved
360}
21526606 361
aa5c7673
HPN
362# Return 1 if target has packed layout of structure members by
363# default, 0 otherwise. Note that this is slightly different than
364# whether the target has "natural alignment": both attributes may be
365# false.
366
367proc check_effective_target_default_packed { } {
8ce1ac69
RS
368 return [check_no_compiler_messages default_packed assembly {
369 struct x { char a; long b; } c;
370 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
371 }]
aa5c7673
HPN
372}
373
edc5687e
HPN
374# Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
375# documentation, where the test also comes from.
376
377proc check_effective_target_pcc_bitfield_type_matters { } {
8ce1ac69
RS
378 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
379 # bitfields, but let's stick to the example code from the docs.
380 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
381 struct foo1 { char x; char :0; char y; };
382 struct foo2 { char x; int :0; char y; };
383 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
384 }]
edc5687e
HPN
385}
386
a98d4769 387# Return 1 if thread local storage (TLS) is supported, 0 otherwise.
ada80067
UB
388#
389# This won't change for different subtargets so cache the result.
390
391proc check_effective_target_tls {} {
392 global et_tls_saved
9b1f6e91 393 global tool
ada80067
UB
394
395 if [info exists et_tls_saved] {
396 verbose "check_effective_target_tls: using cached result" 2
397 } else {
398 set et_tls_saved 1
399
400 set src tls[pid].c
401 set asm tls[pid].S
402 verbose "check_effective_target_tls: compiling testfile $src" 2
403 set f [open $src "w"]
404 # Compile a small test program.
405 puts $f "__thread int i;\n"
406 close $f
407
408 # Test for thread-local data supported by the platform.
a98d4769
RH
409 set comp_output \
410 [${tool}_target_compile $src $asm assembly ""]
ada80067
UB
411 file delete $src
412 if { [string match "*not supported*" $comp_output] } {
413 set et_tls_saved 0
414 }
415 remove-build-file $asm
416 }
417 verbose "check_effective_target_tls: returning $et_tls_saved" 2
418 return $et_tls_saved
419}
420
421# Return 1 if TLS executables can run correctly, 0 otherwise.
422#
423# This won't change for different subtargets so cache the result.
424
425proc check_effective_target_tls_runtime {} {
426 global et_tls_runtime_saved
9b1f6e91 427 global tool
ada80067
UB
428
429 if [info exists et_tls_runtime_saved] {
430 verbose "check_effective_target_tls_runtime: using cached result" 2
431 } else {
432 set et_tls_runtime_saved 0
433
434 set src tls_runtime[pid].c
435 set exe tls_runtime[pid].x
436 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
437 set f [open $src "w"]
438 # Compile a small test program.
439 puts $f "__thread int thr = 0;\n"
440 puts $f "int main(void)\n {\n return thr;\n}"
441 close $f
442
443 set comp_output \
9b1f6e91 444 [${tool}_target_compile $src $exe executable ""]
ada80067
UB
445 file delete $src
446
447 if [string match "" $comp_output] then {
448 # No error messages, everything is OK.
449
450 set result [remote_load target "./$exe" "" ""]
451 set status [lindex $result 0]
452 remote_file build delete $exe
453
454 verbose "check_effective_target_tls_runtime status is <$status>" 2
455
456 if { $status == "pass" } {
457 set et_tls_runtime_saved 1
458 }
459
460 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
461 }
462 }
463
464 return $et_tls_runtime_saved
465}
466
a782ee45
HPN
467# Return 1 if compilation with -fopenmp is error-free for trivial
468# code, 0 otherwise.
469
470proc check_effective_target_fopenmp {} {
8ce1ac69
RS
471 return [check_no_compiler_messages fopenmp object {
472 void foo (void) { }
473 } "-fopenmp"]
a782ee45
HPN
474}
475
3b1a6677
SE
476# Return 1 if compilation with -freorder-blocks-and-partition is error-free
477# for trivial code, 0 otherwise.
478
479proc check_effective_target_freorder {} {
8ce1ac69
RS
480 return [check_no_compiler_messages freorder object {
481 void foo (void) { }
482 } "-freorder-blocks-and-partition"]
3b1a6677
SE
483}
484
b6e3f572
HPN
485# Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
486# emitted, 0 otherwise. Whether a shared library can actually be built is
487# out of scope for this test.
b6e3f572
HPN
488
489proc check_effective_target_fpic { } {
8ce1ac69
RS
490 # Note that M68K has a multilib that supports -fpic but not
491 # -fPIC, so we need to check both. We test with a program that
492 # requires GOT references.
493 foreach arg {fpic fPIC} {
494 if [check_no_compiler_messages $arg object {
b6e3f572
HPN
495 extern int foo (void); extern int bar;
496 int baz (void) { return foo () + bar; }
8ce1ac69
RS
497 } "-$arg"] {
498 return 1
b6e3f572
HPN
499 }
500 }
8ce1ac69 501 return 0
b6e3f572
HPN
502}
503
245f0e1c
RS
504# Return true if the target supports -mpaired-single (as used on MIPS).
505
506proc check_effective_target_mpaired_single { } {
e9b1e828 507 return [check_no_compiler_messages mpaired_single object {
245f0e1c
RS
508 void foo (void) { }
509 } "-mpaired-single"]
510}
511
74231b0f 512# Return true if iconv is supported on the target. In particular IBM1047.
21526606
EC
513
514proc check_iconv_available { test_what } {
515 global tool
5340bbea 516 global libiconv
21526606
EC
517
518 set result ""
519
8dc84ef1
JJ
520 set src iconv[pid].c
521 set exe iconv[pid].x
522 verbose "check_iconv_available compiling testfile $src" 2
523 set f [open $src "w"]
21526606
EC
524 # Compile a small test program.
525 puts $f "#include <iconv.h>\n"
526 puts $f "int main (void)\n {\n iconv_t cd; \n"
527 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
528 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
529 puts $f "return 0;\n}"
530 close $f
531
0b3deaaf
MM
532 # If the tool configuration file has not set libiconv, try "-liconv"
533 if { ![info exists libiconv] } {
534 set libiconv "-liconv"
535 }
8dc84ef1
JJ
536 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
537 file delete $src
21526606 538
5340bbea
EC
539 if [string match "" $lines] then {
540 # No error messages, everything is OK.
21526606 541
0fb4f4b8 542 set result [${tool}_load "./$exe" "" ""]
11289ef9 543 set status [lindex $result 0]
0fb4f4b8 544 remote_file build delete $exe
21526606 545
8dc84ef1 546 verbose "check_iconv_available status is <$status>" 2
5340bbea
EC
547
548 if { $status == "pass" } then {
549 return 1
550 }
21526606
EC
551 }
552
553 return 0
554}
ab37d57e
ZW
555
556# Return true if named sections are supported on this target.
8ce1ac69 557
ab37d57e 558proc check_named_sections_available { } {
8ce1ac69 559 return [check_no_compiler_messages named_sections assembly {
b6dc500c 560 int __attribute__ ((section("whatever"))) foo;
8ce1ac69 561 }]
ab37d57e 562}
763ee179 563
32aa3bff 564# Return 1 if the target supports Fortran real kinds larger than real(8),
f6cf6841
JJ
565# 0 otherwise.
566#
567# When the target name changes, replace the cached result.
32aa3bff
FXC
568
569proc check_effective_target_fortran_large_real { } {
570 global et_fortran_large_real_saved
f6cf6841 571 global et_fortran_large_real_target_name
32aa3bff
FXC
572 global tool
573
f6cf6841
JJ
574 if { ![info exists et_fortran_large_real_target_name] } {
575 set et_fortran_large_real_target_name ""
576 }
577
578 # If the target has changed since we set the cached value, clear it.
579 set current_target [current_target_name]
580 if { $current_target != $et_fortran_large_real_target_name } {
581 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
582 set et_fortran_large_real_target_name $current_target
583 if [info exists et_fortran_large_real_saved] {
584 verbose "check_effective_target_fortran_large_real: removing cached result" 2
585 unset et_fortran_large_real_saved
586 }
587 }
588
32aa3bff
FXC
589 if [info exists et_fortran_large_real_saved] {
590 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
591 } else {
592 set et_fortran_large_real_saved 0
593
594 # Set up, compile, and execute a test program using large real
595 # kinds. Include the current process ID in the file names to
596 # prevent conflicts with invocations for multiple testsuites.
597 set src real[pid].f90
598 set exe real[pid].x
599
600 set f [open $src "w"]
601 puts $f "integer,parameter :: k = &"
602 puts $f " selected_real_kind (precision (0.0_8) + 1)"
603 puts $f "real(kind=k) :: x"
9cfda6fa 604 puts $f "x = cos (x);"
32aa3bff
FXC
605 puts $f "end"
606 close $f
607
608 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
609 set lines [${tool}_target_compile $src $exe executable ""]
610 file delete $src
611
612 if [string match "" $lines] then {
613 # No error message, compilation succeeded.
614 set et_fortran_large_real_saved 1
615 }
616 }
617
618 return $et_fortran_large_real_saved
619}
620
621# Return 1 if the target supports Fortran integer kinds larger than
f6cf6841
JJ
622# integer(8), 0 otherwise.
623#
624# When the target name changes, replace the cached result.
32aa3bff
FXC
625
626proc check_effective_target_fortran_large_int { } {
627 global et_fortran_large_int_saved
f6cf6841 628 global et_fortran_large_int_target_name
32aa3bff
FXC
629 global tool
630
f6cf6841
JJ
631 if { ![info exists et_fortran_large_int_target_name] } {
632 set et_fortran_large_int_target_name ""
633 }
634
635 # If the target has changed since we set the cached value, clear it.
636 set current_target [current_target_name]
637 if { $current_target != $et_fortran_large_int_target_name } {
638 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
639 set et_fortran_large_int_target_name $current_target
640 if [info exists et_fortran_large_int_saved] {
641 verbose "check_effective_target_fortran_large_int: removing cached result" 2
642 unset et_fortran_large_int_saved
643 }
644 }
645
32aa3bff
FXC
646 if [info exists et_fortran_large_int_saved] {
647 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
648 } else {
649 set et_fortran_large_int_saved 0
650
651 # Set up, compile, and execute a test program using large integer
652 # kinds. Include the current process ID in the file names to
653 # prevent conflicts with invocations for multiple testsuites.
654 set src int[pid].f90
655 set exe int[pid].x
656
657 set f [open $src "w"]
658 puts $f "integer,parameter :: k = &"
659 puts $f " selected_int_kind (range (0_8) + 1)"
660 puts $f "integer(kind=k) :: i"
661 puts $f "end"
662 close $f
663
664 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
665 set lines [${tool}_target_compile $src $exe executable ""]
666 file delete $src
667
668 if [string match "" $lines] then {
669 # No error message, compilation succeeded.
670 set et_fortran_large_int_saved 1
671 }
672 }
673
674 return $et_fortran_large_int_saved
675}
676
f2ae4b2b
FXC
677# Return 1 if we can statically link libgfortran, 0 otherwise.
678#
679# When the target name changes, replace the cached result.
680
681proc check_effective_target_static_libgfortran { } {
682 global et_static_libgfortran
683 global et_static_libgfortran_target_name
684 global tool
685
686 if { ![info exists et_static_libgfortran_target_name] } {
687 set et_static_libgfortran_target_name ""
688 }
689
690 # If the target has changed since we set the cached value, clear it.
691 set current_target [current_target_name]
692 if { $current_target != $et_static_libgfortran_target_name } {
693 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
694 set et_static_libgfortran_target_name $current_target
695 if [info exists et_static_libgfortran_saved] {
696 verbose "check_effective_target_static_libgfortran: removing cached result" 2
697 unset et_static_libgfortran_saved
698 }
699 }
700
701 if [info exists et_static_libgfortran_saved] {
702 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
703 } else {
704 set et_static_libgfortran_saved 0
705
706 # Set up, compile, and execute a test program using static linking.
707 # Include the current process ID in the file names to prevent
708 # conflicts with invocations for multiple testsuites.
5bd9e94d 709 set opts "additional_flags=-static"
f2ae4b2b 710 set src static[pid].f
5bd9e94d 711 set exe static[pid].x
f2ae4b2b
FXC
712
713 set f [open $src "w"]
714 puts $f " print *, 'test'"
715 puts $f " end"
716 close $f
717
718 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
5bd9e94d 719 set lines [${tool}_target_compile $src $exe executable "$opts"]
f2ae4b2b
FXC
720 file delete $src
721
722 if [string match "" $lines] then {
723 # No error message, compilation succeeded.
724 set et_static_libgfortran_saved 1
725 }
726 }
727
728 return $et_static_libgfortran_saved
729}
730
763ee179
JJ
731# Return 1 if the target supports executing AltiVec instructions, 0
732# otherwise. Cache the result.
733
734proc check_vmx_hw_available { } {
735 global vmx_hw_available_saved
736 global tool
737
738 if [info exists vmx_hw_available_saved] {
739 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
740 } else {
741 set vmx_hw_available_saved 0
742
743 # Some simulators are known to not support VMX instructions.
744 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
745 verbose "check_hw_available returning 0" 2
746 return $vmx_hw_available_saved
747 }
748
749 # Set up, compile, and execute a test program containing VMX
750 # instructions. Include the current process ID in the file
751 # names to prevent conflicts with invocations for multiple
752 # testsuites.
753 set src vmx[pid].c
754 set exe vmx[pid].x
755
756 set f [open $src "w"]
757 puts $f "int main() {"
758 puts $f "#ifdef __MACH__"
759 puts $f " asm volatile (\"vor v0,v0,v0\");"
760 puts $f "#else"
761 puts $f " asm volatile (\"vor 0,0,0\");"
762 puts $f "#endif"
763 puts $f " return 0; }"
764 close $f
765
3562bc34
JJ
766 # Most targets don't require special flags for this test case, but
767 # Darwin does.
768 if [istarget *-*-darwin*] {
769 set opts "additional_flags=-maltivec"
770 } else {
771 set opts ""
772 }
773
763ee179 774 verbose "check_vmx_hw_available compiling testfile $src" 2
3562bc34 775 set lines [${tool}_target_compile $src $exe executable "$opts"]
763ee179
JJ
776 file delete $src
777
778 if [string match "" $lines] then {
779 # No error message, compilation succeeded.
780 set result [${tool}_load "./$exe" "" ""]
781 set status [lindex $result 0]
782 remote_file build delete $exe
783 verbose "check_vmx_hw_available testfile status is <$status>" 2
784
785 if { $status == "pass" } then {
786 set vmx_hw_available_saved 1
787 }
788 } else {
789 verbose "check_vmx_hw_availalble testfile compilation failed" 2
790 }
791 }
792
793 return $vmx_hw_available_saved
794}
b6dc500c 795
56afd7aa
JJ
796# GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
797# complex float arguments. This affects gfortran tests that call cabsf
798# in libm built by an earlier compiler. Return 1 if libm uses the same
799# argument passing as the compiler under test, 0 otherwise.
800#
801# When the target name changes, replace the cached result.
802
803proc check_effective_target_broken_cplxf_arg { } {
804 global et_broken_cplxf_arg_saved
805 global et_broken_cplxf_arg_target_name
806 global tool
807
808 # Skip the work for targets known not to be affected.
809 if { ![istarget powerpc64-*-linux*] } {
810 return 0
811 } elseif { [is-effective-target ilp32] } {
812 return 0
813 }
814
815 if { ![info exists et_broken_cplxf_arg_target_name] } {
816 set et_broken_cplxf_arg_target_name ""
817 }
818
819 # If the target has changed since we set the cached value, clear it.
820 set current_target [current_target_name]
821 if { $current_target != $et_broken_cplxf_arg_target_name } {
822 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
823 set et_broken_cplxf_arg_target_name $current_target
824 if [info exists et_broken_cplxf_arg_saved] {
825 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
826 unset et_broken_cplxf_arg_saved
827 }
828 }
829
830 if [info exists et_broken_cplxf_arg_saved] {
831 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
832 } else {
833 set et_broken_cplxf_arg_saved 0
834 # This is only known to affect one target.
835 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
836 set et_broken_cplxf_arg_saved 0
837 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
838 return $et_broken_cplxf_arg_saved
839 }
840
841 # Set up, compile, and execute a C test program that calls cabsf.
842 set src cabsf[pid].c
843 set exe cabsf[pid].x
844
845 set f [open $src "w"]
846 puts $f "#include <complex.h>"
847 puts $f "extern void abort (void);"
848 puts $f "float fabsf (float);"
849 puts $f "float cabsf (_Complex float);"
850 puts $f "int main ()"
851 puts $f "{"
852 puts $f " _Complex float cf;"
853 puts $f " float f;"
854 puts $f " cf = 3 + 4.0fi;"
855 puts $f " f = cabsf (cf);"
856 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
857 puts $f " return 0;"
858 puts $f "}"
859 close $f
860
861 set lines [${tool}_target_compile $src $exe executable "-lm"]
862 file delete $src
863
864 if [string match "" $lines] {
865 # No error message, compilation succeeded.
866 set result [${tool}_load "./$exe" "" ""]
867 set status [lindex $result 0]
868 remote_file build delete $exe
869
870 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
871
872 if { $status != "pass" } {
873 set et_broken_cplxf_arg_saved 1
874 }
875 } else {
876 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
877 }
878 }
879 return $et_broken_cplxf_arg_saved
880}
881
31589ec6
RH
882proc check_alpha_max_hw_available { } {
883 global alpha_max_hw_available_saved
884 global tool
885
886 if [info exists alpha_max_hw_available_saved] {
887 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
888 } else {
889 set alpha_max_hw_available_saved 0
890
891 # Set up, compile, and execute a test program probing bit 8 of the
892 # architecture mask, which indicates presence of MAX instructions.
893 set src max[pid].c
894 set exe max[pid].x
895
896 set f [open $src "w"]
897 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
898 close $f
899
900 verbose "check_alpha_max_hw_available compiling testfile $src" 2
901 set lines [${tool}_target_compile $src $exe executable ""]
902 file delete $src
903
904 if [string match "" $lines] then {
905 # No error message, compilation succeeded.
906 set result [${tool}_load "./$exe" "" ""]
907 set status [lindex $result 0]
908 remote_file build delete $exe
909 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
910
911 if { $status == "pass" } then {
912 set alpha_max_hw_available_saved 1
913 }
914 } else {
915 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
916 }
917 }
918
919 return $alpha_max_hw_available_saved
920}
921
34f4edf8
MM
922# Returns true iff the FUNCTION is available on the target system.
923# (This is essentially a Tcl implementation of Autoconf's
924# AC_CHECK_FUNC.)
925
926proc check_function_available { function } {
927 set var "${function}_available_saved"
928 global $var
929 global tool
930
931 if {![info exists $var]} {
932 # Assume it exists.
933 set $var 1
934 # Check to make sure.
935 set src "function[pid].c"
936 set exe "function[pid].exe"
937
938 set f [open $src "w"]
709e1a1a
JM
939 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
940 puts $f "char $function ();\n"
34f4edf8
MM
941 puts $f "int main () { $function (); }"
942 close $f
943
944 set lines [${tool}_target_compile $src $exe executable ""]
945 file delete $src
946 file delete $exe
947
948 if {![string match "" $lines]} then {
949 set $var 0
950 verbose -log "$function is not available"
951 } else {
952 verbose -log "$function is available"
953 }
954 }
955
956 eval return \$$var
957}
958
cea02b6e 959# Returns true iff "fork" is available on the target system.
34f4edf8
MM
960
961proc check_fork_available {} {
962 return [check_function_available "fork"]
963}
964
cea02b6e 965# Returns true iff "mkfifo" is available on the target system.
34f4edf8
MM
966
967proc check_mkfifo_available {} {
cea02b6e
DB
968 if {[istarget *-*-cygwin*]} {
969 # Cygwin has mkfifo, but support is incomplete.
970 return 0
971 }
972
34f4edf8
MM
973 return [check_function_available "mkfifo"]
974}
975
21f638b9
SE
976# Returns true iff "__cxa_atexit" is used on the target system.
977
978proc check_cxa_atexit_available { } {
979 global et_cxa_atexit
980 global et_cxa_atexit_target_name
981 global tool
982
983 if { ![info exists et_cxa_atexit_target_name] } {
984 set et_cxa_atexit_target_name ""
985 }
986
987 # If the target has changed since we set the cached value, clear it.
988 set current_target [current_target_name]
989 if { $current_target != $et_cxa_atexit_target_name } {
990 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
991 set et_cxa_atexit_target_name $current_target
992 if [info exists et_cxa_atexit] {
993 verbose "check_cxa_atexit_available: removing cached result" 2
994 unset et_cxa_atexit
995 }
996 }
997
998 if [info exists et_cxa_atexit] {
999 verbose "check_cxa_atexit_available: using cached result" 2
60784de8 1000 } elseif { [istarget "hppa*-*-hpux10*"] } {
c53fa174
JDA
1001 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1002 set et_cxa_atexit 0
21f638b9
SE
1003 } else {
1004 set et_cxa_atexit 0
1005
1006 # Set up, compile, and execute a C++ test program that depends
1007 # on correct ordering of static object destructors. This is
1008 # indicative of the presence and use of __cxa_atexit.
1009 set src cxaatexit[pid].cc
1010 set exe cxaatexit[pid].x
1011
1012 set f [open $src "w"]
1013 puts $f "#include <stdlib.h>"
1014 puts $f "static unsigned int count;"
1015 puts $f "struct X"
1016 puts $f "{"
1017 puts $f " X() { count = 1; }"
1018 puts $f " ~X()"
1019 puts $f " {"
1020 puts $f " if (count != 3)"
1021 puts $f " exit(1);"
1022 puts $f " count = 4;"
1023 puts $f " }"
1024 puts $f "};"
1025 puts $f "void f()"
1026 puts $f "{"
1027 puts $f " static X x;"
1028 puts $f "}"
1029 puts $f "struct Y"
1030 puts $f "{"
1031 puts $f " Y() { f(); count = 2; }"
1032 puts $f " ~Y()"
1033 puts $f " {"
1034 puts $f " if (count != 2)"
1035 puts $f " exit(1);"
1036 puts $f " count = 3;"
1037 puts $f " }"
1038 puts $f "};"
1039 puts $f "Y y;"
1040 puts $f "int main()"
1041 puts $f "{ return 0; }"
1042 close $f
1043
38ccd98a 1044 set lines [${tool}_target_compile $src $exe executable ""]
21f638b9
SE
1045 file delete $src
1046
1047 if [string match "" $lines] {
1048 # No error message, compilation succeeded.
1049 set result [${tool}_load "./$exe" "" ""]
1050 set status [lindex $result 0]
1051 remote_file build delete $exe
1052
1053 verbose "check_cxa_atexit_available: status is <$status>" 2
1054
1055 if { $status == "pass" } {
1056 set et_cxa_atexit 1
1057 }
1058 } else {
1059 verbose "check_cxa_atexit_available: compilation failed" 2
1060 }
1061 }
1062 return $et_cxa_atexit
1063}
1064
1065
b6dc500c
JJ
1066# Return 1 if we're generating 32-bit code using default options, 0
1067# otherwise.
1068
1069proc check_effective_target_ilp32 { } {
8ce1ac69
RS
1070 return [check_no_compiler_messages ilp32 object {
1071 int dummy[sizeof (int) == 4
1072 && sizeof (void *) == 4
1073 && sizeof (long) == 4 ? 1 : -1];
1074 }]
b6dc500c
JJ
1075}
1076
a239aa95
DD
1077# Return 1 if we're generating 32-bit or larger integers using default
1078# options, 0 otherwise.
1079
1080proc check_effective_target_int32plus { } {
1081 return [check_no_compiler_messages int32plus object {
1082 int dummy[sizeof (int) >= 4 ? 1 : -1];
1083 }]
1084}
1085
1086# Return 1 if we're generating 32-bit or larger pointers using default
1087# options, 0 otherwise.
1088
1089proc check_effective_target_ptr32plus { } {
1090 return [check_no_compiler_messages ptr32plus object {
1091 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1092 }]
1093}
1094
1095# Return 1 if we support 32-bit or larger array and structure sizes
1096# using default options, 0 otherwise.
1097
1098proc check_effective_target_size32plus { } {
1099 return [check_no_compiler_messages size32plus object {
1100 char dummy[65537];
1101 }]
1102}
1103
1104# Returns 1 if we're generating 16-bit or smaller integers with the
1105# default options, 0 otherwise.
1106
1107proc check_effective_target_int16 { } {
1108 return [check_no_compiler_messages int16 object {
1109 int dummy[sizeof (int) < 4 ? 1 : -1];
1110 }]
1111}
1112
b6dc500c
JJ
1113# Return 1 if we're generating 64-bit code using default options, 0
1114# otherwise.
1115
1116proc check_effective_target_lp64 { } {
8ce1ac69
RS
1117 return [check_no_compiler_messages lp64 object {
1118 int dummy[sizeof (int) == 4
1119 && sizeof (void *) == 8
1120 && sizeof (long) == 8 ? 1 : -1];
1121 }]
b6dc500c
JJ
1122}
1123
4efc447f
MLI
1124# Return 1 if the target supports long double larger than double,
1125# 0 otherwise.
1126
1127proc check_effective_target_large_long_double { } {
1128 return [check_no_compiler_messages large_long_double object {
1129 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1130 }]
1131}
1132
1133
265e7d50
JJ
1134# Return 1 if the target supports compiling decimal floating point,
1135# 0 otherwise.
1136
1137proc check_effective_target_dfp_nocache { } {
1138 verbose "check_effective_target_dfp_nocache: compiling source" 2
19450f2b 1139 set ret [string match "" [get_compiler_messages dfp 0 object {
265e7d50
JJ
1140 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1141 }]]
1142 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1143 return $ret
1144}
1145
1146proc check_effective_target_dfprt_nocache { } {
1147 global tool
1148
1149 set ret 0
1150
1151 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1152 # Set up, compile, and execute a test program containing decimal
1153 # float operations.
1154 set src dfprt[pid].c
1155 set exe dfprt[pid].x
1156
1157 set f [open $src "w"]
1158 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1159 puts $f "int main () { z = x + y; return 0; }"
1160 close $f
1161
1162 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1163 set lines [${tool}_target_compile $src $exe executable ""]
1164 file delete $src
1165
1166 if [string match "" $lines] then {
1167 # No error message, compilation succeeded.
1168 set result [${tool}_load "./$exe" "" ""]
1169 set status [lindex $result 0]
1170 remote_file build delete $exe
1171 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1172 if { $status == "pass" } then {
1173 set ret 1
1174 }
1175 }
1176 return $ret
1177 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1178}
1179
1180# Return 1 if the target supports compiling Decimal Floating Point,
1181# 0 otherwise.
27a2694f
JJ
1182#
1183# This won't change for different subtargets so cache the result.
1184
1185proc check_effective_target_dfp { } {
1186 global et_dfp_saved
1187
1188 if [info exists et_dfp_saved] {
1189 verbose "check_effective_target_dfp: using cached result" 2
1190 } else {
265e7d50 1191 set et_dfp_saved [check_effective_target_dfp_nocache]
27a2694f
JJ
1192 }
1193 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1194 return $et_dfp_saved
1195}
1196
265e7d50
JJ
1197# Return 1 if the target supports linking and executing Decimal Floating
1198# Point, # 0 otherwise.
1199#
1200# This won't change for different subtargets so cache the result.
1201
1202proc check_effective_target_dfprt { } {
1203 global et_dfprt_saved
1204 global tool
1205
1206 if [info exists et_dfprt_saved] {
1207 verbose "check_effective_target_dfprt: using cached result" 2
1208 } else {
1209 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1210 }
1211 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1212 return $et_dfprt_saved
1213}
1214
b956116e
PB
1215# Return 1 if the target needs a command line argument to enable a SIMD
1216# instruction set.
b956116e
PB
1217
1218proc check_effective_target_vect_cmdline_needed { } {
1219 global et_vect_cmdline_needed_saved
e87a56b4
JM
1220 global et_vect_cmdline_needed_target_name
1221
1222 if { ![info exists et_vect_cmdline_needed_target_name] } {
1223 set et_vect_cmdline_needed_target_name ""
1224 }
1225
1226 # If the target has changed since we set the cached value, clear it.
1227 set current_target [current_target_name]
1228 if { $current_target != $et_vect_cmdline_needed_target_name } {
1229 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1230 set et_vect_cmdline_needed_target_name $current_target
1231 if { [info exists et_vect_cmdline_needed_saved] } {
1232 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1233 unset et_vect_cmdline_needed_saved
1234 }
1235 }
b956116e
PB
1236
1237 if [info exists et_vect_cmdline_needed_saved] {
1238 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1239 } else {
1240 set et_vect_cmdline_needed_saved 1
1241 if { [istarget ia64-*-*]
e87a56b4 1242 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
624168de
JM
1243 && [check_effective_target_lp64])
1244 || ([istarget powerpc*-*-*]
5eb96b60
JM
1245 && ([check_effective_target_powerpc_spe]
1246 || [check_effective_target_powerpc_altivec]))} {
b956116e
PB
1247 set et_vect_cmdline_needed_saved 0
1248 }
1249 }
1250
1251 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1252 return $et_vect_cmdline_needed_saved
1253}
1254
07d05ffd
JJ
1255# Return 1 if the target supports hardware vectors of int, 0 otherwise.
1256#
1257# This won't change for different subtargets so cache the result.
1258
1259proc check_effective_target_vect_int { } {
1260 global et_vect_int_saved
1261
1262 if [info exists et_vect_int_saved] {
1263 verbose "check_effective_target_vect_int: using cached result" 2
1264 } else {
1265 set et_vect_int_saved 0
1266 if { [istarget i?86-*-*]
1267 || [istarget powerpc*-*-*]
0f6909b9 1268 || [istarget spu-*-*]
07d05ffd 1269 || [istarget x86_64-*-*]
31589ec6 1270 || [istarget sparc*-*-*]
f61134e8
RH
1271 || [istarget alpha*-*-*]
1272 || [istarget ia64-*-*] } {
07d05ffd
JJ
1273 set et_vect_int_saved 1
1274 }
1275 }
1276
1277 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1278 return $et_vect_int_saved
1279}
1280
0d341a6a
PB
1281# Return 1 is this is an arm target using 32-bit instructions
1282proc check_effective_target_arm32 { } {
1283 global et_arm32_saved
1284 global et_arm32_target_name
1285 global compiler_flags
1286
1287 if { ![info exists et_arm32_target_name] } {
1288 set et_arm32_target_name ""
1289 }
1290
1291 # If the target has changed since we set the cached value, clear it.
1292 set current_target [current_target_name]
1293 if { $current_target != $et_arm32_target_name } {
1294 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1295 set et_arm32_target_name $current_target
1296 if { [info exists et_arm32_saved] } {
1297 verbose "check_effective_target_arm32: removing cached result" 2
1298 unset et_arm32_saved
1299 }
1300 }
1301
1302 if [info exists et_arm32_saved] {
1303 verbose "check-effective_target_arm32: using cached result" 2
1304 } else {
1305 set et_arm32_saved 0
1306 if { [istarget arm-*-*]
1307 || [istarget strongarm*-*-*]
1308 || [istarget xscale-*-*] } {
1309 if ![string match "*-mthumb *" $compiler_flags] {
1310 set et_arm32_saved 1
1311 }
1312 }
1313 }
1314 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1315 return $et_arm32_saved
1316}
1317
c03b9206
JM
1318# Return 1 if this is an ARM target supporting -mfpu=vfp
1319# -mfloat-abi=softfp. Some multilibs may be incompatible with these
1320# options.
1321
1322proc check_effective_target_arm_vfp_ok { } {
1323 if { [check_effective_target_arm32] } {
1324 return [check_no_compiler_messages arm_vfp_ok object {
1325 int dummy;
1326 } "-mfpu=vfp -mfloat-abi=softfp"]
1327 } else {
1328 return 0
1329 }
1330}
1331
1dbf8c24
JM
1332# Return 1 if this is a PowerPC target with floating-point registers.
1333
1334proc check_effective_target_powerpc_fprs { } {
1335 if { [istarget powerpc*-*-*]
1336 || [istarget rs6000-*-*] } {
1337 return [check_no_compiler_messages powerpc_fprs object {
1338 #ifdef __NO_FPRS__
1339 #error no FPRs
1340 #else
1341 int dummy;
1342 #endif
1343 }]
1344 } else {
1345 return 0
1346 }
1347}
1348
1349# Return 1 if this is a PowerPC target supporting -maltivec.
1350
1351proc check_effective_target_powerpc_altivec_ok { } {
1352 if { [istarget powerpc*-*-*]
1353 || [istarget rs6000-*-*] } {
1354 # AltiVec is not supported on Aix.
1355 if { [istarget powerpc*-*-aix*] } {
1356 return 0
1357 }
1358 return [check_no_compiler_messages powerpc_altivec_ok object {
1359 int dummy;
1360 } "-maltivec"]
1361 } else {
1362 return 0
1363 }
1364}
1365
624168de
JM
1366# Return 1 if this is a PowerPC target with SPE enabled.
1367
1368proc check_effective_target_powerpc_spe { } {
1369 if { [istarget powerpc*-*-*] } {
1370 return [check_no_compiler_messages powerpc_spe object {
1371 #ifndef __SPE__
1372 #error not SPE
1373 #else
1374 int dummy;
1375 #endif
1376 }]
1377 } else {
1378 return 0
1379 }
1380}
1381
5eb96b60
JM
1382# Return 1 if this is a PowerPC target with Altivec enabled.
1383
1384proc check_effective_target_powerpc_altivec { } {
1385 if { [istarget powerpc*-*-*] } {
1386 return [check_no_compiler_messages powerpc_altivec object {
1387 #ifndef __ALTIVEC__
1388 #error not Altivec
1389 #else
1390 int dummy;
1391 #endif
1392 }]
1393 } else {
1394 return 0
1395 }
1396}
1397
3e0de9d1
DP
1398# Return 1 if the target supports hardware vector shift operation.
1399
1400proc check_effective_target_vect_shift { } {
41a182c6
UB
1401 global et_vect_shift_saved
1402
1403 if [info exists et_vect_shift_saved] {
1404 verbose "check_effective_target_vect_shift: using cached result" 2
3e0de9d1 1405 } else {
41a182c6
UB
1406 set et_vect_shift_saved 0
1407 if { [istarget powerpc*-*-*]
1408 || [istarget ia64-*-*]
1409 || [istarget i?86-*-*]
1410 || [istarget x86_64-*-*] } {
1411 set et_vect_shift_saved 1
1412 }
3e0de9d1
DP
1413 }
1414
41a182c6
UB
1415 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1416 return $et_vect_shift_saved
3e0de9d1
DP
1417}
1418
31589ec6
RH
1419# Return 1 if the target supports hardware vectors of long, 0 otherwise.
1420#
f470b1e5 1421# This can change for different subtargets so do not cache the result.
31589ec6
RH
1422
1423proc check_effective_target_vect_long { } {
f470b1e5
JJ
1424 if { [istarget i?86-*-*]
1425 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1426 || [istarget x86_64-*-*]
1427 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1428 set answer 1
31589ec6 1429 } else {
f470b1e5 1430 set answer 0
31589ec6
RH
1431 }
1432
f470b1e5
JJ
1433 verbose "check_effective_target_vect_long: returning $answer" 2
1434 return $answer
31589ec6
RH
1435}
1436
07d05ffd
JJ
1437# Return 1 if the target supports hardware vectors of float, 0 otherwise.
1438#
1439# This won't change for different subtargets so cache the result.
1440
1441proc check_effective_target_vect_float { } {
1442 global et_vect_float_saved
1443
1444 if [info exists et_vect_float_saved] {
1445 verbose "check_effective_target_vect_float: using cached result" 2
1446 } else {
1447 set et_vect_float_saved 0
1448 if { [istarget i?86-*-*]
1449 || [istarget powerpc*-*-*]
0f6909b9 1450 || [istarget spu-*-*]
07d05ffd 1451 || [istarget mipsisa64*-*-*]
f61134e8
RH
1452 || [istarget x86_64-*-*]
1453 || [istarget ia64-*-*] } {
07d05ffd
JJ
1454 set et_vect_float_saved 1
1455 }
1456 }
1457
1458 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1459 return $et_vect_float_saved
1460}
1461
1462# Return 1 if the target supports hardware vectors of double, 0 otherwise.
1463#
1464# This won't change for different subtargets so cache the result.
1465
1466proc check_effective_target_vect_double { } {
1467 global et_vect_double_saved
1468
1469 if [info exists et_vect_double_saved] {
1470 verbose "check_effective_target_vect_double: using cached result" 2
1471 } else {
1472 set et_vect_double_saved 0
1473 if { [istarget i?86-*-*]
0f6909b9
DN
1474 || [istarget x86_64-*-*]
1475 || [istarget spu-*-*] } {
07d05ffd
JJ
1476 set et_vect_double_saved 1
1477 }
1478 }
1479
1480 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1481 return $et_vect_double_saved
1482}
1483
0f6909b9
DN
1484# Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1485#
1486# This won't change for different subtargets so cache the result.
1487
1488proc check_effective_target_vect_no_compare_double { } {
1489 global et_vect_no_compare_double_saved
1490
1491 if [info exists et_vect_no_compare_double_saved] {
1492 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1493 } else {
1494 set et_vect_no_compare_double_saved 0
1495 if { [istarget spu-*-*] } {
1496 set et_vect_no_compare_double_saved 1
1497 }
1498 }
1499
1500 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1501 return $et_vect_no_compare_double_saved
1502}
1503
eeea13c2 1504# Return 1 if the target plus current options does not support a vector
d5dfe0b8 1505# max instruction on "int", 0 otherwise.
eeea13c2
JJ
1506#
1507# This won't change for different subtargets so cache the result.
1508
d5dfe0b8
RH
1509proc check_effective_target_vect_no_int_max { } {
1510 global et_vect_no_int_max_saved
eeea13c2 1511
d5dfe0b8
RH
1512 if [info exists et_vect_no_int_max_saved] {
1513 verbose "check_effective_target_vect_no_int_max: using cached result" 2
eeea13c2 1514 } else {
d5dfe0b8 1515 set et_vect_no_int_max_saved 0
9fb93f89 1516 if { [istarget sparc*-*-*]
0f6909b9 1517 || [istarget spu-*-*]
eeea13c2 1518 || [istarget alpha*-*-*] } {
d5dfe0b8 1519 set et_vect_no_int_max_saved 1
eeea13c2
JJ
1520 }
1521 }
d5dfe0b8
RH
1522 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1523 return $et_vect_no_int_max_saved
1524}
1525
1526# Return 1 if the target plus current options does not support a vector
1527# add instruction on "int", 0 otherwise.
1528#
1529# This won't change for different subtargets so cache the result.
1530
1531proc check_effective_target_vect_no_int_add { } {
1532 global et_vect_no_int_add_saved
1533
1534 if [info exists et_vect_no_int_add_saved] {
1535 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1536 } else {
1537 set et_vect_no_int_add_saved 0
1538 # Alpha only supports vector add on V8QI and V4HI.
1539 if { [istarget alpha*-*-*] } {
1540 set et_vect_no_int_add_saved 1
1541 }
1542 }
1543 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1544 return $et_vect_no_int_add_saved
eeea13c2
JJ
1545}
1546
1547# Return 1 if the target plus current options does not support vector
1548# bitwise instructions, 0 otherwise.
1549#
1550# This won't change for different subtargets so cache the result.
1551
1552proc check_effective_target_vect_no_bitwise { } {
1553 global et_vect_no_bitwise_saved
1554
1555 if [info exists et_vect_no_bitwise_saved] {
1556 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1557 } else {
1558 set et_vect_no_bitwise_saved 0
eeea13c2
JJ
1559 }
1560 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1561 return $et_vect_no_bitwise_saved
1562}
1563
4035f245
VK
1564# Return 1 if the target plus current options supports a vector
1565# widening summation of *short* args into *int* result, 0 otherwise.
89d67cca
DN
1566# A target can also support this widening summation if it can support
1567# promotion (unpacking) from shorts to ints.
4035f245
VK
1568#
1569# This won't change for different subtargets so cache the result.
1570
1571proc check_effective_target_vect_widen_sum_hi_to_si { } {
1572 global et_vect_widen_sum_hi_to_si
89d67cca 1573
4035f245
VK
1574 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1575 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1576 } else {
89d67cca
DN
1577 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1578 if { [istarget powerpc*-*-*] } {
4035f245
VK
1579 set et_vect_widen_sum_hi_to_si_saved 1
1580 }
1581 }
1582 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1583 return $et_vect_widen_sum_hi_to_si_saved
1584}
1585
1586# Return 1 if the target plus current options supports a vector
1587# widening summation of *char* args into *short* result, 0 otherwise.
89d67cca
DN
1588# A target can also support this widening summation if it can support
1589# promotion (unpacking) from chars to shorts.
4035f245
VK
1590#
1591# This won't change for different subtargets so cache the result.
1592
1593proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1594 global et_vect_widen_sum_qi_to_hi
89d67cca 1595
4035f245
VK
1596 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1597 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1598 } else {
1599 set et_vect_widen_sum_qi_to_hi_saved 0
89d67cca 1600 if { [check_effective_target_vect_unpack] } {
4035f245 1601 set et_vect_widen_sum_qi_to_hi_saved 1
89d67cca 1602 }
4035f245
VK
1603 }
1604 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1605 return $et_vect_widen_sum_qi_to_hi_saved
1606}
1607
1608# Return 1 if the target plus current options supports a vector
1609# widening summation of *char* args into *int* result, 0 otherwise.
1610#
1611# This won't change for different subtargets so cache the result.
1612
1613proc check_effective_target_vect_widen_sum_qi_to_si { } {
1614 global et_vect_widen_sum_qi_to_si
89d67cca 1615
4035f245
VK
1616 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1617 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1618 } else {
1619 set et_vect_widen_sum_qi_to_si_saved 0
1620 if { [istarget powerpc*-*-*] } {
1621 set et_vect_widen_sum_qi_to_si_saved 1
1622 }
1623 }
1624 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1625 return $et_vect_widen_sum_qi_to_si_saved
1626}
1627
20f06221 1628# Return 1 if the target plus current options supports a vector
89d67cca
DN
1629# widening multiplication of *char* args into *short* result, 0 otherwise.
1630# A target can also support this widening multplication if it can support
1631# promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1632# multiplication of shorts).
20f06221
DN
1633#
1634# This won't change for different subtargets so cache the result.
89d67cca
DN
1635
1636
1637proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1638 global et_vect_widen_mult_qi_to_hi
1639
1640 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1641 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
20f06221 1642 } else {
89d67cca
DN
1643 if { [check_effective_target_vect_unpack]
1644 && [check_effective_target_vect_short_mult] } {
1645 set et_vect_widen_mult_qi_to_hi_saved 1
1646 } else {
1647 set et_vect_widen_mult_qi_to_hi_saved 0
1648 }
1649 if { [istarget powerpc*-*-*] } {
1650 set et_vect_widen_mult_qi_to_hi_saved 1
20f06221
DN
1651 }
1652 }
89d67cca
DN
1653 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1654 return $et_vect_widen_mult_qi_to_hi_saved
1655}
1656
1657# Return 1 if the target plus current options supports a vector
1658# widening multiplication of *short* args into *int* result, 0 otherwise.
1659# A target can also support this widening multplication if it can support
1660# promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1661# multiplication of ints).
1662#
1663# This won't change for different subtargets so cache the result.
1664
1665
1666proc check_effective_target_vect_widen_mult_hi_to_si { } {
1667 global et_vect_widen_mult_hi_to_si
1668
1669 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1670 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1671 } else {
1672 if { [check_effective_target_vect_unpack]
1673 && [check_effective_target_vect_int_mult] } {
1674 set et_vect_widen_mult_hi_to_si_saved 1
1675 } else {
1676 set et_vect_widen_mult_hi_to_si_saved 0
1677 }
0e9dac9e 1678 if { [istarget powerpc*-*-*]
c882a2c2 1679 || [istarget spu-*-*]
0e9dac9e
UB
1680 || [istarget i?86-*-*]
1681 || [istarget x86_64-*-*] } {
89d67cca
DN
1682 set et_vect_widen_mult_hi_to_si_saved 1
1683 }
1684 }
1685 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1686 return $et_vect_widen_mult_hi_to_si_saved
20f06221
DN
1687}
1688
1689# Return 1 if the target plus current options supports a vector
1690# dot-product of signed chars, 0 otherwise.
1691#
1692# This won't change for different subtargets so cache the result.
1693
1694proc check_effective_target_vect_sdot_qi { } {
1695 global et_vect_sdot_qi
1696
1697 if [info exists et_vect_sdot_qi_saved] {
1698 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1699 } else {
1700 set et_vect_sdot_qi_saved 0
20f06221
DN
1701 }
1702 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1703 return $et_vect_sdot_qi_saved
1704}
1705
1706# Return 1 if the target plus current options supports a vector
1707# dot-product of unsigned chars, 0 otherwise.
1708#
1709# This won't change for different subtargets so cache the result.
1710
1711proc check_effective_target_vect_udot_qi { } {
1712 global et_vect_udot_qi
1713
1714 if [info exists et_vect_udot_qi_saved] {
1715 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1716 } else {
1717 set et_vect_udot_qi_saved 0
89d67cca 1718 if { [istarget powerpc*-*-*] } {
20f06221
DN
1719 set et_vect_udot_qi_saved 1
1720 }
1721 }
1722 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1723 return $et_vect_udot_qi_saved
1724}
1725
1726# Return 1 if the target plus current options supports a vector
1727# dot-product of signed shorts, 0 otherwise.
1728#
1729# This won't change for different subtargets so cache the result.
1730
1731proc check_effective_target_vect_sdot_hi { } {
1732 global et_vect_sdot_hi
1733
1734 if [info exists et_vect_sdot_hi_saved] {
1735 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1736 } else {
1737 set et_vect_sdot_hi_saved 0
1738 if { [istarget powerpc*-*-*]
1739 || [istarget i?86-*-*]
89d67cca 1740 || [istarget x86_64-*-*] } {
20f06221
DN
1741 set et_vect_sdot_hi_saved 1
1742 }
1743 }
1744 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1745 return $et_vect_sdot_hi_saved
1746}
1747
1748# Return 1 if the target plus current options supports a vector
1749# dot-product of unsigned shorts, 0 otherwise.
1750#
1751# This won't change for different subtargets so cache the result.
1752
1753proc check_effective_target_vect_udot_hi { } {
1754 global et_vect_udot_hi
1755
1756 if [info exists et_vect_udot_hi_saved] {
1757 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1758 } else {
1759 set et_vect_udot_hi_saved 0
1760 if { [istarget powerpc*-*-*] } {
1761 set et_vect_udot_hi_saved 1
1762 }
1763 }
1764 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1765 return $et_vect_udot_hi_saved
1766}
1767
1768
89d67cca
DN
1769# Return 1 if the target plus current options supports a vector
1770# demotion (packing) of shorts (to chars) and ints (to shorts)
1771# using modulo arithmetic, 0 otherwise.
1772#
1773# This won't change for different subtargets so cache the result.
1774
1775proc check_effective_target_vect_pack_mod { } {
1776 global et_vect_pack_mod
1777
1778 if [info exists et_vect_pack_mod_saved] {
1779 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1780 } else {
1781 set et_vect_pack_mod_saved 0
1782 if { [istarget powerpc*-*-*]
1783 || [istarget i?86-*-*]
1784 || [istarget x86_64-*-*] } {
1785 set et_vect_pack_mod_saved 1
1786 }
1787 }
1788 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1789 return $et_vect_pack_mod_saved
1790}
1791
1792# Return 1 if the target plus current options supports a vector
1793# promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1794#
1795# This won't change for different subtargets so cache the result.
1796
1797proc check_effective_target_vect_unpack { } {
1798 global et_vect_unpack
1799
1800 if [info exists et_vect_unpack_saved] {
1801 verbose "check_effective_target_vect_unpack: using cached result" 2
1802 } else {
1803 set et_vect_unpack_saved 0
1804 if { [istarget powerpc*-*-*]
1805 || [istarget i?86-*-*]
1806 || [istarget x86_64-*-*] } {
1807 set et_vect_unpack_saved 1
1808 }
1809 }
1810 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1811 return $et_vect_unpack_saved
1812}
1813
eeea13c2
JJ
1814# Return 1 if the target plus current options does not support a vector
1815# alignment mechanism, 0 otherwise.
1816#
1817# This won't change for different subtargets so cache the result.
1818
1819proc check_effective_target_vect_no_align { } {
1820 global et_vect_no_align_saved
1821
1822 if [info exists et_vect_no_align_saved] {
1823 verbose "check_effective_target_vect_no_align: using cached result" 2
1824 } else {
1825 set et_vect_no_align_saved 0
3e8aba34 1826 if { [istarget mipsisa64*-*-*]
f61134e8
RH
1827 || [istarget sparc*-*-*]
1828 || [istarget ia64-*-*] } {
eeea13c2
JJ
1829 set et_vect_no_align_saved 1
1830 }
1831 }
1832 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1833 return $et_vect_no_align_saved
1834}
1835
b52485c6
DP
1836# Return 1 if the target supports vector conditional operations, 0 otherwise.
1837
1838proc check_effective_target_vect_condition { } {
1839 global et_vect_cond_saved
1840
41a182c6 1841 if [info exists et_vect_cond_saved] {
b52485c6
DP
1842 verbose "check_effective_target_vect_cond: using cached result" 2
1843 } else {
1844 set et_vect_cond_saved 0
ae46a07a
RH
1845 if { [istarget powerpc*-*-*]
1846 || [istarget ia64-*-*]
1847 || [istarget i?86-*-*]
1848 || [istarget x86_64-*-*] } {
b52485c6
DP
1849 set et_vect_cond_saved 1
1850 }
1851 }
1852
1853 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1854 return $et_vect_cond_saved
1855}
1856
4035f245
VK
1857# Return 1 if the target supports vector char multiplication, 0 otherwise.
1858
1859proc check_effective_target_vect_char_mult { } {
1860 global et_vect_char_mult_saved
1861
1862 if [info exists et_vect_char_mult_saved] {
1863 verbose "check_effective_target_vect_char_mult: using cached result" 2
1864 } else {
1865 set et_vect_char_mult_saved 0
1866 if { [istarget ia64-*-*]
1867 || [istarget i?86-*-*]
1868 || [istarget x86_64-*-*] } {
1869 set et_vect_char_mult_saved 1
1870 }
1871 }
1872
1873 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1874 return $et_vect_char_mult_saved
1875}
1876
1877# Return 1 if the target supports vector short multiplication, 0 otherwise.
1878
1879proc check_effective_target_vect_short_mult { } {
1880 global et_vect_short_mult_saved
1881
1882 if [info exists et_vect_short_mult_saved] {
1883 verbose "check_effective_target_vect_short_mult: using cached result" 2
1884 } else {
1885 set et_vect_short_mult_saved 0
1886 if { [istarget ia64-*-*]
1887 || [istarget i?86-*-*]
1888 || [istarget x86_64-*-*] } {
1889 set et_vect_short_mult_saved 1
1890 }
1891 }
1892
1893 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1894 return $et_vect_short_mult_saved
1895}
1896
a45f6936
DP
1897# Return 1 if the target supports vector int multiplication, 0 otherwise.
1898
1899proc check_effective_target_vect_int_mult { } {
1900 global et_vect_int_mult_saved
1901
f12b785d 1902 if [info exists et_vect_int_mult_saved] {
a45f6936
DP
1903 verbose "check_effective_target_vect_int_mult: using cached result" 2
1904 } else {
1905 set et_vect_int_mult_saved 0
2b5bf0e2
RH
1906 if { [istarget powerpc*-*-*]
1907 || [istarget i?86-*-*]
1908 || [istarget x86_64-*-*] } {
a45f6936
DP
1909 set et_vect_int_mult_saved 1
1910 }
1911 }
1912
1913 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1914 return $et_vect_int_mult_saved
1915}
b52485c6 1916
98b44b0e
IR
1917# Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1918
1919proc check_effective_target_vect_extract_even_odd { } {
1920 global et_vect_extract_even_odd_saved
1921
1922 if [info exists et_vect_extract_even_odd_saved] {
1923 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1924 } else {
1925 set et_vect_extract_even_odd_saved 0
1926 if { [istarget powerpc*-*-*] } {
1927 set et_vect_extract_even_odd_saved 1
1928 }
1929 }
1930
1931 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1932 return $et_vect_extract_even_odd_saved
1933}
1934
1935# Return 1 if the target supports vector interleaving, 0 otherwise.
1936
1937proc check_effective_target_vect_interleave { } {
1938 global et_vect_interleave_saved
1939
1940 if [info exists et_vect_interleave_saved] {
1941 verbose "check_effective_target_vect_interleave: using cached result" 2
1942 } else {
1943 set et_vect_interleave_saved 0
1944 if { [istarget powerpc*-*-*]
1945 || [istarget i?86-*-*]
1946 || [istarget x86_64-*-*] } {
1947 set et_vect_interleave_saved 1
1948 }
1949 }
1950
1951 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1952 return $et_vect_interleave_saved
1953}
1954
0be79f24
DN
1955# Return 1 if the target supports section-anchors
1956
1957proc check_effective_target_section_anchors { } {
1958 global et_section_anchors_saved
1959
1960 if [info exists et_section_anchors_saved] {
1961 verbose "check_effective_target_section_anchors: using cached result" 2
1962 } else {
1963 set et_section_anchors_saved 0
1964 if { [istarget powerpc*-*-*] } {
1965 set et_section_anchors_saved 1
1966 }
1967 }
1968
1969 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1970 return $et_section_anchors_saved
1971}
1972
f12b785d
RH
1973# Return 1 if the target supports atomic operations on "int" and "long".
1974
1975proc check_effective_target_sync_int_long { } {
1976 global et_sync_int_long_saved
1977
1978 if [info exists et_sync_int_long_saved] {
1979 verbose "check_effective_target_sync_int_long: using cached result" 2
1980 } else {
1981 set et_sync_int_long_saved 0
915167f5
GK
1982# This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1983# load-reserved/store-conditional instructions.
f12b785d
RH
1984 if { [istarget ia64-*-*]
1985 || [istarget i?86-*-*]
1986 || [istarget x86_64-*-*]
915167f5 1987 || [istarget alpha*-*-*]
89a590b3 1988 || [istarget s390*-*-*]
396b535a
JJ
1989 || [istarget powerpc*-*-*]
1990 || [istarget sparc64-*-*]
1991 || [istarget sparcv9-*-*] } {
f12b785d
RH
1992 set et_sync_int_long_saved 1
1993 }
1994 }
1995
1996 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1997 return $et_sync_int_long_saved
1998}
1999
bc0f348e
GK
2000# Return 1 if the target supports atomic operations on "char" and "short".
2001
2002proc check_effective_target_sync_char_short { } {
2003 global et_sync_char_short_saved
2004
2005 if [info exists et_sync_char_short_saved] {
2006 verbose "check_effective_target_sync_char_short: using cached result" 2
2007 } else {
2008 set et_sync_char_short_saved 0
2009# This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2010# load-reserved/store-conditional instructions.
2011 if { [istarget ia64-*-*]
2012 || [istarget i?86-*-*]
2013 || [istarget x86_64-*-*]
38f31687 2014 || [istarget alpha*-*-*]
3093f076 2015 || [istarget s390*-*-*]
396b535a
JJ
2016 || [istarget powerpc*-*-*]
2017 || [istarget sparc64-*-*]
2018 || [istarget sparcv9-*-*] } {
bc0f348e
GK
2019 set et_sync_char_short_saved 1
2020 }
2021 }
2022
2023 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2024 return $et_sync_char_short_saved
2025}
2026
7fc564b7
RS
2027# Return 1 if the target uses a ColdFire FPU.
2028
2029proc check_effective_target_coldfire_fpu { } {
2030 return [check_no_compiler_messages coldfire_fpu assembly {
2031 #ifndef __mcffpu__
2032 #error FOO
2033 #endif
2034 }]
2035}
2036
2755c056
RS
2037# Return true if this is a uClibc target.
2038
2039proc check_effective_target_uclibc {} {
2040 return [check_no_compiler_messages uclibc object {
2041 #include <features.h>
2042 #if !defined (__UCLIBC__)
2043 #error FOO
2044 #endif
2045 }]
2046}
2047
a5ea7a0b
RS
2048# Return 1 if
2049# (a) an error of a few ULP is expected in string to floating-point
2050# conversion functions; and
2051# (b) overflow is not always detected correctly by those functions.
2052
2053proc check_effective_target_lax_strtofp {} {
2054 # By default, assume that all uClibc targets suffer from this.
2055 return [check_effective_target_uclibc]
2056}
2057
2058# Return 1 if this is a target for which wcsftime is a dummy
2059# function that always returns 0.
2060
2061proc check_effective_target_dummy_wcsftime {} {
2062 # By default, assume that all uClibc targets suffer from this.
2063 return [check_effective_target_uclibc]
2064}
2065
b6dc500c
JJ
2066# Return 1 if the target matches the effective target 'arg', 0 otherwise.
2067# This can be used with any check_* proc that takes no argument and
2068# returns only 1 or 0. It could be used with check_* procs that take
2069# arguments with keywords that pass particular arguments.
2070
2071proc is-effective-target { arg } {
2072 set selected 0
68897708
JJ
2073 if { [info procs check_effective_target_${arg}] != [list] } {
2074 set selected [check_effective_target_${arg}]
2075 } else {
2076 switch $arg {
2077 "vmx_hw" { set selected [check_vmx_hw_available] }
2078 "named_sections" { set selected [check_named_sections_available] }
2079 "gc_sections" { set selected [check_gc_sections_available] }
294f1ce3 2080 "cxa_atexit" { set selected [check_cxa_atexit_available] }
68897708
JJ
2081 default { error "unknown effective target keyword `$arg'" }
2082 }
b6dc500c
JJ
2083 }
2084 verbose "is-effective-target: $arg $selected" 2
2085 return $selected
2086}
810838e7
JJ
2087
2088# Return 1 if the argument is an effective-target keyword, 0 otherwise.
2089
2090proc is-effective-target-keyword { arg } {
2091 if { [info procs check_effective_target_${arg}] != [list] } {
2092 return 1
2093 } else {
2094 # These have different names for their check_* procs.
2095 switch $arg {
2096 "vmx_hw" { return 1 }
2097 "named_sections" { return 1 }
2098 "gc_sections" { return 1 }
294f1ce3 2099 "cxa_atexit" { return 1 }
810838e7
JJ
2100 default { return 0 }
2101 }
2102 }
2103}
efe5e271
PB
2104
2105# Return 1 if target default to short enums
2106
2107proc check_effective_target_short_enums { } {
8ce1ac69
RS
2108 return [check_no_compiler_messages short_enums assembly {
2109 enum foo { bar };
2110 int s[sizeof (enum foo) == 1 ? 1 : -1];
2111 }]
efe5e271
PB
2112}
2113
19450f2b
DJ
2114# Return 1 if target supports merging string constants at link time.
2115
2116proc check_effective_target_string_merging { } {
2117 return [check_no_messages_and_pattern string_merging \
2118 "rodata\\.str" assembly {
2119 const char *var = "String";
2120 } {-O2}]
2121}
8f3fc4aa
JDA
2122
2123# Return 1 if target has the basic signed and unsigned types in
2124# <stdint.h>, 0 otherwise.
2125
2126proc check_effective_target_stdint_types { } {
2127 return [check_no_compiler_messages stdint_types assembly {
2128 #include <stdint.h>
2129 int8_t a; int16_t b; int32_t c; int64_t d;
2130 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2131 }]
2132}
3920f1fd
HPN
2133
2134# Return 1 if programs are intended to be run on a simulator
2135# (i.e. slowly) rather than hardware (i.e. fast).
2136
2137proc check_effective_target_simulator { } {
2138
2139 # All "src/sim" simulators set this one.
2140 if [board_info target exists is_simulator] {
2141 return [board_info target is_simulator]
2142 }
2143
2144 # The "sid" simulators don't set that one, but at least they set
2145 # this one.
2146 if [board_info target exists slow_simulator] {
2147 return [board_info target slow_simulator]
2148 }
2149
2150 return 0
2151}