* doc/extend.texi: Document optional priority argument to
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob2682f8f4b7d9e1fec9f067b298454a7603f02770
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
2 # Free Software Foundation, Inc.
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.
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.
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
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.
27 # BASENAME is a basename to use for temporary files.
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.
32 # TYPE is the type of compilation to perform (see target_compile).
33 # CONTENTS gives the contents of the input file.
34 # The rest is optional:
35 # OPTIONS: additional compiler options to use.
36 proc get_compiler_messages {basename want_output type contents args} {
37 global tool
39 if { [llength $args] > 0 } {
40 set options [list "additional_flags=[lindex $args 0]"]
41 } else {
42 set options ""
45 set src ${basename}[pid].c
46 switch $type {
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
50 set f [open $src "w"]
51 puts $f $contents
52 close $f
53 set lines [${tool}_target_compile $src $output $type "$options"]
54 file delete $src
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"
68 close $chan
69 set result [list $lines $text]
71 } else {
72 set result $lines
75 remote_file build delete $output
76 return $result
79 proc 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 ""
86 return $answer
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.
93 proc check_no_compiler_messages {prop args} {
94 global et_cache
96 set target [current_target_name]
97 if {![info exists et_cache($prop,target)]
98 || $et_cache($prop,target) != $target} {
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]]
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
106 return $value
109 # Similar to check_no_compiler_messages, but also verify that the regular
110 # expression PATTERN matches the compiler's output.
111 proc check_no_messages_and_pattern {prop pattern args} {
112 global et_cache
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
118 set et_cache($prop,target) $target
119 set results [eval get_compiler_messages $prop 1 $args]
120 set et_cache($prop,value) \
121 [expr [string match "" [lindex $results 0]] \
122 && [regexp $pattern [lindex $results 1]]]
124 set value $et_cache($prop,value)
125 verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
126 return $value
129 ###############################
130 # proc check_weak_available { }
131 ###############################
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
136 proc check_weak_available { } {
137 global target_triplet
138 global target_cpu
140 # All mips targets should support it
142 if { [ string first "mips" $target_cpu ] >= 0 } {
143 return 1
146 # All solaris2 targets should support it
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
149 return 1
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
155 return 1
158 # Windows targets Cygwin and MingW32 support it
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
161 return 1
164 # HP-UX 10.X doesn't support it
166 if { [istarget "hppa*-*-hpux10*"] } {
167 return 0
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
173 set objformat [gcc_target_object_format]
175 switch $objformat {
176 elf { return 1 }
177 ecoff { return 1 }
178 a.out { return 1 }
179 mach-o { return 1 }
180 som { return 1 }
181 unknown { return -1 }
182 default { return 0 }
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
190 # The visibility attribute is only support in some object formats
191 # This proc returns 1 if it is supported, 0 if not.
192 # The argument is the kind of visibility, default/protected/hidden/internal.
194 proc check_visibility_available { what_kind } {
195 global tool
196 global target_triplet
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
200 return 0
203 if [string match "" $what_kind] { set what_kind "hidden" }
205 return [check_no_compiler_messages visibility_available_$what_kind object "
206 void f() __attribute__((visibility(\"$what_kind\")));
207 void f() {}
211 ###############################
212 # proc check_alias_available { }
213 ###############################
215 # Determine if the target toolchain supports the alias attribute.
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.
222 proc check_alias_available { } {
223 global alias_available_saved
224 global tool
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
228 } else {
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"]
233 # Compile a small test program. The definition of "g" is
234 # necessary to keep the Solaris assembler from complaining
235 # about the program.
236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
238 close $f
239 set lines [${tool}_target_compile $src $obj object ""]
240 file delete $src
241 remote_file build delete $obj
243 if [string match "" $lines] then {
244 # No error messages, everything is OK.
245 set alias_available_saved 2
246 } else {
247 if [regexp "alias definitions not supported" $lines] {
248 verbose "check_alias_available target does not support aliases" 2
250 set objformat [gcc_target_object_format]
252 if { $objformat == "elf" } {
253 verbose "check_alias_available but target uses ELF format, so it ought to" 2
254 set alias_available_saved -1
255 } else {
256 set alias_available_saved 0
258 } else {
259 if [regexp "only weak aliases are supported" $lines] {
260 verbose "check_alias_available target supports only weak aliases" 2
261 set alias_available_saved 1
262 } else {
263 set alias_available_saved -1
268 verbose "check_alias_available returning $alias_available_saved" 2
271 return $alias_available_saved
274 # Returns true if --gc-sections is supported on the target.
276 proc check_gc_sections_available { } {
277 global gc_sections_available_saved
278 global tool
280 if {![info exists gc_sections_available_saved]} {
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
289 # Check if the ld used by gcc supports --gc-sections.
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]
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
300 return $gc_sections_available_saved
303 # Return true if profiling is supported on the target.
305 proc check_profiling_available { test_what } {
306 global profiling_available_saved
308 verbose "Profiling argument is <$test_what>" 1
310 # These conditions depend on the argument so examine them before
311 # looking at the cache variable.
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
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
325 if { [istarget mips*-*-irix*]
326 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
327 return 0
330 # At present, there is no profiling support on NetWare.
331 if { [istarget *-*-netware*] } {
332 return 0
335 # Now examine the cache variable.
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-*-*]
340 || [istarget arm*-*-eabi*]
341 || [istarget arm*-*-elf]
342 || [istarget arm*-*-symbianelf*]
343 || [istarget powerpc-*-eabi*]
344 || [istarget strongarm*-*-elf]
345 || [istarget xscale*-*-elf]
346 || [istarget cris-*-*]
347 || [istarget h8300-*-*]
348 || [istarget m32c-*-elf]
349 || [istarget m68k-*-elf]
350 || [istarget mips*-*-elf]
351 || [istarget xtensa-*-elf]
352 || [istarget *-*-windiss] } {
353 set profiling_available_saved 0
354 } else {
355 set profiling_available_saved 1
359 return $profiling_available_saved
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.
367 proc check_effective_target_default_packed { } {
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];
374 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
375 # documentation, where the test also comes from.
377 proc check_effective_target_pcc_bitfield_type_matters { } {
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];
387 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
389 # This won't change for different subtargets so cache the result.
391 proc check_effective_target_tls {} {
392 global et_tls_saved
393 global tool
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
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
408 # Test for thread-local data supported by the platform.
409 set comp_output [${tool}_target_compile $src $asm assembly ""]
410 file delete $src
411 if { [string match "*not supported*" $comp_output] } {
412 set et_tls_saved 0
413 } else {
414 set fd [open $asm r]
415 set text [read $fd]
416 close $fd
417 if { [string match "*emutls*" $text]} {
418 set et_tls_saved 0
419 } else {
420 set et_tls_saved 1
423 remove-build-file $asm
425 verbose "check_effective_target_tls: returning $et_tls_saved" 2
426 return $et_tls_saved
429 # Return 1 if TLS executables can run correctly, 0 otherwise.
431 # This won't change for different subtargets so cache the result.
433 proc check_effective_target_tls_runtime {} {
434 global et_tls_runtime_saved
435 global tool
437 if [info exists et_tls_runtime_saved] {
438 verbose "check_effective_target_tls_runtime: using cached result" 2
439 } else {
440 set et_tls_runtime_saved 0
442 set src tls_runtime[pid].c
443 set exe tls_runtime[pid].x
444 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
445 set f [open $src "w"]
446 # Compile a small test program.
447 puts $f "__thread int thr = 0;\n"
448 puts $f "int main(void)\n {\n return thr;\n}"
449 close $f
451 set comp_output \
452 [${tool}_target_compile $src $exe executable ""]
453 file delete $src
455 if [string match "" $comp_output] then {
456 # No error messages, everything is OK.
458 set result [remote_load target "./$exe" "" ""]
459 set status [lindex $result 0]
460 remote_file build delete $exe
462 verbose "check_effective_target_tls_runtime status is <$status>" 2
464 if { $status == "pass" } {
465 set et_tls_runtime_saved 1
468 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
472 return $et_tls_runtime_saved
475 # Return 1 if compilation with -fopenmp is error-free for trivial
476 # code, 0 otherwise.
478 proc check_effective_target_fopenmp {} {
479 return [check_no_compiler_messages fopenmp object {
480 void foo (void) { }
481 } "-fopenmp"]
484 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
485 # for trivial code, 0 otherwise.
487 proc check_effective_target_freorder {} {
488 return [check_no_compiler_messages freorder object {
489 void foo (void) { }
490 } "-freorder-blocks-and-partition"]
493 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
494 # emitted, 0 otherwise. Whether a shared library can actually be built is
495 # out of scope for this test.
497 proc check_effective_target_fpic { } {
498 # Note that M68K has a multilib that supports -fpic but not
499 # -fPIC, so we need to check both. We test with a program that
500 # requires GOT references.
501 foreach arg {fpic fPIC} {
502 if [check_no_compiler_messages $arg object {
503 extern int foo (void); extern int bar;
504 int baz (void) { return foo () + bar; }
505 } "-$arg"] {
506 return 1
509 return 0
512 # Return true if the target supports -mpaired-single (as used on MIPS).
514 proc check_effective_target_mpaired_single { } {
515 return [check_no_compiler_messages mpaired_single object {
516 void foo (void) { }
517 } "-mpaired-single"]
520 # Return 1 if the target does not use a status wrapper.
522 proc check_effective_target_unwrapped { } {
523 if { [target_info needs_status_wrapper] != "" \
524 && [target_info needs_status_wrapper] != "0" } {
525 return 0
527 return 1
530 # Return true if iconv is supported on the target. In particular IBM1047.
532 proc check_iconv_available { test_what } {
533 global tool
534 global libiconv
536 set result ""
538 set src iconv[pid].c
539 set exe iconv[pid].x
540 verbose "check_iconv_available compiling testfile $src" 2
541 set f [open $src "w"]
542 # Compile a small test program.
543 puts $f "#include <iconv.h>\n"
544 puts $f "int main (void)\n {\n iconv_t cd; \n"
545 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
546 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
547 puts $f "return 0;\n}"
548 close $f
550 # If the tool configuration file has not set libiconv, try "-liconv"
551 if { ![info exists libiconv] } {
552 set libiconv "-liconv"
554 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
555 file delete $src
557 if [string match "" $lines] then {
558 # No error messages, everything is OK.
560 set result [${tool}_load "./$exe" "" ""]
561 set status [lindex $result 0]
562 remote_file build delete $exe
564 verbose "check_iconv_available status is <$status>" 2
566 if { $status == "pass" } then {
567 return 1
571 return 0
574 # Return true if named sections are supported on this target.
576 proc check_named_sections_available { } {
577 return [check_no_compiler_messages named_sections assembly {
578 int __attribute__ ((section("whatever"))) foo;
582 # Return 1 if the target supports Fortran real kinds larger than real(8),
583 # 0 otherwise.
585 # When the target name changes, replace the cached result.
587 proc check_effective_target_fortran_large_real { } {
588 global et_fortran_large_real_saved
589 global et_fortran_large_real_target_name
590 global tool
592 if { ![info exists et_fortran_large_real_target_name] } {
593 set et_fortran_large_real_target_name ""
596 # If the target has changed since we set the cached value, clear it.
597 set current_target [current_target_name]
598 if { $current_target != $et_fortran_large_real_target_name } {
599 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
600 set et_fortran_large_real_target_name $current_target
601 if [info exists et_fortran_large_real_saved] {
602 verbose "check_effective_target_fortran_large_real: removing cached result" 2
603 unset et_fortran_large_real_saved
607 if [info exists et_fortran_large_real_saved] {
608 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
609 } else {
610 set et_fortran_large_real_saved 0
612 # Set up, compile, and execute a test program using large real
613 # kinds. Include the current process ID in the file names to
614 # prevent conflicts with invocations for multiple testsuites.
615 set src real[pid].f90
616 set exe real[pid].x
618 set f [open $src "w"]
619 puts $f "integer,parameter :: k = &"
620 puts $f " selected_real_kind (precision (0.0_8) + 1)"
621 puts $f "real(kind=k) :: x"
622 puts $f "x = cos (x);"
623 puts $f "end"
624 close $f
626 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
627 set lines [${tool}_target_compile $src $exe executable ""]
628 file delete $src
630 if [string match "" $lines] then {
631 # No error message, compilation succeeded.
632 set et_fortran_large_real_saved 1
636 return $et_fortran_large_real_saved
639 # Return 1 if the target supports Fortran integer kinds larger than
640 # integer(8), 0 otherwise.
642 # When the target name changes, replace the cached result.
644 proc check_effective_target_fortran_large_int { } {
645 global et_fortran_large_int_saved
646 global et_fortran_large_int_target_name
647 global tool
649 if { ![info exists et_fortran_large_int_target_name] } {
650 set et_fortran_large_int_target_name ""
653 # If the target has changed since we set the cached value, clear it.
654 set current_target [current_target_name]
655 if { $current_target != $et_fortran_large_int_target_name } {
656 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
657 set et_fortran_large_int_target_name $current_target
658 if [info exists et_fortran_large_int_saved] {
659 verbose "check_effective_target_fortran_large_int: removing cached result" 2
660 unset et_fortran_large_int_saved
664 if [info exists et_fortran_large_int_saved] {
665 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
666 } else {
667 set et_fortran_large_int_saved 0
669 # Set up, compile, and execute a test program using large integer
670 # kinds. Include the current process ID in the file names to
671 # prevent conflicts with invocations for multiple testsuites.
672 set src int[pid].f90
673 set exe int[pid].x
675 set f [open $src "w"]
676 puts $f "integer,parameter :: k = &"
677 puts $f " selected_int_kind (range (0_8) + 1)"
678 puts $f "integer(kind=k) :: i"
679 puts $f "end"
680 close $f
682 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
683 set lines [${tool}_target_compile $src $exe executable ""]
684 file delete $src
686 if [string match "" $lines] then {
687 # No error message, compilation succeeded.
688 set et_fortran_large_int_saved 1
692 return $et_fortran_large_int_saved
695 # Return 1 if we can statically link libgfortran, 0 otherwise.
697 # When the target name changes, replace the cached result.
699 proc check_effective_target_static_libgfortran { } {
700 global et_static_libgfortran
701 global et_static_libgfortran_target_name
702 global tool
704 if { ![info exists et_static_libgfortran_target_name] } {
705 set et_static_libgfortran_target_name ""
708 # If the target has changed since we set the cached value, clear it.
709 set current_target [current_target_name]
710 if { $current_target != $et_static_libgfortran_target_name } {
711 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
712 set et_static_libgfortran_target_name $current_target
713 if [info exists et_static_libgfortran_saved] {
714 verbose "check_effective_target_static_libgfortran: removing cached result" 2
715 unset et_static_libgfortran_saved
719 if [info exists et_static_libgfortran_saved] {
720 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
721 } else {
722 set et_static_libgfortran_saved 0
724 # Set up, compile, and execute a test program using static linking.
725 # Include the current process ID in the file names to prevent
726 # conflicts with invocations for multiple testsuites.
727 set opts "additional_flags=-static"
728 set src static[pid].f
729 set exe static[pid].x
731 set f [open $src "w"]
732 puts $f " print *, 'test'"
733 puts $f " end"
734 close $f
736 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
737 set lines [${tool}_target_compile $src $exe executable "$opts"]
738 file delete $src
740 if [string match "" $lines] then {
741 # No error message, compilation succeeded.
742 set et_static_libgfortran_saved 1
746 return $et_static_libgfortran_saved
749 # Return 1 if the target supports executing AltiVec instructions, 0
750 # otherwise. Cache the result.
752 proc check_vmx_hw_available { } {
753 global vmx_hw_available_saved
754 global tool
756 if [info exists vmx_hw_available_saved] {
757 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
758 } else {
759 set vmx_hw_available_saved 0
761 # Some simulators are known to not support VMX instructions.
762 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
763 verbose "check_hw_available returning 0" 2
764 return $vmx_hw_available_saved
767 # Set up, compile, and execute a test program containing VMX
768 # instructions. Include the current process ID in the file
769 # names to prevent conflicts with invocations for multiple
770 # testsuites.
771 set src vmx[pid].c
772 set exe vmx[pid].x
774 set f [open $src "w"]
775 puts $f "int main() {"
776 puts $f "#ifdef __MACH__"
777 puts $f " asm volatile (\"vor v0,v0,v0\");"
778 puts $f "#else"
779 puts $f " asm volatile (\"vor 0,0,0\");"
780 puts $f "#endif"
781 puts $f " return 0; }"
782 close $f
784 # Most targets don't require special flags for this test case, but
785 # Darwin does.
786 if [istarget *-*-darwin*] {
787 set opts "additional_flags=-maltivec"
788 } else {
789 set opts ""
792 verbose "check_vmx_hw_available compiling testfile $src" 2
793 set lines [${tool}_target_compile $src $exe executable "$opts"]
794 file delete $src
796 if [string match "" $lines] then {
797 # No error message, compilation succeeded.
798 set result [${tool}_load "./$exe" "" ""]
799 set status [lindex $result 0]
800 remote_file build delete $exe
801 verbose "check_vmx_hw_available testfile status is <$status>" 2
803 if { $status == "pass" } then {
804 set vmx_hw_available_saved 1
806 } else {
807 verbose "check_vmx_hw_availalble testfile compilation failed" 2
811 return $vmx_hw_available_saved
814 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
815 # complex float arguments. This affects gfortran tests that call cabsf
816 # in libm built by an earlier compiler. Return 1 if libm uses the same
817 # argument passing as the compiler under test, 0 otherwise.
819 # When the target name changes, replace the cached result.
821 proc check_effective_target_broken_cplxf_arg { } {
822 global et_broken_cplxf_arg_saved
823 global et_broken_cplxf_arg_target_name
824 global tool
826 # Skip the work for targets known not to be affected.
827 if { ![istarget powerpc64-*-linux*] } {
828 return 0
829 } elseif { [is-effective-target ilp32] } {
830 return 0
833 if { ![info exists et_broken_cplxf_arg_target_name] } {
834 set et_broken_cplxf_arg_target_name ""
837 # If the target has changed since we set the cached value, clear it.
838 set current_target [current_target_name]
839 if { $current_target != $et_broken_cplxf_arg_target_name } {
840 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
841 set et_broken_cplxf_arg_target_name $current_target
842 if [info exists et_broken_cplxf_arg_saved] {
843 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
844 unset et_broken_cplxf_arg_saved
848 if [info exists et_broken_cplxf_arg_saved] {
849 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
850 } else {
851 set et_broken_cplxf_arg_saved 0
852 # This is only known to affect one target.
853 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
854 set et_broken_cplxf_arg_saved 0
855 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
856 return $et_broken_cplxf_arg_saved
859 # Set up, compile, and execute a C test program that calls cabsf.
860 set src cabsf[pid].c
861 set exe cabsf[pid].x
863 set f [open $src "w"]
864 puts $f "#include <complex.h>"
865 puts $f "extern void abort (void);"
866 puts $f "float fabsf (float);"
867 puts $f "float cabsf (_Complex float);"
868 puts $f "int main ()"
869 puts $f "{"
870 puts $f " _Complex float cf;"
871 puts $f " float f;"
872 puts $f " cf = 3 + 4.0fi;"
873 puts $f " f = cabsf (cf);"
874 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
875 puts $f " return 0;"
876 puts $f "}"
877 close $f
879 set lines [${tool}_target_compile $src $exe executable "-lm"]
880 file delete $src
882 if [string match "" $lines] {
883 # No error message, compilation succeeded.
884 set result [${tool}_load "./$exe" "" ""]
885 set status [lindex $result 0]
886 remote_file build delete $exe
888 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
890 if { $status != "pass" } {
891 set et_broken_cplxf_arg_saved 1
893 } else {
894 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
897 return $et_broken_cplxf_arg_saved
900 proc check_alpha_max_hw_available { } {
901 global alpha_max_hw_available_saved
902 global tool
904 if [info exists alpha_max_hw_available_saved] {
905 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
906 } else {
907 set alpha_max_hw_available_saved 0
909 # Set up, compile, and execute a test program probing bit 8 of the
910 # architecture mask, which indicates presence of MAX instructions.
911 set src max[pid].c
912 set exe max[pid].x
914 set f [open $src "w"]
915 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
916 close $f
918 verbose "check_alpha_max_hw_available compiling testfile $src" 2
919 set lines [${tool}_target_compile $src $exe executable ""]
920 file delete $src
922 if [string match "" $lines] then {
923 # No error message, compilation succeeded.
924 set result [${tool}_load "./$exe" "" ""]
925 set status [lindex $result 0]
926 remote_file build delete $exe
927 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
929 if { $status == "pass" } then {
930 set alpha_max_hw_available_saved 1
932 } else {
933 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
937 return $alpha_max_hw_available_saved
940 # Returns true iff the FUNCTION is available on the target system.
941 # (This is essentially a Tcl implementation of Autoconf's
942 # AC_CHECK_FUNC.)
944 proc check_function_available { function } {
945 set var "${function}_available_saved"
946 global $var
947 global tool
949 if {![info exists $var]} {
950 # Assume it exists.
951 set $var 1
952 # Check to make sure.
953 set src "function[pid].c"
954 set exe "function[pid].exe"
956 set f [open $src "w"]
957 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
958 puts $f "char $function ();\n"
959 puts $f "int main () { $function (); }"
960 close $f
962 set lines [${tool}_target_compile $src $exe executable ""]
963 file delete $src
964 file delete $exe
966 if {![string match "" $lines]} then {
967 set $var 0
968 verbose -log "$function is not available"
969 } else {
970 verbose -log "$function is available"
974 eval return \$$var
977 # Returns true iff "fork" is available on the target system.
979 proc check_fork_available {} {
980 return [check_function_available "fork"]
983 # Returns true iff "mkfifo" is available on the target system.
985 proc check_mkfifo_available {} {
986 if {[istarget *-*-cygwin*]} {
987 # Cygwin has mkfifo, but support is incomplete.
988 return 0
991 return [check_function_available "mkfifo"]
994 # Returns true iff "__cxa_atexit" is used on the target system.
996 proc check_cxa_atexit_available { } {
997 global et_cxa_atexit
998 global et_cxa_atexit_target_name
999 global tool
1001 if { ![info exists et_cxa_atexit_target_name] } {
1002 set et_cxa_atexit_target_name ""
1005 # If the target has changed since we set the cached value, clear it.
1006 set current_target [current_target_name]
1007 if { $current_target != $et_cxa_atexit_target_name } {
1008 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1009 set et_cxa_atexit_target_name $current_target
1010 if [info exists et_cxa_atexit] {
1011 verbose "check_cxa_atexit_available: removing cached result" 2
1012 unset et_cxa_atexit
1016 if [info exists et_cxa_atexit] {
1017 verbose "check_cxa_atexit_available: using cached result" 2
1018 } elseif { [istarget "hppa*-*-hpux10*"] } {
1019 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1020 set et_cxa_atexit 0
1021 } else {
1022 set et_cxa_atexit 0
1024 # Set up, compile, and execute a C++ test program that depends
1025 # on correct ordering of static object destructors. This is
1026 # indicative of the presence and use of __cxa_atexit.
1027 set src cxaatexit[pid].cc
1028 set exe cxaatexit[pid].x
1030 set f [open $src "w"]
1031 puts $f "#include <stdlib.h>"
1032 puts $f "static unsigned int count;"
1033 puts $f "struct X"
1034 puts $f "{"
1035 puts $f " X() { count = 1; }"
1036 puts $f " ~X()"
1037 puts $f " {"
1038 puts $f " if (count != 3)"
1039 puts $f " exit(1);"
1040 puts $f " count = 4;"
1041 puts $f " }"
1042 puts $f "};"
1043 puts $f "void f()"
1044 puts $f "{"
1045 puts $f " static X x;"
1046 puts $f "}"
1047 puts $f "struct Y"
1048 puts $f "{"
1049 puts $f " Y() { f(); count = 2; }"
1050 puts $f " ~Y()"
1051 puts $f " {"
1052 puts $f " if (count != 2)"
1053 puts $f " exit(1);"
1054 puts $f " count = 3;"
1055 puts $f " }"
1056 puts $f "};"
1057 puts $f "Y y;"
1058 puts $f "int main()"
1059 puts $f "{ return 0; }"
1060 close $f
1062 set lines [${tool}_target_compile $src $exe executable ""]
1063 file delete $src
1065 if [string match "" $lines] {
1066 # No error message, compilation succeeded.
1067 set result [${tool}_load "./$exe" "" ""]
1068 set status [lindex $result 0]
1069 remote_file build delete $exe
1071 verbose "check_cxa_atexit_available: status is <$status>" 2
1073 if { $status == "pass" } {
1074 set et_cxa_atexit 1
1076 } else {
1077 verbose "check_cxa_atexit_available: compilation failed" 2
1080 return $et_cxa_atexit
1084 # Return 1 if we're generating 32-bit code using default options, 0
1085 # otherwise.
1087 proc check_effective_target_ilp32 { } {
1088 return [check_no_compiler_messages ilp32 object {
1089 int dummy[sizeof (int) == 4
1090 && sizeof (void *) == 4
1091 && sizeof (long) == 4 ? 1 : -1];
1095 # Return 1 if we're generating 32-bit or larger integers using default
1096 # options, 0 otherwise.
1098 proc check_effective_target_int32plus { } {
1099 return [check_no_compiler_messages int32plus object {
1100 int dummy[sizeof (int) >= 4 ? 1 : -1];
1104 # Return 1 if we're generating 32-bit or larger pointers using default
1105 # options, 0 otherwise.
1107 proc check_effective_target_ptr32plus { } {
1108 return [check_no_compiler_messages ptr32plus object {
1109 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1113 # Return 1 if we support 32-bit or larger array and structure sizes
1114 # using default options, 0 otherwise.
1116 proc check_effective_target_size32plus { } {
1117 return [check_no_compiler_messages size32plus object {
1118 char dummy[65537];
1122 # Returns 1 if we're generating 16-bit or smaller integers with the
1123 # default options, 0 otherwise.
1125 proc check_effective_target_int16 { } {
1126 return [check_no_compiler_messages int16 object {
1127 int dummy[sizeof (int) < 4 ? 1 : -1];
1131 # Return 1 if we're generating 64-bit code using default options, 0
1132 # otherwise.
1134 proc check_effective_target_lp64 { } {
1135 return [check_no_compiler_messages lp64 object {
1136 int dummy[sizeof (int) == 4
1137 && sizeof (void *) == 8
1138 && sizeof (long) == 8 ? 1 : -1];
1142 # Return 1 if the target supports long double larger than double,
1143 # 0 otherwise.
1145 proc check_effective_target_large_long_double { } {
1146 return [check_no_compiler_messages large_long_double object {
1147 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1152 # Return 1 if the target supports compiling decimal floating point,
1153 # 0 otherwise.
1155 proc check_effective_target_dfp_nocache { } {
1156 verbose "check_effective_target_dfp_nocache: compiling source" 2
1157 set ret [string match "" [get_compiler_messages dfp 0 object {
1158 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1160 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1161 return $ret
1164 proc check_effective_target_dfprt_nocache { } {
1165 global tool
1167 set ret 0
1169 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1170 # Set up, compile, and execute a test program containing decimal
1171 # float operations.
1172 set src dfprt[pid].c
1173 set exe dfprt[pid].x
1175 set f [open $src "w"]
1176 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1177 puts $f "int main () { z = x + y; return 0; }"
1178 close $f
1180 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1181 set lines [${tool}_target_compile $src $exe executable ""]
1182 file delete $src
1184 if [string match "" $lines] then {
1185 # No error message, compilation succeeded.
1186 set result [${tool}_load "./$exe" "" ""]
1187 set status [lindex $result 0]
1188 remote_file build delete $exe
1189 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1190 if { $status == "pass" } then {
1191 set ret 1
1194 return $ret
1195 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1198 # Return 1 if the target supports compiling Decimal Floating Point,
1199 # 0 otherwise.
1201 # This won't change for different subtargets so cache the result.
1203 proc check_effective_target_dfp { } {
1204 global et_dfp_saved
1206 if [info exists et_dfp_saved] {
1207 verbose "check_effective_target_dfp: using cached result" 2
1208 } else {
1209 set et_dfp_saved [check_effective_target_dfp_nocache]
1211 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1212 return $et_dfp_saved
1215 # Return 1 if the target supports linking and executing Decimal Floating
1216 # Point, # 0 otherwise.
1218 # This won't change for different subtargets so cache the result.
1220 proc check_effective_target_dfprt { } {
1221 global et_dfprt_saved
1222 global tool
1224 if [info exists et_dfprt_saved] {
1225 verbose "check_effective_target_dfprt: using cached result" 2
1226 } else {
1227 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1229 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1230 return $et_dfprt_saved
1233 # Return 1 if the target needs a command line argument to enable a SIMD
1234 # instruction set.
1236 proc check_effective_target_vect_cmdline_needed { } {
1237 global et_vect_cmdline_needed_saved
1238 global et_vect_cmdline_needed_target_name
1240 if { ![info exists et_vect_cmdline_needed_target_name] } {
1241 set et_vect_cmdline_needed_target_name ""
1244 # If the target has changed since we set the cached value, clear it.
1245 set current_target [current_target_name]
1246 if { $current_target != $et_vect_cmdline_needed_target_name } {
1247 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1248 set et_vect_cmdline_needed_target_name $current_target
1249 if { [info exists et_vect_cmdline_needed_saved] } {
1250 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1251 unset et_vect_cmdline_needed_saved
1255 if [info exists et_vect_cmdline_needed_saved] {
1256 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1257 } else {
1258 set et_vect_cmdline_needed_saved 1
1259 if { [istarget ia64-*-*]
1260 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1261 && [check_effective_target_lp64])
1262 || ([istarget powerpc*-*-*]
1263 && ([check_effective_target_powerpc_spe]
1264 || [check_effective_target_powerpc_altivec]))} {
1265 set et_vect_cmdline_needed_saved 0
1269 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1270 return $et_vect_cmdline_needed_saved
1273 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1275 # This won't change for different subtargets so cache the result.
1277 proc check_effective_target_vect_int { } {
1278 global et_vect_int_saved
1280 if [info exists et_vect_int_saved] {
1281 verbose "check_effective_target_vect_int: using cached result" 2
1282 } else {
1283 set et_vect_int_saved 0
1284 if { [istarget i?86-*-*]
1285 || [istarget powerpc*-*-*]
1286 || [istarget spu-*-*]
1287 || [istarget x86_64-*-*]
1288 || [istarget sparc*-*-*]
1289 || [istarget alpha*-*-*]
1290 || [istarget ia64-*-*] } {
1291 set et_vect_int_saved 1
1295 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1296 return $et_vect_int_saved
1299 # Return 1 is this is an arm target using 32-bit instructions
1300 proc check_effective_target_arm32 { } {
1301 global et_arm32_saved
1302 global et_arm32_target_name
1303 global compiler_flags
1305 if { ![info exists et_arm32_target_name] } {
1306 set et_arm32_target_name ""
1309 # If the target has changed since we set the cached value, clear it.
1310 set current_target [current_target_name]
1311 if { $current_target != $et_arm32_target_name } {
1312 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1313 set et_arm32_target_name $current_target
1314 if { [info exists et_arm32_saved] } {
1315 verbose "check_effective_target_arm32: removing cached result" 2
1316 unset et_arm32_saved
1320 if [info exists et_arm32_saved] {
1321 verbose "check-effective_target_arm32: using cached result" 2
1322 } else {
1323 set et_arm32_saved 0
1324 if { [istarget arm-*-*]
1325 || [istarget strongarm*-*-*]
1326 || [istarget xscale-*-*] } {
1327 if ![string match "*-mthumb *" $compiler_flags] {
1328 set et_arm32_saved 1
1332 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1333 return $et_arm32_saved
1336 # Return 1 if this is an ARM target supporting -mfpu=vfp
1337 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1338 # options.
1340 proc check_effective_target_arm_vfp_ok { } {
1341 if { [check_effective_target_arm32] } {
1342 return [check_no_compiler_messages arm_vfp_ok object {
1343 int dummy;
1344 } "-mfpu=vfp -mfloat-abi=softfp"]
1345 } else {
1346 return 0
1350 # Return 1 if this is a PowerPC target with floating-point registers.
1352 proc check_effective_target_powerpc_fprs { } {
1353 if { [istarget powerpc*-*-*]
1354 || [istarget rs6000-*-*] } {
1355 return [check_no_compiler_messages powerpc_fprs object {
1356 #ifdef __NO_FPRS__
1357 #error no FPRs
1358 #else
1359 int dummy;
1360 #endif
1362 } else {
1363 return 0
1367 # Return 1 if this is a PowerPC target supporting -maltivec.
1369 proc check_effective_target_powerpc_altivec_ok { } {
1370 if { [istarget powerpc*-*-*]
1371 || [istarget rs6000-*-*] } {
1372 # AltiVec is not supported on Aix.
1373 if { [istarget powerpc*-*-aix*] } {
1374 return 0
1376 return [check_no_compiler_messages powerpc_altivec_ok object {
1377 int dummy;
1378 } "-maltivec"]
1379 } else {
1380 return 0
1384 # Return 1 if this is a PowerPC target with SPE enabled.
1386 proc check_effective_target_powerpc_spe { } {
1387 if { [istarget powerpc*-*-*] } {
1388 return [check_no_compiler_messages powerpc_spe object {
1389 #ifndef __SPE__
1390 #error not SPE
1391 #else
1392 int dummy;
1393 #endif
1395 } else {
1396 return 0
1400 # Return 1 if this is a PowerPC target with Altivec enabled.
1402 proc check_effective_target_powerpc_altivec { } {
1403 if { [istarget powerpc*-*-*] } {
1404 return [check_no_compiler_messages powerpc_altivec object {
1405 #ifndef __ALTIVEC__
1406 #error not Altivec
1407 #else
1408 int dummy;
1409 #endif
1411 } else {
1412 return 0
1416 # Return 1 if the target supports hardware vector shift operation.
1418 proc check_effective_target_vect_shift { } {
1419 global et_vect_shift_saved
1421 if [info exists et_vect_shift_saved] {
1422 verbose "check_effective_target_vect_shift: using cached result" 2
1423 } else {
1424 set et_vect_shift_saved 0
1425 if { [istarget powerpc*-*-*]
1426 || [istarget ia64-*-*]
1427 || [istarget i?86-*-*]
1428 || [istarget x86_64-*-*] } {
1429 set et_vect_shift_saved 1
1433 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1434 return $et_vect_shift_saved
1437 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1439 # This can change for different subtargets so do not cache the result.
1441 proc check_effective_target_vect_long { } {
1442 if { [istarget i?86-*-*]
1443 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1444 || [istarget x86_64-*-*]
1445 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1446 set answer 1
1447 } else {
1448 set answer 0
1451 verbose "check_effective_target_vect_long: returning $answer" 2
1452 return $answer
1455 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1457 # This won't change for different subtargets so cache the result.
1459 proc check_effective_target_vect_float { } {
1460 global et_vect_float_saved
1462 if [info exists et_vect_float_saved] {
1463 verbose "check_effective_target_vect_float: using cached result" 2
1464 } else {
1465 set et_vect_float_saved 0
1466 if { [istarget i?86-*-*]
1467 || [istarget powerpc*-*-*]
1468 || [istarget spu-*-*]
1469 || [istarget mipsisa64*-*-*]
1470 || [istarget x86_64-*-*]
1471 || [istarget ia64-*-*] } {
1472 set et_vect_float_saved 1
1476 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1477 return $et_vect_float_saved
1480 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1482 # This won't change for different subtargets so cache the result.
1484 proc check_effective_target_vect_double { } {
1485 global et_vect_double_saved
1487 if [info exists et_vect_double_saved] {
1488 verbose "check_effective_target_vect_double: using cached result" 2
1489 } else {
1490 set et_vect_double_saved 0
1491 if { [istarget i?86-*-*]
1492 || [istarget x86_64-*-*]
1493 || [istarget spu-*-*] } {
1494 set et_vect_double_saved 1
1498 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1499 return $et_vect_double_saved
1502 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1504 # This won't change for different subtargets so cache the result.
1506 proc check_effective_target_vect_no_compare_double { } {
1507 global et_vect_no_compare_double_saved
1509 if [info exists et_vect_no_compare_double_saved] {
1510 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1511 } else {
1512 set et_vect_no_compare_double_saved 0
1513 if { [istarget spu-*-*] } {
1514 set et_vect_no_compare_double_saved 1
1518 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1519 return $et_vect_no_compare_double_saved
1522 # Return 1 if the target plus current options does not support a vector
1523 # max instruction on "int", 0 otherwise.
1525 # This won't change for different subtargets so cache the result.
1527 proc check_effective_target_vect_no_int_max { } {
1528 global et_vect_no_int_max_saved
1530 if [info exists et_vect_no_int_max_saved] {
1531 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1532 } else {
1533 set et_vect_no_int_max_saved 0
1534 if { [istarget sparc*-*-*]
1535 || [istarget spu-*-*]
1536 || [istarget alpha*-*-*] } {
1537 set et_vect_no_int_max_saved 1
1540 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1541 return $et_vect_no_int_max_saved
1544 # Return 1 if the target plus current options does not support a vector
1545 # add instruction on "int", 0 otherwise.
1547 # This won't change for different subtargets so cache the result.
1549 proc check_effective_target_vect_no_int_add { } {
1550 global et_vect_no_int_add_saved
1552 if [info exists et_vect_no_int_add_saved] {
1553 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1554 } else {
1555 set et_vect_no_int_add_saved 0
1556 # Alpha only supports vector add on V8QI and V4HI.
1557 if { [istarget alpha*-*-*] } {
1558 set et_vect_no_int_add_saved 1
1561 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1562 return $et_vect_no_int_add_saved
1565 # Return 1 if the target plus current options does not support vector
1566 # bitwise instructions, 0 otherwise.
1568 # This won't change for different subtargets so cache the result.
1570 proc check_effective_target_vect_no_bitwise { } {
1571 global et_vect_no_bitwise_saved
1573 if [info exists et_vect_no_bitwise_saved] {
1574 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1575 } else {
1576 set et_vect_no_bitwise_saved 0
1578 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1579 return $et_vect_no_bitwise_saved
1582 # Return 1 if the target plus current options supports a vector
1583 # widening summation of *short* args into *int* result, 0 otherwise.
1584 # A target can also support this widening summation if it can support
1585 # promotion (unpacking) from shorts to ints.
1587 # This won't change for different subtargets so cache the result.
1589 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1590 global et_vect_widen_sum_hi_to_si
1592 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1593 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1594 } else {
1595 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1596 if { [istarget powerpc*-*-*] } {
1597 set et_vect_widen_sum_hi_to_si_saved 1
1600 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1601 return $et_vect_widen_sum_hi_to_si_saved
1604 # Return 1 if the target plus current options supports a vector
1605 # widening summation of *char* args into *short* result, 0 otherwise.
1606 # A target can also support this widening summation if it can support
1607 # promotion (unpacking) from chars to shorts.
1609 # This won't change for different subtargets so cache the result.
1611 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1612 global et_vect_widen_sum_qi_to_hi
1614 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1615 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1616 } else {
1617 set et_vect_widen_sum_qi_to_hi_saved 0
1618 if { [check_effective_target_vect_unpack] } {
1619 set et_vect_widen_sum_qi_to_hi_saved 1
1622 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1623 return $et_vect_widen_sum_qi_to_hi_saved
1626 # Return 1 if the target plus current options supports a vector
1627 # widening summation of *char* args into *int* result, 0 otherwise.
1629 # This won't change for different subtargets so cache the result.
1631 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1632 global et_vect_widen_sum_qi_to_si
1634 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1635 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1636 } else {
1637 set et_vect_widen_sum_qi_to_si_saved 0
1638 if { [istarget powerpc*-*-*] } {
1639 set et_vect_widen_sum_qi_to_si_saved 1
1642 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1643 return $et_vect_widen_sum_qi_to_si_saved
1646 # Return 1 if the target plus current options supports a vector
1647 # widening multiplication of *char* args into *short* result, 0 otherwise.
1648 # A target can also support this widening multplication if it can support
1649 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1650 # multiplication of shorts).
1652 # This won't change for different subtargets so cache the result.
1655 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1656 global et_vect_widen_mult_qi_to_hi
1658 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1659 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1660 } else {
1661 if { [check_effective_target_vect_unpack]
1662 && [check_effective_target_vect_short_mult] } {
1663 set et_vect_widen_mult_qi_to_hi_saved 1
1664 } else {
1665 set et_vect_widen_mult_qi_to_hi_saved 0
1667 if { [istarget powerpc*-*-*] } {
1668 set et_vect_widen_mult_qi_to_hi_saved 1
1671 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1672 return $et_vect_widen_mult_qi_to_hi_saved
1675 # Return 1 if the target plus current options supports a vector
1676 # widening multiplication of *short* args into *int* result, 0 otherwise.
1677 # A target can also support this widening multplication if it can support
1678 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1679 # multiplication of ints).
1681 # This won't change for different subtargets so cache the result.
1684 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1685 global et_vect_widen_mult_hi_to_si
1687 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1688 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1689 } else {
1690 if { [check_effective_target_vect_unpack]
1691 && [check_effective_target_vect_int_mult] } {
1692 set et_vect_widen_mult_hi_to_si_saved 1
1693 } else {
1694 set et_vect_widen_mult_hi_to_si_saved 0
1696 if { [istarget powerpc*-*-*]
1697 || [istarget spu-*-*]
1698 || [istarget i?86-*-*]
1699 || [istarget x86_64-*-*] } {
1700 set et_vect_widen_mult_hi_to_si_saved 1
1703 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1704 return $et_vect_widen_mult_hi_to_si_saved
1707 # Return 1 if the target plus current options supports a vector
1708 # dot-product of signed chars, 0 otherwise.
1710 # This won't change for different subtargets so cache the result.
1712 proc check_effective_target_vect_sdot_qi { } {
1713 global et_vect_sdot_qi
1715 if [info exists et_vect_sdot_qi_saved] {
1716 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1717 } else {
1718 set et_vect_sdot_qi_saved 0
1720 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1721 return $et_vect_sdot_qi_saved
1724 # Return 1 if the target plus current options supports a vector
1725 # dot-product of unsigned chars, 0 otherwise.
1727 # This won't change for different subtargets so cache the result.
1729 proc check_effective_target_vect_udot_qi { } {
1730 global et_vect_udot_qi
1732 if [info exists et_vect_udot_qi_saved] {
1733 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1734 } else {
1735 set et_vect_udot_qi_saved 0
1736 if { [istarget powerpc*-*-*] } {
1737 set et_vect_udot_qi_saved 1
1740 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1741 return $et_vect_udot_qi_saved
1744 # Return 1 if the target plus current options supports a vector
1745 # dot-product of signed shorts, 0 otherwise.
1747 # This won't change for different subtargets so cache the result.
1749 proc check_effective_target_vect_sdot_hi { } {
1750 global et_vect_sdot_hi
1752 if [info exists et_vect_sdot_hi_saved] {
1753 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1754 } else {
1755 set et_vect_sdot_hi_saved 0
1756 if { [istarget powerpc*-*-*]
1757 || [istarget i?86-*-*]
1758 || [istarget x86_64-*-*] } {
1759 set et_vect_sdot_hi_saved 1
1762 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1763 return $et_vect_sdot_hi_saved
1766 # Return 1 if the target plus current options supports a vector
1767 # dot-product of unsigned shorts, 0 otherwise.
1769 # This won't change for different subtargets so cache the result.
1771 proc check_effective_target_vect_udot_hi { } {
1772 global et_vect_udot_hi
1774 if [info exists et_vect_udot_hi_saved] {
1775 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1776 } else {
1777 set et_vect_udot_hi_saved 0
1778 if { [istarget powerpc*-*-*] } {
1779 set et_vect_udot_hi_saved 1
1782 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1783 return $et_vect_udot_hi_saved
1787 # Return 1 if the target plus current options supports a vector
1788 # demotion (packing) of shorts (to chars) and ints (to shorts)
1789 # using modulo arithmetic, 0 otherwise.
1791 # This won't change for different subtargets so cache the result.
1793 proc check_effective_target_vect_pack_mod { } {
1794 global et_vect_pack_mod
1796 if [info exists et_vect_pack_mod_saved] {
1797 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1798 } else {
1799 set et_vect_pack_mod_saved 0
1800 if { [istarget powerpc*-*-*]
1801 || [istarget i?86-*-*]
1802 || [istarget x86_64-*-*] } {
1803 set et_vect_pack_mod_saved 1
1806 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1807 return $et_vect_pack_mod_saved
1810 # Return 1 if the target plus current options supports a vector
1811 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1813 # This won't change for different subtargets so cache the result.
1815 proc check_effective_target_vect_unpack { } {
1816 global et_vect_unpack
1818 if [info exists et_vect_unpack_saved] {
1819 verbose "check_effective_target_vect_unpack: using cached result" 2
1820 } else {
1821 set et_vect_unpack_saved 0
1822 if { [istarget powerpc*-*-*]
1823 || [istarget i?86-*-*]
1824 || [istarget x86_64-*-*] } {
1825 set et_vect_unpack_saved 1
1828 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1829 return $et_vect_unpack_saved
1832 # Return 1 if the target plus current options does not support a vector
1833 # alignment mechanism, 0 otherwise.
1835 # This won't change for different subtargets so cache the result.
1837 proc check_effective_target_vect_no_align { } {
1838 global et_vect_no_align_saved
1840 if [info exists et_vect_no_align_saved] {
1841 verbose "check_effective_target_vect_no_align: using cached result" 2
1842 } else {
1843 set et_vect_no_align_saved 0
1844 if { [istarget mipsisa64*-*-*]
1845 || [istarget sparc*-*-*]
1846 || [istarget ia64-*-*] } {
1847 set et_vect_no_align_saved 1
1850 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1851 return $et_vect_no_align_saved
1854 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1856 proc check_effective_target_vect_condition { } {
1857 global et_vect_cond_saved
1859 if [info exists et_vect_cond_saved] {
1860 verbose "check_effective_target_vect_cond: using cached result" 2
1861 } else {
1862 set et_vect_cond_saved 0
1863 if { [istarget powerpc*-*-*]
1864 || [istarget ia64-*-*]
1865 || [istarget i?86-*-*]
1866 || [istarget x86_64-*-*] } {
1867 set et_vect_cond_saved 1
1871 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1872 return $et_vect_cond_saved
1875 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1877 proc check_effective_target_vect_char_mult { } {
1878 global et_vect_char_mult_saved
1880 if [info exists et_vect_char_mult_saved] {
1881 verbose "check_effective_target_vect_char_mult: using cached result" 2
1882 } else {
1883 set et_vect_char_mult_saved 0
1884 if { [istarget ia64-*-*]
1885 || [istarget i?86-*-*]
1886 || [istarget x86_64-*-*] } {
1887 set et_vect_char_mult_saved 1
1891 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1892 return $et_vect_char_mult_saved
1895 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1897 proc check_effective_target_vect_short_mult { } {
1898 global et_vect_short_mult_saved
1900 if [info exists et_vect_short_mult_saved] {
1901 verbose "check_effective_target_vect_short_mult: using cached result" 2
1902 } else {
1903 set et_vect_short_mult_saved 0
1904 if { [istarget ia64-*-*]
1905 || [istarget i?86-*-*]
1906 || [istarget x86_64-*-*] } {
1907 set et_vect_short_mult_saved 1
1911 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1912 return $et_vect_short_mult_saved
1915 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1917 proc check_effective_target_vect_int_mult { } {
1918 global et_vect_int_mult_saved
1920 if [info exists et_vect_int_mult_saved] {
1921 verbose "check_effective_target_vect_int_mult: using cached result" 2
1922 } else {
1923 set et_vect_int_mult_saved 0
1924 if { [istarget powerpc*-*-*]
1925 || [istarget i?86-*-*]
1926 || [istarget x86_64-*-*] } {
1927 set et_vect_int_mult_saved 1
1931 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1932 return $et_vect_int_mult_saved
1935 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1937 proc check_effective_target_vect_extract_even_odd { } {
1938 global et_vect_extract_even_odd_saved
1940 if [info exists et_vect_extract_even_odd_saved] {
1941 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1942 } else {
1943 set et_vect_extract_even_odd_saved 0
1944 if { [istarget powerpc*-*-*] } {
1945 set et_vect_extract_even_odd_saved 1
1949 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1950 return $et_vect_extract_even_odd_saved
1953 # Return 1 if the target supports vector interleaving, 0 otherwise.
1955 proc check_effective_target_vect_interleave { } {
1956 global et_vect_interleave_saved
1958 if [info exists et_vect_interleave_saved] {
1959 verbose "check_effective_target_vect_interleave: using cached result" 2
1960 } else {
1961 set et_vect_interleave_saved 0
1962 if { [istarget powerpc*-*-*]
1963 || [istarget i?86-*-*]
1964 || [istarget x86_64-*-*] } {
1965 set et_vect_interleave_saved 1
1969 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1970 return $et_vect_interleave_saved
1973 # Return 1 if the target supports section-anchors
1975 proc check_effective_target_section_anchors { } {
1976 global et_section_anchors_saved
1978 if [info exists et_section_anchors_saved] {
1979 verbose "check_effective_target_section_anchors: using cached result" 2
1980 } else {
1981 set et_section_anchors_saved 0
1982 if { [istarget powerpc*-*-*] } {
1983 set et_section_anchors_saved 1
1987 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1988 return $et_section_anchors_saved
1991 # Return 1 if the target supports atomic operations on "int" and "long".
1993 proc check_effective_target_sync_int_long { } {
1994 global et_sync_int_long_saved
1996 if [info exists et_sync_int_long_saved] {
1997 verbose "check_effective_target_sync_int_long: using cached result" 2
1998 } else {
1999 set et_sync_int_long_saved 0
2000 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2001 # load-reserved/store-conditional instructions.
2002 if { [istarget ia64-*-*]
2003 || [istarget i?86-*-*]
2004 || [istarget x86_64-*-*]
2005 || [istarget alpha*-*-*]
2006 || [istarget s390*-*-*]
2007 || [istarget powerpc*-*-*]
2008 || [istarget sparc64-*-*]
2009 || [istarget sparcv9-*-*] } {
2010 set et_sync_int_long_saved 1
2014 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2015 return $et_sync_int_long_saved
2018 # Return 1 if the target supports atomic operations on "char" and "short".
2020 proc check_effective_target_sync_char_short { } {
2021 global et_sync_char_short_saved
2023 if [info exists et_sync_char_short_saved] {
2024 verbose "check_effective_target_sync_char_short: using cached result" 2
2025 } else {
2026 set et_sync_char_short_saved 0
2027 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2028 # load-reserved/store-conditional instructions.
2029 if { [istarget ia64-*-*]
2030 || [istarget i?86-*-*]
2031 || [istarget x86_64-*-*]
2032 || [istarget alpha*-*-*]
2033 || [istarget s390*-*-*]
2034 || [istarget powerpc*-*-*]
2035 || [istarget sparc64-*-*]
2036 || [istarget sparcv9-*-*] } {
2037 set et_sync_char_short_saved 1
2041 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2042 return $et_sync_char_short_saved
2045 # Return 1 if the target uses a ColdFire FPU.
2047 proc check_effective_target_coldfire_fpu { } {
2048 return [check_no_compiler_messages coldfire_fpu assembly {
2049 #ifndef __mcffpu__
2050 #error FOO
2051 #endif
2055 # Return true if this is a uClibc target.
2057 proc check_effective_target_uclibc {} {
2058 return [check_no_compiler_messages uclibc object {
2059 #include <features.h>
2060 #if !defined (__UCLIBC__)
2061 #error FOO
2062 #endif
2066 # Return true if this is a Newlib target.
2068 proc check_effective_target_newlib {} {
2069 return [check_no_compiler_messages newlib object {
2070 #include <newlib.h>
2074 # Return 1 if
2075 # (a) an error of a few ULP is expected in string to floating-point
2076 # conversion functions; and
2077 # (b) overflow is not always detected correctly by those functions.
2079 proc check_effective_target_lax_strtofp {} {
2080 # By default, assume that all uClibc targets suffer from this.
2081 return [check_effective_target_uclibc]
2084 # Return 1 if this is a target for which wcsftime is a dummy
2085 # function that always returns 0.
2087 proc check_effective_target_dummy_wcsftime {} {
2088 # By default, assume that all uClibc targets suffer from this.
2089 return [check_effective_target_uclibc]
2092 # Return 1 if constructors with initialization priority arguments are
2093 # supposed on this target.
2095 proc check_effective_target_init_priority {} {
2096 # On Solaris2, initialization priorities are only supported with
2097 # GNU ld, but the compiler accepts them even when using Sun ld.
2098 # For more information, see PR 6482.
2099 if { [istarget *-solaris2*] } {
2100 return 1
2103 return [check_no_compiler_messages init_priority assembly "
2104 void f() __attribute__((constructor (1000)));
2105 void f() \{\}
2109 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2110 # This can be used with any check_* proc that takes no argument and
2111 # returns only 1 or 0. It could be used with check_* procs that take
2112 # arguments with keywords that pass particular arguments.
2114 proc is-effective-target { arg } {
2115 set selected 0
2116 if { [info procs check_effective_target_${arg}] != [list] } {
2117 set selected [check_effective_target_${arg}]
2118 } else {
2119 switch $arg {
2120 "vmx_hw" { set selected [check_vmx_hw_available] }
2121 "named_sections" { set selected [check_named_sections_available] }
2122 "gc_sections" { set selected [check_gc_sections_available] }
2123 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2124 default { error "unknown effective target keyword `$arg'" }
2127 verbose "is-effective-target: $arg $selected" 2
2128 return $selected
2131 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2133 proc is-effective-target-keyword { arg } {
2134 if { [info procs check_effective_target_${arg}] != [list] } {
2135 return 1
2136 } else {
2137 # These have different names for their check_* procs.
2138 switch $arg {
2139 "vmx_hw" { return 1 }
2140 "named_sections" { return 1 }
2141 "gc_sections" { return 1 }
2142 "cxa_atexit" { return 1 }
2143 default { return 0 }
2148 # Return 1 if target default to short enums
2150 proc check_effective_target_short_enums { } {
2151 return [check_no_compiler_messages short_enums assembly {
2152 enum foo { bar };
2153 int s[sizeof (enum foo) == 1 ? 1 : -1];
2157 # Return 1 if target supports merging string constants at link time.
2159 proc check_effective_target_string_merging { } {
2160 return [check_no_messages_and_pattern string_merging \
2161 "rodata\\.str" assembly {
2162 const char *var = "String";
2163 } {-O2}]
2166 # Return 1 if target has the basic signed and unsigned types in
2167 # <stdint.h>, 0 otherwise.
2169 proc check_effective_target_stdint_types { } {
2170 return [check_no_compiler_messages stdint_types assembly {
2171 #include <stdint.h>
2172 int8_t a; int16_t b; int32_t c; int64_t d;
2173 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2177 # Return 1 if programs are intended to be run on a simulator
2178 # (i.e. slowly) rather than hardware (i.e. fast).
2180 proc check_effective_target_simulator { } {
2182 # All "src/sim" simulators set this one.
2183 if [board_info target exists is_simulator] {
2184 return [board_info target is_simulator]
2187 # The "sid" simulators don't set that one, but at least they set
2188 # this one.
2189 if [board_info target exists slow_simulator] {
2190 return [board_info target slow_simulator]
2193 return 0