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 # Return 1 if the target supports executing 750CL paired-single instructions, 0
890 # otherwise. Cache the result.
892 proc check_750cl_hw_available { } {
893 return [check_cached_effective_target 750cl_hw_available {
894 # If this is not the right target then we can skip the test.
895 if { ![istarget powerpc-*paired*] } {
898 check_runtime_nocache 750cl_hw_available {
902 asm volatile ("ps_mul v0,v0,v0");
904 asm volatile ("ps_mul 0,0,0");
913 # Return 1 if the target OS supports running SSE executables, 0
914 # otherwise. Cache the result.
916 proc check_sse_os_support_available { } {
917 return [check_cached_effective_target sse_os_support_available {
918 # If this is not the right target then we can skip the test.
919 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
921 } elseif { [istarget i?86-*-solaris2*] } {
922 # The Solaris 2 kernel doesn't save and restore SSE registers
923 # before Solaris 9 4/04. Before that, executables die with SIGILL.
924 check_runtime_nocache sse_os_support_available {
927 __asm__ volatile ("movss %xmm2,%xmm1");
937 # Return 1 if the target supports executing SSE instructions, 0
938 # otherwise. Cache the result.
940 proc check_sse_hw_available { } {
941 return [check_cached_effective_target sse_hw_available {
942 # If this is not the right target then we can skip the test.
943 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
946 check_runtime_nocache sse_hw_available {
950 unsigned int eax, ebx, ecx, edx = 0;
951 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
952 return !(edx & bit_SSE);
960 # Return 1 if the target supports executing SSE2 instructions, 0
961 # otherwise. Cache the result.
963 proc check_sse2_hw_available { } {
964 return [check_cached_effective_target sse2_hw_available {
965 # If this is not the right target then we can skip the test.
966 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
969 check_runtime_nocache sse2_hw_available {
973 unsigned int eax, ebx, ecx, edx = 0;
974 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
975 return !(edx & bit_SSE2);
983 # Return 1 if the target supports running SSE executables, 0 otherwise.
985 proc check_effective_target_sse_runtime { } {
986 if { [check_sse_hw_available] && [check_sse_os_support_available] } {
993 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
995 proc check_effective_target_sse2_runtime { } {
996 if { [check_sse2_hw_available] && [check_sse_os_support_available] } {
1003 # Return 1 if the target supports executing VSX instructions, 0
1004 # otherwise. Cache the result.
1006 proc check_vsx_hw_available { } {
1007 return [check_cached_effective_target vsx_hw_available {
1008 # Some simulators are known to not support VSX instructions.
1009 # For now, disable on Darwin
1010 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1014 check_runtime_nocache vsx_hw_available {
1018 asm volatile ("xxlor vs0,vs0,vs0");
1020 asm volatile ("xxlor 0,0,0");
1029 # Return 1 if the target supports executing AltiVec instructions, 0
1030 # otherwise. Cache the result.
1032 proc check_vmx_hw_available { } {
1033 return [check_cached_effective_target vmx_hw_available {
1034 # Some simulators are known to not support VMX instructions.
1035 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1038 # Most targets don't require special flags for this test case, but
1039 # Darwin does. Just to be sure, make sure VSX is not enabled for
1040 # the altivec tests.
1041 if { [istarget *-*-darwin*]
1042 || [istarget *-*-aix*] } {
1043 set options "-maltivec -mno-vsx"
1045 set options "-mno-vsx"
1047 check_runtime_nocache vmx_hw_available {
1051 asm volatile ("vor v0,v0,v0");
1053 asm volatile ("vor 0,0,0");
1062 proc check_ppc_recip_hw_available { } {
1063 return [check_cached_effective_target ppc_recip_hw_available {
1064 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1065 # For now, disable on Darwin
1066 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1069 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1070 check_runtime_nocache ppc_recip_hw_available {
1071 volatile double d_recip, d_rsqrt, d_four = 4.0;
1072 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1075 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1076 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1077 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1078 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1086 # Return 1 if the target supports executing AltiVec and Cell PPU
1087 # instructions, 0 otherwise. Cache the result.
1089 proc check_effective_target_cell_hw { } {
1090 return [check_cached_effective_target cell_hw_available {
1091 # Some simulators are known to not support VMX and PPU instructions.
1092 if { [istarget powerpc-*-eabi*] } {
1095 # Most targets don't require special flags for this test
1096 # case, but Darwin and AIX do.
1097 if { [istarget *-*-darwin*]
1098 || [istarget *-*-aix*] } {
1099 set options "-maltivec -mcpu=cell"
1101 set options "-mcpu=cell"
1103 check_runtime_nocache cell_hw_available {
1107 asm volatile ("vor v0,v0,v0");
1108 asm volatile ("lvlx v0,r0,r0");
1110 asm volatile ("vor 0,0,0");
1111 asm volatile ("lvlx 0,0,0");
1120 # Return 1 if the target supports executing 64-bit instructions, 0
1121 # otherwise. Cache the result.
1123 proc check_effective_target_powerpc64 { } {
1124 global powerpc64_available_saved
1127 if [info exists powerpc64_available_saved] {
1128 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1130 set powerpc64_available_saved 0
1132 # Some simulators are known to not support powerpc64 instructions.
1133 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1134 verbose "check_effective_target_powerpc64 returning 0" 2
1135 return $powerpc64_available_saved
1138 # Set up, compile, and execute a test program containing a 64-bit
1139 # instruction. Include the current process ID in the file
1140 # names to prevent conflicts with invocations for multiple
1145 set f [open $src "w"]
1146 puts $f "int main() {"
1147 puts $f "#ifdef __MACH__"
1148 puts $f " asm volatile (\"extsw r0,r0\");"
1150 puts $f " asm volatile (\"extsw 0,0\");"
1152 puts $f " return 0; }"
1155 set opts "additional_flags=-mcpu=G5"
1157 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1158 set lines [${tool}_target_compile $src $exe executable "$opts"]
1161 if [string match "" $lines] then {
1162 # No error message, compilation succeeded.
1163 set result [${tool}_load "./$exe" "" ""]
1164 set status [lindex $result 0]
1165 remote_file build delete $exe
1166 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1168 if { $status == "pass" } then {
1169 set powerpc64_available_saved 1
1172 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1176 return $powerpc64_available_saved
1179 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1180 # complex float arguments. This affects gfortran tests that call cabsf
1181 # in libm built by an earlier compiler. Return 1 if libm uses the same
1182 # argument passing as the compiler under test, 0 otherwise.
1184 # When the target name changes, replace the cached result.
1186 proc check_effective_target_broken_cplxf_arg { } {
1187 return [check_cached_effective_target broken_cplxf_arg {
1188 # Skip the work for targets known not to be affected.
1189 if { ![istarget powerpc64-*-linux*] } {
1191 } elseif { ![is-effective-target lp64] } {
1194 check_runtime_nocache broken_cplxf_arg {
1195 #include <complex.h>
1196 extern void abort (void);
1197 float fabsf (float);
1198 float cabsf (_Complex float);
1205 if (fabsf (f - 5.0) > 0.0001)
1214 proc check_alpha_max_hw_available { } {
1215 return [check_runtime alpha_max_hw_available {
1216 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1220 # Returns true iff the FUNCTION is available on the target system.
1221 # (This is essentially a Tcl implementation of Autoconf's
1224 proc check_function_available { function } {
1225 return [check_no_compiler_messages ${function}_available \
1231 int main () { $function (); }
1235 # Returns true iff "fork" is available on the target system.
1237 proc check_fork_available {} {
1238 return [check_function_available "fork"]
1241 # Returns true iff "mkfifo" is available on the target system.
1243 proc check_mkfifo_available {} {
1244 if {[istarget *-*-cygwin*]} {
1245 # Cygwin has mkfifo, but support is incomplete.
1249 return [check_function_available "mkfifo"]
1252 # Returns true iff "__cxa_atexit" is used on the target system.
1254 proc check_cxa_atexit_available { } {
1255 return [check_cached_effective_target cxa_atexit_available {
1256 if { [istarget "hppa*-*-hpux10*"] } {
1257 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1259 } elseif { [istarget "*-*-vxworks"] } {
1260 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1263 check_runtime_nocache cxa_atexit_available {
1266 static unsigned int count;
1283 Y() { f(); count = 2; }
1292 int main() { return 0; }
1298 proc check_effective_target_objc2 { } {
1299 return [check_no_compiler_messages objc2 object {
1308 proc check_effective_target_next_runtime { } {
1309 return [check_no_compiler_messages objc2 object {
1310 #ifdef __NEXT_RUNTIME__
1318 # Return 1 if we're generating 32-bit code using default options, 0
1321 proc check_effective_target_ilp32 { } {
1322 return [check_no_compiler_messages ilp32 object {
1323 int dummy[sizeof (int) == 4
1324 && sizeof (void *) == 4
1325 && sizeof (long) == 4 ? 1 : -1];
1329 # Return 1 if we're generating 32-bit or larger integers using default
1330 # options, 0 otherwise.
1332 proc check_effective_target_int32plus { } {
1333 return [check_no_compiler_messages int32plus object {
1334 int dummy[sizeof (int) >= 4 ? 1 : -1];
1338 # Return 1 if we're generating 32-bit or larger pointers using default
1339 # options, 0 otherwise.
1341 proc check_effective_target_ptr32plus { } {
1342 return [check_no_compiler_messages ptr32plus object {
1343 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1347 # Return 1 if we support 32-bit or larger array and structure sizes
1348 # using default options, 0 otherwise.
1350 proc check_effective_target_size32plus { } {
1351 return [check_no_compiler_messages size32plus object {
1356 # Returns 1 if we're generating 16-bit or smaller integers with the
1357 # default options, 0 otherwise.
1359 proc check_effective_target_int16 { } {
1360 return [check_no_compiler_messages int16 object {
1361 int dummy[sizeof (int) < 4 ? 1 : -1];
1365 # Return 1 if we're generating 64-bit code using default options, 0
1368 proc check_effective_target_lp64 { } {
1369 return [check_no_compiler_messages lp64 object {
1370 int dummy[sizeof (int) == 4
1371 && sizeof (void *) == 8
1372 && sizeof (long) == 8 ? 1 : -1];
1376 # Return 1 if we're generating 64-bit code using default llp64 options,
1379 proc check_effective_target_llp64 { } {
1380 return [check_no_compiler_messages llp64 object {
1381 int dummy[sizeof (int) == 4
1382 && sizeof (void *) == 8
1383 && sizeof (long long) == 8
1384 && sizeof (long) == 4 ? 1 : -1];
1388 # Return 1 if the target supports long double larger than double,
1391 proc check_effective_target_large_long_double { } {
1392 return [check_no_compiler_messages large_long_double object {
1393 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1397 # Return 1 if the target supports double larger than float,
1400 proc check_effective_target_large_double { } {
1401 return [check_no_compiler_messages large_double object {
1402 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1406 # Return 1 if the target supports double of 64 bits,
1409 proc check_effective_target_double64 { } {
1410 return [check_no_compiler_messages double64 object {
1411 int dummy[sizeof(double) == 8 ? 1 : -1];
1415 # Return 1 if the target supports double of at least 64 bits,
1418 proc check_effective_target_double64plus { } {
1419 return [check_no_compiler_messages double64plus object {
1420 int dummy[sizeof(double) >= 8 ? 1 : -1];
1424 # Return 1 if the target supports compiling fixed-point,
1427 proc check_effective_target_fixed_point { } {
1428 return [check_no_compiler_messages fixed_point object {
1429 _Sat _Fract x; _Sat _Accum y;
1433 # Return 1 if the target supports compiling decimal floating point,
1436 proc check_effective_target_dfp_nocache { } {
1437 verbose "check_effective_target_dfp_nocache: compiling source" 2
1438 set ret [check_no_compiler_messages_nocache dfp object {
1439 float x __attribute__((mode(DD)));
1441 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1445 proc check_effective_target_dfprt_nocache { } {
1446 return [check_runtime_nocache dfprt {
1447 typedef float d64 __attribute__((mode(DD)));
1448 d64 x = 1.2df, y = 2.3dd, z;
1449 int main () { z = x + y; return 0; }
1453 # Return 1 if the target supports compiling Decimal Floating Point,
1456 # This won't change for different subtargets so cache the result.
1458 proc check_effective_target_dfp { } {
1459 return [check_cached_effective_target dfp {
1460 check_effective_target_dfp_nocache
1464 # Return 1 if the target supports linking and executing Decimal Floating
1465 # Point, 0 otherwise.
1467 # This won't change for different subtargets so cache the result.
1469 proc check_effective_target_dfprt { } {
1470 return [check_cached_effective_target dfprt {
1471 check_effective_target_dfprt_nocache
1475 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1477 proc check_effective_target_ucn_nocache { } {
1478 # -std=c99 is only valid for C
1479 if [check_effective_target_c] {
1480 set ucnopts "-std=c99"
1482 append ucnopts " -fextended-identifiers"
1483 verbose "check_effective_target_ucn_nocache: compiling source" 2
1484 set ret [check_no_compiler_messages_nocache ucn object {
1487 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1491 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1493 # This won't change for different subtargets, so cache the result.
1495 proc check_effective_target_ucn { } {
1496 return [check_cached_effective_target ucn {
1497 check_effective_target_ucn_nocache
1501 # Return 1 if the target needs a command line argument to enable a SIMD
1504 proc check_effective_target_vect_cmdline_needed { } {
1505 global et_vect_cmdline_needed_saved
1506 global et_vect_cmdline_needed_target_name
1508 if { ![info exists et_vect_cmdline_needed_target_name] } {
1509 set et_vect_cmdline_needed_target_name ""
1512 # If the target has changed since we set the cached value, clear it.
1513 set current_target [current_target_name]
1514 if { $current_target != $et_vect_cmdline_needed_target_name } {
1515 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1516 set et_vect_cmdline_needed_target_name $current_target
1517 if { [info exists et_vect_cmdline_needed_saved] } {
1518 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1519 unset et_vect_cmdline_needed_saved
1523 if [info exists et_vect_cmdline_needed_saved] {
1524 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1526 set et_vect_cmdline_needed_saved 1
1527 if { [istarget alpha*-*-*]
1528 || [istarget ia64-*-*]
1529 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1530 && [check_effective_target_lp64])
1531 || ([istarget powerpc*-*-*]
1532 && ([check_effective_target_powerpc_spe]
1533 || [check_effective_target_powerpc_altivec]))
1534 || [istarget spu-*-*]
1535 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1536 set et_vect_cmdline_needed_saved 0
1540 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1541 return $et_vect_cmdline_needed_saved
1544 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1546 # This won't change for different subtargets so cache the result.
1548 proc check_effective_target_vect_int { } {
1549 global et_vect_int_saved
1551 if [info exists et_vect_int_saved] {
1552 verbose "check_effective_target_vect_int: using cached result" 2
1554 set et_vect_int_saved 0
1555 if { [istarget i?86-*-*]
1556 || ([istarget powerpc*-*-*]
1557 && ![istarget powerpc-*-linux*paired*])
1558 || [istarget spu-*-*]
1559 || [istarget x86_64-*-*]
1560 || [istarget sparc*-*-*]
1561 || [istarget alpha*-*-*]
1562 || [istarget ia64-*-*]
1563 || [check_effective_target_arm32] } {
1564 set et_vect_int_saved 1
1568 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1569 return $et_vect_int_saved
1572 # Return 1 if the target supports signed int->float conversion
1575 proc check_effective_target_vect_intfloat_cvt { } {
1576 global et_vect_intfloat_cvt_saved
1578 if [info exists et_vect_intfloat_cvt_saved] {
1579 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1581 set et_vect_intfloat_cvt_saved 0
1582 if { [istarget i?86-*-*]
1583 || ([istarget powerpc*-*-*]
1584 && ![istarget powerpc-*-linux*paired*])
1585 || [istarget x86_64-*-*] } {
1586 set et_vect_intfloat_cvt_saved 1
1590 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1591 return $et_vect_intfloat_cvt_saved
1594 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1596 proc check_effective_target_int128 { } {
1597 return [check_no_compiler_messages int128 object {
1599 #ifndef __SIZEOF_INT128__
1608 # Return 1 if the target supports unsigned int->float conversion
1611 proc check_effective_target_vect_uintfloat_cvt { } {
1612 global et_vect_uintfloat_cvt_saved
1614 if [info exists et_vect_uintfloat_cvt_saved] {
1615 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1617 set et_vect_uintfloat_cvt_saved 0
1618 if { [istarget i?86-*-*]
1619 || ([istarget powerpc*-*-*]
1620 && ![istarget powerpc-*-linux*paired*])
1621 || [istarget x86_64-*-*] } {
1622 set et_vect_uintfloat_cvt_saved 1
1626 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1627 return $et_vect_uintfloat_cvt_saved
1631 # Return 1 if the target supports signed float->int conversion
1634 proc check_effective_target_vect_floatint_cvt { } {
1635 global et_vect_floatint_cvt_saved
1637 if [info exists et_vect_floatint_cvt_saved] {
1638 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1640 set et_vect_floatint_cvt_saved 0
1641 if { [istarget i?86-*-*]
1642 || ([istarget powerpc*-*-*]
1643 && ![istarget powerpc-*-linux*paired*])
1644 || [istarget x86_64-*-*] } {
1645 set et_vect_floatint_cvt_saved 1
1649 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1650 return $et_vect_floatint_cvt_saved
1653 # Return 1 if the target supports unsigned float->int conversion
1656 proc check_effective_target_vect_floatuint_cvt { } {
1657 global et_vect_floatuint_cvt_saved
1659 if [info exists et_vect_floatuint_cvt_saved] {
1660 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1662 set et_vect_floatuint_cvt_saved 0
1663 if { ([istarget powerpc*-*-*]
1664 && ![istarget powerpc-*-linux*paired*]) } {
1665 set et_vect_floatuint_cvt_saved 1
1669 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1670 return $et_vect_floatuint_cvt_saved
1673 # Return 1 is this is an arm target using 32-bit instructions
1674 proc check_effective_target_arm32 { } {
1675 return [check_no_compiler_messages arm32 assembly {
1676 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1682 # Return 1 if this is an ARM target supporting -mfpu=vfp
1683 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1686 proc check_effective_target_arm_vfp_ok { } {
1687 if { [check_effective_target_arm32] } {
1688 return [check_no_compiler_messages arm_vfp_ok object {
1690 } "-mfpu=vfp -mfloat-abi=softfp"]
1696 # Return 1 if this is an ARM target supporting -mfpu=vfp
1697 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1700 proc check_effective_target_arm_hard_vfp_ok { } {
1701 if { [check_effective_target_arm32] } {
1702 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1703 int main() { return 0;}
1704 } "-mfpu=vfp -mfloat-abi=hard"]
1710 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1711 # or -mfloat-abi=hard, but if one is already specified by the
1712 # multilib, use it. Similarly, if a -mfpu option already enables
1713 # NEON, do not add -mfpu=neon.
1715 proc add_options_for_arm_neon { flags } {
1716 if { ! [check_effective_target_arm_neon_ok] } {
1719 global et_arm_neon_flags
1720 return "$flags $et_arm_neon_flags"
1723 # Return 1 if this is an ARM target supporting -mfpu=neon
1724 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1725 # incompatible with these options. Also set et_arm_neon_flags to the
1726 # best options to add.
1728 proc check_effective_target_arm_neon_ok_nocache { } {
1729 global et_arm_neon_flags
1730 set et_arm_neon_flags ""
1731 if { [check_effective_target_arm32] } {
1732 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1733 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1734 #include "arm_neon.h"
1737 set et_arm_neon_flags $flags
1746 proc check_effective_target_arm_neon_ok { } {
1747 return [check_cached_effective_target arm_neon_ok \
1748 check_effective_target_arm_neon_ok_nocache]
1751 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1752 # or -mfloat-abi=hard, but if one is already specified by the
1755 proc add_options_for_arm_neon_fp16 { flags } {
1756 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1759 global et_arm_neon_fp16_flags
1760 return "$flags $et_arm_neon_fp16_flags"
1763 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1764 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1765 # incompatible with these options. Also set et_arm_neon_flags to the
1766 # best options to add.
1768 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1769 global et_arm_neon_fp16_flags
1770 set et_arm_neon_fp16_flags ""
1771 if { [check_effective_target_arm32] } {
1772 # Always add -mfpu=neon-fp16, since there is no preprocessor
1773 # macro for FP16 support.
1774 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1775 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1776 #include "arm_neon.h"
1779 set et_arm_neon_fp16_flags $flags
1788 proc check_effective_target_arm_neon_fp16_ok { } {
1789 return [check_cached_effective_target arm_neon_fp16_ok \
1790 check_effective_target_arm_neon_fp16_ok_nocache]
1793 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1796 proc check_effective_target_arm_thumb1_ok { } {
1797 return [check_no_compiler_messages arm_thumb1_ok assembly {
1798 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1804 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1807 proc check_effective_target_arm_thumb2_ok { } {
1808 return [check_no_compiler_messages arm_thumb2_ok assembly {
1809 #if !defined(__thumb2__)
1815 # Return 1 if the target supports executing NEON instructions, 0
1816 # otherwise. Cache the result.
1818 proc check_effective_target_arm_neon_hw { } {
1819 return [check_runtime arm_neon_hw_available {
1823 long long a = 0, b = 1;
1824 asm ("vorr %P0, %P1, %P2"
1826 : "0" (a), "w" (b));
1829 } [add_options_for_arm_neon ""]]
1832 # Return 1 if this is a ARM target with NEON enabled.
1834 proc check_effective_target_arm_neon { } {
1835 if { [check_effective_target_arm32] } {
1836 return [check_no_compiler_messages arm_neon object {
1837 #ifndef __ARM_NEON__
1848 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1849 # the Loongson vector modes.
1851 proc check_effective_target_mips_loongson { } {
1852 return [check_no_compiler_messages loongson assembly {
1853 #if !defined(__mips_loongson_vector_rev)
1859 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1862 proc check_effective_target_arm_eabi { } {
1863 return [check_no_compiler_messages arm_eabi object {
1864 #ifndef __ARM_EABI__
1872 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
1873 # Some multilibs may be incompatible with this option.
1875 proc check_effective_target_arm_iwmmxt_ok { } {
1876 if { [check_effective_target_arm32] } {
1877 return [check_no_compiler_messages arm_iwmmxt_ok object {
1885 # Return 1 if this is a PowerPC target with floating-point registers.
1887 proc check_effective_target_powerpc_fprs { } {
1888 if { [istarget powerpc*-*-*]
1889 || [istarget rs6000-*-*] } {
1890 return [check_no_compiler_messages powerpc_fprs object {
1902 # Return 1 if this is a PowerPC target with hardware double-precision
1905 proc check_effective_target_powerpc_hard_double { } {
1906 if { [istarget powerpc*-*-*]
1907 || [istarget rs6000-*-*] } {
1908 return [check_no_compiler_messages powerpc_hard_double object {
1920 # Return 1 if this is a PowerPC target supporting -maltivec.
1922 proc check_effective_target_powerpc_altivec_ok { } {
1923 if { ([istarget powerpc*-*-*]
1924 && ![istarget powerpc-*-linux*paired*])
1925 || [istarget rs6000-*-*] } {
1926 # AltiVec is not supported on AIX before 5.3.
1927 if { [istarget powerpc*-*-aix4*]
1928 || [istarget powerpc*-*-aix5.1*]
1929 || [istarget powerpc*-*-aix5.2*] } {
1932 return [check_no_compiler_messages powerpc_altivec_ok object {
1940 # Return 1 if this is a PowerPC target supporting -mvsx
1942 proc check_effective_target_powerpc_vsx_ok { } {
1943 if { ([istarget powerpc*-*-*]
1944 && ![istarget powerpc-*-linux*paired*])
1945 || [istarget rs6000-*-*] } {
1946 # AltiVec is not supported on AIX before 5.3.
1947 if { [istarget powerpc*-*-aix4*]
1948 || [istarget powerpc*-*-aix5.1*]
1949 || [istarget powerpc*-*-aix5.2*] } {
1952 return [check_no_compiler_messages powerpc_vsx_ok object {
1955 asm volatile ("xxlor vs0,vs0,vs0");
1957 asm volatile ("xxlor 0,0,0");
1967 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1969 proc check_effective_target_powerpc_ppu_ok { } {
1970 if [check_effective_target_powerpc_altivec_ok] {
1971 return [check_no_compiler_messages cell_asm_available object {
1974 asm volatile ("lvlx v0,v0,v0");
1976 asm volatile ("lvlx 0,0,0");
1986 # Return 1 if this is a PowerPC target that supports SPU.
1988 proc check_effective_target_powerpc_spu { } {
1989 if [istarget powerpc*-*-linux*] {
1990 return [check_effective_target_powerpc_altivec_ok]
1996 # Return 1 if this is a PowerPC SPE target. The check includes options
1997 # specified by dg-options for this test, so don't cache the result.
1999 proc check_effective_target_powerpc_spe_nocache { } {
2000 if { [istarget powerpc*-*-*] } {
2001 return [check_no_compiler_messages_nocache powerpc_spe object {
2007 } [current_compiler_flags]]
2013 # Return 1 if this is a PowerPC target with SPE enabled.
2015 proc check_effective_target_powerpc_spe { } {
2016 if { [istarget powerpc*-*-*] } {
2017 return [check_no_compiler_messages powerpc_spe object {
2029 # Return 1 if this is a PowerPC target with Altivec enabled.
2031 proc check_effective_target_powerpc_altivec { } {
2032 if { [istarget powerpc*-*-*] } {
2033 return [check_no_compiler_messages powerpc_altivec object {
2045 # Return 1 if this is a PowerPC 405 target. The check includes options
2046 # specified by dg-options for this test, so don't cache the result.
2048 proc check_effective_target_powerpc_405_nocache { } {
2049 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2050 return [check_no_compiler_messages_nocache powerpc_405 object {
2056 } [current_compiler_flags]]
2062 # Return 1 if this is a SPU target with a toolchain that
2063 # supports automatic overlay generation.
2065 proc check_effective_target_spu_auto_overlay { } {
2066 if { [istarget spu*-*-elf*] } {
2067 return [check_no_compiler_messages spu_auto_overlay executable {
2069 } "-Wl,--auto-overlay" ]
2075 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2076 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2077 # test environment appears to run executables on such a simulator.
2079 proc check_effective_target_ultrasparc_hw { } {
2080 return [check_runtime ultrasparc_hw {
2081 int main() { return 0; }
2082 } "-mcpu=ultrasparc"]
2085 # Return 1 if the target supports hardware vector shift operation.
2087 proc check_effective_target_vect_shift { } {
2088 global et_vect_shift_saved
2090 if [info exists et_vect_shift_saved] {
2091 verbose "check_effective_target_vect_shift: using cached result" 2
2093 set et_vect_shift_saved 0
2094 if { ([istarget powerpc*-*-*]
2095 && ![istarget powerpc-*-linux*paired*])
2096 || [istarget ia64-*-*]
2097 || [istarget i?86-*-*]
2098 || [istarget x86_64-*-*]
2099 || [check_effective_target_arm32] } {
2100 set et_vect_shift_saved 1
2104 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2105 return $et_vect_shift_saved
2108 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2110 # This can change for different subtargets so do not cache the result.
2112 proc check_effective_target_vect_long { } {
2113 if { [istarget i?86-*-*]
2114 || (([istarget powerpc*-*-*]
2115 && ![istarget powerpc-*-linux*paired*])
2116 && [check_effective_target_ilp32])
2117 || [istarget x86_64-*-*]
2118 || [check_effective_target_arm32]
2119 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2125 verbose "check_effective_target_vect_long: returning $answer" 2
2129 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2131 # This won't change for different subtargets so cache the result.
2133 proc check_effective_target_vect_float { } {
2134 global et_vect_float_saved
2136 if [info exists et_vect_float_saved] {
2137 verbose "check_effective_target_vect_float: using cached result" 2
2139 set et_vect_float_saved 0
2140 if { [istarget i?86-*-*]
2141 || [istarget powerpc*-*-*]
2142 || [istarget spu-*-*]
2143 || [istarget mipsisa64*-*-*]
2144 || [istarget x86_64-*-*]
2145 || [istarget ia64-*-*]
2146 || [check_effective_target_arm32] } {
2147 set et_vect_float_saved 1
2151 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2152 return $et_vect_float_saved
2155 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2157 # This won't change for different subtargets so cache the result.
2159 proc check_effective_target_vect_double { } {
2160 global et_vect_double_saved
2162 if [info exists et_vect_double_saved] {
2163 verbose "check_effective_target_vect_double: using cached result" 2
2165 set et_vect_double_saved 0
2166 if { [istarget i?86-*-*]
2167 || [istarget x86_64-*-*]
2168 || [istarget spu-*-*] } {
2169 set et_vect_double_saved 1
2173 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2174 return $et_vect_double_saved
2177 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2179 # This won't change for different subtargets so cache the result.
2181 proc check_effective_target_vect_long_long { } {
2182 global et_vect_long_long_saved
2184 if [info exists et_vect_long_long_saved] {
2185 verbose "check_effective_target_vect_long_long: using cached result" 2
2187 set et_vect_long_long_saved 0
2188 if { [istarget i?86-*-*]
2189 || [istarget x86_64-*-*] } {
2190 set et_vect_long_long_saved 1
2194 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2195 return $et_vect_long_long_saved
2199 # Return 1 if the target plus current options does not support a vector
2200 # max instruction on "int", 0 otherwise.
2202 # This won't change for different subtargets so cache the result.
2204 proc check_effective_target_vect_no_int_max { } {
2205 global et_vect_no_int_max_saved
2207 if [info exists et_vect_no_int_max_saved] {
2208 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2210 set et_vect_no_int_max_saved 0
2211 if { [istarget sparc*-*-*]
2212 || [istarget spu-*-*]
2213 || [istarget alpha*-*-*] } {
2214 set et_vect_no_int_max_saved 1
2217 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2218 return $et_vect_no_int_max_saved
2221 # Return 1 if the target plus current options does not support a vector
2222 # add instruction on "int", 0 otherwise.
2224 # This won't change for different subtargets so cache the result.
2226 proc check_effective_target_vect_no_int_add { } {
2227 global et_vect_no_int_add_saved
2229 if [info exists et_vect_no_int_add_saved] {
2230 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2232 set et_vect_no_int_add_saved 0
2233 # Alpha only supports vector add on V8QI and V4HI.
2234 if { [istarget alpha*-*-*] } {
2235 set et_vect_no_int_add_saved 1
2238 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2239 return $et_vect_no_int_add_saved
2242 # Return 1 if the target plus current options does not support vector
2243 # bitwise instructions, 0 otherwise.
2245 # This won't change for different subtargets so cache the result.
2247 proc check_effective_target_vect_no_bitwise { } {
2248 global et_vect_no_bitwise_saved
2250 if [info exists et_vect_no_bitwise_saved] {
2251 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2253 set et_vect_no_bitwise_saved 0
2255 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2256 return $et_vect_no_bitwise_saved
2259 # Return 1 if the target plus current options supports vector permutation,
2262 # This won't change for different subtargets so cache the result.
2264 proc check_effective_target_vect_perm { } {
2267 if [info exists et_vect_perm_saved] {
2268 verbose "check_effective_target_vect_perm: using cached result" 2
2270 set et_vect_perm_saved 0
2271 if { [istarget powerpc*-*-*]
2272 || [istarget spu-*-*] } {
2273 set et_vect_perm_saved 1
2276 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2277 return $et_vect_perm_saved
2280 # Return 1 if the target plus current options supports a vector
2281 # widening summation of *short* args into *int* result, 0 otherwise.
2283 # This won't change for different subtargets so cache the result.
2285 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2286 global et_vect_widen_sum_hi_to_si_pattern
2288 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2289 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2291 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2292 if { [istarget powerpc*-*-*] } {
2293 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2296 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2297 return $et_vect_widen_sum_hi_to_si_pattern_saved
2300 # Return 1 if the target plus current options supports a vector
2301 # widening summation of *short* args into *int* result, 0 otherwise.
2302 # A target can also support this widening summation if it can support
2303 # promotion (unpacking) from shorts to ints.
2305 # This won't change for different subtargets so cache the result.
2307 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2308 global et_vect_widen_sum_hi_to_si
2310 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2311 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2313 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2314 if { [istarget powerpc*-*-*]
2315 || [istarget ia64-*-*] } {
2316 set et_vect_widen_sum_hi_to_si_saved 1
2319 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2320 return $et_vect_widen_sum_hi_to_si_saved
2323 # Return 1 if the target plus current options supports a vector
2324 # widening summation of *char* args into *short* result, 0 otherwise.
2325 # A target can also support this widening summation if it can support
2326 # promotion (unpacking) from chars to shorts.
2328 # This won't change for different subtargets so cache the result.
2330 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2331 global et_vect_widen_sum_qi_to_hi
2333 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2334 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2336 set et_vect_widen_sum_qi_to_hi_saved 0
2337 if { [check_effective_target_vect_unpack]
2338 || [istarget ia64-*-*] } {
2339 set et_vect_widen_sum_qi_to_hi_saved 1
2342 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2343 return $et_vect_widen_sum_qi_to_hi_saved
2346 # Return 1 if the target plus current options supports a vector
2347 # widening summation of *char* args into *int* result, 0 otherwise.
2349 # This won't change for different subtargets so cache the result.
2351 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2352 global et_vect_widen_sum_qi_to_si
2354 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2355 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2357 set et_vect_widen_sum_qi_to_si_saved 0
2358 if { [istarget powerpc*-*-*] } {
2359 set et_vect_widen_sum_qi_to_si_saved 1
2362 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2363 return $et_vect_widen_sum_qi_to_si_saved
2366 # Return 1 if the target plus current options supports a vector
2367 # widening multiplication of *char* args into *short* result, 0 otherwise.
2368 # A target can also support this widening multplication if it can support
2369 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2370 # multiplication of shorts).
2372 # This won't change for different subtargets so cache the result.
2375 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2376 global et_vect_widen_mult_qi_to_hi
2378 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2379 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2381 if { [check_effective_target_vect_unpack]
2382 && [check_effective_target_vect_short_mult] } {
2383 set et_vect_widen_mult_qi_to_hi_saved 1
2385 set et_vect_widen_mult_qi_to_hi_saved 0
2387 if { [istarget powerpc*-*-*] } {
2388 set et_vect_widen_mult_qi_to_hi_saved 1
2391 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2392 return $et_vect_widen_mult_qi_to_hi_saved
2395 # Return 1 if the target plus current options supports a vector
2396 # widening multiplication of *short* args into *int* result, 0 otherwise.
2397 # A target can also support this widening multplication if it can support
2398 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2399 # multiplication of ints).
2401 # This won't change for different subtargets so cache the result.
2404 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2405 global et_vect_widen_mult_hi_to_si
2407 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2408 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2410 if { [check_effective_target_vect_unpack]
2411 && [check_effective_target_vect_int_mult] } {
2412 set et_vect_widen_mult_hi_to_si_saved 1
2414 set et_vect_widen_mult_hi_to_si_saved 0
2416 if { [istarget powerpc*-*-*]
2417 || [istarget spu-*-*]
2418 || [istarget i?86-*-*]
2419 || [istarget x86_64-*-*] } {
2420 set et_vect_widen_mult_hi_to_si_saved 1
2423 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2424 return $et_vect_widen_mult_hi_to_si_saved
2427 # Return 1 if the target plus current options supports a vector
2428 # dot-product of signed chars, 0 otherwise.
2430 # This won't change for different subtargets so cache the result.
2432 proc check_effective_target_vect_sdot_qi { } {
2433 global et_vect_sdot_qi
2435 if [info exists et_vect_sdot_qi_saved] {
2436 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2438 set et_vect_sdot_qi_saved 0
2440 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2441 return $et_vect_sdot_qi_saved
2444 # Return 1 if the target plus current options supports a vector
2445 # dot-product of unsigned chars, 0 otherwise.
2447 # This won't change for different subtargets so cache the result.
2449 proc check_effective_target_vect_udot_qi { } {
2450 global et_vect_udot_qi
2452 if [info exists et_vect_udot_qi_saved] {
2453 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2455 set et_vect_udot_qi_saved 0
2456 if { [istarget powerpc*-*-*] } {
2457 set et_vect_udot_qi_saved 1
2460 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2461 return $et_vect_udot_qi_saved
2464 # Return 1 if the target plus current options supports a vector
2465 # dot-product of signed shorts, 0 otherwise.
2467 # This won't change for different subtargets so cache the result.
2469 proc check_effective_target_vect_sdot_hi { } {
2470 global et_vect_sdot_hi
2472 if [info exists et_vect_sdot_hi_saved] {
2473 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2475 set et_vect_sdot_hi_saved 0
2476 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2477 || [istarget i?86-*-*]
2478 || [istarget x86_64-*-*] } {
2479 set et_vect_sdot_hi_saved 1
2482 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2483 return $et_vect_sdot_hi_saved
2486 # Return 1 if the target plus current options supports a vector
2487 # dot-product of unsigned shorts, 0 otherwise.
2489 # This won't change for different subtargets so cache the result.
2491 proc check_effective_target_vect_udot_hi { } {
2492 global et_vect_udot_hi
2494 if [info exists et_vect_udot_hi_saved] {
2495 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2497 set et_vect_udot_hi_saved 0
2498 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2499 set et_vect_udot_hi_saved 1
2502 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2503 return $et_vect_udot_hi_saved
2507 # Return 1 if the target plus current options supports a vector
2508 # demotion (packing) of shorts (to chars) and ints (to shorts)
2509 # using modulo arithmetic, 0 otherwise.
2511 # This won't change for different subtargets so cache the result.
2513 proc check_effective_target_vect_pack_trunc { } {
2514 global et_vect_pack_trunc
2516 if [info exists et_vect_pack_trunc_saved] {
2517 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2519 set et_vect_pack_trunc_saved 0
2520 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2521 || [istarget i?86-*-*]
2522 || [istarget x86_64-*-*]
2523 || [istarget spu-*-*] } {
2524 set et_vect_pack_trunc_saved 1
2527 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2528 return $et_vect_pack_trunc_saved
2531 # Return 1 if the target plus current options supports a vector
2532 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2534 # This won't change for different subtargets so cache the result.
2536 proc check_effective_target_vect_unpack { } {
2537 global et_vect_unpack
2539 if [info exists et_vect_unpack_saved] {
2540 verbose "check_effective_target_vect_unpack: using cached result" 2
2542 set et_vect_unpack_saved 0
2543 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2544 || [istarget i?86-*-*]
2545 || [istarget x86_64-*-*]
2546 || [istarget spu-*-*] } {
2547 set et_vect_unpack_saved 1
2550 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2551 return $et_vect_unpack_saved
2554 # Return 1 if the target plus current options does not guarantee
2555 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2557 # This won't change for different subtargets so cache the result.
2559 proc check_effective_target_unaligned_stack { } {
2560 global et_unaligned_stack_saved
2562 if [info exists et_unaligned_stack_saved] {
2563 verbose "check_effective_target_unaligned_stack: using cached result" 2
2565 set et_unaligned_stack_saved 0
2567 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2568 return $et_unaligned_stack_saved
2571 # Return 1 if the target plus current options does not support a vector
2572 # alignment mechanism, 0 otherwise.
2574 # This won't change for different subtargets so cache the result.
2576 proc check_effective_target_vect_no_align { } {
2577 global et_vect_no_align_saved
2579 if [info exists et_vect_no_align_saved] {
2580 verbose "check_effective_target_vect_no_align: using cached result" 2
2582 set et_vect_no_align_saved 0
2583 if { [istarget mipsisa64*-*-*]
2584 || [istarget sparc*-*-*]
2585 || [istarget ia64-*-*]
2586 || [check_effective_target_arm32] } {
2587 set et_vect_no_align_saved 1
2590 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2591 return $et_vect_no_align_saved
2594 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2596 # This won't change for different subtargets so cache the result.
2598 proc check_effective_target_vect_hw_misalign { } {
2599 global et_vect_hw_misalign_saved
2601 if [info exists et_vect_hw_misalign_saved] {
2602 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2604 set et_vect_hw_misalign_saved 0
2605 if { ([istarget x86_64-*-*]
2606 || [istarget i?86-*-*]) } {
2607 set et_vect_hw_misalign_saved 1
2610 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2611 return $et_vect_hw_misalign_saved
2615 # Return 1 if arrays are aligned to the vector alignment
2616 # boundary, 0 otherwise.
2618 # This won't change for different subtargets so cache the result.
2620 proc check_effective_target_vect_aligned_arrays { } {
2621 global et_vect_aligned_arrays
2623 if [info exists et_vect_aligned_arrays_saved] {
2624 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2626 set et_vect_aligned_arrays_saved 0
2627 if { (([istarget x86_64-*-*]
2628 || [istarget i?86-*-*]) && [is-effective-target lp64])
2629 || [istarget spu-*-*] } {
2630 set et_vect_aligned_arrays_saved 1
2633 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2634 return $et_vect_aligned_arrays_saved
2637 # Return 1 if types of size 32 bit or less are naturally aligned
2638 # (aligned to their type-size), 0 otherwise.
2640 # This won't change for different subtargets so cache the result.
2642 proc check_effective_target_natural_alignment_32 { } {
2643 global et_natural_alignment_32
2645 if [info exists et_natural_alignment_32_saved] {
2646 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2648 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2649 set et_natural_alignment_32_saved 1
2650 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2651 set et_natural_alignment_32_saved 0
2654 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2655 return $et_natural_alignment_32_saved
2658 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2659 # type-size), 0 otherwise.
2661 # This won't change for different subtargets so cache the result.
2663 proc check_effective_target_natural_alignment_64 { } {
2664 global et_natural_alignment_64
2666 if [info exists et_natural_alignment_64_saved] {
2667 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2669 set et_natural_alignment_64_saved 0
2670 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2671 || [istarget spu-*-*] } {
2672 set et_natural_alignment_64_saved 1
2675 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2676 return $et_natural_alignment_64_saved
2679 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2681 # This won't change for different subtargets so cache the result.
2683 proc check_effective_target_vector_alignment_reachable { } {
2684 global et_vector_alignment_reachable
2686 if [info exists et_vector_alignment_reachable_saved] {
2687 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2689 if { [check_effective_target_vect_aligned_arrays]
2690 || [check_effective_target_natural_alignment_32] } {
2691 set et_vector_alignment_reachable_saved 1
2693 set et_vector_alignment_reachable_saved 0
2696 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2697 return $et_vector_alignment_reachable_saved
2700 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2702 # This won't change for different subtargets so cache the result.
2704 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2705 global et_vector_alignment_reachable_for_64bit
2707 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2708 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2710 if { [check_effective_target_vect_aligned_arrays]
2711 || [check_effective_target_natural_alignment_64] } {
2712 set et_vector_alignment_reachable_for_64bit_saved 1
2714 set et_vector_alignment_reachable_for_64bit_saved 0
2717 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2718 return $et_vector_alignment_reachable_for_64bit_saved
2721 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2723 proc check_effective_target_vect_condition { } {
2724 global et_vect_cond_saved
2726 if [info exists et_vect_cond_saved] {
2727 verbose "check_effective_target_vect_cond: using cached result" 2
2729 set et_vect_cond_saved 0
2730 if { [istarget powerpc*-*-*]
2731 || [istarget ia64-*-*]
2732 || [istarget i?86-*-*]
2733 || [istarget spu-*-*]
2734 || [istarget x86_64-*-*] } {
2735 set et_vect_cond_saved 1
2739 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2740 return $et_vect_cond_saved
2743 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2745 proc check_effective_target_vect_char_mult { } {
2746 global et_vect_char_mult_saved
2748 if [info exists et_vect_char_mult_saved] {
2749 verbose "check_effective_target_vect_char_mult: using cached result" 2
2751 set et_vect_char_mult_saved 0
2752 if { [istarget ia64-*-*]
2753 || [istarget i?86-*-*]
2754 || [istarget x86_64-*-*] } {
2755 set et_vect_char_mult_saved 1
2759 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2760 return $et_vect_char_mult_saved
2763 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2765 proc check_effective_target_vect_short_mult { } {
2766 global et_vect_short_mult_saved
2768 if [info exists et_vect_short_mult_saved] {
2769 verbose "check_effective_target_vect_short_mult: using cached result" 2
2771 set et_vect_short_mult_saved 0
2772 if { [istarget ia64-*-*]
2773 || [istarget spu-*-*]
2774 || [istarget i?86-*-*]
2775 || [istarget x86_64-*-*]
2776 || [istarget powerpc*-*-*]
2777 || [check_effective_target_arm32] } {
2778 set et_vect_short_mult_saved 1
2782 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2783 return $et_vect_short_mult_saved
2786 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2788 proc check_effective_target_vect_int_mult { } {
2789 global et_vect_int_mult_saved
2791 if [info exists et_vect_int_mult_saved] {
2792 verbose "check_effective_target_vect_int_mult: using cached result" 2
2794 set et_vect_int_mult_saved 0
2795 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2796 || [istarget spu-*-*]
2797 || [istarget i?86-*-*]
2798 || [istarget x86_64-*-*]
2799 || [check_effective_target_arm32] } {
2800 set et_vect_int_mult_saved 1
2804 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2805 return $et_vect_int_mult_saved
2808 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2810 proc check_effective_target_vect_extract_even_odd { } {
2811 global et_vect_extract_even_odd_saved
2813 if [info exists et_vect_extract_even_odd_saved] {
2814 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2816 set et_vect_extract_even_odd_saved 0
2817 if { [istarget powerpc*-*-*]
2818 || [istarget i?86-*-*]
2819 || [istarget x86_64-*-*]
2820 || [istarget spu-*-*] } {
2821 set et_vect_extract_even_odd_saved 1
2825 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2826 return $et_vect_extract_even_odd_saved
2829 # Return 1 if the target supports vector even/odd elements extraction of
2830 # vectors with SImode elements or larger, 0 otherwise.
2832 proc check_effective_target_vect_extract_even_odd_wide { } {
2833 global et_vect_extract_even_odd_wide_saved
2835 if [info exists et_vect_extract_even_odd_wide_saved] {
2836 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2838 set et_vect_extract_even_odd_wide_saved 0
2839 if { [istarget powerpc*-*-*]
2840 || [istarget i?86-*-*]
2841 || [istarget x86_64-*-*]
2842 || [istarget spu-*-*] } {
2843 set et_vect_extract_even_odd_wide_saved 1
2847 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2848 return $et_vect_extract_even_odd_wide_saved
2851 # Return 1 if the target supports vector interleaving, 0 otherwise.
2853 proc check_effective_target_vect_interleave { } {
2854 global et_vect_interleave_saved
2856 if [info exists et_vect_interleave_saved] {
2857 verbose "check_effective_target_vect_interleave: using cached result" 2
2859 set et_vect_interleave_saved 0
2860 if { [istarget powerpc*-*-*]
2861 || [istarget i?86-*-*]
2862 || [istarget x86_64-*-*]
2863 || [istarget spu-*-*] } {
2864 set et_vect_interleave_saved 1
2868 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2869 return $et_vect_interleave_saved
2872 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2873 proc check_effective_target_vect_strided { } {
2874 global et_vect_strided_saved
2876 if [info exists et_vect_strided_saved] {
2877 verbose "check_effective_target_vect_strided: using cached result" 2
2879 set et_vect_strided_saved 0
2880 if { [check_effective_target_vect_interleave]
2881 && [check_effective_target_vect_extract_even_odd] } {
2882 set et_vect_strided_saved 1
2886 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2887 return $et_vect_strided_saved
2890 # Return 1 if the target supports vector interleaving and extract even/odd
2891 # for wide element types, 0 otherwise.
2892 proc check_effective_target_vect_strided_wide { } {
2893 global et_vect_strided_wide_saved
2895 if [info exists et_vect_strided_wide_saved] {
2896 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2898 set et_vect_strided_wide_saved 0
2899 if { [check_effective_target_vect_interleave]
2900 && [check_effective_target_vect_extract_even_odd_wide] } {
2901 set et_vect_strided_wide_saved 1
2905 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2906 return $et_vect_strided_wide_saved
2909 # Return 1 if the target supports section-anchors
2911 proc check_effective_target_section_anchors { } {
2912 global et_section_anchors_saved
2914 if [info exists et_section_anchors_saved] {
2915 verbose "check_effective_target_section_anchors: using cached result" 2
2917 set et_section_anchors_saved 0
2918 if { [istarget powerpc*-*-*]
2919 || [istarget arm*-*-*] } {
2920 set et_section_anchors_saved 1
2924 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2925 return $et_section_anchors_saved
2928 # Return 1 if the target supports atomic operations on "int" and "long".
2930 proc check_effective_target_sync_int_long { } {
2931 global et_sync_int_long_saved
2933 if [info exists et_sync_int_long_saved] {
2934 verbose "check_effective_target_sync_int_long: using cached result" 2
2936 set et_sync_int_long_saved 0
2937 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2938 # load-reserved/store-conditional instructions.
2939 if { [istarget ia64-*-*]
2940 || [istarget i?86-*-*]
2941 || [istarget x86_64-*-*]
2942 || [istarget alpha*-*-*]
2943 || [istarget bfin*-*linux*]
2944 || [istarget s390*-*-*]
2945 || [istarget powerpc*-*-*]
2946 || [istarget sparc64-*-*]
2947 || [istarget sparcv9-*-*]
2948 || [istarget mips*-*-*] } {
2949 set et_sync_int_long_saved 1
2953 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2954 return $et_sync_int_long_saved
2957 # Return 1 if the target supports atomic operations on "char" and "short".
2959 proc check_effective_target_sync_char_short { } {
2960 global et_sync_char_short_saved
2962 if [info exists et_sync_char_short_saved] {
2963 verbose "check_effective_target_sync_char_short: using cached result" 2
2965 set et_sync_char_short_saved 0
2966 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2967 # load-reserved/store-conditional instructions.
2968 if { [istarget ia64-*-*]
2969 || [istarget i?86-*-*]
2970 || [istarget x86_64-*-*]
2971 || [istarget alpha*-*-*]
2972 || [istarget s390*-*-*]
2973 || [istarget powerpc*-*-*]
2974 || [istarget sparc64-*-*]
2975 || [istarget sparcv9-*-*]
2976 || [istarget mips*-*-*] } {
2977 set et_sync_char_short_saved 1
2981 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2982 return $et_sync_char_short_saved
2985 # Return 1 if the target uses a ColdFire FPU.
2987 proc check_effective_target_coldfire_fpu { } {
2988 return [check_no_compiler_messages coldfire_fpu assembly {
2995 # Return true if this is a uClibc target.
2997 proc check_effective_target_uclibc {} {
2998 return [check_no_compiler_messages uclibc object {
2999 #include <features.h>
3000 #if !defined (__UCLIBC__)
3006 # Return true if this is a uclibc target and if the uclibc feature
3007 # described by __$feature__ is not present.
3009 proc check_missing_uclibc_feature {feature} {
3010 return [check_no_compiler_messages $feature object "
3011 #include <features.h>
3012 #if !defined (__UCLIBC) || defined (__${feature}__)
3018 # Return true if this is a Newlib target.
3020 proc check_effective_target_newlib {} {
3021 return [check_no_compiler_messages newlib object {
3027 # (a) an error of a few ULP is expected in string to floating-point
3028 # conversion functions; and
3029 # (b) overflow is not always detected correctly by those functions.
3031 proc check_effective_target_lax_strtofp {} {
3032 # By default, assume that all uClibc targets suffer from this.
3033 return [check_effective_target_uclibc]
3036 # Return 1 if this is a target for which wcsftime is a dummy
3037 # function that always returns 0.
3039 proc check_effective_target_dummy_wcsftime {} {
3040 # By default, assume that all uClibc targets suffer from this.
3041 return [check_effective_target_uclibc]
3044 # Return 1 if constructors with initialization priority arguments are
3045 # supposed on this target.
3047 proc check_effective_target_init_priority {} {
3048 return [check_no_compiler_messages init_priority assembly "
3049 void f() __attribute__((constructor (1000)));
3054 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3055 # This can be used with any check_* proc that takes no argument and
3056 # returns only 1 or 0. It could be used with check_* procs that take
3057 # arguments with keywords that pass particular arguments.
3059 proc is-effective-target { arg } {
3061 if { [info procs check_effective_target_${arg}] != [list] } {
3062 set selected [check_effective_target_${arg}]
3065 "vmx_hw" { set selected [check_vmx_hw_available] }
3066 "vsx_hw" { set selected [check_vsx_hw_available] }
3067 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3068 "named_sections" { set selected [check_named_sections_available] }
3069 "gc_sections" { set selected [check_gc_sections_available] }
3070 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3071 default { error "unknown effective target keyword `$arg'" }
3074 verbose "is-effective-target: $arg $selected" 2
3078 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3080 proc is-effective-target-keyword { arg } {
3081 if { [info procs check_effective_target_${arg}] != [list] } {
3084 # These have different names for their check_* procs.
3086 "vmx_hw" { return 1 }
3087 "vsx_hw" { return 1 }
3088 "ppc_recip_hw" { return 1 }
3089 "named_sections" { return 1 }
3090 "gc_sections" { return 1 }
3091 "cxa_atexit" { return 1 }
3092 default { return 0 }
3097 # Return 1 if target default to short enums
3099 proc check_effective_target_short_enums { } {
3100 return [check_no_compiler_messages short_enums assembly {
3102 int s[sizeof (enum foo) == 1 ? 1 : -1];
3106 # Return 1 if target supports merging string constants at link time.
3108 proc check_effective_target_string_merging { } {
3109 return [check_no_messages_and_pattern string_merging \
3110 "rodata\\.str" assembly {
3111 const char *var = "String";
3115 # Return 1 if target has the basic signed and unsigned types in
3116 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3117 # working <stdint.h> for all targets.
3119 proc check_effective_target_stdint_types { } {
3120 return [check_no_compiler_messages stdint_types assembly {
3122 int8_t a; int16_t b; int32_t c; int64_t d;
3123 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3127 # Return 1 if target has the basic signed and unsigned types in
3128 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3129 # these types agree with those in the header, as some systems have
3130 # only <inttypes.h>.
3132 proc check_effective_target_inttypes_types { } {
3133 return [check_no_compiler_messages inttypes_types assembly {
3134 #include <inttypes.h>
3135 int8_t a; int16_t b; int32_t c; int64_t d;
3136 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3140 # Return 1 if programs are intended to be run on a simulator
3141 # (i.e. slowly) rather than hardware (i.e. fast).
3143 proc check_effective_target_simulator { } {
3145 # All "src/sim" simulators set this one.
3146 if [board_info target exists is_simulator] {
3147 return [board_info target is_simulator]
3150 # The "sid" simulators don't set that one, but at least they set
3152 if [board_info target exists slow_simulator] {
3153 return [board_info target slow_simulator]
3159 # Return 1 if the target is a VxWorks kernel.
3161 proc check_effective_target_vxworks_kernel { } {
3162 return [check_no_compiler_messages vxworks_kernel assembly {
3163 #if !defined __vxworks || defined __RTP__
3169 # Return 1 if the target is a VxWorks RTP.
3171 proc check_effective_target_vxworks_rtp { } {
3172 return [check_no_compiler_messages vxworks_rtp assembly {
3173 #if !defined __vxworks || !defined __RTP__
3179 # Return 1 if the target is expected to provide wide character support.
3181 proc check_effective_target_wchar { } {
3182 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3185 return [check_no_compiler_messages wchar assembly {
3190 # Return 1 if the target has <pthread.h>.
3192 proc check_effective_target_pthread_h { } {
3193 return [check_no_compiler_messages pthread_h assembly {
3194 #include <pthread.h>
3198 # Return 1 if the target can truncate a file from a file-descriptor,
3199 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3200 # chsize. We test for a trivially functional truncation; no stubs.
3201 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3202 # different function to be used.
3204 proc check_effective_target_fd_truncate { } {
3206 #define _FILE_OFFSET_BITS 64
3212 FILE *f = fopen ("tst.tmp", "wb");
3214 const char t[] = "test writing more than ten characters";
3217 write (fd, t, sizeof (t) - 1);
3219 if (ftruncate (fd, 10) != 0)
3222 f = fopen ("tst.tmp", "rb");
3223 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3229 if { [check_runtime ftruncate $prog] } {
3233 regsub "ftruncate" $prog "chsize" prog
3234 return [check_runtime chsize $prog]
3237 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3239 proc add_options_for_c99_runtime { flags } {
3240 if { [istarget *-*-solaris2*] } {
3241 return "$flags -std=c99"
3243 if { [istarget powerpc-*-darwin*] } {
3244 return "$flags -mmacosx-version-min=10.3"
3249 # Add to FLAGS all the target-specific flags needed to enable
3250 # full IEEE compliance mode.
3252 proc add_options_for_ieee { flags } {
3253 if { [istarget "alpha*-*-*"]
3254 || [istarget "sh*-*-*"] } {
3255 return "$flags -mieee"
3260 # Add to FLAGS the flags needed to enable functions to bind locally
3261 # when using pic/PIC passes in the testsuite.
3263 proc add_options_for_bind_pic_locally { flags } {
3264 if {[check_no_compiler_messages using_pic2 assembly {
3269 return "$flags -fPIE"
3271 if {[check_no_compiler_messages using_pic1 assembly {
3276 return "$flags -fpie"
3282 # Return 1 if the target provides a full C99 runtime.
3284 proc check_effective_target_c99_runtime { } {
3285 return [check_cached_effective_target c99_runtime {
3288 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3289 set contents [read $file]
3292 #ifndef HAVE_C99_RUNTIME
3296 check_no_compiler_messages_nocache c99_runtime assembly \
3297 $contents [add_options_for_c99_runtime ""]
3301 # Return 1 if target wchar_t is at least 4 bytes.
3303 proc check_effective_target_4byte_wchar_t { } {
3304 return [check_no_compiler_messages 4byte_wchar_t object {
3305 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3309 # Return 1 if the target supports automatic stack alignment.
3311 proc check_effective_target_automatic_stack_alignment { } {
3312 if { [istarget i?86*-*-*]
3313 || [istarget x86_64-*-*] } then {
3320 # Return 1 if avx instructions can be compiled.
3322 proc check_effective_target_avx { } {
3323 return [check_no_compiler_messages avx object {
3324 void _mm256_zeroall (void)
3326 __builtin_ia32_vzeroall ();
3331 # Return 1 if sse instructions can be compiled.
3332 proc check_effective_target_sse { } {
3333 return [check_no_compiler_messages sse object {
3336 __builtin_ia32_stmxcsr ();
3342 # Return 1 if sse2 instructions can be compiled.
3343 proc check_effective_target_sse2 { } {
3344 return [check_no_compiler_messages sse2 object {
3345 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3347 __m128i _mm_srli_si128 (__m128i __A, int __N)
3349 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3354 # Return 1 if F16C instructions can be compiled.
3356 proc check_effective_target_f16c { } {
3357 return [check_no_compiler_messages f16c object {
3358 #include "immintrin.h"
3360 foo (unsigned short val)
3362 return _cvtsh_ss (val);
3367 # Return 1 if C wchar_t type is compatible with char16_t.
3369 proc check_effective_target_wchar_t_char16_t_compatible { } {
3370 return [check_no_compiler_messages wchar_t_char16_t object {
3372 __CHAR16_TYPE__ *p16 = &wc;
3373 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3377 # Return 1 if C wchar_t type is compatible with char32_t.
3379 proc check_effective_target_wchar_t_char32_t_compatible { } {
3380 return [check_no_compiler_messages wchar_t_char32_t object {
3382 __CHAR32_TYPE__ *p32 = &wc;
3383 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3387 # Return 1 if pow10 function exists.
3389 proc check_effective_target_pow10 { } {
3390 return [check_runtime pow10 {
3400 # Return 1 if current options generate DFP instructions, 0 otherwise.
3402 proc check_effective_target_hard_dfp {} {
3403 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3404 typedef float d64 __attribute__((mode(DD)));
3406 void foo (void) { z = x + y; }
3410 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3411 # for strchr etc. functions.
3413 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3414 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3417 #if !defined(__cplusplus) \
3418 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3419 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3420 ISO C++ correct string.h and wchar.h protos not supported.
3427 # Return 1 if GNU as is used.
3429 proc check_effective_target_gas { } {
3430 global use_gas_saved
3433 if {![info exists use_gas_saved]} {
3434 # Check if the as used by gcc is GNU as.
3435 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3436 # Provide /dev/null as input, otherwise gas times out reading from
3438 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3439 set as_output [lindex $status 1]
3440 if { [ string first "GNU" $as_output ] >= 0 } {
3446 return $use_gas_saved
3449 # Return 1 if the compiler has been configure with link-time optimization
3452 proc check_effective_target_lto { } {
3454 return [info exists ENABLE_LTO]
3457 # Return 1 if the language for the compiler under test is C.
3459 proc check_effective_target_c { } {
3461 if [string match $tool "gcc"] {
3467 # Return 1 if the language for the compiler under test is C++.
3469 proc check_effective_target_c++ { } {
3471 if [string match $tool "g++"] {