1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
23 # Try to compile the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code.
33 # Otherwise, code should contain:
35 # "! Fortran" for Fortran code,
37 # and "// ObjC++" for ObjC++
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
42 verbose "check_compile tool: $tool for $basename"
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
49 switch -glob -- $contents {
50 "*! Fortran*" { set src ${basename}[pid].f90 }
51 "*// C++*" { set src ${basename}[pid].cc }
52 "*// ObjC++*" { set src ${basename}[pid].mm }
53 "*/* ObjC*" { set src ${basename}[pid].m }
56 "objc" { set src ${basename}[pid].m }
57 "obj-c++" { set src ${basename}[pid].mm }
58 default { set src ${basename}[pid].c }
63 set compile_type $type
65 assembly { set output ${basename}[pid].s }
66 object { set output ${basename}[pid].o }
67 executable { set output ${basename}[pid].exe }
69 set output ${basename}[pid].s
70 lappend options "additional_flags=-fdump-$type"
71 set compile_type assembly
77 set lines [${tool}_target_compile $src $output $compile_type "$options"]
80 set scan_output $output
81 # Don't try folding this into the switch above; calling "glob" before the
82 # file is created won't work.
83 if [regexp "rtl-(.*)" $type dummy rtl_type] {
84 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
88 return [list $lines $scan_output]
91 proc current_target_name { } {
93 if [info exists target_info(target,name)] {
94 set answer $target_info(target,name)
101 # Implement an effective-target check for property PROP by invoking
102 # the Tcl command ARGS and seeing if it returns true.
104 proc check_cached_effective_target { prop args } {
107 set target [current_target_name]
108 if {![info exists et_cache($prop,target)]
109 || $et_cache($prop,target) != $target} {
110 verbose "check_cached_effective_target $prop: checking $target" 2
111 set et_cache($prop,target) $target
112 set et_cache($prop,value) [uplevel eval $args]
114 set value $et_cache($prop,value)
115 verbose "check_cached_effective_target $prop: returning $value for $target" 2
119 # Like check_compile, but delete the output file and return true if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache {args} {
122 set result [eval check_compile $args]
123 set lines [lindex $result 0]
124 set output [lindex $result 1]
125 remote_file build delete $output
126 return [string match "" $lines]
129 # Like check_no_compiler_messages_nocache, but cache the result.
130 # PROP is the property we're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133 return [check_cached_effective_target $prop {
134 eval [list check_no_compiler_messages_nocache $prop] $args
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP, otherwise they satisfy it
142 # if they do match regular expression PATTERN. (PATTERN can start
143 # with something like "[!]" if the regular expression needs to match
144 # "!" as the first character.)
146 # Delete the output file before returning. The other arguments are
147 # as for check_compile.
148 proc check_no_messages_and_pattern_nocache {basename pattern args} {
151 set result [eval [list check_compile $basename] $args]
152 set lines [lindex $result 0]
153 set output [lindex $result 1]
156 if { [string match "" $lines] } {
157 set chan [open "$output"]
158 set invert [regexp {^!(.*)} $pattern dummy pattern]
159 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
163 remote_file build delete $output
167 # Like check_no_messages_and_pattern_nocache, but cache the result.
168 # PROP is the property we're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171 return [check_cached_effective_target $prop {
172 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
176 # Try to compile and run an executable from code CONTENTS. Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense. The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
183 set result [eval [list check_compile $basename executable $contents] $args]
184 set lines [lindex $result 0]
185 set output [lindex $result 1]
188 if { [string match "" $lines] } {
189 # No error messages, everything is OK.
190 set result [remote_load target "./$output" "" ""]
191 set status [lindex $result 0]
192 verbose "check_runtime_nocache $basename: status is <$status>" 2
193 if { $status == "pass" } {
197 remote_file build delete $output
201 # Like check_runtime_nocache, but cache the result. PROP is the
202 # property we're checking, and doubles as a prefix for temporary
204 proc check_runtime {prop args} {
207 return [check_cached_effective_target $prop {
208 eval [list check_runtime_nocache $prop] $args
212 ###############################
213 # proc check_weak_available { }
214 ###############################
216 # weak symbols are only supported in some configs/object formats
217 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
219 proc check_weak_available { } {
220 global target_triplet
223 # All mips targets should support it
225 if { [ string first "mips" $target_cpu ] >= 0 } {
229 # All solaris2 targets should support it
231 if { [regexp ".*-solaris2.*" $target_triplet] } {
235 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
237 if { [regexp "alpha.*osf.*" $target_triplet] } {
241 # Windows targets Cygwin and MingW32 support it
243 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
247 # HP-UX 10.X doesn't support it
249 if { [istarget "hppa*-*-hpux10*"] } {
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
256 set objformat [gcc_target_object_format]
264 unknown { return -1 }
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
276 proc check_weak_override_available { } {
277 if { [istarget "*-*-mingw*"] } {
280 return [check_weak_available]
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
291 proc check_visibility_available { what_kind } {
293 global target_triplet
295 # On NetWare, support makes no sense.
296 if { [istarget *-*-netware*] } {
300 if [string match "" $what_kind] { set what_kind "hidden" }
302 return [check_no_compiler_messages visibility_available_$what_kind object "
303 void f() __attribute__((visibility(\"$what_kind\")));
308 ###############################
309 # proc check_alias_available { }
310 ###############################
312 # Determine if the target toolchain supports the alias attribute.
314 # Returns 2 if the target supports aliases. Returns 1 if the target
315 # only supports weak aliased. Returns 0 if the target does not
316 # support aliases at all. Returns -1 if support for aliases could not
319 proc check_alias_available { } {
320 global alias_available_saved
323 if [info exists alias_available_saved] {
324 verbose "check_alias_available returning saved $alias_available_saved" 2
328 verbose "check_alias_available compiling testfile $src" 2
329 set f [open $src "w"]
330 # Compile a small test program. The definition of "g" is
331 # necessary to keep the Solaris assembler from complaining
333 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
336 set lines [${tool}_target_compile $src $obj object ""]
338 remote_file build delete $obj
340 if [string match "" $lines] then {
341 # No error messages, everything is OK.
342 set alias_available_saved 2
344 if [regexp "alias definitions not supported" $lines] {
345 verbose "check_alias_available target does not support aliases" 2
347 set objformat [gcc_target_object_format]
349 if { $objformat == "elf" } {
350 verbose "check_alias_available but target uses ELF format, so it ought to" 2
351 set alias_available_saved -1
353 set alias_available_saved 0
356 if [regexp "only weak aliases are supported" $lines] {
357 verbose "check_alias_available target supports only weak aliases" 2
358 set alias_available_saved 1
360 set alias_available_saved -1
365 verbose "check_alias_available returning $alias_available_saved" 2
368 return $alias_available_saved
371 ###############################
372 # proc check_ifunc_available { }
373 ###############################
375 # Determine if the target toolchain supports the ifunc attribute.
377 # Returns 1 if the target supports ifunc. Returns 0 if the target
378 # does not support ifunc.
380 proc check_ifunc_available { } {
381 global ifunc_available_saved
384 if [info exists ifunc_available_saved] {
385 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
389 verbose "check_ifunc_available compiling testfile $src" 2
390 set f [open $src "w"]
392 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
393 puts $f "void g() {}"
394 puts $f "void f() __attribute__((ifunc(\"g\")));"
396 set lines [${tool}_target_compile $src $obj object ""]
398 remote_file build delete $obj
400 if [string match "" $lines] then {
401 set ifunc_available_saved 1
403 set ifunc_available_saved 0
406 verbose "check_ifunc_available returning $ifunc_available_saved" 2
409 return $ifunc_available_saved
412 # Returns true if --gc-sections is supported on the target.
414 proc check_gc_sections_available { } {
415 global gc_sections_available_saved
418 if {![info exists gc_sections_available_saved]} {
419 # Some targets don't support gc-sections despite whatever's
420 # advertised by ld's options.
421 if { [istarget alpha*-*-*]
422 || [istarget ia64-*-*] } {
423 set gc_sections_available_saved 0
427 # elf2flt uses -q (--emit-relocs), which is incompatible with
429 if { [board_info target exists ldflags]
430 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
431 set gc_sections_available_saved 0
435 # VxWorks kernel modules are relocatable objects linked with -r,
436 # while RTP executables are linked with -q (--emit-relocs).
437 # Both of these options are incompatible with --gc-sections.
438 if { [istarget *-*-vxworks*] } {
439 set gc_sections_available_saved 0
443 # Check if the ld used by gcc supports --gc-sections.
444 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
445 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
446 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
447 set ld_output [remote_exec host "$gcc_ld" "--help"]
448 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
449 set gc_sections_available_saved 1
451 set gc_sections_available_saved 0
454 return $gc_sections_available_saved
457 # Return 1 if according to target_info struct and explicit target list
458 # target is supposed to support trampolines.
460 proc check_effective_target_trampolines { } {
461 if [target_info exists no_trampolines] {
464 if { [istarget avr-*-*]
465 || [istarget hppa2.0w-hp-hpux11.23]
466 || [istarget hppa64-hp-hpux11.23] } {
472 # Return 1 if according to target_info struct and explicit target list
473 # target is supposed to keep null pointer checks. This could be due to
474 # use of option fno-delete-null-pointer-checks or hardwired in target.
476 proc check_effective_target_keeps_null_pointer_checks { } {
477 if [target_info exists keeps_null_pointer_checks] {
480 if { [istarget avr-*-*] } {
486 # Return true if profiling is supported on the target.
488 proc check_profiling_available { test_what } {
489 global profiling_available_saved
491 verbose "Profiling argument is <$test_what>" 1
493 # These conditions depend on the argument so examine them before
494 # looking at the cache variable.
496 # Support for -p on solaris2 relies on mcrt1.o which comes with the
497 # vendor compiler. We cannot reliably predict the directory where the
498 # vendor compiler (and thus mcrt1.o) is installed so we can't
499 # necessarily find mcrt1.o even if we have it.
500 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
504 # Support for -p on irix relies on libprof1.a which doesn't appear to
505 # exist on any irix6 system currently posting testsuite results.
506 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
507 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
508 if { [istarget mips*-*-irix*]
509 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
513 # We don't yet support profiling for MIPS16.
514 if { [istarget mips*-*-*]
515 && ![check_effective_target_nomips16]
516 && ([lindex $test_what 1] == "-p"
517 || [lindex $test_what 1] == "-pg") } {
521 # MinGW does not support -p.
522 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
526 # cygwin does not support -p.
527 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
531 # uClibc does not have gcrt1.o.
532 if { [check_effective_target_uclibc]
533 && ([lindex $test_what 1] == "-p"
534 || [lindex $test_what 1] == "-pg") } {
538 # Now examine the cache variable.
539 if {![info exists profiling_available_saved]} {
540 # Some targets don't have any implementation of __bb_init_func or are
541 # missing other needed machinery.
542 if { [istarget mmix-*-*]
543 || [istarget arm*-*-eabi*]
544 || [istarget picochip-*-*]
545 || [istarget *-*-netware*]
546 || [istarget arm*-*-elf]
547 || [istarget arm*-*-symbianelf*]
548 || [istarget avr-*-*]
549 || [istarget bfin-*-*]
550 || [istarget powerpc-*-eabi*]
551 || [istarget powerpc-*-elf]
552 || [istarget cris-*-*]
553 || [istarget crisv32-*-*]
554 || [istarget fido-*-elf]
555 || [istarget h8300-*-*]
556 || [istarget lm32-*-*]
557 || [istarget m32c-*-elf]
558 || [istarget m68k-*-elf]
559 || [istarget m68k-*-uclinux*]
560 || [istarget mep-*-elf]
561 || [istarget mips*-*-elf*]
562 || [istarget moxie-*-elf*]
564 || [istarget xstormy16-*]
565 || [istarget xtensa*-*-elf]
566 || [istarget *-*-rtems*]
567 || [istarget *-*-vxworks*] } {
568 set profiling_available_saved 0
570 set profiling_available_saved 1
574 return $profiling_available_saved
577 # Check to see if a target is "freestanding". This is as per the definition
578 # in Section 4 of C99 standard. Effectively, it is a target which supports no
579 # extra headers or libraries other than what is considered essential.
580 proc check_effective_target_freestanding { } {
581 if { [istarget picochip-*-*] } then {
588 # Return 1 if target has packed layout of structure members by
589 # default, 0 otherwise. Note that this is slightly different than
590 # whether the target has "natural alignment": both attributes may be
593 proc check_effective_target_default_packed { } {
594 return [check_no_compiler_messages default_packed assembly {
595 struct x { char a; long b; } c;
596 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
600 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
601 # documentation, where the test also comes from.
603 proc check_effective_target_pcc_bitfield_type_matters { } {
604 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
605 # bitfields, but let's stick to the example code from the docs.
606 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
607 struct foo1 { char x; char :0; char y; };
608 struct foo2 { char x; int :0; char y; };
609 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
613 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
615 proc add_options_for_tls { flags } {
616 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
617 # libthread, so always pass -pthread for native TLS.
618 # Need to duplicate native TLS check from
619 # check_effective_target_tls_native to avoid recursion.
620 if { [istarget *-*-solaris2.\[89\]*] &&
621 [check_no_messages_and_pattern tls_native "!emutls" assembly {
623 int f (void) { return i; }
624 void g (int j) { i = j; }
626 return "$flags -pthread"
631 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
633 proc check_effective_target_tls {} {
634 return [check_no_compiler_messages tls assembly {
636 int f (void) { return i; }
637 void g (int j) { i = j; }
641 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
643 proc check_effective_target_tls_native {} {
644 # VxWorks uses emulated TLS machinery, but with non-standard helper
645 # functions, so we fail to automatically detect it.
646 global target_triplet
647 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
651 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
653 int f (void) { return i; }
654 void g (int j) { i = j; }
658 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
660 proc check_effective_target_tls_emulated {} {
661 # VxWorks uses emulated TLS machinery, but with non-standard helper
662 # functions, so we fail to automatically detect it.
663 global target_triplet
664 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
668 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
670 int f (void) { return i; }
671 void g (int j) { i = j; }
675 # Return 1 if TLS executables can run correctly, 0 otherwise.
677 proc check_effective_target_tls_runtime {} {
678 return [check_runtime tls_runtime {
679 __thread int thr = 0;
680 int main (void) { return thr; }
684 # Return 1 if -ffunction-sections is supported, 0 otherwise.
686 proc check_effective_target_function_sections {} {
687 # Darwin has its own scheme and silently accepts -ffunction-sections.
688 global target_triplet
689 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
693 return [check_no_compiler_messages functionsections assembly {
695 } "-ffunction-sections"]
698 # Return 1 if compilation with -fgraphite is error-free for trivial
701 proc check_effective_target_fgraphite {} {
702 return [check_no_compiler_messages fgraphite object {
707 # Return 1 if compilation with -fopenmp is error-free for trivial
710 proc check_effective_target_fopenmp {} {
711 return [check_no_compiler_messages fopenmp object {
716 # Return 1 if compilation with -pthread is error-free for trivial
719 proc check_effective_target_pthread {} {
720 return [check_no_compiler_messages pthread object {
725 # Return 1 if compilation with -mpe-aligned-commons is error-free
726 # for trivial code, 0 otherwise.
728 proc check_effective_target_pe_aligned_commons {} {
729 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
730 return [check_no_compiler_messages pe_aligned_commons object {
732 } "-mpe-aligned-commons"]
737 # Return 1 if the target supports -static
738 proc check_effective_target_static {} {
739 return [check_no_compiler_messages static executable {
740 int main (void) { return 0; }
744 # Return 1 if the target supports -fstack-protector
745 proc check_effective_target_fstack_protector {} {
746 return [check_runtime fstack_protector {
747 int main (void) { return 0; }
748 } "-fstack-protector"]
751 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
752 # for trivial code, 0 otherwise.
754 proc check_effective_target_freorder {} {
755 return [check_no_compiler_messages freorder object {
757 } "-freorder-blocks-and-partition"]
760 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
761 # emitted, 0 otherwise. Whether a shared library can actually be built is
762 # out of scope for this test.
764 proc check_effective_target_fpic { } {
765 # Note that M68K has a multilib that supports -fpic but not
766 # -fPIC, so we need to check both. We test with a program that
767 # requires GOT references.
768 foreach arg {fpic fPIC} {
769 if [check_no_compiler_messages $arg object {
770 extern int foo (void); extern int bar;
771 int baz (void) { return foo () + bar; }
779 # Return true if the target supports -mpaired-single (as used on MIPS).
781 proc check_effective_target_mpaired_single { } {
782 return [check_no_compiler_messages mpaired_single object {
787 # Return true if the target has access to FPU instructions.
789 proc check_effective_target_hard_float { } {
790 if { [istarget mips*-*-*] } {
791 return [check_no_compiler_messages hard_float assembly {
792 #if (defined __mips_soft_float || defined __mips16)
798 # This proc is actually checking the availabilty of FPU
799 # support for doubles, so on the RX we must fail if the
800 # 64-bit double multilib has been selected.
801 if { [istarget rx-*-*] } {
803 # return [check_no_compiler_messages hard_float assembly {
804 #if defined __RX_64_BIT_DOUBLES__
810 # The generic test equates hard_float with "no call for adding doubles".
811 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
812 double a (double b, double c) { return b + c; }
816 # Return true if the target is a 64-bit MIPS target.
818 proc check_effective_target_mips64 { } {
819 return [check_no_compiler_messages mips64 assembly {
826 # Return true if the target is a MIPS target that does not produce
829 proc check_effective_target_nomips16 { } {
830 return [check_no_compiler_messages nomips16 object {
834 /* A cheap way of testing for -mflip-mips16. */
835 void foo (void) { asm ("addiu $20,$20,1"); }
836 void bar (void) { asm ("addiu $20,$20,1"); }
841 # Add the options needed for MIPS16 function attributes. At the moment,
842 # we don't support MIPS16 PIC.
844 proc add_options_for_mips16_attribute { flags } {
845 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
848 # Return true if we can force a mode that allows MIPS16 code generation.
849 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
852 proc check_effective_target_mips16_attribute { } {
853 return [check_no_compiler_messages mips16_attribute assembly {
857 #if defined __mips_hard_float \
858 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
859 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
862 } [add_options_for_mips16_attribute ""]]
865 # Return 1 if the target supports long double larger than double when
866 # using the new ABI, 0 otherwise.
868 proc check_effective_target_mips_newabi_large_long_double { } {
869 return [check_no_compiler_messages mips_newabi_large_long_double object {
870 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
874 # Return 1 if the current multilib does not generate PIC by default.
876 proc check_effective_target_nonpic { } {
877 return [check_no_compiler_messages nonpic assembly {
884 # Return 1 if the target does not use a status wrapper.
886 proc check_effective_target_unwrapped { } {
887 if { [target_info needs_status_wrapper] != "" \
888 && [target_info needs_status_wrapper] != "0" } {
894 # Return true if iconv is supported on the target. In particular IBM1047.
896 proc check_iconv_available { test_what } {
899 # If the tool configuration file has not set libiconv, try "-liconv"
900 if { ![info exists libiconv] } {
901 set libiconv "-liconv"
903 set test_what [lindex $test_what 1]
904 return [check_runtime_nocache $test_what [subst {
910 cd = iconv_open ("$test_what", "UTF-8");
911 if (cd == (iconv_t) -1)
918 # Return true if named sections are supported on this target.
920 proc check_named_sections_available { } {
921 return [check_no_compiler_messages named_sections assembly {
922 int __attribute__ ((section("whatever"))) foo;
926 # Return 1 if the target supports Fortran real kinds larger than real(8),
929 # When the target name changes, replace the cached result.
931 proc check_effective_target_fortran_large_real { } {
932 return [check_no_compiler_messages fortran_large_real executable {
934 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
941 # Return 1 if the target supports Fortran integer kinds larger than
942 # integer(8), 0 otherwise.
944 # When the target name changes, replace the cached result.
946 proc check_effective_target_fortran_large_int { } {
947 return [check_no_compiler_messages fortran_large_int executable {
949 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
955 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
957 # When the target name changes, replace the cached result.
959 proc check_effective_target_fortran_integer_16 { } {
960 return [check_no_compiler_messages fortran_integer_16 executable {
967 # Return 1 if we can statically link libgfortran, 0 otherwise.
969 # When the target name changes, replace the cached result.
971 proc check_effective_target_static_libgfortran { } {
972 return [check_no_compiler_messages static_libgfortran executable {
979 proc check_linker_plugin_available { } {
980 return [check_no_compiler_messages_nocache linker_plugin executable {
981 int main() { return 0; }
982 } "-flto -fuse-linker-plugin"]
985 # Return 1 if the target supports executing 750CL paired-single instructions, 0
986 # otherwise. Cache the result.
988 proc check_750cl_hw_available { } {
989 return [check_cached_effective_target 750cl_hw_available {
990 # If this is not the right target then we can skip the test.
991 if { ![istarget powerpc-*paired*] } {
994 check_runtime_nocache 750cl_hw_available {
998 asm volatile ("ps_mul v0,v0,v0");
1000 asm volatile ("ps_mul 0,0,0");
1009 # Return 1 if the target OS supports running SSE executables, 0
1010 # otherwise. Cache the result.
1012 proc check_sse_os_support_available { } {
1013 return [check_cached_effective_target sse_os_support_available {
1014 # If this is not the right target then we can skip the test.
1015 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1017 } elseif { [istarget i?86-*-solaris2*] } {
1018 # The Solaris 2 kernel doesn't save and restore SSE registers
1019 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1020 check_runtime_nocache sse_os_support_available {
1023 __asm__ volatile ("movss %xmm2,%xmm1");
1033 # Return 1 if the target supports executing SSE instructions, 0
1034 # otherwise. Cache the result.
1036 proc check_sse_hw_available { } {
1037 return [check_cached_effective_target sse_hw_available {
1038 # If this is not the right target then we can skip the test.
1039 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1042 check_runtime_nocache sse_hw_available {
1046 unsigned int eax, ebx, ecx, edx;
1047 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1048 return !(edx & bit_SSE);
1056 # Return 1 if the target supports executing SSE2 instructions, 0
1057 # otherwise. Cache the result.
1059 proc check_sse2_hw_available { } {
1060 return [check_cached_effective_target sse2_hw_available {
1061 # If this is not the right target then we can skip the test.
1062 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1065 check_runtime_nocache sse2_hw_available {
1069 unsigned int eax, ebx, ecx, edx;
1070 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1071 return !(edx & bit_SSE2);
1079 # Return 1 if the target supports executing AVX instructions, 0
1080 # otherwise. Cache the result.
1082 proc check_avx_hw_available { } {
1083 return [check_cached_effective_target avx_hw_available {
1084 # If this is not the right target then we can skip the test.
1085 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1088 check_runtime_nocache avx_hw_available {
1092 unsigned int eax, ebx, ecx, edx;
1093 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1094 return ((ecx & (bit_AVX | bit_OSXSAVE))
1095 != (bit_AVX | bit_OSXSAVE));
1103 # Return 1 if the target supports running SSE executables, 0 otherwise.
1105 proc check_effective_target_sse_runtime { } {
1106 if { [check_effective_target_sse]
1107 && [check_sse_hw_available]
1108 && [check_sse_os_support_available] } {
1114 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1116 proc check_effective_target_sse2_runtime { } {
1117 if { [check_effective_target_sse2]
1118 && [check_sse2_hw_available]
1119 && [check_sse_os_support_available] } {
1125 # Return 1 if the target supports running AVX executables, 0 otherwise.
1127 proc check_effective_target_avx_runtime { } {
1128 if { [check_effective_target_avx]
1129 && [check_avx_hw_available] } {
1135 # Return 1 if the target supports executing VSX instructions, 0
1136 # otherwise. Cache the result.
1138 proc check_vsx_hw_available { } {
1139 return [check_cached_effective_target vsx_hw_available {
1140 # Some simulators are known to not support VSX instructions.
1141 # For now, disable on Darwin
1142 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1146 check_runtime_nocache vsx_hw_available {
1150 asm volatile ("xxlor vs0,vs0,vs0");
1152 asm volatile ("xxlor 0,0,0");
1161 # Return 1 if the target supports executing AltiVec instructions, 0
1162 # otherwise. Cache the result.
1164 proc check_vmx_hw_available { } {
1165 return [check_cached_effective_target vmx_hw_available {
1166 # Some simulators are known to not support VMX instructions.
1167 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1170 # Most targets don't require special flags for this test case, but
1171 # Darwin does. Just to be sure, make sure VSX is not enabled for
1172 # the altivec tests.
1173 if { [istarget *-*-darwin*]
1174 || [istarget *-*-aix*] } {
1175 set options "-maltivec -mno-vsx"
1177 set options "-mno-vsx"
1179 check_runtime_nocache vmx_hw_available {
1183 asm volatile ("vor v0,v0,v0");
1185 asm volatile ("vor 0,0,0");
1194 proc check_ppc_recip_hw_available { } {
1195 return [check_cached_effective_target ppc_recip_hw_available {
1196 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1197 # For now, disable on Darwin
1198 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1201 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1202 check_runtime_nocache ppc_recip_hw_available {
1203 volatile double d_recip, d_rsqrt, d_four = 4.0;
1204 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1207 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1208 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1209 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1210 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1218 # Return 1 if the target supports executing AltiVec and Cell PPU
1219 # instructions, 0 otherwise. Cache the result.
1221 proc check_effective_target_cell_hw { } {
1222 return [check_cached_effective_target cell_hw_available {
1223 # Some simulators are known to not support VMX and PPU instructions.
1224 if { [istarget powerpc-*-eabi*] } {
1227 # Most targets don't require special flags for this test
1228 # case, but Darwin and AIX do.
1229 if { [istarget *-*-darwin*]
1230 || [istarget *-*-aix*] } {
1231 set options "-maltivec -mcpu=cell"
1233 set options "-mcpu=cell"
1235 check_runtime_nocache cell_hw_available {
1239 asm volatile ("vor v0,v0,v0");
1240 asm volatile ("lvlx v0,r0,r0");
1242 asm volatile ("vor 0,0,0");
1243 asm volatile ("lvlx 0,0,0");
1252 # Return 1 if the target supports executing 64-bit instructions, 0
1253 # otherwise. Cache the result.
1255 proc check_effective_target_powerpc64 { } {
1256 global powerpc64_available_saved
1259 if [info exists powerpc64_available_saved] {
1260 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1262 set powerpc64_available_saved 0
1264 # Some simulators are known to not support powerpc64 instructions.
1265 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1266 verbose "check_effective_target_powerpc64 returning 0" 2
1267 return $powerpc64_available_saved
1270 # Set up, compile, and execute a test program containing a 64-bit
1271 # instruction. Include the current process ID in the file
1272 # names to prevent conflicts with invocations for multiple
1277 set f [open $src "w"]
1278 puts $f "int main() {"
1279 puts $f "#ifdef __MACH__"
1280 puts $f " asm volatile (\"extsw r0,r0\");"
1282 puts $f " asm volatile (\"extsw 0,0\");"
1284 puts $f " return 0; }"
1287 set opts "additional_flags=-mcpu=G5"
1289 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1290 set lines [${tool}_target_compile $src $exe executable "$opts"]
1293 if [string match "" $lines] then {
1294 # No error message, compilation succeeded.
1295 set result [${tool}_load "./$exe" "" ""]
1296 set status [lindex $result 0]
1297 remote_file build delete $exe
1298 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1300 if { $status == "pass" } then {
1301 set powerpc64_available_saved 1
1304 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1308 return $powerpc64_available_saved
1311 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1312 # complex float arguments. This affects gfortran tests that call cabsf
1313 # in libm built by an earlier compiler. Return 1 if libm uses the same
1314 # argument passing as the compiler under test, 0 otherwise.
1316 # When the target name changes, replace the cached result.
1318 proc check_effective_target_broken_cplxf_arg { } {
1319 return [check_cached_effective_target broken_cplxf_arg {
1320 # Skip the work for targets known not to be affected.
1321 if { ![istarget powerpc64-*-linux*] } {
1323 } elseif { ![is-effective-target lp64] } {
1326 check_runtime_nocache broken_cplxf_arg {
1327 #include <complex.h>
1328 extern void abort (void);
1329 float fabsf (float);
1330 float cabsf (_Complex float);
1337 if (fabsf (f - 5.0) > 0.0001)
1346 proc check_alpha_max_hw_available { } {
1347 return [check_runtime alpha_max_hw_available {
1348 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1352 # Returns true iff the FUNCTION is available on the target system.
1353 # (This is essentially a Tcl implementation of Autoconf's
1356 proc check_function_available { function } {
1357 return [check_no_compiler_messages ${function}_available \
1363 int main () { $function (); }
1367 # Returns true iff "fork" is available on the target system.
1369 proc check_fork_available {} {
1370 return [check_function_available "fork"]
1373 # Returns true iff "mkfifo" is available on the target system.
1375 proc check_mkfifo_available {} {
1376 if {[istarget *-*-cygwin*]} {
1377 # Cygwin has mkfifo, but support is incomplete.
1381 return [check_function_available "mkfifo"]
1384 # Returns true iff "__cxa_atexit" is used on the target system.
1386 proc check_cxa_atexit_available { } {
1387 return [check_cached_effective_target cxa_atexit_available {
1388 if { [istarget "hppa*-*-hpux10*"] } {
1389 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1391 } elseif { [istarget "*-*-vxworks"] } {
1392 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1395 check_runtime_nocache cxa_atexit_available {
1398 static unsigned int count;
1415 Y() { f(); count = 2; }
1424 int main() { return 0; }
1430 proc check_effective_target_objc2 { } {
1431 return [check_no_compiler_messages objc2 object {
1440 proc check_effective_target_next_runtime { } {
1441 return [check_no_compiler_messages objc2 object {
1442 #ifdef __NEXT_RUNTIME__
1450 # Return 1 if we're generating 32-bit code using default options, 0
1453 proc check_effective_target_ilp32 { } {
1454 return [check_no_compiler_messages ilp32 object {
1455 int dummy[sizeof (int) == 4
1456 && sizeof (void *) == 4
1457 && sizeof (long) == 4 ? 1 : -1];
1461 # Return 1 if we're generating 32-bit or larger integers using default
1462 # options, 0 otherwise.
1464 proc check_effective_target_int32plus { } {
1465 return [check_no_compiler_messages int32plus object {
1466 int dummy[sizeof (int) >= 4 ? 1 : -1];
1470 # Return 1 if we're generating 32-bit or larger pointers using default
1471 # options, 0 otherwise.
1473 proc check_effective_target_ptr32plus { } {
1474 return [check_no_compiler_messages ptr32plus object {
1475 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1479 # Return 1 if we support 32-bit or larger array and structure sizes
1480 # using default options, 0 otherwise.
1482 proc check_effective_target_size32plus { } {
1483 return [check_no_compiler_messages size32plus object {
1488 # Returns 1 if we're generating 16-bit or smaller integers with the
1489 # default options, 0 otherwise.
1491 proc check_effective_target_int16 { } {
1492 return [check_no_compiler_messages int16 object {
1493 int dummy[sizeof (int) < 4 ? 1 : -1];
1497 # Return 1 if we're generating 64-bit code using default options, 0
1500 proc check_effective_target_lp64 { } {
1501 return [check_no_compiler_messages lp64 object {
1502 int dummy[sizeof (int) == 4
1503 && sizeof (void *) == 8
1504 && sizeof (long) == 8 ? 1 : -1];
1508 # Return 1 if we're generating 64-bit code using default llp64 options,
1511 proc check_effective_target_llp64 { } {
1512 return [check_no_compiler_messages llp64 object {
1513 int dummy[sizeof (int) == 4
1514 && sizeof (void *) == 8
1515 && sizeof (long long) == 8
1516 && sizeof (long) == 4 ? 1 : -1];
1520 # Return 1 if the target supports long double larger than double,
1523 proc check_effective_target_large_long_double { } {
1524 return [check_no_compiler_messages large_long_double object {
1525 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1529 # Return 1 if the target supports double larger than float,
1532 proc check_effective_target_large_double { } {
1533 return [check_no_compiler_messages large_double object {
1534 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1538 # Return 1 if the target supports double of 64 bits,
1541 proc check_effective_target_double64 { } {
1542 return [check_no_compiler_messages double64 object {
1543 int dummy[sizeof(double) == 8 ? 1 : -1];
1547 # Return 1 if the target supports double of at least 64 bits,
1550 proc check_effective_target_double64plus { } {
1551 return [check_no_compiler_messages double64plus object {
1552 int dummy[sizeof(double) >= 8 ? 1 : -1];
1556 # Return 1 if the target supports compiling fixed-point,
1559 proc check_effective_target_fixed_point { } {
1560 return [check_no_compiler_messages fixed_point object {
1561 _Sat _Fract x; _Sat _Accum y;
1565 # Return 1 if the target supports compiling decimal floating point,
1568 proc check_effective_target_dfp_nocache { } {
1569 verbose "check_effective_target_dfp_nocache: compiling source" 2
1570 set ret [check_no_compiler_messages_nocache dfp object {
1571 float x __attribute__((mode(DD)));
1573 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1577 proc check_effective_target_dfprt_nocache { } {
1578 return [check_runtime_nocache dfprt {
1579 typedef float d64 __attribute__((mode(DD)));
1580 d64 x = 1.2df, y = 2.3dd, z;
1581 int main () { z = x + y; return 0; }
1585 # Return 1 if the target supports compiling Decimal Floating Point,
1588 # This won't change for different subtargets so cache the result.
1590 proc check_effective_target_dfp { } {
1591 return [check_cached_effective_target dfp {
1592 check_effective_target_dfp_nocache
1596 # Return 1 if the target supports linking and executing Decimal Floating
1597 # Point, 0 otherwise.
1599 # This won't change for different subtargets so cache the result.
1601 proc check_effective_target_dfprt { } {
1602 return [check_cached_effective_target dfprt {
1603 check_effective_target_dfprt_nocache
1607 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1609 proc check_effective_target_ucn_nocache { } {
1610 # -std=c99 is only valid for C
1611 if [check_effective_target_c] {
1612 set ucnopts "-std=c99"
1614 append ucnopts " -fextended-identifiers"
1615 verbose "check_effective_target_ucn_nocache: compiling source" 2
1616 set ret [check_no_compiler_messages_nocache ucn object {
1619 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1623 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1625 # This won't change for different subtargets, so cache the result.
1627 proc check_effective_target_ucn { } {
1628 return [check_cached_effective_target ucn {
1629 check_effective_target_ucn_nocache
1633 # Return 1 if the target needs a command line argument to enable a SIMD
1636 proc check_effective_target_vect_cmdline_needed { } {
1637 global et_vect_cmdline_needed_saved
1638 global et_vect_cmdline_needed_target_name
1640 if { ![info exists et_vect_cmdline_needed_target_name] } {
1641 set et_vect_cmdline_needed_target_name ""
1644 # If the target has changed since we set the cached value, clear it.
1645 set current_target [current_target_name]
1646 if { $current_target != $et_vect_cmdline_needed_target_name } {
1647 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1648 set et_vect_cmdline_needed_target_name $current_target
1649 if { [info exists et_vect_cmdline_needed_saved] } {
1650 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1651 unset et_vect_cmdline_needed_saved
1655 if [info exists et_vect_cmdline_needed_saved] {
1656 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1658 set et_vect_cmdline_needed_saved 1
1659 if { [istarget alpha*-*-*]
1660 || [istarget ia64-*-*]
1661 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1662 && [check_effective_target_lp64])
1663 || ([istarget powerpc*-*-*]
1664 && ([check_effective_target_powerpc_spe]
1665 || [check_effective_target_powerpc_altivec]))
1666 || [istarget spu-*-*]
1667 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1668 set et_vect_cmdline_needed_saved 0
1672 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1673 return $et_vect_cmdline_needed_saved
1676 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1678 # This won't change for different subtargets so cache the result.
1680 proc check_effective_target_vect_int { } {
1681 global et_vect_int_saved
1683 if [info exists et_vect_int_saved] {
1684 verbose "check_effective_target_vect_int: using cached result" 2
1686 set et_vect_int_saved 0
1687 if { [istarget i?86-*-*]
1688 || ([istarget powerpc*-*-*]
1689 && ![istarget powerpc-*-linux*paired*])
1690 || [istarget spu-*-*]
1691 || [istarget x86_64-*-*]
1692 || [istarget sparc*-*-*]
1693 || [istarget alpha*-*-*]
1694 || [istarget ia64-*-*]
1695 || [check_effective_target_arm32]
1696 || ([istarget mips*-*-*]
1697 && [check_effective_target_mips_loongson]) } {
1698 set et_vect_int_saved 1
1702 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1703 return $et_vect_int_saved
1706 # Return 1 if the target supports signed int->float conversion
1709 proc check_effective_target_vect_intfloat_cvt { } {
1710 global et_vect_intfloat_cvt_saved
1712 if [info exists et_vect_intfloat_cvt_saved] {
1713 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1715 set et_vect_intfloat_cvt_saved 0
1716 if { [istarget i?86-*-*]
1717 || ([istarget powerpc*-*-*]
1718 && ![istarget powerpc-*-linux*paired*])
1719 || [istarget x86_64-*-*] } {
1720 set et_vect_intfloat_cvt_saved 1
1724 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1725 return $et_vect_intfloat_cvt_saved
1728 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1730 proc check_effective_target_int128 { } {
1731 return [check_no_compiler_messages int128 object {
1733 #ifndef __SIZEOF_INT128__
1742 # Return 1 if the target supports unsigned int->float conversion
1745 proc check_effective_target_vect_uintfloat_cvt { } {
1746 global et_vect_uintfloat_cvt_saved
1748 if [info exists et_vect_uintfloat_cvt_saved] {
1749 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1751 set et_vect_uintfloat_cvt_saved 0
1752 if { [istarget i?86-*-*]
1753 || ([istarget powerpc*-*-*]
1754 && ![istarget powerpc-*-linux*paired*])
1755 || [istarget x86_64-*-*] } {
1756 set et_vect_uintfloat_cvt_saved 1
1760 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1761 return $et_vect_uintfloat_cvt_saved
1765 # Return 1 if the target supports signed float->int conversion
1768 proc check_effective_target_vect_floatint_cvt { } {
1769 global et_vect_floatint_cvt_saved
1771 if [info exists et_vect_floatint_cvt_saved] {
1772 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1774 set et_vect_floatint_cvt_saved 0
1775 if { [istarget i?86-*-*]
1776 || ([istarget powerpc*-*-*]
1777 && ![istarget powerpc-*-linux*paired*])
1778 || [istarget x86_64-*-*] } {
1779 set et_vect_floatint_cvt_saved 1
1783 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1784 return $et_vect_floatint_cvt_saved
1787 # Return 1 if the target supports unsigned float->int conversion
1790 proc check_effective_target_vect_floatuint_cvt { } {
1791 global et_vect_floatuint_cvt_saved
1793 if [info exists et_vect_floatuint_cvt_saved] {
1794 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1796 set et_vect_floatuint_cvt_saved 0
1797 if { ([istarget powerpc*-*-*]
1798 && ![istarget powerpc-*-linux*paired*]) } {
1799 set et_vect_floatuint_cvt_saved 1
1803 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1804 return $et_vect_floatuint_cvt_saved
1807 # Return 1 is this is an arm target using 32-bit instructions
1808 proc check_effective_target_arm32 { } {
1809 return [check_no_compiler_messages arm32 assembly {
1810 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1816 # Return 1 if this is an ARM target that only supports aligned vector accesses
1817 proc check_effective_target_arm_vect_no_misalign { } {
1818 return [check_no_compiler_messages arm_vect_no_misalign assembly {
1819 #if !defined(__arm__) \
1820 || (defined(__ARMEL__) \
1821 && (!defined(__thumb__) || defined(__thumb2__)))
1828 # Return 1 if this is an ARM target supporting -mfpu=vfp
1829 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1832 proc check_effective_target_arm_vfp_ok { } {
1833 if { [check_effective_target_arm32] } {
1834 return [check_no_compiler_messages arm_vfp_ok object {
1836 } "-mfpu=vfp -mfloat-abi=softfp"]
1842 # Return 1 if this is an ARM target supporting -mfpu=vfp
1843 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1846 proc check_effective_target_arm_hard_vfp_ok { } {
1847 if { [check_effective_target_arm32] } {
1848 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1849 int main() { return 0;}
1850 } "-mfpu=vfp -mfloat-abi=hard"]
1856 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1857 # or -mfloat-abi=hard, but if one is already specified by the
1858 # multilib, use it. Similarly, if a -mfpu option already enables
1859 # NEON, do not add -mfpu=neon.
1861 proc add_options_for_arm_neon { flags } {
1862 if { ! [check_effective_target_arm_neon_ok] } {
1865 global et_arm_neon_flags
1866 return "$flags $et_arm_neon_flags"
1869 # Return 1 if this is an ARM target supporting -mfpu=neon
1870 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1871 # incompatible with these options. Also set et_arm_neon_flags to the
1872 # best options to add.
1874 proc check_effective_target_arm_neon_ok_nocache { } {
1875 global et_arm_neon_flags
1876 set et_arm_neon_flags ""
1877 if { [check_effective_target_arm32] } {
1878 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1879 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1880 #include "arm_neon.h"
1883 set et_arm_neon_flags $flags
1892 proc check_effective_target_arm_neon_ok { } {
1893 return [check_cached_effective_target arm_neon_ok \
1894 check_effective_target_arm_neon_ok_nocache]
1897 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1898 # or -mfloat-abi=hard, but if one is already specified by the
1901 proc add_options_for_arm_neon_fp16 { flags } {
1902 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1905 global et_arm_neon_fp16_flags
1906 return "$flags $et_arm_neon_fp16_flags"
1909 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1910 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1911 # incompatible with these options. Also set et_arm_neon_flags to the
1912 # best options to add.
1914 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1915 global et_arm_neon_fp16_flags
1916 set et_arm_neon_fp16_flags ""
1917 if { [check_effective_target_arm32] } {
1918 # Always add -mfpu=neon-fp16, since there is no preprocessor
1919 # macro for FP16 support.
1920 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1921 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1922 #include "arm_neon.h"
1925 set et_arm_neon_fp16_flags $flags
1934 proc check_effective_target_arm_neon_fp16_ok { } {
1935 return [check_cached_effective_target arm_neon_fp16_ok \
1936 check_effective_target_arm_neon_fp16_ok_nocache]
1939 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1942 proc check_effective_target_arm_thumb1_ok { } {
1943 return [check_no_compiler_messages arm_thumb1_ok assembly {
1944 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1950 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1953 proc check_effective_target_arm_thumb2_ok { } {
1954 return [check_no_compiler_messages arm_thumb2_ok assembly {
1955 #if !defined(__thumb2__)
1961 # Return 1 if the target supports executing NEON instructions, 0
1962 # otherwise. Cache the result.
1964 proc check_effective_target_arm_neon_hw { } {
1965 return [check_runtime arm_neon_hw_available {
1969 long long a = 0, b = 1;
1970 asm ("vorr %P0, %P1, %P2"
1972 : "0" (a), "w" (b));
1975 } [add_options_for_arm_neon ""]]
1978 # Return 1 if this is a ARM target with NEON enabled.
1980 proc check_effective_target_arm_neon { } {
1981 if { [check_effective_target_arm32] } {
1982 return [check_no_compiler_messages arm_neon object {
1983 #ifndef __ARM_NEON__
1994 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1995 # the Loongson vector modes.
1997 proc check_effective_target_mips_loongson { } {
1998 return [check_no_compiler_messages loongson assembly {
1999 #if !defined(__mips_loongson_vector_rev)
2005 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2008 proc check_effective_target_arm_eabi { } {
2009 return [check_no_compiler_messages arm_eabi object {
2010 #ifndef __ARM_EABI__
2018 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2019 # Some multilibs may be incompatible with this option.
2021 proc check_effective_target_arm_iwmmxt_ok { } {
2022 if { [check_effective_target_arm32] } {
2023 return [check_no_compiler_messages arm_iwmmxt_ok object {
2031 # Return 1 if this is a PowerPC target with floating-point registers.
2033 proc check_effective_target_powerpc_fprs { } {
2034 if { [istarget powerpc*-*-*]
2035 || [istarget rs6000-*-*] } {
2036 return [check_no_compiler_messages powerpc_fprs object {
2048 # Return 1 if this is a PowerPC target with hardware double-precision
2051 proc check_effective_target_powerpc_hard_double { } {
2052 if { [istarget powerpc*-*-*]
2053 || [istarget rs6000-*-*] } {
2054 return [check_no_compiler_messages powerpc_hard_double object {
2066 # Return 1 if this is a PowerPC target supporting -maltivec.
2068 proc check_effective_target_powerpc_altivec_ok { } {
2069 if { ([istarget powerpc*-*-*]
2070 && ![istarget powerpc-*-linux*paired*])
2071 || [istarget rs6000-*-*] } {
2072 # AltiVec is not supported on AIX before 5.3.
2073 if { [istarget powerpc*-*-aix4*]
2074 || [istarget powerpc*-*-aix5.1*]
2075 || [istarget powerpc*-*-aix5.2*] } {
2078 return [check_no_compiler_messages powerpc_altivec_ok object {
2086 # Return 1 if this is a PowerPC target supporting -mvsx
2088 proc check_effective_target_powerpc_vsx_ok { } {
2089 if { ([istarget powerpc*-*-*]
2090 && ![istarget powerpc-*-linux*paired*])
2091 || [istarget rs6000-*-*] } {
2092 # AltiVec is not supported on AIX before 5.3.
2093 if { [istarget powerpc*-*-aix4*]
2094 || [istarget powerpc*-*-aix5.1*]
2095 || [istarget powerpc*-*-aix5.2*] } {
2098 return [check_no_compiler_messages powerpc_vsx_ok object {
2101 asm volatile ("xxlor vs0,vs0,vs0");
2103 asm volatile ("xxlor 0,0,0");
2113 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2115 proc check_effective_target_powerpc_ppu_ok { } {
2116 if [check_effective_target_powerpc_altivec_ok] {
2117 return [check_no_compiler_messages cell_asm_available object {
2120 asm volatile ("lvlx v0,v0,v0");
2122 asm volatile ("lvlx 0,0,0");
2132 # Return 1 if this is a PowerPC target that supports SPU.
2134 proc check_effective_target_powerpc_spu { } {
2135 if [istarget powerpc*-*-linux*] {
2136 return [check_effective_target_powerpc_altivec_ok]
2142 # Return 1 if this is a PowerPC SPE target. The check includes options
2143 # specified by dg-options for this test, so don't cache the result.
2145 proc check_effective_target_powerpc_spe_nocache { } {
2146 if { [istarget powerpc*-*-*] } {
2147 return [check_no_compiler_messages_nocache powerpc_spe object {
2153 } [current_compiler_flags]]
2159 # Return 1 if this is a PowerPC target with SPE enabled.
2161 proc check_effective_target_powerpc_spe { } {
2162 if { [istarget powerpc*-*-*] } {
2163 return [check_no_compiler_messages powerpc_spe object {
2175 # Return 1 if this is a PowerPC target with Altivec enabled.
2177 proc check_effective_target_powerpc_altivec { } {
2178 if { [istarget powerpc*-*-*] } {
2179 return [check_no_compiler_messages powerpc_altivec object {
2191 # Return 1 if this is a PowerPC 405 target. The check includes options
2192 # specified by dg-options for this test, so don't cache the result.
2194 proc check_effective_target_powerpc_405_nocache { } {
2195 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2196 return [check_no_compiler_messages_nocache powerpc_405 object {
2202 } [current_compiler_flags]]
2208 # Return 1 if this is a SPU target with a toolchain that
2209 # supports automatic overlay generation.
2211 proc check_effective_target_spu_auto_overlay { } {
2212 if { [istarget spu*-*-elf*] } {
2213 return [check_no_compiler_messages spu_auto_overlay executable {
2215 } "-Wl,--auto-overlay" ]
2221 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2222 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2223 # test environment appears to run executables on such a simulator.
2225 proc check_effective_target_ultrasparc_hw { } {
2226 return [check_runtime ultrasparc_hw {
2227 int main() { return 0; }
2228 } "-mcpu=ultrasparc"]
2231 # Return 1 if the target supports hardware vector shift operation.
2233 proc check_effective_target_vect_shift { } {
2234 global et_vect_shift_saved
2236 if [info exists et_vect_shift_saved] {
2237 verbose "check_effective_target_vect_shift: using cached result" 2
2239 set et_vect_shift_saved 0
2240 if { ([istarget powerpc*-*-*]
2241 && ![istarget powerpc-*-linux*paired*])
2242 || [istarget ia64-*-*]
2243 || [istarget i?86-*-*]
2244 || [istarget x86_64-*-*]
2245 || [check_effective_target_arm32]
2246 || ([istarget mips*-*-*]
2247 && [check_effective_target_mips_loongson]) } {
2248 set et_vect_shift_saved 1
2252 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2253 return $et_vect_shift_saved
2256 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2258 # This can change for different subtargets so do not cache the result.
2260 proc check_effective_target_vect_long { } {
2261 if { [istarget i?86-*-*]
2262 || (([istarget powerpc*-*-*]
2263 && ![istarget powerpc-*-linux*paired*])
2264 && [check_effective_target_ilp32])
2265 || [istarget x86_64-*-*]
2266 || [check_effective_target_arm32]
2267 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2273 verbose "check_effective_target_vect_long: returning $answer" 2
2277 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2279 # This won't change for different subtargets so cache the result.
2281 proc check_effective_target_vect_float { } {
2282 global et_vect_float_saved
2284 if [info exists et_vect_float_saved] {
2285 verbose "check_effective_target_vect_float: using cached result" 2
2287 set et_vect_float_saved 0
2288 if { [istarget i?86-*-*]
2289 || [istarget powerpc*-*-*]
2290 || [istarget spu-*-*]
2291 || [istarget mipsisa64*-*-*]
2292 || [istarget x86_64-*-*]
2293 || [istarget ia64-*-*]
2294 || [check_effective_target_arm32] } {
2295 set et_vect_float_saved 1
2299 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2300 return $et_vect_float_saved
2303 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2305 # This won't change for different subtargets so cache the result.
2307 proc check_effective_target_vect_double { } {
2308 global et_vect_double_saved
2310 if [info exists et_vect_double_saved] {
2311 verbose "check_effective_target_vect_double: using cached result" 2
2313 set et_vect_double_saved 0
2314 if { [istarget i?86-*-*]
2315 || [istarget x86_64-*-*] } {
2316 if { [check_no_compiler_messages vect_double assembly {
2317 #ifdef __tune_atom__
2318 # error No double vectorizer support.
2321 set et_vect_double_saved 1
2323 set et_vect_double_saved 0
2325 } elseif { [istarget spu-*-*] } {
2326 set et_vect_double_saved 1
2330 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2331 return $et_vect_double_saved
2334 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2336 # This won't change for different subtargets so cache the result.
2338 proc check_effective_target_vect_long_long { } {
2339 global et_vect_long_long_saved
2341 if [info exists et_vect_long_long_saved] {
2342 verbose "check_effective_target_vect_long_long: using cached result" 2
2344 set et_vect_long_long_saved 0
2345 if { [istarget i?86-*-*]
2346 || [istarget x86_64-*-*] } {
2347 set et_vect_long_long_saved 1
2351 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2352 return $et_vect_long_long_saved
2356 # Return 1 if the target plus current options does not support a vector
2357 # max instruction on "int", 0 otherwise.
2359 # This won't change for different subtargets so cache the result.
2361 proc check_effective_target_vect_no_int_max { } {
2362 global et_vect_no_int_max_saved
2364 if [info exists et_vect_no_int_max_saved] {
2365 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2367 set et_vect_no_int_max_saved 0
2368 if { [istarget sparc*-*-*]
2369 || [istarget spu-*-*]
2370 || [istarget alpha*-*-*]
2371 || ([istarget mips*-*-*]
2372 && [check_effective_target_mips_loongson]) } {
2373 set et_vect_no_int_max_saved 1
2376 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2377 return $et_vect_no_int_max_saved
2380 # Return 1 if the target plus current options does not support a vector
2381 # add instruction on "int", 0 otherwise.
2383 # This won't change for different subtargets so cache the result.
2385 proc check_effective_target_vect_no_int_add { } {
2386 global et_vect_no_int_add_saved
2388 if [info exists et_vect_no_int_add_saved] {
2389 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2391 set et_vect_no_int_add_saved 0
2392 # Alpha only supports vector add on V8QI and V4HI.
2393 if { [istarget alpha*-*-*] } {
2394 set et_vect_no_int_add_saved 1
2397 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2398 return $et_vect_no_int_add_saved
2401 # Return 1 if the target plus current options does not support vector
2402 # bitwise instructions, 0 otherwise.
2404 # This won't change for different subtargets so cache the result.
2406 proc check_effective_target_vect_no_bitwise { } {
2407 global et_vect_no_bitwise_saved
2409 if [info exists et_vect_no_bitwise_saved] {
2410 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2412 set et_vect_no_bitwise_saved 0
2414 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2415 return $et_vect_no_bitwise_saved
2418 # Return 1 if the target plus current options supports vector permutation,
2421 # This won't change for different subtargets so cache the result.
2423 proc check_effective_target_vect_perm { } {
2426 if [info exists et_vect_perm_saved] {
2427 verbose "check_effective_target_vect_perm: using cached result" 2
2429 set et_vect_perm_saved 0
2430 if { [istarget powerpc*-*-*]
2431 || [istarget spu-*-*]
2432 || [istarget i?86-*-*]
2433 || [istarget x86_64-*-*] } {
2434 set et_vect_perm_saved 1
2437 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2438 return $et_vect_perm_saved
2441 # Return 1 if the target plus current options supports vector permutation
2442 # on byte-sized elements, 0 otherwise.
2444 # This won't change for different subtargets so cache the result.
2446 proc check_effective_target_vect_perm_byte { } {
2447 global et_vect_perm_byte
2449 if [info exists et_vect_perm_byte_saved] {
2450 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2452 set et_vect_perm_byte_saved 0
2453 if { [istarget powerpc*-*-*]
2454 || [istarget spu-*-*] } {
2455 set et_vect_perm_byte_saved 1
2458 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2459 return $et_vect_perm_byte_saved
2462 # Return 1 if the target plus current options supports vector permutation
2463 # on short-sized elements, 0 otherwise.
2465 # This won't change for different subtargets so cache the result.
2467 proc check_effective_target_vect_perm_short { } {
2468 global et_vect_perm_short
2470 if [info exists et_vect_perm_short_saved] {
2471 verbose "check_effective_target_vect_perm_short: using cached result" 2
2473 set et_vect_perm_short_saved 0
2474 if { [istarget powerpc*-*-*]
2475 || [istarget spu-*-*] } {
2476 set et_vect_perm_short_saved 1
2479 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2480 return $et_vect_perm_short_saved
2483 # Return 1 if the target plus current options supports a vector
2484 # widening summation of *short* args into *int* result, 0 otherwise.
2486 # This won't change for different subtargets so cache the result.
2488 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2489 global et_vect_widen_sum_hi_to_si_pattern
2491 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2492 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2494 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2495 if { [istarget powerpc*-*-*] } {
2496 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2499 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2500 return $et_vect_widen_sum_hi_to_si_pattern_saved
2503 # Return 1 if the target plus current options supports a vector
2504 # widening summation of *short* args into *int* result, 0 otherwise.
2505 # A target can also support this widening summation if it can support
2506 # promotion (unpacking) from shorts to ints.
2508 # This won't change for different subtargets so cache the result.
2510 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2511 global et_vect_widen_sum_hi_to_si
2513 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2514 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2516 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2517 if { [istarget powerpc*-*-*]
2518 || [istarget ia64-*-*] } {
2519 set et_vect_widen_sum_hi_to_si_saved 1
2522 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2523 return $et_vect_widen_sum_hi_to_si_saved
2526 # Return 1 if the target plus current options supports a vector
2527 # widening summation of *char* args into *short* result, 0 otherwise.
2528 # A target can also support this widening summation if it can support
2529 # promotion (unpacking) from chars to shorts.
2531 # This won't change for different subtargets so cache the result.
2533 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2534 global et_vect_widen_sum_qi_to_hi
2536 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2537 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2539 set et_vect_widen_sum_qi_to_hi_saved 0
2540 if { [check_effective_target_vect_unpack]
2541 || [istarget ia64-*-*] } {
2542 set et_vect_widen_sum_qi_to_hi_saved 1
2545 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2546 return $et_vect_widen_sum_qi_to_hi_saved
2549 # Return 1 if the target plus current options supports a vector
2550 # widening summation of *char* args into *int* result, 0 otherwise.
2552 # This won't change for different subtargets so cache the result.
2554 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2555 global et_vect_widen_sum_qi_to_si
2557 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2558 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2560 set et_vect_widen_sum_qi_to_si_saved 0
2561 if { [istarget powerpc*-*-*] } {
2562 set et_vect_widen_sum_qi_to_si_saved 1
2565 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2566 return $et_vect_widen_sum_qi_to_si_saved
2569 # Return 1 if the target plus current options supports a vector
2570 # widening multiplication of *char* args into *short* result, 0 otherwise.
2571 # A target can also support this widening multplication if it can support
2572 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2573 # multiplication of shorts).
2575 # This won't change for different subtargets so cache the result.
2578 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2579 global et_vect_widen_mult_qi_to_hi
2581 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2582 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2584 if { [check_effective_target_vect_unpack]
2585 && [check_effective_target_vect_short_mult] } {
2586 set et_vect_widen_mult_qi_to_hi_saved 1
2588 set et_vect_widen_mult_qi_to_hi_saved 0
2590 if { [istarget powerpc*-*-*] } {
2591 set et_vect_widen_mult_qi_to_hi_saved 1
2594 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2595 return $et_vect_widen_mult_qi_to_hi_saved
2598 # Return 1 if the target plus current options supports a vector
2599 # widening multiplication of *short* args into *int* result, 0 otherwise.
2600 # A target can also support this widening multplication if it can support
2601 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2602 # multiplication of ints).
2604 # This won't change for different subtargets so cache the result.
2607 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2608 global et_vect_widen_mult_hi_to_si
2610 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2611 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2613 if { [check_effective_target_vect_unpack]
2614 && [check_effective_target_vect_int_mult] } {
2615 set et_vect_widen_mult_hi_to_si_saved 1
2617 set et_vect_widen_mult_hi_to_si_saved 0
2619 if { [istarget powerpc*-*-*]
2620 || [istarget spu-*-*]
2621 || [istarget i?86-*-*]
2622 || [istarget x86_64-*-*] } {
2623 set et_vect_widen_mult_hi_to_si_saved 1
2626 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2627 return $et_vect_widen_mult_hi_to_si_saved
2630 # Return 1 if the target plus current options supports a vector
2631 # dot-product of signed chars, 0 otherwise.
2633 # This won't change for different subtargets so cache the result.
2635 proc check_effective_target_vect_sdot_qi { } {
2636 global et_vect_sdot_qi
2638 if [info exists et_vect_sdot_qi_saved] {
2639 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2641 set et_vect_sdot_qi_saved 0
2643 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2644 return $et_vect_sdot_qi_saved
2647 # Return 1 if the target plus current options supports a vector
2648 # dot-product of unsigned chars, 0 otherwise.
2650 # This won't change for different subtargets so cache the result.
2652 proc check_effective_target_vect_udot_qi { } {
2653 global et_vect_udot_qi
2655 if [info exists et_vect_udot_qi_saved] {
2656 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2658 set et_vect_udot_qi_saved 0
2659 if { [istarget powerpc*-*-*] } {
2660 set et_vect_udot_qi_saved 1
2663 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2664 return $et_vect_udot_qi_saved
2667 # Return 1 if the target plus current options supports a vector
2668 # dot-product of signed shorts, 0 otherwise.
2670 # This won't change for different subtargets so cache the result.
2672 proc check_effective_target_vect_sdot_hi { } {
2673 global et_vect_sdot_hi
2675 if [info exists et_vect_sdot_hi_saved] {
2676 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2678 set et_vect_sdot_hi_saved 0
2679 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2680 || [istarget i?86-*-*]
2681 || [istarget x86_64-*-*] } {
2682 set et_vect_sdot_hi_saved 1
2685 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2686 return $et_vect_sdot_hi_saved
2689 # Return 1 if the target plus current options supports a vector
2690 # dot-product of unsigned shorts, 0 otherwise.
2692 # This won't change for different subtargets so cache the result.
2694 proc check_effective_target_vect_udot_hi { } {
2695 global et_vect_udot_hi
2697 if [info exists et_vect_udot_hi_saved] {
2698 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2700 set et_vect_udot_hi_saved 0
2701 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2702 set et_vect_udot_hi_saved 1
2705 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2706 return $et_vect_udot_hi_saved
2710 # Return 1 if the target plus current options supports a vector
2711 # demotion (packing) of shorts (to chars) and ints (to shorts)
2712 # using modulo arithmetic, 0 otherwise.
2714 # This won't change for different subtargets so cache the result.
2716 proc check_effective_target_vect_pack_trunc { } {
2717 global et_vect_pack_trunc
2719 if [info exists et_vect_pack_trunc_saved] {
2720 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2722 set et_vect_pack_trunc_saved 0
2723 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2724 || [istarget i?86-*-*]
2725 || [istarget x86_64-*-*]
2726 || [istarget spu-*-*]
2727 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2728 set et_vect_pack_trunc_saved 1
2731 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2732 return $et_vect_pack_trunc_saved
2735 # Return 1 if the target plus current options supports a vector
2736 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2738 # This won't change for different subtargets so cache the result.
2740 proc check_effective_target_vect_unpack { } {
2741 global et_vect_unpack
2743 if [info exists et_vect_unpack_saved] {
2744 verbose "check_effective_target_vect_unpack: using cached result" 2
2746 set et_vect_unpack_saved 0
2747 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2748 || [istarget i?86-*-*]
2749 || [istarget x86_64-*-*]
2750 || [istarget spu-*-*]
2751 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2752 set et_vect_unpack_saved 1
2755 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2756 return $et_vect_unpack_saved
2759 # Return 1 if the target plus current options does not guarantee
2760 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2762 # This won't change for different subtargets so cache the result.
2764 proc check_effective_target_unaligned_stack { } {
2765 global et_unaligned_stack_saved
2767 if [info exists et_unaligned_stack_saved] {
2768 verbose "check_effective_target_unaligned_stack: using cached result" 2
2770 set et_unaligned_stack_saved 0
2772 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2773 return $et_unaligned_stack_saved
2776 # Return 1 if the target plus current options does not support a vector
2777 # alignment mechanism, 0 otherwise.
2779 # This won't change for different subtargets so cache the result.
2781 proc check_effective_target_vect_no_align { } {
2782 global et_vect_no_align_saved
2784 if [info exists et_vect_no_align_saved] {
2785 verbose "check_effective_target_vect_no_align: using cached result" 2
2787 set et_vect_no_align_saved 0
2788 if { [istarget mipsisa64*-*-*]
2789 || [istarget sparc*-*-*]
2790 || [istarget ia64-*-*]
2791 || [check_effective_target_arm_vect_no_misalign]
2792 || ([istarget mips*-*-*]
2793 && [check_effective_target_mips_loongson]) } {
2794 set et_vect_no_align_saved 1
2797 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2798 return $et_vect_no_align_saved
2801 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2803 # This won't change for different subtargets so cache the result.
2805 proc check_effective_target_vect_hw_misalign { } {
2806 global et_vect_hw_misalign_saved
2808 if [info exists et_vect_hw_misalign_saved] {
2809 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2811 set et_vect_hw_misalign_saved 0
2812 if { ([istarget x86_64-*-*]
2813 || [istarget i?86-*-*]) } {
2814 set et_vect_hw_misalign_saved 1
2817 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2818 return $et_vect_hw_misalign_saved
2822 # Return 1 if arrays are aligned to the vector alignment
2823 # boundary, 0 otherwise.
2825 # This won't change for different subtargets so cache the result.
2827 proc check_effective_target_vect_aligned_arrays { } {
2828 global et_vect_aligned_arrays
2830 if [info exists et_vect_aligned_arrays_saved] {
2831 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2833 set et_vect_aligned_arrays_saved 0
2834 if { (([istarget x86_64-*-*]
2835 || [istarget i?86-*-*]) && [is-effective-target lp64])
2836 || [istarget spu-*-*] } {
2837 set et_vect_aligned_arrays_saved 1
2840 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2841 return $et_vect_aligned_arrays_saved
2844 # Return 1 if types of size 32 bit or less are naturally aligned
2845 # (aligned to their type-size), 0 otherwise.
2847 # This won't change for different subtargets so cache the result.
2849 proc check_effective_target_natural_alignment_32 { } {
2850 global et_natural_alignment_32
2852 if [info exists et_natural_alignment_32_saved] {
2853 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2855 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2856 set et_natural_alignment_32_saved 1
2857 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2858 set et_natural_alignment_32_saved 0
2861 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2862 return $et_natural_alignment_32_saved
2865 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2866 # type-size), 0 otherwise.
2868 # This won't change for different subtargets so cache the result.
2870 proc check_effective_target_natural_alignment_64 { } {
2871 global et_natural_alignment_64
2873 if [info exists et_natural_alignment_64_saved] {
2874 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2876 set et_natural_alignment_64_saved 0
2877 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2878 || [istarget spu-*-*] } {
2879 set et_natural_alignment_64_saved 1
2882 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2883 return $et_natural_alignment_64_saved
2886 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2888 # This won't change for different subtargets so cache the result.
2890 proc check_effective_target_vector_alignment_reachable { } {
2891 global et_vector_alignment_reachable
2893 if [info exists et_vector_alignment_reachable_saved] {
2894 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2896 if { [check_effective_target_vect_aligned_arrays]
2897 || [check_effective_target_natural_alignment_32] } {
2898 set et_vector_alignment_reachable_saved 1
2900 set et_vector_alignment_reachable_saved 0
2903 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2904 return $et_vector_alignment_reachable_saved
2907 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2909 # This won't change for different subtargets so cache the result.
2911 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2912 global et_vector_alignment_reachable_for_64bit
2914 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2915 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2917 if { [check_effective_target_vect_aligned_arrays]
2918 || [check_effective_target_natural_alignment_64] } {
2919 set et_vector_alignment_reachable_for_64bit_saved 1
2921 set et_vector_alignment_reachable_for_64bit_saved 0
2924 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2925 return $et_vector_alignment_reachable_for_64bit_saved
2928 # Return 1 if the target only requires element alignment for vector accesses
2930 proc check_effective_target_vect_element_align { } {
2931 global et_vect_element_align
2933 if [info exists et_vect_element_align] {
2934 verbose "check_effective_target_vect_element_align: using cached result" 2
2936 set et_vect_element_align 0
2937 if { [istarget arm*-*-*]
2938 || [check_effective_target_vect_hw_misalign] } {
2939 set et_vect_element_align 1
2943 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
2944 return $et_vect_element_align
2947 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2949 proc check_effective_target_vect_condition { } {
2950 global et_vect_cond_saved
2952 if [info exists et_vect_cond_saved] {
2953 verbose "check_effective_target_vect_cond: using cached result" 2
2955 set et_vect_cond_saved 0
2956 if { [istarget powerpc*-*-*]
2957 || [istarget ia64-*-*]
2958 || [istarget i?86-*-*]
2959 || [istarget spu-*-*]
2960 || [istarget x86_64-*-*] } {
2961 set et_vect_cond_saved 1
2965 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2966 return $et_vect_cond_saved
2969 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2971 proc check_effective_target_vect_char_mult { } {
2972 global et_vect_char_mult_saved
2974 if [info exists et_vect_char_mult_saved] {
2975 verbose "check_effective_target_vect_char_mult: using cached result" 2
2977 set et_vect_char_mult_saved 0
2978 if { [istarget ia64-*-*]
2979 || [istarget i?86-*-*]
2980 || [istarget x86_64-*-*] } {
2981 set et_vect_char_mult_saved 1
2985 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2986 return $et_vect_char_mult_saved
2989 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2991 proc check_effective_target_vect_short_mult { } {
2992 global et_vect_short_mult_saved
2994 if [info exists et_vect_short_mult_saved] {
2995 verbose "check_effective_target_vect_short_mult: using cached result" 2
2997 set et_vect_short_mult_saved 0
2998 if { [istarget ia64-*-*]
2999 || [istarget spu-*-*]
3000 || [istarget i?86-*-*]
3001 || [istarget x86_64-*-*]
3002 || [istarget powerpc*-*-*]
3003 || [check_effective_target_arm32]
3004 || ([istarget mips*-*-*]
3005 && [check_effective_target_mips_loongson]) } {
3006 set et_vect_short_mult_saved 1
3010 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3011 return $et_vect_short_mult_saved
3014 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3016 proc check_effective_target_vect_int_mult { } {
3017 global et_vect_int_mult_saved
3019 if [info exists et_vect_int_mult_saved] {
3020 verbose "check_effective_target_vect_int_mult: using cached result" 2
3022 set et_vect_int_mult_saved 0
3023 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3024 || [istarget spu-*-*]
3025 || [istarget i?86-*-*]
3026 || [istarget x86_64-*-*]
3027 || [check_effective_target_arm32] } {
3028 set et_vect_int_mult_saved 1
3032 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3033 return $et_vect_int_mult_saved
3036 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3038 proc check_effective_target_vect_extract_even_odd { } {
3039 global et_vect_extract_even_odd_saved
3041 if [info exists et_vect_extract_even_odd_saved] {
3042 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3044 set et_vect_extract_even_odd_saved 0
3045 if { [istarget powerpc*-*-*]
3046 || [istarget i?86-*-*]
3047 || [istarget x86_64-*-*]
3048 || [istarget spu-*-*] } {
3049 set et_vect_extract_even_odd_saved 1
3053 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3054 return $et_vect_extract_even_odd_saved
3057 # Return 1 if the target supports vector even/odd elements extraction of
3058 # vectors with SImode elements or larger, 0 otherwise.
3060 proc check_effective_target_vect_extract_even_odd_wide { } {
3061 global et_vect_extract_even_odd_wide_saved
3063 if [info exists et_vect_extract_even_odd_wide_saved] {
3064 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
3066 set et_vect_extract_even_odd_wide_saved 0
3067 if { [istarget powerpc*-*-*]
3068 || [istarget i?86-*-*]
3069 || [istarget x86_64-*-*]
3070 || [istarget spu-*-*] } {
3071 set et_vect_extract_even_odd_wide_saved 1
3075 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
3076 return $et_vect_extract_even_odd_wide_saved
3079 # Return 1 if the target supports vector interleaving, 0 otherwise.
3081 proc check_effective_target_vect_interleave { } {
3082 global et_vect_interleave_saved
3084 if [info exists et_vect_interleave_saved] {
3085 verbose "check_effective_target_vect_interleave: using cached result" 2
3087 set et_vect_interleave_saved 0
3088 if { [istarget powerpc*-*-*]
3089 || [istarget i?86-*-*]
3090 || [istarget x86_64-*-*]
3091 || [istarget spu-*-*] } {
3092 set et_vect_interleave_saved 1
3096 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3097 return $et_vect_interleave_saved
3100 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
3101 proc check_effective_target_vect_strided { } {
3102 global et_vect_strided_saved
3104 if [info exists et_vect_strided_saved] {
3105 verbose "check_effective_target_vect_strided: using cached result" 2
3107 set et_vect_strided_saved 0
3108 if { [check_effective_target_vect_interleave]
3109 && [check_effective_target_vect_extract_even_odd] } {
3110 set et_vect_strided_saved 1
3114 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
3115 return $et_vect_strided_saved
3118 # Return 1 if the target supports vector interleaving and extract even/odd
3119 # for wide element types, 0 otherwise.
3120 proc check_effective_target_vect_strided_wide { } {
3121 global et_vect_strided_wide_saved
3123 if [info exists et_vect_strided_wide_saved] {
3124 verbose "check_effective_target_vect_strided_wide: using cached result" 2
3126 set et_vect_strided_wide_saved 0
3127 if { [check_effective_target_vect_interleave]
3128 && [check_effective_target_vect_extract_even_odd_wide] } {
3129 set et_vect_strided_wide_saved 1
3133 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
3134 return $et_vect_strided_wide_saved
3137 # Return 1 if the target supports section-anchors
3139 proc check_effective_target_section_anchors { } {
3140 global et_section_anchors_saved
3142 if [info exists et_section_anchors_saved] {
3143 verbose "check_effective_target_section_anchors: using cached result" 2
3145 set et_section_anchors_saved 0
3146 if { [istarget powerpc*-*-*]
3147 || [istarget arm*-*-*] } {
3148 set et_section_anchors_saved 1
3152 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3153 return $et_section_anchors_saved
3156 # Return 1 if the target supports atomic operations on "int" and "long".
3158 proc check_effective_target_sync_int_long { } {
3159 global et_sync_int_long_saved
3161 if [info exists et_sync_int_long_saved] {
3162 verbose "check_effective_target_sync_int_long: using cached result" 2
3164 set et_sync_int_long_saved 0
3165 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3166 # load-reserved/store-conditional instructions.
3167 if { [istarget ia64-*-*]
3168 || [istarget i?86-*-*]
3169 || [istarget x86_64-*-*]
3170 || [istarget alpha*-*-*]
3171 || [istarget arm*-*-linux-gnueabi]
3172 || [istarget bfin*-*linux*]
3173 || [istarget hppa*-*linux*]
3174 || [istarget s390*-*-*]
3175 || [istarget powerpc*-*-*]
3176 || [istarget sparc64-*-*]
3177 || [istarget sparcv9-*-*]
3178 || [istarget mips*-*-*] } {
3179 set et_sync_int_long_saved 1
3183 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3184 return $et_sync_int_long_saved
3187 # Return 1 if the target supports atomic operations on "char" and "short".
3189 proc check_effective_target_sync_char_short { } {
3190 global et_sync_char_short_saved
3192 if [info exists et_sync_char_short_saved] {
3193 verbose "check_effective_target_sync_char_short: using cached result" 2
3195 set et_sync_char_short_saved 0
3196 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3197 # load-reserved/store-conditional instructions.
3198 if { [istarget ia64-*-*]
3199 || [istarget i?86-*-*]
3200 || [istarget x86_64-*-*]
3201 || [istarget alpha*-*-*]
3202 || [istarget arm*-*-linux-gnueabi]
3203 || [istarget hppa*-*linux*]
3204 || [istarget s390*-*-*]
3205 || [istarget powerpc*-*-*]
3206 || [istarget sparc64-*-*]
3207 || [istarget sparcv9-*-*]
3208 || [istarget mips*-*-*] } {
3209 set et_sync_char_short_saved 1
3213 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3214 return $et_sync_char_short_saved
3217 # Return 1 if the target uses a ColdFire FPU.
3219 proc check_effective_target_coldfire_fpu { } {
3220 return [check_no_compiler_messages coldfire_fpu assembly {
3227 # Return true if this is a uClibc target.
3229 proc check_effective_target_uclibc {} {
3230 return [check_no_compiler_messages uclibc object {
3231 #include <features.h>
3232 #if !defined (__UCLIBC__)
3238 # Return true if this is a uclibc target and if the uclibc feature
3239 # described by __$feature__ is not present.
3241 proc check_missing_uclibc_feature {feature} {
3242 return [check_no_compiler_messages $feature object "
3243 #include <features.h>
3244 #if !defined (__UCLIBC) || defined (__${feature}__)
3250 # Return true if this is a Newlib target.
3252 proc check_effective_target_newlib {} {
3253 return [check_no_compiler_messages newlib object {
3259 # (a) an error of a few ULP is expected in string to floating-point
3260 # conversion functions; and
3261 # (b) overflow is not always detected correctly by those functions.
3263 proc check_effective_target_lax_strtofp {} {
3264 # By default, assume that all uClibc targets suffer from this.
3265 return [check_effective_target_uclibc]
3268 # Return 1 if this is a target for which wcsftime is a dummy
3269 # function that always returns 0.
3271 proc check_effective_target_dummy_wcsftime {} {
3272 # By default, assume that all uClibc targets suffer from this.
3273 return [check_effective_target_uclibc]
3276 # Return 1 if constructors with initialization priority arguments are
3277 # supposed on this target.
3279 proc check_effective_target_init_priority {} {
3280 return [check_no_compiler_messages init_priority assembly "
3281 void f() __attribute__((constructor (1000)));
3286 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3287 # This can be used with any check_* proc that takes no argument and
3288 # returns only 1 or 0. It could be used with check_* procs that take
3289 # arguments with keywords that pass particular arguments.
3291 proc is-effective-target { arg } {
3293 if { [info procs check_effective_target_${arg}] != [list] } {
3294 set selected [check_effective_target_${arg}]
3297 "vmx_hw" { set selected [check_vmx_hw_available] }
3298 "vsx_hw" { set selected [check_vsx_hw_available] }
3299 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3300 "named_sections" { set selected [check_named_sections_available] }
3301 "gc_sections" { set selected [check_gc_sections_available] }
3302 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3303 default { error "unknown effective target keyword `$arg'" }
3306 verbose "is-effective-target: $arg $selected" 2
3310 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3312 proc is-effective-target-keyword { arg } {
3313 if { [info procs check_effective_target_${arg}] != [list] } {
3316 # These have different names for their check_* procs.
3318 "vmx_hw" { return 1 }
3319 "vsx_hw" { return 1 }
3320 "ppc_recip_hw" { return 1 }
3321 "named_sections" { return 1 }
3322 "gc_sections" { return 1 }
3323 "cxa_atexit" { return 1 }
3324 default { return 0 }
3329 # Return 1 if target default to short enums
3331 proc check_effective_target_short_enums { } {
3332 return [check_no_compiler_messages short_enums assembly {
3334 int s[sizeof (enum foo) == 1 ? 1 : -1];
3338 # Return 1 if target supports merging string constants at link time.
3340 proc check_effective_target_string_merging { } {
3341 return [check_no_messages_and_pattern string_merging \
3342 "rodata\\.str" assembly {
3343 const char *var = "String";
3347 # Return 1 if target has the basic signed and unsigned types in
3348 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3349 # working <stdint.h> for all targets.
3351 proc check_effective_target_stdint_types { } {
3352 return [check_no_compiler_messages stdint_types assembly {
3354 int8_t a; int16_t b; int32_t c; int64_t d;
3355 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3359 # Return 1 if target has the basic signed and unsigned types in
3360 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3361 # these types agree with those in the header, as some systems have
3362 # only <inttypes.h>.
3364 proc check_effective_target_inttypes_types { } {
3365 return [check_no_compiler_messages inttypes_types assembly {
3366 #include <inttypes.h>
3367 int8_t a; int16_t b; int32_t c; int64_t d;
3368 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3372 # Return 1 if programs are intended to be run on a simulator
3373 # (i.e. slowly) rather than hardware (i.e. fast).
3375 proc check_effective_target_simulator { } {
3377 # All "src/sim" simulators set this one.
3378 if [board_info target exists is_simulator] {
3379 return [board_info target is_simulator]
3382 # The "sid" simulators don't set that one, but at least they set
3384 if [board_info target exists slow_simulator] {
3385 return [board_info target slow_simulator]
3391 # Return 1 if the target is a VxWorks kernel.
3393 proc check_effective_target_vxworks_kernel { } {
3394 return [check_no_compiler_messages vxworks_kernel assembly {
3395 #if !defined __vxworks || defined __RTP__
3401 # Return 1 if the target is a VxWorks RTP.
3403 proc check_effective_target_vxworks_rtp { } {
3404 return [check_no_compiler_messages vxworks_rtp assembly {
3405 #if !defined __vxworks || !defined __RTP__
3411 # Return 1 if the target is expected to provide wide character support.
3413 proc check_effective_target_wchar { } {
3414 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3417 return [check_no_compiler_messages wchar assembly {
3422 # Return 1 if the target has <pthread.h>.
3424 proc check_effective_target_pthread_h { } {
3425 return [check_no_compiler_messages pthread_h assembly {
3426 #include <pthread.h>
3430 # Return 1 if the target can truncate a file from a file-descriptor,
3431 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3432 # chsize. We test for a trivially functional truncation; no stubs.
3433 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3434 # different function to be used.
3436 proc check_effective_target_fd_truncate { } {
3438 #define _FILE_OFFSET_BITS 64
3444 FILE *f = fopen ("tst.tmp", "wb");
3446 const char t[] = "test writing more than ten characters";
3449 write (fd, t, sizeof (t) - 1);
3451 if (ftruncate (fd, 10) != 0)
3454 f = fopen ("tst.tmp", "rb");
3455 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3461 if { [check_runtime ftruncate $prog] } {
3465 regsub "ftruncate" $prog "chsize" prog
3466 return [check_runtime chsize $prog]
3469 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3471 proc add_options_for_c99_runtime { flags } {
3472 if { [istarget *-*-solaris2*] } {
3473 return "$flags -std=c99"
3475 if { [istarget powerpc-*-darwin*] } {
3476 return "$flags -mmacosx-version-min=10.3"
3481 # Add to FLAGS all the target-specific flags needed to enable
3482 # full IEEE compliance mode.
3484 proc add_options_for_ieee { flags } {
3485 if { [istarget "alpha*-*-*"]
3486 || [istarget "sh*-*-*"] } {
3487 return "$flags -mieee"
3492 # Add to FLAGS the flags needed to enable functions to bind locally
3493 # when using pic/PIC passes in the testsuite.
3495 proc add_options_for_bind_pic_locally { flags } {
3496 if {[check_no_compiler_messages using_pic2 assembly {
3501 return "$flags -fPIE"
3503 if {[check_no_compiler_messages using_pic1 assembly {
3508 return "$flags -fpie"
3514 # Add to FLAGS the flags needed to enable 128-bit vectors.
3516 proc add_options_for_quad_vectors { flags } {
3517 if [is-effective-target arm_neon_ok] {
3518 return "$flags -mvectorize-with-neon-quad"
3524 # Return 1 if the target provides a full C99 runtime.
3526 proc check_effective_target_c99_runtime { } {
3527 return [check_cached_effective_target c99_runtime {
3530 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3531 set contents [read $file]
3534 #ifndef HAVE_C99_RUNTIME
3538 check_no_compiler_messages_nocache c99_runtime assembly \
3539 $contents [add_options_for_c99_runtime ""]
3543 # Return 1 if target wchar_t is at least 4 bytes.
3545 proc check_effective_target_4byte_wchar_t { } {
3546 return [check_no_compiler_messages 4byte_wchar_t object {
3547 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3551 # Return 1 if the target supports automatic stack alignment.
3553 proc check_effective_target_automatic_stack_alignment { } {
3554 # Not "stack alignment" per se, but proper stack alignment of decls.
3558 # Return 1 if avx instructions can be compiled.
3560 proc check_effective_target_avx { } {
3561 return [check_no_compiler_messages avx object {
3562 void _mm256_zeroall (void)
3564 __builtin_ia32_vzeroall ();
3569 # Return 1 if sse instructions can be compiled.
3570 proc check_effective_target_sse { } {
3571 return [check_no_compiler_messages sse object {
3574 __builtin_ia32_stmxcsr ();
3580 # Return 1 if sse2 instructions can be compiled.
3581 proc check_effective_target_sse2 { } {
3582 return [check_no_compiler_messages sse2 object {
3583 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3585 __m128i _mm_srli_si128 (__m128i __A, int __N)
3587 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3592 # Return 1 if F16C instructions can be compiled.
3594 proc check_effective_target_f16c { } {
3595 return [check_no_compiler_messages f16c object {
3596 #include "immintrin.h"
3598 foo (unsigned short val)
3600 return _cvtsh_ss (val);
3605 # Return 1 if C wchar_t type is compatible with char16_t.
3607 proc check_effective_target_wchar_t_char16_t_compatible { } {
3608 return [check_no_compiler_messages wchar_t_char16_t object {
3610 __CHAR16_TYPE__ *p16 = &wc;
3611 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3615 # Return 1 if C wchar_t type is compatible with char32_t.
3617 proc check_effective_target_wchar_t_char32_t_compatible { } {
3618 return [check_no_compiler_messages wchar_t_char32_t object {
3620 __CHAR32_TYPE__ *p32 = &wc;
3621 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3625 # Return 1 if pow10 function exists.
3627 proc check_effective_target_pow10 { } {
3628 return [check_runtime pow10 {
3638 # Return 1 if current options generate DFP instructions, 0 otherwise.
3640 proc check_effective_target_hard_dfp {} {
3641 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3642 typedef float d64 __attribute__((mode(DD)));
3644 void foo (void) { z = x + y; }
3648 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3649 # for strchr etc. functions.
3651 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3652 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3655 #if !defined(__cplusplus) \
3656 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3657 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3658 ISO C++ correct string.h and wchar.h protos not supported.
3665 # Return 1 if GNU as is used.
3667 proc check_effective_target_gas { } {
3668 global use_gas_saved
3671 if {![info exists use_gas_saved]} {
3672 # Check if the as used by gcc is GNU as.
3673 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3674 # Provide /dev/null as input, otherwise gas times out reading from
3676 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3677 set as_output [lindex $status 1]
3678 if { [ string first "GNU" $as_output ] >= 0 } {
3684 return $use_gas_saved
3687 # Return 1 if the compiler has been configure with link-time optimization
3690 proc check_effective_target_lto { } {
3692 return [info exists ENABLE_LTO]
3695 # Return 1 if this target supports the -fsplit-stack option, 0
3698 proc check_effective_target_split_stack {} {
3699 return [check_no_compiler_messages split_stack object {
3704 # Return 1 if the language for the compiler under test is C.
3706 proc check_effective_target_c { } {
3708 if [string match $tool "gcc"] {
3714 # Return 1 if the language for the compiler under test is C++.
3716 proc check_effective_target_c++ { } {
3718 if [string match $tool "g++"] {
3724 # Return 1 if expensive testcases should be run.
3726 proc check_effective_target_run_expensive_tests { } {
3727 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {