1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006
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
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} {
39 if { [llength $args] > 0 } {
40 set options [list "additional_flags=[lindex $args 0]"]
45 set src ${basename}[pid].c
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
53 set lines [${tool}_target_compile $src $output $type "$options"]
57 if { $type != "assembly" } {
58 error "WANT_OUTPUT can only be used with assembly output"
59 } elseif { ![string match "" $lines] } {
61 set result [list $lines ""]
64 set chan [open "$output"]
65 while {[gets $chan line] >= 0} {
69 set result [list $lines $text]
75 remote_file build delete $output
79 proc current_target_name { } {
81 if [info exists target_info(target,name)] {
82 set answer $target_info(target,name)
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} {
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
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} {
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
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
140 # All mips targets should support it
142 if { [ string first "mips" $target_cpu ] >= 0 } {
146 # All solaris2 targets should support it
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
158 # Windows targets Cygwin and MingW32 support it
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
164 # HP-UX 10.X doesn't support it
166 if { [regexp "hppa.*hpux10" $target_triplet] } {
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]
181 unknown { return -1 }
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 } {
196 global target_triplet
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
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\")));
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
222 proc check_alias_available { } {
223 global alias_available_saved
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
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
236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
239 set lines [${tool}_target_compile $src $obj object ""]
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
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
256 set alias_available_saved 0
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
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
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
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
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" } {
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") } {
330 # At present, there is no profiling support on NetWare.
331 if { [istarget *-*-netware*] } {
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
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
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 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 {} {
395 if [info exists et_tls_saved] {
396 verbose "check_effective_target_tls: using cached result" 2
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"
408 # Test for thread-local data supported by the platform.
410 [${tool}_target_compile $src $asm assembly ""]
412 if { [string match "*not supported*" $comp_output] } {
415 remove-build-file $asm
417 verbose "check_effective_target_tls: returning $et_tls_saved" 2
421 # Return 1 if TLS executables can run correctly, 0 otherwise.
423 # This won't change for different subtargets so cache the result.
425 proc check_effective_target_tls_runtime {} {
426 global et_tls_runtime_saved
429 if [info exists et_tls_runtime_saved] {
430 verbose "check_effective_target_tls_runtime: using cached result" 2
432 set et_tls_runtime_saved 0
434 set src tls_runtime[pid].c
435 set exe tls_runtime[pid].x
436 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
437 set f [open $src "w"]
438 # Compile a small test program.
439 puts $f "__thread int thr = 0;\n"
440 puts $f "int main(void)\n {\n return thr;\n}"
444 [${tool}_target_compile $src $exe executable ""]
447 if [string match "" $comp_output] then {
448 # No error messages, everything is OK.
450 set result [remote_load target "./$exe" "" ""]
451 set status [lindex $result 0]
452 remote_file build delete $exe
454 verbose "check_effective_target_tls_runtime status is <$status>" 2
456 if { $status == "pass" } {
457 set et_tls_runtime_saved 1
460 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
464 return $et_tls_runtime_saved
467 # Return 1 if compilation with -fopenmp is error-free for trivial
470 proc check_effective_target_fopenmp {} {
471 return [check_no_compiler_messages fopenmp object {
476 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
477 # for trivial code, 0 otherwise.
479 proc check_effective_target_freorder {} {
480 return [check_no_compiler_messages freorder object {
482 } "-freorder-blocks-and-partition"]
485 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
486 # emitted, 0 otherwise. Whether a shared library can actually be built is
487 # out of scope for this test.
489 proc check_effective_target_fpic { } {
490 # Note that M68K has a multilib that supports -fpic but not
491 # -fPIC, so we need to check both. We test with a program that
492 # requires GOT references.
493 foreach arg {fpic fPIC} {
494 if [check_no_compiler_messages $arg object {
495 extern int foo (void); extern int bar;
496 int baz (void) { return foo () + bar; }
504 # Return true if the target supports -mpaired-single (as used on MIPS).
506 proc check_effective_target_mpaired_single { } {
507 return [check_no_compiler_messages mpaired_single object {
512 # Return true if iconv is supported on the target. In particular IBM1047.
514 proc check_iconv_available { test_what } {
522 verbose "check_iconv_available compiling testfile $src" 2
523 set f [open $src "w"]
524 # Compile a small test program.
525 puts $f "#include <iconv.h>\n"
526 puts $f "int main (void)\n {\n iconv_t cd; \n"
527 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
528 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
529 puts $f "return 0;\n}"
532 # If the tool configuration file has not set libiconv, try "-liconv"
533 if { ![info exists libiconv] } {
534 set libiconv "-liconv"
536 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
539 if [string match "" $lines] then {
540 # No error messages, everything is OK.
542 set result [${tool}_load "./$exe" "" ""]
543 set status [lindex $result 0]
544 remote_file build delete $exe
546 verbose "check_iconv_available status is <$status>" 2
548 if { $status == "pass" } then {
556 # Return true if named sections are supported on this target.
558 proc check_named_sections_available { } {
559 return [check_no_compiler_messages named_sections assembly {
560 int __attribute__ ((section("whatever"))) foo;
564 # Return 1 if the target supports Fortran real kinds larger than real(8),
567 # When the target name changes, replace the cached result.
569 proc check_effective_target_fortran_large_real { } {
570 global et_fortran_large_real_saved
571 global et_fortran_large_real_target_name
574 if { ![info exists et_fortran_large_real_target_name] } {
575 set et_fortran_large_real_target_name ""
578 # If the target has changed since we set the cached value, clear it.
579 set current_target [current_target_name]
580 if { $current_target != $et_fortran_large_real_target_name } {
581 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
582 set et_fortran_large_real_target_name $current_target
583 if [info exists et_fortran_large_real_saved] {
584 verbose "check_effective_target_fortran_large_real: removing cached result" 2
585 unset et_fortran_large_real_saved
589 if [info exists et_fortran_large_real_saved] {
590 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
592 set et_fortran_large_real_saved 0
594 # Set up, compile, and execute a test program using large real
595 # kinds. Include the current process ID in the file names to
596 # prevent conflicts with invocations for multiple testsuites.
597 set src real[pid].f90
600 set f [open $src "w"]
601 puts $f "integer,parameter :: k = &"
602 puts $f " selected_real_kind (precision (0.0_8) + 1)"
603 puts $f "real(kind=k) :: x"
604 puts $f "x = cos (x);"
608 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
609 set lines [${tool}_target_compile $src $exe executable ""]
612 if [string match "" $lines] then {
613 # No error message, compilation succeeded.
614 set et_fortran_large_real_saved 1
618 return $et_fortran_large_real_saved
621 # Return 1 if the target supports Fortran integer kinds larger than
622 # integer(8), 0 otherwise.
624 # When the target name changes, replace the cached result.
626 proc check_effective_target_fortran_large_int { } {
627 global et_fortran_large_int_saved
628 global et_fortran_large_int_target_name
631 if { ![info exists et_fortran_large_int_target_name] } {
632 set et_fortran_large_int_target_name ""
635 # If the target has changed since we set the cached value, clear it.
636 set current_target [current_target_name]
637 if { $current_target != $et_fortran_large_int_target_name } {
638 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
639 set et_fortran_large_int_target_name $current_target
640 if [info exists et_fortran_large_int_saved] {
641 verbose "check_effective_target_fortran_large_int: removing cached result" 2
642 unset et_fortran_large_int_saved
646 if [info exists et_fortran_large_int_saved] {
647 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
649 set et_fortran_large_int_saved 0
651 # Set up, compile, and execute a test program using large integer
652 # kinds. Include the current process ID in the file names to
653 # prevent conflicts with invocations for multiple testsuites.
657 set f [open $src "w"]
658 puts $f "integer,parameter :: k = &"
659 puts $f " selected_int_kind (range (0_8) + 1)"
660 puts $f "integer(kind=k) :: i"
664 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
665 set lines [${tool}_target_compile $src $exe executable ""]
668 if [string match "" $lines] then {
669 # No error message, compilation succeeded.
670 set et_fortran_large_int_saved 1
674 return $et_fortran_large_int_saved
677 # Return 1 if we can statically link libgfortran, 0 otherwise.
679 # When the target name changes, replace the cached result.
681 proc check_effective_target_static_libgfortran { } {
682 global et_static_libgfortran
683 global et_static_libgfortran_target_name
686 if { ![info exists et_static_libgfortran_target_name] } {
687 set et_static_libgfortran_target_name ""
690 # If the target has changed since we set the cached value, clear it.
691 set current_target [current_target_name]
692 if { $current_target != $et_static_libgfortran_target_name } {
693 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
694 set et_static_libgfortran_target_name $current_target
695 if [info exists et_static_libgfortran_saved] {
696 verbose "check_effective_target_static_libgfortran: removing cached result" 2
697 unset et_static_libgfortran_saved
701 if [info exists et_static_libgfortran_saved] {
702 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
704 set et_static_libgfortran_saved 0
706 # Set up, compile, and execute a test program using static linking.
707 # Include the current process ID in the file names to prevent
708 # conflicts with invocations for multiple testsuites.
709 set opts "additional_flags=-static"
710 set src static[pid].f
711 set exe static[pid].x
713 set f [open $src "w"]
714 puts $f " print *, 'test'"
718 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
719 set lines [${tool}_target_compile $src $exe executable "$opts"]
722 if [string match "" $lines] then {
723 # No error message, compilation succeeded.
724 set et_static_libgfortran_saved 1
728 return $et_static_libgfortran_saved
731 # Return 1 if the target supports executing AltiVec instructions, 0
732 # otherwise. Cache the result.
734 proc check_vmx_hw_available { } {
735 global vmx_hw_available_saved
738 if [info exists vmx_hw_available_saved] {
739 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
741 set vmx_hw_available_saved 0
743 # Some simulators are known to not support VMX instructions.
744 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
745 verbose "check_hw_available returning 0" 2
746 return $vmx_hw_available_saved
749 # Set up, compile, and execute a test program containing VMX
750 # instructions. Include the current process ID in the file
751 # names to prevent conflicts with invocations for multiple
756 set f [open $src "w"]
757 puts $f "int main() {"
758 puts $f "#ifdef __MACH__"
759 puts $f " asm volatile (\"vor v0,v0,v0\");"
761 puts $f " asm volatile (\"vor 0,0,0\");"
763 puts $f " return 0; }"
766 # Most targets don't require special flags for this test case, but
768 if [istarget *-*-darwin*] {
769 set opts "additional_flags=-maltivec"
774 verbose "check_vmx_hw_available compiling testfile $src" 2
775 set lines [${tool}_target_compile $src $exe executable "$opts"]
778 if [string match "" $lines] then {
779 # No error message, compilation succeeded.
780 set result [${tool}_load "./$exe" "" ""]
781 set status [lindex $result 0]
782 remote_file build delete $exe
783 verbose "check_vmx_hw_available testfile status is <$status>" 2
785 if { $status == "pass" } then {
786 set vmx_hw_available_saved 1
789 verbose "check_vmx_hw_availalble testfile compilation failed" 2
793 return $vmx_hw_available_saved
796 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
797 # complex float arguments. This affects gfortran tests that call cabsf
798 # in libm built by an earlier compiler. Return 1 if libm uses the same
799 # argument passing as the compiler under test, 0 otherwise.
801 # When the target name changes, replace the cached result.
803 proc check_effective_target_broken_cplxf_arg { } {
804 global et_broken_cplxf_arg_saved
805 global et_broken_cplxf_arg_target_name
808 # Skip the work for targets known not to be affected.
809 if { ![istarget powerpc64-*-linux*] } {
811 } elseif { [is-effective-target ilp32] } {
815 if { ![info exists et_broken_cplxf_arg_target_name] } {
816 set et_broken_cplxf_arg_target_name ""
819 # If the target has changed since we set the cached value, clear it.
820 set current_target [current_target_name]
821 if { $current_target != $et_broken_cplxf_arg_target_name } {
822 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
823 set et_broken_cplxf_arg_target_name $current_target
824 if [info exists et_broken_cplxf_arg_saved] {
825 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
826 unset et_broken_cplxf_arg_saved
830 if [info exists et_broken_cplxf_arg_saved] {
831 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
833 set et_broken_cplxf_arg_saved 0
834 # This is only known to affect one target.
835 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
836 set et_broken_cplxf_arg_saved 0
837 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
838 return $et_broken_cplxf_arg_saved
841 # Set up, compile, and execute a C test program that calls cabsf.
845 set f [open $src "w"]
846 puts $f "#include <complex.h>"
847 puts $f "extern void abort (void);"
848 puts $f "float fabsf (float);"
849 puts $f "float cabsf (_Complex float);"
850 puts $f "int main ()"
852 puts $f " _Complex float cf;"
854 puts $f " cf = 3 + 4.0fi;"
855 puts $f " f = cabsf (cf);"
856 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
861 set lines [${tool}_target_compile $src $exe executable "-lm"]
864 if [string match "" $lines] {
865 # No error message, compilation succeeded.
866 set result [${tool}_load "./$exe" "" ""]
867 set status [lindex $result 0]
868 remote_file build delete $exe
870 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
872 if { $status != "pass" } {
873 set et_broken_cplxf_arg_saved 1
876 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
879 return $et_broken_cplxf_arg_saved
882 proc check_alpha_max_hw_available { } {
883 global alpha_max_hw_available_saved
886 if [info exists alpha_max_hw_available_saved] {
887 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
889 set alpha_max_hw_available_saved 0
891 # Set up, compile, and execute a test program probing bit 8 of the
892 # architecture mask, which indicates presence of MAX instructions.
896 set f [open $src "w"]
897 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
900 verbose "check_alpha_max_hw_available compiling testfile $src" 2
901 set lines [${tool}_target_compile $src $exe executable ""]
904 if [string match "" $lines] then {
905 # No error message, compilation succeeded.
906 set result [${tool}_load "./$exe" "" ""]
907 set status [lindex $result 0]
908 remote_file build delete $exe
909 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
911 if { $status == "pass" } then {
912 set alpha_max_hw_available_saved 1
915 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
919 return $alpha_max_hw_available_saved
922 # Returns true iff the FUNCTION is available on the target system.
923 # (This is essentially a Tcl implementation of Autoconf's
926 proc check_function_available { function } {
927 set var "${function}_available_saved"
931 if {![info exists $var]} {
934 # Check to make sure.
935 set src "function[pid].c"
936 set exe "function[pid].exe"
938 set f [open $src "w"]
939 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
940 puts $f "char $function ();\n"
941 puts $f "int main () { $function (); }"
944 set lines [${tool}_target_compile $src $exe executable ""]
948 if {![string match "" $lines]} then {
950 verbose -log "$function is not available"
952 verbose -log "$function is available"
959 # Returns true iff "fork" is available on the target system.
961 proc check_fork_available {} {
962 return [check_function_available "fork"]
965 # Returns true iff "mkfifo" is available on the target system.
967 proc check_mkfifo_available {} {
968 if {[istarget *-*-cygwin*]} {
969 # Cygwin has mkfifo, but support is incomplete.
973 return [check_function_available "mkfifo"]
976 # Returns true iff "__cxa_atexit" is used on the target system.
978 proc check_cxa_atexit_available { } {
980 global et_cxa_atexit_target_name
983 if { ![info exists et_cxa_atexit_target_name] } {
984 set et_cxa_atexit_target_name ""
987 # If the target has changed since we set the cached value, clear it.
988 set current_target [current_target_name]
989 if { $current_target != $et_cxa_atexit_target_name } {
990 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
991 set et_cxa_atexit_target_name $current_target
992 if [info exists et_cxa_atexit] {
993 verbose "check_cxa_atexit_available: removing cached result" 2
998 if [info exists et_cxa_atexit] {
999 verbose "check_cxa_atexit_available: using cached result" 2
1003 # Set up, compile, and execute a C++ test program that depends
1004 # on correct ordering of static object destructors. This is
1005 # indicative of the presence and use of __cxa_atexit.
1006 set src cxaatexit[pid].cc
1007 set exe cxaatexit[pid].x
1009 set f [open $src "w"]
1010 puts $f "#include <stdlib.h>"
1011 puts $f "static unsigned int count;"
1014 puts $f " X() { count = 1; }"
1017 puts $f " if (count != 3)"
1019 puts $f " count = 4;"
1024 puts $f " static X x;"
1028 puts $f " Y() { f(); count = 2; }"
1031 puts $f " if (count != 2)"
1033 puts $f " count = 3;"
1037 puts $f "int main()"
1038 puts $f "{ return 0; }"
1041 set lines [${tool}_target_compile $src $exe executable ""]
1044 if [string match "" $lines] {
1045 # No error message, compilation succeeded.
1046 set result [${tool}_load "./$exe" "" ""]
1047 set status [lindex $result 0]
1048 remote_file build delete $exe
1050 verbose "check_cxa_atexit_available: status is <$status>" 2
1052 if { $status == "pass" } {
1056 verbose "check_cxa_atexit_available: compilation failed" 2
1059 return $et_cxa_atexit
1063 # Return 1 if we're generating 32-bit code using default options, 0
1066 proc check_effective_target_ilp32 { } {
1067 return [check_no_compiler_messages ilp32 object {
1068 int dummy[sizeof (int) == 4
1069 && sizeof (void *) == 4
1070 && sizeof (long) == 4 ? 1 : -1];
1074 # Return 1 if we're generating 32-bit or larger integers using default
1075 # options, 0 otherwise.
1077 proc check_effective_target_int32plus { } {
1078 return [check_no_compiler_messages int32plus object {
1079 int dummy[sizeof (int) >= 4 ? 1 : -1];
1083 # Return 1 if we're generating 32-bit or larger pointers using default
1084 # options, 0 otherwise.
1086 proc check_effective_target_ptr32plus { } {
1087 return [check_no_compiler_messages ptr32plus object {
1088 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1092 # Return 1 if we support 32-bit or larger array and structure sizes
1093 # using default options, 0 otherwise.
1095 proc check_effective_target_size32plus { } {
1096 return [check_no_compiler_messages size32plus object {
1101 # Returns 1 if we're generating 16-bit or smaller integers with the
1102 # default options, 0 otherwise.
1104 proc check_effective_target_int16 { } {
1105 return [check_no_compiler_messages int16 object {
1106 int dummy[sizeof (int) < 4 ? 1 : -1];
1110 # Return 1 if we're generating 64-bit code using default options, 0
1113 proc check_effective_target_lp64 { } {
1114 return [check_no_compiler_messages lp64 object {
1115 int dummy[sizeof (int) == 4
1116 && sizeof (void *) == 8
1117 && sizeof (long) == 8 ? 1 : -1];
1121 # Return 1 if the target supports long double larger than double,
1124 proc check_effective_target_large_long_double { } {
1125 return [check_no_compiler_messages large_long_double object {
1126 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1131 # Return 1 if the target supports compiling decimal floating point,
1134 proc check_effective_target_dfp_nocache { } {
1135 verbose "check_effective_target_dfp_nocache: compiling source" 2
1136 set ret [string match "" [get_compiler_messages dfp 0 object {
1137 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1139 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1143 proc check_effective_target_dfprt_nocache { } {
1148 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1149 # Set up, compile, and execute a test program containing decimal
1151 set src dfprt[pid].c
1152 set exe dfprt[pid].x
1154 set f [open $src "w"]
1155 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1156 puts $f "int main () { z = x + y; return 0; }"
1159 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1160 set lines [${tool}_target_compile $src $exe executable ""]
1163 if [string match "" $lines] then {
1164 # No error message, compilation succeeded.
1165 set result [${tool}_load "./$exe" "" ""]
1166 set status [lindex $result 0]
1167 remote_file build delete $exe
1168 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1169 if { $status == "pass" } then {
1174 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1177 # Return 1 if the target supports compiling Decimal Floating Point,
1180 # This won't change for different subtargets so cache the result.
1182 proc check_effective_target_dfp { } {
1185 if [info exists et_dfp_saved] {
1186 verbose "check_effective_target_dfp: using cached result" 2
1188 set et_dfp_saved [check_effective_target_dfp_nocache]
1190 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1191 return $et_dfp_saved
1194 # Return 1 if the target supports linking and executing Decimal Floating
1195 # Point, # 0 otherwise.
1197 # This won't change for different subtargets so cache the result.
1199 proc check_effective_target_dfprt { } {
1200 global et_dfprt_saved
1203 if [info exists et_dfprt_saved] {
1204 verbose "check_effective_target_dfprt: using cached result" 2
1206 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1208 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1209 return $et_dfprt_saved
1212 # Return 1 if the target needs a command line argument to enable a SIMD
1215 proc check_effective_target_vect_cmdline_needed { } {
1216 global et_vect_cmdline_needed_saved
1217 global et_vect_cmdline_needed_target_name
1219 if { ![info exists et_vect_cmdline_needed_target_name] } {
1220 set et_vect_cmdline_needed_target_name ""
1223 # If the target has changed since we set the cached value, clear it.
1224 set current_target [current_target_name]
1225 if { $current_target != $et_vect_cmdline_needed_target_name } {
1226 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1227 set et_vect_cmdline_needed_target_name $current_target
1228 if { [info exists et_vect_cmdline_needed_saved] } {
1229 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1230 unset et_vect_cmdline_needed_saved
1234 if [info exists et_vect_cmdline_needed_saved] {
1235 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1237 set et_vect_cmdline_needed_saved 1
1238 if { [istarget ia64-*-*]
1239 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1240 && [check_effective_target_lp64])} {
1241 set et_vect_cmdline_needed_saved 0
1245 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1246 return $et_vect_cmdline_needed_saved
1249 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1251 # This won't change for different subtargets so cache the result.
1253 proc check_effective_target_vect_int { } {
1254 global et_vect_int_saved
1256 if [info exists et_vect_int_saved] {
1257 verbose "check_effective_target_vect_int: using cached result" 2
1259 set et_vect_int_saved 0
1260 if { [istarget i?86-*-*]
1261 || [istarget powerpc*-*-*]
1262 || [istarget spu-*-*]
1263 || [istarget x86_64-*-*]
1264 || [istarget sparc*-*-*]
1265 || [istarget alpha*-*-*]
1266 || [istarget ia64-*-*] } {
1267 set et_vect_int_saved 1
1271 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1272 return $et_vect_int_saved
1275 # Return 1 is this is an arm target using 32-bit instructions
1276 proc check_effective_target_arm32 { } {
1277 global et_arm32_saved
1278 global et_arm32_target_name
1279 global compiler_flags
1281 if { ![info exists et_arm32_target_name] } {
1282 set et_arm32_target_name ""
1285 # If the target has changed since we set the cached value, clear it.
1286 set current_target [current_target_name]
1287 if { $current_target != $et_arm32_target_name } {
1288 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1289 set et_arm32_target_name $current_target
1290 if { [info exists et_arm32_saved] } {
1291 verbose "check_effective_target_arm32: removing cached result" 2
1292 unset et_arm32_saved
1296 if [info exists et_arm32_saved] {
1297 verbose "check-effective_target_arm32: using cached result" 2
1299 set et_arm32_saved 0
1300 if { [istarget arm-*-*]
1301 || [istarget strongarm*-*-*]
1302 || [istarget xscale-*-*] } {
1303 if ![string match "*-mthumb *" $compiler_flags] {
1304 set et_arm32_saved 1
1308 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1309 return $et_arm32_saved
1312 # Return 1 if this is an ARM target supporting -mfpu=vfp
1313 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1316 proc check_effective_target_arm_vfp_ok { } {
1317 if { [check_effective_target_arm32] } {
1318 return [check_no_compiler_messages arm_vfp_ok object {
1320 } "-mfpu=vfp -mfloat-abi=softfp"]
1326 # Return 1 if this is a PowerPC target with floating-point registers.
1328 proc check_effective_target_powerpc_fprs { } {
1329 if { [istarget powerpc*-*-*]
1330 || [istarget rs6000-*-*] } {
1331 return [check_no_compiler_messages powerpc_fprs object {
1343 # Return 1 if this is a PowerPC target supporting -maltivec.
1345 proc check_effective_target_powerpc_altivec_ok { } {
1346 if { [istarget powerpc*-*-*]
1347 || [istarget rs6000-*-*] } {
1348 # AltiVec is not supported on Aix.
1349 if { [istarget powerpc*-*-aix*] } {
1352 return [check_no_compiler_messages powerpc_altivec_ok object {
1360 # Return 1 if the target supports hardware vector shift operation.
1362 proc check_effective_target_vect_shift { } {
1363 global et_vect_shift_saved
1365 if [info exists et_vect_shift_saved] {
1366 verbose "check_effective_target_vect_shift: using cached result" 2
1368 set et_vect_shift_saved 0
1369 if { [istarget powerpc*-*-*]
1370 || [istarget ia64-*-*]
1371 || [istarget i?86-*-*]
1372 || [istarget x86_64-*-*] } {
1373 set et_vect_shift_saved 1
1377 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1378 return $et_vect_shift_saved
1381 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1383 # This can change for different subtargets so do not cache the result.
1385 proc check_effective_target_vect_long { } {
1386 if { [istarget i?86-*-*]
1387 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1388 || [istarget x86_64-*-*]
1389 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1395 verbose "check_effective_target_vect_long: returning $answer" 2
1399 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1401 # This won't change for different subtargets so cache the result.
1403 proc check_effective_target_vect_float { } {
1404 global et_vect_float_saved
1406 if [info exists et_vect_float_saved] {
1407 verbose "check_effective_target_vect_float: using cached result" 2
1409 set et_vect_float_saved 0
1410 if { [istarget i?86-*-*]
1411 || [istarget powerpc*-*-*]
1412 || [istarget spu-*-*]
1413 || [istarget mipsisa64*-*-*]
1414 || [istarget x86_64-*-*]
1415 || [istarget ia64-*-*] } {
1416 set et_vect_float_saved 1
1420 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1421 return $et_vect_float_saved
1424 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1426 # This won't change for different subtargets so cache the result.
1428 proc check_effective_target_vect_double { } {
1429 global et_vect_double_saved
1431 if [info exists et_vect_double_saved] {
1432 verbose "check_effective_target_vect_double: using cached result" 2
1434 set et_vect_double_saved 0
1435 if { [istarget i?86-*-*]
1436 || [istarget x86_64-*-*]
1437 || [istarget spu-*-*] } {
1438 set et_vect_double_saved 1
1442 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1443 return $et_vect_double_saved
1446 # Return 0 if the target supports hardware comparison of vectors of double, 0 otherwise.
1448 # This won't change for different subtargets so cache the result.
1450 proc check_effective_target_vect_no_compare_double { } {
1451 global et_vect_no_compare_double_saved
1453 if [info exists et_vect_no_compare_double_saved] {
1454 verbose "check_effective_target_vect_no_compare_double: using cached result" 2
1456 set et_vect_no_compare_double_saved 0
1457 if { [istarget spu-*-*] } {
1458 set et_vect_no_compare_double_saved 1
1462 verbose "check_effective_target_vect_no_compare_double: returning $et_vect_no_compare_double_saved" 2
1463 return $et_vect_no_compare_double_saved
1466 # Return 1 if the target plus current options does not support a vector
1467 # max instruction on "int", 0 otherwise.
1469 # This won't change for different subtargets so cache the result.
1471 proc check_effective_target_vect_no_int_max { } {
1472 global et_vect_no_int_max_saved
1474 if [info exists et_vect_no_int_max_saved] {
1475 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1477 set et_vect_no_int_max_saved 0
1478 if { [istarget sparc*-*-*]
1479 || [istarget spu-*-*]
1480 || [istarget alpha*-*-*] } {
1481 set et_vect_no_int_max_saved 1
1484 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1485 return $et_vect_no_int_max_saved
1488 # Return 1 if the target plus current options does not support a vector
1489 # add instruction on "int", 0 otherwise.
1491 # This won't change for different subtargets so cache the result.
1493 proc check_effective_target_vect_no_int_add { } {
1494 global et_vect_no_int_add_saved
1496 if [info exists et_vect_no_int_add_saved] {
1497 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1499 set et_vect_no_int_add_saved 0
1500 # Alpha only supports vector add on V8QI and V4HI.
1501 if { [istarget alpha*-*-*] } {
1502 set et_vect_no_int_add_saved 1
1505 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1506 return $et_vect_no_int_add_saved
1509 # Return 1 if the target plus current options does not support vector
1510 # bitwise instructions, 0 otherwise.
1512 # This won't change for different subtargets so cache the result.
1514 proc check_effective_target_vect_no_bitwise { } {
1515 global et_vect_no_bitwise_saved
1517 if [info exists et_vect_no_bitwise_saved] {
1518 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1520 set et_vect_no_bitwise_saved 0
1522 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1523 return $et_vect_no_bitwise_saved
1526 # Return 1 if the target plus current options supports a vector
1527 # widening summation of *short* args into *int* result, 0 otherwise.
1528 # A target can also support this widening summation if it can support
1529 # promotion (unpacking) from shorts to ints.
1531 # This won't change for different subtargets so cache the result.
1533 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1534 global et_vect_widen_sum_hi_to_si
1536 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1537 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1539 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1540 if { [istarget powerpc*-*-*] } {
1541 set et_vect_widen_sum_hi_to_si_saved 1
1544 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1545 return $et_vect_widen_sum_hi_to_si_saved
1548 # Return 1 if the target plus current options supports a vector
1549 # widening summation of *char* args into *short* result, 0 otherwise.
1550 # A target can also support this widening summation if it can support
1551 # promotion (unpacking) from chars to shorts.
1553 # This won't change for different subtargets so cache the result.
1555 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1556 global et_vect_widen_sum_qi_to_hi
1558 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1559 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1561 set et_vect_widen_sum_qi_to_hi_saved 0
1562 if { [check_effective_target_vect_unpack] } {
1563 set et_vect_widen_sum_qi_to_hi_saved 1
1566 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1567 return $et_vect_widen_sum_qi_to_hi_saved
1570 # Return 1 if the target plus current options supports a vector
1571 # widening summation of *char* args into *int* result, 0 otherwise.
1573 # This won't change for different subtargets so cache the result.
1575 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1576 global et_vect_widen_sum_qi_to_si
1578 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1579 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1581 set et_vect_widen_sum_qi_to_si_saved 0
1582 if { [istarget powerpc*-*-*] } {
1583 set et_vect_widen_sum_qi_to_si_saved 1
1586 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1587 return $et_vect_widen_sum_qi_to_si_saved
1590 # Return 1 if the target plus current options supports a vector
1591 # widening multiplication of *char* args into *short* result, 0 otherwise.
1592 # A target can also support this widening multplication if it can support
1593 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1594 # multiplication of shorts).
1596 # This won't change for different subtargets so cache the result.
1599 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1600 global et_vect_widen_mult_qi_to_hi
1602 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1603 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1605 if { [check_effective_target_vect_unpack]
1606 && [check_effective_target_vect_short_mult] } {
1607 set et_vect_widen_mult_qi_to_hi_saved 1
1609 set et_vect_widen_mult_qi_to_hi_saved 0
1611 if { [istarget powerpc*-*-*] } {
1612 set et_vect_widen_mult_qi_to_hi_saved 1
1615 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1616 return $et_vect_widen_mult_qi_to_hi_saved
1619 # Return 1 if the target plus current options supports a vector
1620 # widening multiplication of *short* args into *int* result, 0 otherwise.
1621 # A target can also support this widening multplication if it can support
1622 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1623 # multiplication of ints).
1625 # This won't change for different subtargets so cache the result.
1628 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1629 global et_vect_widen_mult_hi_to_si
1631 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1632 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1634 if { [check_effective_target_vect_unpack]
1635 && [check_effective_target_vect_int_mult] } {
1636 set et_vect_widen_mult_hi_to_si_saved 1
1638 set et_vect_widen_mult_hi_to_si_saved 0
1640 if { [istarget powerpc*-*-*]
1641 || [istarget i?86-*-*]
1642 || [istarget x86_64-*-*] } {
1643 set et_vect_widen_mult_hi_to_si_saved 1
1646 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1647 return $et_vect_widen_mult_hi_to_si_saved
1650 # Return 1 if the target plus current options supports a vector
1651 # dot-product of signed chars, 0 otherwise.
1653 # This won't change for different subtargets so cache the result.
1655 proc check_effective_target_vect_sdot_qi { } {
1656 global et_vect_sdot_qi
1658 if [info exists et_vect_sdot_qi_saved] {
1659 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1661 set et_vect_sdot_qi_saved 0
1663 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1664 return $et_vect_sdot_qi_saved
1667 # Return 1 if the target plus current options supports a vector
1668 # dot-product of unsigned chars, 0 otherwise.
1670 # This won't change for different subtargets so cache the result.
1672 proc check_effective_target_vect_udot_qi { } {
1673 global et_vect_udot_qi
1675 if [info exists et_vect_udot_qi_saved] {
1676 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1678 set et_vect_udot_qi_saved 0
1679 if { [istarget powerpc*-*-*] } {
1680 set et_vect_udot_qi_saved 1
1683 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1684 return $et_vect_udot_qi_saved
1687 # Return 1 if the target plus current options supports a vector
1688 # dot-product of signed shorts, 0 otherwise.
1690 # This won't change for different subtargets so cache the result.
1692 proc check_effective_target_vect_sdot_hi { } {
1693 global et_vect_sdot_hi
1695 if [info exists et_vect_sdot_hi_saved] {
1696 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1698 set et_vect_sdot_hi_saved 0
1699 if { [istarget powerpc*-*-*]
1700 || [istarget i?86-*-*]
1701 || [istarget x86_64-*-*] } {
1702 set et_vect_sdot_hi_saved 1
1705 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1706 return $et_vect_sdot_hi_saved
1709 # Return 1 if the target plus current options supports a vector
1710 # dot-product of unsigned shorts, 0 otherwise.
1712 # This won't change for different subtargets so cache the result.
1714 proc check_effective_target_vect_udot_hi { } {
1715 global et_vect_udot_hi
1717 if [info exists et_vect_udot_hi_saved] {
1718 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1720 set et_vect_udot_hi_saved 0
1721 if { [istarget powerpc*-*-*] } {
1722 set et_vect_udot_hi_saved 1
1725 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1726 return $et_vect_udot_hi_saved
1730 # Return 1 if the target plus current options supports a vector
1731 # demotion (packing) of shorts (to chars) and ints (to shorts)
1732 # using modulo arithmetic, 0 otherwise.
1734 # This won't change for different subtargets so cache the result.
1736 proc check_effective_target_vect_pack_mod { } {
1737 global et_vect_pack_mod
1739 if [info exists et_vect_pack_mod_saved] {
1740 verbose "check_effective_target_vect_pack_mod: using cached result" 2
1742 set et_vect_pack_mod_saved 0
1743 if { [istarget powerpc*-*-*]
1744 || [istarget i?86-*-*]
1745 || [istarget x86_64-*-*] } {
1746 set et_vect_pack_mod_saved 1
1749 verbose "check_effective_target_vect_pack_mod: returning $et_vect_pack_mod_saved" 2
1750 return $et_vect_pack_mod_saved
1753 # Return 1 if the target plus current options supports a vector
1754 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1756 # This won't change for different subtargets so cache the result.
1758 proc check_effective_target_vect_unpack { } {
1759 global et_vect_unpack
1761 if [info exists et_vect_unpack_saved] {
1762 verbose "check_effective_target_vect_unpack: using cached result" 2
1764 set et_vect_unpack_saved 0
1765 if { [istarget powerpc*-*-*]
1766 || [istarget i?86-*-*]
1767 || [istarget x86_64-*-*] } {
1768 set et_vect_unpack_saved 1
1771 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1772 return $et_vect_unpack_saved
1775 # Return 1 if the target plus current options does not support a vector
1776 # alignment mechanism, 0 otherwise.
1778 # This won't change for different subtargets so cache the result.
1780 proc check_effective_target_vect_no_align { } {
1781 global et_vect_no_align_saved
1783 if [info exists et_vect_no_align_saved] {
1784 verbose "check_effective_target_vect_no_align: using cached result" 2
1786 set et_vect_no_align_saved 0
1787 if { [istarget mipsisa64*-*-*]
1788 || [istarget spu-*-*]
1789 || [istarget sparc*-*-*]
1790 || [istarget ia64-*-*] } {
1791 set et_vect_no_align_saved 1
1794 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1795 return $et_vect_no_align_saved
1798 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1800 proc check_effective_target_vect_condition { } {
1801 global et_vect_cond_saved
1803 if [info exists et_vect_cond_saved] {
1804 verbose "check_effective_target_vect_cond: using cached result" 2
1806 set et_vect_cond_saved 0
1807 if { [istarget powerpc*-*-*]
1808 || [istarget ia64-*-*]
1809 || [istarget i?86-*-*]
1810 || [istarget x86_64-*-*] } {
1811 set et_vect_cond_saved 1
1815 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1816 return $et_vect_cond_saved
1819 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1821 proc check_effective_target_vect_char_mult { } {
1822 global et_vect_char_mult_saved
1824 if [info exists et_vect_char_mult_saved] {
1825 verbose "check_effective_target_vect_char_mult: using cached result" 2
1827 set et_vect_char_mult_saved 0
1828 if { [istarget ia64-*-*]
1829 || [istarget i?86-*-*]
1830 || [istarget x86_64-*-*] } {
1831 set et_vect_char_mult_saved 1
1835 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1836 return $et_vect_char_mult_saved
1839 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1841 proc check_effective_target_vect_short_mult { } {
1842 global et_vect_short_mult_saved
1844 if [info exists et_vect_short_mult_saved] {
1845 verbose "check_effective_target_vect_short_mult: using cached result" 2
1847 set et_vect_short_mult_saved 0
1848 if { [istarget ia64-*-*]
1849 || [istarget i?86-*-*]
1850 || [istarget x86_64-*-*] } {
1851 set et_vect_short_mult_saved 1
1855 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1856 return $et_vect_short_mult_saved
1859 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1861 proc check_effective_target_vect_int_mult { } {
1862 global et_vect_int_mult_saved
1864 if [info exists et_vect_int_mult_saved] {
1865 verbose "check_effective_target_vect_int_mult: using cached result" 2
1867 set et_vect_int_mult_saved 0
1868 if { [istarget powerpc*-*-*]
1869 || [istarget i?86-*-*]
1870 || [istarget x86_64-*-*] } {
1871 set et_vect_int_mult_saved 1
1875 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1876 return $et_vect_int_mult_saved
1879 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1881 proc check_effective_target_vect_extract_even_odd { } {
1882 global et_vect_extract_even_odd_saved
1884 if [info exists et_vect_extract_even_odd_saved] {
1885 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1887 set et_vect_extract_even_odd_saved 0
1888 if { [istarget powerpc*-*-*] } {
1889 set et_vect_extract_even_odd_saved 1
1893 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1894 return $et_vect_extract_even_odd_saved
1897 # Return 1 if the target supports vector interleaving, 0 otherwise.
1899 proc check_effective_target_vect_interleave { } {
1900 global et_vect_interleave_saved
1902 if [info exists et_vect_interleave_saved] {
1903 verbose "check_effective_target_vect_interleave: using cached result" 2
1905 set et_vect_interleave_saved 0
1906 if { [istarget powerpc*-*-*]
1907 || [istarget i?86-*-*]
1908 || [istarget x86_64-*-*] } {
1909 set et_vect_interleave_saved 1
1913 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1914 return $et_vect_interleave_saved
1917 # Return 1 if the target supports section-anchors
1919 proc check_effective_target_section_anchors { } {
1920 global et_section_anchors_saved
1922 if [info exists et_section_anchors_saved] {
1923 verbose "check_effective_target_section_anchors: using cached result" 2
1925 set et_section_anchors_saved 0
1926 if { [istarget powerpc*-*-*] } {
1927 set et_section_anchors_saved 1
1931 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1932 return $et_section_anchors_saved
1935 # Return 1 if the target supports atomic operations on "int" and "long".
1937 proc check_effective_target_sync_int_long { } {
1938 global et_sync_int_long_saved
1940 if [info exists et_sync_int_long_saved] {
1941 verbose "check_effective_target_sync_int_long: using cached result" 2
1943 set et_sync_int_long_saved 0
1944 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1945 # load-reserved/store-conditional instructions.
1946 if { [istarget ia64-*-*]
1947 || [istarget i?86-*-*]
1948 || [istarget x86_64-*-*]
1949 || [istarget alpha*-*-*]
1950 || [istarget s390*-*-*]
1951 || [istarget powerpc*-*-*]
1952 || [istarget sparc64-*-*]
1953 || [istarget sparcv9-*-*] } {
1954 set et_sync_int_long_saved 1
1958 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1959 return $et_sync_int_long_saved
1962 # Return 1 if the target supports atomic operations on "char" and "short".
1964 proc check_effective_target_sync_char_short { } {
1965 global et_sync_char_short_saved
1967 if [info exists et_sync_char_short_saved] {
1968 verbose "check_effective_target_sync_char_short: using cached result" 2
1970 set et_sync_char_short_saved 0
1971 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1972 # load-reserved/store-conditional instructions.
1973 if { [istarget ia64-*-*]
1974 || [istarget i?86-*-*]
1975 || [istarget x86_64-*-*]
1976 || [istarget alpha*-*-*]
1977 || [istarget s390*-*-*]
1978 || [istarget powerpc*-*-*]
1979 || [istarget sparc64-*-*]
1980 || [istarget sparcv9-*-*] } {
1981 set et_sync_char_short_saved 1
1985 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1986 return $et_sync_char_short_saved
1989 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1990 # This can be used with any check_* proc that takes no argument and
1991 # returns only 1 or 0. It could be used with check_* procs that take
1992 # arguments with keywords that pass particular arguments.
1994 proc is-effective-target { arg } {
1996 if { [info procs check_effective_target_${arg}] != [list] } {
1997 set selected [check_effective_target_${arg}]
2000 "vmx_hw" { set selected [check_vmx_hw_available] }
2001 "named_sections" { set selected [check_named_sections_available] }
2002 "gc_sections" { set selected [check_gc_sections_available] }
2003 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2004 default { error "unknown effective target keyword `$arg'" }
2007 verbose "is-effective-target: $arg $selected" 2
2011 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2013 proc is-effective-target-keyword { arg } {
2014 if { [info procs check_effective_target_${arg}] != [list] } {
2017 # These have different names for their check_* procs.
2019 "vmx_hw" { return 1 }
2020 "named_sections" { return 1 }
2021 "gc_sections" { return 1 }
2022 "cxa_atexit" { return 1 }
2023 default { return 0 }
2028 # Return 1 if target default to short enums
2030 proc check_effective_target_short_enums { } {
2031 return [check_no_compiler_messages short_enums assembly {
2033 int s[sizeof (enum foo) == 1 ? 1 : -1];
2037 # Return 1 if target supports merging string constants at link time.
2039 proc check_effective_target_string_merging { } {
2040 return [check_no_messages_and_pattern string_merging \
2041 "rodata\\.str" assembly {
2042 const char *var = "String";