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 alias attribute.
377 # Returns 2 if the target supports aliases. Returns 1 if the target
378 # only supports weak aliased. Returns 0 if the target does not
379 # support aliases at all. Returns -1 if support for aliases could not
382 proc check_ifunc_available { } {
383 global ifunc_available_saved
386 if [info exists ifunc_available_saved] {
387 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
391 verbose "check_ifunc_available compiling testfile $src" 2
392 set f [open $src "w"]
393 # Compile a small test program. The definition of "g" is
394 # necessary to keep the Solaris assembler from complaining
396 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
397 puts $f "void g() {} void f() __attribute__((ifunc(\"g\")));"
399 set lines [${tool}_target_compile $src $obj object ""]
401 remote_file build delete $obj
403 if [string match "" $lines] then {
404 # No error messages, everything is OK.
405 set ifunc_available_saved 2
407 if [regexp "ifunc is not supported" $lines] {
408 verbose "check_ifunc_available target does not support ifunc" 2
409 set ifunc_available_saved 0
411 set ifunc_available_saved -1
415 verbose "check_ifunc_available returning $ifunc_available_saved" 2
418 return $ifunc_available_saved
421 # Returns true if --gc-sections is supported on the target.
423 proc check_gc_sections_available { } {
424 global gc_sections_available_saved
427 if {![info exists gc_sections_available_saved]} {
428 # Some targets don't support gc-sections despite whatever's
429 # advertised by ld's options.
430 if { [istarget alpha*-*-*]
431 || [istarget ia64-*-*] } {
432 set gc_sections_available_saved 0
436 # elf2flt uses -q (--emit-relocs), which is incompatible with
438 if { [board_info target exists ldflags]
439 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
440 set gc_sections_available_saved 0
444 # VxWorks kernel modules are relocatable objects linked with -r,
445 # while RTP executables are linked with -q (--emit-relocs).
446 # Both of these options are incompatible with --gc-sections.
447 if { [istarget *-*-vxworks*] } {
448 set gc_sections_available_saved 0
452 # Check if the ld used by gcc supports --gc-sections.
453 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
454 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
455 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
456 set ld_output [remote_exec host "$gcc_ld" "--help"]
457 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
458 set gc_sections_available_saved 1
460 set gc_sections_available_saved 0
463 return $gc_sections_available_saved
466 # Return 1 if according to target_info struct and explicit target list
467 # target is supposed to support trampolines.
469 proc check_effective_target_trampolines { } {
470 if [target_info exists no_trampolines] {
473 if { [istarget avr-*-*]
474 || [istarget hppa2.0w-hp-hpux11.23]
475 || [istarget hppa64-hp-hpux11.23] } {
481 # Return 1 if according to target_info struct and explicit target list
482 # target is supposed to keep null pointer checks. This could be due to
483 # use of option fno-delete-null-pointer-checks or hardwired in target.
485 proc check_effective_target_keeps_null_pointer_checks { } {
486 if [target_info exists keeps_null_pointer_checks] {
489 if { [istarget avr-*-*] } {
495 # Return true if profiling is supported on the target.
497 proc check_profiling_available { test_what } {
498 global profiling_available_saved
500 verbose "Profiling argument is <$test_what>" 1
502 # These conditions depend on the argument so examine them before
503 # looking at the cache variable.
505 # Support for -p on solaris2 relies on mcrt1.o which comes with the
506 # vendor compiler. We cannot reliably predict the directory where the
507 # vendor compiler (and thus mcrt1.o) is installed so we can't
508 # necessarily find mcrt1.o even if we have it.
509 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
513 # Support for -p on irix relies on libprof1.a which doesn't appear to
514 # exist on any irix6 system currently posting testsuite results.
515 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
516 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
517 if { [istarget mips*-*-irix*]
518 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
522 # We don't yet support profiling for MIPS16.
523 if { [istarget mips*-*-*]
524 && ![check_effective_target_nomips16]
525 && ([lindex $test_what 1] == "-p"
526 || [lindex $test_what 1] == "-pg") } {
530 # MinGW does not support -p.
531 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
535 # cygwin does not support -p.
536 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
540 # uClibc does not have gcrt1.o.
541 if { [check_effective_target_uclibc]
542 && ([lindex $test_what 1] == "-p"
543 || [lindex $test_what 1] == "-pg") } {
547 # Now examine the cache variable.
548 if {![info exists profiling_available_saved]} {
549 # Some targets don't have any implementation of __bb_init_func or are
550 # missing other needed machinery.
551 if { [istarget mmix-*-*]
552 || [istarget arm*-*-eabi*]
553 || [istarget picochip-*-*]
554 || [istarget *-*-netware*]
555 || [istarget arm*-*-elf]
556 || [istarget arm*-*-symbianelf*]
557 || [istarget avr-*-*]
558 || [istarget bfin-*-*]
559 || [istarget powerpc-*-eabi*]
560 || [istarget powerpc-*-elf]
561 || [istarget cris-*-*]
562 || [istarget crisv32-*-*]
563 || [istarget fido-*-elf]
564 || [istarget h8300-*-*]
565 || [istarget lm32-*-*]
566 || [istarget m32c-*-elf]
567 || [istarget m68k-*-elf]
568 || [istarget m68k-*-uclinux*]
569 || [istarget mep-*-elf]
570 || [istarget mips*-*-elf*]
571 || [istarget moxie-*-elf*]
573 || [istarget xstormy16-*]
574 || [istarget xtensa*-*-elf]
575 || [istarget *-*-rtems*]
576 || [istarget *-*-vxworks*] } {
577 set profiling_available_saved 0
579 set profiling_available_saved 1
583 return $profiling_available_saved
586 # Check to see if a target is "freestanding". This is as per the definition
587 # in Section 4 of C99 standard. Effectively, it is a target which supports no
588 # extra headers or libraries other than what is considered essential.
589 proc check_effective_target_freestanding { } {
590 if { [istarget picochip-*-*] } then {
597 # Return 1 if target has packed layout of structure members by
598 # default, 0 otherwise. Note that this is slightly different than
599 # whether the target has "natural alignment": both attributes may be
602 proc check_effective_target_default_packed { } {
603 return [check_no_compiler_messages default_packed assembly {
604 struct x { char a; long b; } c;
605 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
609 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
610 # documentation, where the test also comes from.
612 proc check_effective_target_pcc_bitfield_type_matters { } {
613 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
614 # bitfields, but let's stick to the example code from the docs.
615 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
616 struct foo1 { char x; char :0; char y; };
617 struct foo2 { char x; int :0; char y; };
618 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
622 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
624 proc add_options_for_tls { flags } {
625 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
626 # libthread, so always pass -pthread for native TLS.
627 # Need to duplicate native TLS check from
628 # check_effective_target_tls_native to avoid recursion.
629 if { [istarget *-*-solaris2.\[89\]*] &&
630 [check_no_messages_and_pattern tls_native "!emutls" assembly {
632 int f (void) { return i; }
633 void g (int j) { i = j; }
635 return "$flags -pthread"
640 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
642 proc check_effective_target_tls {} {
643 return [check_no_compiler_messages tls assembly {
645 int f (void) { return i; }
646 void g (int j) { i = j; }
650 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
652 proc check_effective_target_tls_native {} {
653 # VxWorks uses emulated TLS machinery, but with non-standard helper
654 # functions, so we fail to automatically detect it.
655 global target_triplet
656 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
660 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
662 int f (void) { return i; }
663 void g (int j) { i = j; }
667 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
669 proc check_effective_target_tls_emulated {} {
670 # VxWorks uses emulated TLS machinery, but with non-standard helper
671 # functions, so we fail to automatically detect it.
672 global target_triplet
673 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
677 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
679 int f (void) { return i; }
680 void g (int j) { i = j; }
684 # Return 1 if TLS executables can run correctly, 0 otherwise.
686 proc check_effective_target_tls_runtime {} {
687 return [check_runtime tls_runtime {
688 __thread int thr = 0;
689 int main (void) { return thr; }
693 # Return 1 if -ffunction-sections is supported, 0 otherwise.
695 proc check_effective_target_function_sections {} {
696 # Darwin has its own scheme and silently accepts -ffunction-sections.
697 global target_triplet
698 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
702 return [check_no_compiler_messages functionsections assembly {
704 } "-ffunction-sections"]
707 # Return 1 if compilation with -fgraphite is error-free for trivial
710 proc check_effective_target_fgraphite {} {
711 return [check_no_compiler_messages fgraphite object {
716 # Return 1 if compilation with -fopenmp is error-free for trivial
719 proc check_effective_target_fopenmp {} {
720 return [check_no_compiler_messages fopenmp object {
725 # Return 1 if compilation with -pthread is error-free for trivial
728 proc check_effective_target_pthread {} {
729 return [check_no_compiler_messages pthread object {
734 # Return 1 if compilation with -mpe-aligned-commons is error-free
735 # for trivial code, 0 otherwise.
737 proc check_effective_target_pe_aligned_commons {} {
738 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
739 return [check_no_compiler_messages pe_aligned_commons object {
741 } "-mpe-aligned-commons"]
746 # Return 1 if the target supports -static
747 proc check_effective_target_static {} {
748 return [check_no_compiler_messages static executable {
749 int main (void) { return 0; }
753 # Return 1 if the target supports -fstack-protector
754 proc check_effective_target_fstack_protector {} {
755 return [check_runtime fstack_protector {
756 int main (void) { return 0; }
757 } "-fstack-protector"]
760 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
761 # for trivial code, 0 otherwise.
763 proc check_effective_target_freorder {} {
764 return [check_no_compiler_messages freorder object {
766 } "-freorder-blocks-and-partition"]
769 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
770 # emitted, 0 otherwise. Whether a shared library can actually be built is
771 # out of scope for this test.
773 proc check_effective_target_fpic { } {
774 # Note that M68K has a multilib that supports -fpic but not
775 # -fPIC, so we need to check both. We test with a program that
776 # requires GOT references.
777 foreach arg {fpic fPIC} {
778 if [check_no_compiler_messages $arg object {
779 extern int foo (void); extern int bar;
780 int baz (void) { return foo () + bar; }
788 # Return true if the target supports -mpaired-single (as used on MIPS).
790 proc check_effective_target_mpaired_single { } {
791 return [check_no_compiler_messages mpaired_single object {
796 # Return true if the target has access to FPU instructions.
798 proc check_effective_target_hard_float { } {
799 if { [istarget mips*-*-*] } {
800 return [check_no_compiler_messages hard_float assembly {
801 #if (defined __mips_soft_float || defined __mips16)
807 # This proc is actually checking the availabilty of FPU
808 # support for doubles, so on the RX we must fail if the
809 # 64-bit double multilib has been selected.
810 if { [istarget rx-*-*] } {
812 # return [check_no_compiler_messages hard_float assembly {
813 #if defined __RX_64_BIT_DOUBLES__
819 # The generic test equates hard_float with "no call for adding doubles".
820 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
821 double a (double b, double c) { return b + c; }
825 # Return true if the target is a 64-bit MIPS target.
827 proc check_effective_target_mips64 { } {
828 return [check_no_compiler_messages mips64 assembly {
835 # Return true if the target is a MIPS target that does not produce
838 proc check_effective_target_nomips16 { } {
839 return [check_no_compiler_messages nomips16 object {
843 /* A cheap way of testing for -mflip-mips16. */
844 void foo (void) { asm ("addiu $20,$20,1"); }
845 void bar (void) { asm ("addiu $20,$20,1"); }
850 # Add the options needed for MIPS16 function attributes. At the moment,
851 # we don't support MIPS16 PIC.
853 proc add_options_for_mips16_attribute { flags } {
854 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
857 # Return true if we can force a mode that allows MIPS16 code generation.
858 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
861 proc check_effective_target_mips16_attribute { } {
862 return [check_no_compiler_messages mips16_attribute assembly {
866 #if defined __mips_hard_float \
867 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
868 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
871 } [add_options_for_mips16_attribute ""]]
874 # Return 1 if the target supports long double larger than double when
875 # using the new ABI, 0 otherwise.
877 proc check_effective_target_mips_newabi_large_long_double { } {
878 return [check_no_compiler_messages mips_newabi_large_long_double object {
879 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
883 # Return 1 if the current multilib does not generate PIC by default.
885 proc check_effective_target_nonpic { } {
886 return [check_no_compiler_messages nonpic assembly {
893 # Return 1 if the target does not use a status wrapper.
895 proc check_effective_target_unwrapped { } {
896 if { [target_info needs_status_wrapper] != "" \
897 && [target_info needs_status_wrapper] != "0" } {
903 # Return true if iconv is supported on the target. In particular IBM1047.
905 proc check_iconv_available { test_what } {
908 # If the tool configuration file has not set libiconv, try "-liconv"
909 if { ![info exists libiconv] } {
910 set libiconv "-liconv"
912 set test_what [lindex $test_what 1]
913 return [check_runtime_nocache $test_what [subst {
919 cd = iconv_open ("$test_what", "UTF-8");
920 if (cd == (iconv_t) -1)
927 # Return true if named sections are supported on this target.
929 proc check_named_sections_available { } {
930 return [check_no_compiler_messages named_sections assembly {
931 int __attribute__ ((section("whatever"))) foo;
935 # Return 1 if the target supports Fortran real kinds larger than real(8),
938 # When the target name changes, replace the cached result.
940 proc check_effective_target_fortran_large_real { } {
941 return [check_no_compiler_messages fortran_large_real executable {
943 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
950 # Return 1 if the target supports Fortran integer kinds larger than
951 # integer(8), 0 otherwise.
953 # When the target name changes, replace the cached result.
955 proc check_effective_target_fortran_large_int { } {
956 return [check_no_compiler_messages fortran_large_int executable {
958 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
964 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
966 # When the target name changes, replace the cached result.
968 proc check_effective_target_fortran_integer_16 { } {
969 return [check_no_compiler_messages fortran_integer_16 executable {
976 # Return 1 if we can statically link libgfortran, 0 otherwise.
978 # When the target name changes, replace the cached result.
980 proc check_effective_target_static_libgfortran { } {
981 return [check_no_compiler_messages static_libgfortran executable {
988 proc check_linker_plugin_available { } {
989 return [check_no_compiler_messages_nocache linker_plugin executable {
990 int main() { return 0; }
991 } "-flto -fuse-linker-plugin"]
994 # Return 1 if the target supports executing 750CL paired-single instructions, 0
995 # otherwise. Cache the result.
997 proc check_750cl_hw_available { } {
998 return [check_cached_effective_target 750cl_hw_available {
999 # If this is not the right target then we can skip the test.
1000 if { ![istarget powerpc-*paired*] } {
1003 check_runtime_nocache 750cl_hw_available {
1007 asm volatile ("ps_mul v0,v0,v0");
1009 asm volatile ("ps_mul 0,0,0");
1018 # Return 1 if the target OS supports running SSE executables, 0
1019 # otherwise. Cache the result.
1021 proc check_sse_os_support_available { } {
1022 return [check_cached_effective_target sse_os_support_available {
1023 # If this is not the right target then we can skip the test.
1024 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1026 } elseif { [istarget i?86-*-solaris2*] } {
1027 # The Solaris 2 kernel doesn't save and restore SSE registers
1028 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1029 check_runtime_nocache sse_os_support_available {
1032 __asm__ volatile ("movss %xmm2,%xmm1");
1042 # Return 1 if the target supports executing SSE instructions, 0
1043 # otherwise. Cache the result.
1045 proc check_sse_hw_available { } {
1046 return [check_cached_effective_target sse_hw_available {
1047 # If this is not the right target then we can skip the test.
1048 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1051 check_runtime_nocache sse_hw_available {
1055 unsigned int eax, ebx, ecx, edx;
1056 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1057 return !(edx & bit_SSE);
1065 # Return 1 if the target supports executing SSE2 instructions, 0
1066 # otherwise. Cache the result.
1068 proc check_sse2_hw_available { } {
1069 return [check_cached_effective_target sse2_hw_available {
1070 # If this is not the right target then we can skip the test.
1071 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1074 check_runtime_nocache sse2_hw_available {
1078 unsigned int eax, ebx, ecx, edx;
1079 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1080 return !(edx & bit_SSE2);
1088 # Return 1 if the target supports executing AVX instructions, 0
1089 # otherwise. Cache the result.
1091 proc check_avx_hw_available { } {
1092 return [check_cached_effective_target avx_hw_available {
1093 # If this is not the right target then we can skip the test.
1094 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1097 check_runtime_nocache avx_hw_available {
1101 unsigned int eax, ebx, ecx, edx;
1102 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1103 return ((ecx & (bit_AVX | bit_OSXSAVE))
1104 != (bit_AVX | bit_OSXSAVE));
1112 # Return 1 if the target supports running SSE executables, 0 otherwise.
1114 proc check_effective_target_sse_runtime { } {
1115 if { [check_effective_target_sse]
1116 && [check_sse_hw_available]
1117 && [check_sse_os_support_available] } {
1123 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1125 proc check_effective_target_sse2_runtime { } {
1126 if { [check_effective_target_sse2]
1127 && [check_sse2_hw_available]
1128 && [check_sse_os_support_available] } {
1134 # Return 1 if the target supports running AVX executables, 0 otherwise.
1136 proc check_effective_target_avx_runtime { } {
1137 if { [check_effective_target_avx]
1138 && [check_avx_hw_available] } {
1144 # Return 1 if the target supports executing VSX instructions, 0
1145 # otherwise. Cache the result.
1147 proc check_vsx_hw_available { } {
1148 return [check_cached_effective_target vsx_hw_available {
1149 # Some simulators are known to not support VSX instructions.
1150 # For now, disable on Darwin
1151 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1155 check_runtime_nocache vsx_hw_available {
1159 asm volatile ("xxlor vs0,vs0,vs0");
1161 asm volatile ("xxlor 0,0,0");
1170 # Return 1 if the target supports executing AltiVec instructions, 0
1171 # otherwise. Cache the result.
1173 proc check_vmx_hw_available { } {
1174 return [check_cached_effective_target vmx_hw_available {
1175 # Some simulators are known to not support VMX instructions.
1176 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1179 # Most targets don't require special flags for this test case, but
1180 # Darwin does. Just to be sure, make sure VSX is not enabled for
1181 # the altivec tests.
1182 if { [istarget *-*-darwin*]
1183 || [istarget *-*-aix*] } {
1184 set options "-maltivec -mno-vsx"
1186 set options "-mno-vsx"
1188 check_runtime_nocache vmx_hw_available {
1192 asm volatile ("vor v0,v0,v0");
1194 asm volatile ("vor 0,0,0");
1203 proc check_ppc_recip_hw_available { } {
1204 return [check_cached_effective_target ppc_recip_hw_available {
1205 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1206 # For now, disable on Darwin
1207 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1210 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1211 check_runtime_nocache ppc_recip_hw_available {
1212 volatile double d_recip, d_rsqrt, d_four = 4.0;
1213 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1216 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1217 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1218 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1219 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1227 # Return 1 if the target supports executing AltiVec and Cell PPU
1228 # instructions, 0 otherwise. Cache the result.
1230 proc check_effective_target_cell_hw { } {
1231 return [check_cached_effective_target cell_hw_available {
1232 # Some simulators are known to not support VMX and PPU instructions.
1233 if { [istarget powerpc-*-eabi*] } {
1236 # Most targets don't require special flags for this test
1237 # case, but Darwin and AIX do.
1238 if { [istarget *-*-darwin*]
1239 || [istarget *-*-aix*] } {
1240 set options "-maltivec -mcpu=cell"
1242 set options "-mcpu=cell"
1244 check_runtime_nocache cell_hw_available {
1248 asm volatile ("vor v0,v0,v0");
1249 asm volatile ("lvlx v0,r0,r0");
1251 asm volatile ("vor 0,0,0");
1252 asm volatile ("lvlx 0,0,0");
1261 # Return 1 if the target supports executing 64-bit instructions, 0
1262 # otherwise. Cache the result.
1264 proc check_effective_target_powerpc64 { } {
1265 global powerpc64_available_saved
1268 if [info exists powerpc64_available_saved] {
1269 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1271 set powerpc64_available_saved 0
1273 # Some simulators are known to not support powerpc64 instructions.
1274 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1275 verbose "check_effective_target_powerpc64 returning 0" 2
1276 return $powerpc64_available_saved
1279 # Set up, compile, and execute a test program containing a 64-bit
1280 # instruction. Include the current process ID in the file
1281 # names to prevent conflicts with invocations for multiple
1286 set f [open $src "w"]
1287 puts $f "int main() {"
1288 puts $f "#ifdef __MACH__"
1289 puts $f " asm volatile (\"extsw r0,r0\");"
1291 puts $f " asm volatile (\"extsw 0,0\");"
1293 puts $f " return 0; }"
1296 set opts "additional_flags=-mcpu=G5"
1298 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1299 set lines [${tool}_target_compile $src $exe executable "$opts"]
1302 if [string match "" $lines] then {
1303 # No error message, compilation succeeded.
1304 set result [${tool}_load "./$exe" "" ""]
1305 set status [lindex $result 0]
1306 remote_file build delete $exe
1307 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1309 if { $status == "pass" } then {
1310 set powerpc64_available_saved 1
1313 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1317 return $powerpc64_available_saved
1320 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1321 # complex float arguments. This affects gfortran tests that call cabsf
1322 # in libm built by an earlier compiler. Return 1 if libm uses the same
1323 # argument passing as the compiler under test, 0 otherwise.
1325 # When the target name changes, replace the cached result.
1327 proc check_effective_target_broken_cplxf_arg { } {
1328 return [check_cached_effective_target broken_cplxf_arg {
1329 # Skip the work for targets known not to be affected.
1330 if { ![istarget powerpc64-*-linux*] } {
1332 } elseif { ![is-effective-target lp64] } {
1335 check_runtime_nocache broken_cplxf_arg {
1336 #include <complex.h>
1337 extern void abort (void);
1338 float fabsf (float);
1339 float cabsf (_Complex float);
1346 if (fabsf (f - 5.0) > 0.0001)
1355 proc check_alpha_max_hw_available { } {
1356 return [check_runtime alpha_max_hw_available {
1357 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1361 # Returns true iff the FUNCTION is available on the target system.
1362 # (This is essentially a Tcl implementation of Autoconf's
1365 proc check_function_available { function } {
1366 return [check_no_compiler_messages ${function}_available \
1372 int main () { $function (); }
1376 # Returns true iff "fork" is available on the target system.
1378 proc check_fork_available {} {
1379 return [check_function_available "fork"]
1382 # Returns true iff "mkfifo" is available on the target system.
1384 proc check_mkfifo_available {} {
1385 if {[istarget *-*-cygwin*]} {
1386 # Cygwin has mkfifo, but support is incomplete.
1390 return [check_function_available "mkfifo"]
1393 # Returns true iff "__cxa_atexit" is used on the target system.
1395 proc check_cxa_atexit_available { } {
1396 return [check_cached_effective_target cxa_atexit_available {
1397 if { [istarget "hppa*-*-hpux10*"] } {
1398 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1400 } elseif { [istarget "*-*-vxworks"] } {
1401 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1404 check_runtime_nocache cxa_atexit_available {
1407 static unsigned int count;
1424 Y() { f(); count = 2; }
1433 int main() { return 0; }
1439 proc check_effective_target_objc2 { } {
1440 return [check_no_compiler_messages objc2 object {
1449 proc check_effective_target_next_runtime { } {
1450 return [check_no_compiler_messages objc2 object {
1451 #ifdef __NEXT_RUNTIME__
1459 # Return 1 if we're generating 32-bit code using default options, 0
1462 proc check_effective_target_ilp32 { } {
1463 return [check_no_compiler_messages ilp32 object {
1464 int dummy[sizeof (int) == 4
1465 && sizeof (void *) == 4
1466 && sizeof (long) == 4 ? 1 : -1];
1470 # Return 1 if we're generating 32-bit or larger integers using default
1471 # options, 0 otherwise.
1473 proc check_effective_target_int32plus { } {
1474 return [check_no_compiler_messages int32plus object {
1475 int dummy[sizeof (int) >= 4 ? 1 : -1];
1479 # Return 1 if we're generating 32-bit or larger pointers using default
1480 # options, 0 otherwise.
1482 proc check_effective_target_ptr32plus { } {
1483 return [check_no_compiler_messages ptr32plus object {
1484 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1488 # Return 1 if we support 32-bit or larger array and structure sizes
1489 # using default options, 0 otherwise.
1491 proc check_effective_target_size32plus { } {
1492 return [check_no_compiler_messages size32plus object {
1497 # Returns 1 if we're generating 16-bit or smaller integers with the
1498 # default options, 0 otherwise.
1500 proc check_effective_target_int16 { } {
1501 return [check_no_compiler_messages int16 object {
1502 int dummy[sizeof (int) < 4 ? 1 : -1];
1506 # Return 1 if we're generating 64-bit code using default options, 0
1509 proc check_effective_target_lp64 { } {
1510 return [check_no_compiler_messages lp64 object {
1511 int dummy[sizeof (int) == 4
1512 && sizeof (void *) == 8
1513 && sizeof (long) == 8 ? 1 : -1];
1517 # Return 1 if we're generating 64-bit code using default llp64 options,
1520 proc check_effective_target_llp64 { } {
1521 return [check_no_compiler_messages llp64 object {
1522 int dummy[sizeof (int) == 4
1523 && sizeof (void *) == 8
1524 && sizeof (long long) == 8
1525 && sizeof (long) == 4 ? 1 : -1];
1529 # Return 1 if the target supports long double larger than double,
1532 proc check_effective_target_large_long_double { } {
1533 return [check_no_compiler_messages large_long_double object {
1534 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1538 # Return 1 if the target supports double larger than float,
1541 proc check_effective_target_large_double { } {
1542 return [check_no_compiler_messages large_double object {
1543 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1547 # Return 1 if the target supports double of 64 bits,
1550 proc check_effective_target_double64 { } {
1551 return [check_no_compiler_messages double64 object {
1552 int dummy[sizeof(double) == 8 ? 1 : -1];
1556 # Return 1 if the target supports double of at least 64 bits,
1559 proc check_effective_target_double64plus { } {
1560 return [check_no_compiler_messages double64plus object {
1561 int dummy[sizeof(double) >= 8 ? 1 : -1];
1565 # Return 1 if the target supports compiling fixed-point,
1568 proc check_effective_target_fixed_point { } {
1569 return [check_no_compiler_messages fixed_point object {
1570 _Sat _Fract x; _Sat _Accum y;
1574 # Return 1 if the target supports compiling decimal floating point,
1577 proc check_effective_target_dfp_nocache { } {
1578 verbose "check_effective_target_dfp_nocache: compiling source" 2
1579 set ret [check_no_compiler_messages_nocache dfp object {
1580 float x __attribute__((mode(DD)));
1582 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1586 proc check_effective_target_dfprt_nocache { } {
1587 return [check_runtime_nocache dfprt {
1588 typedef float d64 __attribute__((mode(DD)));
1589 d64 x = 1.2df, y = 2.3dd, z;
1590 int main () { z = x + y; return 0; }
1594 # Return 1 if the target supports compiling Decimal Floating Point,
1597 # This won't change for different subtargets so cache the result.
1599 proc check_effective_target_dfp { } {
1600 return [check_cached_effective_target dfp {
1601 check_effective_target_dfp_nocache
1605 # Return 1 if the target supports linking and executing Decimal Floating
1606 # Point, 0 otherwise.
1608 # This won't change for different subtargets so cache the result.
1610 proc check_effective_target_dfprt { } {
1611 return [check_cached_effective_target dfprt {
1612 check_effective_target_dfprt_nocache
1616 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1618 proc check_effective_target_ucn_nocache { } {
1619 # -std=c99 is only valid for C
1620 if [check_effective_target_c] {
1621 set ucnopts "-std=c99"
1623 append ucnopts " -fextended-identifiers"
1624 verbose "check_effective_target_ucn_nocache: compiling source" 2
1625 set ret [check_no_compiler_messages_nocache ucn object {
1628 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1632 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1634 # This won't change for different subtargets, so cache the result.
1636 proc check_effective_target_ucn { } {
1637 return [check_cached_effective_target ucn {
1638 check_effective_target_ucn_nocache
1642 # Return 1 if the target needs a command line argument to enable a SIMD
1645 proc check_effective_target_vect_cmdline_needed { } {
1646 global et_vect_cmdline_needed_saved
1647 global et_vect_cmdline_needed_target_name
1649 if { ![info exists et_vect_cmdline_needed_target_name] } {
1650 set et_vect_cmdline_needed_target_name ""
1653 # If the target has changed since we set the cached value, clear it.
1654 set current_target [current_target_name]
1655 if { $current_target != $et_vect_cmdline_needed_target_name } {
1656 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1657 set et_vect_cmdline_needed_target_name $current_target
1658 if { [info exists et_vect_cmdline_needed_saved] } {
1659 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1660 unset et_vect_cmdline_needed_saved
1664 if [info exists et_vect_cmdline_needed_saved] {
1665 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1667 set et_vect_cmdline_needed_saved 1
1668 if { [istarget alpha*-*-*]
1669 || [istarget ia64-*-*]
1670 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1671 && [check_effective_target_lp64])
1672 || ([istarget powerpc*-*-*]
1673 && ([check_effective_target_powerpc_spe]
1674 || [check_effective_target_powerpc_altivec]))
1675 || [istarget spu-*-*]
1676 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1677 set et_vect_cmdline_needed_saved 0
1681 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1682 return $et_vect_cmdline_needed_saved
1685 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1687 # This won't change for different subtargets so cache the result.
1689 proc check_effective_target_vect_int { } {
1690 global et_vect_int_saved
1692 if [info exists et_vect_int_saved] {
1693 verbose "check_effective_target_vect_int: using cached result" 2
1695 set et_vect_int_saved 0
1696 if { [istarget i?86-*-*]
1697 || ([istarget powerpc*-*-*]
1698 && ![istarget powerpc-*-linux*paired*])
1699 || [istarget spu-*-*]
1700 || [istarget x86_64-*-*]
1701 || [istarget sparc*-*-*]
1702 || [istarget alpha*-*-*]
1703 || [istarget ia64-*-*]
1704 || [check_effective_target_arm32]
1705 || ([istarget mips*-*-*]
1706 && [check_effective_target_mips_loongson]) } {
1707 set et_vect_int_saved 1
1711 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1712 return $et_vect_int_saved
1715 # Return 1 if the target supports signed int->float conversion
1718 proc check_effective_target_vect_intfloat_cvt { } {
1719 global et_vect_intfloat_cvt_saved
1721 if [info exists et_vect_intfloat_cvt_saved] {
1722 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1724 set et_vect_intfloat_cvt_saved 0
1725 if { [istarget i?86-*-*]
1726 || ([istarget powerpc*-*-*]
1727 && ![istarget powerpc-*-linux*paired*])
1728 || [istarget x86_64-*-*] } {
1729 set et_vect_intfloat_cvt_saved 1
1733 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1734 return $et_vect_intfloat_cvt_saved
1737 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1739 proc check_effective_target_int128 { } {
1740 return [check_no_compiler_messages int128 object {
1742 #ifndef __SIZEOF_INT128__
1751 # Return 1 if the target supports unsigned int->float conversion
1754 proc check_effective_target_vect_uintfloat_cvt { } {
1755 global et_vect_uintfloat_cvt_saved
1757 if [info exists et_vect_uintfloat_cvt_saved] {
1758 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1760 set et_vect_uintfloat_cvt_saved 0
1761 if { [istarget i?86-*-*]
1762 || ([istarget powerpc*-*-*]
1763 && ![istarget powerpc-*-linux*paired*])
1764 || [istarget x86_64-*-*] } {
1765 set et_vect_uintfloat_cvt_saved 1
1769 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1770 return $et_vect_uintfloat_cvt_saved
1774 # Return 1 if the target supports signed float->int conversion
1777 proc check_effective_target_vect_floatint_cvt { } {
1778 global et_vect_floatint_cvt_saved
1780 if [info exists et_vect_floatint_cvt_saved] {
1781 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1783 set et_vect_floatint_cvt_saved 0
1784 if { [istarget i?86-*-*]
1785 || ([istarget powerpc*-*-*]
1786 && ![istarget powerpc-*-linux*paired*])
1787 || [istarget x86_64-*-*] } {
1788 set et_vect_floatint_cvt_saved 1
1792 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1793 return $et_vect_floatint_cvt_saved
1796 # Return 1 if the target supports unsigned float->int conversion
1799 proc check_effective_target_vect_floatuint_cvt { } {
1800 global et_vect_floatuint_cvt_saved
1802 if [info exists et_vect_floatuint_cvt_saved] {
1803 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1805 set et_vect_floatuint_cvt_saved 0
1806 if { ([istarget powerpc*-*-*]
1807 && ![istarget powerpc-*-linux*paired*]) } {
1808 set et_vect_floatuint_cvt_saved 1
1812 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1813 return $et_vect_floatuint_cvt_saved
1816 # Return 1 is this is an arm target using 32-bit instructions
1817 proc check_effective_target_arm32 { } {
1818 return [check_no_compiler_messages arm32 assembly {
1819 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1825 # Return 1 if this is an ARM target supporting -mfpu=vfp
1826 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1829 proc check_effective_target_arm_vfp_ok { } {
1830 if { [check_effective_target_arm32] } {
1831 return [check_no_compiler_messages arm_vfp_ok object {
1833 } "-mfpu=vfp -mfloat-abi=softfp"]
1839 # Return 1 if this is an ARM target supporting -mfpu=vfp
1840 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1843 proc check_effective_target_arm_hard_vfp_ok { } {
1844 if { [check_effective_target_arm32] } {
1845 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1846 int main() { return 0;}
1847 } "-mfpu=vfp -mfloat-abi=hard"]
1853 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1854 # or -mfloat-abi=hard, but if one is already specified by the
1855 # multilib, use it. Similarly, if a -mfpu option already enables
1856 # NEON, do not add -mfpu=neon.
1858 proc add_options_for_arm_neon { flags } {
1859 if { ! [check_effective_target_arm_neon_ok] } {
1862 global et_arm_neon_flags
1863 return "$flags $et_arm_neon_flags"
1866 # Return 1 if this is an ARM target supporting -mfpu=neon
1867 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1868 # incompatible with these options. Also set et_arm_neon_flags to the
1869 # best options to add.
1871 proc check_effective_target_arm_neon_ok_nocache { } {
1872 global et_arm_neon_flags
1873 set et_arm_neon_flags ""
1874 if { [check_effective_target_arm32] } {
1875 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1876 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1877 #include "arm_neon.h"
1880 set et_arm_neon_flags $flags
1889 proc check_effective_target_arm_neon_ok { } {
1890 return [check_cached_effective_target arm_neon_ok \
1891 check_effective_target_arm_neon_ok_nocache]
1894 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1895 # or -mfloat-abi=hard, but if one is already specified by the
1898 proc add_options_for_arm_neon_fp16 { flags } {
1899 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1902 global et_arm_neon_fp16_flags
1903 return "$flags $et_arm_neon_fp16_flags"
1906 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1907 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1908 # incompatible with these options. Also set et_arm_neon_flags to the
1909 # best options to add.
1911 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1912 global et_arm_neon_fp16_flags
1913 set et_arm_neon_fp16_flags ""
1914 if { [check_effective_target_arm32] } {
1915 # Always add -mfpu=neon-fp16, since there is no preprocessor
1916 # macro for FP16 support.
1917 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1918 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1919 #include "arm_neon.h"
1922 set et_arm_neon_fp16_flags $flags
1931 proc check_effective_target_arm_neon_fp16_ok { } {
1932 return [check_cached_effective_target arm_neon_fp16_ok \
1933 check_effective_target_arm_neon_fp16_ok_nocache]
1936 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1939 proc check_effective_target_arm_thumb1_ok { } {
1940 return [check_no_compiler_messages arm_thumb1_ok assembly {
1941 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1947 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1950 proc check_effective_target_arm_thumb2_ok { } {
1951 return [check_no_compiler_messages arm_thumb2_ok assembly {
1952 #if !defined(__thumb2__)
1958 # Return 1 if the target supports executing NEON instructions, 0
1959 # otherwise. Cache the result.
1961 proc check_effective_target_arm_neon_hw { } {
1962 return [check_runtime arm_neon_hw_available {
1966 long long a = 0, b = 1;
1967 asm ("vorr %P0, %P1, %P2"
1969 : "0" (a), "w" (b));
1972 } [add_options_for_arm_neon ""]]
1975 # Return 1 if this is a ARM target with NEON enabled.
1977 proc check_effective_target_arm_neon { } {
1978 if { [check_effective_target_arm32] } {
1979 return [check_no_compiler_messages arm_neon object {
1980 #ifndef __ARM_NEON__
1991 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1992 # the Loongson vector modes.
1994 proc check_effective_target_mips_loongson { } {
1995 return [check_no_compiler_messages loongson assembly {
1996 #if !defined(__mips_loongson_vector_rev)
2002 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2005 proc check_effective_target_arm_eabi { } {
2006 return [check_no_compiler_messages arm_eabi object {
2007 #ifndef __ARM_EABI__
2015 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2016 # Some multilibs may be incompatible with this option.
2018 proc check_effective_target_arm_iwmmxt_ok { } {
2019 if { [check_effective_target_arm32] } {
2020 return [check_no_compiler_messages arm_iwmmxt_ok object {
2028 # Return 1 if this is a PowerPC target with floating-point registers.
2030 proc check_effective_target_powerpc_fprs { } {
2031 if { [istarget powerpc*-*-*]
2032 || [istarget rs6000-*-*] } {
2033 return [check_no_compiler_messages powerpc_fprs object {
2045 # Return 1 if this is a PowerPC target with hardware double-precision
2048 proc check_effective_target_powerpc_hard_double { } {
2049 if { [istarget powerpc*-*-*]
2050 || [istarget rs6000-*-*] } {
2051 return [check_no_compiler_messages powerpc_hard_double object {
2063 # Return 1 if this is a PowerPC target supporting -maltivec.
2065 proc check_effective_target_powerpc_altivec_ok { } {
2066 if { ([istarget powerpc*-*-*]
2067 && ![istarget powerpc-*-linux*paired*])
2068 || [istarget rs6000-*-*] } {
2069 # AltiVec is not supported on AIX before 5.3.
2070 if { [istarget powerpc*-*-aix4*]
2071 || [istarget powerpc*-*-aix5.1*]
2072 || [istarget powerpc*-*-aix5.2*] } {
2075 return [check_no_compiler_messages powerpc_altivec_ok object {
2083 # Return 1 if this is a PowerPC target supporting -mvsx
2085 proc check_effective_target_powerpc_vsx_ok { } {
2086 if { ([istarget powerpc*-*-*]
2087 && ![istarget powerpc-*-linux*paired*])
2088 || [istarget rs6000-*-*] } {
2089 # AltiVec is not supported on AIX before 5.3.
2090 if { [istarget powerpc*-*-aix4*]
2091 || [istarget powerpc*-*-aix5.1*]
2092 || [istarget powerpc*-*-aix5.2*] } {
2095 return [check_no_compiler_messages powerpc_vsx_ok object {
2098 asm volatile ("xxlor vs0,vs0,vs0");
2100 asm volatile ("xxlor 0,0,0");
2110 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2112 proc check_effective_target_powerpc_ppu_ok { } {
2113 if [check_effective_target_powerpc_altivec_ok] {
2114 return [check_no_compiler_messages cell_asm_available object {
2117 asm volatile ("lvlx v0,v0,v0");
2119 asm volatile ("lvlx 0,0,0");
2129 # Return 1 if this is a PowerPC target that supports SPU.
2131 proc check_effective_target_powerpc_spu { } {
2132 if [istarget powerpc*-*-linux*] {
2133 return [check_effective_target_powerpc_altivec_ok]
2139 # Return 1 if this is a PowerPC SPE target. The check includes options
2140 # specified by dg-options for this test, so don't cache the result.
2142 proc check_effective_target_powerpc_spe_nocache { } {
2143 if { [istarget powerpc*-*-*] } {
2144 return [check_no_compiler_messages_nocache powerpc_spe object {
2150 } [current_compiler_flags]]
2156 # Return 1 if this is a PowerPC target with SPE enabled.
2158 proc check_effective_target_powerpc_spe { } {
2159 if { [istarget powerpc*-*-*] } {
2160 return [check_no_compiler_messages powerpc_spe object {
2172 # Return 1 if this is a PowerPC target with Altivec enabled.
2174 proc check_effective_target_powerpc_altivec { } {
2175 if { [istarget powerpc*-*-*] } {
2176 return [check_no_compiler_messages powerpc_altivec object {
2188 # Return 1 if this is a PowerPC 405 target. The check includes options
2189 # specified by dg-options for this test, so don't cache the result.
2191 proc check_effective_target_powerpc_405_nocache { } {
2192 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2193 return [check_no_compiler_messages_nocache powerpc_405 object {
2199 } [current_compiler_flags]]
2205 # Return 1 if this is a SPU target with a toolchain that
2206 # supports automatic overlay generation.
2208 proc check_effective_target_spu_auto_overlay { } {
2209 if { [istarget spu*-*-elf*] } {
2210 return [check_no_compiler_messages spu_auto_overlay executable {
2212 } "-Wl,--auto-overlay" ]
2218 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2219 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2220 # test environment appears to run executables on such a simulator.
2222 proc check_effective_target_ultrasparc_hw { } {
2223 return [check_runtime ultrasparc_hw {
2224 int main() { return 0; }
2225 } "-mcpu=ultrasparc"]
2228 # Return 1 if the target supports hardware vector shift operation.
2230 proc check_effective_target_vect_shift { } {
2231 global et_vect_shift_saved
2233 if [info exists et_vect_shift_saved] {
2234 verbose "check_effective_target_vect_shift: using cached result" 2
2236 set et_vect_shift_saved 0
2237 if { ([istarget powerpc*-*-*]
2238 && ![istarget powerpc-*-linux*paired*])
2239 || [istarget ia64-*-*]
2240 || [istarget i?86-*-*]
2241 || [istarget x86_64-*-*]
2242 || [check_effective_target_arm32]
2243 || ([istarget mips*-*-*]
2244 && [check_effective_target_mips_loongson]) } {
2245 set et_vect_shift_saved 1
2249 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2250 return $et_vect_shift_saved
2253 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2255 # This can change for different subtargets so do not cache the result.
2257 proc check_effective_target_vect_long { } {
2258 if { [istarget i?86-*-*]
2259 || (([istarget powerpc*-*-*]
2260 && ![istarget powerpc-*-linux*paired*])
2261 && [check_effective_target_ilp32])
2262 || [istarget x86_64-*-*]
2263 || [check_effective_target_arm32]
2264 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2270 verbose "check_effective_target_vect_long: returning $answer" 2
2274 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2276 # This won't change for different subtargets so cache the result.
2278 proc check_effective_target_vect_float { } {
2279 global et_vect_float_saved
2281 if [info exists et_vect_float_saved] {
2282 verbose "check_effective_target_vect_float: using cached result" 2
2284 set et_vect_float_saved 0
2285 if { [istarget i?86-*-*]
2286 || [istarget powerpc*-*-*]
2287 || [istarget spu-*-*]
2288 || [istarget mipsisa64*-*-*]
2289 || [istarget x86_64-*-*]
2290 || [istarget ia64-*-*]
2291 || [check_effective_target_arm32] } {
2292 set et_vect_float_saved 1
2296 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2297 return $et_vect_float_saved
2300 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2302 # This won't change for different subtargets so cache the result.
2304 proc check_effective_target_vect_double { } {
2305 global et_vect_double_saved
2307 if [info exists et_vect_double_saved] {
2308 verbose "check_effective_target_vect_double: using cached result" 2
2310 set et_vect_double_saved 0
2311 if { [istarget i?86-*-*]
2312 || [istarget x86_64-*-*] } {
2313 if { [check_no_compiler_messages vect_double assembly {
2314 #ifdef __tune_atom__
2315 # error No double vectorizer support.
2318 set et_vect_double_saved 1
2320 set et_vect_double_saved 0
2322 } elseif { [istarget spu-*-*] } {
2323 set et_vect_double_saved 1
2327 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2328 return $et_vect_double_saved
2331 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2333 # This won't change for different subtargets so cache the result.
2335 proc check_effective_target_vect_long_long { } {
2336 global et_vect_long_long_saved
2338 if [info exists et_vect_long_long_saved] {
2339 verbose "check_effective_target_vect_long_long: using cached result" 2
2341 set et_vect_long_long_saved 0
2342 if { [istarget i?86-*-*]
2343 || [istarget x86_64-*-*] } {
2344 set et_vect_long_long_saved 1
2348 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2349 return $et_vect_long_long_saved
2353 # Return 1 if the target plus current options does not support a vector
2354 # max instruction on "int", 0 otherwise.
2356 # This won't change for different subtargets so cache the result.
2358 proc check_effective_target_vect_no_int_max { } {
2359 global et_vect_no_int_max_saved
2361 if [info exists et_vect_no_int_max_saved] {
2362 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2364 set et_vect_no_int_max_saved 0
2365 if { [istarget sparc*-*-*]
2366 || [istarget spu-*-*]
2367 || [istarget alpha*-*-*]
2368 || ([istarget mips*-*-*]
2369 && [check_effective_target_mips_loongson]) } {
2370 set et_vect_no_int_max_saved 1
2373 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2374 return $et_vect_no_int_max_saved
2377 # Return 1 if the target plus current options does not support a vector
2378 # add instruction on "int", 0 otherwise.
2380 # This won't change for different subtargets so cache the result.
2382 proc check_effective_target_vect_no_int_add { } {
2383 global et_vect_no_int_add_saved
2385 if [info exists et_vect_no_int_add_saved] {
2386 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2388 set et_vect_no_int_add_saved 0
2389 # Alpha only supports vector add on V8QI and V4HI.
2390 if { [istarget alpha*-*-*] } {
2391 set et_vect_no_int_add_saved 1
2394 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2395 return $et_vect_no_int_add_saved
2398 # Return 1 if the target plus current options does not support vector
2399 # bitwise instructions, 0 otherwise.
2401 # This won't change for different subtargets so cache the result.
2403 proc check_effective_target_vect_no_bitwise { } {
2404 global et_vect_no_bitwise_saved
2406 if [info exists et_vect_no_bitwise_saved] {
2407 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2409 set et_vect_no_bitwise_saved 0
2411 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2412 return $et_vect_no_bitwise_saved
2415 # Return 1 if the target plus current options supports vector permutation,
2418 # This won't change for different subtargets so cache the result.
2420 proc check_effective_target_vect_perm { } {
2423 if [info exists et_vect_perm_saved] {
2424 verbose "check_effective_target_vect_perm: using cached result" 2
2426 set et_vect_perm_saved 0
2427 if { [istarget powerpc*-*-*]
2428 || [istarget spu-*-*]
2429 || [istarget i?86-*-*]
2430 || [istarget x86_64-*-*] } {
2431 set et_vect_perm_saved 1
2434 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2435 return $et_vect_perm_saved
2438 # Return 1 if the target plus current options supports vector permutation
2439 # on byte-sized elements, 0 otherwise.
2441 # This won't change for different subtargets so cache the result.
2443 proc check_effective_target_vect_perm_byte { } {
2444 global et_vect_perm_byte
2446 if [info exists et_vect_perm_byte_saved] {
2447 verbose "check_effective_target_vect_perm_byte: using cached result" 2
2449 set et_vect_perm_byte_saved 0
2450 if { [istarget powerpc*-*-*]
2451 || [istarget spu-*-*] } {
2452 set et_vect_perm_byte_saved 1
2455 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
2456 return $et_vect_perm_byte_saved
2459 # Return 1 if the target plus current options supports vector permutation
2460 # on short-sized elements, 0 otherwise.
2462 # This won't change for different subtargets so cache the result.
2464 proc check_effective_target_vect_perm_short { } {
2465 global et_vect_perm_short
2467 if [info exists et_vect_perm_short_saved] {
2468 verbose "check_effective_target_vect_perm_short: using cached result" 2
2470 set et_vect_perm_short_saved 0
2471 if { [istarget powerpc*-*-*]
2472 || [istarget spu-*-*] } {
2473 set et_vect_perm_short_saved 1
2476 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
2477 return $et_vect_perm_short_saved
2480 # Return 1 if the target plus current options supports a vector
2481 # widening summation of *short* args into *int* result, 0 otherwise.
2483 # This won't change for different subtargets so cache the result.
2485 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2486 global et_vect_widen_sum_hi_to_si_pattern
2488 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2489 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2491 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2492 if { [istarget powerpc*-*-*] } {
2493 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2496 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2497 return $et_vect_widen_sum_hi_to_si_pattern_saved
2500 # Return 1 if the target plus current options supports a vector
2501 # widening summation of *short* args into *int* result, 0 otherwise.
2502 # A target can also support this widening summation if it can support
2503 # promotion (unpacking) from shorts to ints.
2505 # This won't change for different subtargets so cache the result.
2507 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2508 global et_vect_widen_sum_hi_to_si
2510 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2511 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2513 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2514 if { [istarget powerpc*-*-*]
2515 || [istarget ia64-*-*] } {
2516 set et_vect_widen_sum_hi_to_si_saved 1
2519 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2520 return $et_vect_widen_sum_hi_to_si_saved
2523 # Return 1 if the target plus current options supports a vector
2524 # widening summation of *char* args into *short* result, 0 otherwise.
2525 # A target can also support this widening summation if it can support
2526 # promotion (unpacking) from chars to shorts.
2528 # This won't change for different subtargets so cache the result.
2530 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2531 global et_vect_widen_sum_qi_to_hi
2533 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2534 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2536 set et_vect_widen_sum_qi_to_hi_saved 0
2537 if { [check_effective_target_vect_unpack]
2538 || [istarget ia64-*-*] } {
2539 set et_vect_widen_sum_qi_to_hi_saved 1
2542 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2543 return $et_vect_widen_sum_qi_to_hi_saved
2546 # Return 1 if the target plus current options supports a vector
2547 # widening summation of *char* args into *int* result, 0 otherwise.
2549 # This won't change for different subtargets so cache the result.
2551 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2552 global et_vect_widen_sum_qi_to_si
2554 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2555 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2557 set et_vect_widen_sum_qi_to_si_saved 0
2558 if { [istarget powerpc*-*-*] } {
2559 set et_vect_widen_sum_qi_to_si_saved 1
2562 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2563 return $et_vect_widen_sum_qi_to_si_saved
2566 # Return 1 if the target plus current options supports a vector
2567 # widening multiplication of *char* args into *short* result, 0 otherwise.
2568 # A target can also support this widening multplication if it can support
2569 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2570 # multiplication of shorts).
2572 # This won't change for different subtargets so cache the result.
2575 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2576 global et_vect_widen_mult_qi_to_hi
2578 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2579 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2581 if { [check_effective_target_vect_unpack]
2582 && [check_effective_target_vect_short_mult] } {
2583 set et_vect_widen_mult_qi_to_hi_saved 1
2585 set et_vect_widen_mult_qi_to_hi_saved 0
2587 if { [istarget powerpc*-*-*] } {
2588 set et_vect_widen_mult_qi_to_hi_saved 1
2591 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2592 return $et_vect_widen_mult_qi_to_hi_saved
2595 # Return 1 if the target plus current options supports a vector
2596 # widening multiplication of *short* args into *int* result, 0 otherwise.
2597 # A target can also support this widening multplication if it can support
2598 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2599 # multiplication of ints).
2601 # This won't change for different subtargets so cache the result.
2604 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2605 global et_vect_widen_mult_hi_to_si
2607 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2608 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2610 if { [check_effective_target_vect_unpack]
2611 && [check_effective_target_vect_int_mult] } {
2612 set et_vect_widen_mult_hi_to_si_saved 1
2614 set et_vect_widen_mult_hi_to_si_saved 0
2616 if { [istarget powerpc*-*-*]
2617 || [istarget spu-*-*]
2618 || [istarget i?86-*-*]
2619 || [istarget x86_64-*-*] } {
2620 set et_vect_widen_mult_hi_to_si_saved 1
2623 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2624 return $et_vect_widen_mult_hi_to_si_saved
2627 # Return 1 if the target plus current options supports a vector
2628 # dot-product of signed chars, 0 otherwise.
2630 # This won't change for different subtargets so cache the result.
2632 proc check_effective_target_vect_sdot_qi { } {
2633 global et_vect_sdot_qi
2635 if [info exists et_vect_sdot_qi_saved] {
2636 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2638 set et_vect_sdot_qi_saved 0
2640 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2641 return $et_vect_sdot_qi_saved
2644 # Return 1 if the target plus current options supports a vector
2645 # dot-product of unsigned chars, 0 otherwise.
2647 # This won't change for different subtargets so cache the result.
2649 proc check_effective_target_vect_udot_qi { } {
2650 global et_vect_udot_qi
2652 if [info exists et_vect_udot_qi_saved] {
2653 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2655 set et_vect_udot_qi_saved 0
2656 if { [istarget powerpc*-*-*] } {
2657 set et_vect_udot_qi_saved 1
2660 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2661 return $et_vect_udot_qi_saved
2664 # Return 1 if the target plus current options supports a vector
2665 # dot-product of signed shorts, 0 otherwise.
2667 # This won't change for different subtargets so cache the result.
2669 proc check_effective_target_vect_sdot_hi { } {
2670 global et_vect_sdot_hi
2672 if [info exists et_vect_sdot_hi_saved] {
2673 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2675 set et_vect_sdot_hi_saved 0
2676 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2677 || [istarget i?86-*-*]
2678 || [istarget x86_64-*-*] } {
2679 set et_vect_sdot_hi_saved 1
2682 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2683 return $et_vect_sdot_hi_saved
2686 # Return 1 if the target plus current options supports a vector
2687 # dot-product of unsigned shorts, 0 otherwise.
2689 # This won't change for different subtargets so cache the result.
2691 proc check_effective_target_vect_udot_hi { } {
2692 global et_vect_udot_hi
2694 if [info exists et_vect_udot_hi_saved] {
2695 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2697 set et_vect_udot_hi_saved 0
2698 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2699 set et_vect_udot_hi_saved 1
2702 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2703 return $et_vect_udot_hi_saved
2707 # Return 1 if the target plus current options supports a vector
2708 # demotion (packing) of shorts (to chars) and ints (to shorts)
2709 # using modulo arithmetic, 0 otherwise.
2711 # This won't change for different subtargets so cache the result.
2713 proc check_effective_target_vect_pack_trunc { } {
2714 global et_vect_pack_trunc
2716 if [info exists et_vect_pack_trunc_saved] {
2717 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2719 set et_vect_pack_trunc_saved 0
2720 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2721 || [istarget i?86-*-*]
2722 || [istarget x86_64-*-*]
2723 || [istarget spu-*-*]
2724 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2725 set et_vect_pack_trunc_saved 1
2728 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2729 return $et_vect_pack_trunc_saved
2732 # Return 1 if the target plus current options supports a vector
2733 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2735 # This won't change for different subtargets so cache the result.
2737 proc check_effective_target_vect_unpack { } {
2738 global et_vect_unpack
2740 if [info exists et_vect_unpack_saved] {
2741 verbose "check_effective_target_vect_unpack: using cached result" 2
2743 set et_vect_unpack_saved 0
2744 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2745 || [istarget i?86-*-*]
2746 || [istarget x86_64-*-*]
2747 || [istarget spu-*-*]
2748 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2749 set et_vect_unpack_saved 1
2752 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2753 return $et_vect_unpack_saved
2756 # Return 1 if the target plus current options does not guarantee
2757 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2759 # This won't change for different subtargets so cache the result.
2761 proc check_effective_target_unaligned_stack { } {
2762 global et_unaligned_stack_saved
2764 if [info exists et_unaligned_stack_saved] {
2765 verbose "check_effective_target_unaligned_stack: using cached result" 2
2767 set et_unaligned_stack_saved 0
2769 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2770 return $et_unaligned_stack_saved
2773 # Return 1 if the target plus current options does not support a vector
2774 # alignment mechanism, 0 otherwise.
2776 # This won't change for different subtargets so cache the result.
2778 proc check_effective_target_vect_no_align { } {
2779 global et_vect_no_align_saved
2781 if [info exists et_vect_no_align_saved] {
2782 verbose "check_effective_target_vect_no_align: using cached result" 2
2784 set et_vect_no_align_saved 0
2785 if { [istarget mipsisa64*-*-*]
2786 || [istarget sparc*-*-*]
2787 || [istarget ia64-*-*]
2788 || [check_effective_target_arm32]
2789 || ([istarget mips*-*-*]
2790 && [check_effective_target_mips_loongson]) } {
2791 set et_vect_no_align_saved 1
2794 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2795 return $et_vect_no_align_saved
2798 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2800 # This won't change for different subtargets so cache the result.
2802 proc check_effective_target_vect_hw_misalign { } {
2803 global et_vect_hw_misalign_saved
2805 if [info exists et_vect_hw_misalign_saved] {
2806 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2808 set et_vect_hw_misalign_saved 0
2809 if { ([istarget x86_64-*-*]
2810 || [istarget i?86-*-*]) } {
2811 set et_vect_hw_misalign_saved 1
2814 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2815 return $et_vect_hw_misalign_saved
2819 # Return 1 if arrays are aligned to the vector alignment
2820 # boundary, 0 otherwise.
2822 # This won't change for different subtargets so cache the result.
2824 proc check_effective_target_vect_aligned_arrays { } {
2825 global et_vect_aligned_arrays
2827 if [info exists et_vect_aligned_arrays_saved] {
2828 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2830 set et_vect_aligned_arrays_saved 0
2831 if { (([istarget x86_64-*-*]
2832 || [istarget i?86-*-*]) && [is-effective-target lp64])
2833 || [istarget spu-*-*] } {
2834 set et_vect_aligned_arrays_saved 1
2837 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2838 return $et_vect_aligned_arrays_saved
2841 # Return 1 if types of size 32 bit or less are naturally aligned
2842 # (aligned to their type-size), 0 otherwise.
2844 # This won't change for different subtargets so cache the result.
2846 proc check_effective_target_natural_alignment_32 { } {
2847 global et_natural_alignment_32
2849 if [info exists et_natural_alignment_32_saved] {
2850 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2852 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2853 set et_natural_alignment_32_saved 1
2854 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2855 set et_natural_alignment_32_saved 0
2858 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2859 return $et_natural_alignment_32_saved
2862 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2863 # type-size), 0 otherwise.
2865 # This won't change for different subtargets so cache the result.
2867 proc check_effective_target_natural_alignment_64 { } {
2868 global et_natural_alignment_64
2870 if [info exists et_natural_alignment_64_saved] {
2871 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2873 set et_natural_alignment_64_saved 0
2874 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2875 || [istarget spu-*-*] } {
2876 set et_natural_alignment_64_saved 1
2879 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2880 return $et_natural_alignment_64_saved
2883 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2885 # This won't change for different subtargets so cache the result.
2887 proc check_effective_target_vector_alignment_reachable { } {
2888 global et_vector_alignment_reachable
2890 if [info exists et_vector_alignment_reachable_saved] {
2891 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2893 if { [check_effective_target_vect_aligned_arrays]
2894 || [check_effective_target_natural_alignment_32] } {
2895 set et_vector_alignment_reachable_saved 1
2897 set et_vector_alignment_reachable_saved 0
2900 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2901 return $et_vector_alignment_reachable_saved
2904 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2906 # This won't change for different subtargets so cache the result.
2908 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2909 global et_vector_alignment_reachable_for_64bit
2911 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2912 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2914 if { [check_effective_target_vect_aligned_arrays]
2915 || [check_effective_target_natural_alignment_64] } {
2916 set et_vector_alignment_reachable_for_64bit_saved 1
2918 set et_vector_alignment_reachable_for_64bit_saved 0
2921 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2922 return $et_vector_alignment_reachable_for_64bit_saved
2925 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2927 proc check_effective_target_vect_condition { } {
2928 global et_vect_cond_saved
2930 if [info exists et_vect_cond_saved] {
2931 verbose "check_effective_target_vect_cond: using cached result" 2
2933 set et_vect_cond_saved 0
2934 if { [istarget powerpc*-*-*]
2935 || [istarget ia64-*-*]
2936 || [istarget i?86-*-*]
2937 || [istarget spu-*-*]
2938 || [istarget x86_64-*-*] } {
2939 set et_vect_cond_saved 1
2943 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2944 return $et_vect_cond_saved
2947 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2949 proc check_effective_target_vect_char_mult { } {
2950 global et_vect_char_mult_saved
2952 if [info exists et_vect_char_mult_saved] {
2953 verbose "check_effective_target_vect_char_mult: using cached result" 2
2955 set et_vect_char_mult_saved 0
2956 if { [istarget ia64-*-*]
2957 || [istarget i?86-*-*]
2958 || [istarget x86_64-*-*] } {
2959 set et_vect_char_mult_saved 1
2963 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2964 return $et_vect_char_mult_saved
2967 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2969 proc check_effective_target_vect_short_mult { } {
2970 global et_vect_short_mult_saved
2972 if [info exists et_vect_short_mult_saved] {
2973 verbose "check_effective_target_vect_short_mult: using cached result" 2
2975 set et_vect_short_mult_saved 0
2976 if { [istarget ia64-*-*]
2977 || [istarget spu-*-*]
2978 || [istarget i?86-*-*]
2979 || [istarget x86_64-*-*]
2980 || [istarget powerpc*-*-*]
2981 || [check_effective_target_arm32]
2982 || ([istarget mips*-*-*]
2983 && [check_effective_target_mips_loongson]) } {
2984 set et_vect_short_mult_saved 1
2988 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2989 return $et_vect_short_mult_saved
2992 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2994 proc check_effective_target_vect_int_mult { } {
2995 global et_vect_int_mult_saved
2997 if [info exists et_vect_int_mult_saved] {
2998 verbose "check_effective_target_vect_int_mult: using cached result" 2
3000 set et_vect_int_mult_saved 0
3001 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3002 || [istarget spu-*-*]
3003 || [istarget i?86-*-*]
3004 || [istarget x86_64-*-*]
3005 || [check_effective_target_arm32] } {
3006 set et_vect_int_mult_saved 1
3010 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3011 return $et_vect_int_mult_saved
3014 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3016 proc check_effective_target_vect_extract_even_odd { } {
3017 global et_vect_extract_even_odd_saved
3019 if [info exists et_vect_extract_even_odd_saved] {
3020 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3022 set et_vect_extract_even_odd_saved 0
3023 if { [istarget powerpc*-*-*]
3024 || [istarget i?86-*-*]
3025 || [istarget x86_64-*-*]
3026 || [istarget spu-*-*] } {
3027 set et_vect_extract_even_odd_saved 1
3031 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3032 return $et_vect_extract_even_odd_saved
3035 # Return 1 if the target supports vector even/odd elements extraction of
3036 # vectors with SImode elements or larger, 0 otherwise.
3038 proc check_effective_target_vect_extract_even_odd_wide { } {
3039 global et_vect_extract_even_odd_wide_saved
3041 if [info exists et_vect_extract_even_odd_wide_saved] {
3042 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
3044 set et_vect_extract_even_odd_wide_saved 0
3045 if { [istarget powerpc*-*-*]
3046 || [istarget i?86-*-*]
3047 || [istarget x86_64-*-*]
3048 || [istarget spu-*-*] } {
3049 set et_vect_extract_even_odd_wide_saved 1
3053 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
3054 return $et_vect_extract_even_odd_wide_saved
3057 # Return 1 if the target supports vector interleaving, 0 otherwise.
3059 proc check_effective_target_vect_interleave { } {
3060 global et_vect_interleave_saved
3062 if [info exists et_vect_interleave_saved] {
3063 verbose "check_effective_target_vect_interleave: using cached result" 2
3065 set et_vect_interleave_saved 0
3066 if { [istarget powerpc*-*-*]
3067 || [istarget i?86-*-*]
3068 || [istarget x86_64-*-*]
3069 || [istarget spu-*-*] } {
3070 set et_vect_interleave_saved 1
3074 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3075 return $et_vect_interleave_saved
3078 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
3079 proc check_effective_target_vect_strided { } {
3080 global et_vect_strided_saved
3082 if [info exists et_vect_strided_saved] {
3083 verbose "check_effective_target_vect_strided: using cached result" 2
3085 set et_vect_strided_saved 0
3086 if { [check_effective_target_vect_interleave]
3087 && [check_effective_target_vect_extract_even_odd] } {
3088 set et_vect_strided_saved 1
3092 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
3093 return $et_vect_strided_saved
3096 # Return 1 if the target supports vector interleaving and extract even/odd
3097 # for wide element types, 0 otherwise.
3098 proc check_effective_target_vect_strided_wide { } {
3099 global et_vect_strided_wide_saved
3101 if [info exists et_vect_strided_wide_saved] {
3102 verbose "check_effective_target_vect_strided_wide: using cached result" 2
3104 set et_vect_strided_wide_saved 0
3105 if { [check_effective_target_vect_interleave]
3106 && [check_effective_target_vect_extract_even_odd_wide] } {
3107 set et_vect_strided_wide_saved 1
3111 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
3112 return $et_vect_strided_wide_saved
3115 # Return 1 if the target supports section-anchors
3117 proc check_effective_target_section_anchors { } {
3118 global et_section_anchors_saved
3120 if [info exists et_section_anchors_saved] {
3121 verbose "check_effective_target_section_anchors: using cached result" 2
3123 set et_section_anchors_saved 0
3124 if { [istarget powerpc*-*-*]
3125 || [istarget arm*-*-*] } {
3126 set et_section_anchors_saved 1
3130 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3131 return $et_section_anchors_saved
3134 # Return 1 if the target supports atomic operations on "int" and "long".
3136 proc check_effective_target_sync_int_long { } {
3137 global et_sync_int_long_saved
3139 if [info exists et_sync_int_long_saved] {
3140 verbose "check_effective_target_sync_int_long: using cached result" 2
3142 set et_sync_int_long_saved 0
3143 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3144 # load-reserved/store-conditional instructions.
3145 if { [istarget ia64-*-*]
3146 || [istarget i?86-*-*]
3147 || [istarget x86_64-*-*]
3148 || [istarget alpha*-*-*]
3149 || [istarget arm*-*-linux-gnueabi]
3150 || [istarget bfin*-*linux*]
3151 || [istarget hppa*-*linux*]
3152 || [istarget s390*-*-*]
3153 || [istarget powerpc*-*-*]
3154 || [istarget sparc64-*-*]
3155 || [istarget sparcv9-*-*]
3156 || [istarget mips*-*-*] } {
3157 set et_sync_int_long_saved 1
3161 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3162 return $et_sync_int_long_saved
3165 # Return 1 if the target supports atomic operations on "char" and "short".
3167 proc check_effective_target_sync_char_short { } {
3168 global et_sync_char_short_saved
3170 if [info exists et_sync_char_short_saved] {
3171 verbose "check_effective_target_sync_char_short: using cached result" 2
3173 set et_sync_char_short_saved 0
3174 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3175 # load-reserved/store-conditional instructions.
3176 if { [istarget ia64-*-*]
3177 || [istarget i?86-*-*]
3178 || [istarget x86_64-*-*]
3179 || [istarget alpha*-*-*]
3180 || [istarget arm*-*-linux-gnueabi]
3181 || [istarget hppa*-*linux*]
3182 || [istarget s390*-*-*]
3183 || [istarget powerpc*-*-*]
3184 || [istarget sparc64-*-*]
3185 || [istarget sparcv9-*-*]
3186 || [istarget mips*-*-*] } {
3187 set et_sync_char_short_saved 1
3191 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3192 return $et_sync_char_short_saved
3195 # Return 1 if the target uses a ColdFire FPU.
3197 proc check_effective_target_coldfire_fpu { } {
3198 return [check_no_compiler_messages coldfire_fpu assembly {
3205 # Return true if this is a uClibc target.
3207 proc check_effective_target_uclibc {} {
3208 return [check_no_compiler_messages uclibc object {
3209 #include <features.h>
3210 #if !defined (__UCLIBC__)
3216 # Return true if this is a uclibc target and if the uclibc feature
3217 # described by __$feature__ is not present.
3219 proc check_missing_uclibc_feature {feature} {
3220 return [check_no_compiler_messages $feature object "
3221 #include <features.h>
3222 #if !defined (__UCLIBC) || defined (__${feature}__)
3228 # Return true if this is a Newlib target.
3230 proc check_effective_target_newlib {} {
3231 return [check_no_compiler_messages newlib object {
3237 # (a) an error of a few ULP is expected in string to floating-point
3238 # conversion functions; and
3239 # (b) overflow is not always detected correctly by those functions.
3241 proc check_effective_target_lax_strtofp {} {
3242 # By default, assume that all uClibc targets suffer from this.
3243 return [check_effective_target_uclibc]
3246 # Return 1 if this is a target for which wcsftime is a dummy
3247 # function that always returns 0.
3249 proc check_effective_target_dummy_wcsftime {} {
3250 # By default, assume that all uClibc targets suffer from this.
3251 return [check_effective_target_uclibc]
3254 # Return 1 if constructors with initialization priority arguments are
3255 # supposed on this target.
3257 proc check_effective_target_init_priority {} {
3258 return [check_no_compiler_messages init_priority assembly "
3259 void f() __attribute__((constructor (1000)));
3264 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3265 # This can be used with any check_* proc that takes no argument and
3266 # returns only 1 or 0. It could be used with check_* procs that take
3267 # arguments with keywords that pass particular arguments.
3269 proc is-effective-target { arg } {
3271 if { [info procs check_effective_target_${arg}] != [list] } {
3272 set selected [check_effective_target_${arg}]
3275 "vmx_hw" { set selected [check_vmx_hw_available] }
3276 "vsx_hw" { set selected [check_vsx_hw_available] }
3277 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3278 "named_sections" { set selected [check_named_sections_available] }
3279 "gc_sections" { set selected [check_gc_sections_available] }
3280 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3281 default { error "unknown effective target keyword `$arg'" }
3284 verbose "is-effective-target: $arg $selected" 2
3288 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3290 proc is-effective-target-keyword { arg } {
3291 if { [info procs check_effective_target_${arg}] != [list] } {
3294 # These have different names for their check_* procs.
3296 "vmx_hw" { return 1 }
3297 "vsx_hw" { return 1 }
3298 "ppc_recip_hw" { return 1 }
3299 "named_sections" { return 1 }
3300 "gc_sections" { return 1 }
3301 "cxa_atexit" { return 1 }
3302 default { return 0 }
3307 # Return 1 if target default to short enums
3309 proc check_effective_target_short_enums { } {
3310 return [check_no_compiler_messages short_enums assembly {
3312 int s[sizeof (enum foo) == 1 ? 1 : -1];
3316 # Return 1 if target supports merging string constants at link time.
3318 proc check_effective_target_string_merging { } {
3319 return [check_no_messages_and_pattern string_merging \
3320 "rodata\\.str" assembly {
3321 const char *var = "String";
3325 # Return 1 if target has the basic signed and unsigned types in
3326 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3327 # working <stdint.h> for all targets.
3329 proc check_effective_target_stdint_types { } {
3330 return [check_no_compiler_messages stdint_types assembly {
3332 int8_t a; int16_t b; int32_t c; int64_t d;
3333 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3337 # Return 1 if target has the basic signed and unsigned types in
3338 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3339 # these types agree with those in the header, as some systems have
3340 # only <inttypes.h>.
3342 proc check_effective_target_inttypes_types { } {
3343 return [check_no_compiler_messages inttypes_types assembly {
3344 #include <inttypes.h>
3345 int8_t a; int16_t b; int32_t c; int64_t d;
3346 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3350 # Return 1 if programs are intended to be run on a simulator
3351 # (i.e. slowly) rather than hardware (i.e. fast).
3353 proc check_effective_target_simulator { } {
3355 # All "src/sim" simulators set this one.
3356 if [board_info target exists is_simulator] {
3357 return [board_info target is_simulator]
3360 # The "sid" simulators don't set that one, but at least they set
3362 if [board_info target exists slow_simulator] {
3363 return [board_info target slow_simulator]
3369 # Return 1 if the target is a VxWorks kernel.
3371 proc check_effective_target_vxworks_kernel { } {
3372 return [check_no_compiler_messages vxworks_kernel assembly {
3373 #if !defined __vxworks || defined __RTP__
3379 # Return 1 if the target is a VxWorks RTP.
3381 proc check_effective_target_vxworks_rtp { } {
3382 return [check_no_compiler_messages vxworks_rtp assembly {
3383 #if !defined __vxworks || !defined __RTP__
3389 # Return 1 if the target is expected to provide wide character support.
3391 proc check_effective_target_wchar { } {
3392 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3395 return [check_no_compiler_messages wchar assembly {
3400 # Return 1 if the target has <pthread.h>.
3402 proc check_effective_target_pthread_h { } {
3403 return [check_no_compiler_messages pthread_h assembly {
3404 #include <pthread.h>
3408 # Return 1 if the target can truncate a file from a file-descriptor,
3409 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3410 # chsize. We test for a trivially functional truncation; no stubs.
3411 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3412 # different function to be used.
3414 proc check_effective_target_fd_truncate { } {
3416 #define _FILE_OFFSET_BITS 64
3422 FILE *f = fopen ("tst.tmp", "wb");
3424 const char t[] = "test writing more than ten characters";
3427 write (fd, t, sizeof (t) - 1);
3429 if (ftruncate (fd, 10) != 0)
3432 f = fopen ("tst.tmp", "rb");
3433 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3439 if { [check_runtime ftruncate $prog] } {
3443 regsub "ftruncate" $prog "chsize" prog
3444 return [check_runtime chsize $prog]
3447 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3449 proc add_options_for_c99_runtime { flags } {
3450 if { [istarget *-*-solaris2*] } {
3451 return "$flags -std=c99"
3453 if { [istarget powerpc-*-darwin*] } {
3454 return "$flags -mmacosx-version-min=10.3"
3459 # Add to FLAGS all the target-specific flags needed to enable
3460 # full IEEE compliance mode.
3462 proc add_options_for_ieee { flags } {
3463 if { [istarget "alpha*-*-*"]
3464 || [istarget "sh*-*-*"] } {
3465 return "$flags -mieee"
3470 # Add to FLAGS the flags needed to enable functions to bind locally
3471 # when using pic/PIC passes in the testsuite.
3473 proc add_options_for_bind_pic_locally { flags } {
3474 if {[check_no_compiler_messages using_pic2 assembly {
3479 return "$flags -fPIE"
3481 if {[check_no_compiler_messages using_pic1 assembly {
3486 return "$flags -fpie"
3492 # Return 1 if the target provides a full C99 runtime.
3494 proc check_effective_target_c99_runtime { } {
3495 return [check_cached_effective_target c99_runtime {
3498 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3499 set contents [read $file]
3502 #ifndef HAVE_C99_RUNTIME
3506 check_no_compiler_messages_nocache c99_runtime assembly \
3507 $contents [add_options_for_c99_runtime ""]
3511 # Return 1 if target wchar_t is at least 4 bytes.
3513 proc check_effective_target_4byte_wchar_t { } {
3514 return [check_no_compiler_messages 4byte_wchar_t object {
3515 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3519 # Return 1 if the target supports automatic stack alignment.
3521 proc check_effective_target_automatic_stack_alignment { } {
3522 if { [istarget i?86*-*-*]
3523 || [istarget x86_64-*-*] } then {
3530 # Return 1 if avx instructions can be compiled.
3532 proc check_effective_target_avx { } {
3533 return [check_no_compiler_messages avx object {
3534 void _mm256_zeroall (void)
3536 __builtin_ia32_vzeroall ();
3541 # Return 1 if sse instructions can be compiled.
3542 proc check_effective_target_sse { } {
3543 return [check_no_compiler_messages sse object {
3546 __builtin_ia32_stmxcsr ();
3552 # Return 1 if sse2 instructions can be compiled.
3553 proc check_effective_target_sse2 { } {
3554 return [check_no_compiler_messages sse2 object {
3555 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3557 __m128i _mm_srli_si128 (__m128i __A, int __N)
3559 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3564 # Return 1 if F16C instructions can be compiled.
3566 proc check_effective_target_f16c { } {
3567 return [check_no_compiler_messages f16c object {
3568 #include "immintrin.h"
3570 foo (unsigned short val)
3572 return _cvtsh_ss (val);
3577 # Return 1 if C wchar_t type is compatible with char16_t.
3579 proc check_effective_target_wchar_t_char16_t_compatible { } {
3580 return [check_no_compiler_messages wchar_t_char16_t object {
3582 __CHAR16_TYPE__ *p16 = &wc;
3583 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3587 # Return 1 if C wchar_t type is compatible with char32_t.
3589 proc check_effective_target_wchar_t_char32_t_compatible { } {
3590 return [check_no_compiler_messages wchar_t_char32_t object {
3592 __CHAR32_TYPE__ *p32 = &wc;
3593 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3597 # Return 1 if pow10 function exists.
3599 proc check_effective_target_pow10 { } {
3600 return [check_runtime pow10 {
3610 # Return 1 if current options generate DFP instructions, 0 otherwise.
3612 proc check_effective_target_hard_dfp {} {
3613 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3614 typedef float d64 __attribute__((mode(DD)));
3616 void foo (void) { z = x + y; }
3620 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3621 # for strchr etc. functions.
3623 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3624 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3627 #if !defined(__cplusplus) \
3628 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3629 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3630 ISO C++ correct string.h and wchar.h protos not supported.
3637 # Return 1 if GNU as is used.
3639 proc check_effective_target_gas { } {
3640 global use_gas_saved
3643 if {![info exists use_gas_saved]} {
3644 # Check if the as used by gcc is GNU as.
3645 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3646 # Provide /dev/null as input, otherwise gas times out reading from
3648 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3649 set as_output [lindex $status 1]
3650 if { [ string first "GNU" $as_output ] >= 0 } {
3656 return $use_gas_saved
3659 # Return 1 if the compiler has been configure with link-time optimization
3662 proc check_effective_target_lto { } {
3664 return [info exists ENABLE_LTO]
3667 # Return 1 if the language for the compiler under test is C.
3669 proc check_effective_target_c { } {
3671 if [string match $tool "gcc"] {
3677 # Return 1 if the language for the compiler under test is C++.
3679 proc check_effective_target_c++ { } {
3681 if [string match $tool "g++"] {
3687 # Return 1 if expensive testcases should be run.
3689 proc check_effective_target_run_expensive_tests { } {
3690 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {