1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008
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 3 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 GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
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 the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code. C++ code should contain
33 # "// C++" and Fortran code should contain "! Fortran".
34 proc check_compile {basename type contents args} {
37 if { [llength $args] > 0 } {
38 set options [list "additional_flags=[lindex $args 0]"]
42 switch -glob -- $contents {
43 "*! Fortran*" { set src ${basename}[pid].f90 }
44 "*// C++*" { set src ${basename}[pid].cc }
45 default { set src ${basename}[pid].c }
47 set compile_type $type
49 assembly { set output ${basename}[pid].s }
50 object { set output ${basename}[pid].o }
51 executable { set output ${basename}[pid].exe }
53 set output ${basename}[pid].s
54 lappend options "additional_flags=-fdump-$type"
55 set compile_type assembly
61 set lines [${tool}_target_compile $src $output $compile_type "$options"]
64 set scan_output $output
65 # Don't try folding this into the switch above; calling "glob" before the
66 # file is created won't work.
67 if [regexp "rtl-(.*)" $type dummy rtl_type] {
68 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
72 return [list $lines $scan_output]
75 proc current_target_name { } {
77 if [info exists target_info(target,name)] {
78 set answer $target_info(target,name)
85 # Implement an effective-target check for property PROP by invoking
86 # the Tcl command ARGS and seeing if it returns true.
88 proc check_cached_effective_target { prop args } {
91 set target [current_target_name]
92 if {![info exists et_cache($prop,target)]
93 || $et_cache($prop,target) != $target} {
94 verbose "check_cached_effective_target $prop: checking $target" 2
95 set et_cache($prop,target) $target
96 set et_cache($prop,value) [uplevel eval $args]
98 set value $et_cache($prop,value)
99 verbose "check_cached_effective_target $prop: returning $value for $target" 2
103 # Like check_compile, but delete the output file and return true if the
104 # compiler printed no messages.
105 proc check_no_compiler_messages_nocache {args} {
106 set result [eval check_compile $args]
107 set lines [lindex $result 0]
108 set output [lindex $result 1]
109 remote_file build delete $output
110 return [string match "" $lines]
113 # Like check_no_compiler_messages_nocache, but cache the result.
114 # PROP is the property we're checking, and doubles as a prefix for
115 # temporary filenames.
116 proc check_no_compiler_messages {prop args} {
117 return [check_cached_effective_target $prop {
118 eval [list check_no_compiler_messages_nocache $prop] $args
122 # Like check_compile, but return true if the compiler printed no
123 # messages and if the contents of the output file satisfy PATTERN.
124 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
125 # don't match regular expression REGEXP, otherwise they satisfy it
126 # if they do match regular expression PATTERN. (PATTERN can start
127 # with something like "[!]" if the regular expression needs to match
128 # "!" as the first character.)
130 # Delete the output file before returning. The other arguments are
131 # as for check_compile.
132 proc check_no_messages_and_pattern_nocache {basename pattern args} {
135 set result [eval [list check_compile $basename] $args]
136 set lines [lindex $result 0]
137 set output [lindex $result 1]
140 if { [string match "" $lines] } {
141 set chan [open "$output"]
142 set invert [regexp {^!(.*)} $pattern dummy pattern]
143 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
147 remote_file build delete $output
151 # Like check_no_messages_and_pattern_nocache, but cache the result.
152 # PROP is the property we're checking, and doubles as a prefix for
153 # temporary filenames.
154 proc check_no_messages_and_pattern {prop pattern args} {
155 return [check_cached_effective_target $prop {
156 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
160 # Try to compile and run an executable from code CONTENTS. Return true
161 # if the compiler reports no messages and if execution "passes" in the
162 # usual DejaGNU sense. The arguments are as for check_compile, with
163 # TYPE implicitly being "executable".
164 proc check_runtime_nocache {basename contents args} {
167 set result [eval [list check_compile $basename executable $contents] $args]
168 set lines [lindex $result 0]
169 set output [lindex $result 1]
172 if { [string match "" $lines] } {
173 # No error messages, everything is OK.
174 set result [remote_load target "./$output" "" ""]
175 set status [lindex $result 0]
176 verbose "check_runtime_nocache $basename: status is <$status>" 2
177 if { $status == "pass" } {
181 remote_file build delete $output
185 # Like check_runtime_nocache, but cache the result. PROP is the
186 # property we're checking, and doubles as a prefix for temporary
188 proc check_runtime {prop args} {
191 return [check_cached_effective_target $prop {
192 eval [list check_runtime_nocache $prop] $args
196 ###############################
197 # proc check_weak_available { }
198 ###############################
200 # weak symbols are only supported in some configs/object formats
201 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
203 proc check_weak_available { } {
204 global target_triplet
207 # All mips targets should support it
209 if { [ string first "mips" $target_cpu ] >= 0 } {
213 # All solaris2 targets should support it
215 if { [regexp ".*-solaris2.*" $target_triplet] } {
219 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
221 if { [regexp "alpha.*osf.*" $target_triplet] } {
225 # Windows targets Cygwin and MingW32 support it
227 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
231 # HP-UX 10.X doesn't support it
233 if { [istarget "hppa*-*-hpux10*"] } {
237 # ELF and ECOFF support it. a.out does with gas/gld but may also with
238 # other linkers, so we should try it
240 set objformat [gcc_target_object_format]
248 unknown { return -1 }
253 ###############################
254 # proc check_visibility_available { what_kind }
255 ###############################
257 # The visibility attribute is only support in some object formats
258 # This proc returns 1 if it is supported, 0 if not.
259 # The argument is the kind of visibility, default/protected/hidden/internal.
261 proc check_visibility_available { what_kind } {
263 global target_triplet
265 # On NetWare, support makes no sense.
266 if { [istarget *-*-netware*] } {
270 if [string match "" $what_kind] { set what_kind "hidden" }
272 return [check_no_compiler_messages visibility_available_$what_kind object "
273 void f() __attribute__((visibility(\"$what_kind\")));
278 ###############################
279 # proc check_alias_available { }
280 ###############################
282 # Determine if the target toolchain supports the alias attribute.
284 # Returns 2 if the target supports aliases. Returns 1 if the target
285 # only supports weak aliased. Returns 0 if the target does not
286 # support aliases at all. Returns -1 if support for aliases could not
289 proc check_alias_available { } {
290 global alias_available_saved
293 if [info exists alias_available_saved] {
294 verbose "check_alias_available returning saved $alias_available_saved" 2
298 verbose "check_alias_available compiling testfile $src" 2
299 set f [open $src "w"]
300 # Compile a small test program. The definition of "g" is
301 # necessary to keep the Solaris assembler from complaining
303 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
304 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
306 set lines [${tool}_target_compile $src $obj object ""]
308 remote_file build delete $obj
310 if [string match "" $lines] then {
311 # No error messages, everything is OK.
312 set alias_available_saved 2
314 if [regexp "alias definitions not supported" $lines] {
315 verbose "check_alias_available target does not support aliases" 2
317 set objformat [gcc_target_object_format]
319 if { $objformat == "elf" } {
320 verbose "check_alias_available but target uses ELF format, so it ought to" 2
321 set alias_available_saved -1
323 set alias_available_saved 0
326 if [regexp "only weak aliases are supported" $lines] {
327 verbose "check_alias_available target supports only weak aliases" 2
328 set alias_available_saved 1
330 set alias_available_saved -1
335 verbose "check_alias_available returning $alias_available_saved" 2
338 return $alias_available_saved
341 # Returns true if --gc-sections is supported on the target.
343 proc check_gc_sections_available { } {
344 global gc_sections_available_saved
347 if {![info exists gc_sections_available_saved]} {
348 # Some targets don't support gc-sections despite whatever's
349 # advertised by ld's options.
350 if { [istarget alpha*-*-*]
351 || [istarget ia64-*-*] } {
352 set gc_sections_available_saved 0
356 # elf2flt uses -q (--emit-relocs), which is incompatible with
358 if { [board_info target exists ldflags]
359 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
360 set gc_sections_available_saved 0
364 # VxWorks kernel modules are relocatable objects linked with -r,
365 # while RTP executables are linked with -q (--emit-relocs).
366 # Both of these options are incompatible with --gc-sections.
367 if { [istarget *-*-vxworks*] } {
368 set gc_sections_available_saved 0
372 # Check if the ld used by gcc supports --gc-sections.
373 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
374 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
375 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
376 set ld_output [remote_exec host "$gcc_ld" "--help"]
377 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
378 set gc_sections_available_saved 1
380 set gc_sections_available_saved 0
383 return $gc_sections_available_saved
386 # Return 1 if according to target_info struct and explicit target list
387 # target is supposed to support trampolines.
389 proc check_effective_target_trampolines { } {
390 if [target_info exists no_trampolines] {
393 if { [istarget avr-*-*]
394 || [istarget hppa2.0w-hp-hpux11.23]
395 || [istarget hppa64-hp-hpux11.23] } {
401 # Return 1 if according to target_info struct and explicit target list
402 # target is supposed to keep null pointer checks. This could be due to
403 # use of option fno-delete-null-pointer-checks or hardwired in target.
405 proc check_effective_target_keeps_null_pointer_checks { } {
406 if [target_info exists keeps_null_pointer_checks] {
409 if { [istarget avr-*-*] } {
415 # Return true if profiling is supported on the target.
417 proc check_profiling_available { test_what } {
418 global profiling_available_saved
420 verbose "Profiling argument is <$test_what>" 1
422 # These conditions depend on the argument so examine them before
423 # looking at the cache variable.
425 # Support for -p on solaris2 relies on mcrt1.o which comes with the
426 # vendor compiler. We cannot reliably predict the directory where the
427 # vendor compiler (and thus mcrt1.o) is installed so we can't
428 # necessarily find mcrt1.o even if we have it.
429 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
433 # Support for -p on irix relies on libprof1.a which doesn't appear to
434 # exist on any irix6 system currently posting testsuite results.
435 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
436 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
437 if { [istarget mips*-*-irix*]
438 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
442 # We don't yet support profiling for MIPS16.
443 if { [istarget mips*-*-*]
444 && ![check_effective_target_nomips16]
445 && ([lindex $test_what 1] == "-p"
446 || [lindex $test_what 1] == "-pg") } {
450 # MinGW does not support -p.
451 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
455 # At present, there is no profiling support on NetWare.
456 if { [istarget *-*-netware*] } {
460 # uClibc does not have gcrt1.o.
461 if { [check_effective_target_uclibc]
462 && ([lindex $test_what 1] == "-p"
463 || [lindex $test_what 1] == "-pg") } {
467 # Now examine the cache variable.
468 if {![info exists profiling_available_saved]} {
469 # Some targets don't have any implementation of __bb_init_func or are
470 # missing other needed machinery.
471 if { [istarget mmix-*-*]
472 || [istarget arm*-*-eabi*]
473 || [istarget arm*-*-elf]
474 || [istarget arm*-*-symbianelf*]
475 || [istarget avr-*-*]
476 || [istarget bfin-*-*]
477 || [istarget powerpc-*-eabi*]
478 || [istarget cris-*-*]
479 || [istarget crisv32-*-*]
480 || [istarget fido-*-elf]
481 || [istarget h8300-*-*]
482 || [istarget m32c-*-elf]
483 || [istarget m68k-*-elf]
484 || [istarget m68k-*-uclinux*]
485 || [istarget mips*-*-elf*]
486 || [istarget xstormy16-*]
487 || [istarget xtensa*-*-elf]
488 || [istarget *-*-rtems*]
489 || [istarget *-*-vxworks*] } {
490 set profiling_available_saved 0
492 set profiling_available_saved 1
496 return $profiling_available_saved
499 # Return 1 if target has packed layout of structure members by
500 # default, 0 otherwise. Note that this is slightly different than
501 # whether the target has "natural alignment": both attributes may be
504 proc check_effective_target_default_packed { } {
505 return [check_no_compiler_messages default_packed assembly {
506 struct x { char a; long b; } c;
507 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
511 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
512 # documentation, where the test also comes from.
514 proc check_effective_target_pcc_bitfield_type_matters { } {
515 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
516 # bitfields, but let's stick to the example code from the docs.
517 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
518 struct foo1 { char x; char :0; char y; };
519 struct foo2 { char x; int :0; char y; };
520 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
524 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
526 # This won't change for different subtargets so cache the result.
528 proc check_effective_target_tls {} {
529 return [check_no_compiler_messages tls assembly {
531 int f (void) { return i; }
532 void g (int j) { i = j; }
536 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
538 # This won't change for different subtargets so cache the result.
540 proc check_effective_target_tls_native {} {
541 # VxWorks uses emulated TLS machinery, but with non-standard helper
542 # functions, so we fail to automatically detect it.
543 global target_triplet
544 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
548 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
550 int f (void) { return i; }
551 void g (int j) { i = j; }
555 # Return 1 if TLS executables can run correctly, 0 otherwise.
557 # This won't change for different subtargets so cache the result.
559 proc check_effective_target_tls_runtime {} {
560 return [check_runtime tls_runtime {
561 __thread int thr = 0;
562 int main (void) { return thr; }
566 # Return 1 if compilation with -fgraphite is error-free for trivial
569 proc check_effective_target_fgraphite {} {
570 return [check_no_compiler_messages fgraphite object {
575 # Return 1 if compilation with -fopenmp is error-free for trivial
578 proc check_effective_target_fopenmp {} {
579 return [check_no_compiler_messages fopenmp object {
584 # Return 1 if compilation with -pthread is error-free for trivial
587 proc check_effective_target_pthread {} {
588 return [check_no_compiler_messages pthread object {
593 # Return 1 if the target supports -fstack-protector
594 proc check_effective_target_fstack_protector {} {
595 return [check_runtime fstack_protector {
596 int main (void) { return 0; }
597 } "-fstack-protector"]
600 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
601 # for trivial code, 0 otherwise.
603 proc check_effective_target_freorder {} {
604 return [check_no_compiler_messages freorder object {
606 } "-freorder-blocks-and-partition"]
609 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
610 # emitted, 0 otherwise. Whether a shared library can actually be built is
611 # out of scope for this test.
613 proc check_effective_target_fpic { } {
614 # Note that M68K has a multilib that supports -fpic but not
615 # -fPIC, so we need to check both. We test with a program that
616 # requires GOT references.
617 foreach arg {fpic fPIC} {
618 if [check_no_compiler_messages $arg object {
619 extern int foo (void); extern int bar;
620 int baz (void) { return foo () + bar; }
628 # Return true if the target supports -mpaired-single (as used on MIPS).
630 proc check_effective_target_mpaired_single { } {
631 return [check_no_compiler_messages mpaired_single object {
636 # Return true if the target has access to FPU instructions.
638 proc check_effective_target_hard_float { } {
639 if { [istarget mips*-*-*] } {
640 return [check_no_compiler_messages hard_float assembly {
641 #if (defined __mips_soft_float || defined __mips16)
647 # The generic test equates hard_float with "no call for adding doubles".
648 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
649 double a (double b, double c) { return b + c; }
653 # Return true if the target is a 64-bit MIPS target.
655 proc check_effective_target_mips64 { } {
656 return [check_no_compiler_messages mips64 assembly {
663 # Return true if the target is a MIPS target that does not produce
666 proc check_effective_target_nomips16 { } {
667 return [check_no_compiler_messages nomips16 object {
671 /* A cheap way of testing for -mflip-mips16. */
672 void foo (void) { asm ("addiu $20,$20,1"); }
673 void bar (void) { asm ("addiu $20,$20,1"); }
678 # Add the options needed for MIPS16 function attributes. At the moment,
679 # we don't support MIPS16 PIC.
681 proc add_options_for_mips16_attribute { flags } {
682 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
685 # Return true if we can force a mode that allows MIPS16 code generation.
686 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
689 proc check_effective_target_mips16_attribute { } {
690 return [check_no_compiler_messages mips16_attribute assembly {
694 #if defined __mips_hard_float \
695 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
696 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
699 } [add_options_for_mips16_attribute ""]]
702 # Return 1 if the current multilib does not generate PIC by default.
704 proc check_effective_target_nonpic { } {
705 return [check_no_compiler_messages nonpic assembly {
712 # Return 1 if the target does not use a status wrapper.
714 proc check_effective_target_unwrapped { } {
715 if { [target_info needs_status_wrapper] != "" \
716 && [target_info needs_status_wrapper] != "0" } {
722 # Return true if iconv is supported on the target. In particular IBM1047.
724 proc check_iconv_available { test_what } {
727 # If the tool configuration file has not set libiconv, try "-liconv"
728 if { ![info exists libiconv] } {
729 set libiconv "-liconv"
731 set test_what [lindex $test_what 1]
732 return [check_runtime_nocache $test_what [subst {
738 cd = iconv_open ("$test_what", "UTF-8");
739 if (cd == (iconv_t) -1)
746 # Return true if named sections are supported on this target.
748 proc check_named_sections_available { } {
749 return [check_no_compiler_messages named_sections assembly {
750 int __attribute__ ((section("whatever"))) foo;
754 # Return 1 if the target supports Fortran real kinds larger than real(8),
757 # When the target name changes, replace the cached result.
759 proc check_effective_target_fortran_large_real { } {
760 return [check_no_compiler_messages fortran_large_real executable {
762 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
769 # Return 1 if the target supports Fortran integer kinds larger than
770 # integer(8), 0 otherwise.
772 # When the target name changes, replace the cached result.
774 proc check_effective_target_fortran_large_int { } {
775 return [check_no_compiler_messages fortran_large_int executable {
777 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
783 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
785 # When the target name changes, replace the cached result.
787 proc check_effective_target_fortran_integer_16 { } {
788 return [check_no_compiler_messages fortran_integer_16 executable {
795 # Return 1 if we can statically link libgfortran, 0 otherwise.
797 # When the target name changes, replace the cached result.
799 proc check_effective_target_static_libgfortran { } {
800 return [check_no_compiler_messages static_libgfortran executable {
807 # Return 1 if the target supports executing 750CL paired-single instructions, 0
808 # otherwise. Cache the result.
810 proc check_750cl_hw_available { } {
811 return [check_cached_effective_target 750cl_hw_available {
812 # If this is not the right target then we can skip the test.
813 if { ![istarget powerpc-*paired*] } {
816 check_runtime_nocache 750cl_hw_available {
820 asm volatile ("ps_mul v0,v0,v0");
822 asm volatile ("ps_mul 0,0,0");
831 # Return 1 if the target supports executing SSE2 instructions, 0
832 # otherwise. Cache the result.
834 proc check_sse2_hw_available { } {
835 return [check_cached_effective_target sse2_hw_available {
836 # If this is not the right target then we can skip the test.
837 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
840 check_runtime_nocache sse2_hw_available {
844 unsigned int eax, ebx, ecx, edx = 0;
845 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
846 return !(edx & bit_SSE2);
854 # Return 1 if the target supports executing AltiVec instructions, 0
855 # otherwise. Cache the result.
857 proc check_vmx_hw_available { } {
858 return [check_cached_effective_target vmx_hw_available {
859 # Some simulators are known to not support VMX instructions.
860 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
863 # Most targets don't require special flags for this test case, but
865 if { [istarget *-*-darwin*]
866 || [istarget *-*-aix*] } {
867 set options "-maltivec"
871 check_runtime_nocache vmx_hw_available {
875 asm volatile ("vor v0,v0,v0");
877 asm volatile ("vor 0,0,0");
886 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
887 # complex float arguments. This affects gfortran tests that call cabsf
888 # in libm built by an earlier compiler. Return 1 if libm uses the same
889 # argument passing as the compiler under test, 0 otherwise.
891 # When the target name changes, replace the cached result.
893 proc check_effective_target_broken_cplxf_arg { } {
894 return [check_cached_effective_target broken_cplxf_arg {
895 # Skip the work for targets known not to be affected.
896 if { ![istarget powerpc64-*-linux*] } {
898 } elseif { ![is-effective-target lp64] } {
901 check_runtime_nocache broken_cplxf_arg {
903 extern void abort (void);
905 float cabsf (_Complex float);
912 if (fabsf (f - 5.0) > 0.0001)
921 proc check_alpha_max_hw_available { } {
922 return [check_runtime alpha_max_hw_available {
923 int main() { return __builtin_alpha_amask(1<<8) != 0; }
927 # Returns true iff the FUNCTION is available on the target system.
928 # (This is essentially a Tcl implementation of Autoconf's
931 proc check_function_available { function } {
932 return [check_no_compiler_messages ${function}_available \
938 int main () { $function (); }
942 # Returns true iff "fork" is available on the target system.
944 proc check_fork_available {} {
945 return [check_function_available "fork"]
948 # Returns true iff "mkfifo" is available on the target system.
950 proc check_mkfifo_available {} {
951 if {[istarget *-*-cygwin*]} {
952 # Cygwin has mkfifo, but support is incomplete.
956 return [check_function_available "mkfifo"]
959 # Returns true iff "__cxa_atexit" is used on the target system.
961 proc check_cxa_atexit_available { } {
962 return [check_cached_effective_target cxa_atexit_available {
963 if { [istarget "hppa*-*-hpux10*"] } {
964 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
967 check_runtime_nocache cxa_atexit_available {
970 static unsigned int count;
987 Y() { f(); count = 2; }
996 int main() { return 0; }
1003 # Return 1 if we're generating 32-bit code using default options, 0
1006 proc check_effective_target_ilp32 { } {
1007 return [check_no_compiler_messages ilp32 object {
1008 int dummy[sizeof (int) == 4
1009 && sizeof (void *) == 4
1010 && sizeof (long) == 4 ? 1 : -1];
1014 # Return 1 if we're generating 32-bit or larger integers using default
1015 # options, 0 otherwise.
1017 proc check_effective_target_int32plus { } {
1018 return [check_no_compiler_messages int32plus object {
1019 int dummy[sizeof (int) >= 4 ? 1 : -1];
1023 # Return 1 if we're generating 32-bit or larger pointers using default
1024 # options, 0 otherwise.
1026 proc check_effective_target_ptr32plus { } {
1027 return [check_no_compiler_messages ptr32plus object {
1028 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1032 # Return 1 if we support 32-bit or larger array and structure sizes
1033 # using default options, 0 otherwise.
1035 proc check_effective_target_size32plus { } {
1036 return [check_no_compiler_messages size32plus object {
1041 # Returns 1 if we're generating 16-bit or smaller integers with the
1042 # default options, 0 otherwise.
1044 proc check_effective_target_int16 { } {
1045 return [check_no_compiler_messages int16 object {
1046 int dummy[sizeof (int) < 4 ? 1 : -1];
1050 # Return 1 if we're generating 64-bit code using default options, 0
1053 proc check_effective_target_lp64 { } {
1054 return [check_no_compiler_messages lp64 object {
1055 int dummy[sizeof (int) == 4
1056 && sizeof (void *) == 8
1057 && sizeof (long) == 8 ? 1 : -1];
1061 # Return 1 if we're generating 64-bit code using default llp64 options,
1064 proc check_effective_target_llp64 { } {
1065 return [check_no_compiler_messages llp64 object {
1066 int dummy[sizeof (int) == 4
1067 && sizeof (void *) == 8
1068 && sizeof (long long) == 8
1069 && sizeof (long) == 4 ? 1 : -1];
1073 # Return 1 if the target supports long double larger than double,
1076 proc check_effective_target_large_long_double { } {
1077 return [check_no_compiler_messages large_long_double object {
1078 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1082 # Return 1 if the target supports compiling fixed-point,
1085 proc check_effective_target_fixed_point { } {
1086 return [check_no_compiler_messages fixed_point object {
1087 _Sat _Fract x; _Sat _Accum y;
1091 # Return 1 if the target supports compiling decimal floating point,
1094 proc check_effective_target_dfp_nocache { } {
1095 verbose "check_effective_target_dfp_nocache: compiling source" 2
1096 set ret [check_no_compiler_messages_nocache dfp object {
1097 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1099 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1103 proc check_effective_target_dfprt_nocache { } {
1104 return [check_runtime_nocache dfprt {
1105 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1106 int main () { z = x + y; return 0; }
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 { } {
1116 return [check_cached_effective_target dfp {
1117 check_effective_target_dfp_nocache
1121 # Return 1 if the target supports linking and executing Decimal Floating
1122 # Point, # 0 otherwise.
1124 # This won't change for different subtargets so cache the result.
1126 proc check_effective_target_dfprt { } {
1127 return [check_cached_effective_target dfprt {
1128 check_effective_target_dfprt_nocache
1132 # Return 1 if the target needs a command line argument to enable a SIMD
1135 proc check_effective_target_vect_cmdline_needed { } {
1136 global et_vect_cmdline_needed_saved
1137 global et_vect_cmdline_needed_target_name
1139 if { ![info exists et_vect_cmdline_needed_target_name] } {
1140 set et_vect_cmdline_needed_target_name ""
1143 # If the target has changed since we set the cached value, clear it.
1144 set current_target [current_target_name]
1145 if { $current_target != $et_vect_cmdline_needed_target_name } {
1146 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1147 set et_vect_cmdline_needed_target_name $current_target
1148 if { [info exists et_vect_cmdline_needed_saved] } {
1149 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1150 unset et_vect_cmdline_needed_saved
1154 if [info exists et_vect_cmdline_needed_saved] {
1155 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1157 set et_vect_cmdline_needed_saved 1
1158 if { [istarget ia64-*-*]
1159 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1160 && [check_effective_target_lp64])
1161 || ([istarget powerpc*-*-*]
1162 && ([check_effective_target_powerpc_spe]
1163 || [check_effective_target_powerpc_altivec]))
1164 || [istarget spu-*-*]
1165 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1166 set et_vect_cmdline_needed_saved 0
1170 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1171 return $et_vect_cmdline_needed_saved
1174 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1176 # This won't change for different subtargets so cache the result.
1178 proc check_effective_target_vect_int { } {
1179 global et_vect_int_saved
1181 if [info exists et_vect_int_saved] {
1182 verbose "check_effective_target_vect_int: using cached result" 2
1184 set et_vect_int_saved 0
1185 if { [istarget i?86-*-*]
1186 || ([istarget powerpc*-*-*]
1187 && ![istarget powerpc-*-linux*paired*])
1188 || [istarget spu-*-*]
1189 || [istarget x86_64-*-*]
1190 || [istarget sparc*-*-*]
1191 || [istarget alpha*-*-*]
1192 || [istarget ia64-*-*]
1193 || [check_effective_target_arm32] } {
1194 set et_vect_int_saved 1
1198 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1199 return $et_vect_int_saved
1202 # Return 1 if the target supports int->float conversion
1205 proc check_effective_target_vect_intfloat_cvt { } {
1206 global et_vect_intfloat_cvt_saved
1208 if [info exists et_vect_intfloat_cvt_saved] {
1209 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1211 set et_vect_intfloat_cvt_saved 0
1212 if { [istarget i?86-*-*]
1213 || ([istarget powerpc*-*-*]
1214 && ![istarget powerpc-*-linux*paired*])
1215 || [istarget x86_64-*-*] } {
1216 set et_vect_intfloat_cvt_saved 1
1220 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1221 return $et_vect_intfloat_cvt_saved
1225 # Return 1 if the target supports float->int conversion
1228 proc check_effective_target_vect_floatint_cvt { } {
1229 global et_vect_floatint_cvt_saved
1231 if [info exists et_vect_floatint_cvt_saved] {
1232 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1234 set et_vect_floatint_cvt_saved 0
1235 if { [istarget i?86-*-*]
1236 || ([istarget powerpc*-*-*]
1237 && ![istarget powerpc-*-linux*paired*])
1238 || [istarget x86_64-*-*] } {
1239 set et_vect_floatint_cvt_saved 1
1243 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1244 return $et_vect_floatint_cvt_saved
1247 # Return 1 is this is an arm target using 32-bit instructions
1248 proc check_effective_target_arm32 { } {
1249 return [check_no_compiler_messages arm32 assembly {
1250 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1256 # Return 1 if this is an ARM target supporting -mfpu=vfp
1257 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1260 proc check_effective_target_arm_vfp_ok { } {
1261 if { [check_effective_target_arm32] } {
1262 return [check_no_compiler_messages arm_vfp_ok object {
1264 } "-mfpu=vfp -mfloat-abi=softfp"]
1270 # Return 1 if this is an ARM target supporting -mfpu=neon
1271 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1274 proc check_effective_target_arm_neon_ok { } {
1275 if { [check_effective_target_arm32] } {
1276 return [check_no_compiler_messages arm_neon_ok object {
1278 } "-mfpu=neon -mfloat-abi=softfp"]
1284 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1287 proc check_effective_target_arm_thumb1_ok { } {
1288 return [check_no_compiler_messages arm_thumb1_ok assembly {
1289 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1295 # Return 1 if the target supports executing NEON instructions, 0
1296 # otherwise. Cache the result.
1298 proc check_effective_target_arm_neon_hw { } {
1299 return [check_runtime arm_neon_hw_available {
1303 long long a = 0, b = 1;
1304 asm ("vorr %P0, %P1, %P2"
1306 : "0" (a), "w" (b));
1309 } "-mfpu=neon -mfloat-abi=softfp"]
1312 # Return 1 if this is a ARM target with NEON enabled.
1314 proc check_effective_target_arm_neon { } {
1315 if { [check_effective_target_arm32] } {
1316 return [check_no_compiler_messages arm_neon object {
1317 #ifndef __ARM_NEON__
1328 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1329 # the Loongson vector modes.
1331 proc check_effective_target_mips_loongson { } {
1332 return [check_no_compiler_messages loongson assembly {
1333 #if !defined(__mips_loongson_vector_rev)
1339 # Return 1 if this is a PowerPC target with floating-point registers.
1341 proc check_effective_target_powerpc_fprs { } {
1342 if { [istarget powerpc*-*-*]
1343 || [istarget rs6000-*-*] } {
1344 return [check_no_compiler_messages powerpc_fprs object {
1356 # Return 1 if this is a PowerPC target with hardware double-precision
1359 proc check_effective_target_powerpc_hard_double { } {
1360 if { [istarget powerpc*-*-*]
1361 || [istarget rs6000-*-*] } {
1362 return [check_no_compiler_messages powerpc_hard_double object {
1374 # Return 1 if this is a PowerPC target supporting -maltivec.
1376 proc check_effective_target_powerpc_altivec_ok { } {
1377 if { ([istarget powerpc*-*-*]
1378 && ![istarget powerpc-*-linux*paired*])
1379 || [istarget rs6000-*-*] } {
1380 # AltiVec is not supported on AIX before 5.3.
1381 if { [istarget powerpc*-*-aix4*]
1382 || [istarget powerpc*-*-aix5.1*]
1383 || [istarget powerpc*-*-aix5.2*] } {
1386 return [check_no_compiler_messages powerpc_altivec_ok object {
1394 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1396 proc check_effective_target_powerpc_ppu_ok { } {
1397 if [check_effective_target_powerpc_altivec_ok] {
1398 return [check_no_compiler_messages cell_asm_available object {
1401 asm volatile ("lvlx v0,v0,v0");
1403 asm volatile ("lvlx 0,0,0");
1413 # Return 1 if this is a PowerPC target that supports SPU.
1415 proc check_effective_target_powerpc_spu { } {
1416 if [istarget powerpc*-*-linux*] {
1417 return [check_effective_target_powerpc_altivec_ok]
1423 # Return 1 if this is a PowerPC target with SPE enabled.
1425 proc check_effective_target_powerpc_spe { } {
1426 if { [istarget powerpc*-*-*] } {
1427 return [check_no_compiler_messages powerpc_spe object {
1439 # Return 1 if this is a PowerPC target with Altivec enabled.
1441 proc check_effective_target_powerpc_altivec { } {
1442 if { [istarget powerpc*-*-*] } {
1443 return [check_no_compiler_messages powerpc_altivec object {
1455 # Return 1 if this is a SPU target with a toolchain that
1456 # supports automatic overlay generation.
1458 proc check_effective_target_spu_auto_overlay { } {
1459 if { [istarget spu*-*-elf*] } {
1460 return [check_no_compiler_messages spu_auto_overlay executable {
1462 } "-Wl,--auto-overlay" ]
1468 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1469 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1470 # test environment appears to run executables on such a simulator.
1472 proc check_effective_target_ultrasparc_hw { } {
1473 return [check_runtime ultrasparc_hw {
1474 int main() { return 0; }
1475 } "-mcpu=ultrasparc"]
1478 # Return 1 if the target supports hardware vector shift operation.
1480 proc check_effective_target_vect_shift { } {
1481 global et_vect_shift_saved
1483 if [info exists et_vect_shift_saved] {
1484 verbose "check_effective_target_vect_shift: using cached result" 2
1486 set et_vect_shift_saved 0
1487 if { ([istarget powerpc*-*-*]
1488 && ![istarget powerpc-*-linux*paired*])
1489 || [istarget ia64-*-*]
1490 || [istarget i?86-*-*]
1491 || [istarget x86_64-*-*]
1492 || [check_effective_target_arm32] } {
1493 set et_vect_shift_saved 1
1497 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1498 return $et_vect_shift_saved
1501 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1503 # This can change for different subtargets so do not cache the result.
1505 proc check_effective_target_vect_long { } {
1506 if { [istarget i?86-*-*]
1507 || (([istarget powerpc*-*-*]
1508 && ![istarget powerpc-*-linux*paired*])
1509 && [check_effective_target_ilp32])
1510 || [istarget x86_64-*-*]
1511 || [check_effective_target_arm32]
1512 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1518 verbose "check_effective_target_vect_long: returning $answer" 2
1522 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1524 # This won't change for different subtargets so cache the result.
1526 proc check_effective_target_vect_float { } {
1527 global et_vect_float_saved
1529 if [info exists et_vect_float_saved] {
1530 verbose "check_effective_target_vect_float: using cached result" 2
1532 set et_vect_float_saved 0
1533 if { [istarget i?86-*-*]
1534 || [istarget powerpc*-*-*]
1535 || [istarget spu-*-*]
1536 || [istarget mipsisa64*-*-*]
1537 || [istarget x86_64-*-*]
1538 || [istarget ia64-*-*]
1539 || [check_effective_target_arm32] } {
1540 set et_vect_float_saved 1
1544 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1545 return $et_vect_float_saved
1548 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1550 # This won't change for different subtargets so cache the result.
1552 proc check_effective_target_vect_double { } {
1553 global et_vect_double_saved
1555 if [info exists et_vect_double_saved] {
1556 verbose "check_effective_target_vect_double: using cached result" 2
1558 set et_vect_double_saved 0
1559 if { [istarget i?86-*-*]
1560 || [istarget x86_64-*-*]
1561 || [istarget spu-*-*] } {
1562 set et_vect_double_saved 1
1566 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1567 return $et_vect_double_saved
1570 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
1572 # This won't change for different subtargets so cache the result.
1574 proc check_effective_target_vect_long_long { } {
1575 global et_vect_long_long_saved
1577 if [info exists et_vect_long_long_saved] {
1578 verbose "check_effective_target_vect_long_long: using cached result" 2
1580 set et_vect_long_long_saved 0
1581 if { [istarget i?86-*-*]
1582 || [istarget x86_64-*-*] } {
1583 set et_vect_long_long_saved 1
1587 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
1588 return $et_vect_long_long_saved
1592 # Return 1 if the target plus current options does not support a vector
1593 # max instruction on "int", 0 otherwise.
1595 # This won't change for different subtargets so cache the result.
1597 proc check_effective_target_vect_no_int_max { } {
1598 global et_vect_no_int_max_saved
1600 if [info exists et_vect_no_int_max_saved] {
1601 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1603 set et_vect_no_int_max_saved 0
1604 if { [istarget sparc*-*-*]
1605 || [istarget spu-*-*]
1606 || [istarget alpha*-*-*] } {
1607 set et_vect_no_int_max_saved 1
1610 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1611 return $et_vect_no_int_max_saved
1614 # Return 1 if the target plus current options does not support a vector
1615 # add instruction on "int", 0 otherwise.
1617 # This won't change for different subtargets so cache the result.
1619 proc check_effective_target_vect_no_int_add { } {
1620 global et_vect_no_int_add_saved
1622 if [info exists et_vect_no_int_add_saved] {
1623 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1625 set et_vect_no_int_add_saved 0
1626 # Alpha only supports vector add on V8QI and V4HI.
1627 if { [istarget alpha*-*-*] } {
1628 set et_vect_no_int_add_saved 1
1631 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1632 return $et_vect_no_int_add_saved
1635 # Return 1 if the target plus current options does not support vector
1636 # bitwise instructions, 0 otherwise.
1638 # This won't change for different subtargets so cache the result.
1640 proc check_effective_target_vect_no_bitwise { } {
1641 global et_vect_no_bitwise_saved
1643 if [info exists et_vect_no_bitwise_saved] {
1644 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1646 set et_vect_no_bitwise_saved 0
1648 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1649 return $et_vect_no_bitwise_saved
1652 # Return 1 if the target plus current options supports vector permutation,
1655 # This won't change for different subtargets so cache the result.
1657 proc check_effective_target_vect_perm { } {
1660 if [info exists et_vect_perm_saved] {
1661 verbose "check_effective_target_vect_perm: using cached result" 2
1663 set et_vect_perm_saved 0
1664 if { [istarget powerpc*-*-*]
1665 || [istarget spu-*-*] } {
1666 set et_vect_perm_saved 1
1669 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
1670 return $et_vect_perm_saved
1674 # Return 1 if the target plus current options supports a vector
1675 # widening summation of *short* args into *int* result, 0 otherwise.
1676 # A target can also support this widening summation if it can support
1677 # promotion (unpacking) from shorts to ints.
1679 # This won't change for different subtargets so cache the result.
1681 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1682 global et_vect_widen_sum_hi_to_si
1684 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1685 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1687 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1688 if { [istarget powerpc*-*-*]
1689 || [istarget ia64-*-*] } {
1690 set et_vect_widen_sum_hi_to_si_saved 1
1693 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1694 return $et_vect_widen_sum_hi_to_si_saved
1697 # Return 1 if the target plus current options supports a vector
1698 # widening summation of *char* args into *short* result, 0 otherwise.
1699 # A target can also support this widening summation if it can support
1700 # promotion (unpacking) from chars to shorts.
1702 # This won't change for different subtargets so cache the result.
1704 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1705 global et_vect_widen_sum_qi_to_hi
1707 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1708 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1710 set et_vect_widen_sum_qi_to_hi_saved 0
1711 if { [check_effective_target_vect_unpack]
1712 || [istarget ia64-*-*] } {
1713 set et_vect_widen_sum_qi_to_hi_saved 1
1716 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1717 return $et_vect_widen_sum_qi_to_hi_saved
1720 # Return 1 if the target plus current options supports a vector
1721 # widening summation of *char* args into *int* result, 0 otherwise.
1723 # This won't change for different subtargets so cache the result.
1725 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1726 global et_vect_widen_sum_qi_to_si
1728 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1729 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1731 set et_vect_widen_sum_qi_to_si_saved 0
1732 if { [istarget powerpc*-*-*] } {
1733 set et_vect_widen_sum_qi_to_si_saved 1
1736 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1737 return $et_vect_widen_sum_qi_to_si_saved
1740 # Return 1 if the target plus current options supports a vector
1741 # widening multiplication of *char* args into *short* result, 0 otherwise.
1742 # A target can also support this widening multplication if it can support
1743 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1744 # multiplication of shorts).
1746 # This won't change for different subtargets so cache the result.
1749 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1750 global et_vect_widen_mult_qi_to_hi
1752 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1753 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1755 if { [check_effective_target_vect_unpack]
1756 && [check_effective_target_vect_short_mult] } {
1757 set et_vect_widen_mult_qi_to_hi_saved 1
1759 set et_vect_widen_mult_qi_to_hi_saved 0
1761 if { [istarget powerpc*-*-*] } {
1762 set et_vect_widen_mult_qi_to_hi_saved 1
1765 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1766 return $et_vect_widen_mult_qi_to_hi_saved
1769 # Return 1 if the target plus current options supports a vector
1770 # widening multiplication of *short* args into *int* result, 0 otherwise.
1771 # A target can also support this widening multplication if it can support
1772 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1773 # multiplication of ints).
1775 # This won't change for different subtargets so cache the result.
1778 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1779 global et_vect_widen_mult_hi_to_si
1781 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1782 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1784 if { [check_effective_target_vect_unpack]
1785 && [check_effective_target_vect_int_mult] } {
1786 set et_vect_widen_mult_hi_to_si_saved 1
1788 set et_vect_widen_mult_hi_to_si_saved 0
1790 if { [istarget powerpc*-*-*]
1791 || [istarget spu-*-*]
1792 || [istarget i?86-*-*]
1793 || [istarget x86_64-*-*] } {
1794 set et_vect_widen_mult_hi_to_si_saved 1
1797 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1798 return $et_vect_widen_mult_hi_to_si_saved
1801 # Return 1 if the target plus current options supports a vector
1802 # dot-product of signed chars, 0 otherwise.
1804 # This won't change for different subtargets so cache the result.
1806 proc check_effective_target_vect_sdot_qi { } {
1807 global et_vect_sdot_qi
1809 if [info exists et_vect_sdot_qi_saved] {
1810 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1812 set et_vect_sdot_qi_saved 0
1814 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1815 return $et_vect_sdot_qi_saved
1818 # Return 1 if the target plus current options supports a vector
1819 # dot-product of unsigned chars, 0 otherwise.
1821 # This won't change for different subtargets so cache the result.
1823 proc check_effective_target_vect_udot_qi { } {
1824 global et_vect_udot_qi
1826 if [info exists et_vect_udot_qi_saved] {
1827 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1829 set et_vect_udot_qi_saved 0
1830 if { [istarget powerpc*-*-*] } {
1831 set et_vect_udot_qi_saved 1
1834 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1835 return $et_vect_udot_qi_saved
1838 # Return 1 if the target plus current options supports a vector
1839 # dot-product of signed shorts, 0 otherwise.
1841 # This won't change for different subtargets so cache the result.
1843 proc check_effective_target_vect_sdot_hi { } {
1844 global et_vect_sdot_hi
1846 if [info exists et_vect_sdot_hi_saved] {
1847 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1849 set et_vect_sdot_hi_saved 0
1850 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1851 || [istarget i?86-*-*]
1852 || [istarget x86_64-*-*] } {
1853 set et_vect_sdot_hi_saved 1
1856 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1857 return $et_vect_sdot_hi_saved
1860 # Return 1 if the target plus current options supports a vector
1861 # dot-product of unsigned shorts, 0 otherwise.
1863 # This won't change for different subtargets so cache the result.
1865 proc check_effective_target_vect_udot_hi { } {
1866 global et_vect_udot_hi
1868 if [info exists et_vect_udot_hi_saved] {
1869 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1871 set et_vect_udot_hi_saved 0
1872 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1873 set et_vect_udot_hi_saved 1
1876 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1877 return $et_vect_udot_hi_saved
1881 # Return 1 if the target plus current options supports a vector
1882 # demotion (packing) of shorts (to chars) and ints (to shorts)
1883 # using modulo arithmetic, 0 otherwise.
1885 # This won't change for different subtargets so cache the result.
1887 proc check_effective_target_vect_pack_trunc { } {
1888 global et_vect_pack_trunc
1890 if [info exists et_vect_pack_trunc_saved] {
1891 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1893 set et_vect_pack_trunc_saved 0
1894 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1895 || [istarget i?86-*-*]
1896 || [istarget x86_64-*-*]
1897 || [istarget spu-*-*] } {
1898 set et_vect_pack_trunc_saved 1
1901 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1902 return $et_vect_pack_trunc_saved
1905 # Return 1 if the target plus current options supports a vector
1906 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1908 # This won't change for different subtargets so cache the result.
1910 proc check_effective_target_vect_unpack { } {
1911 global et_vect_unpack
1913 if [info exists et_vect_unpack_saved] {
1914 verbose "check_effective_target_vect_unpack: using cached result" 2
1916 set et_vect_unpack_saved 0
1917 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1918 || [istarget i?86-*-*]
1919 || [istarget x86_64-*-*]
1920 || [istarget spu-*-*] } {
1921 set et_vect_unpack_saved 1
1924 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1925 return $et_vect_unpack_saved
1928 # Return 1 if the target plus current options does not guarantee
1929 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1931 # This won't change for different subtargets so cache the result.
1933 proc check_effective_target_unaligned_stack { } {
1934 global et_unaligned_stack_saved
1936 if [info exists et_unaligned_stack_saved] {
1937 verbose "check_effective_target_unaligned_stack: using cached result" 2
1939 set et_unaligned_stack_saved 0
1941 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1942 return $et_unaligned_stack_saved
1945 # Return 1 if the target plus current options does not support a vector
1946 # alignment mechanism, 0 otherwise.
1948 # This won't change for different subtargets so cache the result.
1950 proc check_effective_target_vect_no_align { } {
1951 global et_vect_no_align_saved
1953 if [info exists et_vect_no_align_saved] {
1954 verbose "check_effective_target_vect_no_align: using cached result" 2
1956 set et_vect_no_align_saved 0
1957 if { [istarget mipsisa64*-*-*]
1958 || [istarget sparc*-*-*]
1959 || [istarget ia64-*-*]
1960 || [check_effective_target_arm32] } {
1961 set et_vect_no_align_saved 1
1964 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1965 return $et_vect_no_align_saved
1968 # Return 1 if arrays are aligned to the vector alignment
1969 # boundary, 0 otherwise.
1971 # This won't change for different subtargets so cache the result.
1973 proc check_effective_target_vect_aligned_arrays { } {
1974 global et_vect_aligned_arrays
1976 if [info exists et_vect_aligned_arrays_saved] {
1977 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1979 set et_vect_aligned_arrays_saved 0
1980 if { (([istarget x86_64-*-*]
1981 || [istarget i?86-*-*]) && [is-effective-target lp64])
1982 || [istarget spu-*-*] } {
1983 set et_vect_aligned_arrays_saved 1
1986 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1987 return $et_vect_aligned_arrays_saved
1990 # Return 1 if types of size 32 bit or less are naturally aligned
1991 # (aligned to their type-size), 0 otherwise.
1993 # This won't change for different subtargets so cache the result.
1995 proc check_effective_target_natural_alignment_32 { } {
1996 global et_natural_alignment_32
1998 if [info exists et_natural_alignment_32_saved] {
1999 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2001 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2002 set et_natural_alignment_32_saved 1
2003 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2004 set et_natural_alignment_32_saved 0
2007 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2008 return $et_natural_alignment_32_saved
2011 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2012 # type-size), 0 otherwise.
2014 # This won't change for different subtargets so cache the result.
2016 proc check_effective_target_natural_alignment_64 { } {
2017 global et_natural_alignment_64
2019 if [info exists et_natural_alignment_64_saved] {
2020 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2022 set et_natural_alignment_64_saved 0
2023 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2024 || [istarget spu-*-*] } {
2025 set et_natural_alignment_64_saved 1
2028 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2029 return $et_natural_alignment_64_saved
2032 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2034 # This won't change for different subtargets so cache the result.
2036 proc check_effective_target_vector_alignment_reachable { } {
2037 global et_vector_alignment_reachable
2039 if [info exists et_vector_alignment_reachable_saved] {
2040 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2042 if { [check_effective_target_vect_aligned_arrays]
2043 || [check_effective_target_natural_alignment_32] } {
2044 set et_vector_alignment_reachable_saved 1
2046 set et_vector_alignment_reachable_saved 0
2049 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2050 return $et_vector_alignment_reachable_saved
2053 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2055 # This won't change for different subtargets so cache the result.
2057 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2058 global et_vector_alignment_reachable_for_64bit
2060 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2061 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2063 if { [check_effective_target_vect_aligned_arrays]
2064 || [check_effective_target_natural_alignment_64] } {
2065 set et_vector_alignment_reachable_for_64bit_saved 1
2067 set et_vector_alignment_reachable_for_64bit_saved 0
2070 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2071 return $et_vector_alignment_reachable_for_64bit_saved
2074 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2076 proc check_effective_target_vect_condition { } {
2077 global et_vect_cond_saved
2079 if [info exists et_vect_cond_saved] {
2080 verbose "check_effective_target_vect_cond: using cached result" 2
2082 set et_vect_cond_saved 0
2083 if { [istarget powerpc*-*-*]
2084 || [istarget ia64-*-*]
2085 || [istarget i?86-*-*]
2086 || [istarget spu-*-*]
2087 || [istarget x86_64-*-*] } {
2088 set et_vect_cond_saved 1
2092 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2093 return $et_vect_cond_saved
2096 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2098 proc check_effective_target_vect_char_mult { } {
2099 global et_vect_char_mult_saved
2101 if [info exists et_vect_char_mult_saved] {
2102 verbose "check_effective_target_vect_char_mult: using cached result" 2
2104 set et_vect_char_mult_saved 0
2105 if { [istarget ia64-*-*]
2106 || [istarget i?86-*-*]
2107 || [istarget x86_64-*-*] } {
2108 set et_vect_char_mult_saved 1
2112 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2113 return $et_vect_char_mult_saved
2116 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2118 proc check_effective_target_vect_short_mult { } {
2119 global et_vect_short_mult_saved
2121 if [info exists et_vect_short_mult_saved] {
2122 verbose "check_effective_target_vect_short_mult: using cached result" 2
2124 set et_vect_short_mult_saved 0
2125 if { [istarget ia64-*-*]
2126 || [istarget spu-*-*]
2127 || [istarget i?86-*-*]
2128 || [istarget x86_64-*-*]
2129 || [istarget powerpc*-*-*] } {
2130 set et_vect_short_mult_saved 1
2134 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2135 return $et_vect_short_mult_saved
2138 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2140 proc check_effective_target_vect_int_mult { } {
2141 global et_vect_int_mult_saved
2143 if [info exists et_vect_int_mult_saved] {
2144 verbose "check_effective_target_vect_int_mult: using cached result" 2
2146 set et_vect_int_mult_saved 0
2147 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2148 || [istarget spu-*-*]
2149 || [istarget i?86-*-*]
2150 || [istarget x86_64-*-*]
2151 || [check_effective_target_arm32] } {
2152 set et_vect_int_mult_saved 1
2156 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2157 return $et_vect_int_mult_saved
2160 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2162 proc check_effective_target_vect_extract_even_odd { } {
2163 global et_vect_extract_even_odd_saved
2165 if [info exists et_vect_extract_even_odd_saved] {
2166 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2168 set et_vect_extract_even_odd_saved 0
2169 if { [istarget powerpc*-*-*]
2170 || [istarget spu-*-*] } {
2171 set et_vect_extract_even_odd_saved 1
2175 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2176 return $et_vect_extract_even_odd_saved
2179 # Return 1 if the target supports vector even/odd elements extraction of
2180 # vectors with SImode elements or larger, 0 otherwise.
2182 proc check_effective_target_vect_extract_even_odd_wide { } {
2183 global et_vect_extract_even_odd_wide_saved
2185 if [info exists et_vect_extract_even_odd_wide_saved] {
2186 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2188 set et_vect_extract_even_odd_wide_saved 0
2189 if { [istarget powerpc*-*-*]
2190 || [istarget i?86-*-*]
2191 || [istarget x86_64-*-*]
2192 || [istarget spu-*-*] } {
2193 set et_vect_extract_even_odd_wide_saved 1
2197 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2198 return $et_vect_extract_even_odd_wide_saved
2201 # Return 1 if the target supports vector interleaving, 0 otherwise.
2203 proc check_effective_target_vect_interleave { } {
2204 global et_vect_interleave_saved
2206 if [info exists et_vect_interleave_saved] {
2207 verbose "check_effective_target_vect_interleave: using cached result" 2
2209 set et_vect_interleave_saved 0
2210 if { [istarget powerpc*-*-*]
2211 || [istarget i?86-*-*]
2212 || [istarget x86_64-*-*]
2213 || [istarget spu-*-*] } {
2214 set et_vect_interleave_saved 1
2218 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2219 return $et_vect_interleave_saved
2222 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2223 proc check_effective_target_vect_strided { } {
2224 global et_vect_strided_saved
2226 if [info exists et_vect_strided_saved] {
2227 verbose "check_effective_target_vect_strided: using cached result" 2
2229 set et_vect_strided_saved 0
2230 if { [check_effective_target_vect_interleave]
2231 && [check_effective_target_vect_extract_even_odd] } {
2232 set et_vect_strided_saved 1
2236 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2237 return $et_vect_strided_saved
2240 # Return 1 if the target supports vector interleaving and extract even/odd
2241 # for wide element types, 0 otherwise.
2242 proc check_effective_target_vect_strided_wide { } {
2243 global et_vect_strided_wide_saved
2245 if [info exists et_vect_strided_wide_saved] {
2246 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2248 set et_vect_strided_wide_saved 0
2249 if { [check_effective_target_vect_interleave]
2250 && [check_effective_target_vect_extract_even_odd_wide] } {
2251 set et_vect_strided_wide_saved 1
2255 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2256 return $et_vect_strided_wide_saved
2259 # Return 1 if the target supports section-anchors
2261 proc check_effective_target_section_anchors { } {
2262 global et_section_anchors_saved
2264 if [info exists et_section_anchors_saved] {
2265 verbose "check_effective_target_section_anchors: using cached result" 2
2267 set et_section_anchors_saved 0
2268 if { [istarget powerpc*-*-*] } {
2269 set et_section_anchors_saved 1
2273 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2274 return $et_section_anchors_saved
2277 # Return 1 if the target supports atomic operations on "int" and "long".
2279 proc check_effective_target_sync_int_long { } {
2280 global et_sync_int_long_saved
2282 if [info exists et_sync_int_long_saved] {
2283 verbose "check_effective_target_sync_int_long: using cached result" 2
2285 set et_sync_int_long_saved 0
2286 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2287 # load-reserved/store-conditional instructions.
2288 if { [istarget ia64-*-*]
2289 || [istarget i?86-*-*]
2290 || [istarget x86_64-*-*]
2291 || [istarget alpha*-*-*]
2292 || [istarget s390*-*-*]
2293 || [istarget powerpc*-*-*]
2294 || [istarget sparc64-*-*]
2295 || [istarget sparcv9-*-*]
2296 || [istarget mips*-*-*] } {
2297 set et_sync_int_long_saved 1
2301 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2302 return $et_sync_int_long_saved
2305 # Return 1 if the target supports atomic operations on "char" and "short".
2307 proc check_effective_target_sync_char_short { } {
2308 global et_sync_char_short_saved
2310 if [info exists et_sync_char_short_saved] {
2311 verbose "check_effective_target_sync_char_short: using cached result" 2
2313 set et_sync_char_short_saved 0
2314 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2315 # load-reserved/store-conditional instructions.
2316 if { [istarget ia64-*-*]
2317 || [istarget i?86-*-*]
2318 || [istarget x86_64-*-*]
2319 || [istarget alpha*-*-*]
2320 || [istarget s390*-*-*]
2321 || [istarget powerpc*-*-*]
2322 || [istarget sparc64-*-*]
2323 || [istarget sparcv9-*-*]
2324 || [istarget mips*-*-*] } {
2325 set et_sync_char_short_saved 1
2329 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2330 return $et_sync_char_short_saved
2333 # Return 1 if the target uses a ColdFire FPU.
2335 proc check_effective_target_coldfire_fpu { } {
2336 return [check_no_compiler_messages coldfire_fpu assembly {
2343 # Return true if this is a uClibc target.
2345 proc check_effective_target_uclibc {} {
2346 return [check_no_compiler_messages uclibc object {
2347 #include <features.h>
2348 #if !defined (__UCLIBC__)
2354 # Return true if this is a uclibc target and if the uclibc feature
2355 # described by __$feature__ is not present.
2357 proc check_missing_uclibc_feature {feature} {
2358 return [check_no_compiler_messages $feature object "
2359 #include <features.h>
2360 #if !defined (__UCLIBC) || defined (__${feature}__)
2366 # Return true if this is a Newlib target.
2368 proc check_effective_target_newlib {} {
2369 return [check_no_compiler_messages newlib object {
2375 # (a) an error of a few ULP is expected in string to floating-point
2376 # conversion functions; and
2377 # (b) overflow is not always detected correctly by those functions.
2379 proc check_effective_target_lax_strtofp {} {
2380 # By default, assume that all uClibc targets suffer from this.
2381 return [check_effective_target_uclibc]
2384 # Return 1 if this is a target for which wcsftime is a dummy
2385 # function that always returns 0.
2387 proc check_effective_target_dummy_wcsftime {} {
2388 # By default, assume that all uClibc targets suffer from this.
2389 return [check_effective_target_uclibc]
2392 # Return 1 if constructors with initialization priority arguments are
2393 # supposed on this target.
2395 proc check_effective_target_init_priority {} {
2396 return [check_no_compiler_messages init_priority assembly "
2397 void f() __attribute__((constructor (1000)));
2402 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2403 # This can be used with any check_* proc that takes no argument and
2404 # returns only 1 or 0. It could be used with check_* procs that take
2405 # arguments with keywords that pass particular arguments.
2407 proc is-effective-target { arg } {
2409 if { [info procs check_effective_target_${arg}] != [list] } {
2410 set selected [check_effective_target_${arg}]
2413 "vmx_hw" { set selected [check_vmx_hw_available] }
2414 "named_sections" { set selected [check_named_sections_available] }
2415 "gc_sections" { set selected [check_gc_sections_available] }
2416 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2417 default { error "unknown effective target keyword `$arg'" }
2420 verbose "is-effective-target: $arg $selected" 2
2424 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2426 proc is-effective-target-keyword { arg } {
2427 if { [info procs check_effective_target_${arg}] != [list] } {
2430 # These have different names for their check_* procs.
2432 "vmx_hw" { return 1 }
2433 "named_sections" { return 1 }
2434 "gc_sections" { return 1 }
2435 "cxa_atexit" { return 1 }
2436 default { return 0 }
2441 # Return 1 if target default to short enums
2443 proc check_effective_target_short_enums { } {
2444 return [check_no_compiler_messages short_enums assembly {
2446 int s[sizeof (enum foo) == 1 ? 1 : -1];
2450 # Return 1 if target supports merging string constants at link time.
2452 proc check_effective_target_string_merging { } {
2453 return [check_no_messages_and_pattern string_merging \
2454 "rodata\\.str" assembly {
2455 const char *var = "String";
2459 # Return 1 if target has the basic signed and unsigned types in
2460 # <stdint.h>, 0 otherwise.
2462 proc check_effective_target_stdint_types { } {
2463 return [check_no_compiler_messages stdint_types assembly {
2465 int8_t a; int16_t b; int32_t c; int64_t d;
2466 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2470 # Return 1 if programs are intended to be run on a simulator
2471 # (i.e. slowly) rather than hardware (i.e. fast).
2473 proc check_effective_target_simulator { } {
2475 # All "src/sim" simulators set this one.
2476 if [board_info target exists is_simulator] {
2477 return [board_info target is_simulator]
2480 # The "sid" simulators don't set that one, but at least they set
2482 if [board_info target exists slow_simulator] {
2483 return [board_info target slow_simulator]
2489 # Return 1 if the target is a VxWorks kernel.
2491 proc check_effective_target_vxworks_kernel { } {
2492 return [check_no_compiler_messages vxworks_kernel assembly {
2493 #if !defined __vxworks || defined __RTP__
2499 # Return 1 if the target is a VxWorks RTP.
2501 proc check_effective_target_vxworks_rtp { } {
2502 return [check_no_compiler_messages vxworks_rtp assembly {
2503 #if !defined __vxworks || !defined __RTP__
2509 # Return 1 if the target is expected to provide wide character support.
2511 proc check_effective_target_wchar { } {
2512 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2515 return [check_no_compiler_messages wchar assembly {
2520 # Return 1 if the target has <pthread.h>.
2522 proc check_effective_target_pthread_h { } {
2523 return [check_no_compiler_messages pthread_h assembly {
2524 #include <pthread.h>
2528 # Return 1 if the target can truncate a file from a file-descriptor,
2529 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2530 # chsize. We test for a trivially functional truncation; no stubs.
2531 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2532 # different function to be used.
2534 proc check_effective_target_fd_truncate { } {
2536 #define _FILE_OFFSET_BITS 64
2542 FILE *f = fopen ("tst.tmp", "wb");
2544 const char t[] = "test writing more than ten characters";
2547 write (fd, t, sizeof (t) - 1);
2549 if (ftruncate (fd, 10) != 0)
2552 f = fopen ("tst.tmp", "rb");
2553 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2559 if { [check_runtime ftruncate $prog] } {
2563 regsub "ftruncate" $prog "chsize" prog
2564 return [check_runtime chsize $prog]
2567 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2569 proc add_options_for_c99_runtime { flags } {
2570 if { [istarget *-*-solaris2*] } {
2571 return "$flags -std=c99"
2573 if { [istarget powerpc-*-darwin*] } {
2574 return "$flags -mmacosx-version-min=10.3"
2579 # Return 1 if the target provides a full C99 runtime.
2581 proc check_effective_target_c99_runtime { } {
2582 return [check_cached_effective_target c99_runtime {
2585 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2586 set contents [read $file]
2589 #ifndef HAVE_C99_RUNTIME
2593 check_no_compiler_messages_nocache c99_runtime assembly \
2594 $contents [add_options_for_c99_runtime ""]
2598 # Return 1 if target wchar_t is at least 4 bytes.
2600 proc check_effective_target_4byte_wchar_t { } {
2601 return [check_no_compiler_messages 4byte_wchar_t object {
2602 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
2606 # Return 1 if the target supports automatic stack alignment.
2608 proc check_effective_target_automatic_stack_alignment { } {
2609 if { [istarget i?86*-*-*]
2610 || [istarget x86_64-*-*] } then {
2617 # Return 1 if avx instructions can be compiled.
2619 proc check_effective_target_avx { } {
2620 return [check_no_compiler_messages avx object {
2621 void _mm256_zeroall (void)
2623 __builtin_ia32_vzeroall ();
2628 # Return 1 if C wchar_t type is compatible with char16_t.
2630 proc check_effective_target_wchar_t_char16_t_compatible { } {
2631 return [check_no_compiler_messages wchar_t_char16_t object {
2633 __CHAR16_TYPE__ *p16 = &wc;
2634 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2638 # Return 1 if C wchar_t type is compatible with char32_t.
2640 proc check_effective_target_wchar_t_char32_t_compatible { } {
2641 return [check_no_compiler_messages wchar_t_char32_t object {
2643 __CHAR32_TYPE__ *p32 = &wc;
2644 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2648 # Return 1 if pow10 function exists.
2650 proc check_effective_target_pow10 { } {
2651 return [check_runtime pow10 {
2661 # Return 1 if current options generate DFP instructions, 0 otherwise.
2663 proc check_effective_target_hard_dfp {} {
2664 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
2666 void foo (void) { z = x + y; }