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 # Returns true if --gc-sections is supported on the target.
373 proc check_gc_sections_available { } {
374 global gc_sections_available_saved
377 if {![info exists gc_sections_available_saved]} {
378 # Some targets don't support gc-sections despite whatever's
379 # advertised by ld's options.
380 if { [istarget alpha*-*-*]
381 || [istarget ia64-*-*] } {
382 set gc_sections_available_saved 0
386 # elf2flt uses -q (--emit-relocs), which is incompatible with
388 if { [board_info target exists ldflags]
389 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
390 set gc_sections_available_saved 0
394 # VxWorks kernel modules are relocatable objects linked with -r,
395 # while RTP executables are linked with -q (--emit-relocs).
396 # Both of these options are incompatible with --gc-sections.
397 if { [istarget *-*-vxworks*] } {
398 set gc_sections_available_saved 0
402 # Check if the ld used by gcc supports --gc-sections.
403 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
404 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
405 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
406 set ld_output [remote_exec host "$gcc_ld" "--help"]
407 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
408 set gc_sections_available_saved 1
410 set gc_sections_available_saved 0
413 return $gc_sections_available_saved
416 # Return 1 if according to target_info struct and explicit target list
417 # target is supposed to support trampolines.
419 proc check_effective_target_trampolines { } {
420 if [target_info exists no_trampolines] {
423 if { [istarget avr-*-*]
424 || [istarget hppa2.0w-hp-hpux11.23]
425 || [istarget hppa64-hp-hpux11.23] } {
431 # Return 1 if according to target_info struct and explicit target list
432 # target is supposed to keep null pointer checks. This could be due to
433 # use of option fno-delete-null-pointer-checks or hardwired in target.
435 proc check_effective_target_keeps_null_pointer_checks { } {
436 if [target_info exists keeps_null_pointer_checks] {
439 if { [istarget avr-*-*] } {
445 # Return true if profiling is supported on the target.
447 proc check_profiling_available { test_what } {
448 global profiling_available_saved
450 verbose "Profiling argument is <$test_what>" 1
452 # These conditions depend on the argument so examine them before
453 # looking at the cache variable.
455 # Support for -p on solaris2 relies on mcrt1.o which comes with the
456 # vendor compiler. We cannot reliably predict the directory where the
457 # vendor compiler (and thus mcrt1.o) is installed so we can't
458 # necessarily find mcrt1.o even if we have it.
459 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
463 # Support for -p on irix relies on libprof1.a which doesn't appear to
464 # exist on any irix6 system currently posting testsuite results.
465 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
466 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
467 if { [istarget mips*-*-irix*]
468 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
472 # We don't yet support profiling for MIPS16.
473 if { [istarget mips*-*-*]
474 && ![check_effective_target_nomips16]
475 && ([lindex $test_what 1] == "-p"
476 || [lindex $test_what 1] == "-pg") } {
480 # MinGW does not support -p.
481 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
485 # cygwin does not support -p.
486 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
490 # uClibc does not have gcrt1.o.
491 if { [check_effective_target_uclibc]
492 && ([lindex $test_what 1] == "-p"
493 || [lindex $test_what 1] == "-pg") } {
497 # Now examine the cache variable.
498 if {![info exists profiling_available_saved]} {
499 # Some targets don't have any implementation of __bb_init_func or are
500 # missing other needed machinery.
501 if { [istarget mmix-*-*]
502 || [istarget arm*-*-eabi*]
503 || [istarget picochip-*-*]
504 || [istarget *-*-netware*]
505 || [istarget arm*-*-elf]
506 || [istarget arm*-*-symbianelf*]
507 || [istarget avr-*-*]
508 || [istarget bfin-*-*]
509 || [istarget powerpc-*-eabi*]
510 || [istarget powerpc-*-elf]
511 || [istarget cris-*-*]
512 || [istarget crisv32-*-*]
513 || [istarget fido-*-elf]
514 || [istarget h8300-*-*]
515 || [istarget lm32-*-*]
516 || [istarget m32c-*-elf]
517 || [istarget m68k-*-elf]
518 || [istarget m68k-*-uclinux*]
519 || [istarget mep-*-elf]
520 || [istarget mips*-*-elf*]
521 || [istarget moxie-*-elf*]
523 || [istarget xstormy16-*]
524 || [istarget xtensa*-*-elf]
525 || [istarget *-*-rtems*]
526 || [istarget *-*-vxworks*] } {
527 set profiling_available_saved 0
529 set profiling_available_saved 1
533 return $profiling_available_saved
536 # Check to see if a target is "freestanding". This is as per the definition
537 # in Section 4 of C99 standard. Effectively, it is a target which supports no
538 # extra headers or libraries other than what is considered essential.
539 proc check_effective_target_freestanding { } {
540 if { [istarget picochip-*-*] } then {
547 # Return 1 if target has packed layout of structure members by
548 # default, 0 otherwise. Note that this is slightly different than
549 # whether the target has "natural alignment": both attributes may be
552 proc check_effective_target_default_packed { } {
553 return [check_no_compiler_messages default_packed assembly {
554 struct x { char a; long b; } c;
555 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
559 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
560 # documentation, where the test also comes from.
562 proc check_effective_target_pcc_bitfield_type_matters { } {
563 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
564 # bitfields, but let's stick to the example code from the docs.
565 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
566 struct foo1 { char x; char :0; char y; };
567 struct foo2 { char x; int :0; char y; };
568 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
572 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
574 proc check_effective_target_tls {} {
575 return [check_no_compiler_messages tls assembly {
577 int f (void) { return i; }
578 void g (int j) { i = j; }
582 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
584 proc check_effective_target_tls_native {} {
585 # VxWorks uses emulated TLS machinery, but with non-standard helper
586 # functions, so we fail to automatically detect it.
587 global target_triplet
588 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
592 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
594 int f (void) { return i; }
595 void g (int j) { i = j; }
599 # Return 1 if TLS executables can run correctly, 0 otherwise.
601 proc check_effective_target_tls_runtime {} {
602 return [check_runtime tls_runtime {
603 __thread int thr = 0;
604 int main (void) { return thr; }
608 # Return 1 if compilation with -fgraphite is error-free for trivial
611 proc check_effective_target_fgraphite {} {
612 return [check_no_compiler_messages fgraphite object {
617 # Return 1 if compilation with -fopenmp is error-free for trivial
620 proc check_effective_target_fopenmp {} {
621 return [check_no_compiler_messages fopenmp object {
626 # Return 1 if compilation with -pthread is error-free for trivial
629 proc check_effective_target_pthread {} {
630 return [check_no_compiler_messages pthread object {
635 # Return 1 if compilation with -mpe-aligned-commons is error-free
636 # for trivial code, 0 otherwise.
638 proc check_effective_target_pe_aligned_commons {} {
639 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
640 return [check_no_compiler_messages pe_aligned_commons object {
642 } "-mpe-aligned-commons"]
647 # Return 1 if the target supports -static
648 proc check_effective_target_static {} {
649 return [check_no_compiler_messages static executable {
650 int main (void) { return 0; }
654 # Return 1 if the target supports -fstack-protector
655 proc check_effective_target_fstack_protector {} {
656 return [check_runtime fstack_protector {
657 int main (void) { return 0; }
658 } "-fstack-protector"]
661 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
662 # for trivial code, 0 otherwise.
664 proc check_effective_target_freorder {} {
665 return [check_no_compiler_messages freorder object {
667 } "-freorder-blocks-and-partition"]
670 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
671 # emitted, 0 otherwise. Whether a shared library can actually be built is
672 # out of scope for this test.
674 proc check_effective_target_fpic { } {
675 # Note that M68K has a multilib that supports -fpic but not
676 # -fPIC, so we need to check both. We test with a program that
677 # requires GOT references.
678 foreach arg {fpic fPIC} {
679 if [check_no_compiler_messages $arg object {
680 extern int foo (void); extern int bar;
681 int baz (void) { return foo () + bar; }
689 # Return true if the target supports -mpaired-single (as used on MIPS).
691 proc check_effective_target_mpaired_single { } {
692 return [check_no_compiler_messages mpaired_single object {
697 # Return true if the target has access to FPU instructions.
699 proc check_effective_target_hard_float { } {
700 if { [istarget mips*-*-*] } {
701 return [check_no_compiler_messages hard_float assembly {
702 #if (defined __mips_soft_float || defined __mips16)
708 # This proc is actually checking the availabilty of FPU
709 # support for doubles, so on the RX we must fail if the
710 # 64-bit double multilib has been selected.
711 if { [istarget rx-*-*] } {
713 # return [check_no_compiler_messages hard_float assembly {
714 #if defined __RX_64_BIT_DOUBLES__
720 # The generic test equates hard_float with "no call for adding doubles".
721 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
722 double a (double b, double c) { return b + c; }
726 # Return true if the target is a 64-bit MIPS target.
728 proc check_effective_target_mips64 { } {
729 return [check_no_compiler_messages mips64 assembly {
736 # Return true if the target is a MIPS target that does not produce
739 proc check_effective_target_nomips16 { } {
740 return [check_no_compiler_messages nomips16 object {
744 /* A cheap way of testing for -mflip-mips16. */
745 void foo (void) { asm ("addiu $20,$20,1"); }
746 void bar (void) { asm ("addiu $20,$20,1"); }
751 # Add the options needed for MIPS16 function attributes. At the moment,
752 # we don't support MIPS16 PIC.
754 proc add_options_for_mips16_attribute { flags } {
755 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
758 # Return true if we can force a mode that allows MIPS16 code generation.
759 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
762 proc check_effective_target_mips16_attribute { } {
763 return [check_no_compiler_messages mips16_attribute assembly {
767 #if defined __mips_hard_float \
768 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
769 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
772 } [add_options_for_mips16_attribute ""]]
775 # Return 1 if the target supports long double larger than double when
776 # using the new ABI, 0 otherwise.
778 proc check_effective_target_mips_newabi_large_long_double { } {
779 return [check_no_compiler_messages mips_newabi_large_long_double object {
780 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
784 # Return 1 if the current multilib does not generate PIC by default.
786 proc check_effective_target_nonpic { } {
787 return [check_no_compiler_messages nonpic assembly {
794 # Return 1 if the target does not use a status wrapper.
796 proc check_effective_target_unwrapped { } {
797 if { [target_info needs_status_wrapper] != "" \
798 && [target_info needs_status_wrapper] != "0" } {
804 # Return true if iconv is supported on the target. In particular IBM1047.
806 proc check_iconv_available { test_what } {
809 # If the tool configuration file has not set libiconv, try "-liconv"
810 if { ![info exists libiconv] } {
811 set libiconv "-liconv"
813 set test_what [lindex $test_what 1]
814 return [check_runtime_nocache $test_what [subst {
820 cd = iconv_open ("$test_what", "UTF-8");
821 if (cd == (iconv_t) -1)
828 # Return true if named sections are supported on this target.
830 proc check_named_sections_available { } {
831 return [check_no_compiler_messages named_sections assembly {
832 int __attribute__ ((section("whatever"))) foo;
836 # Return 1 if the target supports Fortran real kinds larger than real(8),
839 # When the target name changes, replace the cached result.
841 proc check_effective_target_fortran_large_real { } {
842 return [check_no_compiler_messages fortran_large_real executable {
844 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
851 # Return 1 if the target supports Fortran integer kinds larger than
852 # integer(8), 0 otherwise.
854 # When the target name changes, replace the cached result.
856 proc check_effective_target_fortran_large_int { } {
857 return [check_no_compiler_messages fortran_large_int executable {
859 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
865 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
867 # When the target name changes, replace the cached result.
869 proc check_effective_target_fortran_integer_16 { } {
870 return [check_no_compiler_messages fortran_integer_16 executable {
877 # Return 1 if we can statically link libgfortran, 0 otherwise.
879 # When the target name changes, replace the cached result.
881 proc check_effective_target_static_libgfortran { } {
882 return [check_no_compiler_messages static_libgfortran executable {
889 proc check_linker_plugin_available { } {
890 return [check_no_compiler_messages_nocache linker_plugin executable {
891 int main() { return 0; }
892 } "-flto -fuse-linker-plugin"]
895 # Return 1 if the target supports executing 750CL paired-single instructions, 0
896 # otherwise. Cache the result.
898 proc check_750cl_hw_available { } {
899 return [check_cached_effective_target 750cl_hw_available {
900 # If this is not the right target then we can skip the test.
901 if { ![istarget powerpc-*paired*] } {
904 check_runtime_nocache 750cl_hw_available {
908 asm volatile ("ps_mul v0,v0,v0");
910 asm volatile ("ps_mul 0,0,0");
919 # Return 1 if the target OS supports running SSE executables, 0
920 # otherwise. Cache the result.
922 proc check_sse_os_support_available { } {
923 return [check_cached_effective_target sse_os_support_available {
924 # If this is not the right target then we can skip the test.
925 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
927 } elseif { [istarget i?86-*-solaris2*] } {
928 # The Solaris 2 kernel doesn't save and restore SSE registers
929 # before Solaris 9 4/04. Before that, executables die with SIGILL.
930 check_runtime_nocache sse_os_support_available {
933 __asm__ volatile ("movss %xmm2,%xmm1");
943 # Return 1 if the target supports executing SSE instructions, 0
944 # otherwise. Cache the result.
946 proc check_sse_hw_available { } {
947 return [check_cached_effective_target sse_hw_available {
948 # If this is not the right target then we can skip the test.
949 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
952 check_runtime_nocache sse_hw_available {
956 unsigned int eax, ebx, ecx, edx;
957 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
958 return !(edx & bit_SSE);
966 # Return 1 if the target supports executing SSE2 instructions, 0
967 # otherwise. Cache the result.
969 proc check_sse2_hw_available { } {
970 return [check_cached_effective_target sse2_hw_available {
971 # If this is not the right target then we can skip the test.
972 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
975 check_runtime_nocache sse2_hw_available {
979 unsigned int eax, ebx, ecx, edx;
980 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
981 return !(edx & bit_SSE2);
989 # Return 1 if the target supports executing AVX instructions, 0
990 # otherwise. Cache the result.
992 proc check_avx_hw_available { } {
993 return [check_cached_effective_target avx_hw_available {
994 # If this is not the right target then we can skip the test.
995 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
998 check_runtime_nocache avx_hw_available {
1002 unsigned int eax, ebx, ecx, edx;
1003 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1004 return ((ecx & (bit_AVX | bit_OSXSAVE))
1005 != (bit_AVX | bit_OSXSAVE));
1013 # Return 1 if the target supports running SSE executables, 0 otherwise.
1015 proc check_effective_target_sse_runtime { } {
1016 if { [check_effective_target_sse]
1017 && [check_sse_hw_available]
1018 && [check_sse_os_support_available] } {
1024 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1026 proc check_effective_target_sse2_runtime { } {
1027 if { [check_effective_target_sse2]
1028 && [check_sse2_hw_available]
1029 && [check_sse_os_support_available] } {
1035 # Return 1 if the target supports running AVX executables, 0 otherwise.
1037 proc check_effective_target_avx_runtime { } {
1038 if { [check_effective_target_avx]
1039 && [check_avx_hw_available] } {
1045 # Return 1 if the target supports executing VSX instructions, 0
1046 # otherwise. Cache the result.
1048 proc check_vsx_hw_available { } {
1049 return [check_cached_effective_target vsx_hw_available {
1050 # Some simulators are known to not support VSX instructions.
1051 # For now, disable on Darwin
1052 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1056 check_runtime_nocache vsx_hw_available {
1060 asm volatile ("xxlor vs0,vs0,vs0");
1062 asm volatile ("xxlor 0,0,0");
1071 # Return 1 if the target supports executing AltiVec instructions, 0
1072 # otherwise. Cache the result.
1074 proc check_vmx_hw_available { } {
1075 return [check_cached_effective_target vmx_hw_available {
1076 # Some simulators are known to not support VMX instructions.
1077 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1080 # Most targets don't require special flags for this test case, but
1081 # Darwin does. Just to be sure, make sure VSX is not enabled for
1082 # the altivec tests.
1083 if { [istarget *-*-darwin*]
1084 || [istarget *-*-aix*] } {
1085 set options "-maltivec -mno-vsx"
1087 set options "-mno-vsx"
1089 check_runtime_nocache vmx_hw_available {
1093 asm volatile ("vor v0,v0,v0");
1095 asm volatile ("vor 0,0,0");
1104 proc check_ppc_recip_hw_available { } {
1105 return [check_cached_effective_target ppc_recip_hw_available {
1106 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1107 # For now, disable on Darwin
1108 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1111 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1112 check_runtime_nocache ppc_recip_hw_available {
1113 volatile double d_recip, d_rsqrt, d_four = 4.0;
1114 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1117 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1118 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1119 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1120 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1128 # Return 1 if the target supports executing AltiVec and Cell PPU
1129 # instructions, 0 otherwise. Cache the result.
1131 proc check_effective_target_cell_hw { } {
1132 return [check_cached_effective_target cell_hw_available {
1133 # Some simulators are known to not support VMX and PPU instructions.
1134 if { [istarget powerpc-*-eabi*] } {
1137 # Most targets don't require special flags for this test
1138 # case, but Darwin and AIX do.
1139 if { [istarget *-*-darwin*]
1140 || [istarget *-*-aix*] } {
1141 set options "-maltivec -mcpu=cell"
1143 set options "-mcpu=cell"
1145 check_runtime_nocache cell_hw_available {
1149 asm volatile ("vor v0,v0,v0");
1150 asm volatile ("lvlx v0,r0,r0");
1152 asm volatile ("vor 0,0,0");
1153 asm volatile ("lvlx 0,0,0");
1162 # Return 1 if the target supports executing 64-bit instructions, 0
1163 # otherwise. Cache the result.
1165 proc check_effective_target_powerpc64 { } {
1166 global powerpc64_available_saved
1169 if [info exists powerpc64_available_saved] {
1170 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1172 set powerpc64_available_saved 0
1174 # Some simulators are known to not support powerpc64 instructions.
1175 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1176 verbose "check_effective_target_powerpc64 returning 0" 2
1177 return $powerpc64_available_saved
1180 # Set up, compile, and execute a test program containing a 64-bit
1181 # instruction. Include the current process ID in the file
1182 # names to prevent conflicts with invocations for multiple
1187 set f [open $src "w"]
1188 puts $f "int main() {"
1189 puts $f "#ifdef __MACH__"
1190 puts $f " asm volatile (\"extsw r0,r0\");"
1192 puts $f " asm volatile (\"extsw 0,0\");"
1194 puts $f " return 0; }"
1197 set opts "additional_flags=-mcpu=G5"
1199 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1200 set lines [${tool}_target_compile $src $exe executable "$opts"]
1203 if [string match "" $lines] then {
1204 # No error message, compilation succeeded.
1205 set result [${tool}_load "./$exe" "" ""]
1206 set status [lindex $result 0]
1207 remote_file build delete $exe
1208 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1210 if { $status == "pass" } then {
1211 set powerpc64_available_saved 1
1214 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1218 return $powerpc64_available_saved
1221 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1222 # complex float arguments. This affects gfortran tests that call cabsf
1223 # in libm built by an earlier compiler. Return 1 if libm uses the same
1224 # argument passing as the compiler under test, 0 otherwise.
1226 # When the target name changes, replace the cached result.
1228 proc check_effective_target_broken_cplxf_arg { } {
1229 return [check_cached_effective_target broken_cplxf_arg {
1230 # Skip the work for targets known not to be affected.
1231 if { ![istarget powerpc64-*-linux*] } {
1233 } elseif { ![is-effective-target lp64] } {
1236 check_runtime_nocache broken_cplxf_arg {
1237 #include <complex.h>
1238 extern void abort (void);
1239 float fabsf (float);
1240 float cabsf (_Complex float);
1247 if (fabsf (f - 5.0) > 0.0001)
1256 proc check_alpha_max_hw_available { } {
1257 return [check_runtime alpha_max_hw_available {
1258 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1262 # Returns true iff the FUNCTION is available on the target system.
1263 # (This is essentially a Tcl implementation of Autoconf's
1266 proc check_function_available { function } {
1267 return [check_no_compiler_messages ${function}_available \
1273 int main () { $function (); }
1277 # Returns true iff "fork" is available on the target system.
1279 proc check_fork_available {} {
1280 return [check_function_available "fork"]
1283 # Returns true iff "mkfifo" is available on the target system.
1285 proc check_mkfifo_available {} {
1286 if {[istarget *-*-cygwin*]} {
1287 # Cygwin has mkfifo, but support is incomplete.
1291 return [check_function_available "mkfifo"]
1294 # Returns true iff "__cxa_atexit" is used on the target system.
1296 proc check_cxa_atexit_available { } {
1297 return [check_cached_effective_target cxa_atexit_available {
1298 if { [istarget "hppa*-*-hpux10*"] } {
1299 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1301 } elseif { [istarget "*-*-vxworks"] } {
1302 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1305 check_runtime_nocache cxa_atexit_available {
1308 static unsigned int count;
1325 Y() { f(); count = 2; }
1334 int main() { return 0; }
1340 proc check_effective_target_objc2 { } {
1341 return [check_no_compiler_messages objc2 object {
1350 proc check_effective_target_next_runtime { } {
1351 return [check_no_compiler_messages objc2 object {
1352 #ifdef __NEXT_RUNTIME__
1360 # Return 1 if we're generating 32-bit code using default options, 0
1363 proc check_effective_target_ilp32 { } {
1364 return [check_no_compiler_messages ilp32 object {
1365 int dummy[sizeof (int) == 4
1366 && sizeof (void *) == 4
1367 && sizeof (long) == 4 ? 1 : -1];
1371 # Return 1 if we're generating 32-bit or larger integers using default
1372 # options, 0 otherwise.
1374 proc check_effective_target_int32plus { } {
1375 return [check_no_compiler_messages int32plus object {
1376 int dummy[sizeof (int) >= 4 ? 1 : -1];
1380 # Return 1 if we're generating 32-bit or larger pointers using default
1381 # options, 0 otherwise.
1383 proc check_effective_target_ptr32plus { } {
1384 return [check_no_compiler_messages ptr32plus object {
1385 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1389 # Return 1 if we support 32-bit or larger array and structure sizes
1390 # using default options, 0 otherwise.
1392 proc check_effective_target_size32plus { } {
1393 return [check_no_compiler_messages size32plus object {
1398 # Returns 1 if we're generating 16-bit or smaller integers with the
1399 # default options, 0 otherwise.
1401 proc check_effective_target_int16 { } {
1402 return [check_no_compiler_messages int16 object {
1403 int dummy[sizeof (int) < 4 ? 1 : -1];
1407 # Return 1 if we're generating 64-bit code using default options, 0
1410 proc check_effective_target_lp64 { } {
1411 return [check_no_compiler_messages lp64 object {
1412 int dummy[sizeof (int) == 4
1413 && sizeof (void *) == 8
1414 && sizeof (long) == 8 ? 1 : -1];
1418 # Return 1 if we're generating 64-bit code using default llp64 options,
1421 proc check_effective_target_llp64 { } {
1422 return [check_no_compiler_messages llp64 object {
1423 int dummy[sizeof (int) == 4
1424 && sizeof (void *) == 8
1425 && sizeof (long long) == 8
1426 && sizeof (long) == 4 ? 1 : -1];
1430 # Return 1 if the target supports long double larger than double,
1433 proc check_effective_target_large_long_double { } {
1434 return [check_no_compiler_messages large_long_double object {
1435 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1439 # Return 1 if the target supports double larger than float,
1442 proc check_effective_target_large_double { } {
1443 return [check_no_compiler_messages large_double object {
1444 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1448 # Return 1 if the target supports double of 64 bits,
1451 proc check_effective_target_double64 { } {
1452 return [check_no_compiler_messages double64 object {
1453 int dummy[sizeof(double) == 8 ? 1 : -1];
1457 # Return 1 if the target supports double of at least 64 bits,
1460 proc check_effective_target_double64plus { } {
1461 return [check_no_compiler_messages double64plus object {
1462 int dummy[sizeof(double) >= 8 ? 1 : -1];
1466 # Return 1 if the target supports compiling fixed-point,
1469 proc check_effective_target_fixed_point { } {
1470 return [check_no_compiler_messages fixed_point object {
1471 _Sat _Fract x; _Sat _Accum y;
1475 # Return 1 if the target supports compiling decimal floating point,
1478 proc check_effective_target_dfp_nocache { } {
1479 verbose "check_effective_target_dfp_nocache: compiling source" 2
1480 set ret [check_no_compiler_messages_nocache dfp object {
1481 float x __attribute__((mode(DD)));
1483 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1487 proc check_effective_target_dfprt_nocache { } {
1488 return [check_runtime_nocache dfprt {
1489 typedef float d64 __attribute__((mode(DD)));
1490 d64 x = 1.2df, y = 2.3dd, z;
1491 int main () { z = x + y; return 0; }
1495 # Return 1 if the target supports compiling Decimal Floating Point,
1498 # This won't change for different subtargets so cache the result.
1500 proc check_effective_target_dfp { } {
1501 return [check_cached_effective_target dfp {
1502 check_effective_target_dfp_nocache
1506 # Return 1 if the target supports linking and executing Decimal Floating
1507 # Point, 0 otherwise.
1509 # This won't change for different subtargets so cache the result.
1511 proc check_effective_target_dfprt { } {
1512 return [check_cached_effective_target dfprt {
1513 check_effective_target_dfprt_nocache
1517 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1519 proc check_effective_target_ucn_nocache { } {
1520 # -std=c99 is only valid for C
1521 if [check_effective_target_c] {
1522 set ucnopts "-std=c99"
1524 append ucnopts " -fextended-identifiers"
1525 verbose "check_effective_target_ucn_nocache: compiling source" 2
1526 set ret [check_no_compiler_messages_nocache ucn object {
1529 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1533 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1535 # This won't change for different subtargets, so cache the result.
1537 proc check_effective_target_ucn { } {
1538 return [check_cached_effective_target ucn {
1539 check_effective_target_ucn_nocache
1543 # Return 1 if the target needs a command line argument to enable a SIMD
1546 proc check_effective_target_vect_cmdline_needed { } {
1547 global et_vect_cmdline_needed_saved
1548 global et_vect_cmdline_needed_target_name
1550 if { ![info exists et_vect_cmdline_needed_target_name] } {
1551 set et_vect_cmdline_needed_target_name ""
1554 # If the target has changed since we set the cached value, clear it.
1555 set current_target [current_target_name]
1556 if { $current_target != $et_vect_cmdline_needed_target_name } {
1557 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1558 set et_vect_cmdline_needed_target_name $current_target
1559 if { [info exists et_vect_cmdline_needed_saved] } {
1560 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1561 unset et_vect_cmdline_needed_saved
1565 if [info exists et_vect_cmdline_needed_saved] {
1566 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1568 set et_vect_cmdline_needed_saved 1
1569 if { [istarget alpha*-*-*]
1570 || [istarget ia64-*-*]
1571 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1572 && [check_effective_target_lp64])
1573 || ([istarget powerpc*-*-*]
1574 && ([check_effective_target_powerpc_spe]
1575 || [check_effective_target_powerpc_altivec]))
1576 || [istarget spu-*-*]
1577 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1578 set et_vect_cmdline_needed_saved 0
1582 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1583 return $et_vect_cmdline_needed_saved
1586 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1588 # This won't change for different subtargets so cache the result.
1590 proc check_effective_target_vect_int { } {
1591 global et_vect_int_saved
1593 if [info exists et_vect_int_saved] {
1594 verbose "check_effective_target_vect_int: using cached result" 2
1596 set et_vect_int_saved 0
1597 if { [istarget i?86-*-*]
1598 || ([istarget powerpc*-*-*]
1599 && ![istarget powerpc-*-linux*paired*])
1600 || [istarget spu-*-*]
1601 || [istarget x86_64-*-*]
1602 || [istarget sparc*-*-*]
1603 || [istarget alpha*-*-*]
1604 || [istarget ia64-*-*]
1605 || [check_effective_target_arm32] } {
1606 set et_vect_int_saved 1
1610 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1611 return $et_vect_int_saved
1614 # Return 1 if the target supports signed int->float conversion
1617 proc check_effective_target_vect_intfloat_cvt { } {
1618 global et_vect_intfloat_cvt_saved
1620 if [info exists et_vect_intfloat_cvt_saved] {
1621 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1623 set et_vect_intfloat_cvt_saved 0
1624 if { [istarget i?86-*-*]
1625 || ([istarget powerpc*-*-*]
1626 && ![istarget powerpc-*-linux*paired*])
1627 || [istarget x86_64-*-*] } {
1628 set et_vect_intfloat_cvt_saved 1
1632 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1633 return $et_vect_intfloat_cvt_saved
1636 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1638 proc check_effective_target_int128 { } {
1639 return [check_no_compiler_messages int128 object {
1641 #ifndef __SIZEOF_INT128__
1650 # Return 1 if the target supports unsigned int->float conversion
1653 proc check_effective_target_vect_uintfloat_cvt { } {
1654 global et_vect_uintfloat_cvt_saved
1656 if [info exists et_vect_uintfloat_cvt_saved] {
1657 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1659 set et_vect_uintfloat_cvt_saved 0
1660 if { [istarget i?86-*-*]
1661 || ([istarget powerpc*-*-*]
1662 && ![istarget powerpc-*-linux*paired*])
1663 || [istarget x86_64-*-*] } {
1664 set et_vect_uintfloat_cvt_saved 1
1668 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1669 return $et_vect_uintfloat_cvt_saved
1673 # Return 1 if the target supports signed float->int conversion
1676 proc check_effective_target_vect_floatint_cvt { } {
1677 global et_vect_floatint_cvt_saved
1679 if [info exists et_vect_floatint_cvt_saved] {
1680 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1682 set et_vect_floatint_cvt_saved 0
1683 if { [istarget i?86-*-*]
1684 || ([istarget powerpc*-*-*]
1685 && ![istarget powerpc-*-linux*paired*])
1686 || [istarget x86_64-*-*] } {
1687 set et_vect_floatint_cvt_saved 1
1691 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1692 return $et_vect_floatint_cvt_saved
1695 # Return 1 if the target supports unsigned float->int conversion
1698 proc check_effective_target_vect_floatuint_cvt { } {
1699 global et_vect_floatuint_cvt_saved
1701 if [info exists et_vect_floatuint_cvt_saved] {
1702 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1704 set et_vect_floatuint_cvt_saved 0
1705 if { ([istarget powerpc*-*-*]
1706 && ![istarget powerpc-*-linux*paired*]) } {
1707 set et_vect_floatuint_cvt_saved 1
1711 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1712 return $et_vect_floatuint_cvt_saved
1715 # Return 1 is this is an arm target using 32-bit instructions
1716 proc check_effective_target_arm32 { } {
1717 return [check_no_compiler_messages arm32 assembly {
1718 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1724 # Return 1 if this is an ARM target supporting -mfpu=vfp
1725 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1728 proc check_effective_target_arm_vfp_ok { } {
1729 if { [check_effective_target_arm32] } {
1730 return [check_no_compiler_messages arm_vfp_ok object {
1732 } "-mfpu=vfp -mfloat-abi=softfp"]
1738 # Return 1 if this is an ARM target supporting -mfpu=vfp
1739 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1742 proc check_effective_target_arm_hard_vfp_ok { } {
1743 if { [check_effective_target_arm32] } {
1744 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1745 int main() { return 0;}
1746 } "-mfpu=vfp -mfloat-abi=hard"]
1752 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1753 # or -mfloat-abi=hard, but if one is already specified by the
1754 # multilib, use it. Similarly, if a -mfpu option already enables
1755 # NEON, do not add -mfpu=neon.
1757 proc add_options_for_arm_neon { flags } {
1758 if { ! [check_effective_target_arm_neon_ok] } {
1761 global et_arm_neon_flags
1762 return "$flags $et_arm_neon_flags"
1765 # Return 1 if this is an ARM target supporting -mfpu=neon
1766 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1767 # incompatible with these options. Also set et_arm_neon_flags to the
1768 # best options to add.
1770 proc check_effective_target_arm_neon_ok_nocache { } {
1771 global et_arm_neon_flags
1772 set et_arm_neon_flags ""
1773 if { [check_effective_target_arm32] } {
1774 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1775 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1776 #include "arm_neon.h"
1779 set et_arm_neon_flags $flags
1788 proc check_effective_target_arm_neon_ok { } {
1789 return [check_cached_effective_target arm_neon_ok \
1790 check_effective_target_arm_neon_ok_nocache]
1793 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1794 # or -mfloat-abi=hard, but if one is already specified by the
1797 proc add_options_for_arm_neon_fp16 { flags } {
1798 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1801 global et_arm_neon_fp16_flags
1802 return "$flags $et_arm_neon_fp16_flags"
1805 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1806 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1807 # incompatible with these options. Also set et_arm_neon_flags to the
1808 # best options to add.
1810 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1811 global et_arm_neon_fp16_flags
1812 set et_arm_neon_fp16_flags ""
1813 if { [check_effective_target_arm32] } {
1814 # Always add -mfpu=neon-fp16, since there is no preprocessor
1815 # macro for FP16 support.
1816 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1817 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1818 #include "arm_neon.h"
1821 set et_arm_neon_fp16_flags $flags
1830 proc check_effective_target_arm_neon_fp16_ok { } {
1831 return [check_cached_effective_target arm_neon_fp16_ok \
1832 check_effective_target_arm_neon_fp16_ok_nocache]
1835 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1838 proc check_effective_target_arm_thumb1_ok { } {
1839 return [check_no_compiler_messages arm_thumb1_ok assembly {
1840 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1846 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1849 proc check_effective_target_arm_thumb2_ok { } {
1850 return [check_no_compiler_messages arm_thumb2_ok assembly {
1851 #if !defined(__thumb2__)
1857 # Return 1 if the target supports executing NEON instructions, 0
1858 # otherwise. Cache the result.
1860 proc check_effective_target_arm_neon_hw { } {
1861 return [check_runtime arm_neon_hw_available {
1865 long long a = 0, b = 1;
1866 asm ("vorr %P0, %P1, %P2"
1868 : "0" (a), "w" (b));
1871 } [add_options_for_arm_neon ""]]
1874 # Return 1 if this is a ARM target with NEON enabled.
1876 proc check_effective_target_arm_neon { } {
1877 if { [check_effective_target_arm32] } {
1878 return [check_no_compiler_messages arm_neon object {
1879 #ifndef __ARM_NEON__
1890 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1891 # the Loongson vector modes.
1893 proc check_effective_target_mips_loongson { } {
1894 return [check_no_compiler_messages loongson assembly {
1895 #if !defined(__mips_loongson_vector_rev)
1901 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1904 proc check_effective_target_arm_eabi { } {
1905 return [check_no_compiler_messages arm_eabi object {
1906 #ifndef __ARM_EABI__
1914 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
1915 # Some multilibs may be incompatible with this option.
1917 proc check_effective_target_arm_iwmmxt_ok { } {
1918 if { [check_effective_target_arm32] } {
1919 return [check_no_compiler_messages arm_iwmmxt_ok object {
1927 # Return 1 if this is a PowerPC target with floating-point registers.
1929 proc check_effective_target_powerpc_fprs { } {
1930 if { [istarget powerpc*-*-*]
1931 || [istarget rs6000-*-*] } {
1932 return [check_no_compiler_messages powerpc_fprs object {
1944 # Return 1 if this is a PowerPC target with hardware double-precision
1947 proc check_effective_target_powerpc_hard_double { } {
1948 if { [istarget powerpc*-*-*]
1949 || [istarget rs6000-*-*] } {
1950 return [check_no_compiler_messages powerpc_hard_double object {
1962 # Return 1 if this is a PowerPC target supporting -maltivec.
1964 proc check_effective_target_powerpc_altivec_ok { } {
1965 if { ([istarget powerpc*-*-*]
1966 && ![istarget powerpc-*-linux*paired*])
1967 || [istarget rs6000-*-*] } {
1968 # AltiVec is not supported on AIX before 5.3.
1969 if { [istarget powerpc*-*-aix4*]
1970 || [istarget powerpc*-*-aix5.1*]
1971 || [istarget powerpc*-*-aix5.2*] } {
1974 return [check_no_compiler_messages powerpc_altivec_ok object {
1982 # Return 1 if this is a PowerPC target supporting -mvsx
1984 proc check_effective_target_powerpc_vsx_ok { } {
1985 if { ([istarget powerpc*-*-*]
1986 && ![istarget powerpc-*-linux*paired*])
1987 || [istarget rs6000-*-*] } {
1988 # AltiVec is not supported on AIX before 5.3.
1989 if { [istarget powerpc*-*-aix4*]
1990 || [istarget powerpc*-*-aix5.1*]
1991 || [istarget powerpc*-*-aix5.2*] } {
1994 return [check_no_compiler_messages powerpc_vsx_ok object {
1997 asm volatile ("xxlor vs0,vs0,vs0");
1999 asm volatile ("xxlor 0,0,0");
2009 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2011 proc check_effective_target_powerpc_ppu_ok { } {
2012 if [check_effective_target_powerpc_altivec_ok] {
2013 return [check_no_compiler_messages cell_asm_available object {
2016 asm volatile ("lvlx v0,v0,v0");
2018 asm volatile ("lvlx 0,0,0");
2028 # Return 1 if this is a PowerPC target that supports SPU.
2030 proc check_effective_target_powerpc_spu { } {
2031 if [istarget powerpc*-*-linux*] {
2032 return [check_effective_target_powerpc_altivec_ok]
2038 # Return 1 if this is a PowerPC SPE target. The check includes options
2039 # specified by dg-options for this test, so don't cache the result.
2041 proc check_effective_target_powerpc_spe_nocache { } {
2042 if { [istarget powerpc*-*-*] } {
2043 return [check_no_compiler_messages_nocache powerpc_spe object {
2049 } [current_compiler_flags]]
2055 # Return 1 if this is a PowerPC target with SPE enabled.
2057 proc check_effective_target_powerpc_spe { } {
2058 if { [istarget powerpc*-*-*] } {
2059 return [check_no_compiler_messages powerpc_spe object {
2071 # Return 1 if this is a PowerPC target with Altivec enabled.
2073 proc check_effective_target_powerpc_altivec { } {
2074 if { [istarget powerpc*-*-*] } {
2075 return [check_no_compiler_messages powerpc_altivec object {
2087 # Return 1 if this is a PowerPC 405 target. The check includes options
2088 # specified by dg-options for this test, so don't cache the result.
2090 proc check_effective_target_powerpc_405_nocache { } {
2091 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2092 return [check_no_compiler_messages_nocache powerpc_405 object {
2098 } [current_compiler_flags]]
2104 # Return 1 if this is a SPU target with a toolchain that
2105 # supports automatic overlay generation.
2107 proc check_effective_target_spu_auto_overlay { } {
2108 if { [istarget spu*-*-elf*] } {
2109 return [check_no_compiler_messages spu_auto_overlay executable {
2111 } "-Wl,--auto-overlay" ]
2117 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2118 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2119 # test environment appears to run executables on such a simulator.
2121 proc check_effective_target_ultrasparc_hw { } {
2122 return [check_runtime ultrasparc_hw {
2123 int main() { return 0; }
2124 } "-mcpu=ultrasparc"]
2127 # Return 1 if the target supports hardware vector shift operation.
2129 proc check_effective_target_vect_shift { } {
2130 global et_vect_shift_saved
2132 if [info exists et_vect_shift_saved] {
2133 verbose "check_effective_target_vect_shift: using cached result" 2
2135 set et_vect_shift_saved 0
2136 if { ([istarget powerpc*-*-*]
2137 && ![istarget powerpc-*-linux*paired*])
2138 || [istarget ia64-*-*]
2139 || [istarget i?86-*-*]
2140 || [istarget x86_64-*-*]
2141 || [check_effective_target_arm32] } {
2142 set et_vect_shift_saved 1
2146 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2147 return $et_vect_shift_saved
2150 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2152 # This can change for different subtargets so do not cache the result.
2154 proc check_effective_target_vect_long { } {
2155 if { [istarget i?86-*-*]
2156 || (([istarget powerpc*-*-*]
2157 && ![istarget powerpc-*-linux*paired*])
2158 && [check_effective_target_ilp32])
2159 || [istarget x86_64-*-*]
2160 || [check_effective_target_arm32]
2161 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2167 verbose "check_effective_target_vect_long: returning $answer" 2
2171 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2173 # This won't change for different subtargets so cache the result.
2175 proc check_effective_target_vect_float { } {
2176 global et_vect_float_saved
2178 if [info exists et_vect_float_saved] {
2179 verbose "check_effective_target_vect_float: using cached result" 2
2181 set et_vect_float_saved 0
2182 if { [istarget i?86-*-*]
2183 || [istarget powerpc*-*-*]
2184 || [istarget spu-*-*]
2185 || [istarget mipsisa64*-*-*]
2186 || [istarget x86_64-*-*]
2187 || [istarget ia64-*-*]
2188 || [check_effective_target_arm32] } {
2189 set et_vect_float_saved 1
2193 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2194 return $et_vect_float_saved
2197 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2199 # This won't change for different subtargets so cache the result.
2201 proc check_effective_target_vect_double { } {
2202 global et_vect_double_saved
2204 if [info exists et_vect_double_saved] {
2205 verbose "check_effective_target_vect_double: using cached result" 2
2207 set et_vect_double_saved 0
2208 if { [istarget i?86-*-*]
2209 || [istarget x86_64-*-*]
2210 || [istarget spu-*-*] } {
2211 set et_vect_double_saved 1
2215 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2216 return $et_vect_double_saved
2219 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2221 # This won't change for different subtargets so cache the result.
2223 proc check_effective_target_vect_long_long { } {
2224 global et_vect_long_long_saved
2226 if [info exists et_vect_long_long_saved] {
2227 verbose "check_effective_target_vect_long_long: using cached result" 2
2229 set et_vect_long_long_saved 0
2230 if { [istarget i?86-*-*]
2231 || [istarget x86_64-*-*] } {
2232 set et_vect_long_long_saved 1
2236 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2237 return $et_vect_long_long_saved
2241 # Return 1 if the target plus current options does not support a vector
2242 # max instruction on "int", 0 otherwise.
2244 # This won't change for different subtargets so cache the result.
2246 proc check_effective_target_vect_no_int_max { } {
2247 global et_vect_no_int_max_saved
2249 if [info exists et_vect_no_int_max_saved] {
2250 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2252 set et_vect_no_int_max_saved 0
2253 if { [istarget sparc*-*-*]
2254 || [istarget spu-*-*]
2255 || [istarget alpha*-*-*] } {
2256 set et_vect_no_int_max_saved 1
2259 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2260 return $et_vect_no_int_max_saved
2263 # Return 1 if the target plus current options does not support a vector
2264 # add instruction on "int", 0 otherwise.
2266 # This won't change for different subtargets so cache the result.
2268 proc check_effective_target_vect_no_int_add { } {
2269 global et_vect_no_int_add_saved
2271 if [info exists et_vect_no_int_add_saved] {
2272 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2274 set et_vect_no_int_add_saved 0
2275 # Alpha only supports vector add on V8QI and V4HI.
2276 if { [istarget alpha*-*-*] } {
2277 set et_vect_no_int_add_saved 1
2280 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2281 return $et_vect_no_int_add_saved
2284 # Return 1 if the target plus current options does not support vector
2285 # bitwise instructions, 0 otherwise.
2287 # This won't change for different subtargets so cache the result.
2289 proc check_effective_target_vect_no_bitwise { } {
2290 global et_vect_no_bitwise_saved
2292 if [info exists et_vect_no_bitwise_saved] {
2293 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2295 set et_vect_no_bitwise_saved 0
2297 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2298 return $et_vect_no_bitwise_saved
2301 # Return 1 if the target plus current options supports vector permutation,
2304 # This won't change for different subtargets so cache the result.
2306 proc check_effective_target_vect_perm { } {
2309 if [info exists et_vect_perm_saved] {
2310 verbose "check_effective_target_vect_perm: using cached result" 2
2312 set et_vect_perm_saved 0
2313 if { [istarget powerpc*-*-*]
2314 || [istarget spu-*-*] } {
2315 set et_vect_perm_saved 1
2318 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2319 return $et_vect_perm_saved
2322 # Return 1 if the target plus current options supports a vector
2323 # widening summation of *short* args into *int* result, 0 otherwise.
2325 # This won't change for different subtargets so cache the result.
2327 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2328 global et_vect_widen_sum_hi_to_si_pattern
2330 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2331 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2333 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2334 if { [istarget powerpc*-*-*] } {
2335 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2338 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2339 return $et_vect_widen_sum_hi_to_si_pattern_saved
2342 # Return 1 if the target plus current options supports a vector
2343 # widening summation of *short* args into *int* result, 0 otherwise.
2344 # A target can also support this widening summation if it can support
2345 # promotion (unpacking) from shorts to ints.
2347 # This won't change for different subtargets so cache the result.
2349 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2350 global et_vect_widen_sum_hi_to_si
2352 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2353 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2355 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2356 if { [istarget powerpc*-*-*]
2357 || [istarget ia64-*-*] } {
2358 set et_vect_widen_sum_hi_to_si_saved 1
2361 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2362 return $et_vect_widen_sum_hi_to_si_saved
2365 # Return 1 if the target plus current options supports a vector
2366 # widening summation of *char* args into *short* result, 0 otherwise.
2367 # A target can also support this widening summation if it can support
2368 # promotion (unpacking) from chars to shorts.
2370 # This won't change for different subtargets so cache the result.
2372 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2373 global et_vect_widen_sum_qi_to_hi
2375 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2376 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2378 set et_vect_widen_sum_qi_to_hi_saved 0
2379 if { [check_effective_target_vect_unpack]
2380 || [istarget ia64-*-*] } {
2381 set et_vect_widen_sum_qi_to_hi_saved 1
2384 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2385 return $et_vect_widen_sum_qi_to_hi_saved
2388 # Return 1 if the target plus current options supports a vector
2389 # widening summation of *char* args into *int* result, 0 otherwise.
2391 # This won't change for different subtargets so cache the result.
2393 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2394 global et_vect_widen_sum_qi_to_si
2396 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2397 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2399 set et_vect_widen_sum_qi_to_si_saved 0
2400 if { [istarget powerpc*-*-*] } {
2401 set et_vect_widen_sum_qi_to_si_saved 1
2404 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2405 return $et_vect_widen_sum_qi_to_si_saved
2408 # Return 1 if the target plus current options supports a vector
2409 # widening multiplication of *char* args into *short* result, 0 otherwise.
2410 # A target can also support this widening multplication if it can support
2411 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2412 # multiplication of shorts).
2414 # This won't change for different subtargets so cache the result.
2417 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2418 global et_vect_widen_mult_qi_to_hi
2420 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2421 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2423 if { [check_effective_target_vect_unpack]
2424 && [check_effective_target_vect_short_mult] } {
2425 set et_vect_widen_mult_qi_to_hi_saved 1
2427 set et_vect_widen_mult_qi_to_hi_saved 0
2429 if { [istarget powerpc*-*-*] } {
2430 set et_vect_widen_mult_qi_to_hi_saved 1
2433 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2434 return $et_vect_widen_mult_qi_to_hi_saved
2437 # Return 1 if the target plus current options supports a vector
2438 # widening multiplication of *short* args into *int* result, 0 otherwise.
2439 # A target can also support this widening multplication if it can support
2440 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2441 # multiplication of ints).
2443 # This won't change for different subtargets so cache the result.
2446 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2447 global et_vect_widen_mult_hi_to_si
2449 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2450 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2452 if { [check_effective_target_vect_unpack]
2453 && [check_effective_target_vect_int_mult] } {
2454 set et_vect_widen_mult_hi_to_si_saved 1
2456 set et_vect_widen_mult_hi_to_si_saved 0
2458 if { [istarget powerpc*-*-*]
2459 || [istarget spu-*-*]
2460 || [istarget i?86-*-*]
2461 || [istarget x86_64-*-*] } {
2462 set et_vect_widen_mult_hi_to_si_saved 1
2465 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2466 return $et_vect_widen_mult_hi_to_si_saved
2469 # Return 1 if the target plus current options supports a vector
2470 # dot-product of signed chars, 0 otherwise.
2472 # This won't change for different subtargets so cache the result.
2474 proc check_effective_target_vect_sdot_qi { } {
2475 global et_vect_sdot_qi
2477 if [info exists et_vect_sdot_qi_saved] {
2478 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2480 set et_vect_sdot_qi_saved 0
2482 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2483 return $et_vect_sdot_qi_saved
2486 # Return 1 if the target plus current options supports a vector
2487 # dot-product of unsigned chars, 0 otherwise.
2489 # This won't change for different subtargets so cache the result.
2491 proc check_effective_target_vect_udot_qi { } {
2492 global et_vect_udot_qi
2494 if [info exists et_vect_udot_qi_saved] {
2495 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2497 set et_vect_udot_qi_saved 0
2498 if { [istarget powerpc*-*-*] } {
2499 set et_vect_udot_qi_saved 1
2502 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2503 return $et_vect_udot_qi_saved
2506 # Return 1 if the target plus current options supports a vector
2507 # dot-product of signed shorts, 0 otherwise.
2509 # This won't change for different subtargets so cache the result.
2511 proc check_effective_target_vect_sdot_hi { } {
2512 global et_vect_sdot_hi
2514 if [info exists et_vect_sdot_hi_saved] {
2515 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2517 set et_vect_sdot_hi_saved 0
2518 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2519 || [istarget i?86-*-*]
2520 || [istarget x86_64-*-*] } {
2521 set et_vect_sdot_hi_saved 1
2524 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2525 return $et_vect_sdot_hi_saved
2528 # Return 1 if the target plus current options supports a vector
2529 # dot-product of unsigned shorts, 0 otherwise.
2531 # This won't change for different subtargets so cache the result.
2533 proc check_effective_target_vect_udot_hi { } {
2534 global et_vect_udot_hi
2536 if [info exists et_vect_udot_hi_saved] {
2537 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2539 set et_vect_udot_hi_saved 0
2540 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2541 set et_vect_udot_hi_saved 1
2544 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2545 return $et_vect_udot_hi_saved
2549 # Return 1 if the target plus current options supports a vector
2550 # demotion (packing) of shorts (to chars) and ints (to shorts)
2551 # using modulo arithmetic, 0 otherwise.
2553 # This won't change for different subtargets so cache the result.
2555 proc check_effective_target_vect_pack_trunc { } {
2556 global et_vect_pack_trunc
2558 if [info exists et_vect_pack_trunc_saved] {
2559 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2561 set et_vect_pack_trunc_saved 0
2562 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2563 || [istarget i?86-*-*]
2564 || [istarget x86_64-*-*]
2565 || [istarget spu-*-*] } {
2566 set et_vect_pack_trunc_saved 1
2569 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2570 return $et_vect_pack_trunc_saved
2573 # Return 1 if the target plus current options supports a vector
2574 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2576 # This won't change for different subtargets so cache the result.
2578 proc check_effective_target_vect_unpack { } {
2579 global et_vect_unpack
2581 if [info exists et_vect_unpack_saved] {
2582 verbose "check_effective_target_vect_unpack: using cached result" 2
2584 set et_vect_unpack_saved 0
2585 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2586 || [istarget i?86-*-*]
2587 || [istarget x86_64-*-*]
2588 || [istarget spu-*-*] } {
2589 set et_vect_unpack_saved 1
2592 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2593 return $et_vect_unpack_saved
2596 # Return 1 if the target plus current options does not guarantee
2597 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2599 # This won't change for different subtargets so cache the result.
2601 proc check_effective_target_unaligned_stack { } {
2602 global et_unaligned_stack_saved
2604 if [info exists et_unaligned_stack_saved] {
2605 verbose "check_effective_target_unaligned_stack: using cached result" 2
2607 set et_unaligned_stack_saved 0
2609 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2610 return $et_unaligned_stack_saved
2613 # Return 1 if the target plus current options does not support a vector
2614 # alignment mechanism, 0 otherwise.
2616 # This won't change for different subtargets so cache the result.
2618 proc check_effective_target_vect_no_align { } {
2619 global et_vect_no_align_saved
2621 if [info exists et_vect_no_align_saved] {
2622 verbose "check_effective_target_vect_no_align: using cached result" 2
2624 set et_vect_no_align_saved 0
2625 if { [istarget mipsisa64*-*-*]
2626 || [istarget sparc*-*-*]
2627 || [istarget ia64-*-*]
2628 || [check_effective_target_arm32] } {
2629 set et_vect_no_align_saved 1
2632 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2633 return $et_vect_no_align_saved
2636 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2638 # This won't change for different subtargets so cache the result.
2640 proc check_effective_target_vect_hw_misalign { } {
2641 global et_vect_hw_misalign_saved
2643 if [info exists et_vect_hw_misalign_saved] {
2644 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2646 set et_vect_hw_misalign_saved 0
2647 if { ([istarget x86_64-*-*]
2648 || [istarget i?86-*-*]) } {
2649 set et_vect_hw_misalign_saved 1
2652 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2653 return $et_vect_hw_misalign_saved
2657 # Return 1 if arrays are aligned to the vector alignment
2658 # boundary, 0 otherwise.
2660 # This won't change for different subtargets so cache the result.
2662 proc check_effective_target_vect_aligned_arrays { } {
2663 global et_vect_aligned_arrays
2665 if [info exists et_vect_aligned_arrays_saved] {
2666 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2668 set et_vect_aligned_arrays_saved 0
2669 if { (([istarget x86_64-*-*]
2670 || [istarget i?86-*-*]) && [is-effective-target lp64])
2671 || [istarget spu-*-*] } {
2672 set et_vect_aligned_arrays_saved 1
2675 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2676 return $et_vect_aligned_arrays_saved
2679 # Return 1 if types of size 32 bit or less are naturally aligned
2680 # (aligned to their type-size), 0 otherwise.
2682 # This won't change for different subtargets so cache the result.
2684 proc check_effective_target_natural_alignment_32 { } {
2685 global et_natural_alignment_32
2687 if [info exists et_natural_alignment_32_saved] {
2688 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2690 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2691 set et_natural_alignment_32_saved 1
2692 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2693 set et_natural_alignment_32_saved 0
2696 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2697 return $et_natural_alignment_32_saved
2700 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2701 # type-size), 0 otherwise.
2703 # This won't change for different subtargets so cache the result.
2705 proc check_effective_target_natural_alignment_64 { } {
2706 global et_natural_alignment_64
2708 if [info exists et_natural_alignment_64_saved] {
2709 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2711 set et_natural_alignment_64_saved 0
2712 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2713 || [istarget spu-*-*] } {
2714 set et_natural_alignment_64_saved 1
2717 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2718 return $et_natural_alignment_64_saved
2721 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2723 # This won't change for different subtargets so cache the result.
2725 proc check_effective_target_vector_alignment_reachable { } {
2726 global et_vector_alignment_reachable
2728 if [info exists et_vector_alignment_reachable_saved] {
2729 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2731 if { [check_effective_target_vect_aligned_arrays]
2732 || [check_effective_target_natural_alignment_32] } {
2733 set et_vector_alignment_reachable_saved 1
2735 set et_vector_alignment_reachable_saved 0
2738 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2739 return $et_vector_alignment_reachable_saved
2742 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2744 # This won't change for different subtargets so cache the result.
2746 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2747 global et_vector_alignment_reachable_for_64bit
2749 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2750 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2752 if { [check_effective_target_vect_aligned_arrays]
2753 || [check_effective_target_natural_alignment_64] } {
2754 set et_vector_alignment_reachable_for_64bit_saved 1
2756 set et_vector_alignment_reachable_for_64bit_saved 0
2759 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2760 return $et_vector_alignment_reachable_for_64bit_saved
2763 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2765 proc check_effective_target_vect_condition { } {
2766 global et_vect_cond_saved
2768 if [info exists et_vect_cond_saved] {
2769 verbose "check_effective_target_vect_cond: using cached result" 2
2771 set et_vect_cond_saved 0
2772 if { [istarget powerpc*-*-*]
2773 || [istarget ia64-*-*]
2774 || [istarget i?86-*-*]
2775 || [istarget spu-*-*]
2776 || [istarget x86_64-*-*] } {
2777 set et_vect_cond_saved 1
2781 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2782 return $et_vect_cond_saved
2785 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2787 proc check_effective_target_vect_char_mult { } {
2788 global et_vect_char_mult_saved
2790 if [info exists et_vect_char_mult_saved] {
2791 verbose "check_effective_target_vect_char_mult: using cached result" 2
2793 set et_vect_char_mult_saved 0
2794 if { [istarget ia64-*-*]
2795 || [istarget i?86-*-*]
2796 || [istarget x86_64-*-*] } {
2797 set et_vect_char_mult_saved 1
2801 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2802 return $et_vect_char_mult_saved
2805 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2807 proc check_effective_target_vect_short_mult { } {
2808 global et_vect_short_mult_saved
2810 if [info exists et_vect_short_mult_saved] {
2811 verbose "check_effective_target_vect_short_mult: using cached result" 2
2813 set et_vect_short_mult_saved 0
2814 if { [istarget ia64-*-*]
2815 || [istarget spu-*-*]
2816 || [istarget i?86-*-*]
2817 || [istarget x86_64-*-*]
2818 || [istarget powerpc*-*-*]
2819 || [check_effective_target_arm32] } {
2820 set et_vect_short_mult_saved 1
2824 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2825 return $et_vect_short_mult_saved
2828 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2830 proc check_effective_target_vect_int_mult { } {
2831 global et_vect_int_mult_saved
2833 if [info exists et_vect_int_mult_saved] {
2834 verbose "check_effective_target_vect_int_mult: using cached result" 2
2836 set et_vect_int_mult_saved 0
2837 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2838 || [istarget spu-*-*]
2839 || [istarget i?86-*-*]
2840 || [istarget x86_64-*-*]
2841 || [check_effective_target_arm32] } {
2842 set et_vect_int_mult_saved 1
2846 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2847 return $et_vect_int_mult_saved
2850 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2852 proc check_effective_target_vect_extract_even_odd { } {
2853 global et_vect_extract_even_odd_saved
2855 if [info exists et_vect_extract_even_odd_saved] {
2856 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2858 set et_vect_extract_even_odd_saved 0
2859 if { [istarget powerpc*-*-*]
2860 || [istarget i?86-*-*]
2861 || [istarget x86_64-*-*]
2862 || [istarget spu-*-*] } {
2863 set et_vect_extract_even_odd_saved 1
2867 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2868 return $et_vect_extract_even_odd_saved
2871 # Return 1 if the target supports vector even/odd elements extraction of
2872 # vectors with SImode elements or larger, 0 otherwise.
2874 proc check_effective_target_vect_extract_even_odd_wide { } {
2875 global et_vect_extract_even_odd_wide_saved
2877 if [info exists et_vect_extract_even_odd_wide_saved] {
2878 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2880 set et_vect_extract_even_odd_wide_saved 0
2881 if { [istarget powerpc*-*-*]
2882 || [istarget i?86-*-*]
2883 || [istarget x86_64-*-*]
2884 || [istarget spu-*-*] } {
2885 set et_vect_extract_even_odd_wide_saved 1
2889 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2890 return $et_vect_extract_even_odd_wide_saved
2893 # Return 1 if the target supports vector interleaving, 0 otherwise.
2895 proc check_effective_target_vect_interleave { } {
2896 global et_vect_interleave_saved
2898 if [info exists et_vect_interleave_saved] {
2899 verbose "check_effective_target_vect_interleave: using cached result" 2
2901 set et_vect_interleave_saved 0
2902 if { [istarget powerpc*-*-*]
2903 || [istarget i?86-*-*]
2904 || [istarget x86_64-*-*]
2905 || [istarget spu-*-*] } {
2906 set et_vect_interleave_saved 1
2910 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2911 return $et_vect_interleave_saved
2914 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2915 proc check_effective_target_vect_strided { } {
2916 global et_vect_strided_saved
2918 if [info exists et_vect_strided_saved] {
2919 verbose "check_effective_target_vect_strided: using cached result" 2
2921 set et_vect_strided_saved 0
2922 if { [check_effective_target_vect_interleave]
2923 && [check_effective_target_vect_extract_even_odd] } {
2924 set et_vect_strided_saved 1
2928 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2929 return $et_vect_strided_saved
2932 # Return 1 if the target supports vector interleaving and extract even/odd
2933 # for wide element types, 0 otherwise.
2934 proc check_effective_target_vect_strided_wide { } {
2935 global et_vect_strided_wide_saved
2937 if [info exists et_vect_strided_wide_saved] {
2938 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2940 set et_vect_strided_wide_saved 0
2941 if { [check_effective_target_vect_interleave]
2942 && [check_effective_target_vect_extract_even_odd_wide] } {
2943 set et_vect_strided_wide_saved 1
2947 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2948 return $et_vect_strided_wide_saved
2951 # Return 1 if the target supports section-anchors
2953 proc check_effective_target_section_anchors { } {
2954 global et_section_anchors_saved
2956 if [info exists et_section_anchors_saved] {
2957 verbose "check_effective_target_section_anchors: using cached result" 2
2959 set et_section_anchors_saved 0
2960 if { [istarget powerpc*-*-*]
2961 || [istarget arm*-*-*] } {
2962 set et_section_anchors_saved 1
2966 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2967 return $et_section_anchors_saved
2970 # Return 1 if the target supports atomic operations on "int" and "long".
2972 proc check_effective_target_sync_int_long { } {
2973 global et_sync_int_long_saved
2975 if [info exists et_sync_int_long_saved] {
2976 verbose "check_effective_target_sync_int_long: using cached result" 2
2978 set et_sync_int_long_saved 0
2979 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2980 # load-reserved/store-conditional instructions.
2981 if { [istarget ia64-*-*]
2982 || [istarget i?86-*-*]
2983 || [istarget x86_64-*-*]
2984 || [istarget alpha*-*-*]
2985 || [istarget bfin*-*linux*]
2986 || [istarget s390*-*-*]
2987 || [istarget powerpc*-*-*]
2988 || [istarget sparc64-*-*]
2989 || [istarget sparcv9-*-*]
2990 || [istarget mips*-*-*] } {
2991 set et_sync_int_long_saved 1
2995 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2996 return $et_sync_int_long_saved
2999 # Return 1 if the target supports atomic operations on "char" and "short".
3001 proc check_effective_target_sync_char_short { } {
3002 global et_sync_char_short_saved
3004 if [info exists et_sync_char_short_saved] {
3005 verbose "check_effective_target_sync_char_short: using cached result" 2
3007 set et_sync_char_short_saved 0
3008 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3009 # load-reserved/store-conditional instructions.
3010 if { [istarget ia64-*-*]
3011 || [istarget i?86-*-*]
3012 || [istarget x86_64-*-*]
3013 || [istarget alpha*-*-*]
3014 || [istarget s390*-*-*]
3015 || [istarget powerpc*-*-*]
3016 || [istarget sparc64-*-*]
3017 || [istarget sparcv9-*-*]
3018 || [istarget mips*-*-*] } {
3019 set et_sync_char_short_saved 1
3023 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3024 return $et_sync_char_short_saved
3027 # Return 1 if the target uses a ColdFire FPU.
3029 proc check_effective_target_coldfire_fpu { } {
3030 return [check_no_compiler_messages coldfire_fpu assembly {
3037 # Return true if this is a uClibc target.
3039 proc check_effective_target_uclibc {} {
3040 return [check_no_compiler_messages uclibc object {
3041 #include <features.h>
3042 #if !defined (__UCLIBC__)
3048 # Return true if this is a uclibc target and if the uclibc feature
3049 # described by __$feature__ is not present.
3051 proc check_missing_uclibc_feature {feature} {
3052 return [check_no_compiler_messages $feature object "
3053 #include <features.h>
3054 #if !defined (__UCLIBC) || defined (__${feature}__)
3060 # Return true if this is a Newlib target.
3062 proc check_effective_target_newlib {} {
3063 return [check_no_compiler_messages newlib object {
3069 # (a) an error of a few ULP is expected in string to floating-point
3070 # conversion functions; and
3071 # (b) overflow is not always detected correctly by those functions.
3073 proc check_effective_target_lax_strtofp {} {
3074 # By default, assume that all uClibc targets suffer from this.
3075 return [check_effective_target_uclibc]
3078 # Return 1 if this is a target for which wcsftime is a dummy
3079 # function that always returns 0.
3081 proc check_effective_target_dummy_wcsftime {} {
3082 # By default, assume that all uClibc targets suffer from this.
3083 return [check_effective_target_uclibc]
3086 # Return 1 if constructors with initialization priority arguments are
3087 # supposed on this target.
3089 proc check_effective_target_init_priority {} {
3090 return [check_no_compiler_messages init_priority assembly "
3091 void f() __attribute__((constructor (1000)));
3096 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3097 # This can be used with any check_* proc that takes no argument and
3098 # returns only 1 or 0. It could be used with check_* procs that take
3099 # arguments with keywords that pass particular arguments.
3101 proc is-effective-target { arg } {
3103 if { [info procs check_effective_target_${arg}] != [list] } {
3104 set selected [check_effective_target_${arg}]
3107 "vmx_hw" { set selected [check_vmx_hw_available] }
3108 "vsx_hw" { set selected [check_vsx_hw_available] }
3109 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3110 "named_sections" { set selected [check_named_sections_available] }
3111 "gc_sections" { set selected [check_gc_sections_available] }
3112 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3113 default { error "unknown effective target keyword `$arg'" }
3116 verbose "is-effective-target: $arg $selected" 2
3120 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3122 proc is-effective-target-keyword { arg } {
3123 if { [info procs check_effective_target_${arg}] != [list] } {
3126 # These have different names for their check_* procs.
3128 "vmx_hw" { return 1 }
3129 "vsx_hw" { return 1 }
3130 "ppc_recip_hw" { return 1 }
3131 "named_sections" { return 1 }
3132 "gc_sections" { return 1 }
3133 "cxa_atexit" { return 1 }
3134 default { return 0 }
3139 # Return 1 if target default to short enums
3141 proc check_effective_target_short_enums { } {
3142 return [check_no_compiler_messages short_enums assembly {
3144 int s[sizeof (enum foo) == 1 ? 1 : -1];
3148 # Return 1 if target supports merging string constants at link time.
3150 proc check_effective_target_string_merging { } {
3151 return [check_no_messages_and_pattern string_merging \
3152 "rodata\\.str" assembly {
3153 const char *var = "String";
3157 # Return 1 if target has the basic signed and unsigned types in
3158 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3159 # working <stdint.h> for all targets.
3161 proc check_effective_target_stdint_types { } {
3162 return [check_no_compiler_messages stdint_types assembly {
3164 int8_t a; int16_t b; int32_t c; int64_t d;
3165 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3169 # Return 1 if target has the basic signed and unsigned types in
3170 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3171 # these types agree with those in the header, as some systems have
3172 # only <inttypes.h>.
3174 proc check_effective_target_inttypes_types { } {
3175 return [check_no_compiler_messages inttypes_types assembly {
3176 #include <inttypes.h>
3177 int8_t a; int16_t b; int32_t c; int64_t d;
3178 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3182 # Return 1 if programs are intended to be run on a simulator
3183 # (i.e. slowly) rather than hardware (i.e. fast).
3185 proc check_effective_target_simulator { } {
3187 # All "src/sim" simulators set this one.
3188 if [board_info target exists is_simulator] {
3189 return [board_info target is_simulator]
3192 # The "sid" simulators don't set that one, but at least they set
3194 if [board_info target exists slow_simulator] {
3195 return [board_info target slow_simulator]
3201 # Return 1 if the target is a VxWorks kernel.
3203 proc check_effective_target_vxworks_kernel { } {
3204 return [check_no_compiler_messages vxworks_kernel assembly {
3205 #if !defined __vxworks || defined __RTP__
3211 # Return 1 if the target is a VxWorks RTP.
3213 proc check_effective_target_vxworks_rtp { } {
3214 return [check_no_compiler_messages vxworks_rtp assembly {
3215 #if !defined __vxworks || !defined __RTP__
3221 # Return 1 if the target is expected to provide wide character support.
3223 proc check_effective_target_wchar { } {
3224 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3227 return [check_no_compiler_messages wchar assembly {
3232 # Return 1 if the target has <pthread.h>.
3234 proc check_effective_target_pthread_h { } {
3235 return [check_no_compiler_messages pthread_h assembly {
3236 #include <pthread.h>
3240 # Return 1 if the target can truncate a file from a file-descriptor,
3241 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3242 # chsize. We test for a trivially functional truncation; no stubs.
3243 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3244 # different function to be used.
3246 proc check_effective_target_fd_truncate { } {
3248 #define _FILE_OFFSET_BITS 64
3254 FILE *f = fopen ("tst.tmp", "wb");
3256 const char t[] = "test writing more than ten characters";
3259 write (fd, t, sizeof (t) - 1);
3261 if (ftruncate (fd, 10) != 0)
3264 f = fopen ("tst.tmp", "rb");
3265 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3271 if { [check_runtime ftruncate $prog] } {
3275 regsub "ftruncate" $prog "chsize" prog
3276 return [check_runtime chsize $prog]
3279 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3281 proc add_options_for_c99_runtime { flags } {
3282 if { [istarget *-*-solaris2*] } {
3283 return "$flags -std=c99"
3285 if { [istarget powerpc-*-darwin*] } {
3286 return "$flags -mmacosx-version-min=10.3"
3291 # Add to FLAGS all the target-specific flags needed to enable
3292 # full IEEE compliance mode.
3294 proc add_options_for_ieee { flags } {
3295 if { [istarget "alpha*-*-*"]
3296 || [istarget "sh*-*-*"] } {
3297 return "$flags -mieee"
3302 # Add to FLAGS the flags needed to enable functions to bind locally
3303 # when using pic/PIC passes in the testsuite.
3305 proc add_options_for_bind_pic_locally { flags } {
3306 if {[check_no_compiler_messages using_pic2 assembly {
3311 return "$flags -fPIE"
3313 if {[check_no_compiler_messages using_pic1 assembly {
3318 return "$flags -fpie"
3324 # Return 1 if the target provides a full C99 runtime.
3326 proc check_effective_target_c99_runtime { } {
3327 return [check_cached_effective_target c99_runtime {
3330 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3331 set contents [read $file]
3334 #ifndef HAVE_C99_RUNTIME
3338 check_no_compiler_messages_nocache c99_runtime assembly \
3339 $contents [add_options_for_c99_runtime ""]
3343 # Return 1 if target wchar_t is at least 4 bytes.
3345 proc check_effective_target_4byte_wchar_t { } {
3346 return [check_no_compiler_messages 4byte_wchar_t object {
3347 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3351 # Return 1 if the target supports automatic stack alignment.
3353 proc check_effective_target_automatic_stack_alignment { } {
3354 if { [istarget i?86*-*-*]
3355 || [istarget x86_64-*-*] } then {
3362 # Return 1 if avx instructions can be compiled.
3364 proc check_effective_target_avx { } {
3365 return [check_no_compiler_messages avx object {
3366 void _mm256_zeroall (void)
3368 __builtin_ia32_vzeroall ();
3373 # Return 1 if sse instructions can be compiled.
3374 proc check_effective_target_sse { } {
3375 return [check_no_compiler_messages sse object {
3378 __builtin_ia32_stmxcsr ();
3384 # Return 1 if sse2 instructions can be compiled.
3385 proc check_effective_target_sse2 { } {
3386 return [check_no_compiler_messages sse2 object {
3387 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3389 __m128i _mm_srli_si128 (__m128i __A, int __N)
3391 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3396 # Return 1 if F16C instructions can be compiled.
3398 proc check_effective_target_f16c { } {
3399 return [check_no_compiler_messages f16c object {
3400 #include "immintrin.h"
3402 foo (unsigned short val)
3404 return _cvtsh_ss (val);
3409 # Return 1 if C wchar_t type is compatible with char16_t.
3411 proc check_effective_target_wchar_t_char16_t_compatible { } {
3412 return [check_no_compiler_messages wchar_t_char16_t object {
3414 __CHAR16_TYPE__ *p16 = &wc;
3415 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3419 # Return 1 if C wchar_t type is compatible with char32_t.
3421 proc check_effective_target_wchar_t_char32_t_compatible { } {
3422 return [check_no_compiler_messages wchar_t_char32_t object {
3424 __CHAR32_TYPE__ *p32 = &wc;
3425 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3429 # Return 1 if pow10 function exists.
3431 proc check_effective_target_pow10 { } {
3432 return [check_runtime pow10 {
3442 # Return 1 if current options generate DFP instructions, 0 otherwise.
3444 proc check_effective_target_hard_dfp {} {
3445 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3446 typedef float d64 __attribute__((mode(DD)));
3448 void foo (void) { z = x + y; }
3452 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3453 # for strchr etc. functions.
3455 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3456 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3459 #if !defined(__cplusplus) \
3460 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3461 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3462 ISO C++ correct string.h and wchar.h protos not supported.
3469 # Return 1 if GNU as is used.
3471 proc check_effective_target_gas { } {
3472 global use_gas_saved
3475 if {![info exists use_gas_saved]} {
3476 # Check if the as used by gcc is GNU as.
3477 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3478 # Provide /dev/null as input, otherwise gas times out reading from
3480 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3481 set as_output [lindex $status 1]
3482 if { [ string first "GNU" $as_output ] >= 0 } {
3488 return $use_gas_saved
3491 # Return 1 if the compiler has been configure with link-time optimization
3494 proc check_effective_target_lto { } {
3496 return [info exists ENABLE_LTO]
3499 # Return 1 if the language for the compiler under test is C.
3501 proc check_effective_target_c { } {
3503 if [string match $tool "gcc"] {
3509 # Return 1 if the language for the compiler under test is C++.
3511 proc check_effective_target_c++ { } {
3513 if [string match $tool "g++"] {