* lib/target-supports.exp (check_profiling_available): Not available
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob51a3258a54c760dcb9360c2b18ca7d96aa1ee1b8
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 bfin-*-*]
344 || [istarget powerpc-*-eabi*]
345 || [istarget strongarm*-*-elf]
346 || [istarget xscale*-*-elf]
347 || [istarget cris-*-*]
348 || [istarget h8300-*-*]
349 || [istarget m32c-*-elf]
350 || [istarget m68k-*-elf]
351 || [istarget mips*-*-elf]
352 || [istarget xtensa-*-elf]
353 || [istarget *-*-windiss] } {
354 set profiling_available_saved 0
355 } else {
356 set profiling_available_saved 1
360 return $profiling_available_saved
363 # Return 1 if target has packed layout of structure members by
364 # default, 0 otherwise. Note that this is slightly different than
365 # whether the target has "natural alignment": both attributes may be
366 # false.
368 proc check_effective_target_default_packed { } {
369 return [check_no_compiler_messages default_packed assembly {
370 struct x { char a; long b; } c;
371 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
375 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
376 # documentation, where the test also comes from.
378 proc check_effective_target_pcc_bitfield_type_matters { } {
379 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
380 # bitfields, but let's stick to the example code from the docs.
381 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
382 struct foo1 { char x; char :0; char y; };
383 struct foo2 { char x; int :0; char y; };
384 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
388 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
390 # This won't change for different subtargets so cache the result.
392 proc check_effective_target_tls {} {
393 global et_tls_saved
394 global tool
396 if [info exists et_tls_saved] {
397 verbose "check_effective_target_tls: using cached result" 2
398 } else {
399 set et_tls_saved 1
401 set src tls[pid].c
402 set asm tls[pid].S
403 verbose "check_effective_target_tls: compiling testfile $src" 2
404 set f [open $src "w"]
405 # Compile a small test program.
406 puts $f "__thread int i;\n"
407 close $f
409 # Test for thread-local data supported by the platform.
410 set comp_output [${tool}_target_compile $src $asm assembly ""]
411 file delete $src
412 if { [string match "*not supported*" $comp_output] } {
413 set et_tls_saved 0
414 } else {
415 set fd [open $asm r]
416 set text [read $fd]
417 close $fd
418 if { [string match "*emutls*" $text]} {
419 set et_tls_saved 0
420 } else {
421 set et_tls_saved 1
424 remove-build-file $asm
426 verbose "check_effective_target_tls: returning $et_tls_saved" 2
427 return $et_tls_saved
430 # Return 1 if TLS executables can run correctly, 0 otherwise.
432 # This won't change for different subtargets so cache the result.
434 proc check_effective_target_tls_runtime {} {
435 global et_tls_runtime_saved
436 global tool
438 if [info exists et_tls_runtime_saved] {
439 verbose "check_effective_target_tls_runtime: using cached result" 2
440 } else {
441 set et_tls_runtime_saved 0
443 set src tls_runtime[pid].c
444 set exe tls_runtime[pid].x
445 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
446 set f [open $src "w"]
447 # Compile a small test program.
448 puts $f "__thread int thr = 0;\n"
449 puts $f "int main(void)\n {\n return thr;\n}"
450 close $f
452 set comp_output \
453 [${tool}_target_compile $src $exe executable ""]
454 file delete $src
456 if [string match "" $comp_output] then {
457 # No error messages, everything is OK.
459 set result [remote_load target "./$exe" "" ""]
460 set status [lindex $result 0]
461 remote_file build delete $exe
463 verbose "check_effective_target_tls_runtime status is <$status>" 2
465 if { $status == "pass" } {
466 set et_tls_runtime_saved 1
469 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
473 return $et_tls_runtime_saved
476 # Return 1 if compilation with -fopenmp is error-free for trivial
477 # code, 0 otherwise.
479 proc check_effective_target_fopenmp {} {
480 return [check_no_compiler_messages fopenmp object {
481 void foo (void) { }
482 } "-fopenmp"]
485 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
486 # for trivial code, 0 otherwise.
488 proc check_effective_target_freorder {} {
489 return [check_no_compiler_messages freorder object {
490 void foo (void) { }
491 } "-freorder-blocks-and-partition"]
494 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
495 # emitted, 0 otherwise. Whether a shared library can actually be built is
496 # out of scope for this test.
498 proc check_effective_target_fpic { } {
499 # Note that M68K has a multilib that supports -fpic but not
500 # -fPIC, so we need to check both. We test with a program that
501 # requires GOT references.
502 foreach arg {fpic fPIC} {
503 if [check_no_compiler_messages $arg object {
504 extern int foo (void); extern int bar;
505 int baz (void) { return foo () + bar; }
506 } "-$arg"] {
507 return 1
510 return 0
513 # Return true if the target supports -mpaired-single (as used on MIPS).
515 proc check_effective_target_mpaired_single { } {
516 return [check_no_compiler_messages mpaired_single object {
517 void foo (void) { }
518 } "-mpaired-single"]
521 # Return 1 if the target does not use a status wrapper.
523 proc check_effective_target_unwrapped { } {
524 if { [target_info needs_status_wrapper] != "" \
525 && [target_info needs_status_wrapper] != "0" } {
526 return 0
528 return 1
531 # Return true if iconv is supported on the target. In particular IBM1047.
533 proc check_iconv_available { test_what } {
534 global tool
535 global libiconv
537 set result ""
539 set src iconv[pid].c
540 set exe iconv[pid].x
541 verbose "check_iconv_available compiling testfile $src" 2
542 set f [open $src "w"]
543 # Compile a small test program.
544 puts $f "#include <iconv.h>\n"
545 puts $f "int main (void)\n {\n iconv_t cd; \n"
546 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
547 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
548 puts $f "return 0;\n}"
549 close $f
551 # If the tool configuration file has not set libiconv, try "-liconv"
552 if { ![info exists libiconv] } {
553 set libiconv "-liconv"
555 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
556 file delete $src
558 if [string match "" $lines] then {
559 # No error messages, everything is OK.
561 set result [${tool}_load "./$exe" "" ""]
562 set status [lindex $result 0]
563 remote_file build delete $exe
565 verbose "check_iconv_available status is <$status>" 2
567 if { $status == "pass" } then {
568 return 1
572 return 0
575 # Return true if named sections are supported on this target.
577 proc check_named_sections_available { } {
578 return [check_no_compiler_messages named_sections assembly {
579 int __attribute__ ((section("whatever"))) foo;
583 # Return 1 if the target supports Fortran real kinds larger than real(8),
584 # 0 otherwise.
586 # When the target name changes, replace the cached result.
588 proc check_effective_target_fortran_large_real { } {
589 global et_fortran_large_real_saved
590 global et_fortran_large_real_target_name
591 global tool
593 if { ![info exists et_fortran_large_real_target_name] } {
594 set et_fortran_large_real_target_name ""
597 # If the target has changed since we set the cached value, clear it.
598 set current_target [current_target_name]
599 if { $current_target != $et_fortran_large_real_target_name } {
600 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
601 set et_fortran_large_real_target_name $current_target
602 if [info exists et_fortran_large_real_saved] {
603 verbose "check_effective_target_fortran_large_real: removing cached result" 2
604 unset et_fortran_large_real_saved
608 if [info exists et_fortran_large_real_saved] {
609 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
610 } else {
611 set et_fortran_large_real_saved 0
613 # Set up, compile, and execute a test program using large real
614 # kinds. Include the current process ID in the file names to
615 # prevent conflicts with invocations for multiple testsuites.
616 set src real[pid].f90
617 set exe real[pid].x
619 set f [open $src "w"]
620 puts $f "integer,parameter :: k = &"
621 puts $f " selected_real_kind (precision (0.0_8) + 1)"
622 puts $f "real(kind=k) :: x"
623 puts $f "x = cos (x);"
624 puts $f "end"
625 close $f
627 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
628 set lines [${tool}_target_compile $src $exe executable ""]
629 file delete $src
631 if [string match "" $lines] then {
632 # No error message, compilation succeeded.
633 set et_fortran_large_real_saved 1
637 return $et_fortran_large_real_saved
640 # Return 1 if the target supports Fortran integer kinds larger than
641 # integer(8), 0 otherwise.
643 # When the target name changes, replace the cached result.
645 proc check_effective_target_fortran_large_int { } {
646 global et_fortran_large_int_saved
647 global et_fortran_large_int_target_name
648 global tool
650 if { ![info exists et_fortran_large_int_target_name] } {
651 set et_fortran_large_int_target_name ""
654 # If the target has changed since we set the cached value, clear it.
655 set current_target [current_target_name]
656 if { $current_target != $et_fortran_large_int_target_name } {
657 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
658 set et_fortran_large_int_target_name $current_target
659 if [info exists et_fortran_large_int_saved] {
660 verbose "check_effective_target_fortran_large_int: removing cached result" 2
661 unset et_fortran_large_int_saved
665 if [info exists et_fortran_large_int_saved] {
666 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
667 } else {
668 set et_fortran_large_int_saved 0
670 # Set up, compile, and execute a test program using large integer
671 # kinds. Include the current process ID in the file names to
672 # prevent conflicts with invocations for multiple testsuites.
673 set src int[pid].f90
674 set exe int[pid].x
676 set f [open $src "w"]
677 puts $f "integer,parameter :: k = &"
678 puts $f " selected_int_kind (range (0_8) + 1)"
679 puts $f "integer(kind=k) :: i"
680 puts $f "end"
681 close $f
683 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
684 set lines [${tool}_target_compile $src $exe executable ""]
685 file delete $src
687 if [string match "" $lines] then {
688 # No error message, compilation succeeded.
689 set et_fortran_large_int_saved 1
693 return $et_fortran_large_int_saved
696 # Return 1 if we can statically link libgfortran, 0 otherwise.
698 # When the target name changes, replace the cached result.
700 proc check_effective_target_static_libgfortran { } {
701 global et_static_libgfortran
702 global et_static_libgfortran_target_name
703 global tool
705 if { ![info exists et_static_libgfortran_target_name] } {
706 set et_static_libgfortran_target_name ""
709 # If the target has changed since we set the cached value, clear it.
710 set current_target [current_target_name]
711 if { $current_target != $et_static_libgfortran_target_name } {
712 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
713 set et_static_libgfortran_target_name $current_target
714 if [info exists et_static_libgfortran_saved] {
715 verbose "check_effective_target_static_libgfortran: removing cached result" 2
716 unset et_static_libgfortran_saved
720 if [info exists et_static_libgfortran_saved] {
721 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
722 } else {
723 set et_static_libgfortran_saved 0
725 # Set up, compile, and execute a test program using static linking.
726 # Include the current process ID in the file names to prevent
727 # conflicts with invocations for multiple testsuites.
728 set opts "additional_flags=-static"
729 set src static[pid].f
730 set exe static[pid].x
732 set f [open $src "w"]
733 puts $f " print *, 'test'"
734 puts $f " end"
735 close $f
737 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
738 set lines [${tool}_target_compile $src $exe executable "$opts"]
739 file delete $src
741 if [string match "" $lines] then {
742 # No error message, compilation succeeded.
743 set et_static_libgfortran_saved 1
747 return $et_static_libgfortran_saved
750 # Return 1 if the target supports executing AltiVec instructions, 0
751 # otherwise. Cache the result.
753 proc check_vmx_hw_available { } {
754 global vmx_hw_available_saved
755 global tool
757 if [info exists vmx_hw_available_saved] {
758 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
759 } else {
760 set vmx_hw_available_saved 0
762 # Some simulators are known to not support VMX instructions.
763 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
764 verbose "check_hw_available returning 0" 2
765 return $vmx_hw_available_saved
768 # Set up, compile, and execute a test program containing VMX
769 # instructions. Include the current process ID in the file
770 # names to prevent conflicts with invocations for multiple
771 # testsuites.
772 set src vmx[pid].c
773 set exe vmx[pid].x
775 set f [open $src "w"]
776 puts $f "int main() {"
777 puts $f "#ifdef __MACH__"
778 puts $f " asm volatile (\"vor v0,v0,v0\");"
779 puts $f "#else"
780 puts $f " asm volatile (\"vor 0,0,0\");"
781 puts $f "#endif"
782 puts $f " return 0; }"
783 close $f
785 # Most targets don't require special flags for this test case, but
786 # Darwin does.
787 if [istarget *-*-darwin*] {
788 set opts "additional_flags=-maltivec"
789 } else {
790 set opts ""
793 verbose "check_vmx_hw_available compiling testfile $src" 2
794 set lines [${tool}_target_compile $src $exe executable "$opts"]
795 file delete $src
797 if [string match "" $lines] then {
798 # No error message, compilation succeeded.
799 set result [${tool}_load "./$exe" "" ""]
800 set status [lindex $result 0]
801 remote_file build delete $exe
802 verbose "check_vmx_hw_available testfile status is <$status>" 2
804 if { $status == "pass" } then {
805 set vmx_hw_available_saved 1
807 } else {
808 verbose "check_vmx_hw_availalble testfile compilation failed" 2
812 return $vmx_hw_available_saved
815 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
816 # complex float arguments. This affects gfortran tests that call cabsf
817 # in libm built by an earlier compiler. Return 1 if libm uses the same
818 # argument passing as the compiler under test, 0 otherwise.
820 # When the target name changes, replace the cached result.
822 proc check_effective_target_broken_cplxf_arg { } {
823 global et_broken_cplxf_arg_saved
824 global et_broken_cplxf_arg_target_name
825 global tool
827 # Skip the work for targets known not to be affected.
828 if { ![istarget powerpc64-*-linux*] } {
829 return 0
830 } elseif { [is-effective-target ilp32] } {
831 return 0
834 if { ![info exists et_broken_cplxf_arg_target_name] } {
835 set et_broken_cplxf_arg_target_name ""
838 # If the target has changed since we set the cached value, clear it.
839 set current_target [current_target_name]
840 if { $current_target != $et_broken_cplxf_arg_target_name } {
841 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
842 set et_broken_cplxf_arg_target_name $current_target
843 if [info exists et_broken_cplxf_arg_saved] {
844 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
845 unset et_broken_cplxf_arg_saved
849 if [info exists et_broken_cplxf_arg_saved] {
850 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
851 } else {
852 set et_broken_cplxf_arg_saved 0
853 # This is only known to affect one target.
854 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
855 set et_broken_cplxf_arg_saved 0
856 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
857 return $et_broken_cplxf_arg_saved
860 # Set up, compile, and execute a C test program that calls cabsf.
861 set src cabsf[pid].c
862 set exe cabsf[pid].x
864 set f [open $src "w"]
865 puts $f "#include <complex.h>"
866 puts $f "extern void abort (void);"
867 puts $f "float fabsf (float);"
868 puts $f "float cabsf (_Complex float);"
869 puts $f "int main ()"
870 puts $f "{"
871 puts $f " _Complex float cf;"
872 puts $f " float f;"
873 puts $f " cf = 3 + 4.0fi;"
874 puts $f " f = cabsf (cf);"
875 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
876 puts $f " return 0;"
877 puts $f "}"
878 close $f
880 set lines [${tool}_target_compile $src $exe executable "-lm"]
881 file delete $src
883 if [string match "" $lines] {
884 # No error message, compilation succeeded.
885 set result [${tool}_load "./$exe" "" ""]
886 set status [lindex $result 0]
887 remote_file build delete $exe
889 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
891 if { $status != "pass" } {
892 set et_broken_cplxf_arg_saved 1
894 } else {
895 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
898 return $et_broken_cplxf_arg_saved
901 proc check_alpha_max_hw_available { } {
902 global alpha_max_hw_available_saved
903 global tool
905 if [info exists alpha_max_hw_available_saved] {
906 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
907 } else {
908 set alpha_max_hw_available_saved 0
910 # Set up, compile, and execute a test program probing bit 8 of the
911 # architecture mask, which indicates presence of MAX instructions.
912 set src max[pid].c
913 set exe max[pid].x
915 set f [open $src "w"]
916 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
917 close $f
919 verbose "check_alpha_max_hw_available compiling testfile $src" 2
920 set lines [${tool}_target_compile $src $exe executable ""]
921 file delete $src
923 if [string match "" $lines] then {
924 # No error message, compilation succeeded.
925 set result [${tool}_load "./$exe" "" ""]
926 set status [lindex $result 0]
927 remote_file build delete $exe
928 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
930 if { $status == "pass" } then {
931 set alpha_max_hw_available_saved 1
933 } else {
934 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
938 return $alpha_max_hw_available_saved
941 # Returns true iff the FUNCTION is available on the target system.
942 # (This is essentially a Tcl implementation of Autoconf's
943 # AC_CHECK_FUNC.)
945 proc check_function_available { function } {
946 set var "${function}_available_saved"
947 global $var
948 global tool
950 if {![info exists $var]} {
951 # Assume it exists.
952 set $var 1
953 # Check to make sure.
954 set src "function[pid].c"
955 set exe "function[pid].exe"
957 set f [open $src "w"]
958 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
959 puts $f "char $function ();\n"
960 puts $f "int main () { $function (); }"
961 close $f
963 set lines [${tool}_target_compile $src $exe executable ""]
964 file delete $src
965 file delete $exe
967 if {![string match "" $lines]} then {
968 set $var 0
969 verbose -log "$function is not available"
970 } else {
971 verbose -log "$function is available"
975 eval return \$$var
978 # Returns true iff "fork" is available on the target system.
980 proc check_fork_available {} {
981 return [check_function_available "fork"]
984 # Returns true iff "mkfifo" is available on the target system.
986 proc check_mkfifo_available {} {
987 if {[istarget *-*-cygwin*]} {
988 # Cygwin has mkfifo, but support is incomplete.
989 return 0
992 return [check_function_available "mkfifo"]
995 # Returns true iff "__cxa_atexit" is used on the target system.
997 proc check_cxa_atexit_available { } {
998 global et_cxa_atexit
999 global et_cxa_atexit_target_name
1000 global tool
1002 if { ![info exists et_cxa_atexit_target_name] } {
1003 set et_cxa_atexit_target_name ""
1006 # If the target has changed since we set the cached value, clear it.
1007 set current_target [current_target_name]
1008 if { $current_target != $et_cxa_atexit_target_name } {
1009 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1010 set et_cxa_atexit_target_name $current_target
1011 if [info exists et_cxa_atexit] {
1012 verbose "check_cxa_atexit_available: removing cached result" 2
1013 unset et_cxa_atexit
1017 if [info exists et_cxa_atexit] {
1018 verbose "check_cxa_atexit_available: using cached result" 2
1019 } elseif { [istarget "hppa*-*-hpux10*"] } {
1020 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1021 set et_cxa_atexit 0
1022 } else {
1023 set et_cxa_atexit 0
1025 # Set up, compile, and execute a C++ test program that depends
1026 # on correct ordering of static object destructors. This is
1027 # indicative of the presence and use of __cxa_atexit.
1028 set src cxaatexit[pid].cc
1029 set exe cxaatexit[pid].x
1031 set f [open $src "w"]
1032 puts $f "#include <stdlib.h>"
1033 puts $f "static unsigned int count;"
1034 puts $f "struct X"
1035 puts $f "{"
1036 puts $f " X() { count = 1; }"
1037 puts $f " ~X()"
1038 puts $f " {"
1039 puts $f " if (count != 3)"
1040 puts $f " exit(1);"
1041 puts $f " count = 4;"
1042 puts $f " }"
1043 puts $f "};"
1044 puts $f "void f()"
1045 puts $f "{"
1046 puts $f " static X x;"
1047 puts $f "}"
1048 puts $f "struct Y"
1049 puts $f "{"
1050 puts $f " Y() { f(); count = 2; }"
1051 puts $f " ~Y()"
1052 puts $f " {"
1053 puts $f " if (count != 2)"
1054 puts $f " exit(1);"
1055 puts $f " count = 3;"
1056 puts $f " }"
1057 puts $f "};"
1058 puts $f "Y y;"
1059 puts $f "int main()"
1060 puts $f "{ return 0; }"
1061 close $f
1063 set lines [${tool}_target_compile $src $exe executable ""]
1064 file delete $src
1066 if [string match "" $lines] {
1067 # No error message, compilation succeeded.
1068 set result [${tool}_load "./$exe" "" ""]
1069 set status [lindex $result 0]
1070 remote_file build delete $exe
1072 verbose "check_cxa_atexit_available: status is <$status>" 2
1074 if { $status == "pass" } {
1075 set et_cxa_atexit 1
1077 } else {
1078 verbose "check_cxa_atexit_available: compilation failed" 2
1081 return $et_cxa_atexit
1085 # Return 1 if we're generating 32-bit code using default options, 0
1086 # otherwise.
1088 proc check_effective_target_ilp32 { } {
1089 return [check_no_compiler_messages ilp32 object {
1090 int dummy[sizeof (int) == 4
1091 && sizeof (void *) == 4
1092 && sizeof (long) == 4 ? 1 : -1];
1096 # Return 1 if we're generating 32-bit or larger integers using default
1097 # options, 0 otherwise.
1099 proc check_effective_target_int32plus { } {
1100 return [check_no_compiler_messages int32plus object {
1101 int dummy[sizeof (int) >= 4 ? 1 : -1];
1105 # Return 1 if we're generating 32-bit or larger pointers using default
1106 # options, 0 otherwise.
1108 proc check_effective_target_ptr32plus { } {
1109 return [check_no_compiler_messages ptr32plus object {
1110 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1114 # Return 1 if we support 32-bit or larger array and structure sizes
1115 # using default options, 0 otherwise.
1117 proc check_effective_target_size32plus { } {
1118 return [check_no_compiler_messages size32plus object {
1119 char dummy[65537];
1123 # Returns 1 if we're generating 16-bit or smaller integers with the
1124 # default options, 0 otherwise.
1126 proc check_effective_target_int16 { } {
1127 return [check_no_compiler_messages int16 object {
1128 int dummy[sizeof (int) < 4 ? 1 : -1];
1132 # Return 1 if we're generating 64-bit code using default options, 0
1133 # otherwise.
1135 proc check_effective_target_lp64 { } {
1136 return [check_no_compiler_messages lp64 object {
1137 int dummy[sizeof (int) == 4
1138 && sizeof (void *) == 8
1139 && sizeof (long) == 8 ? 1 : -1];
1143 # Return 1 if the target supports long double larger than double,
1144 # 0 otherwise.
1146 proc check_effective_target_large_long_double { } {
1147 return [check_no_compiler_messages large_long_double object {
1148 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1153 # Return 1 if the target supports compiling decimal floating point,
1154 # 0 otherwise.
1156 proc check_effective_target_dfp_nocache { } {
1157 verbose "check_effective_target_dfp_nocache: compiling source" 2
1158 set ret [string match "" [get_compiler_messages dfp 0 object {
1159 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1161 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1162 return $ret
1165 proc check_effective_target_dfprt_nocache { } {
1166 global tool
1168 set ret 0
1170 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1171 # Set up, compile, and execute a test program containing decimal
1172 # float operations.
1173 set src dfprt[pid].c
1174 set exe dfprt[pid].x
1176 set f [open $src "w"]
1177 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1178 puts $f "int main () { z = x + y; return 0; }"
1179 close $f
1181 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1182 set lines [${tool}_target_compile $src $exe executable ""]
1183 file delete $src
1185 if [string match "" $lines] then {
1186 # No error message, compilation succeeded.
1187 set result [${tool}_load "./$exe" "" ""]
1188 set status [lindex $result 0]
1189 remote_file build delete $exe
1190 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1191 if { $status == "pass" } then {
1192 set ret 1
1195 return $ret
1196 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1199 # Return 1 if the target supports compiling Decimal Floating Point,
1200 # 0 otherwise.
1202 # This won't change for different subtargets so cache the result.
1204 proc check_effective_target_dfp { } {
1205 global et_dfp_saved
1207 if [info exists et_dfp_saved] {
1208 verbose "check_effective_target_dfp: using cached result" 2
1209 } else {
1210 set et_dfp_saved [check_effective_target_dfp_nocache]
1212 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1213 return $et_dfp_saved
1216 # Return 1 if the target supports linking and executing Decimal Floating
1217 # Point, # 0 otherwise.
1219 # This won't change for different subtargets so cache the result.
1221 proc check_effective_target_dfprt { } {
1222 global et_dfprt_saved
1223 global tool
1225 if [info exists et_dfprt_saved] {
1226 verbose "check_effective_target_dfprt: using cached result" 2
1227 } else {
1228 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1230 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1231 return $et_dfprt_saved
1234 # Return 1 if the target needs a command line argument to enable a SIMD
1235 # instruction set.
1237 proc check_effective_target_vect_cmdline_needed { } {
1238 global et_vect_cmdline_needed_saved
1239 global et_vect_cmdline_needed_target_name
1241 if { ![info exists et_vect_cmdline_needed_target_name] } {
1242 set et_vect_cmdline_needed_target_name ""
1245 # If the target has changed since we set the cached value, clear it.
1246 set current_target [current_target_name]
1247 if { $current_target != $et_vect_cmdline_needed_target_name } {
1248 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1249 set et_vect_cmdline_needed_target_name $current_target
1250 if { [info exists et_vect_cmdline_needed_saved] } {
1251 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1252 unset et_vect_cmdline_needed_saved
1256 if [info exists et_vect_cmdline_needed_saved] {
1257 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1258 } else {
1259 set et_vect_cmdline_needed_saved 1
1260 if { [istarget ia64-*-*]
1261 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1262 && [check_effective_target_lp64])
1263 || ([istarget powerpc*-*-*]
1264 && ([check_effective_target_powerpc_spe]
1265 || [check_effective_target_powerpc_altivec]))} {
1266 set et_vect_cmdline_needed_saved 0
1270 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1271 return $et_vect_cmdline_needed_saved
1274 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1276 # This won't change for different subtargets so cache the result.
1278 proc check_effective_target_vect_int { } {
1279 global et_vect_int_saved
1281 if [info exists et_vect_int_saved] {
1282 verbose "check_effective_target_vect_int: using cached result" 2
1283 } else {
1284 set et_vect_int_saved 0
1285 if { [istarget i?86-*-*]
1286 || [istarget powerpc*-*-*]
1287 || [istarget spu-*-*]
1288 || [istarget x86_64-*-*]
1289 || [istarget sparc*-*-*]
1290 || [istarget alpha*-*-*]
1291 || [istarget ia64-*-*] } {
1292 set et_vect_int_saved 1
1296 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1297 return $et_vect_int_saved
1300 # Return 1 is this is an arm target using 32-bit instructions
1301 proc check_effective_target_arm32 { } {
1302 global et_arm32_saved
1303 global et_arm32_target_name
1304 global compiler_flags
1306 if { ![info exists et_arm32_target_name] } {
1307 set et_arm32_target_name ""
1310 # If the target has changed since we set the cached value, clear it.
1311 set current_target [current_target_name]
1312 if { $current_target != $et_arm32_target_name } {
1313 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1314 set et_arm32_target_name $current_target
1315 if { [info exists et_arm32_saved] } {
1316 verbose "check_effective_target_arm32: removing cached result" 2
1317 unset et_arm32_saved
1321 if [info exists et_arm32_saved] {
1322 verbose "check-effective_target_arm32: using cached result" 2
1323 } else {
1324 set et_arm32_saved 0
1325 if { [istarget arm-*-*]
1326 || [istarget strongarm*-*-*]
1327 || [istarget xscale-*-*] } {
1328 if ![string match "*-mthumb *" $compiler_flags] {
1329 set et_arm32_saved 1
1333 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1334 return $et_arm32_saved
1337 # Return 1 if this is an ARM target supporting -mfpu=vfp
1338 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1339 # options.
1341 proc check_effective_target_arm_vfp_ok { } {
1342 if { [check_effective_target_arm32] } {
1343 return [check_no_compiler_messages arm_vfp_ok object {
1344 int dummy;
1345 } "-mfpu=vfp -mfloat-abi=softfp"]
1346 } else {
1347 return 0
1351 # Return 1 if this is a PowerPC target with floating-point registers.
1353 proc check_effective_target_powerpc_fprs { } {
1354 if { [istarget powerpc*-*-*]
1355 || [istarget rs6000-*-*] } {
1356 return [check_no_compiler_messages powerpc_fprs object {
1357 #ifdef __NO_FPRS__
1358 #error no FPRs
1359 #else
1360 int dummy;
1361 #endif
1363 } else {
1364 return 0
1368 # Return 1 if this is a PowerPC target supporting -maltivec.
1370 proc check_effective_target_powerpc_altivec_ok { } {
1371 if { [istarget powerpc*-*-*]
1372 || [istarget rs6000-*-*] } {
1373 # AltiVec is not supported on Aix.
1374 if { [istarget powerpc*-*-aix*] } {
1375 return 0
1377 return [check_no_compiler_messages powerpc_altivec_ok object {
1378 int dummy;
1379 } "-maltivec"]
1380 } else {
1381 return 0
1385 # Return 1 if this is a PowerPC target with SPE enabled.
1387 proc check_effective_target_powerpc_spe { } {
1388 if { [istarget powerpc*-*-*] } {
1389 return [check_no_compiler_messages powerpc_spe object {
1390 #ifndef __SPE__
1391 #error not SPE
1392 #else
1393 int dummy;
1394 #endif
1396 } else {
1397 return 0
1401 # Return 1 if this is a PowerPC target with Altivec enabled.
1403 proc check_effective_target_powerpc_altivec { } {
1404 if { [istarget powerpc*-*-*] } {
1405 return [check_no_compiler_messages powerpc_altivec object {
1406 #ifndef __ALTIVEC__
1407 #error not Altivec
1408 #else
1409 int dummy;
1410 #endif
1412 } else {
1413 return 0
1417 # Return 1 if the target supports hardware vector shift operation.
1419 proc check_effective_target_vect_shift { } {
1420 global et_vect_shift_saved
1422 if [info exists et_vect_shift_saved] {
1423 verbose "check_effective_target_vect_shift: using cached result" 2
1424 } else {
1425 set et_vect_shift_saved 0
1426 if { [istarget powerpc*-*-*]
1427 || [istarget ia64-*-*]
1428 || [istarget i?86-*-*]
1429 || [istarget x86_64-*-*] } {
1430 set et_vect_shift_saved 1
1434 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1435 return $et_vect_shift_saved
1438 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1440 # This can change for different subtargets so do not cache the result.
1442 proc check_effective_target_vect_long { } {
1443 if { [istarget i?86-*-*]
1444 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1445 || [istarget x86_64-*-*]
1446 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1447 set answer 1
1448 } else {
1449 set answer 0
1452 verbose "check_effective_target_vect_long: returning $answer" 2
1453 return $answer
1456 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1458 # This won't change for different subtargets so cache the result.
1460 proc check_effective_target_vect_float { } {
1461 global et_vect_float_saved
1463 if [info exists et_vect_float_saved] {
1464 verbose "check_effective_target_vect_float: using cached result" 2
1465 } else {
1466 set et_vect_float_saved 0
1467 if { [istarget i?86-*-*]
1468 || [istarget powerpc*-*-*]
1469 || [istarget spu-*-*]
1470 || [istarget mipsisa64*-*-*]
1471 || [istarget x86_64-*-*]
1472 || [istarget ia64-*-*] } {
1473 set et_vect_float_saved 1
1477 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1478 return $et_vect_float_saved
1481 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1483 # This won't change for different subtargets so cache the result.
1485 proc check_effective_target_vect_double { } {
1486 global et_vect_double_saved
1488 if [info exists et_vect_double_saved] {
1489 verbose "check_effective_target_vect_double: using cached result" 2
1490 } else {
1491 set et_vect_double_saved 0
1492 if { [istarget i?86-*-*]
1493 || [istarget x86_64-*-*]
1494 || [istarget spu-*-*] } {
1495 set et_vect_double_saved 1
1499 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1500 return $et_vect_double_saved
1503 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1505 # This won't change for different subtargets so cache the result.
1507 proc check_effective_target_vect_no_compare_double { } {
1508 global et_vect_no_compare_double_saved
1510 if [info exists et_vect_no_compare_double_saved] {
1511 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1512 } else {
1513 set et_vect_no_compare_double_saved 0
1514 if { [istarget spu-*-*] } {
1515 set et_vect_no_compare_double_saved 1
1519 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1520 return $et_vect_no_compare_double_saved
1523 # Return 1 if the target plus current options does not support a vector
1524 # max instruction on "int", 0 otherwise.
1526 # This won't change for different subtargets so cache the result.
1528 proc check_effective_target_vect_no_int_max { } {
1529 global et_vect_no_int_max_saved
1531 if [info exists et_vect_no_int_max_saved] {
1532 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1533 } else {
1534 set et_vect_no_int_max_saved 0
1535 if { [istarget sparc*-*-*]
1536 || [istarget spu-*-*]
1537 || [istarget alpha*-*-*] } {
1538 set et_vect_no_int_max_saved 1
1541 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1542 return $et_vect_no_int_max_saved
1545 # Return 1 if the target plus current options does not support a vector
1546 # add instruction on "int", 0 otherwise.
1548 # This won't change for different subtargets so cache the result.
1550 proc check_effective_target_vect_no_int_add { } {
1551 global et_vect_no_int_add_saved
1553 if [info exists et_vect_no_int_add_saved] {
1554 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1555 } else {
1556 set et_vect_no_int_add_saved 0
1557 # Alpha only supports vector add on V8QI and V4HI.
1558 if { [istarget alpha*-*-*] } {
1559 set et_vect_no_int_add_saved 1
1562 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1563 return $et_vect_no_int_add_saved
1566 # Return 1 if the target plus current options does not support vector
1567 # bitwise instructions, 0 otherwise.
1569 # This won't change for different subtargets so cache the result.
1571 proc check_effective_target_vect_no_bitwise { } {
1572 global et_vect_no_bitwise_saved
1574 if [info exists et_vect_no_bitwise_saved] {
1575 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1576 } else {
1577 set et_vect_no_bitwise_saved 0
1579 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1580 return $et_vect_no_bitwise_saved
1583 # Return 1 if the target plus current options supports a vector
1584 # widening summation of *short* args into *int* result, 0 otherwise.
1585 # A target can also support this widening summation if it can support
1586 # promotion (unpacking) from shorts to ints.
1588 # This won't change for different subtargets so cache the result.
1590 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1591 global et_vect_widen_sum_hi_to_si
1593 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1594 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1595 } else {
1596 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1597 if { [istarget powerpc*-*-*] } {
1598 set et_vect_widen_sum_hi_to_si_saved 1
1601 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1602 return $et_vect_widen_sum_hi_to_si_saved
1605 # Return 1 if the target plus current options supports a vector
1606 # widening summation of *char* args into *short* result, 0 otherwise.
1607 # A target can also support this widening summation if it can support
1608 # promotion (unpacking) from chars to shorts.
1610 # This won't change for different subtargets so cache the result.
1612 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1613 global et_vect_widen_sum_qi_to_hi
1615 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1616 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1617 } else {
1618 set et_vect_widen_sum_qi_to_hi_saved 0
1619 if { [check_effective_target_vect_unpack] } {
1620 set et_vect_widen_sum_qi_to_hi_saved 1
1623 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1624 return $et_vect_widen_sum_qi_to_hi_saved
1627 # Return 1 if the target plus current options supports a vector
1628 # widening summation of *char* args into *int* result, 0 otherwise.
1630 # This won't change for different subtargets so cache the result.
1632 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1633 global et_vect_widen_sum_qi_to_si
1635 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1636 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1637 } else {
1638 set et_vect_widen_sum_qi_to_si_saved 0
1639 if { [istarget powerpc*-*-*] } {
1640 set et_vect_widen_sum_qi_to_si_saved 1
1643 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1644 return $et_vect_widen_sum_qi_to_si_saved
1647 # Return 1 if the target plus current options supports a vector
1648 # widening multiplication of *char* args into *short* result, 0 otherwise.
1649 # A target can also support this widening multplication if it can support
1650 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1651 # multiplication of shorts).
1653 # This won't change for different subtargets so cache the result.
1656 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1657 global et_vect_widen_mult_qi_to_hi
1659 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1660 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1661 } else {
1662 if { [check_effective_target_vect_unpack]
1663 && [check_effective_target_vect_short_mult] } {
1664 set et_vect_widen_mult_qi_to_hi_saved 1
1665 } else {
1666 set et_vect_widen_mult_qi_to_hi_saved 0
1668 if { [istarget powerpc*-*-*] } {
1669 set et_vect_widen_mult_qi_to_hi_saved 1
1672 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1673 return $et_vect_widen_mult_qi_to_hi_saved
1676 # Return 1 if the target plus current options supports a vector
1677 # widening multiplication of *short* args into *int* result, 0 otherwise.
1678 # A target can also support this widening multplication if it can support
1679 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1680 # multiplication of ints).
1682 # This won't change for different subtargets so cache the result.
1685 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1686 global et_vect_widen_mult_hi_to_si
1688 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1689 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1690 } else {
1691 if { [check_effective_target_vect_unpack]
1692 && [check_effective_target_vect_int_mult] } {
1693 set et_vect_widen_mult_hi_to_si_saved 1
1694 } else {
1695 set et_vect_widen_mult_hi_to_si_saved 0
1697 if { [istarget powerpc*-*-*]
1698 || [istarget spu-*-*]
1699 || [istarget i?86-*-*]
1700 || [istarget x86_64-*-*] } {
1701 set et_vect_widen_mult_hi_to_si_saved 1
1704 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1705 return $et_vect_widen_mult_hi_to_si_saved
1708 # Return 1 if the target plus current options supports a vector
1709 # dot-product of signed chars, 0 otherwise.
1711 # This won't change for different subtargets so cache the result.
1713 proc check_effective_target_vect_sdot_qi { } {
1714 global et_vect_sdot_qi
1716 if [info exists et_vect_sdot_qi_saved] {
1717 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1718 } else {
1719 set et_vect_sdot_qi_saved 0
1721 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1722 return $et_vect_sdot_qi_saved
1725 # Return 1 if the target plus current options supports a vector
1726 # dot-product of unsigned chars, 0 otherwise.
1728 # This won't change for different subtargets so cache the result.
1730 proc check_effective_target_vect_udot_qi { } {
1731 global et_vect_udot_qi
1733 if [info exists et_vect_udot_qi_saved] {
1734 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1735 } else {
1736 set et_vect_udot_qi_saved 0
1737 if { [istarget powerpc*-*-*] } {
1738 set et_vect_udot_qi_saved 1
1741 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1742 return $et_vect_udot_qi_saved
1745 # Return 1 if the target plus current options supports a vector
1746 # dot-product of signed shorts, 0 otherwise.
1748 # This won't change for different subtargets so cache the result.
1750 proc check_effective_target_vect_sdot_hi { } {
1751 global et_vect_sdot_hi
1753 if [info exists et_vect_sdot_hi_saved] {
1754 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1755 } else {
1756 set et_vect_sdot_hi_saved 0
1757 if { [istarget powerpc*-*-*]
1758 || [istarget i?86-*-*]
1759 || [istarget x86_64-*-*] } {
1760 set et_vect_sdot_hi_saved 1
1763 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1764 return $et_vect_sdot_hi_saved
1767 # Return 1 if the target plus current options supports a vector
1768 # dot-product of unsigned shorts, 0 otherwise.
1770 # This won't change for different subtargets so cache the result.
1772 proc check_effective_target_vect_udot_hi { } {
1773 global et_vect_udot_hi
1775 if [info exists et_vect_udot_hi_saved] {
1776 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1777 } else {
1778 set et_vect_udot_hi_saved 0
1779 if { [istarget powerpc*-*-*] } {
1780 set et_vect_udot_hi_saved 1
1783 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1784 return $et_vect_udot_hi_saved
1788 # Return 1 if the target plus current options supports a vector
1789 # demotion (packing) of shorts (to chars) and ints (to shorts)
1790 # using modulo arithmetic, 0 otherwise.
1792 # This won't change for different subtargets so cache the result.
1794 proc check_effective_target_vect_pack_mod { } {
1795 global et_vect_pack_mod
1797 if [info exists et_vect_pack_mod_saved] {
1798 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1799 } else {
1800 set et_vect_pack_mod_saved 0
1801 if { [istarget powerpc*-*-*]
1802 || [istarget i?86-*-*]
1803 || [istarget x86_64-*-*] } {
1804 set et_vect_pack_mod_saved 1
1807 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1808 return $et_vect_pack_mod_saved
1811 # Return 1 if the target plus current options supports a vector
1812 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1814 # This won't change for different subtargets so cache the result.
1816 proc check_effective_target_vect_unpack { } {
1817 global et_vect_unpack
1819 if [info exists et_vect_unpack_saved] {
1820 verbose "check_effective_target_vect_unpack: using cached result" 2
1821 } else {
1822 set et_vect_unpack_saved 0
1823 if { [istarget powerpc*-*-*]
1824 || [istarget i?86-*-*]
1825 || [istarget x86_64-*-*] } {
1826 set et_vect_unpack_saved 1
1829 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1830 return $et_vect_unpack_saved
1833 # Return 1 if the target plus current options does not support a vector
1834 # alignment mechanism, 0 otherwise.
1836 # This won't change for different subtargets so cache the result.
1838 proc check_effective_target_vect_no_align { } {
1839 global et_vect_no_align_saved
1841 if [info exists et_vect_no_align_saved] {
1842 verbose "check_effective_target_vect_no_align: using cached result" 2
1843 } else {
1844 set et_vect_no_align_saved 0
1845 if { [istarget mipsisa64*-*-*]
1846 || [istarget sparc*-*-*]
1847 || [istarget ia64-*-*] } {
1848 set et_vect_no_align_saved 1
1851 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1852 return $et_vect_no_align_saved
1855 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1857 proc check_effective_target_vect_condition { } {
1858 global et_vect_cond_saved
1860 if [info exists et_vect_cond_saved] {
1861 verbose "check_effective_target_vect_cond: using cached result" 2
1862 } else {
1863 set et_vect_cond_saved 0
1864 if { [istarget powerpc*-*-*]
1865 || [istarget ia64-*-*]
1866 || [istarget i?86-*-*]
1867 || [istarget x86_64-*-*] } {
1868 set et_vect_cond_saved 1
1872 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1873 return $et_vect_cond_saved
1876 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1878 proc check_effective_target_vect_char_mult { } {
1879 global et_vect_char_mult_saved
1881 if [info exists et_vect_char_mult_saved] {
1882 verbose "check_effective_target_vect_char_mult: using cached result" 2
1883 } else {
1884 set et_vect_char_mult_saved 0
1885 if { [istarget ia64-*-*]
1886 || [istarget i?86-*-*]
1887 || [istarget x86_64-*-*] } {
1888 set et_vect_char_mult_saved 1
1892 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1893 return $et_vect_char_mult_saved
1896 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1898 proc check_effective_target_vect_short_mult { } {
1899 global et_vect_short_mult_saved
1901 if [info exists et_vect_short_mult_saved] {
1902 verbose "check_effective_target_vect_short_mult: using cached result" 2
1903 } else {
1904 set et_vect_short_mult_saved 0
1905 if { [istarget ia64-*-*]
1906 || [istarget i?86-*-*]
1907 || [istarget x86_64-*-*] } {
1908 set et_vect_short_mult_saved 1
1912 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1913 return $et_vect_short_mult_saved
1916 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1918 proc check_effective_target_vect_int_mult { } {
1919 global et_vect_int_mult_saved
1921 if [info exists et_vect_int_mult_saved] {
1922 verbose "check_effective_target_vect_int_mult: using cached result" 2
1923 } else {
1924 set et_vect_int_mult_saved 0
1925 if { [istarget powerpc*-*-*]
1926 || [istarget i?86-*-*]
1927 || [istarget x86_64-*-*] } {
1928 set et_vect_int_mult_saved 1
1932 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1933 return $et_vect_int_mult_saved
1936 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1938 proc check_effective_target_vect_extract_even_odd { } {
1939 global et_vect_extract_even_odd_saved
1941 if [info exists et_vect_extract_even_odd_saved] {
1942 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1943 } else {
1944 set et_vect_extract_even_odd_saved 0
1945 if { [istarget powerpc*-*-*] } {
1946 set et_vect_extract_even_odd_saved 1
1950 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1951 return $et_vect_extract_even_odd_saved
1954 # Return 1 if the target supports vector interleaving, 0 otherwise.
1956 proc check_effective_target_vect_interleave { } {
1957 global et_vect_interleave_saved
1959 if [info exists et_vect_interleave_saved] {
1960 verbose "check_effective_target_vect_interleave: using cached result" 2
1961 } else {
1962 set et_vect_interleave_saved 0
1963 if { [istarget powerpc*-*-*]
1964 || [istarget i?86-*-*]
1965 || [istarget x86_64-*-*] } {
1966 set et_vect_interleave_saved 1
1970 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1971 return $et_vect_interleave_saved
1974 # Return 1 if the target supports section-anchors
1976 proc check_effective_target_section_anchors { } {
1977 global et_section_anchors_saved
1979 if [info exists et_section_anchors_saved] {
1980 verbose "check_effective_target_section_anchors: using cached result" 2
1981 } else {
1982 set et_section_anchors_saved 0
1983 if { [istarget powerpc*-*-*] } {
1984 set et_section_anchors_saved 1
1988 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1989 return $et_section_anchors_saved
1992 # Return 1 if the target supports atomic operations on "int" and "long".
1994 proc check_effective_target_sync_int_long { } {
1995 global et_sync_int_long_saved
1997 if [info exists et_sync_int_long_saved] {
1998 verbose "check_effective_target_sync_int_long: using cached result" 2
1999 } else {
2000 set et_sync_int_long_saved 0
2001 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2002 # load-reserved/store-conditional instructions.
2003 if { [istarget ia64-*-*]
2004 || [istarget i?86-*-*]
2005 || [istarget x86_64-*-*]
2006 || [istarget alpha*-*-*]
2007 || [istarget s390*-*-*]
2008 || [istarget powerpc*-*-*]
2009 || [istarget sparc64-*-*]
2010 || [istarget sparcv9-*-*] } {
2011 set et_sync_int_long_saved 1
2015 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2016 return $et_sync_int_long_saved
2019 # Return 1 if the target supports atomic operations on "char" and "short".
2021 proc check_effective_target_sync_char_short { } {
2022 global et_sync_char_short_saved
2024 if [info exists et_sync_char_short_saved] {
2025 verbose "check_effective_target_sync_char_short: using cached result" 2
2026 } else {
2027 set et_sync_char_short_saved 0
2028 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2029 # load-reserved/store-conditional instructions.
2030 if { [istarget ia64-*-*]
2031 || [istarget i?86-*-*]
2032 || [istarget x86_64-*-*]
2033 || [istarget alpha*-*-*]
2034 || [istarget s390*-*-*]
2035 || [istarget powerpc*-*-*]
2036 || [istarget sparc64-*-*]
2037 || [istarget sparcv9-*-*] } {
2038 set et_sync_char_short_saved 1
2042 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2043 return $et_sync_char_short_saved
2046 # Return 1 if the target uses a ColdFire FPU.
2048 proc check_effective_target_coldfire_fpu { } {
2049 return [check_no_compiler_messages coldfire_fpu assembly {
2050 #ifndef __mcffpu__
2051 #error FOO
2052 #endif
2056 # Return true if this is a uClibc target.
2058 proc check_effective_target_uclibc {} {
2059 return [check_no_compiler_messages uclibc object {
2060 #include <features.h>
2061 #if !defined (__UCLIBC__)
2062 #error FOO
2063 #endif
2067 # Return true if this is a Newlib target.
2069 proc check_effective_target_newlib {} {
2070 return [check_no_compiler_messages newlib object {
2071 #include <newlib.h>
2075 # Return 1 if
2076 # (a) an error of a few ULP is expected in string to floating-point
2077 # conversion functions; and
2078 # (b) overflow is not always detected correctly by those functions.
2080 proc check_effective_target_lax_strtofp {} {
2081 # By default, assume that all uClibc targets suffer from this.
2082 return [check_effective_target_uclibc]
2085 # Return 1 if this is a target for which wcsftime is a dummy
2086 # function that always returns 0.
2088 proc check_effective_target_dummy_wcsftime {} {
2089 # By default, assume that all uClibc targets suffer from this.
2090 return [check_effective_target_uclibc]
2093 # Return 1 if constructors with initialization priority arguments are
2094 # supposed on this target.
2096 proc check_effective_target_init_priority {} {
2097 return [check_no_compiler_messages init_priority assembly "
2098 void f() __attribute__((constructor (1000)));
2099 void f() \{\}
2103 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2104 # This can be used with any check_* proc that takes no argument and
2105 # returns only 1 or 0. It could be used with check_* procs that take
2106 # arguments with keywords that pass particular arguments.
2108 proc is-effective-target { arg } {
2109 set selected 0
2110 if { [info procs check_effective_target_${arg}] != [list] } {
2111 set selected [check_effective_target_${arg}]
2112 } else {
2113 switch $arg {
2114 "vmx_hw" { set selected [check_vmx_hw_available] }
2115 "named_sections" { set selected [check_named_sections_available] }
2116 "gc_sections" { set selected [check_gc_sections_available] }
2117 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2118 default { error "unknown effective target keyword `$arg'" }
2121 verbose "is-effective-target: $arg $selected" 2
2122 return $selected
2125 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2127 proc is-effective-target-keyword { arg } {
2128 if { [info procs check_effective_target_${arg}] != [list] } {
2129 return 1
2130 } else {
2131 # These have different names for their check_* procs.
2132 switch $arg {
2133 "vmx_hw" { return 1 }
2134 "named_sections" { return 1 }
2135 "gc_sections" { return 1 }
2136 "cxa_atexit" { return 1 }
2137 default { return 0 }
2142 # Return 1 if target default to short enums
2144 proc check_effective_target_short_enums { } {
2145 return [check_no_compiler_messages short_enums assembly {
2146 enum foo { bar };
2147 int s[sizeof (enum foo) == 1 ? 1 : -1];
2151 # Return 1 if target supports merging string constants at link time.
2153 proc check_effective_target_string_merging { } {
2154 return [check_no_messages_and_pattern string_merging \
2155 "rodata\\.str" assembly {
2156 const char *var = "String";
2157 } {-O2}]
2160 # Return 1 if target has the basic signed and unsigned types in
2161 # <stdint.h>, 0 otherwise.
2163 proc check_effective_target_stdint_types { } {
2164 return [check_no_compiler_messages stdint_types assembly {
2165 #include <stdint.h>
2166 int8_t a; int16_t b; int32_t c; int64_t d;
2167 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2171 # Return 1 if programs are intended to be run on a simulator
2172 # (i.e. slowly) rather than hardware (i.e. fast).
2174 proc check_effective_target_simulator { } {
2176 # All "src/sim" simulators set this one.
2177 if [board_info target exists is_simulator] {
2178 return [board_info target is_simulator]
2181 # The "sid" simulators don't set that one, but at least they set
2182 # this one.
2183 if [board_info target exists slow_simulator] {
2184 return [board_info target slow_simulator]
2187 return 0