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.
25 # BASENAME is a basename to use for temporary files.
26 # TYPE is the type of compilation to perform (see target_compile).
27 # CONTENTS gives the contents of the input file.
28 # The rest is optional:
29 # OPTIONS: additional compiler options to use.
30 proc get_compiler_messages {basename type contents args} {
33 if { [llength $args] > 0 } {
34 set options "additional_flags=[lindex $args 0]"
39 set src ${basename}[pid].c
41 assembly { set output ${basename}[pid].s }
42 object { set output ${basename}[pid].o }
47 set lines [${tool}_target_compile $src $output $type "$options"]
49 remote_file build delete $output
54 proc current_target_name { } {
56 if [info exists target_info(target,name)] {
57 set answer $target_info(target,name)
64 # Implement an effective-target check for property PROP by invoking
65 # the compiler and seeing if it prints any messages. Assume that the
66 # property holds if the compiler doesn't print anything. The other
67 # arguments are as for get_compiler_messages, starting with TYPE.
68 proc check_no_compiler_messages {prop args} {
71 set target [current_target_name]
72 if {![info exists et_cache($prop,target)]
73 || $et_cache($prop,target) != $target} {
74 verbose "check_effective_target $prop: compiling source for $target" 2
75 set et_cache($prop,target) $target
76 set et_cache($prop,value) \
77 [string match "" [eval get_compiler_messages $prop $args]]
79 set value $et_cache($prop,value)
80 verbose "check_effective_target $prop: returning $value for $target" 2
84 ###############################
85 # proc check_weak_available { }
86 ###############################
88 # weak symbols are only supported in some configs/object formats
89 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
91 proc check_weak_available { } {
95 # All mips targets should support it
97 if { [ string first "mips" $target_cpu ] >= 0 } {
101 # All solaris2 targets should support it
103 if { [regexp ".*-solaris2.*" $target_triplet] } {
107 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
109 if { [regexp "alpha.*osf.*" $target_triplet] } {
113 # Windows targets Cygwin and MingW32 support it
115 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
119 # HP-UX 10.X doesn't support it
121 if { [regexp "hppa.*hpux10" $target_triplet] } {
125 # ELF and ECOFF support it. a.out does with gas/gld but may also with
126 # other linkers, so we should try it
128 set objformat [gcc_target_object_format]
136 unknown { return -1 }
141 ###############################
142 # proc check_visibility_available { what_kind }
143 ###############################
145 # The visibility attribute is only support in some object formats
146 # This proc returns 1 if it is supported, 0 if not.
147 # The argument is the kind of visibility, default/protected/hidden/internal.
149 proc check_visibility_available { what_kind } {
151 global target_triplet
153 # On NetWare, support makes no sense.
154 if { [istarget *-*-netware*] } {
158 if [string match "" $what_kind] { set what_kind "hidden" }
160 return [check_no_compiler_messages visibility_available_$what_kind object "
161 void f() __attribute__((visibility(\"$what_kind\")));
166 ###############################
167 # proc check_alias_available { }
168 ###############################
170 # Determine if the target toolchain supports the alias attribute.
172 # Returns 2 if the target supports aliases. Returns 1 if the target
173 # only supports weak aliased. Returns 0 if the target does not
174 # support aliases at all. Returns -1 if support for aliases could not
177 proc check_alias_available { } {
178 global alias_available_saved
181 if [info exists alias_available_saved] {
182 verbose "check_alias_available returning saved $alias_available_saved" 2
186 verbose "check_alias_available compiling testfile $src" 2
187 set f [open $src "w"]
188 # Compile a small test program. The definition of "g" is
189 # necessary to keep the Solaris assembler from complaining
191 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
192 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
194 set lines [${tool}_target_compile $src $obj object ""]
196 remote_file build delete $obj
198 if [string match "" $lines] then {
199 # No error messages, everything is OK.
200 set alias_available_saved 2
202 if [regexp "alias definitions not supported" $lines] {
203 verbose "check_alias_available target does not support aliases" 2
205 set objformat [gcc_target_object_format]
207 if { $objformat == "elf" } {
208 verbose "check_alias_available but target uses ELF format, so it ought to" 2
209 set alias_available_saved -1
211 set alias_available_saved 0
214 if [regexp "only weak aliases are supported" $lines] {
215 verbose "check_alias_available target supports only weak aliases" 2
216 set alias_available_saved 1
218 set alias_available_saved -1
223 verbose "check_alias_available returning $alias_available_saved" 2
226 return $alias_available_saved
229 # Returns true if --gc-sections is supported on the target.
231 proc check_gc_sections_available { } {
232 global gc_sections_available_saved
235 if {![info exists gc_sections_available_saved]} {
236 # Some targets don't support gc-sections despite whatever's
237 # advertised by ld's options.
238 if { [istarget alpha*-*-*]
239 || [istarget ia64-*-*] } {
240 set gc_sections_available_saved 0
244 # Check if the ld used by gcc supports --gc-sections.
245 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
246 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
247 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
248 set ld_output [remote_exec host "$gcc_ld" "--help"]
249 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
250 set gc_sections_available_saved 1
252 set gc_sections_available_saved 0
255 return $gc_sections_available_saved
258 # Return true if profiling is supported on the target.
260 proc check_profiling_available { test_what } {
261 global profiling_available_saved
263 verbose "Profiling argument is <$test_what>" 1
265 # These conditions depend on the argument so examine them before
266 # looking at the cache variable.
268 # Support for -p on solaris2 relies on mcrt1.o which comes with the
269 # vendor compiler. We cannot reliably predict the directory where the
270 # vendor compiler (and thus mcrt1.o) is installed so we can't
271 # necessarily find mcrt1.o even if we have it.
272 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
276 # Support for -p on irix relies on libprof1.a which doesn't appear to
277 # exist on any irix6 system currently posting testsuite results.
278 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
279 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
280 if { [istarget mips*-*-irix*]
281 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
285 # At present, there is no profiling support on NetWare.
286 if { [istarget *-*-netware*] } {
290 # Now examine the cache variable.
291 if {![info exists profiling_available_saved]} {
292 # Some targets don't have any implementation of __bb_init_func or are
293 # missing other needed machinery.
294 if { [istarget mmix-*-*]
295 || [istarget arm*-*-eabi*]
296 || [istarget arm*-*-elf]
297 || [istarget arm*-*-symbianelf*]
298 || [istarget powerpc-*-eabi*]
299 || [istarget strongarm*-*-elf]
300 || [istarget xscale*-*-elf]
301 || [istarget cris-*-*]
302 || [istarget h8300-*-*]
303 || [istarget m32c-*-elf]
304 || [istarget m68k-*-elf]
305 || [istarget mips*-*-elf]
306 || [istarget xtensa-*-elf]
307 || [istarget *-*-windiss] } {
308 set profiling_available_saved 0
310 set profiling_available_saved 1
314 return $profiling_available_saved
317 # Return 1 if target has packed layout of structure members by
318 # default, 0 otherwise. Note that this is slightly different than
319 # whether the target has "natural alignment": both attributes may be
322 proc check_effective_target_default_packed { } {
323 return [check_no_compiler_messages default_packed assembly {
324 struct x { char a; long b; } c;
325 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
329 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
330 # documentation, where the test also comes from.
332 proc check_effective_target_pcc_bitfield_type_matters { } {
333 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
334 # bitfields, but let's stick to the example code from the docs.
335 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
336 struct foo1 { char x; char :0; char y; };
337 struct foo2 { char x; int :0; char y; };
338 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
342 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
344 # This won't change for different subtargets so cache the result.
346 proc check_effective_target_tls {} {
349 if [info exists et_tls_saved] {
350 verbose "check_effective_target_tls: using cached result" 2
356 verbose "check_effective_target_tls: compiling testfile $src" 2
357 set f [open $src "w"]
358 # Compile a small test program.
359 puts $f "__thread int i;\n"
362 # Test for thread-local data supported by the platform.
364 [target_compile $src $asm assembly ""]
366 if { [string match "*not supported*" $comp_output] } {
369 remove-build-file $asm
371 verbose "check_effective_target_tls: returning $et_tls_saved" 2
375 # Return 1 if TLS executables can run correctly, 0 otherwise.
377 # This won't change for different subtargets so cache the result.
379 proc check_effective_target_tls_runtime {} {
380 global et_tls_runtime_saved
382 if [info exists et_tls_runtime_saved] {
383 verbose "check_effective_target_tls_runtime: using cached result" 2
385 set et_tls_runtime_saved 0
387 set src tls_runtime[pid].c
388 set exe tls_runtime[pid].x
389 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
390 set f [open $src "w"]
391 # Compile a small test program.
392 puts $f "__thread int thr = 0;\n"
393 puts $f "int main(void)\n {\n return thr;\n}"
397 [target_compile $src $exe executable ""]
400 if [string match "" $comp_output] then {
401 # No error messages, everything is OK.
403 set result [remote_load target "./$exe" "" ""]
404 set status [lindex $result 0]
405 remote_file build delete $exe
407 verbose "check_effective_target_tls_runtime status is <$status>" 2
409 if { $status == "pass" } {
410 set et_tls_runtime_saved 1
413 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
417 return $et_tls_runtime_saved
420 # Return 1 if compilation with -fopenmp is error-free for trivial
423 proc check_effective_target_fopenmp {} {
424 return [check_no_compiler_messages fopenmp object {
429 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
430 # for trivial code, 0 otherwise.
432 proc check_effective_target_freorder {} {
433 return [check_no_compiler_messages freorder object {
435 } "-freorder-blocks-and-partition"]
438 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
439 # emitted, 0 otherwise. Whether a shared library can actually be built is
440 # out of scope for this test.
442 proc check_effective_target_fpic { } {
443 # Note that M68K has a multilib that supports -fpic but not
444 # -fPIC, so we need to check both. We test with a program that
445 # requires GOT references.
446 foreach arg {fpic fPIC} {
447 if [check_no_compiler_messages $arg object {
448 extern int foo (void); extern int bar;
449 int baz (void) { return foo () + bar; }
457 # Return true if iconv is supported on the target. In particular IBM1047.
459 proc check_iconv_available { test_what } {
467 verbose "check_iconv_available compiling testfile $src" 2
468 set f [open $src "w"]
469 # Compile a small test program.
470 puts $f "#include <iconv.h>\n"
471 puts $f "int main (void)\n {\n iconv_t cd; \n"
472 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
473 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
474 puts $f "return 0;\n}"
477 # If the tool configuration file has not set libiconv, try "-liconv"
478 if { ![info exists libiconv] } {
479 set libiconv "-liconv"
481 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
484 if [string match "" $lines] then {
485 # No error messages, everything is OK.
487 set result [${tool}_load "./$exe" "" ""]
488 set status [lindex $result 0]
489 remote_file build delete $exe
491 verbose "check_iconv_available status is <$status>" 2
493 if { $status == "pass" } then {
501 # Return true if named sections are supported on this target.
503 proc check_named_sections_available { } {
504 return [check_no_compiler_messages named_sections assembly {
505 int __attribute__ ((section("whatever"))) foo;
509 # Return 1 if the target supports Fortran real kinds larger than real(8),
512 # When the target name changes, replace the cached result.
514 proc check_effective_target_fortran_large_real { } {
515 global et_fortran_large_real_saved
516 global et_fortran_large_real_target_name
519 if { ![info exists et_fortran_large_real_target_name] } {
520 set et_fortran_large_real_target_name ""
523 # If the target has changed since we set the cached value, clear it.
524 set current_target [current_target_name]
525 if { $current_target != $et_fortran_large_real_target_name } {
526 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
527 set et_fortran_large_real_target_name $current_target
528 if [info exists et_fortran_large_real_saved] {
529 verbose "check_effective_target_fortran_large_real: removing cached result" 2
530 unset et_fortran_large_real_saved
534 if [info exists et_fortran_large_real_saved] {
535 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
537 set et_fortran_large_real_saved 0
539 # Set up, compile, and execute a test program using large real
540 # kinds. Include the current process ID in the file names to
541 # prevent conflicts with invocations for multiple testsuites.
542 set src real[pid].f90
545 set f [open $src "w"]
546 puts $f "integer,parameter :: k = &"
547 puts $f " selected_real_kind (precision (0.0_8) + 1)"
548 puts $f "real(kind=k) :: x"
549 puts $f "x = cos (x);"
553 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
554 set lines [${tool}_target_compile $src $exe executable ""]
557 if [string match "" $lines] then {
558 # No error message, compilation succeeded.
559 set et_fortran_large_real_saved 1
563 return $et_fortran_large_real_saved
566 # Return 1 if the target supports Fortran integer kinds larger than
567 # integer(8), 0 otherwise.
569 # When the target name changes, replace the cached result.
571 proc check_effective_target_fortran_large_int { } {
572 global et_fortran_large_int_saved
573 global et_fortran_large_int_target_name
576 if { ![info exists et_fortran_large_int_target_name] } {
577 set et_fortran_large_int_target_name ""
580 # If the target has changed since we set the cached value, clear it.
581 set current_target [current_target_name]
582 if { $current_target != $et_fortran_large_int_target_name } {
583 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
584 set et_fortran_large_int_target_name $current_target
585 if [info exists et_fortran_large_int_saved] {
586 verbose "check_effective_target_fortran_large_int: removing cached result" 2
587 unset et_fortran_large_int_saved
591 if [info exists et_fortran_large_int_saved] {
592 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
594 set et_fortran_large_int_saved 0
596 # Set up, compile, and execute a test program using large integer
597 # kinds. Include the current process ID in the file names to
598 # prevent conflicts with invocations for multiple testsuites.
602 set f [open $src "w"]
603 puts $f "integer,parameter :: k = &"
604 puts $f " selected_int_kind (range (0_8) + 1)"
605 puts $f "integer(kind=k) :: i"
609 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
610 set lines [${tool}_target_compile $src $exe executable ""]
613 if [string match "" $lines] then {
614 # No error message, compilation succeeded.
615 set et_fortran_large_int_saved 1
619 return $et_fortran_large_int_saved
622 # Return 1 if we can statically link libgfortran, 0 otherwise.
624 # When the target name changes, replace the cached result.
626 proc check_effective_target_static_libgfortran { } {
627 global et_static_libgfortran
628 global et_static_libgfortran_target_name
631 if { ![info exists et_static_libgfortran_target_name] } {
632 set et_static_libgfortran_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_static_libgfortran_target_name } {
638 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
639 set et_static_libgfortran_target_name $current_target
640 if [info exists et_static_libgfortran_saved] {
641 verbose "check_effective_target_static_libgfortran: removing cached result" 2
642 unset et_static_libgfortran_saved
646 if [info exists et_static_libgfortran_saved] {
647 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
649 set et_static_libgfortran_saved 0
651 # Set up, compile, and execute a test program using static linking.
652 # Include the current process ID in the file names to prevent
653 # conflicts with invocations for multiple testsuites.
654 set opts "additional_flags=-static"
655 set src static[pid].f
656 set exe static[pid].x
658 set f [open $src "w"]
659 puts $f " print *, 'test'"
663 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
664 set lines [${tool}_target_compile $src $exe executable "$opts"]
667 if [string match "" $lines] then {
668 # No error message, compilation succeeded.
669 set et_static_libgfortran_saved 1
673 return $et_static_libgfortran_saved
676 # Return 1 if the target supports executing AltiVec instructions, 0
677 # otherwise. Cache the result.
679 proc check_vmx_hw_available { } {
680 global vmx_hw_available_saved
683 if [info exists vmx_hw_available_saved] {
684 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
686 set vmx_hw_available_saved 0
688 # Some simulators are known to not support VMX instructions.
689 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
690 verbose "check_hw_available returning 0" 2
691 return $vmx_hw_available_saved
694 # Set up, compile, and execute a test program containing VMX
695 # instructions. Include the current process ID in the file
696 # names to prevent conflicts with invocations for multiple
701 set f [open $src "w"]
702 puts $f "int main() {"
703 puts $f "#ifdef __MACH__"
704 puts $f " asm volatile (\"vor v0,v0,v0\");"
706 puts $f " asm volatile (\"vor 0,0,0\");"
708 puts $f " return 0; }"
711 # Most targets don't require special flags for this test case, but
713 if [istarget *-*-darwin*] {
714 set opts "additional_flags=-maltivec"
719 verbose "check_vmx_hw_available compiling testfile $src" 2
720 set lines [${tool}_target_compile $src $exe executable "$opts"]
723 if [string match "" $lines] then {
724 # No error message, compilation succeeded.
725 set result [${tool}_load "./$exe" "" ""]
726 set status [lindex $result 0]
727 remote_file build delete $exe
728 verbose "check_vmx_hw_available testfile status is <$status>" 2
730 if { $status == "pass" } then {
731 set vmx_hw_available_saved 1
734 verbose "check_vmx_hw_availalble testfile compilation failed" 2
738 return $vmx_hw_available_saved
741 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
742 # complex float arguments. This affects gfortran tests that call cabsf
743 # in libm built by an earlier compiler. Return 1 if libm uses the same
744 # argument passing as the compiler under test, 0 otherwise.
746 # When the target name changes, replace the cached result.
748 proc check_effective_target_broken_cplxf_arg { } {
749 global et_broken_cplxf_arg_saved
750 global et_broken_cplxf_arg_target_name
753 # Skip the work for targets known not to be affected.
754 if { ![istarget powerpc64-*-linux*] } {
756 } elseif { [is-effective-target ilp32] } {
760 if { ![info exists et_broken_cplxf_arg_target_name] } {
761 set et_broken_cplxf_arg_target_name ""
764 # If the target has changed since we set the cached value, clear it.
765 set current_target [current_target_name]
766 if { $current_target != $et_broken_cplxf_arg_target_name } {
767 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
768 set et_broken_cplxf_arg_target_name $current_target
769 if [info exists et_broken_cplxf_arg_saved] {
770 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
771 unset et_broken_cplxf_arg_saved
775 if [info exists et_broken_cplxf_arg_saved] {
776 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
778 set et_broken_cplxf_arg_saved 0
779 # This is only known to affect one target.
780 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
781 set et_broken_cplxf_arg_saved 0
782 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
783 return $et_broken_cplxf_arg_saved
786 # Set up, compile, and execute a C test program that calls cabsf.
790 set f [open $src "w"]
791 puts $f "#include <complex.h>"
792 puts $f "extern void abort (void);"
793 puts $f "float fabsf (float);"
794 puts $f "float cabsf (_Complex float);"
795 puts $f "int main ()"
797 puts $f " _Complex float cf;"
799 puts $f " cf = 3 + 4.0fi;"
800 puts $f " f = cabsf (cf);"
801 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
806 set lines [${tool}_target_compile $src $exe executable "-lm"]
809 if [string match "" $lines] {
810 # No error message, compilation succeeded.
811 set result [${tool}_load "./$exe" "" ""]
812 set status [lindex $result 0]
813 remote_file build delete $exe
815 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
817 if { $status != "pass" } {
818 set et_broken_cplxf_arg_saved 1
821 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
824 return $et_broken_cplxf_arg_saved
827 proc check_alpha_max_hw_available { } {
828 global alpha_max_hw_available_saved
831 if [info exists alpha_max_hw_available_saved] {
832 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
834 set alpha_max_hw_available_saved 0
836 # Set up, compile, and execute a test program probing bit 8 of the
837 # architecture mask, which indicates presence of MAX instructions.
841 set f [open $src "w"]
842 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
845 verbose "check_alpha_max_hw_available compiling testfile $src" 2
846 set lines [${tool}_target_compile $src $exe executable ""]
849 if [string match "" $lines] then {
850 # No error message, compilation succeeded.
851 set result [${tool}_load "./$exe" "" ""]
852 set status [lindex $result 0]
853 remote_file build delete $exe
854 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
856 if { $status == "pass" } then {
857 set alpha_max_hw_available_saved 1
860 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
864 return $alpha_max_hw_available_saved
867 # Returns true iff the FUNCTION is available on the target system.
868 # (This is essentially a Tcl implementation of Autoconf's
871 proc check_function_available { function } {
872 set var "${function}_available_saved"
876 if {![info exists $var]} {
879 # Check to make sure.
880 set src "function[pid].c"
881 set exe "function[pid].exe"
883 set f [open $src "w"]
884 puts $f "int main () { $function (); }"
887 set lines [${tool}_target_compile $src $exe executable ""]
891 if {![string match "" $lines]} then {
893 verbose -log "$function is not available"
895 verbose -log "$function is available"
902 # Returns true iff "fork" is available on the target system.
904 proc check_fork_available {} {
905 return [check_function_available "fork"]
908 # Returns true iff "mkfifo" is available on the target system.
910 proc check_mkfifo_available {} {
911 if {[istarget *-*-cygwin*]} {
912 # Cygwin has mkfifo, but support is incomplete.
916 return [check_function_available "mkfifo"]
919 # Returns true iff "__cxa_atexit" is used on the target system.
921 proc check_cxa_atexit_available { } {
923 global et_cxa_atexit_target_name
926 if { ![info exists et_cxa_atexit_target_name] } {
927 set et_cxa_atexit_target_name ""
930 # If the target has changed since we set the cached value, clear it.
931 set current_target [current_target_name]
932 if { $current_target != $et_cxa_atexit_target_name } {
933 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
934 set et_cxa_atexit_target_name $current_target
935 if [info exists et_cxa_atexit] {
936 verbose "check_cxa_atexit_available: removing cached result" 2
941 if [info exists et_cxa_atexit] {
942 verbose "check_cxa_atexit_available: using cached result" 2
946 # Set up, compile, and execute a C++ test program that depends
947 # on correct ordering of static object destructors. This is
948 # indicative of the presence and use of __cxa_atexit.
949 set src cxaatexit[pid].cc
950 set exe cxaatexit[pid].x
952 set f [open $src "w"]
953 puts $f "#include <stdlib.h>"
954 puts $f "static unsigned int count;"
957 puts $f " X() { count = 1; }"
960 puts $f " if (count != 3)"
962 puts $f " count = 4;"
967 puts $f " static X x;"
971 puts $f " Y() { f(); count = 2; }"
974 puts $f " if (count != 2)"
976 puts $f " count = 3;"
981 puts $f "{ return 0; }"
984 set lines [${tool}_target_compile $src $exe executable ""]
987 if [string match "" $lines] {
988 # No error message, compilation succeeded.
989 set result [${tool}_load "./$exe" "" ""]
990 set status [lindex $result 0]
991 remote_file build delete $exe
993 verbose "check_cxa_atexit_available: status is <$status>" 2
995 if { $status == "pass" } {
999 verbose "check_cxa_atexit_available: compilation failed" 2
1002 return $et_cxa_atexit
1006 # Return 1 if we're generating 32-bit code using default options, 0
1009 proc check_effective_target_ilp32 { } {
1010 return [check_no_compiler_messages ilp32 object {
1011 int dummy[sizeof (int) == 4
1012 && sizeof (void *) == 4
1013 && sizeof (long) == 4 ? 1 : -1];
1017 # Return 1 if we're generating 32-bit or larger integers using default
1018 # options, 0 otherwise.
1020 proc check_effective_target_int32plus { } {
1021 return [check_no_compiler_messages int32plus object {
1022 int dummy[sizeof (int) >= 4 ? 1 : -1];
1026 # Return 1 if we're generating 32-bit or larger pointers using default
1027 # options, 0 otherwise.
1029 proc check_effective_target_ptr32plus { } {
1030 return [check_no_compiler_messages ptr32plus object {
1031 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1035 # Return 1 if we support 32-bit or larger array and structure sizes
1036 # using default options, 0 otherwise.
1038 proc check_effective_target_size32plus { } {
1039 return [check_no_compiler_messages size32plus object {
1044 # Returns 1 if we're generating 16-bit or smaller integers with the
1045 # default options, 0 otherwise.
1047 proc check_effective_target_int16 { } {
1048 return [check_no_compiler_messages int16 object {
1049 int dummy[sizeof (int) < 4 ? 1 : -1];
1053 # Return 1 if we're generating 64-bit code using default options, 0
1056 proc check_effective_target_lp64 { } {
1057 return [check_no_compiler_messages lp64 object {
1058 int dummy[sizeof (int) == 4
1059 && sizeof (void *) == 8
1060 && sizeof (long) == 8 ? 1 : -1];
1064 # Return 1 if the target supports compiling decimal floating point,
1067 proc check_effective_target_dfp_nocache { } {
1068 verbose "check_effective_target_dfp_nocache: compiling source" 2
1069 set ret [string match "" [get_compiler_messages dfp object {
1070 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1072 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1076 proc check_effective_target_dfprt_nocache { } {
1081 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1082 # Set up, compile, and execute a test program containing decimal
1084 set src dfprt[pid].c
1085 set exe dfprt[pid].x
1087 set f [open $src "w"]
1088 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1089 puts $f "int main () { z = x + y; return 0; }"
1092 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1093 set lines [${tool}_target_compile $src $exe executable ""]
1096 if [string match "" $lines] then {
1097 # No error message, compilation succeeded.
1098 set result [${tool}_load "./$exe" "" ""]
1099 set status [lindex $result 0]
1100 remote_file build delete $exe
1101 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1102 if { $status == "pass" } then {
1107 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1110 # Return 1 if the target supports compiling Decimal Floating Point,
1113 # This won't change for different subtargets so cache the result.
1115 proc check_effective_target_dfp { } {
1118 if [info exists et_dfp_saved] {
1119 verbose "check_effective_target_dfp: using cached result" 2
1121 set et_dfp_saved [check_effective_target_dfp_nocache]
1123 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1124 return $et_dfp_saved
1127 # Return 1 if the target supports linking and executing Decimal Floating
1128 # Point, # 0 otherwise.
1130 # This won't change for different subtargets so cache the result.
1132 proc check_effective_target_dfprt { } {
1133 global et_dfprt_saved
1136 if [info exists et_dfprt_saved] {
1137 verbose "check_effective_target_dfprt: using cached result" 2
1139 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1141 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1142 return $et_dfprt_saved
1145 # Return 1 if the target needs a command line argument to enable a SIMD
1148 # This won't change for different subtargets so cache the result.
1150 proc check_effective_target_vect_cmdline_needed { } {
1151 global et_vect_cmdline_needed_saved
1153 if [info exists et_vect_cmdline_needed_saved] {
1154 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1156 set et_vect_cmdline_needed_saved 1
1157 if { [istarget ia64-*-*]
1158 || [istarget x86_64-*-*] } {
1159 set et_vect_cmdline_needed_saved 0
1163 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1164 return $et_vect_cmdline_needed_saved
1167 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1169 # This won't change for different subtargets so cache the result.
1171 proc check_effective_target_vect_int { } {
1172 global et_vect_int_saved
1174 if [info exists et_vect_int_saved] {
1175 verbose "check_effective_target_vect_int: using cached result" 2
1177 set et_vect_int_saved 0
1178 if { [istarget i?86-*-*]
1179 || [istarget powerpc*-*-*]
1180 || [istarget x86_64-*-*]
1181 || [istarget sparc*-*-*]
1182 || [istarget alpha*-*-*]
1183 || [istarget ia64-*-*] } {
1184 set et_vect_int_saved 1
1188 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1189 return $et_vect_int_saved
1192 # Return 1 is this is an arm target using 32-bit instructions
1193 proc check_effective_target_arm32 { } {
1194 global et_arm32_saved
1195 global et_arm32_target_name
1196 global compiler_flags
1198 if { ![info exists et_arm32_target_name] } {
1199 set et_arm32_target_name ""
1202 # If the target has changed since we set the cached value, clear it.
1203 set current_target [current_target_name]
1204 if { $current_target != $et_arm32_target_name } {
1205 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1206 set et_arm32_target_name $current_target
1207 if { [info exists et_arm32_saved] } {
1208 verbose "check_effective_target_arm32: removing cached result" 2
1209 unset et_arm32_saved
1213 if [info exists et_arm32_saved] {
1214 verbose "check-effective_target_arm32: using cached result" 2
1216 set et_arm32_saved 0
1217 if { [istarget arm-*-*]
1218 || [istarget strongarm*-*-*]
1219 || [istarget xscale-*-*] } {
1220 if ![string match "*-mthumb *" $compiler_flags] {
1221 set et_arm32_saved 1
1225 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1226 return $et_arm32_saved
1229 # Return 1 if this is a PowerPC target with floating-point registers.
1231 proc check_effective_target_powerpc_fprs { } {
1232 if { [istarget powerpc*-*-*]
1233 || [istarget rs6000-*-*] } {
1234 return [check_no_compiler_messages powerpc_fprs object {
1246 # Return 1 if this is a PowerPC target supporting -maltivec.
1248 proc check_effective_target_powerpc_altivec_ok { } {
1249 if { [istarget powerpc*-*-*]
1250 || [istarget rs6000-*-*] } {
1251 # AltiVec is not supported on Aix.
1252 if { [istarget powerpc*-*-aix*] } {
1255 return [check_no_compiler_messages powerpc_altivec_ok object {
1263 # Return 1 if the target supports hardware vector shift operation.
1265 proc check_effective_target_vect_shift { } {
1266 global et_vect_shift_saved
1268 if [info exists et_vect_shift_saved] {
1269 verbose "check_effective_target_vect_shift: using cached result" 2
1271 set et_vect_shift_saved 0
1272 if { [istarget powerpc*-*-*]
1273 || [istarget ia64-*-*]
1274 || [istarget i?86-*-*]
1275 || [istarget x86_64-*-*] } {
1276 set et_vect_shift_saved 1
1280 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1281 return $et_vect_shift_saved
1284 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1286 # This can change for different subtargets so do not cache the result.
1288 proc check_effective_target_vect_long { } {
1289 if { [istarget i?86-*-*]
1290 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1291 || [istarget x86_64-*-*]
1292 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1298 verbose "check_effective_target_vect_long: returning $answer" 2
1302 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1304 # This won't change for different subtargets so cache the result.
1306 proc check_effective_target_vect_float { } {
1307 global et_vect_float_saved
1309 if [info exists et_vect_float_saved] {
1310 verbose "check_effective_target_vect_float: using cached result" 2
1312 set et_vect_float_saved 0
1313 if { [istarget i?86-*-*]
1314 || [istarget powerpc*-*-*]
1315 || [istarget mipsisa64*-*-*]
1316 || [istarget x86_64-*-*]
1317 || [istarget ia64-*-*] } {
1318 set et_vect_float_saved 1
1322 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1323 return $et_vect_float_saved
1326 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1328 # This won't change for different subtargets so cache the result.
1330 proc check_effective_target_vect_double { } {
1331 global et_vect_double_saved
1333 if [info exists et_vect_double_saved] {
1334 verbose "check_effective_target_vect_double: using cached result" 2
1336 set et_vect_double_saved 0
1337 if { [istarget i?86-*-*]
1338 || [istarget x86_64-*-*] } {
1339 set et_vect_double_saved 1
1343 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1344 return $et_vect_double_saved
1347 # Return 1 if the target plus current options does not support a vector
1348 # max instruction on "int", 0 otherwise.
1350 # This won't change for different subtargets so cache the result.
1352 proc check_effective_target_vect_no_int_max { } {
1353 global et_vect_no_int_max_saved
1355 if [info exists et_vect_no_int_max_saved] {
1356 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1358 set et_vect_no_int_max_saved 0
1359 if { [istarget sparc*-*-*]
1360 || [istarget alpha*-*-*] } {
1361 set et_vect_no_int_max_saved 1
1364 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1365 return $et_vect_no_int_max_saved
1368 # Return 1 if the target plus current options does not support a vector
1369 # add instruction on "int", 0 otherwise.
1371 # This won't change for different subtargets so cache the result.
1373 proc check_effective_target_vect_no_int_add { } {
1374 global et_vect_no_int_add_saved
1376 if [info exists et_vect_no_int_add_saved] {
1377 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1379 set et_vect_no_int_add_saved 0
1380 # Alpha only supports vector add on V8QI and V4HI.
1381 if { [istarget alpha*-*-*] } {
1382 set et_vect_no_int_add_saved 1
1385 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1386 return $et_vect_no_int_add_saved
1389 # Return 1 if the target plus current options does not support vector
1390 # bitwise instructions, 0 otherwise.
1392 # This won't change for different subtargets so cache the result.
1394 proc check_effective_target_vect_no_bitwise { } {
1395 global et_vect_no_bitwise_saved
1397 if [info exists et_vect_no_bitwise_saved] {
1398 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1400 set et_vect_no_bitwise_saved 0
1402 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1403 return $et_vect_no_bitwise_saved
1406 # Return 1 if the target plus current options supports a vector
1407 # widening summation of *short* args into *int* result, 0 otherwise.
1409 # This won't change for different subtargets so cache the result.
1411 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1412 global et_vect_widen_sum_hi_to_si
1414 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1415 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1417 set et_vect_widen_sum_hi_to_si_saved 0
1418 if { [istarget powerpc*-*-*]
1419 || [istarget ia64-*-*] } {
1420 set et_vect_widen_sum_hi_to_si_saved 1
1423 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1424 return $et_vect_widen_sum_hi_to_si_saved
1427 # Return 1 if the target plus current options supports a vector
1428 # widening summation of *char* args into *short* result, 0 otherwise.
1430 # This won't change for different subtargets so cache the result.
1432 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1433 global et_vect_widen_sum_qi_to_hi
1435 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1436 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1438 set et_vect_widen_sum_qi_to_hi_saved 0
1439 if { [istarget ia64-*-*] } {
1440 set et_vect_widen_sum_qi_to_hi_saved 1
1443 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1444 return $et_vect_widen_sum_qi_to_hi_saved
1447 # Return 1 if the target plus current options supports a vector
1448 # widening summation of *char* args into *int* result, 0 otherwise.
1450 # This won't change for different subtargets so cache the result.
1452 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1453 global et_vect_widen_sum_qi_to_si
1455 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1456 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1458 set et_vect_widen_sum_qi_to_si_saved 0
1459 if { [istarget powerpc*-*-*] } {
1460 set et_vect_widen_sum_qi_to_si_saved 1
1463 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1464 return $et_vect_widen_sum_qi_to_si_saved
1467 # Return 1 if the target plus current options supports a vector
1468 # widening summation, 0 otherwise.
1470 # This won't change for different subtargets so cache the result.
1472 proc check_effective_target_vect_widen_sum { } {
1473 global et_vect_widen_sum
1475 if [info exists et_vect_widen_sum_saved] {
1476 verbose "check_effective_target_vect_widen_sum: using cached result" 2
1478 set et_vect_widen_sum_saved 0
1479 if { [istarget powerpc*-*-*]
1480 || [istarget ia64-*-*] } {
1481 set et_vect_widen_sum_saved 1
1484 verbose "check_effective_target_vect_widen_sum: returning $et_vect_widen_sum_saved" 2
1485 return $et_vect_widen_sum_saved
1488 # Return 1 if the target plus current options supports a vector
1489 # dot-product of signed chars, 0 otherwise.
1491 # This won't change for different subtargets so cache the result.
1493 proc check_effective_target_vect_sdot_qi { } {
1494 global et_vect_sdot_qi
1496 if [info exists et_vect_sdot_qi_saved] {
1497 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1499 set et_vect_sdot_qi_saved 0
1500 if { [istarget ia64-*-*] } {
1501 set et_vect_sdot_qi_saved 1
1504 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1505 return $et_vect_sdot_qi_saved
1508 # Return 1 if the target plus current options supports a vector
1509 # dot-product of unsigned chars, 0 otherwise.
1511 # This won't change for different subtargets so cache the result.
1513 proc check_effective_target_vect_udot_qi { } {
1514 global et_vect_udot_qi
1516 if [info exists et_vect_udot_qi_saved] {
1517 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1519 set et_vect_udot_qi_saved 0
1520 if { [istarget powerpc*-*-*]
1521 || [istarget ia64-*-*] } {
1522 set et_vect_udot_qi_saved 1
1525 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1526 return $et_vect_udot_qi_saved
1529 # Return 1 if the target plus current options supports a vector
1530 # dot-product of signed shorts, 0 otherwise.
1532 # This won't change for different subtargets so cache the result.
1534 proc check_effective_target_vect_sdot_hi { } {
1535 global et_vect_sdot_hi
1537 if [info exists et_vect_sdot_hi_saved] {
1538 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1540 set et_vect_sdot_hi_saved 0
1541 if { [istarget powerpc*-*-*]
1542 || [istarget i?86-*-*]
1543 || [istarget x86_64-*-*]
1544 || [istarget ia64-*-*] } {
1545 set et_vect_sdot_hi_saved 1
1548 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1549 return $et_vect_sdot_hi_saved
1552 # Return 1 if the target plus current options supports a vector
1553 # dot-product of unsigned shorts, 0 otherwise.
1555 # This won't change for different subtargets so cache the result.
1557 proc check_effective_target_vect_udot_hi { } {
1558 global et_vect_udot_hi
1560 if [info exists et_vect_udot_hi_saved] {
1561 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1563 set et_vect_udot_hi_saved 0
1564 if { [istarget powerpc*-*-*] } {
1565 set et_vect_udot_hi_saved 1
1568 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1569 return $et_vect_udot_hi_saved
1573 # Return 1 if the target plus current options does not support a vector
1574 # alignment mechanism, 0 otherwise.
1576 # This won't change for different subtargets so cache the result.
1578 proc check_effective_target_vect_no_align { } {
1579 global et_vect_no_align_saved
1581 if [info exists et_vect_no_align_saved] {
1582 verbose "check_effective_target_vect_no_align: using cached result" 2
1584 set et_vect_no_align_saved 0
1585 if { [istarget mipsisa64*-*-*]
1586 || [istarget sparc*-*-*]
1587 || [istarget ia64-*-*] } {
1588 set et_vect_no_align_saved 1
1591 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1592 return $et_vect_no_align_saved
1595 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1597 proc check_effective_target_vect_condition { } {
1598 global et_vect_cond_saved
1600 if [info exists et_vect_cond_saved] {
1601 verbose "check_effective_target_vect_cond: using cached result" 2
1603 set et_vect_cond_saved 0
1604 if { [istarget powerpc*-*-*]
1605 || [istarget ia64-*-*]
1606 || [istarget i?86-*-*]
1607 || [istarget x86_64-*-*] } {
1608 set et_vect_cond_saved 1
1612 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1613 return $et_vect_cond_saved
1616 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1618 proc check_effective_target_vect_char_mult { } {
1619 global et_vect_char_mult_saved
1621 if [info exists et_vect_char_mult_saved] {
1622 verbose "check_effective_target_vect_char_mult: using cached result" 2
1624 set et_vect_char_mult_saved 0
1625 if { [istarget ia64-*-*]
1626 || [istarget i?86-*-*]
1627 || [istarget x86_64-*-*] } {
1628 set et_vect_char_mult_saved 1
1632 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1633 return $et_vect_char_mult_saved
1636 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1638 proc check_effective_target_vect_short_mult { } {
1639 global et_vect_short_mult_saved
1641 if [info exists et_vect_short_mult_saved] {
1642 verbose "check_effective_target_vect_short_mult: using cached result" 2
1644 set et_vect_short_mult_saved 0
1645 if { [istarget ia64-*-*]
1646 || [istarget i?86-*-*]
1647 || [istarget x86_64-*-*] } {
1648 set et_vect_short_mult_saved 1
1652 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1653 return $et_vect_short_mult_saved
1656 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1658 proc check_effective_target_vect_int_mult { } {
1659 global et_vect_int_mult_saved
1661 if [info exists et_vect_int_mult_saved] {
1662 verbose "check_effective_target_vect_int_mult: using cached result" 2
1664 set et_vect_int_mult_saved 0
1665 if { [istarget powerpc*-*-*]
1666 || [istarget i?86-*-*]
1667 || [istarget x86_64-*-*] } {
1668 set et_vect_int_mult_saved 1
1672 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1673 return $et_vect_int_mult_saved
1676 # Return 1 if the target supports atomic operations on "int" and "long".
1678 proc check_effective_target_sync_int_long { } {
1679 global et_sync_int_long_saved
1681 if [info exists et_sync_int_long_saved] {
1682 verbose "check_effective_target_sync_int_long: using cached result" 2
1684 set et_sync_int_long_saved 0
1685 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1686 # load-reserved/store-conditional instructions.
1687 if { [istarget ia64-*-*]
1688 || [istarget i?86-*-*]
1689 || [istarget x86_64-*-*]
1690 || [istarget alpha*-*-*]
1691 || [istarget s390*-*-*]
1692 || [istarget powerpc*-*-*]
1693 || [istarget sparc64-*-*]
1694 || [istarget sparcv9-*-*] } {
1695 set et_sync_int_long_saved 1
1699 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1700 return $et_sync_int_long_saved
1703 # Return 1 if the target supports atomic operations on "char" and "short".
1705 proc check_effective_target_sync_char_short { } {
1706 global et_sync_char_short_saved
1708 if [info exists et_sync_char_short_saved] {
1709 verbose "check_effective_target_sync_char_short: using cached result" 2
1711 set et_sync_char_short_saved 0
1712 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1713 # load-reserved/store-conditional instructions.
1714 if { [istarget ia64-*-*]
1715 || [istarget i?86-*-*]
1716 || [istarget x86_64-*-*]
1717 || [istarget alpha*-*-*]
1718 || [istarget s390*-*-*]
1719 || [istarget powerpc*-*-*]
1720 || [istarget sparc64-*-*]
1721 || [istarget sparcv9-*-*] } {
1722 set et_sync_char_short_saved 1
1726 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1727 return $et_sync_char_short_saved
1730 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1731 # This can be used with any check_* proc that takes no argument and
1732 # returns only 1 or 0. It could be used with check_* procs that take
1733 # arguments with keywords that pass particular arguments.
1735 proc is-effective-target { arg } {
1737 if { [info procs check_effective_target_${arg}] != [list] } {
1738 set selected [check_effective_target_${arg}]
1741 "vmx_hw" { set selected [check_vmx_hw_available] }
1742 "named_sections" { set selected [check_named_sections_available] }
1743 "gc_sections" { set selected [check_gc_sections_available] }
1744 default { error "unknown effective target keyword `$arg'" }
1747 verbose "is-effective-target: $arg $selected" 2
1751 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1753 proc is-effective-target-keyword { arg } {
1754 if { [info procs check_effective_target_${arg}] != [list] } {
1757 # These have different names for their check_* procs.
1759 "vmx_hw" { return 1 }
1760 "named_sections" { return 1 }
1761 "gc_sections" { return 1 }
1762 default { return 0 }
1767 # Return 1 if target default to short enums
1769 proc check_effective_target_short_enums { } {
1770 return [check_no_compiler_messages short_enums assembly {
1772 int s[sizeof (enum foo) == 1 ? 1 : -1];