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 strongarm*-*-elf]
457 || [istarget xscale*-*-elf]
458 || [istarget cris-*-*]
459 || [istarget crisv32-*-*]
460 || [istarget fido-*-elf]
461 || [istarget h8300-*-*]
462 || [istarget m32c-*-elf]
463 || [istarget m68k-*-elf]
464 || [istarget m68k-*-uclinux*]
465 || [istarget mips*-*-elf*]
466 || [istarget xstormy16-*]
467 || [istarget xtensa-*-elf]
468 || [istarget *-*-vxworks*]
469 || [istarget *-*-windiss] } {
470 set profiling_available_saved 0
472 set profiling_available_saved 1
476 return $profiling_available_saved
479 # Return 1 if target has packed layout of structure members by
480 # default, 0 otherwise. Note that this is slightly different than
481 # whether the target has "natural alignment": both attributes may be
484 proc check_effective_target_default_packed { } {
485 return [check_no_compiler_messages default_packed assembly {
486 struct x { char a; long b; } c;
487 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
491 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
492 # documentation, where the test also comes from.
494 proc check_effective_target_pcc_bitfield_type_matters { } {
495 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
496 # bitfields, but let's stick to the example code from the docs.
497 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
498 struct foo1 { char x; char :0; char y; };
499 struct foo2 { char x; int :0; char y; };
500 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
504 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
506 # This won't change for different subtargets so cache the result.
508 proc check_effective_target_tls {} {
509 return [check_no_compiler_messages tls assembly {
511 int f (void) { return i; }
512 void g (int j) { i = j; }
516 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
518 # This won't change for different subtargets so cache the result.
520 proc check_effective_target_tls_native {} {
521 # VxWorks uses emulated TLS machinery, but with non-standard helper
522 # functions, so we fail to automatically detect it.
523 global target_triplet
524 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
528 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
530 int f (void) { return i; }
531 void g (int j) { i = j; }
535 # Return 1 if TLS executables can run correctly, 0 otherwise.
537 # This won't change for different subtargets so cache the result.
539 proc check_effective_target_tls_runtime {} {
540 return [check_runtime tls_runtime {
541 __thread int thr = 0;
542 int main (void) { return thr; }
546 # Return 1 if compilation with -fopenmp is error-free for trivial
549 proc check_effective_target_fopenmp {} {
550 return [check_no_compiler_messages fopenmp object {
555 # Return 1 if compilation with -pthread is error-free for trivial
558 proc check_effective_target_pthread {} {
559 return [check_no_compiler_messages pthread object {
564 # Return 1 if the target supports -fstack-protector
565 proc check_effective_target_fstack_protector {} {
566 return [check_runtime fstack_protector {
567 int main (void) { return 0; }
568 } "-fstack-protector"]
571 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
572 # for trivial code, 0 otherwise.
574 proc check_effective_target_freorder {} {
575 return [check_no_compiler_messages freorder object {
577 } "-freorder-blocks-and-partition"]
580 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
581 # emitted, 0 otherwise. Whether a shared library can actually be built is
582 # out of scope for this test.
584 proc check_effective_target_fpic { } {
585 # Note that M68K has a multilib that supports -fpic but not
586 # -fPIC, so we need to check both. We test with a program that
587 # requires GOT references.
588 foreach arg {fpic fPIC} {
589 if [check_no_compiler_messages $arg object {
590 extern int foo (void); extern int bar;
591 int baz (void) { return foo () + bar; }
599 # Return true if the target supports -mpaired-single (as used on MIPS).
601 proc check_effective_target_mpaired_single { } {
602 return [check_no_compiler_messages mpaired_single object {
607 # Return true if the target has access to FPU instructions.
609 proc check_effective_target_hard_float { } {
610 if { [istarget mips*-*-*] } {
611 return [check_no_compiler_messages hard_float assembly {
612 #if (defined __mips_soft_float || defined __mips16)
618 # The generic test equates hard_float with "no call for adding doubles".
619 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
620 double a (double b, double c) { return b + c; }
624 # Return true if the target is a 64-bit MIPS target.
626 proc check_effective_target_mips64 { } {
627 return [check_no_compiler_messages mips64 assembly {
634 # Return true if the target is a MIPS target that does not produce
637 proc check_effective_target_nomips16 { } {
638 return [check_no_compiler_messages nomips16 object {
642 /* A cheap way of testing for -mflip-mips16. */
643 void foo (void) { asm ("addiu $20,$20,1"); }
644 void bar (void) { asm ("addiu $20,$20,1"); }
649 # Add the options needed for MIPS16 function attributes. At the moment,
650 # we don't support MIPS16 PIC.
652 proc add_options_for_mips16_attribute { flags } {
653 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
656 # Return true if we can force a mode that allows MIPS16 code generation.
657 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
660 proc check_effective_target_mips16_attribute { } {
661 return [check_no_compiler_messages mips16_attribute assembly {
665 #if defined __mips_hard_float \
666 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
667 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
670 } [add_options_for_mips16_attribute ""]]
673 # Return 1 if the current multilib does not generate PIC by default.
675 proc check_effective_target_nonpic { } {
676 return [check_no_compiler_messages nonpic assembly {
683 # Return 1 if the target does not use a status wrapper.
685 proc check_effective_target_unwrapped { } {
686 if { [target_info needs_status_wrapper] != "" \
687 && [target_info needs_status_wrapper] != "0" } {
693 # Return true if iconv is supported on the target. In particular IBM1047.
695 proc check_iconv_available { test_what } {
698 # If the tool configuration file has not set libiconv, try "-liconv"
699 if { ![info exists libiconv] } {
700 set libiconv "-liconv"
702 set test_what [lindex $test_what 1]
703 return [check_runtime_nocache $test_what [subst {
709 cd = iconv_open ("$test_what", "UTF-8");
710 if (cd == (iconv_t) -1)
717 # Return true if named sections are supported on this target.
719 proc check_named_sections_available { } {
720 return [check_no_compiler_messages named_sections assembly {
721 int __attribute__ ((section("whatever"))) foo;
725 # Return 1 if the target supports Fortran real kinds larger than real(8),
728 # When the target name changes, replace the cached result.
730 proc check_effective_target_fortran_large_real { } {
731 return [check_no_compiler_messages fortran_large_real executable {
733 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
740 # Return 1 if the target supports Fortran integer kinds larger than
741 # integer(8), 0 otherwise.
743 # When the target name changes, replace the cached result.
745 proc check_effective_target_fortran_large_int { } {
746 return [check_no_compiler_messages fortran_large_int executable {
748 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
754 # Return 1 if we can statically link libgfortran, 0 otherwise.
756 # When the target name changes, replace the cached result.
758 proc check_effective_target_static_libgfortran { } {
759 return [check_no_compiler_messages static_libgfortran executable {
766 # Return 1 if the target supports executing 750CL paired-single instructions, 0
767 # otherwise. Cache the result.
769 proc check_750cl_hw_available { } {
770 return [check_cached_effective_target 750cl_hw_available {
771 # If this is not the right target then we can skip the test.
772 if { ![istarget powerpc-*paired*] } {
775 check_runtime_nocache 750cl_hw_available {
779 asm volatile ("ps_mul v0,v0,v0");
781 asm volatile ("ps_mul 0,0,0");
790 # Return 1 if the target supports executing SSE2 instructions, 0
791 # otherwise. Cache the result.
793 proc check_sse2_hw_available { } {
794 return [check_cached_effective_target sse2_hw_available {
795 # If this is not the right target then we can skip the test.
796 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
799 check_runtime_nocache sse2_hw_available {
803 unsigned int eax, ebx, ecx, edx = 0;
804 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
805 return !(edx & bit_SSE2);
813 # Return 1 if the target supports executing AltiVec instructions, 0
814 # otherwise. Cache the result.
816 proc check_vmx_hw_available { } {
817 return [check_cached_effective_target vmx_hw_available {
818 # Some simulators are known to not support VMX instructions.
819 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
822 # Most targets don't require special flags for this test case, but
824 if { [istarget *-*-darwin*]
825 || [istarget *-*-aix*] } {
826 set options "-maltivec"
830 check_runtime_nocache vmx_hw_available {
834 asm volatile ("vor v0,v0,v0");
836 asm volatile ("vor 0,0,0");
845 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
846 # complex float arguments. This affects gfortran tests that call cabsf
847 # in libm built by an earlier compiler. Return 1 if libm uses the same
848 # argument passing as the compiler under test, 0 otherwise.
850 # When the target name changes, replace the cached result.
852 proc check_effective_target_broken_cplxf_arg { } {
853 return [check_cached_effective_target broken_cplxf_arg {
854 # Skip the work for targets known not to be affected.
855 if { ![istarget powerpc64-*-linux*] } {
857 } elseif { ![is-effective-target lp64] } {
860 check_runtime_nocache broken_cplxf_arg {
862 extern void abort (void);
864 float cabsf (_Complex float);
871 if (fabsf (f - 5.0) > 0.0001)
880 proc check_alpha_max_hw_available { } {
881 return [check_runtime alpha_max_hw_available {
882 int main() { return __builtin_alpha_amask(1<<8) != 0; }
886 # Returns true iff the FUNCTION is available on the target system.
887 # (This is essentially a Tcl implementation of Autoconf's
890 proc check_function_available { function } {
891 return [check_no_compiler_messages ${function}_available \
897 int main () { $function (); }
901 # Returns true iff "fork" is available on the target system.
903 proc check_fork_available {} {
904 return [check_function_available "fork"]
907 # Returns true iff "mkfifo" is available on the target system.
909 proc check_mkfifo_available {} {
910 if {[istarget *-*-cygwin*]} {
911 # Cygwin has mkfifo, but support is incomplete.
915 return [check_function_available "mkfifo"]
918 # Returns true iff "__cxa_atexit" is used on the target system.
920 proc check_cxa_atexit_available { } {
921 return [check_cached_effective_target cxa_atexit_available {
922 if { [istarget "hppa*-*-hpux10*"] } {
923 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
926 check_runtime_nocache cxa_atexit_available {
929 static unsigned int count;
946 Y() { f(); count = 2; }
955 int main() { return 0; }
962 # Return 1 if we're generating 32-bit code using default options, 0
965 proc check_effective_target_ilp32 { } {
966 return [check_no_compiler_messages ilp32 object {
967 int dummy[sizeof (int) == 4
968 && sizeof (void *) == 4
969 && sizeof (long) == 4 ? 1 : -1];
973 # Return 1 if we're generating 32-bit or larger integers using default
974 # options, 0 otherwise.
976 proc check_effective_target_int32plus { } {
977 return [check_no_compiler_messages int32plus object {
978 int dummy[sizeof (int) >= 4 ? 1 : -1];
982 # Return 1 if we're generating 32-bit or larger pointers using default
983 # options, 0 otherwise.
985 proc check_effective_target_ptr32plus { } {
986 return [check_no_compiler_messages ptr32plus object {
987 int dummy[sizeof (void *) >= 4 ? 1 : -1];
991 # Return 1 if we support 32-bit or larger array and structure sizes
992 # using default options, 0 otherwise.
994 proc check_effective_target_size32plus { } {
995 return [check_no_compiler_messages size32plus object {
1000 # Returns 1 if we're generating 16-bit or smaller integers with the
1001 # default options, 0 otherwise.
1003 proc check_effective_target_int16 { } {
1004 return [check_no_compiler_messages int16 object {
1005 int dummy[sizeof (int) < 4 ? 1 : -1];
1009 # Return 1 if we're generating 64-bit code using default options, 0
1012 proc check_effective_target_lp64 { } {
1013 return [check_no_compiler_messages lp64 object {
1014 int dummy[sizeof (int) == 4
1015 && sizeof (void *) == 8
1016 && sizeof (long) == 8 ? 1 : -1];
1020 # Return 1 if the target supports long double larger than double,
1023 proc check_effective_target_large_long_double { } {
1024 return [check_no_compiler_messages large_long_double object {
1025 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1029 # Return 1 if the target supports compiling fixed-point,
1032 proc check_effective_target_fixed_point { } {
1033 return [check_no_compiler_messages fixed_point object {
1034 _Sat _Fract x; _Sat _Accum y;
1038 # Return 1 if the target supports compiling decimal floating point,
1041 proc check_effective_target_dfp_nocache { } {
1042 verbose "check_effective_target_dfp_nocache: compiling source" 2
1043 set ret [check_no_compiler_messages_nocache dfp object {
1044 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1046 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1050 proc check_effective_target_dfprt_nocache { } {
1051 return [check_runtime_nocache dfprt {
1052 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1053 int main () { z = x + y; return 0; }
1057 # Return 1 if the target supports compiling Decimal Floating Point,
1060 # This won't change for different subtargets so cache the result.
1062 proc check_effective_target_dfp { } {
1063 return [check_cached_effective_target dfp {
1064 check_effective_target_dfp_nocache
1068 # Return 1 if the target supports linking and executing Decimal Floating
1069 # Point, # 0 otherwise.
1071 # This won't change for different subtargets so cache the result.
1073 proc check_effective_target_dfprt { } {
1074 return [check_cached_effective_target dfprt {
1075 check_effective_target_dfprt_nocache
1079 # Return 1 if the target needs a command line argument to enable a SIMD
1082 proc check_effective_target_vect_cmdline_needed { } {
1083 global et_vect_cmdline_needed_saved
1084 global et_vect_cmdline_needed_target_name
1086 if { ![info exists et_vect_cmdline_needed_target_name] } {
1087 set et_vect_cmdline_needed_target_name ""
1090 # If the target has changed since we set the cached value, clear it.
1091 set current_target [current_target_name]
1092 if { $current_target != $et_vect_cmdline_needed_target_name } {
1093 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1094 set et_vect_cmdline_needed_target_name $current_target
1095 if { [info exists et_vect_cmdline_needed_saved] } {
1096 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1097 unset et_vect_cmdline_needed_saved
1101 if [info exists et_vect_cmdline_needed_saved] {
1102 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1104 set et_vect_cmdline_needed_saved 1
1105 if { [istarget ia64-*-*]
1106 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1107 && [check_effective_target_lp64])
1108 || ([istarget powerpc*-*-*]
1109 && ([check_effective_target_powerpc_spe]
1110 || [check_effective_target_powerpc_altivec]))} {
1111 set et_vect_cmdline_needed_saved 0
1115 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1116 return $et_vect_cmdline_needed_saved
1119 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1121 # This won't change for different subtargets so cache the result.
1123 proc check_effective_target_vect_int { } {
1124 global et_vect_int_saved
1126 if [info exists et_vect_int_saved] {
1127 verbose "check_effective_target_vect_int: using cached result" 2
1129 set et_vect_int_saved 0
1130 if { [istarget i?86-*-*]
1131 || ([istarget powerpc*-*-*]
1132 && ![istarget powerpc-*-linux*paired*])
1133 || [istarget spu-*-*]
1134 || [istarget x86_64-*-*]
1135 || [istarget sparc*-*-*]
1136 || [istarget alpha*-*-*]
1137 || [istarget ia64-*-*] } {
1138 set et_vect_int_saved 1
1142 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1143 return $et_vect_int_saved
1146 # Return 1 if the target supports int->float conversion
1149 proc check_effective_target_vect_intfloat_cvt { } {
1150 global et_vect_intfloat_cvt_saved
1152 if [info exists et_vect_intfloat_cvt_saved] {
1153 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1155 set et_vect_intfloat_cvt_saved 0
1156 if { [istarget i?86-*-*]
1157 || ([istarget powerpc*-*-*]
1158 && ![istarget powerpc-*-linux*paired*])
1159 || [istarget x86_64-*-*] } {
1160 set et_vect_intfloat_cvt_saved 1
1164 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1165 return $et_vect_intfloat_cvt_saved
1169 # Return 1 if the target supports float->int conversion
1172 proc check_effective_target_vect_floatint_cvt { } {
1173 global et_vect_floatint_cvt_saved
1175 if [info exists et_vect_floatint_cvt_saved] {
1176 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1178 set et_vect_floatint_cvt_saved 0
1179 if { [istarget i?86-*-*]
1180 || [istarget x86_64-*-*] } {
1181 set et_vect_floatint_cvt_saved 1
1185 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1186 return $et_vect_floatint_cvt_saved
1189 # Return 1 is this is an arm target using 32-bit instructions
1190 proc check_effective_target_arm32 { } {
1191 return [check_no_compiler_messages arm32 assembly {
1192 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1198 # Return 1 if this is an ARM target supporting -mfpu=vfp
1199 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1202 proc check_effective_target_arm_vfp_ok { } {
1203 if { [check_effective_target_arm32] } {
1204 return [check_no_compiler_messages arm_vfp_ok object {
1206 } "-mfpu=vfp -mfloat-abi=softfp"]
1212 # Return 1 if this is an ARM target supporting -mfpu=neon
1213 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1216 proc check_effective_target_arm_neon_ok { } {
1217 if { [check_effective_target_arm32] } {
1218 return [check_no_compiler_messages arm_neon_ok object {
1220 } "-mfpu=neon -mfloat-abi=softfp"]
1226 # Return 1 if the target supports executing NEON instructions, 0
1227 # otherwise. Cache the result.
1229 proc check_effective_target_arm_neon_hw { } {
1230 return [check_runtime arm_neon_hw_available {
1234 long long a = 0, b = 1;
1235 asm ("vorr %P0, %P1, %P2"
1237 : "0" (a), "w" (b));
1240 } "-mfpu=neon -mfloat-abi=softfp"]
1243 # Return 1 if this is a PowerPC target with floating-point registers.
1245 proc check_effective_target_powerpc_fprs { } {
1246 if { [istarget powerpc*-*-*]
1247 || [istarget rs6000-*-*] } {
1248 return [check_no_compiler_messages powerpc_fprs object {
1260 # Return 1 if this is a PowerPC target supporting -maltivec.
1262 proc check_effective_target_powerpc_altivec_ok { } {
1263 if { ([istarget powerpc*-*-*]
1264 && ![istarget powerpc-*-linux*paired*])
1265 || [istarget rs6000-*-*] } {
1266 # AltiVec is not supported on AIX before 5.3.
1267 if { [istarget powerpc*-*-aix4*]
1268 || [istarget powerpc*-*-aix5.1*]
1269 || [istarget powerpc*-*-aix5.2*] } {
1272 return [check_no_compiler_messages powerpc_altivec_ok object {
1280 # Return 1 if this is a PowerPC target that supports SPU.
1282 proc check_effective_target_powerpc_spu { } {
1283 return [istarget powerpc*-*-linux*]
1286 # Return 1 if this is a PowerPC target with SPE enabled.
1288 proc check_effective_target_powerpc_spe { } {
1289 if { [istarget powerpc*-*-*] } {
1290 return [check_no_compiler_messages powerpc_spe object {
1302 # Return 1 if this is a PowerPC target with Altivec enabled.
1304 proc check_effective_target_powerpc_altivec { } {
1305 if { [istarget powerpc*-*-*] } {
1306 return [check_no_compiler_messages powerpc_altivec object {
1318 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1319 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1320 # test environment appears to run executables on such a simulator.
1322 proc check_effective_target_ultrasparc_hw { } {
1323 return [check_runtime ultrasparc_hw {
1324 int main() { return 0; }
1325 } "-mcpu=ultrasparc"]
1328 # Return 1 if the target supports hardware vector shift operation.
1330 proc check_effective_target_vect_shift { } {
1331 global et_vect_shift_saved
1333 if [info exists et_vect_shift_saved] {
1334 verbose "check_effective_target_vect_shift: using cached result" 2
1336 set et_vect_shift_saved 0
1337 if { ([istarget powerpc*-*-*]
1338 && ![istarget powerpc-*-linux*paired*])
1339 || [istarget ia64-*-*]
1340 || [istarget i?86-*-*]
1341 || [istarget x86_64-*-*] } {
1342 set et_vect_shift_saved 1
1346 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1347 return $et_vect_shift_saved
1350 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1352 # This can change for different subtargets so do not cache the result.
1354 proc check_effective_target_vect_long { } {
1355 if { [istarget i?86-*-*]
1356 || (([istarget powerpc*-*-*]
1357 && ![istarget powerpc-*-linux*paired*])
1358 && [check_effective_target_ilp32])
1359 || [istarget x86_64-*-*]
1360 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1366 verbose "check_effective_target_vect_long: returning $answer" 2
1370 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1372 # This won't change for different subtargets so cache the result.
1374 proc check_effective_target_vect_float { } {
1375 global et_vect_float_saved
1377 if [info exists et_vect_float_saved] {
1378 verbose "check_effective_target_vect_float: using cached result" 2
1380 set et_vect_float_saved 0
1381 if { [istarget i?86-*-*]
1382 || [istarget powerpc*-*-*]
1383 || [istarget spu-*-*]
1384 || [istarget mipsisa64*-*-*]
1385 || [istarget x86_64-*-*]
1386 || [istarget ia64-*-*] } {
1387 set et_vect_float_saved 1
1391 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1392 return $et_vect_float_saved
1395 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1397 # This won't change for different subtargets so cache the result.
1399 proc check_effective_target_vect_double { } {
1400 global et_vect_double_saved
1402 if [info exists et_vect_double_saved] {
1403 verbose "check_effective_target_vect_double: using cached result" 2
1405 set et_vect_double_saved 0
1406 if { [istarget i?86-*-*]
1407 || [istarget x86_64-*-*]
1408 || [istarget spu-*-*] } {
1409 set et_vect_double_saved 1
1413 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1414 return $et_vect_double_saved
1417 # Return 1 if the target plus current options does not support a vector
1418 # max instruction on "int", 0 otherwise.
1420 # This won't change for different subtargets so cache the result.
1422 proc check_effective_target_vect_no_int_max { } {
1423 global et_vect_no_int_max_saved
1425 if [info exists et_vect_no_int_max_saved] {
1426 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1428 set et_vect_no_int_max_saved 0
1429 if { [istarget sparc*-*-*]
1430 || [istarget spu-*-*]
1431 || [istarget alpha*-*-*] } {
1432 set et_vect_no_int_max_saved 1
1435 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1436 return $et_vect_no_int_max_saved
1439 # Return 1 if the target plus current options does not support a vector
1440 # add instruction on "int", 0 otherwise.
1442 # This won't change for different subtargets so cache the result.
1444 proc check_effective_target_vect_no_int_add { } {
1445 global et_vect_no_int_add_saved
1447 if [info exists et_vect_no_int_add_saved] {
1448 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1450 set et_vect_no_int_add_saved 0
1451 # Alpha only supports vector add on V8QI and V4HI.
1452 if { [istarget alpha*-*-*] } {
1453 set et_vect_no_int_add_saved 1
1456 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1457 return $et_vect_no_int_add_saved
1460 # Return 1 if the target plus current options does not support vector
1461 # bitwise instructions, 0 otherwise.
1463 # This won't change for different subtargets so cache the result.
1465 proc check_effective_target_vect_no_bitwise { } {
1466 global et_vect_no_bitwise_saved
1468 if [info exists et_vect_no_bitwise_saved] {
1469 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1471 set et_vect_no_bitwise_saved 0
1473 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1474 return $et_vect_no_bitwise_saved
1477 # Return 1 if the target plus current options supports a vector
1478 # widening summation of *short* args into *int* result, 0 otherwise.
1479 # A target can also support this widening summation if it can support
1480 # promotion (unpacking) from shorts to ints.
1482 # This won't change for different subtargets so cache the result.
1484 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1485 global et_vect_widen_sum_hi_to_si
1487 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1488 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1490 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1491 if { [istarget powerpc*-*-*]
1492 || [istarget ia64-*-*] } {
1493 set et_vect_widen_sum_hi_to_si_saved 1
1496 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1497 return $et_vect_widen_sum_hi_to_si_saved
1500 # Return 1 if the target plus current options supports a vector
1501 # widening summation of *char* args into *short* result, 0 otherwise.
1502 # A target can also support this widening summation if it can support
1503 # promotion (unpacking) from chars to shorts.
1505 # This won't change for different subtargets so cache the result.
1507 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1508 global et_vect_widen_sum_qi_to_hi
1510 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1511 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1513 set et_vect_widen_sum_qi_to_hi_saved 0
1514 if { [check_effective_target_vect_unpack]
1515 || [istarget ia64-*-*] } {
1516 set et_vect_widen_sum_qi_to_hi_saved 1
1519 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1520 return $et_vect_widen_sum_qi_to_hi_saved
1523 # Return 1 if the target plus current options supports a vector
1524 # widening summation of *char* args into *int* result, 0 otherwise.
1526 # This won't change for different subtargets so cache the result.
1528 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1529 global et_vect_widen_sum_qi_to_si
1531 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1532 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1534 set et_vect_widen_sum_qi_to_si_saved 0
1535 if { [istarget powerpc*-*-*] } {
1536 set et_vect_widen_sum_qi_to_si_saved 1
1539 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1540 return $et_vect_widen_sum_qi_to_si_saved
1543 # Return 1 if the target plus current options supports a vector
1544 # widening multiplication of *char* args into *short* result, 0 otherwise.
1545 # A target can also support this widening multplication if it can support
1546 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1547 # multiplication of shorts).
1549 # This won't change for different subtargets so cache the result.
1552 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1553 global et_vect_widen_mult_qi_to_hi
1555 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1556 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1558 if { [check_effective_target_vect_unpack]
1559 && [check_effective_target_vect_short_mult] } {
1560 set et_vect_widen_mult_qi_to_hi_saved 1
1562 set et_vect_widen_mult_qi_to_hi_saved 0
1564 if { [istarget powerpc*-*-*] } {
1565 set et_vect_widen_mult_qi_to_hi_saved 1
1568 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1569 return $et_vect_widen_mult_qi_to_hi_saved
1572 # Return 1 if the target plus current options supports a vector
1573 # widening multiplication of *short* args into *int* result, 0 otherwise.
1574 # A target can also support this widening multplication if it can support
1575 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1576 # multiplication of ints).
1578 # This won't change for different subtargets so cache the result.
1581 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1582 global et_vect_widen_mult_hi_to_si
1584 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1585 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1587 if { [check_effective_target_vect_unpack]
1588 && [check_effective_target_vect_int_mult] } {
1589 set et_vect_widen_mult_hi_to_si_saved 1
1591 set et_vect_widen_mult_hi_to_si_saved 0
1593 if { [istarget powerpc*-*-*]
1594 || [istarget spu-*-*]
1595 || [istarget i?86-*-*]
1596 || [istarget x86_64-*-*] } {
1597 set et_vect_widen_mult_hi_to_si_saved 1
1600 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1601 return $et_vect_widen_mult_hi_to_si_saved
1604 # Return 1 if the target plus current options supports a vector
1605 # dot-product of signed chars, 0 otherwise.
1607 # This won't change for different subtargets so cache the result.
1609 proc check_effective_target_vect_sdot_qi { } {
1610 global et_vect_sdot_qi
1612 if [info exists et_vect_sdot_qi_saved] {
1613 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1615 set et_vect_sdot_qi_saved 0
1617 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1618 return $et_vect_sdot_qi_saved
1621 # Return 1 if the target plus current options supports a vector
1622 # dot-product of unsigned chars, 0 otherwise.
1624 # This won't change for different subtargets so cache the result.
1626 proc check_effective_target_vect_udot_qi { } {
1627 global et_vect_udot_qi
1629 if [info exists et_vect_udot_qi_saved] {
1630 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1632 set et_vect_udot_qi_saved 0
1633 if { [istarget powerpc*-*-*] } {
1634 set et_vect_udot_qi_saved 1
1637 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1638 return $et_vect_udot_qi_saved
1641 # Return 1 if the target plus current options supports a vector
1642 # dot-product of signed shorts, 0 otherwise.
1644 # This won't change for different subtargets so cache the result.
1646 proc check_effective_target_vect_sdot_hi { } {
1647 global et_vect_sdot_hi
1649 if [info exists et_vect_sdot_hi_saved] {
1650 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1652 set et_vect_sdot_hi_saved 0
1653 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1654 || [istarget i?86-*-*]
1655 || [istarget x86_64-*-*] } {
1656 set et_vect_sdot_hi_saved 1
1659 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1660 return $et_vect_sdot_hi_saved
1663 # Return 1 if the target plus current options supports a vector
1664 # dot-product of unsigned shorts, 0 otherwise.
1666 # This won't change for different subtargets so cache the result.
1668 proc check_effective_target_vect_udot_hi { } {
1669 global et_vect_udot_hi
1671 if [info exists et_vect_udot_hi_saved] {
1672 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1674 set et_vect_udot_hi_saved 0
1675 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1676 set et_vect_udot_hi_saved 1
1679 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1680 return $et_vect_udot_hi_saved
1684 # Return 1 if the target plus current options supports a vector
1685 # demotion (packing) of shorts (to chars) and ints (to shorts)
1686 # using modulo arithmetic, 0 otherwise.
1688 # This won't change for different subtargets so cache the result.
1690 proc check_effective_target_vect_pack_trunc { } {
1691 global et_vect_pack_trunc
1693 if [info exists et_vect_pack_trunc_saved] {
1694 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1696 set et_vect_pack_trunc_saved 0
1697 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1698 || [istarget i?86-*-*]
1699 || [istarget x86_64-*-*] } {
1700 set et_vect_pack_trunc_saved 1
1703 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1704 return $et_vect_pack_trunc_saved
1707 # Return 1 if the target plus current options supports a vector
1708 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1710 # This won't change for different subtargets so cache the result.
1712 proc check_effective_target_vect_unpack { } {
1713 global et_vect_unpack
1715 if [info exists et_vect_unpack_saved] {
1716 verbose "check_effective_target_vect_unpack: using cached result" 2
1718 set et_vect_unpack_saved 0
1719 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1720 || [istarget i?86-*-*]
1721 || [istarget x86_64-*-*]
1722 || [istarget spu-*-*] } {
1723 set et_vect_unpack_saved 1
1726 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1727 return $et_vect_unpack_saved
1730 # Return 1 if the target plus current options does not guarantee
1731 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1733 # This won't change for different subtargets so cache the result.
1735 proc check_effective_target_unaligned_stack { } {
1736 global et_unaligned_stack_saved
1738 if [info exists et_unaligned_stack_saved] {
1739 verbose "check_effective_target_unaligned_stack: using cached result" 2
1741 set et_unaligned_stack_saved 0
1742 if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] )
1743 && (! [istarget *-*-darwin*] ) } {
1744 set et_unaligned_stack_saved 1
1747 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1748 return $et_unaligned_stack_saved
1751 # Return 1 if the target plus current options does not support a vector
1752 # alignment mechanism, 0 otherwise.
1754 # This won't change for different subtargets so cache the result.
1756 proc check_effective_target_vect_no_align { } {
1757 global et_vect_no_align_saved
1759 if [info exists et_vect_no_align_saved] {
1760 verbose "check_effective_target_vect_no_align: using cached result" 2
1762 set et_vect_no_align_saved 0
1763 if { [istarget mipsisa64*-*-*]
1764 || [istarget sparc*-*-*]
1765 || [istarget ia64-*-*] } {
1766 set et_vect_no_align_saved 1
1769 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1770 return $et_vect_no_align_saved
1773 # Return 1 if arrays are aligned to the vector alignment
1774 # boundary, 0 otherwise.
1776 # This won't change for different subtargets so cache the result.
1778 proc check_effective_target_vect_aligned_arrays { } {
1779 global et_vect_aligned_arrays
1781 if [info exists et_vect_aligned_arrays_saved] {
1782 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1784 set et_vect_aligned_arrays_saved 0
1785 if { (([istarget x86_64-*-*]
1786 || [istarget i?86-*-*]) && [is-effective-target lp64])
1787 || [istarget spu-*-*] } {
1788 set et_vect_aligned_arrays_saved 1
1791 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1792 return $et_vect_aligned_arrays_saved
1795 # Return 1 if types of size 32 bit or less are naturally aligned
1796 # (aligned to their type-size), 0 otherwise.
1798 # This won't change for different subtargets so cache the result.
1800 proc check_effective_target_natural_alignment_32 { } {
1801 global et_natural_alignment_32
1803 if [info exists et_natural_alignment_32_saved] {
1804 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1806 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
1807 set et_natural_alignment_32_saved 1
1808 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
1809 set et_natural_alignment_32_saved 0
1812 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
1813 return $et_natural_alignment_32_saved
1816 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
1817 # type-size), 0 otherwise.
1819 # This won't change for different subtargets so cache the result.
1821 proc check_effective_target_natural_alignment_64 { } {
1822 global et_natural_alignment_64
1824 if [info exists et_natural_alignment_64_saved] {
1825 verbose "check_effective_target_natural_alignment_64: using cached result" 2
1827 set et_natural_alignment_64_saved 0
1828 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
1829 || [istarget spu-*-*] } {
1830 set et_natural_alignment_64_saved 1
1833 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
1834 return $et_natural_alignment_64_saved
1837 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
1839 # This won't change for different subtargets so cache the result.
1841 proc check_effective_target_vector_alignment_reachable { } {
1842 global et_vector_alignment_reachable
1844 if [info exists et_vector_alignment_reachable_saved] {
1845 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
1847 if { [check_effective_target_vect_aligned_arrays]
1848 || [check_effective_target_natural_alignment_32] } {
1849 set et_vector_alignment_reachable_saved 1
1851 set et_vector_alignment_reachable_saved 0
1854 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
1855 return $et_vector_alignment_reachable_saved
1858 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
1860 # This won't change for different subtargets so cache the result.
1862 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
1863 global et_vector_alignment_reachable_for_64bit
1865 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
1866 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
1868 if { [check_effective_target_vect_aligned_arrays]
1869 || [check_effective_target_natural_alignment_64] } {
1870 set et_vector_alignment_reachable_for_64bit_saved 1
1872 set et_vector_alignment_reachable_for_64bit_saved 0
1875 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
1876 return $et_vector_alignment_reachable_for_64bit_saved
1879 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1881 proc check_effective_target_vect_condition { } {
1882 global et_vect_cond_saved
1884 if [info exists et_vect_cond_saved] {
1885 verbose "check_effective_target_vect_cond: using cached result" 2
1887 set et_vect_cond_saved 0
1888 if { [istarget powerpc*-*-*]
1889 || [istarget ia64-*-*]
1890 || [istarget i?86-*-*]
1891 || [istarget spu-*-*]
1892 || [istarget x86_64-*-*] } {
1893 set et_vect_cond_saved 1
1897 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1898 return $et_vect_cond_saved
1901 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1903 proc check_effective_target_vect_char_mult { } {
1904 global et_vect_char_mult_saved
1906 if [info exists et_vect_char_mult_saved] {
1907 verbose "check_effective_target_vect_char_mult: using cached result" 2
1909 set et_vect_char_mult_saved 0
1910 if { [istarget ia64-*-*]
1911 || [istarget i?86-*-*]
1912 || [istarget x86_64-*-*] } {
1913 set et_vect_char_mult_saved 1
1917 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1918 return $et_vect_char_mult_saved
1921 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1923 proc check_effective_target_vect_short_mult { } {
1924 global et_vect_short_mult_saved
1926 if [info exists et_vect_short_mult_saved] {
1927 verbose "check_effective_target_vect_short_mult: using cached result" 2
1929 set et_vect_short_mult_saved 0
1930 if { [istarget ia64-*-*]
1931 || [istarget spu-*-*]
1932 || [istarget i?86-*-*]
1933 || [istarget x86_64-*-*] } {
1934 set et_vect_short_mult_saved 1
1938 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1939 return $et_vect_short_mult_saved
1942 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1944 proc check_effective_target_vect_int_mult { } {
1945 global et_vect_int_mult_saved
1947 if [info exists et_vect_int_mult_saved] {
1948 verbose "check_effective_target_vect_int_mult: using cached result" 2
1950 set et_vect_int_mult_saved 0
1951 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1952 || [istarget spu-*-*]
1953 || [istarget i?86-*-*]
1954 || [istarget x86_64-*-*] } {
1955 set et_vect_int_mult_saved 1
1959 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1960 return $et_vect_int_mult_saved
1963 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
1965 proc check_effective_target_vect_extract_even_odd { } {
1966 global et_vect_extract_even_odd_saved
1968 if [info exists et_vect_extract_even_odd_saved] {
1969 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
1971 set et_vect_extract_even_odd_saved 0
1972 if { [istarget powerpc*-*-*] } {
1973 set et_vect_extract_even_odd_saved 1
1977 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
1978 return $et_vect_extract_even_odd_saved
1981 # Return 1 if the target supports vector interleaving, 0 otherwise.
1983 proc check_effective_target_vect_interleave { } {
1984 global et_vect_interleave_saved
1986 if [info exists et_vect_interleave_saved] {
1987 verbose "check_effective_target_vect_interleave: using cached result" 2
1989 set et_vect_interleave_saved 0
1990 if { [istarget powerpc*-*-*]
1991 || [istarget i?86-*-*]
1992 || [istarget x86_64-*-*] } {
1993 set et_vect_interleave_saved 1
1997 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
1998 return $et_vect_interleave_saved
2001 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2002 proc check_effective_target_vect_strided { } {
2003 global et_vect_strided_saved
2005 if [info exists et_vect_strided_saved] {
2006 verbose "check_effective_target_vect_strided: using cached result" 2
2008 set et_vect_strided_saved 0
2009 if { [check_effective_target_vect_interleave]
2010 && [check_effective_target_vect_extract_even_odd] } {
2011 set et_vect_strided_saved 1
2015 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2016 return $et_vect_strided_saved
2019 # Return 1 if the target supports section-anchors
2021 proc check_effective_target_section_anchors { } {
2022 global et_section_anchors_saved
2024 if [info exists et_section_anchors_saved] {
2025 verbose "check_effective_target_section_anchors: using cached result" 2
2027 set et_section_anchors_saved 0
2028 if { [istarget powerpc*-*-*] } {
2029 set et_section_anchors_saved 1
2033 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2034 return $et_section_anchors_saved
2037 # Return 1 if the target supports atomic operations on "int" and "long".
2039 proc check_effective_target_sync_int_long { } {
2040 global et_sync_int_long_saved
2042 if [info exists et_sync_int_long_saved] {
2043 verbose "check_effective_target_sync_int_long: using cached result" 2
2045 set et_sync_int_long_saved 0
2046 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2047 # load-reserved/store-conditional instructions.
2048 if { [istarget ia64-*-*]
2049 || [istarget i?86-*-*]
2050 || [istarget x86_64-*-*]
2051 || [istarget alpha*-*-*]
2052 || [istarget s390*-*-*]
2053 || [istarget powerpc*-*-*]
2054 || [istarget sparc64-*-*]
2055 || [istarget sparcv9-*-*]
2056 || [istarget mips*-*-*] } {
2057 set et_sync_int_long_saved 1
2061 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2062 return $et_sync_int_long_saved
2065 # Return 1 if the target supports atomic operations on "char" and "short".
2067 proc check_effective_target_sync_char_short { } {
2068 global et_sync_char_short_saved
2070 if [info exists et_sync_char_short_saved] {
2071 verbose "check_effective_target_sync_char_short: using cached result" 2
2073 set et_sync_char_short_saved 0
2074 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2075 # load-reserved/store-conditional instructions.
2076 if { [istarget ia64-*-*]
2077 || [istarget i?86-*-*]
2078 || [istarget x86_64-*-*]
2079 || [istarget alpha*-*-*]
2080 || [istarget s390*-*-*]
2081 || [istarget powerpc*-*-*]
2082 || [istarget sparc64-*-*]
2083 || [istarget sparcv9-*-*]
2084 || [istarget mips*-*-*] } {
2085 set et_sync_char_short_saved 1
2089 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2090 return $et_sync_char_short_saved
2093 # Return 1 if the target uses a ColdFire FPU.
2095 proc check_effective_target_coldfire_fpu { } {
2096 return [check_no_compiler_messages coldfire_fpu assembly {
2103 # Return true if this is a uClibc target.
2105 proc check_effective_target_uclibc {} {
2106 return [check_no_compiler_messages uclibc object {
2107 #include <features.h>
2108 #if !defined (__UCLIBC__)
2114 # Return true if this is a uclibc target and if the uclibc feature
2115 # described by __$feature__ is not present.
2117 proc check_missing_uclibc_feature {feature} {
2118 return [check_no_compiler_messages $feature object "
2119 #include <features.h>
2120 #if !defined (__UCLIBC) || defined (__${feature}__)
2126 # Return true if this is a Newlib target.
2128 proc check_effective_target_newlib {} {
2129 return [check_no_compiler_messages newlib object {
2135 # (a) an error of a few ULP is expected in string to floating-point
2136 # conversion functions; and
2137 # (b) overflow is not always detected correctly by those functions.
2139 proc check_effective_target_lax_strtofp {} {
2140 # By default, assume that all uClibc targets suffer from this.
2141 return [check_effective_target_uclibc]
2144 # Return 1 if this is a target for which wcsftime is a dummy
2145 # function that always returns 0.
2147 proc check_effective_target_dummy_wcsftime {} {
2148 # By default, assume that all uClibc targets suffer from this.
2149 return [check_effective_target_uclibc]
2152 # Return 1 if constructors with initialization priority arguments are
2153 # supposed on this target.
2155 proc check_effective_target_init_priority {} {
2156 return [check_no_compiler_messages init_priority assembly "
2157 void f() __attribute__((constructor (1000)));
2162 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2163 # This can be used with any check_* proc that takes no argument and
2164 # returns only 1 or 0. It could be used with check_* procs that take
2165 # arguments with keywords that pass particular arguments.
2167 proc is-effective-target { arg } {
2169 if { [info procs check_effective_target_${arg}] != [list] } {
2170 set selected [check_effective_target_${arg}]
2173 "vmx_hw" { set selected [check_vmx_hw_available] }
2174 "named_sections" { set selected [check_named_sections_available] }
2175 "gc_sections" { set selected [check_gc_sections_available] }
2176 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2177 default { error "unknown effective target keyword `$arg'" }
2180 verbose "is-effective-target: $arg $selected" 2
2184 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2186 proc is-effective-target-keyword { arg } {
2187 if { [info procs check_effective_target_${arg}] != [list] } {
2190 # These have different names for their check_* procs.
2192 "vmx_hw" { return 1 }
2193 "named_sections" { return 1 }
2194 "gc_sections" { return 1 }
2195 "cxa_atexit" { return 1 }
2196 default { return 0 }
2201 # Return 1 if target default to short enums
2203 proc check_effective_target_short_enums { } {
2204 return [check_no_compiler_messages short_enums assembly {
2206 int s[sizeof (enum foo) == 1 ? 1 : -1];
2210 # Return 1 if target supports merging string constants at link time.
2212 proc check_effective_target_string_merging { } {
2213 return [check_no_messages_and_pattern string_merging \
2214 "rodata\\.str" assembly {
2215 const char *var = "String";
2219 # Return 1 if target has the basic signed and unsigned types in
2220 # <stdint.h>, 0 otherwise.
2222 proc check_effective_target_stdint_types { } {
2223 return [check_no_compiler_messages stdint_types assembly {
2225 int8_t a; int16_t b; int32_t c; int64_t d;
2226 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2230 # Return 1 if programs are intended to be run on a simulator
2231 # (i.e. slowly) rather than hardware (i.e. fast).
2233 proc check_effective_target_simulator { } {
2235 # All "src/sim" simulators set this one.
2236 if [board_info target exists is_simulator] {
2237 return [board_info target is_simulator]
2240 # The "sid" simulators don't set that one, but at least they set
2242 if [board_info target exists slow_simulator] {
2243 return [board_info target slow_simulator]
2249 # Return 1 if the target is a VxWorks kernel.
2251 proc check_effective_target_vxworks_kernel { } {
2252 return [check_no_compiler_messages vxworks_kernel assembly {
2253 #if !defined __vxworks || defined __RTP__
2259 # Return 1 if the target is a VxWorks RTP.
2261 proc check_effective_target_vxworks_rtp { } {
2262 return [check_no_compiler_messages vxworks_rtp assembly {
2263 #if !defined __vxworks || !defined __RTP__
2269 # Return 1 if the target is expected to provide wide character support.
2271 proc check_effective_target_wchar { } {
2272 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2275 return [check_no_compiler_messages wchar assembly {
2280 # Return 1 if the target has <pthread.h>.
2282 proc check_effective_target_pthread_h { } {
2283 return [check_no_compiler_messages pthread_h assembly {
2284 #include <pthread.h>
2288 # Return 1 if the target can truncate a file from a file-descriptor,
2289 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2290 # chsize. We test for a trivially functional truncation; no stubs.
2291 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2292 # different function to be used.
2294 proc check_effective_target_fd_truncate { } {
2296 #define _FILE_OFFSET_BITS 64
2302 FILE *f = fopen ("tst.tmp", "wb");
2304 const char t[] = "test writing more than ten characters";
2307 write (fd, t, sizeof (t) - 1);
2309 if (ftruncate (fd, 10) != 0)
2312 f = fopen ("tst.tmp", "rb");
2313 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2319 if { [check_runtime ftruncate $prog] } {
2323 regsub "ftruncate" $prog "chsize" prog
2324 return [check_runtime chsize $prog]
2327 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2329 proc add_options_for_c99_runtime { flags } {
2330 if { [istarget *-*-solaris2*] } {
2331 return "$flags -std=c99"
2333 if { [istarget powerpc-*-darwin*] } {
2334 return "$flags -mmacosx-version-min=10.3"
2339 # Return 1 if the target provides a full C99 runtime.
2341 proc check_effective_target_c99_runtime { } {
2342 return [check_cached_effective_target c99_runtime {
2345 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2346 set contents [read $file]
2349 #ifndef HAVE_C99_RUNTIME
2353 check_no_compiler_messages_nocache c99_runtime assembly \
2354 $contents [add_options_for_c99_runtime ""]
2358 # Return 1 if target wchar_t is at least 4 bytes.
2360 proc check_effective_target_4byte_wchar_t { } {
2361 return [check_no_compiler_messages 4byte_wchar_t object {
2362 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];