1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 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 true if profiling is supported on the target.
403 proc check_profiling_available { test_what } {
404 global profiling_available_saved
406 verbose "Profiling argument is <$test_what>" 1
408 # These conditions depend on the argument so examine them before
409 # looking at the cache variable.
411 # Support for -p on solaris2 relies on mcrt1.o which comes with the
412 # vendor compiler. We cannot reliably predict the directory where the
413 # vendor compiler (and thus mcrt1.o) is installed so we can't
414 # necessarily find mcrt1.o even if we have it.
415 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
419 # Support for -p on irix relies on libprof1.a which doesn't appear to
420 # exist on any irix6 system currently posting testsuite results.
421 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
422 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
423 if { [istarget mips*-*-irix*]
424 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
428 # MinGW does not support -p.
429 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
433 # At present, there is no profiling support on NetWare.
434 if { [istarget *-*-netware*] } {
438 # uClibc does not have gcrt1.o.
439 if { [check_effective_target_uclibc]
440 && ([lindex $test_what 1] == "-p"
441 || [lindex $test_what 1] == "-pg") } {
445 # Now examine the cache variable.
446 if {![info exists profiling_available_saved]} {
447 # Some targets don't have any implementation of __bb_init_func or are
448 # missing other needed machinery.
449 if { [istarget mmix-*-*]
450 || [istarget arm*-*-eabi*]
451 || [istarget arm*-*-elf]
452 || [istarget arm*-*-symbianelf*]
453 || [istarget avr-*-*]
454 || [istarget bfin-*-*]
455 || [istarget powerpc-*-eabi*]
456 || [istarget cris-*-*]
457 || [istarget crisv32-*-*]
458 || [istarget fido-*-elf]
459 || [istarget h8300-*-*]
460 || [istarget m32c-*-elf]
461 || [istarget m68k-*-elf]
462 || [istarget m68k-*-uclinux*]
463 || [istarget mips*-*-elf*]
464 || [istarget xstormy16-*]
465 || [istarget xtensa-*-elf]
466 || [istarget *-*-vxworks*] } {
467 set profiling_available_saved 0
469 set profiling_available_saved 1
473 return $profiling_available_saved
476 # Return 1 if target has packed layout of structure members by
477 # default, 0 otherwise. Note that this is slightly different than
478 # whether the target has "natural alignment": both attributes may be
481 proc check_effective_target_default_packed { } {
482 return [check_no_compiler_messages default_packed assembly {
483 struct x { char a; long b; } c;
484 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
488 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
489 # documentation, where the test also comes from.
491 proc check_effective_target_pcc_bitfield_type_matters { } {
492 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
493 # bitfields, but let's stick to the example code from the docs.
494 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
495 struct foo1 { char x; char :0; char y; };
496 struct foo2 { char x; int :0; char y; };
497 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
501 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
503 # This won't change for different subtargets so cache the result.
505 proc check_effective_target_tls {} {
506 return [check_no_compiler_messages tls assembly {
508 int f (void) { return i; }
509 void g (int j) { i = j; }
513 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
515 # This won't change for different subtargets so cache the result.
517 proc check_effective_target_tls_native {} {
518 # VxWorks uses emulated TLS machinery, but with non-standard helper
519 # functions, so we fail to automatically detect it.
520 global target_triplet
521 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
525 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
527 int f (void) { return i; }
528 void g (int j) { i = j; }
532 # Return 1 if TLS executables can run correctly, 0 otherwise.
534 # This won't change for different subtargets so cache the result.
536 proc check_effective_target_tls_runtime {} {
537 return [check_runtime tls_runtime {
538 __thread int thr = 0;
539 int main (void) { return thr; }
543 # Return 1 if compilation with -fopenmp is error-free for trivial
546 proc check_effective_target_fopenmp {} {
547 return [check_no_compiler_messages fopenmp object {
552 # Return 1 if compilation with -pthread is error-free for trivial
555 proc check_effective_target_pthread {} {
556 return [check_no_compiler_messages pthread object {
561 # Return 1 if the target supports -fstack-protector
562 proc check_effective_target_fstack_protector {} {
563 return [check_runtime fstack_protector {
564 int main (void) { return 0; }
565 } "-fstack-protector"]
568 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
569 # for trivial code, 0 otherwise.
571 proc check_effective_target_freorder {} {
572 return [check_no_compiler_messages freorder object {
574 } "-freorder-blocks-and-partition"]
577 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
578 # emitted, 0 otherwise. Whether a shared library can actually be built is
579 # out of scope for this test.
581 proc check_effective_target_fpic { } {
582 # Note that M68K has a multilib that supports -fpic but not
583 # -fPIC, so we need to check both. We test with a program that
584 # requires GOT references.
585 foreach arg {fpic fPIC} {
586 if [check_no_compiler_messages $arg object {
587 extern int foo (void); extern int bar;
588 int baz (void) { return foo () + bar; }
596 # Return true if the target supports -mpaired-single (as used on MIPS).
598 proc check_effective_target_mpaired_single { } {
599 return [check_no_compiler_messages mpaired_single object {
604 # Return true if the target has access to FPU instructions.
606 proc check_effective_target_hard_float { } {
607 if { [istarget mips*-*-*] } {
608 return [check_no_compiler_messages hard_float assembly {
609 #if (defined __mips_soft_float || defined __mips16)
615 # The generic test equates hard_float with "no call for adding doubles".
616 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
617 double a (double b, double c) { return b + c; }
621 # Return true if the target is a 64-bit MIPS target.
623 proc check_effective_target_mips64 { } {
624 return [check_no_compiler_messages mips64 assembly {
631 # Return true if the target is a MIPS target that does not produce
634 proc check_effective_target_nomips16 { } {
635 return [check_no_compiler_messages nomips16 object {
639 /* A cheap way of testing for -mflip-mips16. */
640 void foo (void) { asm ("addiu $20,$20,1"); }
641 void bar (void) { asm ("addiu $20,$20,1"); }
646 # Add the options needed for MIPS16 function attributes. At the moment,
647 # we don't support MIPS16 PIC.
649 proc add_options_for_mips16_attribute { flags } {
650 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
653 # Return true if we can force a mode that allows MIPS16 code generation.
654 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
657 proc check_effective_target_mips16_attribute { } {
658 return [check_no_compiler_messages mips16_attribute assembly {
662 #if defined __mips_hard_float \
663 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
664 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
667 } [add_options_for_mips16_attribute ""]]
670 # Return 1 if the current multilib does not generate PIC by default.
672 proc check_effective_target_nonpic { } {
673 return [check_no_compiler_messages nonpic assembly {
680 # Return 1 if the target does not use a status wrapper.
682 proc check_effective_target_unwrapped { } {
683 if { [target_info needs_status_wrapper] != "" \
684 && [target_info needs_status_wrapper] != "0" } {
690 # Return true if iconv is supported on the target. In particular IBM1047.
692 proc check_iconv_available { test_what } {
695 # If the tool configuration file has not set libiconv, try "-liconv"
696 if { ![info exists libiconv] } {
697 set libiconv "-liconv"
699 set test_what [lindex $test_what 1]
700 return [check_runtime_nocache $test_what [subst {
706 cd = iconv_open ("$test_what", "UTF-8");
707 if (cd == (iconv_t) -1)
714 # Return true if named sections are supported on this target.
716 proc check_named_sections_available { } {
717 return [check_no_compiler_messages named_sections assembly {
718 int __attribute__ ((section("whatever"))) foo;
722 # Return 1 if the target supports Fortran real kinds larger than real(8),
725 # When the target name changes, replace the cached result.
727 proc check_effective_target_fortran_large_real { } {
728 return [check_no_compiler_messages fortran_large_real executable {
730 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
737 # Return 1 if the target supports Fortran integer kinds larger than
738 # integer(8), 0 otherwise.
740 # When the target name changes, replace the cached result.
742 proc check_effective_target_fortran_large_int { } {
743 return [check_no_compiler_messages fortran_large_int executable {
745 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
751 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
753 # When the target name changes, replace the cached result.
755 proc check_effective_target_fortran_integer_16 { } {
756 return [check_no_compiler_messages fortran_integer_16 executable {
763 # Return 1 if we can statically link libgfortran, 0 otherwise.
765 # When the target name changes, replace the cached result.
767 proc check_effective_target_static_libgfortran { } {
768 return [check_no_compiler_messages static_libgfortran executable {
775 # Return 1 if the target supports executing 750CL paired-single instructions, 0
776 # otherwise. Cache the result.
778 proc check_750cl_hw_available { } {
779 return [check_cached_effective_target 750cl_hw_available {
780 # If this is not the right target then we can skip the test.
781 if { ![istarget powerpc-*paired*] } {
784 check_runtime_nocache 750cl_hw_available {
788 asm volatile ("ps_mul v0,v0,v0");
790 asm volatile ("ps_mul 0,0,0");
799 # Return 1 if the target supports executing SSE2 instructions, 0
800 # otherwise. Cache the result.
802 proc check_sse2_hw_available { } {
803 return [check_cached_effective_target sse2_hw_available {
804 # If this is not the right target then we can skip the test.
805 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
808 check_runtime_nocache sse2_hw_available {
812 unsigned int eax, ebx, ecx, edx = 0;
813 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
814 return !(edx & bit_SSE2);
822 # Return 1 if the target supports executing AltiVec instructions, 0
823 # otherwise. Cache the result.
825 proc check_vmx_hw_available { } {
826 return [check_cached_effective_target vmx_hw_available {
827 # Some simulators are known to not support VMX instructions.
828 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
831 # Most targets don't require special flags for this test case, but
833 if { [istarget *-*-darwin*]
834 || [istarget *-*-aix*] } {
835 set options "-maltivec"
839 check_runtime_nocache vmx_hw_available {
843 asm volatile ("vor v0,v0,v0");
845 asm volatile ("vor 0,0,0");
854 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
855 # complex float arguments. This affects gfortran tests that call cabsf
856 # in libm built by an earlier compiler. Return 1 if libm uses the same
857 # argument passing as the compiler under test, 0 otherwise.
859 # When the target name changes, replace the cached result.
861 proc check_effective_target_broken_cplxf_arg { } {
862 return [check_cached_effective_target broken_cplxf_arg {
863 # Skip the work for targets known not to be affected.
864 if { ![istarget powerpc64-*-linux*] } {
866 } elseif { ![is-effective-target lp64] } {
869 check_runtime_nocache broken_cplxf_arg {
871 extern void abort (void);
873 float cabsf (_Complex float);
880 if (fabsf (f - 5.0) > 0.0001)
889 proc check_alpha_max_hw_available { } {
890 return [check_runtime alpha_max_hw_available {
891 int main() { return __builtin_alpha_amask(1<<8) != 0; }
895 # Returns true iff the FUNCTION is available on the target system.
896 # (This is essentially a Tcl implementation of Autoconf's
899 proc check_function_available { function } {
900 return [check_no_compiler_messages ${function}_available \
906 int main () { $function (); }
910 # Returns true iff "fork" is available on the target system.
912 proc check_fork_available {} {
913 return [check_function_available "fork"]
916 # Returns true iff "mkfifo" is available on the target system.
918 proc check_mkfifo_available {} {
919 if {[istarget *-*-cygwin*]} {
920 # Cygwin has mkfifo, but support is incomplete.
924 return [check_function_available "mkfifo"]
927 # Returns true iff "__cxa_atexit" is used on the target system.
929 proc check_cxa_atexit_available { } {
930 return [check_cached_effective_target cxa_atexit_available {
931 if { [istarget "hppa*-*-hpux10*"] } {
932 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
935 check_runtime_nocache cxa_atexit_available {
938 static unsigned int count;
955 Y() { f(); count = 2; }
964 int main() { return 0; }
971 # Return 1 if we're generating 32-bit code using default options, 0
974 proc check_effective_target_ilp32 { } {
975 return [check_no_compiler_messages ilp32 object {
976 int dummy[sizeof (int) == 4
977 && sizeof (void *) == 4
978 && sizeof (long) == 4 ? 1 : -1];
982 # Return 1 if we're generating 32-bit or larger integers using default
983 # options, 0 otherwise.
985 proc check_effective_target_int32plus { } {
986 return [check_no_compiler_messages int32plus object {
987 int dummy[sizeof (int) >= 4 ? 1 : -1];
991 # Return 1 if we're generating 32-bit or larger pointers using default
992 # options, 0 otherwise.
994 proc check_effective_target_ptr32plus { } {
995 return [check_no_compiler_messages ptr32plus object {
996 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1000 # Return 1 if we support 32-bit or larger array and structure sizes
1001 # using default options, 0 otherwise.
1003 proc check_effective_target_size32plus { } {
1004 return [check_no_compiler_messages size32plus object {
1009 # Returns 1 if we're generating 16-bit or smaller integers with the
1010 # default options, 0 otherwise.
1012 proc check_effective_target_int16 { } {
1013 return [check_no_compiler_messages int16 object {
1014 int dummy[sizeof (int) < 4 ? 1 : -1];
1018 # Return 1 if we're generating 64-bit code using default options, 0
1021 proc check_effective_target_lp64 { } {
1022 return [check_no_compiler_messages lp64 object {
1023 int dummy[sizeof (int) == 4
1024 && sizeof (void *) == 8
1025 && sizeof (long) == 8 ? 1 : -1];
1029 # Return 1 if the target supports long double larger than double,
1032 proc check_effective_target_large_long_double { } {
1033 return [check_no_compiler_messages large_long_double object {
1034 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1038 # Return 1 if the target supports compiling fixed-point,
1041 proc check_effective_target_fixed_point { } {
1042 return [check_no_compiler_messages fixed_point object {
1043 _Sat _Fract x; _Sat _Accum y;
1047 # Return 1 if the target supports compiling decimal floating point,
1050 proc check_effective_target_dfp_nocache { } {
1051 verbose "check_effective_target_dfp_nocache: compiling source" 2
1052 set ret [check_no_compiler_messages_nocache dfp object {
1053 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1055 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1059 proc check_effective_target_dfprt_nocache { } {
1060 return [check_runtime_nocache dfprt {
1061 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1062 int main () { z = x + y; return 0; }
1066 # Return 1 if the target supports compiling Decimal Floating Point,
1069 # This won't change for different subtargets so cache the result.
1071 proc check_effective_target_dfp { } {
1072 return [check_cached_effective_target dfp {
1073 check_effective_target_dfp_nocache
1077 # Return 1 if the target supports linking and executing Decimal Floating
1078 # Point, # 0 otherwise.
1080 # This won't change for different subtargets so cache the result.
1082 proc check_effective_target_dfprt { } {
1083 return [check_cached_effective_target dfprt {
1084 check_effective_target_dfprt_nocache
1088 # Return 1 if the target needs a command line argument to enable a SIMD
1091 proc check_effective_target_vect_cmdline_needed { } {
1092 global et_vect_cmdline_needed_saved
1093 global et_vect_cmdline_needed_target_name
1095 if { ![info exists et_vect_cmdline_needed_target_name] } {
1096 set et_vect_cmdline_needed_target_name ""
1099 # If the target has changed since we set the cached value, clear it.
1100 set current_target [current_target_name]
1101 if { $current_target != $et_vect_cmdline_needed_target_name } {
1102 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1103 set et_vect_cmdline_needed_target_name $current_target
1104 if { [info exists et_vect_cmdline_needed_saved] } {
1105 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1106 unset et_vect_cmdline_needed_saved
1110 if [info exists et_vect_cmdline_needed_saved] {
1111 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1113 set et_vect_cmdline_needed_saved 1
1114 if { [istarget ia64-*-*]
1115 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1116 && [check_effective_target_lp64])
1117 || ([istarget powerpc*-*-*]
1118 && ([check_effective_target_powerpc_spe]
1119 || [check_effective_target_powerpc_altivec]))} {
1120 set et_vect_cmdline_needed_saved 0
1124 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1125 return $et_vect_cmdline_needed_saved
1128 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1130 # This won't change for different subtargets so cache the result.
1132 proc check_effective_target_vect_int { } {
1133 global et_vect_int_saved
1135 if [info exists et_vect_int_saved] {
1136 verbose "check_effective_target_vect_int: using cached result" 2
1138 set et_vect_int_saved 0
1139 if { [istarget i?86-*-*]
1140 || ([istarget powerpc*-*-*]
1141 && ![istarget powerpc-*-linux*paired*])
1142 || [istarget spu-*-*]
1143 || [istarget x86_64-*-*]
1144 || [istarget sparc*-*-*]
1145 || [istarget alpha*-*-*]
1146 || [istarget ia64-*-*] } {
1147 set et_vect_int_saved 1
1151 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1152 return $et_vect_int_saved
1155 # Return 1 if the target supports int->float conversion
1158 proc check_effective_target_vect_intfloat_cvt { } {
1159 global et_vect_intfloat_cvt_saved
1161 if [info exists et_vect_intfloat_cvt_saved] {
1162 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1164 set et_vect_intfloat_cvt_saved 0
1165 if { [istarget i?86-*-*]
1166 || ([istarget powerpc*-*-*]
1167 && ![istarget powerpc-*-linux*paired*])
1168 || [istarget x86_64-*-*] } {
1169 set et_vect_intfloat_cvt_saved 1
1173 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1174 return $et_vect_intfloat_cvt_saved
1178 # Return 1 if the target supports float->int conversion
1181 proc check_effective_target_vect_floatint_cvt { } {
1182 global et_vect_floatint_cvt_saved
1184 if [info exists et_vect_floatint_cvt_saved] {
1185 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1187 set et_vect_floatint_cvt_saved 0
1188 if { [istarget i?86-*-*]
1189 || [istarget x86_64-*-*] } {
1190 set et_vect_floatint_cvt_saved 1
1194 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1195 return $et_vect_floatint_cvt_saved
1198 # Return 1 is this is an arm target using 32-bit instructions
1199 proc check_effective_target_arm32 { } {
1200 return [check_no_compiler_messages arm32 assembly {
1201 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1207 # Return 1 if this is an ARM target supporting -mfpu=vfp
1208 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1211 proc check_effective_target_arm_vfp_ok { } {
1212 if { [check_effective_target_arm32] } {
1213 return [check_no_compiler_messages arm_vfp_ok object {
1215 } "-mfpu=vfp -mfloat-abi=softfp"]
1221 # Return 1 if this is an ARM target supporting -mfpu=neon
1222 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1225 proc check_effective_target_arm_neon_ok { } {
1226 if { [check_effective_target_arm32] } {
1227 return [check_no_compiler_messages arm_neon_ok object {
1229 } "-mfpu=neon -mfloat-abi=softfp"]
1235 # Return 1 if the target supports executing NEON instructions, 0
1236 # otherwise. Cache the result.
1238 proc check_effective_target_arm_neon_hw { } {
1239 return [check_runtime arm_neon_hw_available {
1243 long long a = 0, b = 1;
1244 asm ("vorr %P0, %P1, %P2"
1246 : "0" (a), "w" (b));
1249 } "-mfpu=neon -mfloat-abi=softfp"]
1252 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1253 # the Loongson vector modes.
1255 proc check_effective_target_mips_loongson { } {
1256 return [check_no_compiler_messages loongson assembly {
1257 #if !defined(__mips_loongson_vector_rev)
1263 # Return 1 if this is a PowerPC target with floating-point registers.
1265 proc check_effective_target_powerpc_fprs { } {
1266 if { [istarget powerpc*-*-*]
1267 || [istarget rs6000-*-*] } {
1268 return [check_no_compiler_messages powerpc_fprs object {
1280 # Return 1 if this is a PowerPC target supporting -maltivec.
1282 proc check_effective_target_powerpc_altivec_ok { } {
1283 if { ([istarget powerpc*-*-*]
1284 && ![istarget powerpc-*-linux*paired*])
1285 || [istarget rs6000-*-*] } {
1286 # AltiVec is not supported on AIX before 5.3.
1287 if { [istarget powerpc*-*-aix4*]
1288 || [istarget powerpc*-*-aix5.1*]
1289 || [istarget powerpc*-*-aix5.2*] } {
1292 return [check_no_compiler_messages powerpc_altivec_ok object {
1300 # Return 1 if this is a PowerPC target that supports SPU.
1302 proc check_effective_target_powerpc_spu { } {
1303 if [istarget powerpc*-*-linux*] {
1304 return [check_effective_target_powerpc_altivec_ok]
1310 # Return 1 if this is a PowerPC target with SPE enabled.
1312 proc check_effective_target_powerpc_spe { } {
1313 if { [istarget powerpc*-*-*] } {
1314 return [check_no_compiler_messages powerpc_spe object {
1326 # Return 1 if this is a PowerPC target with Altivec enabled.
1328 proc check_effective_target_powerpc_altivec { } {
1329 if { [istarget powerpc*-*-*] } {
1330 return [check_no_compiler_messages powerpc_altivec object {
1342 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1343 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1344 # test environment appears to run executables on such a simulator.
1346 proc check_effective_target_ultrasparc_hw { } {
1347 return [check_runtime ultrasparc_hw {
1348 int main() { return 0; }
1349 } "-mcpu=ultrasparc"]
1352 # Return 1 if the target supports hardware vector shift operation.
1354 proc check_effective_target_vect_shift { } {
1355 global et_vect_shift_saved
1357 if [info exists et_vect_shift_saved] {
1358 verbose "check_effective_target_vect_shift: using cached result" 2
1360 set et_vect_shift_saved 0
1361 if { ([istarget powerpc*-*-*]
1362 && ![istarget powerpc-*-linux*paired*])
1363 || [istarget ia64-*-*]
1364 || [istarget i?86-*-*]
1365 || [istarget x86_64-*-*] } {
1366 set et_vect_shift_saved 1
1370 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1371 return $et_vect_shift_saved
1374 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1376 # This can change for different subtargets so do not cache the result.
1378 proc check_effective_target_vect_long { } {
1379 if { [istarget i?86-*-*]
1380 || (([istarget powerpc*-*-*]
1381 && ![istarget powerpc-*-linux*paired*])
1382 && [check_effective_target_ilp32])
1383 || [istarget x86_64-*-*]
1384 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1390 verbose "check_effective_target_vect_long: returning $answer" 2
1394 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1396 # This won't change for different subtargets so cache the result.
1398 proc check_effective_target_vect_float { } {
1399 global et_vect_float_saved
1401 if [info exists et_vect_float_saved] {
1402 verbose "check_effective_target_vect_float: using cached result" 2
1404 set et_vect_float_saved 0
1405 if { [istarget i?86-*-*]
1406 || [istarget powerpc*-*-*]
1407 || [istarget spu-*-*]
1408 || [istarget mipsisa64*-*-*]
1409 || [istarget x86_64-*-*]
1410 || [istarget ia64-*-*] } {
1411 set et_vect_float_saved 1
1415 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1416 return $et_vect_float_saved
1419 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1421 # This won't change for different subtargets so cache the result.
1423 proc check_effective_target_vect_double { } {
1424 global et_vect_double_saved
1426 if [info exists et_vect_double_saved] {
1427 verbose "check_effective_target_vect_double: using cached result" 2
1429 set et_vect_double_saved 0
1430 if { [istarget i?86-*-*]
1431 || [istarget x86_64-*-*]
1432 || [istarget spu-*-*] } {
1433 set et_vect_double_saved 1
1437 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1438 return $et_vect_double_saved
1441 # Return 1 if the target plus current options does not support a vector
1442 # max instruction on "int", 0 otherwise.
1444 # This won't change for different subtargets so cache the result.
1446 proc check_effective_target_vect_no_int_max { } {
1447 global et_vect_no_int_max_saved
1449 if [info exists et_vect_no_int_max_saved] {
1450 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1452 set et_vect_no_int_max_saved 0
1453 if { [istarget sparc*-*-*]
1454 || [istarget spu-*-*]
1455 || [istarget alpha*-*-*] } {
1456 set et_vect_no_int_max_saved 1
1459 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1460 return $et_vect_no_int_max_saved
1463 # Return 1 if the target plus current options does not support a vector
1464 # add instruction on "int", 0 otherwise.
1466 # This won't change for different subtargets so cache the result.
1468 proc check_effective_target_vect_no_int_add { } {
1469 global et_vect_no_int_add_saved
1471 if [info exists et_vect_no_int_add_saved] {
1472 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1474 set et_vect_no_int_add_saved 0
1475 # Alpha only supports vector add on V8QI and V4HI.
1476 if { [istarget alpha*-*-*] } {
1477 set et_vect_no_int_add_saved 1
1480 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1481 return $et_vect_no_int_add_saved
1484 # Return 1 if the target plus current options does not support vector
1485 # bitwise instructions, 0 otherwise.
1487 # This won't change for different subtargets so cache the result.
1489 proc check_effective_target_vect_no_bitwise { } {
1490 global et_vect_no_bitwise_saved
1492 if [info exists et_vect_no_bitwise_saved] {
1493 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1495 set et_vect_no_bitwise_saved 0
1497 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1498 return $et_vect_no_bitwise_saved
1501 # Return 1 if the target plus current options supports a vector
1502 # widening summation of *short* args into *int* result, 0 otherwise.
1503 # A target can also support this widening summation if it can support
1504 # promotion (unpacking) from shorts to ints.
1506 # This won't change for different subtargets so cache the result.
1508 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1509 global et_vect_widen_sum_hi_to_si
1511 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1512 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1514 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1515 if { [istarget powerpc*-*-*]
1516 || [istarget ia64-*-*] } {
1517 set et_vect_widen_sum_hi_to_si_saved 1
1520 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1521 return $et_vect_widen_sum_hi_to_si_saved
1524 # Return 1 if the target plus current options supports a vector
1525 # widening summation of *char* args into *short* result, 0 otherwise.
1526 # A target can also support this widening summation if it can support
1527 # promotion (unpacking) from chars to shorts.
1529 # This won't change for different subtargets so cache the result.
1531 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1532 global et_vect_widen_sum_qi_to_hi
1534 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1535 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1537 set et_vect_widen_sum_qi_to_hi_saved 0
1538 if { [check_effective_target_vect_unpack]
1539 || [istarget ia64-*-*] } {
1540 set et_vect_widen_sum_qi_to_hi_saved 1
1543 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1544 return $et_vect_widen_sum_qi_to_hi_saved
1547 # Return 1 if the target plus current options supports a vector
1548 # widening summation of *char* args into *int* result, 0 otherwise.
1550 # This won't change for different subtargets so cache the result.
1552 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1553 global et_vect_widen_sum_qi_to_si
1555 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1556 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1558 set et_vect_widen_sum_qi_to_si_saved 0
1559 if { [istarget powerpc*-*-*] } {
1560 set et_vect_widen_sum_qi_to_si_saved 1
1563 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1564 return $et_vect_widen_sum_qi_to_si_saved
1567 # Return 1 if the target plus current options supports a vector
1568 # widening multiplication of *char* args into *short* result, 0 otherwise.
1569 # A target can also support this widening multplication if it can support
1570 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1571 # multiplication of shorts).
1573 # This won't change for different subtargets so cache the result.
1576 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1577 global et_vect_widen_mult_qi_to_hi
1579 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1580 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1582 if { [check_effective_target_vect_unpack]
1583 && [check_effective_target_vect_short_mult] } {
1584 set et_vect_widen_mult_qi_to_hi_saved 1
1586 set et_vect_widen_mult_qi_to_hi_saved 0
1588 if { [istarget powerpc*-*-*] } {
1589 set et_vect_widen_mult_qi_to_hi_saved 1
1592 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1593 return $et_vect_widen_mult_qi_to_hi_saved
1596 # Return 1 if the target plus current options supports a vector
1597 # widening multiplication of *short* args into *int* result, 0 otherwise.
1598 # A target can also support this widening multplication if it can support
1599 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1600 # multiplication of ints).
1602 # This won't change for different subtargets so cache the result.
1605 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1606 global et_vect_widen_mult_hi_to_si
1608 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1609 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1611 if { [check_effective_target_vect_unpack]
1612 && [check_effective_target_vect_int_mult] } {
1613 set et_vect_widen_mult_hi_to_si_saved 1
1615 set et_vect_widen_mult_hi_to_si_saved 0
1617 if { [istarget powerpc*-*-*]
1618 || [istarget spu-*-*]
1619 || [istarget i?86-*-*]
1620 || [istarget x86_64-*-*] } {
1621 set et_vect_widen_mult_hi_to_si_saved 1
1624 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1625 return $et_vect_widen_mult_hi_to_si_saved
1628 # Return 1 if the target plus current options supports a vector
1629 # dot-product of signed chars, 0 otherwise.
1631 # This won't change for different subtargets so cache the result.
1633 proc check_effective_target_vect_sdot_qi { } {
1634 global et_vect_sdot_qi
1636 if [info exists et_vect_sdot_qi_saved] {
1637 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1639 set et_vect_sdot_qi_saved 0
1641 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1642 return $et_vect_sdot_qi_saved
1645 # Return 1 if the target plus current options supports a vector
1646 # dot-product of unsigned chars, 0 otherwise.
1648 # This won't change for different subtargets so cache the result.
1650 proc check_effective_target_vect_udot_qi { } {
1651 global et_vect_udot_qi
1653 if [info exists et_vect_udot_qi_saved] {
1654 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1656 set et_vect_udot_qi_saved 0
1657 if { [istarget powerpc*-*-*] } {
1658 set et_vect_udot_qi_saved 1
1661 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1662 return $et_vect_udot_qi_saved
1665 # Return 1 if the target plus current options supports a vector
1666 # dot-product of signed shorts, 0 otherwise.
1668 # This won't change for different subtargets so cache the result.
1670 proc check_effective_target_vect_sdot_hi { } {
1671 global et_vect_sdot_hi
1673 if [info exists et_vect_sdot_hi_saved] {
1674 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1676 set et_vect_sdot_hi_saved 0
1677 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1678 || [istarget i?86-*-*]
1679 || [istarget x86_64-*-*] } {
1680 set et_vect_sdot_hi_saved 1
1683 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1684 return $et_vect_sdot_hi_saved
1687 # Return 1 if the target plus current options supports a vector
1688 # dot-product of unsigned shorts, 0 otherwise.
1690 # This won't change for different subtargets so cache the result.
1692 proc check_effective_target_vect_udot_hi { } {
1693 global et_vect_udot_hi
1695 if [info exists et_vect_udot_hi_saved] {
1696 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1698 set et_vect_udot_hi_saved 0
1699 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1700 set et_vect_udot_hi_saved 1
1703 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1704 return $et_vect_udot_hi_saved
1708 # Return 1 if the target plus current options supports a vector
1709 # demotion (packing) of shorts (to chars) and ints (to shorts)
1710 # using modulo arithmetic, 0 otherwise.
1712 # This won't change for different subtargets so cache the result.
1714 proc check_effective_target_vect_pack_trunc { } {
1715 global et_vect_pack_trunc
1717 if [info exists et_vect_pack_trunc_saved] {
1718 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1720 set et_vect_pack_trunc_saved 0
1721 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1722 || [istarget i?86-*-*]
1723 || [istarget x86_64-*-*] } {
1724 set et_vect_pack_trunc_saved 1
1727 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1728 return $et_vect_pack_trunc_saved
1731 # Return 1 if the target plus current options supports a vector
1732 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1734 # This won't change for different subtargets so cache the result.
1736 proc check_effective_target_vect_unpack { } {
1737 global et_vect_unpack
1739 if [info exists et_vect_unpack_saved] {
1740 verbose "check_effective_target_vect_unpack: using cached result" 2
1742 set et_vect_unpack_saved 0
1743 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1744 || [istarget i?86-*-*]
1745 || [istarget x86_64-*-*]
1746 || [istarget spu-*-*] } {
1747 set et_vect_unpack_saved 1
1750 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1751 return $et_vect_unpack_saved
1754 # Return 1 if the target plus current options does not guarantee
1755 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1757 # This won't change for different subtargets so cache the result.
1759 proc check_effective_target_unaligned_stack { } {
1760 global et_unaligned_stack_saved
1762 if [info exists et_unaligned_stack_saved] {
1763 verbose "check_effective_target_unaligned_stack: using cached result" 2
1765 set et_unaligned_stack_saved 0
1766 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
1767 && (! [istarget *-*-darwin*] ) } {
1768 set et_unaligned_stack_saved 1
1771 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1772 return $et_unaligned_stack_saved
1775 # Return 1 if the target plus current options does not support a vector
1776 # alignment mechanism, 0 otherwise.
1778 # This won't change for different subtargets so cache the result.
1780 proc check_effective_target_vect_no_align { } {
1781 global et_vect_no_align_saved
1783 if [info exists et_vect_no_align_saved] {
1784 verbose "check_effective_target_vect_no_align: using cached result" 2
1786 set et_vect_no_align_saved 0
1787 if { [istarget mipsisa64*-*-*]
1788 || [istarget sparc*-*-*]
1789 || [istarget ia64-*-*] } {
1790 set et_vect_no_align_saved 1
1793 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1794 return $et_vect_no_align_saved
1797 # Return 1 if arrays are aligned to the vector alignment
1798 # boundary, 0 otherwise.
1800 # This won't change for different subtargets so cache the result.
1802 proc check_effective_target_vect_aligned_arrays { } {
1803 global et_vect_aligned_arrays
1805 if [info exists et_vect_aligned_arrays_saved] {
1806 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1808 set et_vect_aligned_arrays_saved 0
1809 if { (([istarget x86_64-*-*]
1810 || [istarget i?86-*-*]) && [is-effective-target lp64])
1811 || [istarget spu-*-*] } {
1812 set et_vect_aligned_arrays_saved 1
1815 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1816 return $et_vect_aligned_arrays_saved
1819 # Return 1 if types of size 32 bit or less are naturally aligned
1820 # (aligned to their type-size), 0 otherwise.
1822 # This won't change for different subtargets so cache the result.
1824 proc check_effective_target_natural_alignment_32 { } {
1825 global et_natural_alignment_32
1827 if [info exists et_natural_alignment_32_saved] {
1828 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1830 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
1831 set et_natural_alignment_32_saved 1
1832 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
1833 set et_natural_alignment_32_saved 0
1836 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
1837 return $et_natural_alignment_32_saved
1840 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
1841 # type-size), 0 otherwise.
1843 # This won't change for different subtargets so cache the result.
1845 proc check_effective_target_natural_alignment_64 { } {
1846 global et_natural_alignment_64
1848 if [info exists et_natural_alignment_64_saved] {
1849 verbose "check_effective_target_natural_alignment_64: using cached result" 2
1851 set et_natural_alignment_64_saved 0
1852 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
1853 || [istarget spu-*-*] } {
1854 set et_natural_alignment_64_saved 1
1857 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
1858 return $et_natural_alignment_64_saved
1861 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
1863 # This won't change for different subtargets so cache the result.
1865 proc check_effective_target_vector_alignment_reachable { } {
1866 global et_vector_alignment_reachable
1868 if [info exists et_vector_alignment_reachable_saved] {
1869 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
1871 if { [check_effective_target_vect_aligned_arrays]
1872 || [check_effective_target_natural_alignment_32] } {
1873 set et_vector_alignment_reachable_saved 1
1875 set et_vector_alignment_reachable_saved 0
1878 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
1879 return $et_vector_alignment_reachable_saved
1882 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
1884 # This won't change for different subtargets so cache the result.
1886 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
1887 global et_vector_alignment_reachable_for_64bit
1889 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
1890 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
1892 if { [check_effective_target_vect_aligned_arrays]
1893 || [check_effective_target_natural_alignment_64] } {
1894 set et_vector_alignment_reachable_for_64bit_saved 1
1896 set et_vector_alignment_reachable_for_64bit_saved 0
1899 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
1900 return $et_vector_alignment_reachable_for_64bit_saved
1903 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1905 proc check_effective_target_vect_condition { } {
1906 global et_vect_cond_saved
1908 if [info exists et_vect_cond_saved] {
1909 verbose "check_effective_target_vect_cond: using cached result" 2
1911 set et_vect_cond_saved 0
1912 if { [istarget powerpc*-*-*]
1913 || [istarget ia64-*-*]
1914 || [istarget i?86-*-*]
1915 || [istarget spu-*-*]
1916 || [istarget x86_64-*-*] } {
1917 set et_vect_cond_saved 1
1921 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1922 return $et_vect_cond_saved
1925 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1927 proc check_effective_target_vect_char_mult { } {
1928 global et_vect_char_mult_saved
1930 if [info exists et_vect_char_mult_saved] {
1931 verbose "check_effective_target_vect_char_mult: using cached result" 2
1933 set et_vect_char_mult_saved 0
1934 if { [istarget ia64-*-*]
1935 || [istarget i?86-*-*]
1936 || [istarget x86_64-*-*] } {
1937 set et_vect_char_mult_saved 1
1941 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1942 return $et_vect_char_mult_saved
1945 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1947 proc check_effective_target_vect_short_mult { } {
1948 global et_vect_short_mult_saved
1950 if [info exists et_vect_short_mult_saved] {
1951 verbose "check_effective_target_vect_short_mult: using cached result" 2
1953 set et_vect_short_mult_saved 0
1954 if { [istarget ia64-*-*]
1955 || [istarget spu-*-*]
1956 || [istarget i?86-*-*]
1957 || [istarget x86_64-*-*] } {
1958 set et_vect_short_mult_saved 1
1962 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1963 return $et_vect_short_mult_saved
1966 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1968 proc check_effective_target_vect_int_mult { } {
1969 global et_vect_int_mult_saved
1971 if [info exists et_vect_int_mult_saved] {
1972 verbose "check_effective_target_vect_int_mult: using cached result" 2
1974 set et_vect_int_mult_saved 0
1975 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1976 || [istarget spu-*-*]
1977 || [istarget i?86-*-*]
1978 || [istarget x86_64-*-*] } {
1979 set et_vect_int_mult_saved 1
1983 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1984 return $et_vect_int_mult_saved
1987 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1989 proc check_effective_target_vect_extract_even_odd { } {
1990 global et_vect_extract_even_odd_saved
1992 if [info exists et_vect_extract_even_odd_saved] {
1993 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1995 set et_vect_extract_even_odd_saved 0
1996 if { [istarget powerpc*-*-*] } {
1997 set et_vect_extract_even_odd_saved 1
2001 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2002 return $et_vect_extract_even_odd_saved
2005 # Return 1 if the target supports vector interleaving, 0 otherwise.
2007 proc check_effective_target_vect_interleave { } {
2008 global et_vect_interleave_saved
2010 if [info exists et_vect_interleave_saved] {
2011 verbose "check_effective_target_vect_interleave: using cached result" 2
2013 set et_vect_interleave_saved 0
2014 if { [istarget powerpc*-*-*]
2015 || [istarget i?86-*-*]
2016 || [istarget x86_64-*-*] } {
2017 set et_vect_interleave_saved 1
2021 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2022 return $et_vect_interleave_saved
2025 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2026 proc check_effective_target_vect_strided { } {
2027 global et_vect_strided_saved
2029 if [info exists et_vect_strided_saved] {
2030 verbose "check_effective_target_vect_strided: using cached result" 2
2032 set et_vect_strided_saved 0
2033 if { [check_effective_target_vect_interleave]
2034 && [check_effective_target_vect_extract_even_odd] } {
2035 set et_vect_strided_saved 1
2039 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2040 return $et_vect_strided_saved
2043 # Return 1 if the target supports section-anchors
2045 proc check_effective_target_section_anchors { } {
2046 global et_section_anchors_saved
2048 if [info exists et_section_anchors_saved] {
2049 verbose "check_effective_target_section_anchors: using cached result" 2
2051 set et_section_anchors_saved 0
2052 if { [istarget powerpc*-*-*] } {
2053 set et_section_anchors_saved 1
2057 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2058 return $et_section_anchors_saved
2061 # Return 1 if the target supports atomic operations on "int" and "long".
2063 proc check_effective_target_sync_int_long { } {
2064 global et_sync_int_long_saved
2066 if [info exists et_sync_int_long_saved] {
2067 verbose "check_effective_target_sync_int_long: using cached result" 2
2069 set et_sync_int_long_saved 0
2070 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2071 # load-reserved/store-conditional instructions.
2072 if { [istarget ia64-*-*]
2073 || [istarget i?86-*-*]
2074 || [istarget x86_64-*-*]
2075 || [istarget alpha*-*-*]
2076 || [istarget s390*-*-*]
2077 || [istarget powerpc*-*-*]
2078 || [istarget sparc64-*-*]
2079 || [istarget sparcv9-*-*]
2080 || [istarget mips*-*-*] } {
2081 set et_sync_int_long_saved 1
2085 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2086 return $et_sync_int_long_saved
2089 # Return 1 if the target supports atomic operations on "char" and "short".
2091 proc check_effective_target_sync_char_short { } {
2092 global et_sync_char_short_saved
2094 if [info exists et_sync_char_short_saved] {
2095 verbose "check_effective_target_sync_char_short: using cached result" 2
2097 set et_sync_char_short_saved 0
2098 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2099 # load-reserved/store-conditional instructions.
2100 if { [istarget ia64-*-*]
2101 || [istarget i?86-*-*]
2102 || [istarget x86_64-*-*]
2103 || [istarget alpha*-*-*]
2104 || [istarget s390*-*-*]
2105 || [istarget powerpc*-*-*]
2106 || [istarget sparc64-*-*]
2107 || [istarget sparcv9-*-*]
2108 || [istarget mips*-*-*] } {
2109 set et_sync_char_short_saved 1
2113 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2114 return $et_sync_char_short_saved
2117 # Return 1 if the target uses a ColdFire FPU.
2119 proc check_effective_target_coldfire_fpu { } {
2120 return [check_no_compiler_messages coldfire_fpu assembly {
2127 # Return true if this is a uClibc target.
2129 proc check_effective_target_uclibc {} {
2130 return [check_no_compiler_messages uclibc object {
2131 #include <features.h>
2132 #if !defined (__UCLIBC__)
2138 # Return true if this is a uclibc target and if the uclibc feature
2139 # described by __$feature__ is not present.
2141 proc check_missing_uclibc_feature {feature} {
2142 return [check_no_compiler_messages $feature object "
2143 #include <features.h>
2144 #if !defined (__UCLIBC) || defined (__${feature}__)
2150 # Return true if this is a Newlib target.
2152 proc check_effective_target_newlib {} {
2153 return [check_no_compiler_messages newlib object {
2159 # (a) an error of a few ULP is expected in string to floating-point
2160 # conversion functions; and
2161 # (b) overflow is not always detected correctly by those functions.
2163 proc check_effective_target_lax_strtofp {} {
2164 # By default, assume that all uClibc targets suffer from this.
2165 return [check_effective_target_uclibc]
2168 # Return 1 if this is a target for which wcsftime is a dummy
2169 # function that always returns 0.
2171 proc check_effective_target_dummy_wcsftime {} {
2172 # By default, assume that all uClibc targets suffer from this.
2173 return [check_effective_target_uclibc]
2176 # Return 1 if constructors with initialization priority arguments are
2177 # supposed on this target.
2179 proc check_effective_target_init_priority {} {
2180 return [check_no_compiler_messages init_priority assembly "
2181 void f() __attribute__((constructor (1000)));
2186 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2187 # This can be used with any check_* proc that takes no argument and
2188 # returns only 1 or 0. It could be used with check_* procs that take
2189 # arguments with keywords that pass particular arguments.
2191 proc is-effective-target { arg } {
2193 if { [info procs check_effective_target_${arg}] != [list] } {
2194 set selected [check_effective_target_${arg}]
2197 "vmx_hw" { set selected [check_vmx_hw_available] }
2198 "named_sections" { set selected [check_named_sections_available] }
2199 "gc_sections" { set selected [check_gc_sections_available] }
2200 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2201 default { error "unknown effective target keyword `$arg'" }
2204 verbose "is-effective-target: $arg $selected" 2
2208 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2210 proc is-effective-target-keyword { arg } {
2211 if { [info procs check_effective_target_${arg}] != [list] } {
2214 # These have different names for their check_* procs.
2216 "vmx_hw" { return 1 }
2217 "named_sections" { return 1 }
2218 "gc_sections" { return 1 }
2219 "cxa_atexit" { return 1 }
2220 default { return 0 }
2225 # Return 1 if target default to short enums
2227 proc check_effective_target_short_enums { } {
2228 return [check_no_compiler_messages short_enums assembly {
2230 int s[sizeof (enum foo) == 1 ? 1 : -1];
2234 # Return 1 if target supports merging string constants at link time.
2236 proc check_effective_target_string_merging { } {
2237 return [check_no_messages_and_pattern string_merging \
2238 "rodata\\.str" assembly {
2239 const char *var = "String";
2243 # Return 1 if target has the basic signed and unsigned types in
2244 # <stdint.h>, 0 otherwise.
2246 proc check_effective_target_stdint_types { } {
2247 return [check_no_compiler_messages stdint_types assembly {
2249 int8_t a; int16_t b; int32_t c; int64_t d;
2250 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2254 # Return 1 if programs are intended to be run on a simulator
2255 # (i.e. slowly) rather than hardware (i.e. fast).
2257 proc check_effective_target_simulator { } {
2259 # All "src/sim" simulators set this one.
2260 if [board_info target exists is_simulator] {
2261 return [board_info target is_simulator]
2264 # The "sid" simulators don't set that one, but at least they set
2266 if [board_info target exists slow_simulator] {
2267 return [board_info target slow_simulator]
2273 # Return 1 if the target is a VxWorks kernel.
2275 proc check_effective_target_vxworks_kernel { } {
2276 return [check_no_compiler_messages vxworks_kernel assembly {
2277 #if !defined __vxworks || defined __RTP__
2283 # Return 1 if the target is a VxWorks RTP.
2285 proc check_effective_target_vxworks_rtp { } {
2286 return [check_no_compiler_messages vxworks_rtp assembly {
2287 #if !defined __vxworks || !defined __RTP__
2293 # Return 1 if the target is expected to provide wide character support.
2295 proc check_effective_target_wchar { } {
2296 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2299 return [check_no_compiler_messages wchar assembly {
2304 # Return 1 if the target has <pthread.h>.
2306 proc check_effective_target_pthread_h { } {
2307 return [check_no_compiler_messages pthread_h assembly {
2308 #include <pthread.h>
2312 # Return 1 if the target can truncate a file from a file-descriptor,
2313 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2314 # chsize. We test for a trivially functional truncation; no stubs.
2315 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2316 # different function to be used.
2318 proc check_effective_target_fd_truncate { } {
2320 #define _FILE_OFFSET_BITS 64
2326 FILE *f = fopen ("tst.tmp", "wb");
2328 const char t[] = "test writing more than ten characters";
2331 write (fd, t, sizeof (t) - 1);
2333 if (ftruncate (fd, 10) != 0)
2336 f = fopen ("tst.tmp", "rb");
2337 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2343 if { [check_runtime ftruncate $prog] } {
2347 regsub "ftruncate" $prog "chsize" prog
2348 return [check_runtime chsize $prog]
2351 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2353 proc add_options_for_c99_runtime { flags } {
2354 if { [istarget *-*-solaris2*] } {
2355 return "$flags -std=c99"
2357 if { [istarget powerpc-*-darwin*] } {
2358 return "$flags -mmacosx-version-min=10.3"
2363 # Return 1 if the target provides a full C99 runtime.
2365 proc check_effective_target_c99_runtime { } {
2366 return [check_cached_effective_target c99_runtime {
2369 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2370 set contents [read $file]
2373 #ifndef HAVE_C99_RUNTIME
2377 check_no_compiler_messages_nocache c99_runtime assembly \
2378 $contents [add_options_for_c99_runtime ""]
2382 # Return 1 if target wchar_t is at least 4 bytes.
2384 proc check_effective_target_4byte_wchar_t { } {
2385 return [check_no_compiler_messages 4byte_wchar_t object {
2386 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];