1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2 # 2011 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.
33 # Otherwise, code should contain:
35 # "! Fortran" for Fortran code,
37 # "// ObjC++" for ObjC++
39 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
40 # allow for ObjC/ObjC++ specific flags.
41 proc check_compile {basename type contents args} {
43 verbose "check_compile tool: $tool for $basename"
45 if { [llength $args] > 0 } {
46 set options [list "additional_flags=[lindex $args 0]"]
50 switch -glob -- $contents {
51 "*! Fortran*" { set src ${basename}[pid].f90 }
52 "*// C++*" { set src ${basename}[pid].cc }
53 "*// ObjC++*" { set src ${basename}[pid].mm }
54 "*/* ObjC*" { set src ${basename}[pid].m }
55 "*// Go*" { set src ${basename}[pid].go }
58 "objc" { set src ${basename}[pid].m }
59 "obj-c++" { set src ${basename}[pid].mm }
60 default { set src ${basename}[pid].c }
65 set compile_type $type
67 assembly { set output ${basename}[pid].s }
68 object { set output ${basename}[pid].o }
69 executable { set output ${basename}[pid].exe }
71 set output ${basename}[pid].s
72 lappend options "additional_flags=-fdump-$type"
73 set compile_type assembly
79 set lines [${tool}_target_compile $src $output $compile_type "$options"]
82 set scan_output $output
83 # Don't try folding this into the switch above; calling "glob" before the
84 # file is created won't work.
85 if [regexp "rtl-(.*)" $type dummy rtl_type] {
86 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
90 return [list $lines $scan_output]
93 proc current_target_name { } {
95 if [info exists target_info(target,name)] {
96 set answer $target_info(target,name)
103 # Implement an effective-target check for property PROP by invoking
104 # the Tcl command ARGS and seeing if it returns true.
106 proc check_cached_effective_target { prop args } {
109 set target [current_target_name]
110 if {![info exists et_cache($prop,target)]
111 || $et_cache($prop,target) != $target} {
112 verbose "check_cached_effective_target $prop: checking $target" 2
113 set et_cache($prop,target) $target
114 set et_cache($prop,value) [uplevel eval $args]
116 set value $et_cache($prop,value)
117 verbose "check_cached_effective_target $prop: returning $value for $target" 2
121 # Like check_compile, but delete the output file and return true if the
122 # compiler printed no messages.
123 proc check_no_compiler_messages_nocache {args} {
124 set result [eval check_compile $args]
125 set lines [lindex $result 0]
126 set output [lindex $result 1]
127 remote_file build delete $output
128 return [string match "" $lines]
131 # Like check_no_compiler_messages_nocache, but cache the result.
132 # PROP is the property we're checking, and doubles as a prefix for
133 # temporary filenames.
134 proc check_no_compiler_messages {prop args} {
135 return [check_cached_effective_target $prop {
136 eval [list check_no_compiler_messages_nocache $prop] $args
140 # Like check_compile, but return true if the compiler printed no
141 # messages and if the contents of the output file satisfy PATTERN.
142 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
143 # don't match regular expression REGEXP, otherwise they satisfy it
144 # if they do match regular expression PATTERN. (PATTERN can start
145 # with something like "[!]" if the regular expression needs to match
146 # "!" as the first character.)
148 # Delete the output file before returning. The other arguments are
149 # as for check_compile.
150 proc check_no_messages_and_pattern_nocache {basename pattern args} {
153 set result [eval [list check_compile $basename] $args]
154 set lines [lindex $result 0]
155 set output [lindex $result 1]
158 if { [string match "" $lines] } {
159 set chan [open "$output"]
160 set invert [regexp {^!(.*)} $pattern dummy pattern]
161 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
165 remote_file build delete $output
169 # Like check_no_messages_and_pattern_nocache, but cache the result.
170 # PROP is the property we're checking, and doubles as a prefix for
171 # temporary filenames.
172 proc check_no_messages_and_pattern {prop pattern args} {
173 return [check_cached_effective_target $prop {
174 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
178 # Try to compile and run an executable from code CONTENTS. Return true
179 # if the compiler reports no messages and if execution "passes" in the
180 # usual DejaGNU sense. The arguments are as for check_compile, with
181 # TYPE implicitly being "executable".
182 proc check_runtime_nocache {basename contents args} {
185 set result [eval [list check_compile $basename executable $contents] $args]
186 set lines [lindex $result 0]
187 set output [lindex $result 1]
190 if { [string match "" $lines] } {
191 # No error messages, everything is OK.
192 set result [remote_load target "./$output" "" ""]
193 set status [lindex $result 0]
194 verbose "check_runtime_nocache $basename: status is <$status>" 2
195 if { $status == "pass" } {
199 remote_file build delete $output
203 # Like check_runtime_nocache, but cache the result. PROP is the
204 # property we're checking, and doubles as a prefix for temporary
206 proc check_runtime {prop args} {
209 return [check_cached_effective_target $prop {
210 eval [list check_runtime_nocache $prop] $args
214 ###############################
215 # proc check_weak_available { }
216 ###############################
218 # weak symbols are only supported in some configs/object formats
219 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
221 proc check_weak_available { } {
222 global target_triplet
225 # All mips targets should support it
227 if { [ string first "mips" $target_cpu ] >= 0 } {
231 # All solaris2 targets should support it
233 if { [regexp ".*-solaris2.*" $target_triplet] } {
237 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
239 if { [regexp "alpha.*osf.*" $target_triplet] } {
243 # Windows targets Cygwin and MingW32 support it
245 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
249 # HP-UX 10.X doesn't support it
251 if { [istarget "hppa*-*-hpux10*"] } {
255 # ELF and ECOFF support it. a.out does with gas/gld but may also with
256 # other linkers, so we should try it
258 set objformat [gcc_target_object_format]
266 unknown { return -1 }
271 ###############################
272 # proc check_weak_override_available { }
273 ###############################
275 # Like check_weak_available, but return 0 if weak symbol definitions
276 # cannot be overridden.
278 proc check_weak_override_available { } {
279 if { [istarget "*-*-mingw*"] } {
282 return [check_weak_available]
285 ###############################
286 # proc check_visibility_available { what_kind }
287 ###############################
289 # The visibility attribute is only support in some object formats
290 # This proc returns 1 if it is supported, 0 if not.
291 # The argument is the kind of visibility, default/protected/hidden/internal.
293 proc check_visibility_available { what_kind } {
295 global target_triplet
297 # On NetWare, support makes no sense.
298 if { [istarget *-*-netware*] } {
302 if [string match "" $what_kind] { set what_kind "hidden" }
304 return [check_no_compiler_messages visibility_available_$what_kind object "
305 void f() __attribute__((visibility(\"$what_kind\")));
310 ###############################
311 # proc check_alias_available { }
312 ###############################
314 # Determine if the target toolchain supports the alias attribute.
316 # Returns 2 if the target supports aliases. Returns 1 if the target
317 # only supports weak aliased. Returns 0 if the target does not
318 # support aliases at all. Returns -1 if support for aliases could not
321 proc check_alias_available { } {
322 global alias_available_saved
325 if [info exists alias_available_saved] {
326 verbose "check_alias_available returning saved $alias_available_saved" 2
330 verbose "check_alias_available compiling testfile $src" 2
331 set f [open $src "w"]
332 # Compile a small test program. The definition of "g" is
333 # necessary to keep the Solaris assembler from complaining
335 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
336 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
338 set lines [${tool}_target_compile $src $obj object ""]
340 remote_file build delete $obj
342 if [string match "" $lines] then {
343 # No error messages, everything is OK.
344 set alias_available_saved 2
346 if [regexp "alias definitions not supported" $lines] {
347 verbose "check_alias_available target does not support aliases" 2
349 set objformat [gcc_target_object_format]
351 if { $objformat == "elf" } {
352 verbose "check_alias_available but target uses ELF format, so it ought to" 2
353 set alias_available_saved -1
355 set alias_available_saved 0
358 if [regexp "only weak aliases are supported" $lines] {
359 verbose "check_alias_available target supports only weak aliases" 2
360 set alias_available_saved 1
362 set alias_available_saved -1
367 verbose "check_alias_available returning $alias_available_saved" 2
370 return $alias_available_saved
373 ###############################
374 # proc check_ifunc_available { }
375 ###############################
377 # Determine if the target toolchain supports the ifunc attribute.
379 # Returns 1 if the target supports ifunc. Returns 0 if the target
380 # does not support ifunc.
382 proc check_ifunc_available { } {
383 global ifunc_available_saved
386 if [info exists ifunc_available_saved] {
387 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
391 verbose "check_ifunc_available compiling testfile $src" 2
392 set f [open $src "w"]
394 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
395 puts $f "void g() {}"
396 puts $f "void f() __attribute__((ifunc(\"g\")));"
398 set lines [${tool}_target_compile $src $obj object ""]
400 remote_file build delete $obj
402 if [string match "" $lines] then {
403 set ifunc_available_saved 1
405 set ifunc_available_saved 0
408 verbose "check_ifunc_available returning $ifunc_available_saved" 2
411 return $ifunc_available_saved
414 # Returns true if --gc-sections is supported on the target.
416 proc check_gc_sections_available { } {
417 global gc_sections_available_saved
420 if {![info exists gc_sections_available_saved]} {
421 # Some targets don't support gc-sections despite whatever's
422 # advertised by ld's options.
423 if { [istarget alpha*-*-*]
424 || [istarget ia64-*-*] } {
425 set gc_sections_available_saved 0
429 # elf2flt uses -q (--emit-relocs), which is incompatible with
431 if { [board_info target exists ldflags]
432 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
433 set gc_sections_available_saved 0
437 # VxWorks kernel modules are relocatable objects linked with -r,
438 # while RTP executables are linked with -q (--emit-relocs).
439 # Both of these options are incompatible with --gc-sections.
440 if { [istarget *-*-vxworks*] } {
441 set gc_sections_available_saved 0
445 # Check if the ld used by gcc supports --gc-sections.
446 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
447 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
448 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
449 set ld_output [remote_exec host "$gcc_ld" "--help"]
450 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
451 set gc_sections_available_saved 1
453 set gc_sections_available_saved 0
456 return $gc_sections_available_saved
459 # Return 1 if according to target_info struct and explicit target list
460 # target is supposed to support trampolines.
462 proc check_effective_target_trampolines { } {
463 if [target_info exists no_trampolines] {
466 if { [istarget avr-*-*]
467 || [istarget hppa2.0w-hp-hpux11.23]
468 || [istarget hppa64-hp-hpux11.23] } {
474 # Return 1 if according to target_info struct and explicit target list
475 # target is supposed to keep null pointer checks. This could be due to
476 # use of option fno-delete-null-pointer-checks or hardwired in target.
478 proc check_effective_target_keeps_null_pointer_checks { } {
479 if [target_info exists keeps_null_pointer_checks] {
482 if { [istarget avr-*-*] } {
488 # Return true if profiling is supported on the target.
490 proc check_profiling_available { test_what } {
491 global profiling_available_saved
493 verbose "Profiling argument is <$test_what>" 1
495 # These conditions depend on the argument so examine them before
496 # looking at the cache variable.
498 # Support for -p on solaris2 relies on mcrt1.o which comes with the
499 # vendor compiler. We cannot reliably predict the directory where the
500 # vendor compiler (and thus mcrt1.o) is installed so we can't
501 # necessarily find mcrt1.o even if we have it.
502 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
506 # Support for -p on irix relies on libprof1.a which doesn't appear to
507 # exist on any irix6 system currently posting testsuite results.
508 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
509 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
510 if { [istarget mips*-*-irix*]
511 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
515 # We don't yet support profiling for MIPS16.
516 if { [istarget mips*-*-*]
517 && ![check_effective_target_nomips16]
518 && ([lindex $test_what 1] == "-p"
519 || [lindex $test_what 1] == "-pg") } {
523 # MinGW does not support -p.
524 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
528 # cygwin does not support -p.
529 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
533 # uClibc does not have gcrt1.o.
534 if { [check_effective_target_uclibc]
535 && ([lindex $test_what 1] == "-p"
536 || [lindex $test_what 1] == "-pg") } {
540 # Now examine the cache variable.
541 if {![info exists profiling_available_saved]} {
542 # Some targets don't have any implementation of __bb_init_func or are
543 # missing other needed machinery.
544 if { [istarget am3*-*-linux*]
545 || [istarget arm*-*-eabi*]
546 || [istarget arm*-*-elf]
547 || [istarget arm*-*-symbianelf*]
548 || [istarget avr-*-*]
549 || [istarget bfin-*-*]
550 || [istarget cris-*-*]
551 || [istarget crisv32-*-*]
552 || [istarget fido-*-elf]
553 || [istarget h8300-*-*]
554 || [istarget lm32-*-*]
555 || [istarget m32c-*-elf]
556 || [istarget m68k-*-elf]
557 || [istarget m68k-*-uclinux*]
558 || [istarget mep-*-elf]
559 || [istarget mips*-*-elf*]
560 || [istarget mmix-*-*]
561 || [istarget mn10300-*-elf*]
562 || [istarget moxie-*-elf*]
563 || [istarget picochip-*-*]
564 || [istarget powerpc-*-eabi*]
565 || [istarget powerpc-*-elf]
567 || [istarget xstormy16-*]
568 || [istarget xtensa*-*-elf]
569 || [istarget *-*-netware*]
570 || [istarget *-*-rtems*]
571 || [istarget *-*-vxworks*] } {
572 set profiling_available_saved 0
574 set profiling_available_saved 1
578 return $profiling_available_saved
581 # Check to see if a target is "freestanding". This is as per the definition
582 # in Section 4 of C99 standard. Effectively, it is a target which supports no
583 # extra headers or libraries other than what is considered essential.
584 proc check_effective_target_freestanding { } {
585 if { [istarget picochip-*-*] } then {
592 # Return 1 if target has packed layout of structure members by
593 # default, 0 otherwise. Note that this is slightly different than
594 # whether the target has "natural alignment": both attributes may be
597 proc check_effective_target_default_packed { } {
598 return [check_no_compiler_messages default_packed assembly {
599 struct x { char a; long b; } c;
600 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
604 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
605 # documentation, where the test also comes from.
607 proc check_effective_target_pcc_bitfield_type_matters { } {
608 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
609 # bitfields, but let's stick to the example code from the docs.
610 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
611 struct foo1 { char x; char :0; char y; };
612 struct foo2 { char x; int :0; char y; };
613 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
617 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
619 proc add_options_for_tls { flags } {
620 # Tru64 UNIX uses emutls, which relies on a couple of pthread functions
621 # which only live in libpthread, so always pass -pthread for TLS.
622 if { [istarget *-*-osf*] } {
623 return "$flags -pthread"
625 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
626 # libthread, so always pass -pthread for native TLS.
627 # Need to duplicate native TLS check from
628 # check_effective_target_tls_native to avoid recursion.
629 if { [istarget *-*-solaris2.\[89\]*] &&
630 [check_no_messages_and_pattern tls_native "!emutls" assembly {
632 int f (void) { return i; }
633 void g (int j) { i = j; }
635 return "$flags -pthread"
640 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
642 proc check_effective_target_tls {} {
643 return [check_no_compiler_messages tls assembly {
645 int f (void) { return i; }
646 void g (int j) { i = j; }
650 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
652 proc check_effective_target_tls_native {} {
653 # VxWorks uses emulated TLS machinery, but with non-standard helper
654 # functions, so we fail to automatically detect it.
655 global target_triplet
656 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
660 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
662 int f (void) { return i; }
663 void g (int j) { i = j; }
667 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
669 proc check_effective_target_tls_emulated {} {
670 # VxWorks uses emulated TLS machinery, but with non-standard helper
671 # functions, so we fail to automatically detect it.
672 global target_triplet
673 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
677 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
679 int f (void) { return i; }
680 void g (int j) { i = j; }
684 # Return 1 if TLS executables can run correctly, 0 otherwise.
686 proc check_effective_target_tls_runtime {} {
687 return [check_runtime tls_runtime {
688 __thread int thr = 0;
689 int main (void) { return thr; }
690 } [add_options_for_tls ""]]
693 # Return 1 if -ffunction-sections is supported, 0 otherwise.
695 proc check_effective_target_function_sections {} {
696 # Darwin has its own scheme and silently accepts -ffunction-sections.
697 global target_triplet
698 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
702 return [check_no_compiler_messages functionsections assembly {
704 } "-ffunction-sections"]
707 # Return 1 if compilation with -fgraphite is error-free for trivial
710 proc check_effective_target_fgraphite {} {
711 return [check_no_compiler_messages fgraphite object {
716 # Return 1 if compilation with -fopenmp is error-free for trivial
719 proc check_effective_target_fopenmp {} {
720 return [check_no_compiler_messages fopenmp object {
725 # Return 1 if compilation with -pthread is error-free for trivial
728 proc check_effective_target_pthread {} {
729 return [check_no_compiler_messages pthread object {
734 # Return 1 if compilation with -mpe-aligned-commons is error-free
735 # for trivial code, 0 otherwise.
737 proc check_effective_target_pe_aligned_commons {} {
738 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
739 return [check_no_compiler_messages pe_aligned_commons object {
741 } "-mpe-aligned-commons"]
746 # Return 1 if the target supports -static
747 proc check_effective_target_static {} {
748 return [check_no_compiler_messages static executable {
749 int main (void) { return 0; }
753 # Return 1 if the target supports -fstack-protector
754 proc check_effective_target_fstack_protector {} {
755 return [check_runtime fstack_protector {
756 int main (void) { return 0; }
757 } "-fstack-protector"]
760 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
761 # for trivial code, 0 otherwise.
763 proc check_effective_target_freorder {} {
764 return [check_no_compiler_messages freorder object {
766 } "-freorder-blocks-and-partition"]
769 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
770 # emitted, 0 otherwise. Whether a shared library can actually be built is
771 # out of scope for this test.
773 proc check_effective_target_fpic { } {
774 # Note that M68K has a multilib that supports -fpic but not
775 # -fPIC, so we need to check both. We test with a program that
776 # requires GOT references.
777 foreach arg {fpic fPIC} {
778 if [check_no_compiler_messages $arg object {
779 extern int foo (void); extern int bar;
780 int baz (void) { return foo () + bar; }
788 # Return true if the target supports -mpaired-single (as used on MIPS).
790 proc check_effective_target_mpaired_single { } {
791 return [check_no_compiler_messages mpaired_single object {
796 # Return true if the target has access to FPU instructions.
798 proc check_effective_target_hard_float { } {
799 if { [istarget mips*-*-*] } {
800 return [check_no_compiler_messages hard_float assembly {
801 #if (defined __mips_soft_float || defined __mips16)
807 # This proc is actually checking the availabilty of FPU
808 # support for doubles, so on the RX we must fail if the
809 # 64-bit double multilib has been selected.
810 if { [istarget rx-*-*] } {
812 # return [check_no_compiler_messages hard_float assembly {
813 #if defined __RX_64_BIT_DOUBLES__
819 # The generic test equates hard_float with "no call for adding doubles".
820 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
821 double a (double b, double c) { return b + c; }
825 # Return true if the target is a 64-bit MIPS target.
827 proc check_effective_target_mips64 { } {
828 return [check_no_compiler_messages mips64 assembly {
835 # Return true if the target is a MIPS target that does not produce
838 proc check_effective_target_nomips16 { } {
839 return [check_no_compiler_messages nomips16 object {
843 /* A cheap way of testing for -mflip-mips16. */
844 void foo (void) { asm ("addiu $20,$20,1"); }
845 void bar (void) { asm ("addiu $20,$20,1"); }
850 # Add the options needed for MIPS16 function attributes. At the moment,
851 # we don't support MIPS16 PIC.
853 proc add_options_for_mips16_attribute { flags } {
854 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
857 # Return true if we can force a mode that allows MIPS16 code generation.
858 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
861 proc check_effective_target_mips16_attribute { } {
862 return [check_no_compiler_messages mips16_attribute assembly {
866 #if defined __mips_hard_float \
867 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
868 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
871 } [add_options_for_mips16_attribute ""]]
874 # Return 1 if the target supports long double larger than double when
875 # using the new ABI, 0 otherwise.
877 proc check_effective_target_mips_newabi_large_long_double { } {
878 return [check_no_compiler_messages mips_newabi_large_long_double object {
879 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
883 # Return 1 if the current multilib does not generate PIC by default.
885 proc check_effective_target_nonpic { } {
886 return [check_no_compiler_messages nonpic assembly {
893 # Return 1 if the target does not use a status wrapper.
895 proc check_effective_target_unwrapped { } {
896 if { [target_info needs_status_wrapper] != "" \
897 && [target_info needs_status_wrapper] != "0" } {
903 # Return true if iconv is supported on the target. In particular IBM1047.
905 proc check_iconv_available { test_what } {
908 # If the tool configuration file has not set libiconv, try "-liconv"
909 if { ![info exists libiconv] } {
910 set libiconv "-liconv"
912 set test_what [lindex $test_what 1]
913 return [check_runtime_nocache $test_what [subst {
919 cd = iconv_open ("$test_what", "UTF-8");
920 if (cd == (iconv_t) -1)
927 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
929 proc check_ascii_locale_available { } {
930 if { ([ishost alpha*-dec-osf*] || [ishost mips-sgi-irix*]) } {
931 # Neither Tru64 UNIX nor IRIX support an ASCII locale.
938 # Return true if named sections are supported on this target.
940 proc check_named_sections_available { } {
941 return [check_no_compiler_messages named_sections assembly {
942 int __attribute__ ((section("whatever"))) foo;
946 # Return 1 if the target supports Fortran real kinds larger than real(8),
949 # When the target name changes, replace the cached result.
951 proc check_effective_target_fortran_large_real { } {
952 return [check_no_compiler_messages fortran_large_real executable {
954 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
961 # Return 1 if the target supports Fortran real kind real(16),
962 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
963 # this checks for Real(16) only; the other returned real(10) if
964 # both real(10) and real(16) are available.
966 # When the target name changes, replace the cached result.
968 proc check_effective_target_fortran_real_16 { } {
969 return [check_no_compiler_messages fortran_real_16 executable {
977 # Return 1 if the target supports Fortran integer kinds larger than
978 # integer(8), 0 otherwise.
980 # When the target name changes, replace the cached result.
982 proc check_effective_target_fortran_large_int { } {
983 return [check_no_compiler_messages fortran_large_int executable {
985 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
991 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
993 # When the target name changes, replace the cached result.
995 proc check_effective_target_fortran_integer_16 { } {
996 return [check_no_compiler_messages fortran_integer_16 executable {
1003 # Return 1 if we can statically link libgfortran, 0 otherwise.
1005 # When the target name changes, replace the cached result.
1007 proc check_effective_target_static_libgfortran { } {
1008 return [check_no_compiler_messages static_libgfortran executable {
1015 proc check_linker_plugin_available { } {
1016 return [check_no_compiler_messages_nocache linker_plugin executable {
1017 int main() { return 0; }
1018 } "-flto -fuse-linker-plugin"]
1021 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1022 # otherwise. Cache the result.
1024 proc check_750cl_hw_available { } {
1025 return [check_cached_effective_target 750cl_hw_available {
1026 # If this is not the right target then we can skip the test.
1027 if { ![istarget powerpc-*paired*] } {
1030 check_runtime_nocache 750cl_hw_available {
1034 asm volatile ("ps_mul v0,v0,v0");
1036 asm volatile ("ps_mul 0,0,0");
1045 # Return 1 if the target OS supports running SSE executables, 0
1046 # otherwise. Cache the result.
1048 proc check_sse_os_support_available { } {
1049 return [check_cached_effective_target sse_os_support_available {
1050 # If this is not the right target then we can skip the test.
1051 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1053 } elseif { [istarget i?86-*-solaris2*] } {
1054 # The Solaris 2 kernel doesn't save and restore SSE registers
1055 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1056 check_runtime_nocache sse_os_support_available {
1059 __asm__ volatile ("movss %xmm2,%xmm1");
1069 # Return 1 if the target supports executing SSE instructions, 0
1070 # otherwise. Cache the result.
1072 proc check_sse_hw_available { } {
1073 return [check_cached_effective_target sse_hw_available {
1074 # If this is not the right target then we can skip the test.
1075 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1078 check_runtime_nocache sse_hw_available {
1082 unsigned int eax, ebx, ecx, edx;
1083 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1084 return !(edx & bit_SSE);
1092 # Return 1 if the target supports executing SSE2 instructions, 0
1093 # otherwise. Cache the result.
1095 proc check_sse2_hw_available { } {
1096 return [check_cached_effective_target sse2_hw_available {
1097 # If this is not the right target then we can skip the test.
1098 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1101 check_runtime_nocache sse2_hw_available {
1105 unsigned int eax, ebx, ecx, edx;
1106 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1107 return !(edx & bit_SSE2);
1115 # Return 1 if the target supports executing AVX instructions, 0
1116 # otherwise. Cache the result.
1118 proc check_avx_hw_available { } {
1119 return [check_cached_effective_target avx_hw_available {
1120 # If this is not the right target then we can skip the test.
1121 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1124 check_runtime_nocache avx_hw_available {
1128 unsigned int eax, ebx, ecx, edx;
1129 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1130 return ((ecx & (bit_AVX | bit_OSXSAVE))
1131 != (bit_AVX | bit_OSXSAVE));
1139 # Return 1 if the target supports running SSE executables, 0 otherwise.
1141 proc check_effective_target_sse_runtime { } {
1142 if { [check_effective_target_sse]
1143 && [check_sse_hw_available]
1144 && [check_sse_os_support_available] } {
1150 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1152 proc check_effective_target_sse2_runtime { } {
1153 if { [check_effective_target_sse2]
1154 && [check_sse2_hw_available]
1155 && [check_sse_os_support_available] } {
1161 # Return 1 if the target supports running AVX executables, 0 otherwise.
1163 proc check_effective_target_avx_runtime { } {
1164 if { [check_effective_target_avx]
1165 && [check_avx_hw_available] } {
1171 # Return 1 if the target supports executing VSX instructions, 0
1172 # otherwise. Cache the result.
1174 proc check_vsx_hw_available { } {
1175 return [check_cached_effective_target vsx_hw_available {
1176 # Some simulators are known to not support VSX instructions.
1177 # For now, disable on Darwin
1178 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1182 check_runtime_nocache vsx_hw_available {
1186 asm volatile ("xxlor vs0,vs0,vs0");
1188 asm volatile ("xxlor 0,0,0");
1197 # Return 1 if the target supports executing AltiVec instructions, 0
1198 # otherwise. Cache the result.
1200 proc check_vmx_hw_available { } {
1201 return [check_cached_effective_target vmx_hw_available {
1202 # Some simulators are known to not support VMX instructions.
1203 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1206 # Most targets don't require special flags for this test case, but
1207 # Darwin does. Just to be sure, make sure VSX is not enabled for
1208 # the altivec tests.
1209 if { [istarget *-*-darwin*]
1210 || [istarget *-*-aix*] } {
1211 set options "-maltivec -mno-vsx"
1213 set options "-mno-vsx"
1215 check_runtime_nocache vmx_hw_available {
1219 asm volatile ("vor v0,v0,v0");
1221 asm volatile ("vor 0,0,0");
1230 proc check_ppc_recip_hw_available { } {
1231 return [check_cached_effective_target ppc_recip_hw_available {
1232 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1233 # For now, disable on Darwin
1234 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1237 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1238 check_runtime_nocache ppc_recip_hw_available {
1239 volatile double d_recip, d_rsqrt, d_four = 4.0;
1240 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1243 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1244 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1245 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1246 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1254 # Return 1 if the target supports executing AltiVec and Cell PPU
1255 # instructions, 0 otherwise. Cache the result.
1257 proc check_effective_target_cell_hw { } {
1258 return [check_cached_effective_target cell_hw_available {
1259 # Some simulators are known to not support VMX and PPU instructions.
1260 if { [istarget powerpc-*-eabi*] } {
1263 # Most targets don't require special flags for this test
1264 # case, but Darwin and AIX do.
1265 if { [istarget *-*-darwin*]
1266 || [istarget *-*-aix*] } {
1267 set options "-maltivec -mcpu=cell"
1269 set options "-mcpu=cell"
1271 check_runtime_nocache cell_hw_available {
1275 asm volatile ("vor v0,v0,v0");
1276 asm volatile ("lvlx v0,r0,r0");
1278 asm volatile ("vor 0,0,0");
1279 asm volatile ("lvlx 0,0,0");
1288 # Return 1 if the target supports executing 64-bit instructions, 0
1289 # otherwise. Cache the result.
1291 proc check_effective_target_powerpc64 { } {
1292 global powerpc64_available_saved
1295 if [info exists powerpc64_available_saved] {
1296 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1298 set powerpc64_available_saved 0
1300 # Some simulators are known to not support powerpc64 instructions.
1301 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1302 verbose "check_effective_target_powerpc64 returning 0" 2
1303 return $powerpc64_available_saved
1306 # Set up, compile, and execute a test program containing a 64-bit
1307 # instruction. Include the current process ID in the file
1308 # names to prevent conflicts with invocations for multiple
1313 set f [open $src "w"]
1314 puts $f "int main() {"
1315 puts $f "#ifdef __MACH__"
1316 puts $f " asm volatile (\"extsw r0,r0\");"
1318 puts $f " asm volatile (\"extsw 0,0\");"
1320 puts $f " return 0; }"
1323 set opts "additional_flags=-mcpu=G5"
1325 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1326 set lines [${tool}_target_compile $src $exe executable "$opts"]
1329 if [string match "" $lines] then {
1330 # No error message, compilation succeeded.
1331 set result [${tool}_load "./$exe" "" ""]
1332 set status [lindex $result 0]
1333 remote_file build delete $exe
1334 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1336 if { $status == "pass" } then {
1337 set powerpc64_available_saved 1
1340 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1344 return $powerpc64_available_saved
1347 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1348 # complex float arguments. This affects gfortran tests that call cabsf
1349 # in libm built by an earlier compiler. Return 1 if libm uses the same
1350 # argument passing as the compiler under test, 0 otherwise.
1352 # When the target name changes, replace the cached result.
1354 proc check_effective_target_broken_cplxf_arg { } {
1355 return [check_cached_effective_target broken_cplxf_arg {
1356 # Skip the work for targets known not to be affected.
1357 if { ![istarget powerpc64-*-linux*] } {
1359 } elseif { ![is-effective-target lp64] } {
1362 check_runtime_nocache broken_cplxf_arg {
1363 #include <complex.h>
1364 extern void abort (void);
1365 float fabsf (float);
1366 float cabsf (_Complex float);
1373 if (fabsf (f - 5.0) > 0.0001)
1382 proc check_alpha_max_hw_available { } {
1383 return [check_runtime alpha_max_hw_available {
1384 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1388 # Returns true iff the FUNCTION is available on the target system.
1389 # (This is essentially a Tcl implementation of Autoconf's
1392 proc check_function_available { function } {
1393 return [check_no_compiler_messages ${function}_available \
1399 int main () { $function (); }
1403 # Returns true iff "fork" is available on the target system.
1405 proc check_fork_available {} {
1406 return [check_function_available "fork"]
1409 # Returns true iff "mkfifo" is available on the target system.
1411 proc check_mkfifo_available {} {
1412 if {[istarget *-*-cygwin*]} {
1413 # Cygwin has mkfifo, but support is incomplete.
1417 return [check_function_available "mkfifo"]
1420 # Returns true iff "__cxa_atexit" is used on the target system.
1422 proc check_cxa_atexit_available { } {
1423 return [check_cached_effective_target cxa_atexit_available {
1424 if { [istarget "hppa*-*-hpux10*"] } {
1425 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1427 } elseif { [istarget "*-*-vxworks"] } {
1428 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1431 check_runtime_nocache cxa_atexit_available {
1434 static unsigned int count;
1451 Y() { f(); count = 2; }
1460 int main() { return 0; }
1466 proc check_effective_target_objc2 { } {
1467 return [check_no_compiler_messages objc2 object {
1476 proc check_effective_target_next_runtime { } {
1477 return [check_no_compiler_messages objc2 object {
1478 #ifdef __NEXT_RUNTIME__
1486 # Return 1 if we're generating 32-bit code using default options, 0
1489 proc check_effective_target_ilp32 { } {
1490 return [check_no_compiler_messages ilp32 object {
1491 int dummy[sizeof (int) == 4
1492 && sizeof (void *) == 4
1493 && sizeof (long) == 4 ? 1 : -1];
1497 # Return 1 if we're generating 32-bit or larger integers using default
1498 # options, 0 otherwise.
1500 proc check_effective_target_int32plus { } {
1501 return [check_no_compiler_messages int32plus object {
1502 int dummy[sizeof (int) >= 4 ? 1 : -1];
1506 # Return 1 if we're generating 32-bit or larger pointers using default
1507 # options, 0 otherwise.
1509 proc check_effective_target_ptr32plus { } {
1510 return [check_no_compiler_messages ptr32plus object {
1511 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1515 # Return 1 if we support 32-bit or larger array and structure sizes
1516 # using default options, 0 otherwise.
1518 proc check_effective_target_size32plus { } {
1519 return [check_no_compiler_messages size32plus object {
1524 # Returns 1 if we're generating 16-bit or smaller integers with the
1525 # default options, 0 otherwise.
1527 proc check_effective_target_int16 { } {
1528 return [check_no_compiler_messages int16 object {
1529 int dummy[sizeof (int) < 4 ? 1 : -1];
1533 # Return 1 if we're generating 64-bit code using default options, 0
1536 proc check_effective_target_lp64 { } {
1537 return [check_no_compiler_messages lp64 object {
1538 int dummy[sizeof (int) == 4
1539 && sizeof (void *) == 8
1540 && sizeof (long) == 8 ? 1 : -1];
1544 # Return 1 if we're generating 64-bit code using default llp64 options,
1547 proc check_effective_target_llp64 { } {
1548 return [check_no_compiler_messages llp64 object {
1549 int dummy[sizeof (int) == 4
1550 && sizeof (void *) == 8
1551 && sizeof (long long) == 8
1552 && sizeof (long) == 4 ? 1 : -1];
1556 # Return 1 if the target supports long double larger than double,
1559 proc check_effective_target_large_long_double { } {
1560 return [check_no_compiler_messages large_long_double object {
1561 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1565 # Return 1 if the target supports double larger than float,
1568 proc check_effective_target_large_double { } {
1569 return [check_no_compiler_messages large_double object {
1570 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1574 # Return 1 if the target supports double of 64 bits,
1577 proc check_effective_target_double64 { } {
1578 return [check_no_compiler_messages double64 object {
1579 int dummy[sizeof(double) == 8 ? 1 : -1];
1583 # Return 1 if the target supports double of at least 64 bits,
1586 proc check_effective_target_double64plus { } {
1587 return [check_no_compiler_messages double64plus object {
1588 int dummy[sizeof(double) >= 8 ? 1 : -1];
1592 # Return 1 if the target supports compiling fixed-point,
1595 proc check_effective_target_fixed_point { } {
1596 return [check_no_compiler_messages fixed_point object {
1597 _Sat _Fract x; _Sat _Accum y;
1601 # Return 1 if the target supports compiling decimal floating point,
1604 proc check_effective_target_dfp_nocache { } {
1605 verbose "check_effective_target_dfp_nocache: compiling source" 2
1606 set ret [check_no_compiler_messages_nocache dfp object {
1607 float x __attribute__((mode(DD)));
1609 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1613 proc check_effective_target_dfprt_nocache { } {
1614 return [check_runtime_nocache dfprt {
1615 typedef float d64 __attribute__((mode(DD)));
1616 d64 x = 1.2df, y = 2.3dd, z;
1617 int main () { z = x + y; return 0; }
1621 # Return 1 if the target supports compiling Decimal Floating Point,
1624 # This won't change for different subtargets so cache the result.
1626 proc check_effective_target_dfp { } {
1627 return [check_cached_effective_target dfp {
1628 check_effective_target_dfp_nocache
1632 # Return 1 if the target supports linking and executing Decimal Floating
1633 # Point, 0 otherwise.
1635 # This won't change for different subtargets so cache the result.
1637 proc check_effective_target_dfprt { } {
1638 return [check_cached_effective_target dfprt {
1639 check_effective_target_dfprt_nocache
1643 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1645 proc check_effective_target_ucn_nocache { } {
1646 # -std=c99 is only valid for C
1647 if [check_effective_target_c] {
1648 set ucnopts "-std=c99"
1650 append ucnopts " -fextended-identifiers"
1651 verbose "check_effective_target_ucn_nocache: compiling source" 2
1652 set ret [check_no_compiler_messages_nocache ucn object {
1655 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1659 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1661 # This won't change for different subtargets, so cache the result.
1663 proc check_effective_target_ucn { } {
1664 return [check_cached_effective_target ucn {
1665 check_effective_target_ucn_nocache
1669 # Return 1 if the target needs a command line argument to enable a SIMD
1672 proc check_effective_target_vect_cmdline_needed { } {
1673 global et_vect_cmdline_needed_saved
1674 global et_vect_cmdline_needed_target_name
1676 if { ![info exists et_vect_cmdline_needed_target_name] } {
1677 set et_vect_cmdline_needed_target_name ""
1680 # If the target has changed since we set the cached value, clear it.
1681 set current_target [current_target_name]
1682 if { $current_target != $et_vect_cmdline_needed_target_name } {
1683 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1684 set et_vect_cmdline_needed_target_name $current_target
1685 if { [info exists et_vect_cmdline_needed_saved] } {
1686 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1687 unset et_vect_cmdline_needed_saved
1691 if [info exists et_vect_cmdline_needed_saved] {
1692 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1694 set et_vect_cmdline_needed_saved 1
1695 if { [istarget alpha*-*-*]
1696 || [istarget ia64-*-*]
1697 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1698 && [check_effective_target_lp64])
1699 || ([istarget powerpc*-*-*]
1700 && ([check_effective_target_powerpc_spe]
1701 || [check_effective_target_powerpc_altivec]))
1702 || [istarget spu-*-*]
1703 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1704 set et_vect_cmdline_needed_saved 0
1708 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1709 return $et_vect_cmdline_needed_saved
1712 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1714 # This won't change for different subtargets so cache the result.
1716 proc check_effective_target_vect_int { } {
1717 global et_vect_int_saved
1719 if [info exists et_vect_int_saved] {
1720 verbose "check_effective_target_vect_int: using cached result" 2
1722 set et_vect_int_saved 0
1723 if { [istarget i?86-*-*]
1724 || ([istarget powerpc*-*-*]
1725 && ![istarget powerpc-*-linux*paired*])
1726 || [istarget spu-*-*]
1727 || [istarget x86_64-*-*]
1728 || [istarget sparc*-*-*]
1729 || [istarget alpha*-*-*]
1730 || [istarget ia64-*-*]
1731 || [check_effective_target_arm32]
1732 || ([istarget mips*-*-*]
1733 && [check_effective_target_mips_loongson]) } {
1734 set et_vect_int_saved 1
1738 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1739 return $et_vect_int_saved
1742 # Return 1 if the target supports signed int->float conversion
1745 proc check_effective_target_vect_intfloat_cvt { } {
1746 global et_vect_intfloat_cvt_saved
1748 if [info exists et_vect_intfloat_cvt_saved] {
1749 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1751 set et_vect_intfloat_cvt_saved 0
1752 if { [istarget i?86-*-*]
1753 || ([istarget powerpc*-*-*]
1754 && ![istarget powerpc-*-linux*paired*])
1755 || [istarget x86_64-*-*] } {
1756 set et_vect_intfloat_cvt_saved 1
1760 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1761 return $et_vect_intfloat_cvt_saved
1764 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1766 proc check_effective_target_int128 { } {
1767 return [check_no_compiler_messages int128 object {
1769 #ifndef __SIZEOF_INT128__
1778 # Return 1 if the target supports unsigned int->float conversion
1781 proc check_effective_target_vect_uintfloat_cvt { } {
1782 global et_vect_uintfloat_cvt_saved
1784 if [info exists et_vect_uintfloat_cvt_saved] {
1785 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1787 set et_vect_uintfloat_cvt_saved 0
1788 if { [istarget i?86-*-*]
1789 || ([istarget powerpc*-*-*]
1790 && ![istarget powerpc-*-linux*paired*])
1791 || [istarget x86_64-*-*] } {
1792 set et_vect_uintfloat_cvt_saved 1
1796 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1797 return $et_vect_uintfloat_cvt_saved
1801 # Return 1 if the target supports signed float->int conversion
1804 proc check_effective_target_vect_floatint_cvt { } {
1805 global et_vect_floatint_cvt_saved
1807 if [info exists et_vect_floatint_cvt_saved] {
1808 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1810 set et_vect_floatint_cvt_saved 0
1811 if { [istarget i?86-*-*]
1812 || ([istarget powerpc*-*-*]
1813 && ![istarget powerpc-*-linux*paired*])
1814 || [istarget x86_64-*-*] } {
1815 set et_vect_floatint_cvt_saved 1
1819 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1820 return $et_vect_floatint_cvt_saved
1823 # Return 1 if the target supports unsigned float->int conversion
1826 proc check_effective_target_vect_floatuint_cvt { } {
1827 global et_vect_floatuint_cvt_saved
1829 if [info exists et_vect_floatuint_cvt_saved] {
1830 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1832 set et_vect_floatuint_cvt_saved 0
1833 if { ([istarget powerpc*-*-*]
1834 && ![istarget powerpc-*-linux*paired*]) } {
1835 set et_vect_floatuint_cvt_saved 1
1839 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1840 return $et_vect_floatuint_cvt_saved
1843 # Return 1 is this is an arm target using 32-bit instructions
1844 proc check_effective_target_arm32 { } {
1845 return [check_no_compiler_messages arm32 assembly {
1846 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1852 # Return 1 if this is an ARM target that only supports aligned vector accesses
1853 proc check_effective_target_arm_vect_no_misalign { } {
1854 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1855 #if !defined(__arm__) \
1856 || (defined(__ARMEL__) \
1857 && (!defined(__thumb__) || defined(__thumb2__)))
1864 # Return 1 if this is an ARM target supporting -mfpu=vfp
1865 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1868 proc check_effective_target_arm_vfp_ok { } {
1869 if { [check_effective_target_arm32] } {
1870 return [check_no_compiler_messages arm_vfp_ok object {
1872 } "-mfpu=vfp -mfloat-abi=softfp"]
1878 # Return 1 if this is an ARM target supporting -mfpu=vfp
1879 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1882 proc check_effective_target_arm_hard_vfp_ok { } {
1883 if { [check_effective_target_arm32] } {
1884 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1885 int main() { return 0;}
1886 } "-mfpu=vfp -mfloat-abi=hard"]
1892 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1893 # or -mfloat-abi=hard, but if one is already specified by the
1894 # multilib, use it. Similarly, if a -mfpu option already enables
1895 # NEON, do not add -mfpu=neon.
1897 proc add_options_for_arm_neon { flags } {
1898 if { ! [check_effective_target_arm_neon_ok] } {
1901 global et_arm_neon_flags
1902 return "$flags $et_arm_neon_flags"
1905 # Return 1 if this is an ARM target supporting -mfpu=neon
1906 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1907 # incompatible with these options. Also set et_arm_neon_flags to the
1908 # best options to add.
1910 proc check_effective_target_arm_neon_ok_nocache { } {
1911 global et_arm_neon_flags
1912 set et_arm_neon_flags ""
1913 if { [check_effective_target_arm32] } {
1914 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1915 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1916 #include "arm_neon.h"
1919 set et_arm_neon_flags $flags
1928 proc check_effective_target_arm_neon_ok { } {
1929 return [check_cached_effective_target arm_neon_ok \
1930 check_effective_target_arm_neon_ok_nocache]
1933 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1934 # or -mfloat-abi=hard, but if one is already specified by the
1937 proc add_options_for_arm_neon_fp16 { flags } {
1938 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1941 global et_arm_neon_fp16_flags
1942 return "$flags $et_arm_neon_fp16_flags"
1945 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1946 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1947 # incompatible with these options. Also set et_arm_neon_flags to the
1948 # best options to add.
1950 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1951 global et_arm_neon_fp16_flags
1952 set et_arm_neon_fp16_flags ""
1953 if { [check_effective_target_arm32] } {
1954 # Always add -mfpu=neon-fp16, since there is no preprocessor
1955 # macro for FP16 support.
1956 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1957 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1958 #include "arm_neon.h"
1961 set et_arm_neon_fp16_flags $flags
1970 proc check_effective_target_arm_neon_fp16_ok { } {
1971 return [check_cached_effective_target arm_neon_fp16_ok \
1972 check_effective_target_arm_neon_fp16_ok_nocache]
1975 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1978 proc check_effective_target_arm_thumb1_ok { } {
1979 return [check_no_compiler_messages arm_thumb1_ok assembly {
1980 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1986 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1989 proc check_effective_target_arm_thumb2_ok { } {
1990 return [check_no_compiler_messages arm_thumb2_ok assembly {
1991 #if !defined(__thumb2__)
1997 # Return 1 if the target supports executing NEON instructions, 0
1998 # otherwise. Cache the result.
2000 proc check_effective_target_arm_neon_hw { } {
2001 return [check_runtime arm_neon_hw_available {
2005 long long a = 0, b = 1;
2006 asm ("vorr %P0, %P1, %P2"
2008 : "0" (a), "w" (b));
2011 } [add_options_for_arm_neon ""]]
2014 # Return 1 if this is a ARM target with NEON enabled.
2016 proc check_effective_target_arm_neon { } {
2017 if { [check_effective_target_arm32] } {
2018 return [check_no_compiler_messages arm_neon object {
2019 #ifndef __ARM_NEON__
2030 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2031 # the Loongson vector modes.
2033 proc check_effective_target_mips_loongson { } {
2034 return [check_no_compiler_messages loongson assembly {
2035 #if !defined(__mips_loongson_vector_rev)
2041 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2044 proc check_effective_target_arm_eabi { } {
2045 return [check_no_compiler_messages arm_eabi object {
2046 #ifndef __ARM_EABI__
2054 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2055 # Some multilibs may be incompatible with this option.
2057 proc check_effective_target_arm_iwmmxt_ok { } {
2058 if { [check_effective_target_arm32] } {
2059 return [check_no_compiler_messages arm_iwmmxt_ok object {
2067 # Return 1 if this is a PowerPC target with floating-point registers.
2069 proc check_effective_target_powerpc_fprs { } {
2070 if { [istarget powerpc*-*-*]
2071 || [istarget rs6000-*-*] } {
2072 return [check_no_compiler_messages powerpc_fprs object {
2084 # Return 1 if this is a PowerPC target with hardware double-precision
2087 proc check_effective_target_powerpc_hard_double { } {
2088 if { [istarget powerpc*-*-*]
2089 || [istarget rs6000-*-*] } {
2090 return [check_no_compiler_messages powerpc_hard_double object {
2102 # Return 1 if this is a PowerPC target supporting -maltivec.
2104 proc check_effective_target_powerpc_altivec_ok { } {
2105 if { ([istarget powerpc*-*-*]
2106 && ![istarget powerpc-*-linux*paired*])
2107 || [istarget rs6000-*-*] } {
2108 # AltiVec is not supported on AIX before 5.3.
2109 if { [istarget powerpc*-*-aix4*]
2110 || [istarget powerpc*-*-aix5.1*]
2111 || [istarget powerpc*-*-aix5.2*] } {
2114 return [check_no_compiler_messages powerpc_altivec_ok object {
2122 # Return 1 if this is a PowerPC target supporting -mvsx
2124 proc check_effective_target_powerpc_vsx_ok { } {
2125 if { ([istarget powerpc*-*-*]
2126 && ![istarget powerpc-*-linux*paired*])
2127 || [istarget rs6000-*-*] } {
2128 # AltiVec is not supported on AIX before 5.3.
2129 if { [istarget powerpc*-*-aix4*]
2130 || [istarget powerpc*-*-aix5.1*]
2131 || [istarget powerpc*-*-aix5.2*] } {
2134 return [check_no_compiler_messages powerpc_vsx_ok object {
2137 asm volatile ("xxlor vs0,vs0,vs0");
2139 asm volatile ("xxlor 0,0,0");
2149 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2151 proc check_effective_target_powerpc_ppu_ok { } {
2152 if [check_effective_target_powerpc_altivec_ok] {
2153 return [check_no_compiler_messages cell_asm_available object {
2156 asm volatile ("lvlx v0,v0,v0");
2158 asm volatile ("lvlx 0,0,0");
2168 # Return 1 if this is a PowerPC target that supports SPU.
2170 proc check_effective_target_powerpc_spu { } {
2171 if [istarget powerpc*-*-linux*] {
2172 return [check_effective_target_powerpc_altivec_ok]
2178 # Return 1 if this is a PowerPC SPE target. The check includes options
2179 # specified by dg-options for this test, so don't cache the result.
2181 proc check_effective_target_powerpc_spe_nocache { } {
2182 if { [istarget powerpc*-*-*] } {
2183 return [check_no_compiler_messages_nocache powerpc_spe object {
2189 } [current_compiler_flags]]
2195 # Return 1 if this is a PowerPC target with SPE enabled.
2197 proc check_effective_target_powerpc_spe { } {
2198 if { [istarget powerpc*-*-*] } {
2199 return [check_no_compiler_messages powerpc_spe object {
2211 # Return 1 if this is a PowerPC target with Altivec enabled.
2213 proc check_effective_target_powerpc_altivec { } {
2214 if { [istarget powerpc*-*-*] } {
2215 return [check_no_compiler_messages powerpc_altivec object {
2227 # Return 1 if this is a PowerPC 405 target. The check includes options
2228 # specified by dg-options for this test, so don't cache the result.
2230 proc check_effective_target_powerpc_405_nocache { } {
2231 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2232 return [check_no_compiler_messages_nocache powerpc_405 object {
2238 } [current_compiler_flags]]
2244 # Return 1 if this is a SPU target with a toolchain that
2245 # supports automatic overlay generation.
2247 proc check_effective_target_spu_auto_overlay { } {
2248 if { [istarget spu*-*-elf*] } {
2249 return [check_no_compiler_messages spu_auto_overlay executable {
2251 } "-Wl,--auto-overlay" ]
2257 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2258 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2259 # test environment appears to run executables on such a simulator.
2261 proc check_effective_target_ultrasparc_hw { } {
2262 return [check_runtime ultrasparc_hw {
2263 int main() { return 0; }
2264 } "-mcpu=ultrasparc"]
2267 # Return 1 if the target supports hardware vector shift operation.
2269 proc check_effective_target_vect_shift { } {
2270 global et_vect_shift_saved
2272 if [info exists et_vect_shift_saved] {
2273 verbose "check_effective_target_vect_shift: using cached result" 2
2275 set et_vect_shift_saved 0
2276 if { ([istarget powerpc*-*-*]
2277 && ![istarget powerpc-*-linux*paired*])
2278 || [istarget ia64-*-*]
2279 || [istarget i?86-*-*]
2280 || [istarget x86_64-*-*]
2281 || [check_effective_target_arm32]
2282 || ([istarget mips*-*-*]
2283 && [check_effective_target_mips_loongson]) } {
2284 set et_vect_shift_saved 1
2288 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2289 return $et_vect_shift_saved
2292 # Return 1 if the target supports hardware vector shift operation with
2293 # scalar shift argument.
2295 proc check_effective_target_vect_shift_scalar { } {
2296 global et_vect_shift_scalar_saved
2298 if [info exists et_vect_shift_scalar_saved] {
2299 verbose "check_effective_target_vect_shift_scalar: using cached result" 2
2301 set et_vect_shift_scalar_saved 0
2302 if { [istarget x86_64-*-*]
2303 || [istarget i?86-*-*] } {
2304 set et_vect_shift_scalar_saved 1
2308 verbose "check_effective_target_vect_shift_scalar: returning $et_vect_shift_scalar_saved" 2
2309 return $et_vect_shift_scalar_saved
2313 # Return 1 if the target supports hardware vector shift operation for char.
2315 proc check_effective_target_vect_shift_char { } {
2316 global et_vect_shift_char_saved
2318 if [info exists et_vect_shift_char_saved] {
2319 verbose "check_effective_target_vect_shift_char: using cached result" 2
2321 set et_vect_shift_char_saved 0
2322 if { ([istarget powerpc*-*-*]
2323 && ![istarget powerpc-*-linux*paired*])
2324 || [check_effective_target_arm32] } {
2325 set et_vect_shift_char_saved 1
2329 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2330 return $et_vect_shift_char_saved
2333 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2335 # This can change for different subtargets so do not cache the result.
2337 proc check_effective_target_vect_long { } {
2338 if { [istarget i?86-*-*]
2339 || (([istarget powerpc*-*-*]
2340 && ![istarget powerpc-*-linux*paired*])
2341 && [check_effective_target_ilp32])
2342 || [istarget x86_64-*-*]
2343 || [check_effective_target_arm32]
2344 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2350 verbose "check_effective_target_vect_long: returning $answer" 2
2354 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2356 # This won't change for different subtargets so cache the result.
2358 proc check_effective_target_vect_float { } {
2359 global et_vect_float_saved
2361 if [info exists et_vect_float_saved] {
2362 verbose "check_effective_target_vect_float: using cached result" 2
2364 set et_vect_float_saved 0
2365 if { [istarget i?86-*-*]
2366 || [istarget powerpc*-*-*]
2367 || [istarget spu-*-*]
2368 || [istarget mipsisa64*-*-*]
2369 || [istarget x86_64-*-*]
2370 || [istarget ia64-*-*]
2371 || [check_effective_target_arm32] } {
2372 set et_vect_float_saved 1
2376 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2377 return $et_vect_float_saved
2380 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2382 # This won't change for different subtargets so cache the result.
2384 proc check_effective_target_vect_double { } {
2385 global et_vect_double_saved
2387 if [info exists et_vect_double_saved] {
2388 verbose "check_effective_target_vect_double: using cached result" 2
2390 set et_vect_double_saved 0
2391 if { [istarget i?86-*-*]
2392 || [istarget x86_64-*-*] } {
2393 if { [check_no_compiler_messages vect_double assembly {
2394 #ifdef __tune_atom__
2395 # error No double vectorizer support.
2398 set et_vect_double_saved 1
2400 set et_vect_double_saved 0
2402 } elseif { [istarget spu-*-*] } {
2403 set et_vect_double_saved 1
2407 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2408 return $et_vect_double_saved
2411 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2413 # This won't change for different subtargets so cache the result.
2415 proc check_effective_target_vect_long_long { } {
2416 global et_vect_long_long_saved
2418 if [info exists et_vect_long_long_saved] {
2419 verbose "check_effective_target_vect_long_long: using cached result" 2
2421 set et_vect_long_long_saved 0
2422 if { [istarget i?86-*-*]
2423 || [istarget x86_64-*-*] } {
2424 set et_vect_long_long_saved 1
2428 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2429 return $et_vect_long_long_saved
2433 # Return 1 if the target plus current options does not support a vector
2434 # max instruction on "int", 0 otherwise.
2436 # This won't change for different subtargets so cache the result.
2438 proc check_effective_target_vect_no_int_max { } {
2439 global et_vect_no_int_max_saved
2441 if [info exists et_vect_no_int_max_saved] {
2442 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2444 set et_vect_no_int_max_saved 0
2445 if { [istarget sparc*-*-*]
2446 || [istarget spu-*-*]
2447 || [istarget alpha*-*-*]
2448 || ([istarget mips*-*-*]
2449 && [check_effective_target_mips_loongson]) } {
2450 set et_vect_no_int_max_saved 1
2453 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2454 return $et_vect_no_int_max_saved
2457 # Return 1 if the target plus current options does not support a vector
2458 # add instruction on "int", 0 otherwise.
2460 # This won't change for different subtargets so cache the result.
2462 proc check_effective_target_vect_no_int_add { } {
2463 global et_vect_no_int_add_saved
2465 if [info exists et_vect_no_int_add_saved] {
2466 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2468 set et_vect_no_int_add_saved 0
2469 # Alpha only supports vector add on V8QI and V4HI.
2470 if { [istarget alpha*-*-*] } {
2471 set et_vect_no_int_add_saved 1
2474 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2475 return $et_vect_no_int_add_saved
2478 # Return 1 if the target plus current options does not support vector
2479 # bitwise instructions, 0 otherwise.
2481 # This won't change for different subtargets so cache the result.
2483 proc check_effective_target_vect_no_bitwise { } {
2484 global et_vect_no_bitwise_saved
2486 if [info exists et_vect_no_bitwise_saved] {
2487 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2489 set et_vect_no_bitwise_saved 0
2491 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2492 return $et_vect_no_bitwise_saved
2495 # Return 1 if the target plus current options supports vector permutation,
2498 # This won't change for different subtargets so cache the result.
2500 proc check_effective_target_vect_perm { } {
2503 if [info exists et_vect_perm_saved] {
2504 verbose "check_effective_target_vect_perm: using cached result" 2
2506 set et_vect_perm_saved 0
2507 if { [istarget powerpc*-*-*]
2508 || [istarget spu-*-*]
2509 || [istarget i?86-*-*]
2510 || [istarget x86_64-*-*] } {
2511 set et_vect_perm_saved 1
2514 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2515 return $et_vect_perm_saved
2518 # Return 1 if the target plus current options supports vector permutation
2519 # on byte-sized elements, 0 otherwise.
2521 # This won't change for different subtargets so cache the result.
2523 proc check_effective_target_vect_perm_byte { } {
2524 global et_vect_perm_byte
2526 if [info exists et_vect_perm_byte_saved] {
2527 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2529 set et_vect_perm_byte_saved 0
2530 if { [istarget powerpc*-*-*]
2531 || [istarget spu-*-*] } {
2532 set et_vect_perm_byte_saved 1
2535 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2536 return $et_vect_perm_byte_saved
2539 # Return 1 if the target plus current options supports vector permutation
2540 # on short-sized elements, 0 otherwise.
2542 # This won't change for different subtargets so cache the result.
2544 proc check_effective_target_vect_perm_short { } {
2545 global et_vect_perm_short
2547 if [info exists et_vect_perm_short_saved] {
2548 verbose "check_effective_target_vect_perm_short: using cached result" 2
2550 set et_vect_perm_short_saved 0
2551 if { [istarget powerpc*-*-*]
2552 || [istarget spu-*-*] } {
2553 set et_vect_perm_short_saved 1
2556 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2557 return $et_vect_perm_short_saved
2560 # Return 1 if the target plus current options supports a vector
2561 # widening summation of *short* args into *int* result, 0 otherwise.
2563 # This won't change for different subtargets so cache the result.
2565 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2566 global et_vect_widen_sum_hi_to_si_pattern
2568 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2569 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2571 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2572 if { [istarget powerpc*-*-*]
2573 || [istarget ia64-*-*] } {
2574 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2577 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2578 return $et_vect_widen_sum_hi_to_si_pattern_saved
2581 # Return 1 if the target plus current options supports a vector
2582 # widening summation of *short* args into *int* result, 0 otherwise.
2583 # A target can also support this widening summation if it can support
2584 # promotion (unpacking) from shorts to ints.
2586 # This won't change for different subtargets so cache the result.
2588 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2589 global et_vect_widen_sum_hi_to_si
2591 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2592 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2594 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2595 if { [istarget powerpc*-*-*]
2596 || [istarget ia64-*-*] } {
2597 set et_vect_widen_sum_hi_to_si_saved 1
2600 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2601 return $et_vect_widen_sum_hi_to_si_saved
2604 # Return 1 if the target plus current options supports a vector
2605 # widening summation of *char* args into *short* result, 0 otherwise.
2606 # A target can also support this widening summation if it can support
2607 # promotion (unpacking) from chars to shorts.
2609 # This won't change for different subtargets so cache the result.
2611 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2612 global et_vect_widen_sum_qi_to_hi
2614 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2615 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2617 set et_vect_widen_sum_qi_to_hi_saved 0
2618 if { [check_effective_target_vect_unpack]
2619 || [istarget ia64-*-*] } {
2620 set et_vect_widen_sum_qi_to_hi_saved 1
2623 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2624 return $et_vect_widen_sum_qi_to_hi_saved
2627 # Return 1 if the target plus current options supports a vector
2628 # widening summation of *char* args into *int* result, 0 otherwise.
2630 # This won't change for different subtargets so cache the result.
2632 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2633 global et_vect_widen_sum_qi_to_si
2635 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2636 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2638 set et_vect_widen_sum_qi_to_si_saved 0
2639 if { [istarget powerpc*-*-*] } {
2640 set et_vect_widen_sum_qi_to_si_saved 1
2643 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2644 return $et_vect_widen_sum_qi_to_si_saved
2647 # Return 1 if the target plus current options supports a vector
2648 # widening multiplication of *char* args into *short* result, 0 otherwise.
2649 # A target can also support this widening multplication if it can support
2650 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2651 # multiplication of shorts).
2653 # This won't change for different subtargets so cache the result.
2656 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2657 global et_vect_widen_mult_qi_to_hi
2659 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2660 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2662 if { [check_effective_target_vect_unpack]
2663 && [check_effective_target_vect_short_mult] } {
2664 set et_vect_widen_mult_qi_to_hi_saved 1
2666 set et_vect_widen_mult_qi_to_hi_saved 0
2668 if { [istarget powerpc*-*-*] } {
2669 set et_vect_widen_mult_qi_to_hi_saved 1
2672 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2673 return $et_vect_widen_mult_qi_to_hi_saved
2676 # Return 1 if the target plus current options supports a vector
2677 # widening multiplication of *short* args into *int* result, 0 otherwise.
2678 # A target can also support this widening multplication if it can support
2679 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2680 # multiplication of ints).
2682 # This won't change for different subtargets so cache the result.
2685 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2686 global et_vect_widen_mult_hi_to_si
2688 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2689 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2691 if { [check_effective_target_vect_unpack]
2692 && [check_effective_target_vect_int_mult] } {
2693 set et_vect_widen_mult_hi_to_si_saved 1
2695 set et_vect_widen_mult_hi_to_si_saved 0
2697 if { [istarget powerpc*-*-*]
2698 || [istarget spu-*-*]
2699 || [istarget ia64-*-*]
2700 || [istarget i?86-*-*]
2701 || [istarget x86_64-*-*] } {
2702 set et_vect_widen_mult_hi_to_si_saved 1
2705 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2706 return $et_vect_widen_mult_hi_to_si_saved
2709 # Return 1 if the target plus current options supports a vector
2710 # dot-product of signed chars, 0 otherwise.
2712 # This won't change for different subtargets so cache the result.
2714 proc check_effective_target_vect_sdot_qi { } {
2715 global et_vect_sdot_qi
2717 if [info exists et_vect_sdot_qi_saved] {
2718 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2720 set et_vect_sdot_qi_saved 0
2721 if { [istarget ia64-*-*] } {
2722 set et_vect_udot_qi_saved 1
2725 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2726 return $et_vect_sdot_qi_saved
2729 # Return 1 if the target plus current options supports a vector
2730 # dot-product of unsigned chars, 0 otherwise.
2732 # This won't change for different subtargets so cache the result.
2734 proc check_effective_target_vect_udot_qi { } {
2735 global et_vect_udot_qi
2737 if [info exists et_vect_udot_qi_saved] {
2738 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2740 set et_vect_udot_qi_saved 0
2741 if { [istarget powerpc*-*-*]
2742 || [istarget ia64-*-*] } {
2743 set et_vect_udot_qi_saved 1
2746 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2747 return $et_vect_udot_qi_saved
2750 # Return 1 if the target plus current options supports a vector
2751 # dot-product of signed shorts, 0 otherwise.
2753 # This won't change for different subtargets so cache the result.
2755 proc check_effective_target_vect_sdot_hi { } {
2756 global et_vect_sdot_hi
2758 if [info exists et_vect_sdot_hi_saved] {
2759 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2761 set et_vect_sdot_hi_saved 0
2762 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2763 || [istarget ia64-*-*]
2764 || [istarget i?86-*-*]
2765 || [istarget x86_64-*-*] } {
2766 set et_vect_sdot_hi_saved 1
2769 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2770 return $et_vect_sdot_hi_saved
2773 # Return 1 if the target plus current options supports a vector
2774 # dot-product of unsigned shorts, 0 otherwise.
2776 # This won't change for different subtargets so cache the result.
2778 proc check_effective_target_vect_udot_hi { } {
2779 global et_vect_udot_hi
2781 if [info exists et_vect_udot_hi_saved] {
2782 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2784 set et_vect_udot_hi_saved 0
2785 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2786 set et_vect_udot_hi_saved 1
2789 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2790 return $et_vect_udot_hi_saved
2794 # Return 1 if the target plus current options supports a vector
2795 # demotion (packing) of shorts (to chars) and ints (to shorts)
2796 # using modulo arithmetic, 0 otherwise.
2798 # This won't change for different subtargets so cache the result.
2800 proc check_effective_target_vect_pack_trunc { } {
2801 global et_vect_pack_trunc
2803 if [info exists et_vect_pack_trunc_saved] {
2804 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2806 set et_vect_pack_trunc_saved 0
2807 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2808 || [istarget i?86-*-*]
2809 || [istarget x86_64-*-*]
2810 || [istarget spu-*-*]
2811 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2812 set et_vect_pack_trunc_saved 1
2815 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2816 return $et_vect_pack_trunc_saved
2819 # Return 1 if the target plus current options supports a vector
2820 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2822 # This won't change for different subtargets so cache the result.
2824 proc check_effective_target_vect_unpack { } {
2825 global et_vect_unpack
2827 if [info exists et_vect_unpack_saved] {
2828 verbose "check_effective_target_vect_unpack: using cached result" 2
2830 set et_vect_unpack_saved 0
2831 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2832 || [istarget i?86-*-*]
2833 || [istarget x86_64-*-*]
2834 || [istarget spu-*-*]
2835 || [istarget ia64-*-*]
2836 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2837 set et_vect_unpack_saved 1
2840 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2841 return $et_vect_unpack_saved
2844 # Return 1 if the target plus current options does not guarantee
2845 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2847 # This won't change for different subtargets so cache the result.
2849 proc check_effective_target_unaligned_stack { } {
2850 global et_unaligned_stack_saved
2852 if [info exists et_unaligned_stack_saved] {
2853 verbose "check_effective_target_unaligned_stack: using cached result" 2
2855 set et_unaligned_stack_saved 0
2857 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2858 return $et_unaligned_stack_saved
2861 # Return 1 if the target plus current options does not support a vector
2862 # alignment mechanism, 0 otherwise.
2864 # This won't change for different subtargets so cache the result.
2866 proc check_effective_target_vect_no_align { } {
2867 global et_vect_no_align_saved
2869 if [info exists et_vect_no_align_saved] {
2870 verbose "check_effective_target_vect_no_align: using cached result" 2
2872 set et_vect_no_align_saved 0
2873 if { [istarget mipsisa64*-*-*]
2874 || [istarget sparc*-*-*]
2875 || [istarget ia64-*-*]
2876 || [check_effective_target_arm_vect_no_misalign]
2877 || ([istarget mips*-*-*]
2878 && [check_effective_target_mips_loongson]) } {
2879 set et_vect_no_align_saved 1
2882 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2883 return $et_vect_no_align_saved
2886 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2888 # This won't change for different subtargets so cache the result.
2890 proc check_effective_target_vect_hw_misalign { } {
2891 global et_vect_hw_misalign_saved
2893 if [info exists et_vect_hw_misalign_saved] {
2894 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2896 set et_vect_hw_misalign_saved 0
2897 if { ([istarget x86_64-*-*]
2898 || [istarget i?86-*-*]) } {
2899 set et_vect_hw_misalign_saved 1
2902 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2903 return $et_vect_hw_misalign_saved
2907 # Return 1 if arrays are aligned to the vector alignment
2908 # boundary, 0 otherwise.
2910 # This won't change for different subtargets so cache the result.
2912 proc check_effective_target_vect_aligned_arrays { } {
2913 global et_vect_aligned_arrays
2915 if [info exists et_vect_aligned_arrays_saved] {
2916 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2918 set et_vect_aligned_arrays_saved 0
2919 if { (([istarget x86_64-*-*]
2920 || [istarget i?86-*-*]) && [is-effective-target lp64])
2921 || [istarget spu-*-*] } {
2922 set et_vect_aligned_arrays_saved 1
2925 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2926 return $et_vect_aligned_arrays_saved
2929 # Return 1 if types of size 32 bit or less are naturally aligned
2930 # (aligned to their type-size), 0 otherwise.
2932 # This won't change for different subtargets so cache the result.
2934 proc check_effective_target_natural_alignment_32 { } {
2935 global et_natural_alignment_32
2937 if [info exists et_natural_alignment_32_saved] {
2938 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2940 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2941 set et_natural_alignment_32_saved 1
2942 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2943 set et_natural_alignment_32_saved 0
2946 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2947 return $et_natural_alignment_32_saved
2950 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2951 # type-size), 0 otherwise.
2953 # This won't change for different subtargets so cache the result.
2955 proc check_effective_target_natural_alignment_64 { } {
2956 global et_natural_alignment_64
2958 if [info exists et_natural_alignment_64_saved] {
2959 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2961 set et_natural_alignment_64_saved 0
2962 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2963 || [istarget spu-*-*] } {
2964 set et_natural_alignment_64_saved 1
2967 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2968 return $et_natural_alignment_64_saved
2971 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2973 # This won't change for different subtargets so cache the result.
2975 proc check_effective_target_vector_alignment_reachable { } {
2976 global et_vector_alignment_reachable
2978 if [info exists et_vector_alignment_reachable_saved] {
2979 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2981 if { [check_effective_target_vect_aligned_arrays]
2982 || [check_effective_target_natural_alignment_32] } {
2983 set et_vector_alignment_reachable_saved 1
2985 set et_vector_alignment_reachable_saved 0
2988 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2989 return $et_vector_alignment_reachable_saved
2992 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2994 # This won't change for different subtargets so cache the result.
2996 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2997 global et_vector_alignment_reachable_for_64bit
2999 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3000 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3002 if { [check_effective_target_vect_aligned_arrays]
3003 || [check_effective_target_natural_alignment_64] } {
3004 set et_vector_alignment_reachable_for_64bit_saved 1
3006 set et_vector_alignment_reachable_for_64bit_saved 0
3009 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3010 return $et_vector_alignment_reachable_for_64bit_saved
3013 # Return 1 if the target only requires element alignment for vector accesses
3015 proc check_effective_target_vect_element_align { } {
3016 global et_vect_element_align
3018 if [info exists et_vect_element_align] {
3019 verbose "check_effective_target_vect_element_align: using cached result" 2
3021 set et_vect_element_align 0
3022 if { [istarget arm*-*-*]
3023 || [check_effective_target_vect_hw_misalign] } {
3024 set et_vect_element_align 1
3028 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3029 return $et_vect_element_align
3032 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3034 proc check_effective_target_vect_condition { } {
3035 global et_vect_cond_saved
3037 if [info exists et_vect_cond_saved] {
3038 verbose "check_effective_target_vect_cond: using cached result" 2
3040 set et_vect_cond_saved 0
3041 if { [istarget powerpc*-*-*]
3042 || [istarget ia64-*-*]
3043 || [istarget i?86-*-*]
3044 || [istarget spu-*-*]
3045 || [istarget x86_64-*-*] } {
3046 set et_vect_cond_saved 1
3050 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3051 return $et_vect_cond_saved
3054 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3056 proc check_effective_target_vect_char_mult { } {
3057 global et_vect_char_mult_saved
3059 if [info exists et_vect_char_mult_saved] {
3060 verbose "check_effective_target_vect_char_mult: using cached result" 2
3062 set et_vect_char_mult_saved 0
3063 if { [istarget ia64-*-*]
3064 || [istarget i?86-*-*]
3065 || [istarget x86_64-*-*] } {
3066 set et_vect_char_mult_saved 1
3070 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3071 return $et_vect_char_mult_saved
3074 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3076 proc check_effective_target_vect_short_mult { } {
3077 global et_vect_short_mult_saved
3079 if [info exists et_vect_short_mult_saved] {
3080 verbose "check_effective_target_vect_short_mult: using cached result" 2
3082 set et_vect_short_mult_saved 0
3083 if { [istarget ia64-*-*]
3084 || [istarget spu-*-*]
3085 || [istarget i?86-*-*]
3086 || [istarget x86_64-*-*]
3087 || [istarget powerpc*-*-*]
3088 || [check_effective_target_arm32]
3089 || ([istarget mips*-*-*]
3090 && [check_effective_target_mips_loongson]) } {
3091 set et_vect_short_mult_saved 1
3095 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3096 return $et_vect_short_mult_saved
3099 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3101 proc check_effective_target_vect_int_mult { } {
3102 global et_vect_int_mult_saved
3104 if [info exists et_vect_int_mult_saved] {
3105 verbose "check_effective_target_vect_int_mult: using cached result" 2
3107 set et_vect_int_mult_saved 0
3108 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3109 || [istarget spu-*-*]
3110 || [istarget i?86-*-*]
3111 || [istarget x86_64-*-*]
3112 || [istarget ia64-*-*]
3113 || [check_effective_target_arm32] } {
3114 set et_vect_int_mult_saved 1
3118 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3119 return $et_vect_int_mult_saved
3122 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3124 proc check_effective_target_vect_extract_even_odd { } {
3125 global et_vect_extract_even_odd_saved
3127 if [info exists et_vect_extract_even_odd_saved] {
3128 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3130 set et_vect_extract_even_odd_saved 0
3131 if { [istarget powerpc*-*-*]
3132 || [istarget i?86-*-*]
3133 || [istarget x86_64-*-*]
3134 || [istarget ia64-*-*]
3135 || [istarget spu-*-*] } {
3136 set et_vect_extract_even_odd_saved 1
3140 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3141 return $et_vect_extract_even_odd_saved
3144 # Return 1 if the target supports vector interleaving, 0 otherwise.
3146 proc check_effective_target_vect_interleave { } {
3147 global et_vect_interleave_saved
3149 if [info exists et_vect_interleave_saved] {
3150 verbose "check_effective_target_vect_interleave: using cached result" 2
3152 set et_vect_interleave_saved 0
3153 if { [istarget powerpc*-*-*]
3154 || [istarget i?86-*-*]
3155 || [istarget x86_64-*-*]
3156 || [istarget ia64-*-*]
3157 || [istarget spu-*-*] } {
3158 set et_vect_interleave_saved 1
3162 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3163 return $et_vect_interleave_saved
3166 foreach N {2 3 4 8} {
3167 eval [string map [list N $N] {
3168 # Return 1 if the target supports 2-vector interleaving
3169 proc check_effective_target_vect_stridedN { } {
3170 global et_vect_stridedN_saved
3172 if [info exists et_vect_stridedN_saved] {
3173 verbose "check_effective_target_vect_stridedN: using cached result" 2
3175 set et_vect_stridedN_saved 0
3177 && [check_effective_target_vect_interleave]
3178 && [check_effective_target_vect_extract_even_odd] } {
3179 set et_vect_stridedN_saved 1
3181 if { [istarget arm*-*-*] && N >= 2 && N <= 4 } {
3182 set et_vect_stridedN_saved 1
3186 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3187 return $et_vect_stridedN_saved
3192 # Return 1 if the target supports section-anchors
3194 proc check_effective_target_section_anchors { } {
3195 global et_section_anchors_saved
3197 if [info exists et_section_anchors_saved] {
3198 verbose "check_effective_target_section_anchors: using cached result" 2
3200 set et_section_anchors_saved 0
3201 if { [istarget powerpc*-*-*]
3202 || [istarget arm*-*-*] } {
3203 set et_section_anchors_saved 1
3207 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3208 return $et_section_anchors_saved
3211 # Return 1 if the target supports atomic operations on "int" and "long".
3213 proc check_effective_target_sync_int_long { } {
3214 global et_sync_int_long_saved
3216 if [info exists et_sync_int_long_saved] {
3217 verbose "check_effective_target_sync_int_long: using cached result" 2
3219 set et_sync_int_long_saved 0
3220 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3221 # load-reserved/store-conditional instructions.
3222 if { [istarget ia64-*-*]
3223 || [istarget i?86-*-*]
3224 || [istarget x86_64-*-*]
3225 || [istarget alpha*-*-*]
3226 || [istarget arm*-*-linux-gnueabi]
3227 || [istarget bfin*-*linux*]
3228 || [istarget hppa*-*linux*]
3229 || [istarget s390*-*-*]
3230 || [istarget powerpc*-*-*]
3231 || [istarget sparc64-*-*]
3232 || [istarget sparcv9-*-*]
3233 || [istarget mips*-*-*] } {
3234 set et_sync_int_long_saved 1
3238 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3239 return $et_sync_int_long_saved
3242 # Return 1 if the target supports atomic operations on "char" and "short".
3244 proc check_effective_target_sync_char_short { } {
3245 global et_sync_char_short_saved
3247 if [info exists et_sync_char_short_saved] {
3248 verbose "check_effective_target_sync_char_short: using cached result" 2
3250 set et_sync_char_short_saved 0
3251 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3252 # load-reserved/store-conditional instructions.
3253 if { [istarget ia64-*-*]
3254 || [istarget i?86-*-*]
3255 || [istarget x86_64-*-*]
3256 || [istarget alpha*-*-*]
3257 || [istarget arm*-*-linux-gnueabi]
3258 || [istarget hppa*-*linux*]
3259 || [istarget s390*-*-*]
3260 || [istarget powerpc*-*-*]
3261 || [istarget sparc64-*-*]
3262 || [istarget sparcv9-*-*]
3263 || [istarget mips*-*-*] } {
3264 set et_sync_char_short_saved 1
3268 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3269 return $et_sync_char_short_saved
3272 # Return 1 if the target uses a ColdFire FPU.
3274 proc check_effective_target_coldfire_fpu { } {
3275 return [check_no_compiler_messages coldfire_fpu assembly {
3282 # Return true if this is a uClibc target.
3284 proc check_effective_target_uclibc {} {
3285 return [check_no_compiler_messages uclibc object {
3286 #include <features.h>
3287 #if !defined (__UCLIBC__)
3293 # Return true if this is a uclibc target and if the uclibc feature
3294 # described by __$feature__ is not present.
3296 proc check_missing_uclibc_feature {feature} {
3297 return [check_no_compiler_messages $feature object "
3298 #include <features.h>
3299 #if !defined (__UCLIBC) || defined (__${feature}__)
3305 # Return true if this is a Newlib target.
3307 proc check_effective_target_newlib {} {
3308 return [check_no_compiler_messages newlib object {
3314 # (a) an error of a few ULP is expected in string to floating-point
3315 # conversion functions; and
3316 # (b) overflow is not always detected correctly by those functions.
3318 proc check_effective_target_lax_strtofp {} {
3319 # By default, assume that all uClibc targets suffer from this.
3320 return [check_effective_target_uclibc]
3323 # Return 1 if this is a target for which wcsftime is a dummy
3324 # function that always returns 0.
3326 proc check_effective_target_dummy_wcsftime {} {
3327 # By default, assume that all uClibc targets suffer from this.
3328 return [check_effective_target_uclibc]
3331 # Return 1 if constructors with initialization priority arguments are
3332 # supposed on this target.
3334 proc check_effective_target_init_priority {} {
3335 return [check_no_compiler_messages init_priority assembly "
3336 void f() __attribute__((constructor (1000)));
3341 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3342 # This can be used with any check_* proc that takes no argument and
3343 # returns only 1 or 0. It could be used with check_* procs that take
3344 # arguments with keywords that pass particular arguments.
3346 proc is-effective-target { arg } {
3348 if { [info procs check_effective_target_${arg}] != [list] } {
3349 set selected [check_effective_target_${arg}]
3352 "vmx_hw" { set selected [check_vmx_hw_available] }
3353 "vsx_hw" { set selected [check_vsx_hw_available] }
3354 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3355 "named_sections" { set selected [check_named_sections_available] }
3356 "gc_sections" { set selected [check_gc_sections_available] }
3357 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3358 default { error "unknown effective target keyword `$arg'" }
3361 verbose "is-effective-target: $arg $selected" 2
3365 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3367 proc is-effective-target-keyword { arg } {
3368 if { [info procs check_effective_target_${arg}] != [list] } {
3371 # These have different names for their check_* procs.
3373 "vmx_hw" { return 1 }
3374 "vsx_hw" { return 1 }
3375 "ppc_recip_hw" { return 1 }
3376 "named_sections" { return 1 }
3377 "gc_sections" { return 1 }
3378 "cxa_atexit" { return 1 }
3379 default { return 0 }
3384 # Return 1 if target default to short enums
3386 proc check_effective_target_short_enums { } {
3387 return [check_no_compiler_messages short_enums assembly {
3389 int s[sizeof (enum foo) == 1 ? 1 : -1];
3393 # Return 1 if target supports merging string constants at link time.
3395 proc check_effective_target_string_merging { } {
3396 return [check_no_messages_and_pattern string_merging \
3397 "rodata\\.str" assembly {
3398 const char *var = "String";
3402 # Return 1 if target has the basic signed and unsigned types in
3403 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3404 # working <stdint.h> for all targets.
3406 proc check_effective_target_stdint_types { } {
3407 return [check_no_compiler_messages stdint_types assembly {
3409 int8_t a; int16_t b; int32_t c; int64_t d;
3410 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3414 # Return 1 if target has the basic signed and unsigned types in
3415 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3416 # these types agree with those in the header, as some systems have
3417 # only <inttypes.h>.
3419 proc check_effective_target_inttypes_types { } {
3420 return [check_no_compiler_messages inttypes_types assembly {
3421 #include <inttypes.h>
3422 int8_t a; int16_t b; int32_t c; int64_t d;
3423 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3427 # Return 1 if programs are intended to be run on a simulator
3428 # (i.e. slowly) rather than hardware (i.e. fast).
3430 proc check_effective_target_simulator { } {
3432 # All "src/sim" simulators set this one.
3433 if [board_info target exists is_simulator] {
3434 return [board_info target is_simulator]
3437 # The "sid" simulators don't set that one, but at least they set
3439 if [board_info target exists slow_simulator] {
3440 return [board_info target slow_simulator]
3446 # Return 1 if the target is a VxWorks kernel.
3448 proc check_effective_target_vxworks_kernel { } {
3449 return [check_no_compiler_messages vxworks_kernel assembly {
3450 #if !defined __vxworks || defined __RTP__
3456 # Return 1 if the target is a VxWorks RTP.
3458 proc check_effective_target_vxworks_rtp { } {
3459 return [check_no_compiler_messages vxworks_rtp assembly {
3460 #if !defined __vxworks || !defined __RTP__
3466 # Return 1 if the target is expected to provide wide character support.
3468 proc check_effective_target_wchar { } {
3469 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3472 return [check_no_compiler_messages wchar assembly {
3477 # Return 1 if the target has <pthread.h>.
3479 proc check_effective_target_pthread_h { } {
3480 return [check_no_compiler_messages pthread_h assembly {
3481 #include <pthread.h>
3485 # Return 1 if the target can truncate a file from a file-descriptor,
3486 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3487 # chsize. We test for a trivially functional truncation; no stubs.
3488 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3489 # different function to be used.
3491 proc check_effective_target_fd_truncate { } {
3493 #define _FILE_OFFSET_BITS 64
3499 FILE *f = fopen ("tst.tmp", "wb");
3501 const char t[] = "test writing more than ten characters";
3504 write (fd, t, sizeof (t) - 1);
3506 if (ftruncate (fd, 10) != 0)
3509 f = fopen ("tst.tmp", "rb");
3510 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3516 if { [check_runtime ftruncate $prog] } {
3520 regsub "ftruncate" $prog "chsize" prog
3521 return [check_runtime chsize $prog]
3524 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3526 proc add_options_for_c99_runtime { flags } {
3527 if { [istarget *-*-solaris2*] } {
3528 return "$flags -std=c99"
3530 if { [istarget mips-sgi-irix6.5*] } {
3531 return "$flags -std=c99"
3533 if { [istarget powerpc-*-darwin*] } {
3534 return "$flags -mmacosx-version-min=10.3"
3539 # Add to FLAGS all the target-specific flags needed to enable
3540 # full IEEE compliance mode.
3542 proc add_options_for_ieee { flags } {
3543 if { [istarget "alpha*-*-*"]
3544 || [istarget "sh*-*-*"] } {
3545 return "$flags -mieee"
3547 if { [istarget "rx-*-*"] } {
3548 return "$flags -mnofpu"
3553 # Add to FLAGS the flags needed to enable functions to bind locally
3554 # when using pic/PIC passes in the testsuite.
3556 proc add_options_for_bind_pic_locally { flags } {
3557 if {[check_no_compiler_messages using_pic2 assembly {
3562 return "$flags -fPIE"
3564 if {[check_no_compiler_messages using_pic1 assembly {
3569 return "$flags -fpie"
3575 # Add to FLAGS the flags needed to enable 128-bit vectors.
3577 proc add_options_for_quad_vectors { flags } {
3578 if [is-effective-target arm_neon_ok] {
3579 return "$flags -mvectorize-with-neon-quad"
3585 # Return 1 if the target provides a full C99 runtime.
3587 proc check_effective_target_c99_runtime { } {
3588 return [check_cached_effective_target c99_runtime {
3591 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3592 set contents [read $file]
3595 #ifndef HAVE_C99_RUNTIME
3599 check_no_compiler_messages_nocache c99_runtime assembly \
3600 $contents [add_options_for_c99_runtime ""]
3604 # Return 1 if target wchar_t is at least 4 bytes.
3606 proc check_effective_target_4byte_wchar_t { } {
3607 return [check_no_compiler_messages 4byte_wchar_t object {
3608 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3612 # Return 1 if the target supports automatic stack alignment.
3614 proc check_effective_target_automatic_stack_alignment { } {
3615 # Ordinarily x86 supports automatic stack alignment ...
3616 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
3617 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
3618 # ... except Win64 SEH doesn't. Succeed for Win32 though.
3619 return [check_effective_target_ilp32];
3626 # Return 1 if avx instructions can be compiled.
3628 proc check_effective_target_avx { } {
3629 return [check_no_compiler_messages avx object {
3630 void _mm256_zeroall (void)
3632 __builtin_ia32_vzeroall ();
3637 # Return 1 if sse instructions can be compiled.
3638 proc check_effective_target_sse { } {
3639 return [check_no_compiler_messages sse object {
3642 __builtin_ia32_stmxcsr ();
3648 # Return 1 if sse2 instructions can be compiled.
3649 proc check_effective_target_sse2 { } {
3650 return [check_no_compiler_messages sse2 object {
3651 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3653 __m128i _mm_srli_si128 (__m128i __A, int __N)
3655 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3660 # Return 1 if F16C instructions can be compiled.
3662 proc check_effective_target_f16c { } {
3663 return [check_no_compiler_messages f16c object {
3664 #include "immintrin.h"
3666 foo (unsigned short val)
3668 return _cvtsh_ss (val);
3673 # Return 1 if C wchar_t type is compatible with char16_t.
3675 proc check_effective_target_wchar_t_char16_t_compatible { } {
3676 return [check_no_compiler_messages wchar_t_char16_t object {
3678 __CHAR16_TYPE__ *p16 = &wc;
3679 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3683 # Return 1 if C wchar_t type is compatible with char32_t.
3685 proc check_effective_target_wchar_t_char32_t_compatible { } {
3686 return [check_no_compiler_messages wchar_t_char32_t object {
3688 __CHAR32_TYPE__ *p32 = &wc;
3689 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3693 # Return 1 if pow10 function exists.
3695 proc check_effective_target_pow10 { } {
3696 return [check_runtime pow10 {
3706 # Return 1 if current options generate DFP instructions, 0 otherwise.
3708 proc check_effective_target_hard_dfp {} {
3709 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3710 typedef float d64 __attribute__((mode(DD)));
3712 void foo (void) { z = x + y; }
3716 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3717 # for strchr etc. functions.
3719 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3720 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3723 #if !defined(__cplusplus) \
3724 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3725 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3726 ISO C++ correct string.h and wchar.h protos not supported.
3733 # Return 1 if GNU as is used.
3735 proc check_effective_target_gas { } {
3736 global use_gas_saved
3739 if {![info exists use_gas_saved]} {
3740 # Check if the as used by gcc is GNU as.
3741 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3742 # Provide /dev/null as input, otherwise gas times out reading from
3744 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3745 set as_output [lindex $status 1]
3746 if { [ string first "GNU" $as_output ] >= 0 } {
3752 return $use_gas_saved
3755 # Return 1 if the compiler has been configure with link-time optimization
3758 proc check_effective_target_lto { } {
3760 return [info exists ENABLE_LTO]
3763 # Return 1 if this target supports the -fsplit-stack option, 0
3766 proc check_effective_target_split_stack {} {
3767 return [check_no_compiler_messages split_stack object {
3772 # Return 1 if the language for the compiler under test is C.
3774 proc check_effective_target_c { } {
3776 if [string match $tool "gcc"] {
3782 # Return 1 if the language for the compiler under test is C++.
3784 proc check_effective_target_c++ { } {
3786 if [string match $tool "g++"] {
3792 # Return 1 if expensive testcases should be run.
3794 proc check_effective_target_run_expensive_tests { } {
3795 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
3801 # Returns 1 if "mempcpy" is available on the target system.
3803 proc check_effective_target_mempcpy {} {
3804 return [check_function_available "mempcpy"]
3807 # Check whether the vectorizer tests are supported by the target and
3808 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
3809 # Set dg-do-what-default to either compile or run, depending on target
3810 # capabilities. Return 1 if vectorizer tests are supported by
3811 # target, 0 otherwise.
3813 proc check_vect_support_and_set_flags { } {
3814 global DEFAULT_VECTCFLAGS
3815 global dg-do-what-default
3817 if [istarget "powerpc-*paired*"] {
3818 lappend DEFAULT_VECTCFLAGS "-mpaired"
3819 if [check_750cl_hw_available] {
3820 set dg-do-what-default run
3822 set dg-do-what-default compile
3824 } elseif [istarget "powerpc*-*-*"] {
3825 # Skip targets not supporting -maltivec.
3826 if ![is-effective-target powerpc_altivec_ok] {
3830 lappend DEFAULT_VECTCFLAGS "-maltivec"
3831 if [check_vsx_hw_available] {
3832 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
3835 if [check_vmx_hw_available] {
3836 set dg-do-what-default run
3838 if [is-effective-target ilp32] {
3839 # Specify a cpu that supports VMX for compile-only tests.
3840 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
3842 set dg-do-what-default compile
3844 } elseif { [istarget "spu-*-*"] } {
3845 set dg-do-what-default run
3846 } elseif { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
3847 lappend DEFAULT_VECTCFLAGS "-msse2"
3848 if { [check_effective_target_sse2_runtime] } {
3849 set dg-do-what-default run
3851 set dg-do-what-default compile
3853 } elseif { [istarget "mips*-*-*"]
3854 && ([check_effective_target_mpaired_single]
3855 || [check_effective_target_mips_loongson])
3856 && [check_effective_target_nomips16] } {
3857 if { [check_effective_target_mpaired_single] } {
3858 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
3860 set dg-do-what-default run
3861 } elseif [istarget "sparc*-*-*"] {
3862 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
3863 if [check_effective_target_ultrasparc_hw] {
3864 set dg-do-what-default run
3866 set dg-do-what-default compile
3868 } elseif [istarget "alpha*-*-*"] {
3869 # Alpha's vectorization capabilities are extremely limited.
3870 # It's more effort than its worth disabling all of the tests
3871 # that it cannot pass. But if you actually want to see what
3872 # does work, command out the return.
3875 lappend DEFAULT_VECTCFLAGS "-mmax"
3876 if [check_alpha_max_hw_available] {
3877 set dg-do-what-default run
3879 set dg-do-what-default compile
3881 } elseif [istarget "ia64-*-*"] {
3882 set dg-do-what-default run
3883 } elseif [is-effective-target arm_neon_ok] {
3884 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
3885 # NEON does not support denormals, so is not used for vectorization by
3886 # default to avoid loss of precision. We must pass -ffast-math to test
3887 # vectorization of float operations.
3888 lappend DEFAULT_VECTCFLAGS "-ffast-math"
3889 if [is-effective-target arm_neon_hw] {
3890 set dg-do-what-default run
3892 set dg-do-what-default compile