1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009
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_weak_override_available { }
255 ###############################
257 # Like check_weak_available, but return 0 if weak symbol definitions
258 # cannot be overridden.
260 proc check_weak_override_available { } {
261 if { [istarget "*-*-mingw*"] } {
264 return [check_weak_available]
267 ###############################
268 # proc check_visibility_available { what_kind }
269 ###############################
271 # The visibility attribute is only support in some object formats
272 # This proc returns 1 if it is supported, 0 if not.
273 # The argument is the kind of visibility, default/protected/hidden/internal.
275 proc check_visibility_available { what_kind } {
277 global target_triplet
279 # On NetWare, support makes no sense.
280 if { [istarget *-*-netware*] } {
284 if [string match "" $what_kind] { set what_kind "hidden" }
286 return [check_no_compiler_messages visibility_available_$what_kind object "
287 void f() __attribute__((visibility(\"$what_kind\")));
292 ###############################
293 # proc check_alias_available { }
294 ###############################
296 # Determine if the target toolchain supports the alias attribute.
298 # Returns 2 if the target supports aliases. Returns 1 if the target
299 # only supports weak aliased. Returns 0 if the target does not
300 # support aliases at all. Returns -1 if support for aliases could not
303 proc check_alias_available { } {
304 global alias_available_saved
307 if [info exists alias_available_saved] {
308 verbose "check_alias_available returning saved $alias_available_saved" 2
312 verbose "check_alias_available compiling testfile $src" 2
313 set f [open $src "w"]
314 # Compile a small test program. The definition of "g" is
315 # necessary to keep the Solaris assembler from complaining
317 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
318 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
320 set lines [${tool}_target_compile $src $obj object ""]
322 remote_file build delete $obj
324 if [string match "" $lines] then {
325 # No error messages, everything is OK.
326 set alias_available_saved 2
328 if [regexp "alias definitions not supported" $lines] {
329 verbose "check_alias_available target does not support aliases" 2
331 set objformat [gcc_target_object_format]
333 if { $objformat == "elf" } {
334 verbose "check_alias_available but target uses ELF format, so it ought to" 2
335 set alias_available_saved -1
337 set alias_available_saved 0
340 if [regexp "only weak aliases are supported" $lines] {
341 verbose "check_alias_available target supports only weak aliases" 2
342 set alias_available_saved 1
344 set alias_available_saved -1
349 verbose "check_alias_available returning $alias_available_saved" 2
352 return $alias_available_saved
355 # Returns true if --gc-sections is supported on the target.
357 proc check_gc_sections_available { } {
358 global gc_sections_available_saved
361 if {![info exists gc_sections_available_saved]} {
362 # Some targets don't support gc-sections despite whatever's
363 # advertised by ld's options.
364 if { [istarget alpha*-*-*]
365 || [istarget ia64-*-*] } {
366 set gc_sections_available_saved 0
370 # elf2flt uses -q (--emit-relocs), which is incompatible with
372 if { [board_info target exists ldflags]
373 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
374 set gc_sections_available_saved 0
378 # VxWorks kernel modules are relocatable objects linked with -r,
379 # while RTP executables are linked with -q (--emit-relocs).
380 # Both of these options are incompatible with --gc-sections.
381 if { [istarget *-*-vxworks*] } {
382 set gc_sections_available_saved 0
386 # Check if the ld used by gcc supports --gc-sections.
387 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
388 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
389 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
390 set ld_output [remote_exec host "$gcc_ld" "--help"]
391 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
392 set gc_sections_available_saved 1
394 set gc_sections_available_saved 0
397 return $gc_sections_available_saved
400 # Return 1 if according to target_info struct and explicit target list
401 # target is supposed to support trampolines.
403 proc check_effective_target_trampolines { } {
404 if [target_info exists no_trampolines] {
407 if { [istarget avr-*-*]
408 || [istarget hppa2.0w-hp-hpux11.23]
409 || [istarget hppa64-hp-hpux11.23] } {
415 # Return 1 if according to target_info struct and explicit target list
416 # target is supposed to keep null pointer checks. This could be due to
417 # use of option fno-delete-null-pointer-checks or hardwired in target.
419 proc check_effective_target_keeps_null_pointer_checks { } {
420 if [target_info exists keeps_null_pointer_checks] {
423 if { [istarget avr-*-*] } {
429 # Return true if profiling is supported on the target.
431 proc check_profiling_available { test_what } {
432 global profiling_available_saved
434 verbose "Profiling argument is <$test_what>" 1
436 # These conditions depend on the argument so examine them before
437 # looking at the cache variable.
439 # Support for -p on solaris2 relies on mcrt1.o which comes with the
440 # vendor compiler. We cannot reliably predict the directory where the
441 # vendor compiler (and thus mcrt1.o) is installed so we can't
442 # necessarily find mcrt1.o even if we have it.
443 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
447 # Support for -p on irix relies on libprof1.a which doesn't appear to
448 # exist on any irix6 system currently posting testsuite results.
449 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
450 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
451 if { [istarget mips*-*-irix*]
452 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
456 # We don't yet support profiling for MIPS16.
457 if { [istarget mips*-*-*]
458 && ![check_effective_target_nomips16]
459 && ([lindex $test_what 1] == "-p"
460 || [lindex $test_what 1] == "-pg") } {
464 # MinGW does not support -p.
465 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
469 # cygwin does not support -p.
470 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
474 # uClibc does not have gcrt1.o.
475 if { [check_effective_target_uclibc]
476 && ([lindex $test_what 1] == "-p"
477 || [lindex $test_what 1] == "-pg") } {
481 # Now examine the cache variable.
482 if {![info exists profiling_available_saved]} {
483 # Some targets don't have any implementation of __bb_init_func or are
484 # missing other needed machinery.
485 if { [istarget mmix-*-*]
486 || [istarget arm*-*-eabi*]
487 || [istarget picochip-*-*]
488 || [istarget *-*-netware*]
489 || [istarget arm*-*-elf]
490 || [istarget arm*-*-symbianelf*]
491 || [istarget avr-*-*]
492 || [istarget bfin-*-*]
493 || [istarget powerpc-*-eabi*]
494 || [istarget cris-*-*]
495 || [istarget crisv32-*-*]
496 || [istarget fido-*-elf]
497 || [istarget h8300-*-*]
498 || [istarget m32c-*-elf]
499 || [istarget m68k-*-elf]
500 || [istarget m68k-*-uclinux*]
501 || [istarget mep-*-elf]
502 || [istarget mips*-*-elf*]
503 || [istarget moxie-*-elf*]
504 || [istarget xstormy16-*]
505 || [istarget xtensa*-*-elf]
506 || [istarget *-*-rtems*]
507 || [istarget *-*-vxworks*] } {
508 set profiling_available_saved 0
510 set profiling_available_saved 1
514 return $profiling_available_saved
517 # Check to see if a target is "freestanding". This is as per the definition
518 # in Section 4 of C99 standard. Effectively, it is a target which supports no
519 # extra headers or libraries other than what is considered essential.
520 proc check_effective_target_freestanding { } {
521 if { [istarget picochip-*-*] } then {
528 # Return 1 if target has packed layout of structure members by
529 # default, 0 otherwise. Note that this is slightly different than
530 # whether the target has "natural alignment": both attributes may be
533 proc check_effective_target_default_packed { } {
534 return [check_no_compiler_messages default_packed assembly {
535 struct x { char a; long b; } c;
536 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
540 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
541 # documentation, where the test also comes from.
543 proc check_effective_target_pcc_bitfield_type_matters { } {
544 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
545 # bitfields, but let's stick to the example code from the docs.
546 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
547 struct foo1 { char x; char :0; char y; };
548 struct foo2 { char x; int :0; char y; };
549 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
553 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
555 proc check_effective_target_tls {} {
556 return [check_no_compiler_messages tls assembly {
558 int f (void) { return i; }
559 void g (int j) { i = j; }
563 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
565 proc check_effective_target_tls_native {} {
566 # VxWorks uses emulated TLS machinery, but with non-standard helper
567 # functions, so we fail to automatically detect it.
568 global target_triplet
569 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
573 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
575 int f (void) { return i; }
576 void g (int j) { i = j; }
580 # Return 1 if TLS executables can run correctly, 0 otherwise.
582 proc check_effective_target_tls_runtime {} {
583 return [check_runtime tls_runtime {
584 __thread int thr = 0;
585 int main (void) { return thr; }
589 # Return 1 if compilation with -fgraphite is error-free for trivial
592 proc check_effective_target_fgraphite {} {
593 return [check_no_compiler_messages fgraphite object {
598 # Return 1 if compilation with -fopenmp is error-free for trivial
601 proc check_effective_target_fopenmp {} {
602 return [check_no_compiler_messages fopenmp object {
607 # Return 1 if compilation with -pthread is error-free for trivial
610 proc check_effective_target_pthread {} {
611 return [check_no_compiler_messages pthread object {
616 # Return 1 if compilation with -mpe-aligned-commons is error-free
617 # for trivial code, 0 otherwise.
619 proc check_effective_target_pe_aligned_commons {} {
620 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
621 return [check_no_compiler_messages pe_aligned_commons object {
623 } "-mpe-aligned-commons"]
628 # Return 1 if the target supports -static
629 proc check_effective_target_static {} {
630 return [check_no_compiler_messages static executable {
631 int main (void) { return 0; }
635 # Return 1 if the target supports -fstack-protector
636 proc check_effective_target_fstack_protector {} {
637 return [check_runtime fstack_protector {
638 int main (void) { return 0; }
639 } "-fstack-protector"]
642 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
643 # for trivial code, 0 otherwise.
645 proc check_effective_target_freorder {} {
646 return [check_no_compiler_messages freorder object {
648 } "-freorder-blocks-and-partition"]
651 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
652 # emitted, 0 otherwise. Whether a shared library can actually be built is
653 # out of scope for this test.
655 proc check_effective_target_fpic { } {
656 # Note that M68K has a multilib that supports -fpic but not
657 # -fPIC, so we need to check both. We test with a program that
658 # requires GOT references.
659 foreach arg {fpic fPIC} {
660 if [check_no_compiler_messages $arg object {
661 extern int foo (void); extern int bar;
662 int baz (void) { return foo () + bar; }
670 # Return true if the target supports -mpaired-single (as used on MIPS).
672 proc check_effective_target_mpaired_single { } {
673 return [check_no_compiler_messages mpaired_single object {
678 # Return true if the target has access to FPU instructions.
680 proc check_effective_target_hard_float { } {
681 if { [istarget mips*-*-*] } {
682 return [check_no_compiler_messages hard_float assembly {
683 #if (defined __mips_soft_float || defined __mips16)
689 # The generic test equates hard_float with "no call for adding doubles".
690 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
691 double a (double b, double c) { return b + c; }
695 # Return true if the target is a 64-bit MIPS target.
697 proc check_effective_target_mips64 { } {
698 return [check_no_compiler_messages mips64 assembly {
705 # Return true if the target is a MIPS target that does not produce
708 proc check_effective_target_nomips16 { } {
709 return [check_no_compiler_messages nomips16 object {
713 /* A cheap way of testing for -mflip-mips16. */
714 void foo (void) { asm ("addiu $20,$20,1"); }
715 void bar (void) { asm ("addiu $20,$20,1"); }
720 # Add the options needed for MIPS16 function attributes. At the moment,
721 # we don't support MIPS16 PIC.
723 proc add_options_for_mips16_attribute { flags } {
724 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
727 # Return true if we can force a mode that allows MIPS16 code generation.
728 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
731 proc check_effective_target_mips16_attribute { } {
732 return [check_no_compiler_messages mips16_attribute assembly {
736 #if defined __mips_hard_float \
737 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
738 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
741 } [add_options_for_mips16_attribute ""]]
744 # Return 1 if the target supports long double larger than double when
745 # using the new ABI, 0 otherwise.
747 proc check_effective_target_mips_newabi_large_long_double { } {
748 return [check_no_compiler_messages mips_newabi_large_long_double object {
749 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
753 # Return 1 if the current multilib does not generate PIC by default.
755 proc check_effective_target_nonpic { } {
756 return [check_no_compiler_messages nonpic assembly {
763 # Return 1 if the target does not use a status wrapper.
765 proc check_effective_target_unwrapped { } {
766 if { [target_info needs_status_wrapper] != "" \
767 && [target_info needs_status_wrapper] != "0" } {
773 # Return true if iconv is supported on the target. In particular IBM1047.
775 proc check_iconv_available { test_what } {
778 # If the tool configuration file has not set libiconv, try "-liconv"
779 if { ![info exists libiconv] } {
780 set libiconv "-liconv"
782 set test_what [lindex $test_what 1]
783 return [check_runtime_nocache $test_what [subst {
789 cd = iconv_open ("$test_what", "UTF-8");
790 if (cd == (iconv_t) -1)
797 # Return true if named sections are supported on this target.
799 proc check_named_sections_available { } {
800 return [check_no_compiler_messages named_sections assembly {
801 int __attribute__ ((section("whatever"))) foo;
805 # Return 1 if the target supports Fortran real kinds larger than real(8),
808 # When the target name changes, replace the cached result.
810 proc check_effective_target_fortran_large_real { } {
811 return [check_no_compiler_messages fortran_large_real executable {
813 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
820 # Return 1 if the target supports Fortran integer kinds larger than
821 # integer(8), 0 otherwise.
823 # When the target name changes, replace the cached result.
825 proc check_effective_target_fortran_large_int { } {
826 return [check_no_compiler_messages fortran_large_int executable {
828 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
834 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
836 # When the target name changes, replace the cached result.
838 proc check_effective_target_fortran_integer_16 { } {
839 return [check_no_compiler_messages fortran_integer_16 executable {
846 # Return 1 if we can statically link libgfortran, 0 otherwise.
848 # When the target name changes, replace the cached result.
850 proc check_effective_target_static_libgfortran { } {
851 return [check_no_compiler_messages static_libgfortran executable {
858 # Return 1 if the target supports executing 750CL paired-single instructions, 0
859 # otherwise. Cache the result.
861 proc check_750cl_hw_available { } {
862 return [check_cached_effective_target 750cl_hw_available {
863 # If this is not the right target then we can skip the test.
864 if { ![istarget powerpc-*paired*] } {
867 check_runtime_nocache 750cl_hw_available {
871 asm volatile ("ps_mul v0,v0,v0");
873 asm volatile ("ps_mul 0,0,0");
882 # Return 1 if the target supports executing SSE2 instructions, 0
883 # otherwise. Cache the result.
885 proc check_sse2_hw_available { } {
886 return [check_cached_effective_target sse2_hw_available {
887 # If this is not the right target then we can skip the test.
888 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
891 check_runtime_nocache sse2_hw_available {
895 unsigned int eax, ebx, ecx, edx = 0;
896 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
897 return !(edx & bit_SSE2);
905 # Return 1 if the target supports executing VSX instructions, 0
906 # otherwise. Cache the result.
908 proc check_vsx_hw_available { } {
909 return [check_cached_effective_target vsx_hw_available {
910 # Some simulators are known to not support VSX instructions.
911 # For now, disable on Darwin
912 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
916 check_runtime_nocache vsx_hw_available {
920 asm volatile ("xxlor vs0,vs0,vs0");
922 asm volatile ("xxlor 0,0,0");
931 # Return 1 if the target supports executing AltiVec instructions, 0
932 # otherwise. Cache the result.
934 proc check_vmx_hw_available { } {
935 return [check_cached_effective_target vmx_hw_available {
936 # Some simulators are known to not support VMX instructions.
937 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
940 # Most targets don't require special flags for this test case, but
941 # Darwin does. Just to be sure, make sure VSX is not enabled for
943 if { [istarget *-*-darwin*]
944 || [istarget *-*-aix*] } {
945 set options "-maltivec -mno-vsx"
947 set options "-mno-vsx"
949 check_runtime_nocache vmx_hw_available {
953 asm volatile ("vor v0,v0,v0");
955 asm volatile ("vor 0,0,0");
964 # Return 1 if the target supports executing AltiVec and Cell PPU
965 # instructions, 0 otherwise. Cache the result.
967 proc check_effective_target_cell_hw { } {
968 return [check_cached_effective_target cell_hw_available {
969 # Some simulators are known to not support VMX and PPU instructions.
970 if { [istarget powerpc-*-eabi*] } {
973 # Most targets don't require special flags for this test
974 # case, but Darwin and AIX do.
975 if { [istarget *-*-darwin*]
976 || [istarget *-*-aix*] } {
977 set options "-maltivec -mcpu=cell"
979 set options "-mcpu=cell"
981 check_runtime_nocache cell_hw_available {
985 asm volatile ("vor v0,v0,v0");
986 asm volatile ("lvlx v0,r0,r0");
988 asm volatile ("vor 0,0,0");
989 asm volatile ("lvlx 0,0,0");
998 # Return 1 if the target supports executing 64-bit instructions, 0
999 # otherwise. Cache the result.
1001 proc check_effective_target_powerpc64 { } {
1002 global powerpc64_available_saved
1005 if [info exists powerpc64_available_saved] {
1006 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1008 set powerpc64_available_saved 0
1010 # Some simulators are known to not support powerpc64 instructions.
1011 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1012 verbose "check_effective_target_powerpc64 returning 0" 2
1013 return $powerpc64_available_saved
1016 # Set up, compile, and execute a test program containing a 64-bit
1017 # instruction. Include the current process ID in the file
1018 # names to prevent conflicts with invocations for multiple
1023 set f [open $src "w"]
1024 puts $f "int main() {"
1025 puts $f "#ifdef __MACH__"
1026 puts $f " asm volatile (\"extsw r0,r0\");"
1028 puts $f " asm volatile (\"extsw 0,0\");"
1030 puts $f " return 0; }"
1033 set opts "additional_flags=-mcpu=G5"
1035 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1036 set lines [${tool}_target_compile $src $exe executable "$opts"]
1039 if [string match "" $lines] then {
1040 # No error message, compilation succeeded.
1041 set result [${tool}_load "./$exe" "" ""]
1042 set status [lindex $result 0]
1043 remote_file build delete $exe
1044 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1046 if { $status == "pass" } then {
1047 set powerpc64_available_saved 1
1050 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1054 return $powerpc64_available_saved
1057 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1058 # complex float arguments. This affects gfortran tests that call cabsf
1059 # in libm built by an earlier compiler. Return 1 if libm uses the same
1060 # argument passing as the compiler under test, 0 otherwise.
1062 # When the target name changes, replace the cached result.
1064 proc check_effective_target_broken_cplxf_arg { } {
1065 return [check_cached_effective_target broken_cplxf_arg {
1066 # Skip the work for targets known not to be affected.
1067 if { ![istarget powerpc64-*-linux*] } {
1069 } elseif { ![is-effective-target lp64] } {
1072 check_runtime_nocache broken_cplxf_arg {
1073 #include <complex.h>
1074 extern void abort (void);
1075 float fabsf (float);
1076 float cabsf (_Complex float);
1083 if (fabsf (f - 5.0) > 0.0001)
1092 proc check_alpha_max_hw_available { } {
1093 return [check_runtime alpha_max_hw_available {
1094 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1098 # Returns true iff the FUNCTION is available on the target system.
1099 # (This is essentially a Tcl implementation of Autoconf's
1102 proc check_function_available { function } {
1103 return [check_no_compiler_messages ${function}_available \
1109 int main () { $function (); }
1113 # Returns true iff "fork" is available on the target system.
1115 proc check_fork_available {} {
1116 return [check_function_available "fork"]
1119 # Returns true iff "mkfifo" is available on the target system.
1121 proc check_mkfifo_available {} {
1122 if {[istarget *-*-cygwin*]} {
1123 # Cygwin has mkfifo, but support is incomplete.
1127 return [check_function_available "mkfifo"]
1130 # Returns true iff "__cxa_atexit" is used on the target system.
1132 proc check_cxa_atexit_available { } {
1133 return [check_cached_effective_target cxa_atexit_available {
1134 if { [istarget "hppa*-*-hpux10*"] } {
1135 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1137 } elseif { [istarget "*-*-vxworks"] } {
1138 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1141 check_runtime_nocache cxa_atexit_available {
1144 static unsigned int count;
1161 Y() { f(); count = 2; }
1170 int main() { return 0; }
1177 # Return 1 if we're generating 32-bit code using default options, 0
1180 proc check_effective_target_ilp32 { } {
1181 return [check_no_compiler_messages ilp32 object {
1182 int dummy[sizeof (int) == 4
1183 && sizeof (void *) == 4
1184 && sizeof (long) == 4 ? 1 : -1];
1188 # Return 1 if we're generating 32-bit or larger integers using default
1189 # options, 0 otherwise.
1191 proc check_effective_target_int32plus { } {
1192 return [check_no_compiler_messages int32plus object {
1193 int dummy[sizeof (int) >= 4 ? 1 : -1];
1197 # Return 1 if we're generating 32-bit or larger pointers using default
1198 # options, 0 otherwise.
1200 proc check_effective_target_ptr32plus { } {
1201 return [check_no_compiler_messages ptr32plus object {
1202 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1206 # Return 1 if we support 32-bit or larger array and structure sizes
1207 # using default options, 0 otherwise.
1209 proc check_effective_target_size32plus { } {
1210 return [check_no_compiler_messages size32plus object {
1215 # Returns 1 if we're generating 16-bit or smaller integers with the
1216 # default options, 0 otherwise.
1218 proc check_effective_target_int16 { } {
1219 return [check_no_compiler_messages int16 object {
1220 int dummy[sizeof (int) < 4 ? 1 : -1];
1224 # Return 1 if we're generating 64-bit code using default options, 0
1227 proc check_effective_target_lp64 { } {
1228 return [check_no_compiler_messages lp64 object {
1229 int dummy[sizeof (int) == 4
1230 && sizeof (void *) == 8
1231 && sizeof (long) == 8 ? 1 : -1];
1235 # Return 1 if we're generating 64-bit code using default llp64 options,
1238 proc check_effective_target_llp64 { } {
1239 return [check_no_compiler_messages llp64 object {
1240 int dummy[sizeof (int) == 4
1241 && sizeof (void *) == 8
1242 && sizeof (long long) == 8
1243 && sizeof (long) == 4 ? 1 : -1];
1247 # Return 1 if the target supports long double larger than double,
1250 proc check_effective_target_large_long_double { } {
1251 return [check_no_compiler_messages large_long_double object {
1252 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1256 # Return 1 if the target supports double larger than float,
1259 proc check_effective_target_large_double { } {
1260 return [check_no_compiler_messages large_double object {
1261 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1265 # Return 1 if the target supports double of 64 bits,
1268 proc check_effective_target_double64 { } {
1269 return [check_no_compiler_messages double64 object {
1270 int dummy[sizeof(double) == 8 ? 1 : -1];
1274 # Return 1 if the target supports double of at least 64 bits,
1277 proc check_effective_target_double64plus { } {
1278 return [check_no_compiler_messages double64plus object {
1279 int dummy[sizeof(double) >= 8 ? 1 : -1];
1283 # Return 1 if the target supports compiling fixed-point,
1286 proc check_effective_target_fixed_point { } {
1287 return [check_no_compiler_messages fixed_point object {
1288 _Sat _Fract x; _Sat _Accum y;
1292 # Return 1 if the target supports compiling decimal floating point,
1295 proc check_effective_target_dfp_nocache { } {
1296 verbose "check_effective_target_dfp_nocache: compiling source" 2
1297 set ret [check_no_compiler_messages_nocache dfp object {
1298 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1300 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1304 proc check_effective_target_dfprt_nocache { } {
1305 return [check_runtime_nocache dfprt {
1306 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1307 int main () { z = x + y; return 0; }
1311 # Return 1 if the target supports compiling Decimal Floating Point,
1314 # This won't change for different subtargets so cache the result.
1316 proc check_effective_target_dfp { } {
1317 return [check_cached_effective_target dfp {
1318 check_effective_target_dfp_nocache
1322 # Return 1 if the target supports linking and executing Decimal Floating
1323 # Point, # 0 otherwise.
1325 # This won't change for different subtargets so cache the result.
1327 proc check_effective_target_dfprt { } {
1328 return [check_cached_effective_target dfprt {
1329 check_effective_target_dfprt_nocache
1333 # Return 1 if the target needs a command line argument to enable a SIMD
1336 proc check_effective_target_vect_cmdline_needed { } {
1337 global et_vect_cmdline_needed_saved
1338 global et_vect_cmdline_needed_target_name
1340 if { ![info exists et_vect_cmdline_needed_target_name] } {
1341 set et_vect_cmdline_needed_target_name ""
1344 # If the target has changed since we set the cached value, clear it.
1345 set current_target [current_target_name]
1346 if { $current_target != $et_vect_cmdline_needed_target_name } {
1347 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1348 set et_vect_cmdline_needed_target_name $current_target
1349 if { [info exists et_vect_cmdline_needed_saved] } {
1350 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1351 unset et_vect_cmdline_needed_saved
1355 if [info exists et_vect_cmdline_needed_saved] {
1356 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1358 set et_vect_cmdline_needed_saved 1
1359 if { [istarget ia64-*-*]
1360 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1361 && [check_effective_target_lp64])
1362 || ([istarget powerpc*-*-*]
1363 && ([check_effective_target_powerpc_spe]
1364 || [check_effective_target_powerpc_altivec]))
1365 || [istarget spu-*-*]
1366 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1367 set et_vect_cmdline_needed_saved 0
1371 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1372 return $et_vect_cmdline_needed_saved
1375 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1377 # This won't change for different subtargets so cache the result.
1379 proc check_effective_target_vect_int { } {
1380 global et_vect_int_saved
1382 if [info exists et_vect_int_saved] {
1383 verbose "check_effective_target_vect_int: using cached result" 2
1385 set et_vect_int_saved 0
1386 if { [istarget i?86-*-*]
1387 || ([istarget powerpc*-*-*]
1388 && ![istarget powerpc-*-linux*paired*])
1389 || [istarget spu-*-*]
1390 || [istarget x86_64-*-*]
1391 || [istarget sparc*-*-*]
1392 || [istarget alpha*-*-*]
1393 || [istarget ia64-*-*]
1394 || [check_effective_target_arm32] } {
1395 set et_vect_int_saved 1
1399 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1400 return $et_vect_int_saved
1403 # Return 1 if the target supports signed int->float conversion
1406 proc check_effective_target_vect_intfloat_cvt { } {
1407 global et_vect_intfloat_cvt_saved
1409 if [info exists et_vect_intfloat_cvt_saved] {
1410 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1412 set et_vect_intfloat_cvt_saved 0
1413 if { [istarget i?86-*-*]
1414 || ([istarget powerpc*-*-*]
1415 && ![istarget powerpc-*-linux*paired*])
1416 || [istarget x86_64-*-*] } {
1417 set et_vect_intfloat_cvt_saved 1
1421 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1422 return $et_vect_intfloat_cvt_saved
1426 # Return 1 if the target supports unsigned int->float conversion
1429 proc check_effective_target_vect_uintfloat_cvt { } {
1430 global et_vect_uintfloat_cvt_saved
1432 if [info exists et_vect_uintfloat_cvt_saved] {
1433 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1435 set et_vect_uintfloat_cvt_saved 0
1436 if { [istarget i?86-*-*]
1437 || ([istarget powerpc*-*-*]
1438 && ![istarget powerpc-*-linux*paired*])
1439 || [istarget x86_64-*-*] } {
1440 set et_vect_uintfloat_cvt_saved 1
1444 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1445 return $et_vect_uintfloat_cvt_saved
1449 # Return 1 if the target supports signed float->int conversion
1452 proc check_effective_target_vect_floatint_cvt { } {
1453 global et_vect_floatint_cvt_saved
1455 if [info exists et_vect_floatint_cvt_saved] {
1456 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1458 set et_vect_floatint_cvt_saved 0
1459 if { [istarget i?86-*-*]
1460 || ([istarget powerpc*-*-*]
1461 && ![istarget powerpc-*-linux*paired*])
1462 || [istarget x86_64-*-*] } {
1463 set et_vect_floatint_cvt_saved 1
1467 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1468 return $et_vect_floatint_cvt_saved
1471 # Return 1 if the target supports unsigned float->int conversion
1474 proc check_effective_target_vect_floatuint_cvt { } {
1475 global et_vect_floatuint_cvt_saved
1477 if [info exists et_vect_floatuint_cvt_saved] {
1478 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1480 set et_vect_floatuint_cvt_saved 0
1481 if { ([istarget powerpc*-*-*]
1482 && ![istarget powerpc-*-linux*paired*]) } {
1483 set et_vect_floatuint_cvt_saved 1
1487 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1488 return $et_vect_floatuint_cvt_saved
1491 # Return 1 is this is an arm target using 32-bit instructions
1492 proc check_effective_target_arm32 { } {
1493 return [check_no_compiler_messages arm32 assembly {
1494 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1500 # Return 1 if this is an ARM target supporting -mfpu=vfp
1501 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1504 proc check_effective_target_arm_vfp_ok { } {
1505 if { [check_effective_target_arm32] } {
1506 return [check_no_compiler_messages arm_vfp_ok object {
1508 } "-mfpu=vfp -mfloat-abi=softfp"]
1514 # Return 1 if this is an ARM target supporting -mfpu=vfp
1515 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1518 proc check_effective_target_arm_hard_vfp_ok { } {
1519 if { [check_effective_target_arm32] } {
1520 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1521 int main() { return 0;}
1522 } "-mfpu=vfp -mfloat-abi=hard"]
1528 # Return 1 if this is an ARM target supporting -mfpu=neon
1529 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1532 proc check_effective_target_arm_neon_ok { } {
1533 if { [check_effective_target_arm32] } {
1534 return [check_no_compiler_messages arm_neon_ok object {
1535 #include "arm_neon.h"
1537 } "-mfpu=neon -mfloat-abi=softfp"]
1543 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1546 proc check_effective_target_arm_thumb1_ok { } {
1547 return [check_no_compiler_messages arm_thumb1_ok assembly {
1548 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1554 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1557 proc check_effective_target_arm_thumb2_ok { } {
1558 return [check_no_compiler_messages arm_thumb2_ok assembly {
1559 #if !defined(__thumb2__)
1565 # Return 1 if the target supports executing NEON instructions, 0
1566 # otherwise. Cache the result.
1568 proc check_effective_target_arm_neon_hw { } {
1569 return [check_runtime arm_neon_hw_available {
1573 long long a = 0, b = 1;
1574 asm ("vorr %P0, %P1, %P2"
1576 : "0" (a), "w" (b));
1579 } "-mfpu=neon -mfloat-abi=softfp"]
1582 # Return 1 if this is a ARM target with NEON enabled.
1584 proc check_effective_target_arm_neon { } {
1585 if { [check_effective_target_arm32] } {
1586 return [check_no_compiler_messages arm_neon object {
1587 #ifndef __ARM_NEON__
1598 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1599 # the Loongson vector modes.
1601 proc check_effective_target_mips_loongson { } {
1602 return [check_no_compiler_messages loongson assembly {
1603 #if !defined(__mips_loongson_vector_rev)
1609 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1612 proc check_effective_target_arm_eabi { } {
1613 return [check_no_compiler_messages arm_eabi object {
1614 #ifndef __ARM_EABI__
1622 # Return 1 if this is a PowerPC target with floating-point registers.
1624 proc check_effective_target_powerpc_fprs { } {
1625 if { [istarget powerpc*-*-*]
1626 || [istarget rs6000-*-*] } {
1627 return [check_no_compiler_messages powerpc_fprs object {
1639 # Return 1 if this is a PowerPC target with hardware double-precision
1642 proc check_effective_target_powerpc_hard_double { } {
1643 if { [istarget powerpc*-*-*]
1644 || [istarget rs6000-*-*] } {
1645 return [check_no_compiler_messages powerpc_hard_double object {
1657 # Return 1 if this is a PowerPC target supporting -maltivec.
1659 proc check_effective_target_powerpc_altivec_ok { } {
1660 if { ([istarget powerpc*-*-*]
1661 && ![istarget powerpc-*-linux*paired*])
1662 || [istarget rs6000-*-*] } {
1663 # AltiVec is not supported on AIX before 5.3.
1664 if { [istarget powerpc*-*-aix4*]
1665 || [istarget powerpc*-*-aix5.1*]
1666 || [istarget powerpc*-*-aix5.2*] } {
1669 return [check_no_compiler_messages powerpc_altivec_ok object {
1677 # Return 1 if this is a PowerPC target supporting -mvsx
1679 proc check_effective_target_powerpc_vsx_ok { } {
1680 if { ([istarget powerpc*-*-*]
1681 && ![istarget powerpc-*-linux*paired*])
1682 || [istarget rs6000-*-*] } {
1683 # AltiVec is not supported on AIX before 5.3.
1684 if { [istarget powerpc*-*-aix4*]
1685 || [istarget powerpc*-*-aix5.1*]
1686 || [istarget powerpc*-*-aix5.2*] } {
1689 return [check_no_compiler_messages powerpc_vsx_ok object {
1692 asm volatile ("xxlor vs0,vs0,vs0");
1694 asm volatile ("xxlor 0,0,0");
1704 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1706 proc check_effective_target_powerpc_ppu_ok { } {
1707 if [check_effective_target_powerpc_altivec_ok] {
1708 return [check_no_compiler_messages cell_asm_available object {
1711 asm volatile ("lvlx v0,v0,v0");
1713 asm volatile ("lvlx 0,0,0");
1723 # Return 1 if this is a PowerPC target that supports SPU.
1725 proc check_effective_target_powerpc_spu { } {
1726 if [istarget powerpc*-*-linux*] {
1727 return [check_effective_target_powerpc_altivec_ok]
1733 # Return 1 if this is a PowerPC SPE target. The check includes options
1734 # specified by dg-options for this test, so don't cache the result.
1736 proc check_effective_target_powerpc_spe_nocache { } {
1737 if { [istarget powerpc*-*-*] } {
1738 return [check_no_compiler_messages_nocache powerpc_spe object {
1744 } [current_compiler_flags]]
1750 # Return 1 if this is a PowerPC target with SPE enabled.
1752 proc check_effective_target_powerpc_spe { } {
1753 if { [istarget powerpc*-*-*] } {
1754 return [check_no_compiler_messages powerpc_spe object {
1766 # Return 1 if this is a PowerPC target with Altivec enabled.
1768 proc check_effective_target_powerpc_altivec { } {
1769 if { [istarget powerpc*-*-*] } {
1770 return [check_no_compiler_messages powerpc_altivec object {
1782 # Return 1 if this is a PowerPC 405 target. The check includes options
1783 # specified by dg-options for this test, so don't cache the result.
1785 proc check_effective_target_powerpc_405_nocache { } {
1786 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
1787 return [check_no_compiler_messages_nocache powerpc_405 object {
1793 } [current_compiler_flags]]
1799 # Return 1 if this is a SPU target with a toolchain that
1800 # supports automatic overlay generation.
1802 proc check_effective_target_spu_auto_overlay { } {
1803 if { [istarget spu*-*-elf*] } {
1804 return [check_no_compiler_messages spu_auto_overlay executable {
1806 } "-Wl,--auto-overlay" ]
1812 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1813 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1814 # test environment appears to run executables on such a simulator.
1816 proc check_effective_target_ultrasparc_hw { } {
1817 return [check_runtime ultrasparc_hw {
1818 int main() { return 0; }
1819 } "-mcpu=ultrasparc"]
1822 # Return 1 if the target supports hardware vector shift operation.
1824 proc check_effective_target_vect_shift { } {
1825 global et_vect_shift_saved
1827 if [info exists et_vect_shift_saved] {
1828 verbose "check_effective_target_vect_shift: using cached result" 2
1830 set et_vect_shift_saved 0
1831 if { ([istarget powerpc*-*-*]
1832 && ![istarget powerpc-*-linux*paired*])
1833 || [istarget ia64-*-*]
1834 || [istarget i?86-*-*]
1835 || [istarget x86_64-*-*]
1836 || [check_effective_target_arm32] } {
1837 set et_vect_shift_saved 1
1841 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1842 return $et_vect_shift_saved
1845 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1847 # This can change for different subtargets so do not cache the result.
1849 proc check_effective_target_vect_long { } {
1850 if { [istarget i?86-*-*]
1851 || (([istarget powerpc*-*-*]
1852 && ![istarget powerpc-*-linux*paired*])
1853 && [check_effective_target_ilp32])
1854 || [istarget x86_64-*-*]
1855 || [check_effective_target_arm32]
1856 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1862 verbose "check_effective_target_vect_long: returning $answer" 2
1866 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1868 # This won't change for different subtargets so cache the result.
1870 proc check_effective_target_vect_float { } {
1871 global et_vect_float_saved
1873 if [info exists et_vect_float_saved] {
1874 verbose "check_effective_target_vect_float: using cached result" 2
1876 set et_vect_float_saved 0
1877 if { [istarget i?86-*-*]
1878 || [istarget powerpc*-*-*]
1879 || [istarget spu-*-*]
1880 || [istarget mipsisa64*-*-*]
1881 || [istarget x86_64-*-*]
1882 || [istarget ia64-*-*]
1883 || [check_effective_target_arm32] } {
1884 set et_vect_float_saved 1
1888 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1889 return $et_vect_float_saved
1892 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1894 # This won't change for different subtargets so cache the result.
1896 proc check_effective_target_vect_double { } {
1897 global et_vect_double_saved
1899 if [info exists et_vect_double_saved] {
1900 verbose "check_effective_target_vect_double: using cached result" 2
1902 set et_vect_double_saved 0
1903 if { [istarget i?86-*-*]
1904 || [istarget x86_64-*-*]
1905 || [istarget spu-*-*] } {
1906 set et_vect_double_saved 1
1910 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1911 return $et_vect_double_saved
1914 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
1916 # This won't change for different subtargets so cache the result.
1918 proc check_effective_target_vect_long_long { } {
1919 global et_vect_long_long_saved
1921 if [info exists et_vect_long_long_saved] {
1922 verbose "check_effective_target_vect_long_long: using cached result" 2
1924 set et_vect_long_long_saved 0
1925 if { [istarget i?86-*-*]
1926 || [istarget x86_64-*-*] } {
1927 set et_vect_long_long_saved 1
1931 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
1932 return $et_vect_long_long_saved
1936 # Return 1 if the target plus current options does not support a vector
1937 # max instruction on "int", 0 otherwise.
1939 # This won't change for different subtargets so cache the result.
1941 proc check_effective_target_vect_no_int_max { } {
1942 global et_vect_no_int_max_saved
1944 if [info exists et_vect_no_int_max_saved] {
1945 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1947 set et_vect_no_int_max_saved 0
1948 if { [istarget sparc*-*-*]
1949 || [istarget spu-*-*]
1950 || [istarget alpha*-*-*] } {
1951 set et_vect_no_int_max_saved 1
1954 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1955 return $et_vect_no_int_max_saved
1958 # Return 1 if the target plus current options does not support a vector
1959 # add instruction on "int", 0 otherwise.
1961 # This won't change for different subtargets so cache the result.
1963 proc check_effective_target_vect_no_int_add { } {
1964 global et_vect_no_int_add_saved
1966 if [info exists et_vect_no_int_add_saved] {
1967 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1969 set et_vect_no_int_add_saved 0
1970 # Alpha only supports vector add on V8QI and V4HI.
1971 if { [istarget alpha*-*-*] } {
1972 set et_vect_no_int_add_saved 1
1975 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1976 return $et_vect_no_int_add_saved
1979 # Return 1 if the target plus current options does not support vector
1980 # bitwise instructions, 0 otherwise.
1982 # This won't change for different subtargets so cache the result.
1984 proc check_effective_target_vect_no_bitwise { } {
1985 global et_vect_no_bitwise_saved
1987 if [info exists et_vect_no_bitwise_saved] {
1988 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1990 set et_vect_no_bitwise_saved 0
1992 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1993 return $et_vect_no_bitwise_saved
1996 # Return 1 if the target plus current options supports vector permutation,
1999 # This won't change for different subtargets so cache the result.
2001 proc check_effective_target_vect_perm { } {
2004 if [info exists et_vect_perm_saved] {
2005 verbose "check_effective_target_vect_perm: using cached result" 2
2007 set et_vect_perm_saved 0
2008 if { [istarget powerpc*-*-*]
2009 || [istarget spu-*-*] } {
2010 set et_vect_perm_saved 1
2013 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2014 return $et_vect_perm_saved
2018 # Return 1 if the target plus current options supports a vector
2019 # widening summation of *short* args into *int* result, 0 otherwise.
2020 # A target can also support this widening summation if it can support
2021 # promotion (unpacking) from shorts to ints.
2023 # This won't change for different subtargets so cache the result.
2025 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2026 global et_vect_widen_sum_hi_to_si
2028 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2029 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2031 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2032 if { [istarget powerpc*-*-*]
2033 || [istarget ia64-*-*] } {
2034 set et_vect_widen_sum_hi_to_si_saved 1
2037 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2038 return $et_vect_widen_sum_hi_to_si_saved
2041 # Return 1 if the target plus current options supports a vector
2042 # widening summation of *char* args into *short* result, 0 otherwise.
2043 # A target can also support this widening summation if it can support
2044 # promotion (unpacking) from chars to shorts.
2046 # This won't change for different subtargets so cache the result.
2048 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2049 global et_vect_widen_sum_qi_to_hi
2051 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2052 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2054 set et_vect_widen_sum_qi_to_hi_saved 0
2055 if { [check_effective_target_vect_unpack]
2056 || [istarget ia64-*-*] } {
2057 set et_vect_widen_sum_qi_to_hi_saved 1
2060 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2061 return $et_vect_widen_sum_qi_to_hi_saved
2064 # Return 1 if the target plus current options supports a vector
2065 # widening summation of *char* args into *int* result, 0 otherwise.
2067 # This won't change for different subtargets so cache the result.
2069 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2070 global et_vect_widen_sum_qi_to_si
2072 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2073 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2075 set et_vect_widen_sum_qi_to_si_saved 0
2076 if { [istarget powerpc*-*-*] } {
2077 set et_vect_widen_sum_qi_to_si_saved 1
2080 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2081 return $et_vect_widen_sum_qi_to_si_saved
2084 # Return 1 if the target plus current options supports a vector
2085 # widening multiplication of *char* args into *short* result, 0 otherwise.
2086 # A target can also support this widening multplication if it can support
2087 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2088 # multiplication of shorts).
2090 # This won't change for different subtargets so cache the result.
2093 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2094 global et_vect_widen_mult_qi_to_hi
2096 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2097 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2099 if { [check_effective_target_vect_unpack]
2100 && [check_effective_target_vect_short_mult] } {
2101 set et_vect_widen_mult_qi_to_hi_saved 1
2103 set et_vect_widen_mult_qi_to_hi_saved 0
2105 if { [istarget powerpc*-*-*] } {
2106 set et_vect_widen_mult_qi_to_hi_saved 1
2109 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2110 return $et_vect_widen_mult_qi_to_hi_saved
2113 # Return 1 if the target plus current options supports a vector
2114 # widening multiplication of *short* args into *int* result, 0 otherwise.
2115 # A target can also support this widening multplication if it can support
2116 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2117 # multiplication of ints).
2119 # This won't change for different subtargets so cache the result.
2122 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2123 global et_vect_widen_mult_hi_to_si
2125 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2126 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2128 if { [check_effective_target_vect_unpack]
2129 && [check_effective_target_vect_int_mult] } {
2130 set et_vect_widen_mult_hi_to_si_saved 1
2132 set et_vect_widen_mult_hi_to_si_saved 0
2134 if { [istarget powerpc*-*-*]
2135 || [istarget spu-*-*]
2136 || [istarget i?86-*-*]
2137 || [istarget x86_64-*-*] } {
2138 set et_vect_widen_mult_hi_to_si_saved 1
2141 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2142 return $et_vect_widen_mult_hi_to_si_saved
2145 # Return 1 if the target plus current options supports a vector
2146 # dot-product of signed chars, 0 otherwise.
2148 # This won't change for different subtargets so cache the result.
2150 proc check_effective_target_vect_sdot_qi { } {
2151 global et_vect_sdot_qi
2153 if [info exists et_vect_sdot_qi_saved] {
2154 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2156 set et_vect_sdot_qi_saved 0
2158 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2159 return $et_vect_sdot_qi_saved
2162 # Return 1 if the target plus current options supports a vector
2163 # dot-product of unsigned chars, 0 otherwise.
2165 # This won't change for different subtargets so cache the result.
2167 proc check_effective_target_vect_udot_qi { } {
2168 global et_vect_udot_qi
2170 if [info exists et_vect_udot_qi_saved] {
2171 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2173 set et_vect_udot_qi_saved 0
2174 if { [istarget powerpc*-*-*] } {
2175 set et_vect_udot_qi_saved 1
2178 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2179 return $et_vect_udot_qi_saved
2182 # Return 1 if the target plus current options supports a vector
2183 # dot-product of signed shorts, 0 otherwise.
2185 # This won't change for different subtargets so cache the result.
2187 proc check_effective_target_vect_sdot_hi { } {
2188 global et_vect_sdot_hi
2190 if [info exists et_vect_sdot_hi_saved] {
2191 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2193 set et_vect_sdot_hi_saved 0
2194 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2195 || [istarget i?86-*-*]
2196 || [istarget x86_64-*-*] } {
2197 set et_vect_sdot_hi_saved 1
2200 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2201 return $et_vect_sdot_hi_saved
2204 # Return 1 if the target plus current options supports a vector
2205 # dot-product of unsigned shorts, 0 otherwise.
2207 # This won't change for different subtargets so cache the result.
2209 proc check_effective_target_vect_udot_hi { } {
2210 global et_vect_udot_hi
2212 if [info exists et_vect_udot_hi_saved] {
2213 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2215 set et_vect_udot_hi_saved 0
2216 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2217 set et_vect_udot_hi_saved 1
2220 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2221 return $et_vect_udot_hi_saved
2225 # Return 1 if the target plus current options supports a vector
2226 # demotion (packing) of shorts (to chars) and ints (to shorts)
2227 # using modulo arithmetic, 0 otherwise.
2229 # This won't change for different subtargets so cache the result.
2231 proc check_effective_target_vect_pack_trunc { } {
2232 global et_vect_pack_trunc
2234 if [info exists et_vect_pack_trunc_saved] {
2235 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2237 set et_vect_pack_trunc_saved 0
2238 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2239 || [istarget i?86-*-*]
2240 || [istarget x86_64-*-*]
2241 || [istarget spu-*-*] } {
2242 set et_vect_pack_trunc_saved 1
2245 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2246 return $et_vect_pack_trunc_saved
2249 # Return 1 if the target plus current options supports a vector
2250 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2252 # This won't change for different subtargets so cache the result.
2254 proc check_effective_target_vect_unpack { } {
2255 global et_vect_unpack
2257 if [info exists et_vect_unpack_saved] {
2258 verbose "check_effective_target_vect_unpack: using cached result" 2
2260 set et_vect_unpack_saved 0
2261 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2262 || [istarget i?86-*-*]
2263 || [istarget x86_64-*-*]
2264 || [istarget spu-*-*] } {
2265 set et_vect_unpack_saved 1
2268 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2269 return $et_vect_unpack_saved
2272 # Return 1 if the target plus current options does not guarantee
2273 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2275 # This won't change for different subtargets so cache the result.
2277 proc check_effective_target_unaligned_stack { } {
2278 global et_unaligned_stack_saved
2280 if [info exists et_unaligned_stack_saved] {
2281 verbose "check_effective_target_unaligned_stack: using cached result" 2
2283 set et_unaligned_stack_saved 0
2285 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2286 return $et_unaligned_stack_saved
2289 # Return 1 if the target plus current options does not support a vector
2290 # alignment mechanism, 0 otherwise.
2292 # This won't change for different subtargets so cache the result.
2294 proc check_effective_target_vect_no_align { } {
2295 global et_vect_no_align_saved
2297 if [info exists et_vect_no_align_saved] {
2298 verbose "check_effective_target_vect_no_align: using cached result" 2
2300 set et_vect_no_align_saved 0
2301 if { [istarget mipsisa64*-*-*]
2302 || [istarget sparc*-*-*]
2303 || [istarget ia64-*-*]
2304 || [check_effective_target_arm32] } {
2305 set et_vect_no_align_saved 1
2308 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2309 return $et_vect_no_align_saved
2312 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2314 # This won't change for different subtargets so cache the result.
2316 proc check_effective_target_vect_hw_misalign { } {
2317 global et_vect_hw_misalign_saved
2319 if [info exists et_vect_hw_misalign_saved] {
2320 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2322 set et_vect_hw_misalign_saved 0
2323 if { ([istarget x86_64-*-*]
2324 || [istarget i?86-*-*]) } {
2325 set et_vect_hw_misalign_saved 1
2328 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2329 return $et_vect_hw_misalign_saved
2333 # Return 1 if arrays are aligned to the vector alignment
2334 # boundary, 0 otherwise.
2336 # This won't change for different subtargets so cache the result.
2338 proc check_effective_target_vect_aligned_arrays { } {
2339 global et_vect_aligned_arrays
2341 if [info exists et_vect_aligned_arrays_saved] {
2342 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2344 set et_vect_aligned_arrays_saved 0
2345 if { (([istarget x86_64-*-*]
2346 || [istarget i?86-*-*]) && [is-effective-target lp64])
2347 || [istarget spu-*-*] } {
2348 set et_vect_aligned_arrays_saved 1
2351 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2352 return $et_vect_aligned_arrays_saved
2355 # Return 1 if types of size 32 bit or less are naturally aligned
2356 # (aligned to their type-size), 0 otherwise.
2358 # This won't change for different subtargets so cache the result.
2360 proc check_effective_target_natural_alignment_32 { } {
2361 global et_natural_alignment_32
2363 if [info exists et_natural_alignment_32_saved] {
2364 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2366 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2367 set et_natural_alignment_32_saved 1
2368 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2369 set et_natural_alignment_32_saved 0
2372 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2373 return $et_natural_alignment_32_saved
2376 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2377 # type-size), 0 otherwise.
2379 # This won't change for different subtargets so cache the result.
2381 proc check_effective_target_natural_alignment_64 { } {
2382 global et_natural_alignment_64
2384 if [info exists et_natural_alignment_64_saved] {
2385 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2387 set et_natural_alignment_64_saved 0
2388 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2389 || [istarget spu-*-*] } {
2390 set et_natural_alignment_64_saved 1
2393 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2394 return $et_natural_alignment_64_saved
2397 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2399 # This won't change for different subtargets so cache the result.
2401 proc check_effective_target_vector_alignment_reachable { } {
2402 global et_vector_alignment_reachable
2404 if [info exists et_vector_alignment_reachable_saved] {
2405 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2407 if { [check_effective_target_vect_aligned_arrays]
2408 || [check_effective_target_natural_alignment_32] } {
2409 set et_vector_alignment_reachable_saved 1
2411 set et_vector_alignment_reachable_saved 0
2414 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2415 return $et_vector_alignment_reachable_saved
2418 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2420 # This won't change for different subtargets so cache the result.
2422 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2423 global et_vector_alignment_reachable_for_64bit
2425 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2426 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2428 if { [check_effective_target_vect_aligned_arrays]
2429 || [check_effective_target_natural_alignment_64] } {
2430 set et_vector_alignment_reachable_for_64bit_saved 1
2432 set et_vector_alignment_reachable_for_64bit_saved 0
2435 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2436 return $et_vector_alignment_reachable_for_64bit_saved
2439 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2441 proc check_effective_target_vect_condition { } {
2442 global et_vect_cond_saved
2444 if [info exists et_vect_cond_saved] {
2445 verbose "check_effective_target_vect_cond: using cached result" 2
2447 set et_vect_cond_saved 0
2448 if { [istarget powerpc*-*-*]
2449 || [istarget ia64-*-*]
2450 || [istarget i?86-*-*]
2451 || [istarget spu-*-*]
2452 || [istarget x86_64-*-*] } {
2453 set et_vect_cond_saved 1
2457 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2458 return $et_vect_cond_saved
2461 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2463 proc check_effective_target_vect_char_mult { } {
2464 global et_vect_char_mult_saved
2466 if [info exists et_vect_char_mult_saved] {
2467 verbose "check_effective_target_vect_char_mult: using cached result" 2
2469 set et_vect_char_mult_saved 0
2470 if { [istarget ia64-*-*]
2471 || [istarget i?86-*-*]
2472 || [istarget x86_64-*-*] } {
2473 set et_vect_char_mult_saved 1
2477 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2478 return $et_vect_char_mult_saved
2481 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2483 proc check_effective_target_vect_short_mult { } {
2484 global et_vect_short_mult_saved
2486 if [info exists et_vect_short_mult_saved] {
2487 verbose "check_effective_target_vect_short_mult: using cached result" 2
2489 set et_vect_short_mult_saved 0
2490 if { [istarget ia64-*-*]
2491 || [istarget spu-*-*]
2492 || [istarget i?86-*-*]
2493 || [istarget x86_64-*-*]
2494 || [istarget powerpc*-*-*]
2495 || [check_effective_target_arm32] } {
2496 set et_vect_short_mult_saved 1
2500 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2501 return $et_vect_short_mult_saved
2504 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2506 proc check_effective_target_vect_int_mult { } {
2507 global et_vect_int_mult_saved
2509 if [info exists et_vect_int_mult_saved] {
2510 verbose "check_effective_target_vect_int_mult: using cached result" 2
2512 set et_vect_int_mult_saved 0
2513 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2514 || [istarget spu-*-*]
2515 || [istarget i?86-*-*]
2516 || [istarget x86_64-*-*]
2517 || [check_effective_target_arm32] } {
2518 set et_vect_int_mult_saved 1
2522 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2523 return $et_vect_int_mult_saved
2526 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2528 proc check_effective_target_vect_extract_even_odd { } {
2529 global et_vect_extract_even_odd_saved
2531 if [info exists et_vect_extract_even_odd_saved] {
2532 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2534 set et_vect_extract_even_odd_saved 0
2535 if { [istarget powerpc*-*-*]
2536 || [istarget spu-*-*] } {
2537 set et_vect_extract_even_odd_saved 1
2541 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2542 return $et_vect_extract_even_odd_saved
2545 # Return 1 if the target supports vector even/odd elements extraction of
2546 # vectors with SImode elements or larger, 0 otherwise.
2548 proc check_effective_target_vect_extract_even_odd_wide { } {
2549 global et_vect_extract_even_odd_wide_saved
2551 if [info exists et_vect_extract_even_odd_wide_saved] {
2552 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2554 set et_vect_extract_even_odd_wide_saved 0
2555 if { [istarget powerpc*-*-*]
2556 || [istarget i?86-*-*]
2557 || [istarget x86_64-*-*]
2558 || [istarget spu-*-*] } {
2559 set et_vect_extract_even_odd_wide_saved 1
2563 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2564 return $et_vect_extract_even_odd_wide_saved
2567 # Return 1 if the target supports vector interleaving, 0 otherwise.
2569 proc check_effective_target_vect_interleave { } {
2570 global et_vect_interleave_saved
2572 if [info exists et_vect_interleave_saved] {
2573 verbose "check_effective_target_vect_interleave: using cached result" 2
2575 set et_vect_interleave_saved 0
2576 if { [istarget powerpc*-*-*]
2577 || [istarget i?86-*-*]
2578 || [istarget x86_64-*-*]
2579 || [istarget spu-*-*] } {
2580 set et_vect_interleave_saved 1
2584 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2585 return $et_vect_interleave_saved
2588 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2589 proc check_effective_target_vect_strided { } {
2590 global et_vect_strided_saved
2592 if [info exists et_vect_strided_saved] {
2593 verbose "check_effective_target_vect_strided: using cached result" 2
2595 set et_vect_strided_saved 0
2596 if { [check_effective_target_vect_interleave]
2597 && [check_effective_target_vect_extract_even_odd] } {
2598 set et_vect_strided_saved 1
2602 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2603 return $et_vect_strided_saved
2606 # Return 1 if the target supports vector interleaving and extract even/odd
2607 # for wide element types, 0 otherwise.
2608 proc check_effective_target_vect_strided_wide { } {
2609 global et_vect_strided_wide_saved
2611 if [info exists et_vect_strided_wide_saved] {
2612 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2614 set et_vect_strided_wide_saved 0
2615 if { [check_effective_target_vect_interleave]
2616 && [check_effective_target_vect_extract_even_odd_wide] } {
2617 set et_vect_strided_wide_saved 1
2621 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2622 return $et_vect_strided_wide_saved
2625 # Return 1 if the target supports section-anchors
2627 proc check_effective_target_section_anchors { } {
2628 global et_section_anchors_saved
2630 if [info exists et_section_anchors_saved] {
2631 verbose "check_effective_target_section_anchors: using cached result" 2
2633 set et_section_anchors_saved 0
2634 if { [istarget powerpc*-*-*]
2635 || [istarget arm*-*-*] } {
2636 set et_section_anchors_saved 1
2640 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2641 return $et_section_anchors_saved
2644 # Return 1 if the target supports atomic operations on "int" and "long".
2646 proc check_effective_target_sync_int_long { } {
2647 global et_sync_int_long_saved
2649 if [info exists et_sync_int_long_saved] {
2650 verbose "check_effective_target_sync_int_long: using cached result" 2
2652 set et_sync_int_long_saved 0
2653 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2654 # load-reserved/store-conditional instructions.
2655 if { [istarget ia64-*-*]
2656 || [istarget i?86-*-*]
2657 || [istarget x86_64-*-*]
2658 || [istarget alpha*-*-*]
2659 || [istarget s390*-*-*]
2660 || [istarget powerpc*-*-*]
2661 || [istarget sparc64-*-*]
2662 || [istarget sparcv9-*-*]
2663 || [istarget mips*-*-*] } {
2664 set et_sync_int_long_saved 1
2668 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2669 return $et_sync_int_long_saved
2672 # Return 1 if the target supports atomic operations on "char" and "short".
2674 proc check_effective_target_sync_char_short { } {
2675 global et_sync_char_short_saved
2677 if [info exists et_sync_char_short_saved] {
2678 verbose "check_effective_target_sync_char_short: using cached result" 2
2680 set et_sync_char_short_saved 0
2681 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2682 # load-reserved/store-conditional instructions.
2683 if { [istarget ia64-*-*]
2684 || [istarget i?86-*-*]
2685 || [istarget x86_64-*-*]
2686 || [istarget alpha*-*-*]
2687 || [istarget s390*-*-*]
2688 || [istarget powerpc*-*-*]
2689 || [istarget sparc64-*-*]
2690 || [istarget sparcv9-*-*]
2691 || [istarget mips*-*-*] } {
2692 set et_sync_char_short_saved 1
2696 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2697 return $et_sync_char_short_saved
2700 # Return 1 if the target uses a ColdFire FPU.
2702 proc check_effective_target_coldfire_fpu { } {
2703 return [check_no_compiler_messages coldfire_fpu assembly {
2710 # Return true if this is a uClibc target.
2712 proc check_effective_target_uclibc {} {
2713 return [check_no_compiler_messages uclibc object {
2714 #include <features.h>
2715 #if !defined (__UCLIBC__)
2721 # Return true if this is a uclibc target and if the uclibc feature
2722 # described by __$feature__ is not present.
2724 proc check_missing_uclibc_feature {feature} {
2725 return [check_no_compiler_messages $feature object "
2726 #include <features.h>
2727 #if !defined (__UCLIBC) || defined (__${feature}__)
2733 # Return true if this is a Newlib target.
2735 proc check_effective_target_newlib {} {
2736 return [check_no_compiler_messages newlib object {
2742 # (a) an error of a few ULP is expected in string to floating-point
2743 # conversion functions; and
2744 # (b) overflow is not always detected correctly by those functions.
2746 proc check_effective_target_lax_strtofp {} {
2747 # By default, assume that all uClibc targets suffer from this.
2748 return [check_effective_target_uclibc]
2751 # Return 1 if this is a target for which wcsftime is a dummy
2752 # function that always returns 0.
2754 proc check_effective_target_dummy_wcsftime {} {
2755 # By default, assume that all uClibc targets suffer from this.
2756 return [check_effective_target_uclibc]
2759 # Return 1 if constructors with initialization priority arguments are
2760 # supposed on this target.
2762 proc check_effective_target_init_priority {} {
2763 return [check_no_compiler_messages init_priority assembly "
2764 void f() __attribute__((constructor (1000)));
2769 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2770 # This can be used with any check_* proc that takes no argument and
2771 # returns only 1 or 0. It could be used with check_* procs that take
2772 # arguments with keywords that pass particular arguments.
2774 proc is-effective-target { arg } {
2776 if { [info procs check_effective_target_${arg}] != [list] } {
2777 set selected [check_effective_target_${arg}]
2780 "vmx_hw" { set selected [check_vmx_hw_available] }
2781 "named_sections" { set selected [check_named_sections_available] }
2782 "gc_sections" { set selected [check_gc_sections_available] }
2783 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2784 default { error "unknown effective target keyword `$arg'" }
2787 verbose "is-effective-target: $arg $selected" 2
2791 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2793 proc is-effective-target-keyword { arg } {
2794 if { [info procs check_effective_target_${arg}] != [list] } {
2797 # These have different names for their check_* procs.
2799 "vmx_hw" { return 1 }
2800 "named_sections" { return 1 }
2801 "gc_sections" { return 1 }
2802 "cxa_atexit" { return 1 }
2803 default { return 0 }
2808 # Return 1 if target default to short enums
2810 proc check_effective_target_short_enums { } {
2811 return [check_no_compiler_messages short_enums assembly {
2813 int s[sizeof (enum foo) == 1 ? 1 : -1];
2817 # Return 1 if target supports merging string constants at link time.
2819 proc check_effective_target_string_merging { } {
2820 return [check_no_messages_and_pattern string_merging \
2821 "rodata\\.str" assembly {
2822 const char *var = "String";
2826 # Return 1 if target has the basic signed and unsigned types in
2827 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
2828 # working <stdint.h> for all targets.
2830 proc check_effective_target_stdint_types { } {
2831 return [check_no_compiler_messages stdint_types assembly {
2833 int8_t a; int16_t b; int32_t c; int64_t d;
2834 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2838 # Return 1 if target has the basic signed and unsigned types in
2839 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
2840 # these types agree with those in the header, as some systems have
2841 # only <inttypes.h>.
2843 proc check_effective_target_inttypes_types { } {
2844 return [check_no_compiler_messages inttypes_types assembly {
2845 #include <inttypes.h>
2846 int8_t a; int16_t b; int32_t c; int64_t d;
2847 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2851 # Return 1 if programs are intended to be run on a simulator
2852 # (i.e. slowly) rather than hardware (i.e. fast).
2854 proc check_effective_target_simulator { } {
2856 # All "src/sim" simulators set this one.
2857 if [board_info target exists is_simulator] {
2858 return [board_info target is_simulator]
2861 # The "sid" simulators don't set that one, but at least they set
2863 if [board_info target exists slow_simulator] {
2864 return [board_info target slow_simulator]
2870 # Return 1 if the target is a VxWorks kernel.
2872 proc check_effective_target_vxworks_kernel { } {
2873 return [check_no_compiler_messages vxworks_kernel assembly {
2874 #if !defined __vxworks || defined __RTP__
2880 # Return 1 if the target is a VxWorks RTP.
2882 proc check_effective_target_vxworks_rtp { } {
2883 return [check_no_compiler_messages vxworks_rtp assembly {
2884 #if !defined __vxworks || !defined __RTP__
2890 # Return 1 if the target is expected to provide wide character support.
2892 proc check_effective_target_wchar { } {
2893 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2896 return [check_no_compiler_messages wchar assembly {
2901 # Return 1 if the target has <pthread.h>.
2903 proc check_effective_target_pthread_h { } {
2904 return [check_no_compiler_messages pthread_h assembly {
2905 #include <pthread.h>
2909 # Return 1 if the target can truncate a file from a file-descriptor,
2910 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2911 # chsize. We test for a trivially functional truncation; no stubs.
2912 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2913 # different function to be used.
2915 proc check_effective_target_fd_truncate { } {
2917 #define _FILE_OFFSET_BITS 64
2923 FILE *f = fopen ("tst.tmp", "wb");
2925 const char t[] = "test writing more than ten characters";
2928 write (fd, t, sizeof (t) - 1);
2930 if (ftruncate (fd, 10) != 0)
2933 f = fopen ("tst.tmp", "rb");
2934 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2940 if { [check_runtime ftruncate $prog] } {
2944 regsub "ftruncate" $prog "chsize" prog
2945 return [check_runtime chsize $prog]
2948 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2950 proc add_options_for_c99_runtime { flags } {
2951 if { [istarget *-*-solaris2*] } {
2952 return "$flags -std=c99"
2954 if { [istarget powerpc-*-darwin*] } {
2955 return "$flags -mmacosx-version-min=10.3"
2960 # Return 1 if the target provides a full C99 runtime.
2962 proc check_effective_target_c99_runtime { } {
2963 return [check_cached_effective_target c99_runtime {
2966 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2967 set contents [read $file]
2970 #ifndef HAVE_C99_RUNTIME
2974 check_no_compiler_messages_nocache c99_runtime assembly \
2975 $contents [add_options_for_c99_runtime ""]
2979 # Return 1 if target wchar_t is at least 4 bytes.
2981 proc check_effective_target_4byte_wchar_t { } {
2982 return [check_no_compiler_messages 4byte_wchar_t object {
2983 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
2987 # Return 1 if the target supports automatic stack alignment.
2989 proc check_effective_target_automatic_stack_alignment { } {
2990 if { [istarget i?86*-*-*]
2991 || [istarget x86_64-*-*] } then {
2998 # Return 1 if avx instructions can be compiled.
3000 proc check_effective_target_avx { } {
3001 return [check_no_compiler_messages avx object {
3002 void _mm256_zeroall (void)
3004 __builtin_ia32_vzeroall ();
3009 # Return 1 if C wchar_t type is compatible with char16_t.
3011 proc check_effective_target_wchar_t_char16_t_compatible { } {
3012 return [check_no_compiler_messages wchar_t_char16_t object {
3014 __CHAR16_TYPE__ *p16 = &wc;
3015 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3019 # Return 1 if C wchar_t type is compatible with char32_t.
3021 proc check_effective_target_wchar_t_char32_t_compatible { } {
3022 return [check_no_compiler_messages wchar_t_char32_t object {
3024 __CHAR32_TYPE__ *p32 = &wc;
3025 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3029 # Return 1 if pow10 function exists.
3031 proc check_effective_target_pow10 { } {
3032 return [check_runtime pow10 {
3042 # Return 1 if current options generate DFP instructions, 0 otherwise.
3044 proc check_effective_target_hard_dfp {} {
3045 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3047 void foo (void) { z = x + y; }
3051 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3052 # for strchr etc. functions.
3054 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3055 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3058 #if !defined(__cplusplus) \
3059 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3060 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3061 ISO C++ correct string.h and wchar.h protos not supported.
3068 # Return 1 if the MPC library is integrated with GCC, 0 otherwise.
3070 proc check_effective_target_mpc { } {
3071 return [check_no_compiler_messages mpc executable {
3072 extern void link_error(void);
3075 if (__builtin_csin(0) != 0)
3081 # Return 1 if the MPC library with mpc_pow is integrated with GCC, 0 otherwise.
3083 proc check_effective_target_mpc_pow { } {
3084 return [check_no_compiler_messages mpc_pow executable {
3085 extern void link_error(void);
3088 if (__builtin_cpow(1,1) != 1)
3094 # Return 1 if the language for the compiler under test is C.
3096 proc check_effective_target_c { } {
3098 if [string match $tool "gcc"] {
3104 # Return 1 if the language for the compiler under test is C++.
3106 proc check_effective_target_c++ { } {
3108 if [string match $tool "g++"] {