Merge branches/gcc-4_8-branch rev 216856
[official-gcc.git] / gcc-4_8-branch / gcc / testsuite / lib / target-supports.exp
blobf8e633744b83060c156071d0ac34a08434c1f437
1 # Copyright (C) 1999-2013 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
20 # This file defines procs for determining features supported by the target.
22 # Try to compile the code given by CONTENTS into an output file of
23 # type TYPE, where TYPE is as for target_compile. Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the name of the output file.
27 # BASENAME is a prefix to use for source and output files.
28 # If ARGS is not empty, its first element is a string that
29 # should be added to the command line.
31 # Assume by default that CONTENTS is C code.
32 # Otherwise, code should contain:
33 # "// C++" for c++,
34 # "! Fortran" for Fortran code,
35 # "/* ObjC", for ObjC
36 # "// ObjC++" for ObjC++
37 # and "// Go" for Go
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} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
46 } else {
47 set options ""
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 }
54 "*// Go*" { set src ${basename}[pid].go }
55 default {
56 switch -- $tool {
57 "objc" { set src ${basename}[pid].m }
58 "obj-c++" { set src ${basename}[pid].mm }
59 default { set src ${basename}[pid].c }
64 set compile_type $type
65 switch -glob $type {
66 assembly { set output ${basename}[pid].s }
67 object { set output ${basename}[pid].o }
68 executable { set output ${basename}[pid].exe }
69 "rtl-*" {
70 set output ${basename}[pid].s
71 lappend options "additional_flags=-fdump-$type"
72 set compile_type assembly
75 set f [open $src "w"]
76 puts $f $contents
77 close $f
78 set lines [${tool}_target_compile $src $output $compile_type "$options"]
79 file delete $src
81 set scan_output $output
82 # Don't try folding this into the switch above; calling "glob" before the
83 # file is created won't work.
84 if [regexp "rtl-(.*)" $type dummy rtl_type] {
85 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
86 file delete $output
89 return [list $lines $scan_output]
92 proc current_target_name { } {
93 global target_info
94 if [info exists target_info(target,name)] {
95 set answer $target_info(target,name)
96 } else {
97 set answer ""
99 return $answer
102 # Implement an effective-target check for property PROP by invoking
103 # the Tcl command ARGS and seeing if it returns true.
105 proc check_cached_effective_target { prop args } {
106 global et_cache
108 set target [current_target_name]
109 if {![info exists et_cache($prop,target)]
110 || $et_cache($prop,target) != $target} {
111 verbose "check_cached_effective_target $prop: checking $target" 2
112 set et_cache($prop,target) $target
113 set et_cache($prop,value) [uplevel eval $args]
115 set value $et_cache($prop,value)
116 verbose "check_cached_effective_target $prop: returning $value for $target" 2
117 return $value
120 # Like check_compile, but delete the output file and return true if the
121 # compiler printed no messages.
122 proc check_no_compiler_messages_nocache {args} {
123 set result [eval check_compile $args]
124 set lines [lindex $result 0]
125 set output [lindex $result 1]
126 remote_file build delete $output
127 return [string match "" $lines]
130 # Like check_no_compiler_messages_nocache, but cache the result.
131 # PROP is the property we're checking, and doubles as a prefix for
132 # temporary filenames.
133 proc check_no_compiler_messages {prop args} {
134 return [check_cached_effective_target $prop {
135 eval [list check_no_compiler_messages_nocache $prop] $args
139 # Like check_compile, but return true if the compiler printed no
140 # messages and if the contents of the output file satisfy PATTERN.
141 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
142 # don't match regular expression REGEXP, otherwise they satisfy it
143 # if they do match regular expression PATTERN. (PATTERN can start
144 # with something like "[!]" if the regular expression needs to match
145 # "!" as the first character.)
147 # Delete the output file before returning. The other arguments are
148 # as for check_compile.
149 proc check_no_messages_and_pattern_nocache {basename pattern args} {
150 global tool
152 set result [eval [list check_compile $basename] $args]
153 set lines [lindex $result 0]
154 set output [lindex $result 1]
156 set ok 0
157 if { [string match "" $lines] } {
158 set chan [open "$output"]
159 set invert [regexp {^!(.*)} $pattern dummy pattern]
160 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
161 close $chan
164 remote_file build delete $output
165 return $ok
168 # Like check_no_messages_and_pattern_nocache, but cache the result.
169 # PROP is the property we're checking, and doubles as a prefix for
170 # temporary filenames.
171 proc check_no_messages_and_pattern {prop pattern args} {
172 return [check_cached_effective_target $prop {
173 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
177 # Try to compile and run an executable from code CONTENTS. Return true
178 # if the compiler reports no messages and if execution "passes" in the
179 # usual DejaGNU sense. The arguments are as for check_compile, with
180 # TYPE implicitly being "executable".
181 proc check_runtime_nocache {basename contents args} {
182 global tool
184 set result [eval [list check_compile $basename executable $contents] $args]
185 set lines [lindex $result 0]
186 set output [lindex $result 1]
188 set ok 0
189 if { [string match "" $lines] } {
190 # No error messages, everything is OK.
191 set result [remote_load target "./$output" "" ""]
192 set status [lindex $result 0]
193 verbose "check_runtime_nocache $basename: status is <$status>" 2
194 if { $status == "pass" } {
195 set ok 1
198 remote_file build delete $output
199 return $ok
202 # Like check_runtime_nocache, but cache the result. PROP is the
203 # property we're checking, and doubles as a prefix for temporary
204 # filenames.
205 proc check_runtime {prop args} {
206 global tool
208 return [check_cached_effective_target $prop {
209 eval [list check_runtime_nocache $prop] $args
213 ###############################
214 # proc check_weak_available { }
215 ###############################
217 # weak symbols are only supported in some configs/object formats
218 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
220 proc check_weak_available { } {
221 global target_cpu
223 # All mips targets should support it
225 if { [ string first "mips" $target_cpu ] >= 0 } {
226 return 1
229 # All solaris2 targets should support it
231 if { [istarget *-*-solaris2*] } {
232 return 1
235 # Windows targets Cygwin and MingW32 support it
237 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
238 return 1
241 # HP-UX 10.X doesn't support it
243 if { [istarget hppa*-*-hpux10*] } {
244 return 0
247 # ELF and ECOFF support it. a.out does with gas/gld but may also with
248 # other linkers, so we should try it
250 set objformat [gcc_target_object_format]
252 switch $objformat {
253 elf { return 1 }
254 ecoff { return 1 }
255 a.out { return 1 }
256 mach-o { return 1 }
257 som { return 1 }
258 unknown { return -1 }
259 default { return 0 }
263 ###############################
264 # proc check_weak_override_available { }
265 ###############################
267 # Like check_weak_available, but return 0 if weak symbol definitions
268 # cannot be overridden.
270 proc check_weak_override_available { } {
271 if { [istarget *-*-mingw*] } {
272 return 0
274 return [check_weak_available]
277 ###############################
278 # proc check_visibility_available { what_kind }
279 ###############################
281 # The visibility attribute is only support in some object formats
282 # This proc returns 1 if it is supported, 0 if not.
283 # The argument is the kind of visibility, default/protected/hidden/internal.
285 proc check_visibility_available { what_kind } {
286 if [string match "" $what_kind] { set what_kind "hidden" }
288 return [check_no_compiler_messages visibility_available_$what_kind object "
289 void f() __attribute__((visibility(\"$what_kind\")));
290 void f() {}
294 ###############################
295 # proc check_alias_available { }
296 ###############################
298 # Determine if the target toolchain supports the alias attribute.
300 # Returns 2 if the target supports aliases. Returns 1 if the target
301 # only supports weak aliased. Returns 0 if the target does not
302 # support aliases at all. Returns -1 if support for aliases could not
303 # be determined.
305 proc check_alias_available { } {
306 global alias_available_saved
307 global tool
309 if [info exists alias_available_saved] {
310 verbose "check_alias_available returning saved $alias_available_saved" 2
311 } else {
312 set src alias[pid].c
313 set obj alias[pid].o
314 verbose "check_alias_available compiling testfile $src" 2
315 set f [open $src "w"]
316 # Compile a small test program. The definition of "g" is
317 # necessary to keep the Solaris assembler from complaining
318 # about the program.
319 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
320 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
321 close $f
322 set lines [${tool}_target_compile $src $obj object ""]
323 file delete $src
324 remote_file build delete $obj
326 if [string match "" $lines] then {
327 # No error messages, everything is OK.
328 set alias_available_saved 2
329 } else {
330 if [regexp "alias definitions not supported" $lines] {
331 verbose "check_alias_available target does not support aliases" 2
333 set objformat [gcc_target_object_format]
335 if { $objformat == "elf" } {
336 verbose "check_alias_available but target uses ELF format, so it ought to" 2
337 set alias_available_saved -1
338 } else {
339 set alias_available_saved 0
341 } else {
342 if [regexp "only weak aliases are supported" $lines] {
343 verbose "check_alias_available target supports only weak aliases" 2
344 set alias_available_saved 1
345 } else {
346 set alias_available_saved -1
351 verbose "check_alias_available returning $alias_available_saved" 2
354 return $alias_available_saved
357 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
359 proc check_effective_target_alias { } {
360 if { [check_alias_available] < 2 } {
361 return 0
362 } else {
363 return 1
367 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
369 proc check_ifunc_available { } {
370 return [check_no_compiler_messages ifunc_available object {
371 #ifdef __cplusplus
372 extern "C"
373 #endif
374 void g() {}
375 void f() __attribute__((ifunc("g")));
379 # Returns true if --gc-sections is supported on the target.
381 proc check_gc_sections_available { } {
382 global gc_sections_available_saved
383 global tool
385 if {![info exists gc_sections_available_saved]} {
386 # Some targets don't support gc-sections despite whatever's
387 # advertised by ld's options.
388 if { [istarget alpha*-*-*]
389 || [istarget ia64-*-*] } {
390 set gc_sections_available_saved 0
391 return 0
394 # elf2flt uses -q (--emit-relocs), which is incompatible with
395 # --gc-sections.
396 if { [board_info target exists ldflags]
397 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
398 set gc_sections_available_saved 0
399 return 0
402 # VxWorks kernel modules are relocatable objects linked with -r,
403 # while RTP executables are linked with -q (--emit-relocs).
404 # Both of these options are incompatible with --gc-sections.
405 if { [istarget *-*-vxworks*] } {
406 set gc_sections_available_saved 0
407 return 0
410 # Check if the ld used by gcc supports --gc-sections.
411 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
412 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
413 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
414 set ld_output [remote_exec host "$gcc_ld" "--help"]
415 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
416 set gc_sections_available_saved 1
417 } else {
418 set gc_sections_available_saved 0
421 return $gc_sections_available_saved
424 # Return 1 if according to target_info struct and explicit target list
425 # target is supposed to support trampolines.
427 proc check_effective_target_trampolines { } {
428 if [target_info exists no_trampolines] {
429 return 0
431 if { [istarget avr-*-*]
432 || [istarget hppa2.0w-hp-hpux11.23]
433 || [istarget hppa64-hp-hpux11.23] } {
434 return 0;
436 return 1
439 # Return 1 if according to target_info struct and explicit target list
440 # target is supposed to keep null pointer checks. This could be due to
441 # use of option fno-delete-null-pointer-checks or hardwired in target.
443 proc check_effective_target_keeps_null_pointer_checks { } {
444 if [target_info exists keeps_null_pointer_checks] {
445 return 1
447 if { [istarget avr-*-*] } {
448 return 1;
450 return 0
453 # Return true if profiling is supported on the target.
455 proc check_profiling_available { test_what } {
456 global profiling_available_saved
458 verbose "Profiling argument is <$test_what>" 1
460 # These conditions depend on the argument so examine them before
461 # looking at the cache variable.
463 # Tree profiling requires TLS runtime support.
464 if { $test_what == "-fprofile-generate" } {
465 if { ![check_effective_target_tls_runtime] } {
466 return 0
470 # Support for -p on solaris2 relies on mcrt1.o which comes with the
471 # vendor compiler. We cannot reliably predict the directory where the
472 # vendor compiler (and thus mcrt1.o) is installed so we can't
473 # necessarily find mcrt1.o even if we have it.
474 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
475 return 0
478 # We don't yet support profiling for MIPS16.
479 if { [istarget mips*-*-*]
480 && ![check_effective_target_nomips16]
481 && ($test_what == "-p" || $test_what == "-pg") } {
482 return 0
485 # MinGW does not support -p.
486 if { [istarget *-*-mingw*] && $test_what == "-p" } {
487 return 0
490 # cygwin does not support -p.
491 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
492 return 0
495 # uClibc does not have gcrt1.o.
496 if { [check_effective_target_uclibc]
497 && ($test_what == "-p" || $test_what == "-pg") } {
498 return 0
501 # Now examine the cache variable.
502 if {![info exists profiling_available_saved]} {
503 # Some targets don't have any implementation of __bb_init_func or are
504 # missing other needed machinery.
505 if { [istarget aarch64*-*-elf]
506 || [istarget am3*-*-linux*]
507 || [istarget arm*-*-eabi*]
508 || [istarget arm*-*-elf]
509 || [istarget arm*-*-symbianelf*]
510 || [istarget avr-*-*]
511 || [istarget bfin-*-*]
512 || [istarget cris-*-*]
513 || [istarget crisv32-*-*]
514 || [istarget fido-*-elf]
515 || [istarget h8300-*-*]
516 || [istarget lm32-*-*]
517 || [istarget m32c-*-elf]
518 || [istarget m68k-*-elf]
519 || [istarget m68k-*-uclinux*]
520 || [istarget mep-*-elf]
521 || [istarget mips*-*-elf*]
522 || [istarget mmix-*-*]
523 || [istarget mn10300-*-elf*]
524 || [istarget moxie-*-elf*]
525 || [istarget picochip-*-*]
526 || [istarget powerpc-*-eabi*]
527 || [istarget powerpc-*-elf]
528 || [istarget rx-*-*]
529 || [istarget tic6x-*-elf]
530 || [istarget xstormy16-*]
531 || [istarget xtensa*-*-elf]
532 || [istarget *-*-rtems*]
533 || [istarget *-*-vxworks*] } {
534 set profiling_available_saved 0
535 } else {
536 set profiling_available_saved 1
540 return $profiling_available_saved
543 # Check to see if a target is "freestanding". This is as per the definition
544 # in Section 4 of C99 standard. Effectively, it is a target which supports no
545 # extra headers or libraries other than what is considered essential.
546 proc check_effective_target_freestanding { } {
547 if { [istarget picochip-*-*] } then {
548 return 1
549 } else {
550 return 0
554 # Return 1 if target has packed layout of structure members by
555 # default, 0 otherwise. Note that this is slightly different than
556 # whether the target has "natural alignment": both attributes may be
557 # false.
559 proc check_effective_target_default_packed { } {
560 return [check_no_compiler_messages default_packed assembly {
561 struct x { char a; long b; } c;
562 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
566 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
567 # documentation, where the test also comes from.
569 proc check_effective_target_pcc_bitfield_type_matters { } {
570 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
571 # bitfields, but let's stick to the example code from the docs.
572 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
573 struct foo1 { char x; char :0; char y; };
574 struct foo2 { char x; int :0; char y; };
575 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
579 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
581 proc add_options_for_tls { flags } {
582 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
583 # libthread, so always pass -pthread for native TLS. Same for AIX.
584 # Need to duplicate native TLS check from
585 # check_effective_target_tls_native to avoid recursion.
586 if { ([istarget *-*-solaris2.9*] || [istarget powerpc-ibm-aix*]) &&
587 [check_no_messages_and_pattern tls_native "!emutls" assembly {
588 __thread int i;
589 int f (void) { return i; }
590 void g (int j) { i = j; }
591 }] } {
592 return "$flags -pthread"
594 return $flags
597 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
599 proc check_effective_target_tls {} {
600 return [check_no_compiler_messages tls assembly {
601 __thread int i;
602 int f (void) { return i; }
603 void g (int j) { i = j; }
607 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
609 proc check_effective_target_tls_native {} {
610 # VxWorks uses emulated TLS machinery, but with non-standard helper
611 # functions, so we fail to automatically detect it.
612 if { [istarget *-*-vxworks*] } {
613 return 0
616 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
617 __thread int i;
618 int f (void) { return i; }
619 void g (int j) { i = j; }
623 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
625 proc check_effective_target_tls_emulated {} {
626 # VxWorks uses emulated TLS machinery, but with non-standard helper
627 # functions, so we fail to automatically detect it.
628 if { [istarget *-*-vxworks*] } {
629 return 1
632 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
633 __thread int i;
634 int f (void) { return i; }
635 void g (int j) { i = j; }
639 # Return 1 if TLS executables can run correctly, 0 otherwise.
641 proc check_effective_target_tls_runtime {} {
642 return [check_runtime tls_runtime {
643 __thread int thr = 0;
644 int main (void) { return thr; }
645 } [add_options_for_tls ""]]
648 # Return 1 if atomic compare-and-swap is supported on 'int'
650 proc check_effective_target_cas_char {} {
651 return [check_no_compiler_messages cas_char assembly {
652 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
653 #error unsupported
654 #endif
655 } ""]
658 proc check_effective_target_cas_int {} {
659 return [check_no_compiler_messages cas_int assembly {
660 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
661 /* ok */
662 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
663 /* ok */
664 #else
665 #error unsupported
666 #endif
667 } ""]
670 # Return 1 if -ffunction-sections is supported, 0 otherwise.
672 proc check_effective_target_function_sections {} {
673 # Darwin has its own scheme and silently accepts -ffunction-sections.
674 if { [istarget *-*-darwin*] } {
675 return 0
678 return [check_no_compiler_messages functionsections assembly {
679 void foo (void) { }
680 } "-ffunction-sections"]
683 # Return 1 if instruction scheduling is available, 0 otherwise.
685 proc check_effective_target_scheduling {} {
686 return [check_no_compiler_messages scheduling object {
687 void foo (void) { }
688 } "-fschedule-insns"]
691 # Return 1 if compilation with -fgraphite is error-free for trivial
692 # code, 0 otherwise.
694 proc check_effective_target_fgraphite {} {
695 return [check_no_compiler_messages fgraphite object {
696 void foo (void) { }
697 } "-O1 -fgraphite"]
700 # Return 1 if compilation with -fopenmp is error-free for trivial
701 # code, 0 otherwise.
703 proc check_effective_target_fopenmp {} {
704 return [check_no_compiler_messages fopenmp object {
705 void foo (void) { }
706 } "-fopenmp"]
709 # Return 1 if compilation with -fgnu-tm is error-free for trivial
710 # code, 0 otherwise.
712 proc check_effective_target_fgnu_tm {} {
713 return [check_no_compiler_messages fgnu_tm object {
714 void foo (void) { }
715 } "-fgnu-tm"]
718 # Return 1 if the target supports mmap, 0 otherwise.
720 proc check_effective_target_mmap {} {
721 return [check_function_available "mmap"]
724 # Return 1 if the target supports dlopen, 0 otherwise.
725 proc check_effective_target_dlopen {} {
726 return [check_function_available "dlopen"]
729 # Return 1 if the target supports clone, 0 otherwise.
730 proc check_effective_target_clone {} {
731 return [check_function_available "clone"]
734 # Return 1 if the target supports setrlimit, 0 otherwise.
735 proc check_effective_target_setrlimit {} {
736 # Darwin has non-posix compliant RLIMIT_AS
737 if { [istarget *-*-darwin*] } {
738 return 0
740 return [check_function_available "setrlimit"]
743 # Return 1 if the target supports swapcontext, 0 otherwise.
744 proc check_effective_target_swapcontext {} {
745 return [check_no_compiler_messages swapcontext executable {
746 #include <ucontext.h>
747 int main (void)
749 ucontext_t orig_context,child_context;
750 if (swapcontext(&child_context, &orig_context) < 0) { }
755 # Return 1 if compilation with -pthread is error-free for trivial
756 # code, 0 otherwise.
758 proc check_effective_target_pthread {} {
759 return [check_no_compiler_messages pthread object {
760 void foo (void) { }
761 } "-pthread"]
764 # Return 1 if compilation with -mpe-aligned-commons is error-free
765 # for trivial code, 0 otherwise.
767 proc check_effective_target_pe_aligned_commons {} {
768 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
769 return [check_no_compiler_messages pe_aligned_commons object {
770 int foo;
771 } "-mpe-aligned-commons"]
773 return 0
776 # Return 1 if the target supports -static
777 proc check_effective_target_static {} {
778 return [check_no_compiler_messages static executable {
779 int main (void) { return 0; }
780 } "-static"]
783 # Return 1 if the target supports -fstack-protector
784 proc check_effective_target_fstack_protector {} {
785 return [check_runtime fstack_protector {
786 int main (void) { return 0; }
787 } "-fstack-protector"]
790 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
791 # for trivial code, 0 otherwise.
793 proc check_effective_target_freorder {} {
794 return [check_no_compiler_messages freorder object {
795 void foo (void) { }
796 } "-freorder-blocks-and-partition"]
799 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
800 # emitted, 0 otherwise. Whether a shared library can actually be built is
801 # out of scope for this test.
803 proc check_effective_target_fpic { } {
804 # Note that M68K has a multilib that supports -fpic but not
805 # -fPIC, so we need to check both. We test with a program that
806 # requires GOT references.
807 foreach arg {fpic fPIC} {
808 if [check_no_compiler_messages $arg object {
809 extern int foo (void); extern int bar;
810 int baz (void) { return foo () + bar; }
811 } "-$arg"] {
812 return 1
815 return 0
818 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
820 proc check_effective_target_pie { } {
821 if { [istarget *-*-darwin\[912\]*]
822 || [istarget *-*-linux*] } {
823 return 1;
825 return 0
828 # Return true if the target supports -mpaired-single (as used on MIPS).
830 proc check_effective_target_mpaired_single { } {
831 return [check_no_compiler_messages mpaired_single object {
832 void foo (void) { }
833 } "-mpaired-single"]
836 # Return true if the target has access to FPU instructions.
838 proc check_effective_target_hard_float { } {
839 if { [istarget mips*-*-*] } {
840 return [check_no_compiler_messages hard_float assembly {
841 #if (defined __mips_soft_float || defined __mips16)
842 #error FOO
843 #endif
847 # This proc is actually checking the availabilty of FPU
848 # support for doubles, so on the RX we must fail if the
849 # 64-bit double multilib has been selected.
850 if { [istarget rx-*-*] } {
851 return 0
852 # return [check_no_compiler_messages hard_float assembly {
853 #if defined __RX_64_BIT_DOUBLES__
854 #error FOO
855 #endif
856 # }]
859 # The generic test equates hard_float with "no call for adding doubles".
860 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
861 double a (double b, double c) { return b + c; }
865 # Return true if the target is a 64-bit MIPS target.
867 proc check_effective_target_mips64 { } {
868 return [check_no_compiler_messages mips64 assembly {
869 #ifndef __mips64
870 #error FOO
871 #endif
875 # Return true if the target is a MIPS target that does not produce
876 # MIPS16 code.
878 proc check_effective_target_nomips16 { } {
879 return [check_no_compiler_messages nomips16 object {
880 #ifndef __mips
881 #error FOO
882 #else
883 /* A cheap way of testing for -mflip-mips16. */
884 void foo (void) { asm ("addiu $20,$20,1"); }
885 void bar (void) { asm ("addiu $20,$20,1"); }
886 #endif
890 # Add the options needed for MIPS16 function attributes. At the moment,
891 # we don't support MIPS16 PIC.
893 proc add_options_for_mips16_attribute { flags } {
894 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
897 # Return true if we can force a mode that allows MIPS16 code generation.
898 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
899 # for o32 and o64.
901 proc check_effective_target_mips16_attribute { } {
902 return [check_no_compiler_messages mips16_attribute assembly {
903 #ifdef PIC
904 #error FOO
905 #endif
906 #if defined __mips_hard_float \
907 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
908 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
909 #error FOO
910 #endif
911 } [add_options_for_mips16_attribute ""]]
914 # Return 1 if the target supports long double larger than double when
915 # using the new ABI, 0 otherwise.
917 proc check_effective_target_mips_newabi_large_long_double { } {
918 return [check_no_compiler_messages mips_newabi_large_long_double object {
919 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
920 } "-mabi=64"]
923 # Return true if the target is a MIPS target that has access
924 # to the LL and SC instructions.
926 proc check_effective_target_mips_llsc { } {
927 if { ![istarget mips*-*-*] } {
928 return 0
930 # Assume that these instructions are always implemented for
931 # non-elf* targets, via emulation if necessary.
932 if { ![istarget *-*-elf*] } {
933 return 1
935 # Otherwise assume LL/SC support for everything but MIPS I.
936 return [check_no_compiler_messages mips_llsc assembly {
937 #if __mips == 1
938 #error FOO
939 #endif
943 # Return true if the target is a MIPS target that uses in-place relocations.
945 proc check_effective_target_mips_rel { } {
946 if { ![istarget mips*-*-*] } {
947 return 0
949 return [check_no_compiler_messages mips_rel object {
950 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
951 || (defined _ABI64 && _MIPS_SIM == _ABI64)
952 #error FOO
953 #endif
957 # Return true if the target is a MIPS target that uses the EABI.
959 proc check_effective_target_mips_eabi { } {
960 if { ![istarget mips*-*-*] } {
961 return 0
963 return [check_no_compiler_messages mips_eabi object {
964 #ifndef __mips_eabi
965 #error FOO
966 #endif
970 # Return 1 if the current multilib does not generate PIC by default.
972 proc check_effective_target_nonpic { } {
973 return [check_no_compiler_messages nonpic assembly {
974 #if __PIC__
975 #error FOO
976 #endif
980 # Return 1 if the target does not use a status wrapper.
982 proc check_effective_target_unwrapped { } {
983 if { [target_info needs_status_wrapper] != "" \
984 && [target_info needs_status_wrapper] != "0" } {
985 return 0
987 return 1
990 # Return true if iconv is supported on the target. In particular IBM1047.
992 proc check_iconv_available { test_what } {
993 global libiconv
995 # If the tool configuration file has not set libiconv, try "-liconv"
996 if { ![info exists libiconv] } {
997 set libiconv "-liconv"
999 set test_what [lindex $test_what 1]
1000 return [check_runtime_nocache $test_what [subst {
1001 #include <iconv.h>
1002 int main (void)
1004 iconv_t cd;
1006 cd = iconv_open ("$test_what", "UTF-8");
1007 if (cd == (iconv_t) -1)
1008 return 1;
1009 return 0;
1011 }] $libiconv]
1014 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1016 proc check_ascii_locale_available { } {
1017 return 1
1020 # Return true if named sections are supported on this target.
1022 proc check_named_sections_available { } {
1023 return [check_no_compiler_messages named_sections assembly {
1024 int __attribute__ ((section("whatever"))) foo;
1028 # Return true if the "naked" function attribute is supported on this target.
1030 proc check_effective_target_naked_functions { } {
1031 return [check_no_compiler_messages naked_functions assembly {
1032 void f() __attribute__((naked));
1036 # Return 1 if the target supports Fortran real kinds larger than real(8),
1037 # 0 otherwise.
1039 # When the target name changes, replace the cached result.
1041 proc check_effective_target_fortran_large_real { } {
1042 return [check_no_compiler_messages fortran_large_real executable {
1043 ! Fortran
1044 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1045 real(kind=k) :: x
1046 x = cos (x)
1051 # Return 1 if the target supports Fortran real kind real(16),
1052 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1053 # this checks for Real(16) only; the other returned real(10) if
1054 # both real(10) and real(16) are available.
1056 # When the target name changes, replace the cached result.
1058 proc check_effective_target_fortran_real_16 { } {
1059 return [check_no_compiler_messages fortran_real_16 executable {
1060 ! Fortran
1061 real(kind=16) :: x
1062 x = cos (x)
1068 # Return 1 if the target supports SQRT for the largest floating-point
1069 # type. (Some targets lack the libm support for this FP type.)
1070 # On most targets, this check effectively checks either whether sqrtl is
1071 # available or on __float128 systems whether libquadmath is installed,
1072 # which provides sqrtq.
1074 # When the target name changes, replace the cached result.
1076 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1077 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1078 ! Fortran
1079 use iso_fortran_env, only: real_kinds
1080 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1081 real(kind=maxFP), volatile :: x
1082 x = 2.0_maxFP
1083 x = sqrt (x)
1089 # Return 1 if the target supports Fortran integer kinds larger than
1090 # integer(8), 0 otherwise.
1092 # When the target name changes, replace the cached result.
1094 proc check_effective_target_fortran_large_int { } {
1095 return [check_no_compiler_messages fortran_large_int executable {
1096 ! Fortran
1097 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1098 integer(kind=k) :: i
1103 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1105 # When the target name changes, replace the cached result.
1107 proc check_effective_target_fortran_integer_16 { } {
1108 return [check_no_compiler_messages fortran_integer_16 executable {
1109 ! Fortran
1110 integer(16) :: i
1115 # Return 1 if we can statically link libgfortran, 0 otherwise.
1117 # When the target name changes, replace the cached result.
1119 proc check_effective_target_static_libgfortran { } {
1120 return [check_no_compiler_messages static_libgfortran executable {
1121 ! Fortran
1122 print *, 'test'
1124 } "-static"]
1127 proc check_linker_plugin_available { } {
1128 return [check_no_compiler_messages_nocache linker_plugin executable {
1129 int main() { return 0; }
1130 } "-flto -fuse-linker-plugin"]
1133 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1134 # otherwise. Cache the result.
1136 proc check_750cl_hw_available { } {
1137 return [check_cached_effective_target 750cl_hw_available {
1138 # If this is not the right target then we can skip the test.
1139 if { ![istarget powerpc-*paired*] } {
1140 expr 0
1141 } else {
1142 check_runtime_nocache 750cl_hw_available {
1143 int main()
1145 #ifdef __MACH__
1146 asm volatile ("ps_mul v0,v0,v0");
1147 #else
1148 asm volatile ("ps_mul 0,0,0");
1149 #endif
1150 return 0;
1152 } "-mpaired"
1157 # Return 1 if the target OS supports running SSE executables, 0
1158 # otherwise. Cache the result.
1160 proc check_sse_os_support_available { } {
1161 return [check_cached_effective_target sse_os_support_available {
1162 # If this is not the right target then we can skip the test.
1163 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1164 expr 0
1165 } elseif { [istarget i?86-*-solaris2*] } {
1166 # The Solaris 2 kernel doesn't save and restore SSE registers
1167 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1168 check_runtime_nocache sse_os_support_available {
1169 int main ()
1171 asm volatile ("movaps %xmm0,%xmm0");
1172 return 0;
1174 } "-msse"
1175 } else {
1176 expr 1
1181 # Return 1 if the target OS supports running AVX executables, 0
1182 # otherwise. Cache the result.
1184 proc check_avx_os_support_available { } {
1185 return [check_cached_effective_target avx_os_support_available {
1186 # If this is not the right target then we can skip the test.
1187 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1188 expr 0
1189 } else {
1190 # Check that OS has AVX and SSE saving enabled.
1191 check_runtime_nocache avx_os_support_available {
1192 int main ()
1194 unsigned int eax, edx;
1196 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1197 return (eax & 6) != 6;
1199 } ""
1204 # Return 1 if the target supports executing SSE instructions, 0
1205 # otherwise. Cache the result.
1207 proc check_sse_hw_available { } {
1208 return [check_cached_effective_target sse_hw_available {
1209 # If this is not the right target then we can skip the test.
1210 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1211 expr 0
1212 } else {
1213 check_runtime_nocache sse_hw_available {
1214 #include "cpuid.h"
1215 int main ()
1217 unsigned int eax, ebx, ecx, edx;
1218 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1219 return !(edx & bit_SSE);
1220 return 1;
1222 } ""
1227 # Return 1 if the target supports executing SSE2 instructions, 0
1228 # otherwise. Cache the result.
1230 proc check_sse2_hw_available { } {
1231 return [check_cached_effective_target sse2_hw_available {
1232 # If this is not the right target then we can skip the test.
1233 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1234 expr 0
1235 } else {
1236 check_runtime_nocache sse2_hw_available {
1237 #include "cpuid.h"
1238 int main ()
1240 unsigned int eax, ebx, ecx, edx;
1241 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1242 return !(edx & bit_SSE2);
1243 return 1;
1245 } ""
1250 # Return 1 if the target supports executing AVX instructions, 0
1251 # otherwise. Cache the result.
1253 proc check_avx_hw_available { } {
1254 return [check_cached_effective_target avx_hw_available {
1255 # If this is not the right target then we can skip the test.
1256 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1257 expr 0
1258 } else {
1259 check_runtime_nocache avx_hw_available {
1260 #include "cpuid.h"
1261 int main ()
1263 unsigned int eax, ebx, ecx, edx;
1264 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1265 return ((ecx & (bit_AVX | bit_OSXSAVE))
1266 != (bit_AVX | bit_OSXSAVE));
1267 return 1;
1269 } ""
1274 # Return 1 if the target supports running SSE executables, 0 otherwise.
1276 proc check_effective_target_sse_runtime { } {
1277 if { [check_effective_target_sse]
1278 && [check_sse_hw_available]
1279 && [check_sse_os_support_available] } {
1280 return 1
1282 return 0
1285 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1287 proc check_effective_target_sse2_runtime { } {
1288 if { [check_effective_target_sse2]
1289 && [check_sse2_hw_available]
1290 && [check_sse_os_support_available] } {
1291 return 1
1293 return 0
1296 # Return 1 if the target supports running AVX executables, 0 otherwise.
1298 proc check_effective_target_avx_runtime { } {
1299 if { [check_effective_target_avx]
1300 && [check_avx_hw_available]
1301 && [check_avx_os_support_available] } {
1302 return 1
1304 return 0
1307 # Return 1 if the target supports executing power8 vector instructions, 0
1308 # otherwise. Cache the result.
1310 proc check_p8vector_hw_available { } {
1311 return [check_cached_effective_target p8vector_hw_available {
1312 # Some simulators are known to not support VSX/power8 instructions.
1313 # For now, disable on Darwin
1314 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1315 expr 0
1316 } else {
1317 set options "-mpower8-vector"
1318 check_runtime_nocache p8vector_hw_available {
1319 int main()
1321 #ifdef __MACH__
1322 asm volatile ("xxlorc vs0,vs0,vs0");
1323 #else
1324 asm volatile ("xxlorc 0,0,0");
1325 #endif
1326 return 0;
1328 } $options
1333 # Return 1 if the target supports executing VSX instructions, 0
1334 # otherwise. Cache the result.
1336 proc check_vsx_hw_available { } {
1337 return [check_cached_effective_target vsx_hw_available {
1338 # Some simulators are known to not support VSX instructions.
1339 # For now, disable on Darwin
1340 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1341 expr 0
1342 } else {
1343 set options "-mvsx"
1344 check_runtime_nocache vsx_hw_available {
1345 int main()
1347 #ifdef __MACH__
1348 asm volatile ("xxlor vs0,vs0,vs0");
1349 #else
1350 asm volatile ("xxlor 0,0,0");
1351 #endif
1352 return 0;
1354 } $options
1359 # Return 1 if the target supports executing AltiVec instructions, 0
1360 # otherwise. Cache the result.
1362 proc check_vmx_hw_available { } {
1363 return [check_cached_effective_target vmx_hw_available {
1364 # Some simulators are known to not support VMX instructions.
1365 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1366 expr 0
1367 } else {
1368 # Most targets don't require special flags for this test case, but
1369 # Darwin does. Just to be sure, make sure VSX is not enabled for
1370 # the altivec tests.
1371 if { [istarget *-*-darwin*]
1372 || [istarget *-*-aix*] } {
1373 set options "-maltivec -mno-vsx"
1374 } else {
1375 set options "-mno-vsx"
1377 check_runtime_nocache vmx_hw_available {
1378 int main()
1380 #ifdef __MACH__
1381 asm volatile ("vor v0,v0,v0");
1382 #else
1383 asm volatile ("vor 0,0,0");
1384 #endif
1385 return 0;
1387 } $options
1392 proc check_ppc_recip_hw_available { } {
1393 return [check_cached_effective_target ppc_recip_hw_available {
1394 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1395 # For now, disable on Darwin
1396 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1397 expr 0
1398 } else {
1399 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1400 check_runtime_nocache ppc_recip_hw_available {
1401 volatile double d_recip, d_rsqrt, d_four = 4.0;
1402 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1403 int main()
1405 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1406 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1407 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1408 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1409 return 0;
1411 } $options
1416 # Return 1 if the target supports executing AltiVec and Cell PPU
1417 # instructions, 0 otherwise. Cache the result.
1419 proc check_effective_target_cell_hw { } {
1420 return [check_cached_effective_target cell_hw_available {
1421 # Some simulators are known to not support VMX and PPU instructions.
1422 if { [istarget powerpc-*-eabi*] } {
1423 expr 0
1424 } else {
1425 # Most targets don't require special flags for this test
1426 # case, but Darwin and AIX do.
1427 if { [istarget *-*-darwin*]
1428 || [istarget *-*-aix*] } {
1429 set options "-maltivec -mcpu=cell"
1430 } else {
1431 set options "-mcpu=cell"
1433 check_runtime_nocache cell_hw_available {
1434 int main()
1436 #ifdef __MACH__
1437 asm volatile ("vor v0,v0,v0");
1438 asm volatile ("lvlx v0,r0,r0");
1439 #else
1440 asm volatile ("vor 0,0,0");
1441 asm volatile ("lvlx 0,0,0");
1442 #endif
1443 return 0;
1445 } $options
1450 # Return 1 if the target supports executing 64-bit instructions, 0
1451 # otherwise. Cache the result.
1453 proc check_effective_target_powerpc64 { } {
1454 global powerpc64_available_saved
1455 global tool
1457 if [info exists powerpc64_available_saved] {
1458 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1459 } else {
1460 set powerpc64_available_saved 0
1462 # Some simulators are known to not support powerpc64 instructions.
1463 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1464 verbose "check_effective_target_powerpc64 returning 0" 2
1465 return $powerpc64_available_saved
1468 # Set up, compile, and execute a test program containing a 64-bit
1469 # instruction. Include the current process ID in the file
1470 # names to prevent conflicts with invocations for multiple
1471 # testsuites.
1472 set src ppc[pid].c
1473 set exe ppc[pid].x
1475 set f [open $src "w"]
1476 puts $f "int main() {"
1477 puts $f "#ifdef __MACH__"
1478 puts $f " asm volatile (\"extsw r0,r0\");"
1479 puts $f "#else"
1480 puts $f " asm volatile (\"extsw 0,0\");"
1481 puts $f "#endif"
1482 puts $f " return 0; }"
1483 close $f
1485 set opts "additional_flags=-mcpu=G5"
1487 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1488 set lines [${tool}_target_compile $src $exe executable "$opts"]
1489 file delete $src
1491 if [string match "" $lines] then {
1492 # No error message, compilation succeeded.
1493 set result [${tool}_load "./$exe" "" ""]
1494 set status [lindex $result 0]
1495 remote_file build delete $exe
1496 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1498 if { $status == "pass" } then {
1499 set powerpc64_available_saved 1
1501 } else {
1502 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1506 return $powerpc64_available_saved
1509 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1510 # complex float arguments. This affects gfortran tests that call cabsf
1511 # in libm built by an earlier compiler. Return 1 if libm uses the same
1512 # argument passing as the compiler under test, 0 otherwise.
1514 # When the target name changes, replace the cached result.
1516 proc check_effective_target_broken_cplxf_arg { } {
1517 return [check_cached_effective_target broken_cplxf_arg {
1518 # Skip the work for targets known not to be affected.
1519 if { ![istarget powerpc64-*-linux*] } {
1520 expr 0
1521 } elseif { ![is-effective-target lp64] } {
1522 expr 0
1523 } else {
1524 check_runtime_nocache broken_cplxf_arg {
1525 #include <complex.h>
1526 extern void abort (void);
1527 float fabsf (float);
1528 float cabsf (_Complex float);
1529 int main ()
1531 _Complex float cf;
1532 float f;
1533 cf = 3 + 4.0fi;
1534 f = cabsf (cf);
1535 if (fabsf (f - 5.0) > 0.0001)
1536 abort ();
1537 return 0;
1539 } "-lm"
1544 # Return 1 is this is a TI C6X target supporting C67X instructions
1545 proc check_effective_target_ti_c67x { } {
1546 return [check_no_compiler_messages ti_c67x assembly {
1547 #if !defined(_TMS320C6700)
1548 #error FOO
1549 #endif
1553 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1554 proc check_effective_target_ti_c64xp { } {
1555 return [check_no_compiler_messages ti_c64xp assembly {
1556 #if !defined(_TMS320C6400_PLUS)
1557 #error FOO
1558 #endif
1563 proc check_alpha_max_hw_available { } {
1564 return [check_runtime alpha_max_hw_available {
1565 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1569 # Returns true iff the FUNCTION is available on the target system.
1570 # (This is essentially a Tcl implementation of Autoconf's
1571 # AC_CHECK_FUNC.)
1573 proc check_function_available { function } {
1574 return [check_no_compiler_messages ${function}_available \
1575 executable [subst {
1576 #ifdef __cplusplus
1577 extern "C"
1578 #endif
1579 char $function ();
1580 int main () { $function (); }
1581 }] "-fno-builtin" ]
1584 # Returns true iff "fork" is available on the target system.
1586 proc check_fork_available {} {
1587 return [check_function_available "fork"]
1590 # Returns true iff "mkfifo" is available on the target system.
1592 proc check_mkfifo_available {} {
1593 if { [istarget *-*-cygwin*] } {
1594 # Cygwin has mkfifo, but support is incomplete.
1595 return 0
1598 return [check_function_available "mkfifo"]
1601 # Returns true iff "__cxa_atexit" is used on the target system.
1603 proc check_cxa_atexit_available { } {
1604 return [check_cached_effective_target cxa_atexit_available {
1605 if { [istarget hppa*-*-hpux10*] } {
1606 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1607 expr 0
1608 } elseif { [istarget *-*-vxworks] } {
1609 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1610 expr 0
1611 } else {
1612 check_runtime_nocache cxa_atexit_available {
1613 // C++
1614 #include <stdlib.h>
1615 static unsigned int count;
1616 struct X
1618 X() { count = 1; }
1619 ~X()
1621 if (count != 3)
1622 exit(1);
1623 count = 4;
1626 void f()
1628 static X x;
1630 struct Y
1632 Y() { f(); count = 2; }
1633 ~Y()
1635 if (count != 2)
1636 exit(1);
1637 count = 3;
1640 Y y;
1641 int main() { return 0; }
1647 proc check_effective_target_objc2 { } {
1648 return [check_no_compiler_messages objc2 object {
1649 #ifdef __OBJC2__
1650 int dummy[1];
1651 #else
1652 #error
1653 #endif
1657 proc check_effective_target_next_runtime { } {
1658 return [check_no_compiler_messages objc2 object {
1659 #ifdef __NEXT_RUNTIME__
1660 int dummy[1];
1661 #else
1662 #error
1663 #endif
1667 # Return 1 if we're generating 32-bit code using default options, 0
1668 # otherwise.
1670 proc check_effective_target_ilp32 { } {
1671 return [check_no_compiler_messages ilp32 object {
1672 int dummy[sizeof (int) == 4
1673 && sizeof (void *) == 4
1674 && sizeof (long) == 4 ? 1 : -1];
1678 # Return 1 if we're generating ia32 code using default options, 0
1679 # otherwise.
1681 proc check_effective_target_ia32 { } {
1682 return [check_no_compiler_messages ia32 object {
1683 int dummy[sizeof (int) == 4
1684 && sizeof (void *) == 4
1685 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1689 # Return 1 if we're generating x32 code using default options, 0
1690 # otherwise.
1692 proc check_effective_target_x32 { } {
1693 return [check_no_compiler_messages x32 object {
1694 int dummy[sizeof (int) == 4
1695 && sizeof (void *) == 4
1696 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1700 # Return 1 if we're generating 32-bit or larger integers using default
1701 # options, 0 otherwise.
1703 proc check_effective_target_int32plus { } {
1704 return [check_no_compiler_messages int32plus object {
1705 int dummy[sizeof (int) >= 4 ? 1 : -1];
1709 # Return 1 if we're generating 32-bit or larger pointers using default
1710 # options, 0 otherwise.
1712 proc check_effective_target_ptr32plus { } {
1713 return [check_no_compiler_messages ptr32plus object {
1714 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1718 # Return 1 if we support 32-bit or larger array and structure sizes
1719 # using default options, 0 otherwise.
1721 proc check_effective_target_size32plus { } {
1722 return [check_no_compiler_messages size32plus object {
1723 char dummy[65537];
1727 # Returns 1 if we're generating 16-bit or smaller integers with the
1728 # default options, 0 otherwise.
1730 proc check_effective_target_int16 { } {
1731 return [check_no_compiler_messages int16 object {
1732 int dummy[sizeof (int) < 4 ? 1 : -1];
1736 # Return 1 if we're generating 64-bit code using default options, 0
1737 # otherwise.
1739 proc check_effective_target_lp64 { } {
1740 return [check_no_compiler_messages lp64 object {
1741 int dummy[sizeof (int) == 4
1742 && sizeof (void *) == 8
1743 && sizeof (long) == 8 ? 1 : -1];
1747 # Return 1 if we're generating 64-bit code using default llp64 options,
1748 # 0 otherwise.
1750 proc check_effective_target_llp64 { } {
1751 return [check_no_compiler_messages llp64 object {
1752 int dummy[sizeof (int) == 4
1753 && sizeof (void *) == 8
1754 && sizeof (long long) == 8
1755 && sizeof (long) == 4 ? 1 : -1];
1759 # Return 1 if long and int have different sizes,
1760 # 0 otherwise.
1762 proc check_effective_target_long_neq_int { } {
1763 return [check_no_compiler_messages long_ne_int object {
1764 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
1768 # Return 1 if the target supports long double larger than double,
1769 # 0 otherwise.
1771 proc check_effective_target_large_long_double { } {
1772 return [check_no_compiler_messages large_long_double object {
1773 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1777 # Return 1 if the target supports double larger than float,
1778 # 0 otherwise.
1780 proc check_effective_target_large_double { } {
1781 return [check_no_compiler_messages large_double object {
1782 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1786 # Return 1 if the target supports long double of 128 bits,
1787 # 0 otherwise.
1789 proc check_effective_target_longdouble128 { } {
1790 return [check_no_compiler_messages longdouble128 object {
1791 int dummy[sizeof(long double) == 16 ? 1 : -1];
1795 # Return 1 if the target supports double of 64 bits,
1796 # 0 otherwise.
1798 proc check_effective_target_double64 { } {
1799 return [check_no_compiler_messages double64 object {
1800 int dummy[sizeof(double) == 8 ? 1 : -1];
1804 # Return 1 if the target supports double of at least 64 bits,
1805 # 0 otherwise.
1807 proc check_effective_target_double64plus { } {
1808 return [check_no_compiler_messages double64plus object {
1809 int dummy[sizeof(double) >= 8 ? 1 : -1];
1813 # Return 1 if the target supports 'w' suffix on floating constant
1814 # 0 otherwise.
1816 proc check_effective_target_has_w_floating_suffix { } {
1817 set opts ""
1818 if [check_effective_target_c++] {
1819 append opts "-std=gnu++03"
1821 return [check_no_compiler_messages w_fp_suffix object {
1822 float dummy = 1.0w;
1823 } "$opts"]
1826 # Return 1 if the target supports 'q' suffix on floating constant
1827 # 0 otherwise.
1829 proc check_effective_target_has_q_floating_suffix { } {
1830 set opts ""
1831 if [check_effective_target_c++] {
1832 append opts "-std=gnu++03"
1834 return [check_no_compiler_messages q_fp_suffix object {
1835 float dummy = 1.0q;
1836 } "$opts"]
1838 # Return 1 if the target supports compiling fixed-point,
1839 # 0 otherwise.
1841 proc check_effective_target_fixed_point { } {
1842 return [check_no_compiler_messages fixed_point object {
1843 _Sat _Fract x; _Sat _Accum y;
1847 # Return 1 if the target supports compiling decimal floating point,
1848 # 0 otherwise.
1850 proc check_effective_target_dfp_nocache { } {
1851 verbose "check_effective_target_dfp_nocache: compiling source" 2
1852 set ret [check_no_compiler_messages_nocache dfp object {
1853 float x __attribute__((mode(DD)));
1855 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1856 return $ret
1859 proc check_effective_target_dfprt_nocache { } {
1860 return [check_runtime_nocache dfprt {
1861 typedef float d64 __attribute__((mode(DD)));
1862 d64 x = 1.2df, y = 2.3dd, z;
1863 int main () { z = x + y; return 0; }
1867 # Return 1 if the target supports compiling Decimal Floating Point,
1868 # 0 otherwise.
1870 # This won't change for different subtargets so cache the result.
1872 proc check_effective_target_dfp { } {
1873 return [check_cached_effective_target dfp {
1874 check_effective_target_dfp_nocache
1878 # Return 1 if the target supports linking and executing Decimal Floating
1879 # Point, 0 otherwise.
1881 # This won't change for different subtargets so cache the result.
1883 proc check_effective_target_dfprt { } {
1884 return [check_cached_effective_target dfprt {
1885 check_effective_target_dfprt_nocache
1889 # Return 1 if the target supports executing DFP hardware instructions,
1890 # 0 otherwise. Cache the result.
1892 proc check_dfp_hw_available { } {
1893 return [check_cached_effective_target dfp_hw_available {
1894 # For now, disable on Darwin
1895 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1896 expr 0
1897 } else {
1898 check_runtime_nocache dfp_hw_available {
1899 volatile _Decimal64 r;
1900 volatile _Decimal64 a = 4.0DD;
1901 volatile _Decimal64 b = 2.0DD;
1902 int main()
1904 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
1905 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
1906 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
1907 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
1908 return 0;
1910 } "-mcpu=power6 -mhard-float"
1915 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1917 proc check_effective_target_ucn_nocache { } {
1918 # -std=c99 is only valid for C
1919 if [check_effective_target_c] {
1920 set ucnopts "-std=c99"
1922 append ucnopts " -fextended-identifiers"
1923 verbose "check_effective_target_ucn_nocache: compiling source" 2
1924 set ret [check_no_compiler_messages_nocache ucn object {
1925 int \u00C0;
1926 } $ucnopts]
1927 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1928 return $ret
1931 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1933 # This won't change for different subtargets, so cache the result.
1935 proc check_effective_target_ucn { } {
1936 return [check_cached_effective_target ucn {
1937 check_effective_target_ucn_nocache
1941 # Return 1 if the target needs a command line argument to enable a SIMD
1942 # instruction set.
1944 proc check_effective_target_vect_cmdline_needed { } {
1945 global et_vect_cmdline_needed_saved
1946 global et_vect_cmdline_needed_target_name
1948 if { ![info exists et_vect_cmdline_needed_target_name] } {
1949 set et_vect_cmdline_needed_target_name ""
1952 # If the target has changed since we set the cached value, clear it.
1953 set current_target [current_target_name]
1954 if { $current_target != $et_vect_cmdline_needed_target_name } {
1955 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1956 set et_vect_cmdline_needed_target_name $current_target
1957 if { [info exists et_vect_cmdline_needed_saved] } {
1958 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1959 unset et_vect_cmdline_needed_saved
1963 if [info exists et_vect_cmdline_needed_saved] {
1964 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1965 } else {
1966 set et_vect_cmdline_needed_saved 1
1967 if { [istarget alpha*-*-*]
1968 || [istarget ia64-*-*]
1969 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1970 && ([check_effective_target_x32]
1971 || [check_effective_target_lp64]))
1972 || ([istarget powerpc*-*-*]
1973 && ([check_effective_target_powerpc_spe]
1974 || [check_effective_target_powerpc_altivec]))
1975 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1976 || [istarget spu-*-*]
1977 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1978 set et_vect_cmdline_needed_saved 0
1982 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1983 return $et_vect_cmdline_needed_saved
1986 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1988 # This won't change for different subtargets so cache the result.
1990 proc check_effective_target_vect_int { } {
1991 global et_vect_int_saved
1993 if [info exists et_vect_int_saved] {
1994 verbose "check_effective_target_vect_int: using cached result" 2
1995 } else {
1996 set et_vect_int_saved 0
1997 if { [istarget i?86-*-*]
1998 || ([istarget powerpc*-*-*]
1999 && ![istarget powerpc-*-linux*paired*])
2000 || [istarget spu-*-*]
2001 || [istarget x86_64-*-*]
2002 || [istarget sparc*-*-*]
2003 || [istarget alpha*-*-*]
2004 || [istarget ia64-*-*]
2005 || [istarget aarch64*-*-*]
2006 || [check_effective_target_arm32]
2007 || ([istarget mips*-*-*]
2008 && [check_effective_target_mips_loongson]) } {
2009 set et_vect_int_saved 1
2013 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2014 return $et_vect_int_saved
2017 # Return 1 if the target supports signed int->float conversion
2020 proc check_effective_target_vect_intfloat_cvt { } {
2021 global et_vect_intfloat_cvt_saved
2023 if [info exists et_vect_intfloat_cvt_saved] {
2024 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2025 } else {
2026 set et_vect_intfloat_cvt_saved 0
2027 if { [istarget i?86-*-*]
2028 || ([istarget powerpc*-*-*]
2029 && ![istarget powerpc-*-linux*paired*])
2030 || [istarget x86_64-*-*]
2031 || ([istarget arm*-*-*]
2032 && [check_effective_target_arm_neon_ok])} {
2033 set et_vect_intfloat_cvt_saved 1
2037 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2038 return $et_vect_intfloat_cvt_saved
2041 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2043 proc check_effective_target_int128 { } {
2044 return [check_no_compiler_messages int128 object {
2045 int dummy[
2046 #ifndef __SIZEOF_INT128__
2048 #else
2050 #endif
2055 # Return 1 if the target supports unsigned int->float conversion
2058 proc check_effective_target_vect_uintfloat_cvt { } {
2059 global et_vect_uintfloat_cvt_saved
2061 if [info exists et_vect_uintfloat_cvt_saved] {
2062 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2063 } else {
2064 set et_vect_uintfloat_cvt_saved 0
2065 if { [istarget i?86-*-*]
2066 || ([istarget powerpc*-*-*]
2067 && ![istarget powerpc-*-linux*paired*])
2068 || [istarget x86_64-*-*]
2069 || [istarget aarch64*-*-*]
2070 || ([istarget arm*-*-*]
2071 && [check_effective_target_arm_neon_ok])} {
2072 set et_vect_uintfloat_cvt_saved 1
2076 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2077 return $et_vect_uintfloat_cvt_saved
2081 # Return 1 if the target supports signed float->int conversion
2084 proc check_effective_target_vect_floatint_cvt { } {
2085 global et_vect_floatint_cvt_saved
2087 if [info exists et_vect_floatint_cvt_saved] {
2088 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2089 } else {
2090 set et_vect_floatint_cvt_saved 0
2091 if { [istarget i?86-*-*]
2092 || ([istarget powerpc*-*-*]
2093 && ![istarget powerpc-*-linux*paired*])
2094 || [istarget x86_64-*-*]
2095 || ([istarget arm*-*-*]
2096 && [check_effective_target_arm_neon_ok])} {
2097 set et_vect_floatint_cvt_saved 1
2101 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2102 return $et_vect_floatint_cvt_saved
2105 # Return 1 if the target supports unsigned float->int conversion
2108 proc check_effective_target_vect_floatuint_cvt { } {
2109 global et_vect_floatuint_cvt_saved
2111 if [info exists et_vect_floatuint_cvt_saved] {
2112 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2113 } else {
2114 set et_vect_floatuint_cvt_saved 0
2115 if { ([istarget powerpc*-*-*]
2116 && ![istarget powerpc-*-linux*paired*])
2117 || ([istarget arm*-*-*]
2118 && [check_effective_target_arm_neon_ok])} {
2119 set et_vect_floatuint_cvt_saved 1
2123 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2124 return $et_vect_floatuint_cvt_saved
2127 # Return 1 if this is a AArch64 target supporting big endian
2128 proc check_effective_target_aarch64_big_endian { } {
2129 return [check_no_compiler_messages aarch64_big_endian assembly {
2130 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2131 #error FOO
2132 #endif
2136 # Return 1 if this is a AArch64 target supporting little endian
2137 proc check_effective_target_aarch64_little_endian { } {
2138 return [check_no_compiler_messages aarch64_little_endian assembly {
2139 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2140 #error FOO
2141 #endif
2145 # Return 1 is this is an arm target using 32-bit instructions
2146 proc check_effective_target_arm32 { } {
2147 return [check_no_compiler_messages arm32 assembly {
2148 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2149 #error FOO
2150 #endif
2154 # Return 1 is this is an arm target not using Thumb
2155 proc check_effective_target_arm_nothumb { } {
2156 return [check_no_compiler_messages arm_nothumb assembly {
2157 #if (defined(__thumb__) || defined(__thumb2__))
2158 #error FOO
2159 #endif
2163 # Return 1 if this is a little-endian ARM target
2164 proc check_effective_target_arm_little_endian { } {
2165 return [check_no_compiler_messages arm_little_endian assembly {
2166 #if !defined(__arm__) || !defined(__ARMEL__)
2167 #error FOO
2168 #endif
2172 # Return 1 if this is an ARM target that only supports aligned vector accesses
2173 proc check_effective_target_arm_vect_no_misalign { } {
2174 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2175 #if !defined(__arm__) \
2176 || (defined(__ARMEL__) \
2177 && (!defined(__thumb__) || defined(__thumb2__)))
2178 #error FOO
2179 #endif
2184 # Return 1 if this is an ARM target supporting -mfpu=vfp
2185 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2186 # options.
2188 proc check_effective_target_arm_vfp_ok { } {
2189 if { [check_effective_target_arm32] } {
2190 return [check_no_compiler_messages arm_vfp_ok object {
2191 int dummy;
2192 } "-mfpu=vfp -mfloat-abi=softfp"]
2193 } else {
2194 return 0
2198 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2199 # -mfloat-abi=softfp.
2200 proc check_effective_target_arm_v8_vfp_ok {} {
2201 if { [check_effective_target_arm32] } {
2202 return [check_no_compiler_messages arm_v8_vfp_ok object {
2203 int foo (void)
2205 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2206 return 0;
2208 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2209 } else {
2210 return 0
2214 # Return 1 if this is an ARM target supporting -mfpu=vfp
2215 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2216 # options.
2218 proc check_effective_target_arm_hard_vfp_ok { } {
2219 if { [check_effective_target_arm32]
2220 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2221 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2222 int main() { return 0;}
2223 } "-mfpu=vfp -mfloat-abi=hard"]
2224 } else {
2225 return 0
2229 # Return 1 if this is an ARM target that supports DSP multiply with
2230 # current multilib flags.
2232 proc check_effective_target_arm_dsp { } {
2233 return [check_no_compiler_messages arm_dsp assembly {
2234 #ifndef __ARM_FEATURE_DSP
2235 #error not DSP
2236 #endif
2237 int i;
2241 # Return 1 if this is an ARM target that supports unaligned word/halfword
2242 # load/store instructions.
2244 proc check_effective_target_arm_unaligned { } {
2245 return [check_no_compiler_messages arm_unaligned assembly {
2246 #ifndef __ARM_FEATURE_UNALIGNED
2247 #error no unaligned support
2248 #endif
2249 int i;
2253 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2254 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2255 # incompatible with these options. Also set et_arm_crypto_flags to the
2256 # best options to add.
2258 proc check_effective_target_arm_crypto_ok_nocache { } {
2259 global et_arm_crypto_flags
2260 set et_arm_crypto_flags ""
2261 if { [check_effective_target_arm32] } {
2262 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2263 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2264 #include "arm_neon.h"
2265 uint8x16_t
2266 foo (uint8x16_t a, uint8x16_t b)
2268 return vaeseq_u8 (a, b);
2270 } "$flags"] } {
2271 set et_arm_crypto_flags $flags
2272 return 1
2277 return 0
2280 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2282 proc check_effective_target_arm_crypto_ok { } {
2283 return [check_cached_effective_target arm_crypto_ok \
2284 check_effective_target_arm_crypto_ok_nocache]
2287 # Add options for crypto extensions.
2288 proc add_options_for_arm_crypto { flags } {
2289 if { ! [check_effective_target_arm_crypto_ok] } {
2290 return "$flags"
2292 global et_arm_crypto_flags
2293 return "$flags $et_arm_crypto_flags"
2296 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2297 # or -mfloat-abi=hard, but if one is already specified by the
2298 # multilib, use it. Similarly, if a -mfpu option already enables
2299 # NEON, do not add -mfpu=neon.
2301 proc add_options_for_arm_neon { flags } {
2302 if { ! [check_effective_target_arm_neon_ok] } {
2303 return "$flags"
2305 global et_arm_neon_flags
2306 return "$flags $et_arm_neon_flags"
2309 proc add_options_for_arm_v8_vfp { flags } {
2310 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2311 return "$flags"
2313 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2316 proc add_options_for_arm_v8_neon { flags } {
2317 if { ! [check_effective_target_arm_v8_neon_ok] } {
2318 return "$flags"
2320 global et_arm_v8_neon_flags
2321 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2324 proc add_options_for_arm_crc { flags } {
2325 if { ! [check_effective_target_arm_crc_ok] } {
2326 return "$flags"
2328 global et_arm_crc_flags
2329 return "$flags $et_arm_crc_flags"
2332 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2333 # or -mfloat-abi=hard, but if one is already specified by the
2334 # multilib, use it. Similarly, if a -mfpu option already enables
2335 # NEON, do not add -mfpu=neon.
2337 proc add_options_for_arm_neonv2 { flags } {
2338 if { ! [check_effective_target_arm_neonv2_ok] } {
2339 return "$flags"
2341 global et_arm_neonv2_flags
2342 return "$flags $et_arm_neonv2_flags"
2345 # Return 1 if this is an ARM target supporting -mfpu=neon
2346 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2347 # incompatible with these options. Also set et_arm_neon_flags to the
2348 # best options to add.
2350 proc check_effective_target_arm_neon_ok_nocache { } {
2351 global et_arm_neon_flags
2352 set et_arm_neon_flags ""
2353 if { [check_effective_target_arm32] } {
2354 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2355 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2356 #include "arm_neon.h"
2357 int dummy;
2358 } "$flags"] } {
2359 set et_arm_neon_flags $flags
2360 return 1
2365 return 0
2368 proc check_effective_target_arm_neon_ok { } {
2369 return [check_cached_effective_target arm_neon_ok \
2370 check_effective_target_arm_neon_ok_nocache]
2373 proc check_effective_target_arm_crc_ok_nocache { } {
2374 global et_arm_crc_flags
2375 set et_arm_crc_flags "-march=armv8-a+crc"
2376 return [check_no_compiler_messages_nocache arm_crc_ok object {
2377 #if !defined (__ARM_FEATURE_CRC32)
2378 #error FOO
2379 #endif
2380 } "$et_arm_crc_flags"]
2383 proc check_effective_target_arm_crc_ok { } {
2384 return [check_cached_effective_target arm_crc_ok \
2385 check_effective_target_arm_crc_ok_nocache]
2388 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2389 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2390 # incompatible with these options. Also set et_arm_neon_flags to the
2391 # best options to add.
2393 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2394 global et_arm_neon_fp16_flags
2395 set et_arm_neon_fp16_flags ""
2396 if { [check_effective_target_arm32] } {
2397 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2398 "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
2399 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
2400 #include "arm_neon.h"
2401 float16x4_t
2402 foo (float32x4_t arg)
2404 return vcvt_f16_f32 (arg);
2406 } "$flags"] } {
2407 set et_arm_neon_fp16_flags $flags
2408 return 1
2413 return 0
2416 proc check_effective_target_arm_neon_fp16_ok { } {
2417 return [check_cached_effective_target arm_neon_fp16_ok \
2418 check_effective_target_arm_neon_fp16_ok_nocache]
2421 proc add_options_for_arm_neon_fp16 { flags } {
2422 if { ! [check_effective_target_arm_neon_fp16_ok] } {
2423 return "$flags"
2425 global et_arm_neon_fp16_flags
2426 return "$flags $et_arm_neon_fp16_flags"
2429 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2430 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2431 # incompatible with these options. Also set et_arm_v8_neon_flags to the
2432 # best options to add.
2434 proc check_effective_target_arm_v8_neon_ok_nocache { } {
2435 global et_arm_v8_neon_flags
2436 set et_arm_v8_neon_flags ""
2437 if { [check_effective_target_arm32] } {
2438 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
2439 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
2440 #include "arm_neon.h"
2441 void
2442 foo ()
2444 __asm__ volatile ("vrintn.f32 q0, q0");
2446 } "$flags"] } {
2447 set et_arm_v8_neon_flags $flags
2448 return 1
2453 return 0
2456 proc check_effective_target_arm_v8_neon_ok { } {
2457 return [check_cached_effective_target arm_v8_neon_ok \
2458 check_effective_target_arm_v8_neon_ok_nocache]
2461 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2462 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2463 # incompatible with these options. Also set et_arm_neonv2_flags to the
2464 # best options to add.
2466 proc check_effective_target_arm_neonv2_ok_nocache { } {
2467 global et_arm_neonv2_flags
2468 set et_arm_neonv2_flags ""
2469 if { [check_effective_target_arm32] } {
2470 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2471 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2472 #include "arm_neon.h"
2473 float32x2_t
2474 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2476 return vfma_f32 (a, b, c);
2478 } "$flags"] } {
2479 set et_arm_neonv2_flags $flags
2480 return 1
2485 return 0
2488 proc check_effective_target_arm_neonv2_ok { } {
2489 return [check_cached_effective_target arm_neonv2_ok \
2490 check_effective_target_arm_neonv2_ok_nocache]
2493 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2494 # or -mfloat-abi=hard, but if one is already specified by the
2495 # multilib, use it.
2497 proc add_options_for_arm_fp16 { flags } {
2498 if { ! [check_effective_target_arm_fp16_ok] } {
2499 return "$flags"
2501 global et_arm_fp16_flags
2502 return "$flags $et_arm_fp16_flags"
2505 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2506 # Skip multilibs that are incompatible with these options and set
2507 # et_arm_fp16_flags to the best options to add.
2509 proc check_effective_target_arm_fp16_ok_nocache { } {
2510 global et_arm_fp16_flags
2511 set et_arm_fp16_flags ""
2512 if { ! [check_effective_target_arm32] } {
2513 return 0;
2515 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2516 # Multilib flags would override -mfpu.
2517 return 0
2519 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2520 # Must generate floating-point instructions.
2521 return 0
2523 if [check_effective_target_arm_hf_eabi] {
2524 # Use existing float-abi and force an fpu which supports fp16
2525 set et_arm_fp16_flags "-mfpu=vfpv4"
2526 return 1;
2528 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2529 # The existing -mfpu value is OK; use it, but add softfp.
2530 set et_arm_fp16_flags "-mfloat-abi=softfp"
2531 return 1;
2533 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2534 # macro to check for this support.
2535 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2536 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2537 int dummy;
2538 } "$flags"] } {
2539 set et_arm_fp16_flags "$flags"
2540 return 1
2543 return 0
2546 proc check_effective_target_arm_fp16_ok { } {
2547 return [check_cached_effective_target arm_fp16_ok \
2548 check_effective_target_arm_fp16_ok_nocache]
2551 # Creates a series of routines that return 1 if the given architecture
2552 # can be selected and a routine to give the flags to select that architecture
2553 # Note: Extra flags may be added to disable options from newer compilers
2554 # (Thumb in particular - but others may be added in the future)
2555 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2556 # /* { dg-add-options arm_arch_v5 } */
2557 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2558 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2559 v4t "-march=armv4t" __ARM_ARCH_4T__
2560 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2561 v5t "-march=armv5t" __ARM_ARCH_5T__
2562 v5te "-march=armv5te" __ARM_ARCH_5TE__
2563 v6 "-march=armv6" __ARM_ARCH_6__
2564 v6k "-march=armv6k" __ARM_ARCH_6K__
2565 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2566 v6z "-march=armv6z" __ARM_ARCH_6Z__
2567 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2568 v7a "-march=armv7-a" __ARM_ARCH_7A__
2569 v7r "-march=armv7-r" __ARM_ARCH_7R__
2570 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2571 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2572 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2573 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2574 proc check_effective_target_arm_arch_FUNC_ok { } {
2575 if { [ string match "*-marm*" "FLAG" ] &&
2576 ![check_effective_target_arm_arm_ok] } {
2577 return 0
2579 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2580 #if !defined (DEF)
2581 #error FOO
2582 #endif
2583 } "FLAG" ]
2586 proc add_options_for_arm_arch_FUNC { flags } {
2587 return "$flags FLAG"
2590 proc check_effective_target_arm_arch_FUNC_multilib { } {
2591 return [check_runtime arm_arch_FUNC_multilib {
2593 main (void)
2595 return 0;
2597 } [add_options_for_arm_arch_FUNC ""]]
2602 # Return 1 if this is an ARM target where -marm causes ARM to be
2603 # used (not Thumb)
2605 proc check_effective_target_arm_arm_ok { } {
2606 return [check_no_compiler_messages arm_arm_ok assembly {
2607 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2608 #error FOO
2609 #endif
2610 } "-marm"]
2614 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2615 # used.
2617 proc check_effective_target_arm_thumb1_ok { } {
2618 return [check_no_compiler_messages arm_thumb1_ok assembly {
2619 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2620 #error FOO
2621 #endif
2622 } "-mthumb"]
2625 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2626 # used.
2628 proc check_effective_target_arm_thumb2_ok { } {
2629 return [check_no_compiler_messages arm_thumb2_ok assembly {
2630 #if !defined(__thumb2__)
2631 #error FOO
2632 #endif
2633 } "-mthumb"]
2636 # Return 1 if this is an ARM target where Thumb-1 is used without options
2637 # added by the test.
2639 proc check_effective_target_arm_thumb1 { } {
2640 return [check_no_compiler_messages arm_thumb1 assembly {
2641 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2642 #error not thumb1
2643 #endif
2644 int i;
2645 } ""]
2648 # Return 1 if this is an ARM target where Thumb-2 is used without options
2649 # added by the test.
2651 proc check_effective_target_arm_thumb2 { } {
2652 return [check_no_compiler_messages arm_thumb2 assembly {
2653 #if !defined(__thumb2__)
2654 #error FOO
2655 #endif
2656 int i;
2657 } ""]
2660 # Return 1 if this is an ARM target where conditional execution is available.
2662 proc check_effective_target_arm_cond_exec { } {
2663 return [check_no_compiler_messages arm_cond_exec assembly {
2664 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
2665 #error FOO
2666 #endif
2667 int i;
2668 } ""]
2671 # Return 1 if this is an ARM cortex-M profile cpu
2673 proc check_effective_target_arm_cortex_m { } {
2674 return [check_no_compiler_messages arm_cortex_m assembly {
2675 #if !defined(__ARM_ARCH_7M__) \
2676 && !defined (__ARM_ARCH_7EM__) \
2677 && !defined (__ARM_ARCH_6M__)
2678 #error FOO
2679 #endif
2680 int i;
2681 } "-mthumb"]
2684 # Return 1 if the target supports executing NEON instructions, 0
2685 # otherwise. Cache the result.
2687 proc check_effective_target_arm_neon_hw { } {
2688 return [check_runtime arm_neon_hw_available {
2690 main (void)
2692 long long a = 0, b = 1;
2693 asm ("vorr %P0, %P1, %P2"
2694 : "=w" (a)
2695 : "0" (a), "w" (b));
2696 return (a != 1);
2698 } [add_options_for_arm_neon ""]]
2701 proc check_effective_target_arm_neonv2_hw { } {
2702 return [check_runtime arm_neon_hwv2_available {
2703 #include "arm_neon.h"
2705 main (void)
2707 float32x2_t a, b, c;
2708 asm ("vfma.f32 %P0, %P1, %P2"
2709 : "=w" (a)
2710 : "w" (b), "w" (c));
2711 return 0;
2713 } [add_options_for_arm_neonv2 ""]]
2716 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
2717 # otherwise.
2719 proc check_effective_target_arm_v8_neon_hw { } {
2720 return [check_runtime arm_v8_neon_hw_available {
2721 #include "arm_neon.h"
2723 main (void)
2725 float32x2_t a;
2726 asm ("vrinta.f32 %P0, %P1"
2727 : "=w" (a)
2728 : "0" (a));
2729 return 0;
2731 } [add_options_for_arm_v8_neon ""]]
2734 # Return 1 if this is a ARM target with NEON enabled.
2736 proc check_effective_target_arm_neon { } {
2737 if { [check_effective_target_arm32] } {
2738 return [check_no_compiler_messages arm_neon object {
2739 #ifndef __ARM_NEON__
2740 #error not NEON
2741 #else
2742 int dummy;
2743 #endif
2745 } else {
2746 return 0
2750 proc check_effective_target_arm_neonv2 { } {
2751 if { [check_effective_target_arm32] } {
2752 return [check_no_compiler_messages arm_neon object {
2753 #ifndef __ARM_NEON__
2754 #error not NEON
2755 #else
2756 #ifndef __ARM_FEATURE_FMA
2757 #error not NEONv2
2758 #else
2759 int dummy;
2760 #endif
2761 #endif
2763 } else {
2764 return 0
2768 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2769 # the Loongson vector modes.
2771 proc check_effective_target_mips_loongson { } {
2772 return [check_no_compiler_messages loongson assembly {
2773 #if !defined(__mips_loongson_vector_rev)
2774 #error FOO
2775 #endif
2779 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2780 # Architecture.
2782 proc check_effective_target_arm_eabi { } {
2783 return [check_no_compiler_messages arm_eabi object {
2784 #ifndef __ARM_EABI__
2785 #error not EABI
2786 #else
2787 int dummy;
2788 #endif
2792 # Return 1 if this is an ARM target that adheres to the hard-float variant of
2793 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
2795 proc check_effective_target_arm_hf_eabi { } {
2796 return [check_no_compiler_messages arm_hf_eabi object {
2797 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
2798 #error not hard-float EABI
2799 #else
2800 int dummy;
2801 #endif
2805 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2806 # Some multilibs may be incompatible with this option.
2808 proc check_effective_target_arm_iwmmxt_ok { } {
2809 if { [check_effective_target_arm32] } {
2810 return [check_no_compiler_messages arm_iwmmxt_ok object {
2811 int dummy;
2812 } "-mcpu=iwmmxt"]
2813 } else {
2814 return 0
2818 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
2819 # for an ARM target.
2820 proc check_effective_target_arm_prefer_ldrd_strd { } {
2821 if { ![check_effective_target_arm32] } {
2822 return 0;
2825 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
2826 void foo (int *p) { p[0] = 1; p[1] = 0;}
2827 } "-O2 -mthumb" ]
2830 # Return 1 if this is a PowerPC target supporting -meabi.
2832 proc check_effective_target_powerpc_eabi_ok { } {
2833 if { [istarget powerpc*-*-*] } {
2834 return [check_no_compiler_messages powerpc_eabi_ok object {
2835 int dummy;
2836 } "-meabi"]
2837 } else {
2838 return 0
2842 # Return 1 if this is a PowerPC target with floating-point registers.
2844 proc check_effective_target_powerpc_fprs { } {
2845 if { [istarget powerpc*-*-*]
2846 || [istarget rs6000-*-*] } {
2847 return [check_no_compiler_messages powerpc_fprs object {
2848 #ifdef __NO_FPRS__
2849 #error no FPRs
2850 #else
2851 int dummy;
2852 #endif
2854 } else {
2855 return 0
2859 # Return 1 if this is a PowerPC target with hardware double-precision
2860 # floating point.
2862 proc check_effective_target_powerpc_hard_double { } {
2863 if { [istarget powerpc*-*-*]
2864 || [istarget rs6000-*-*] } {
2865 return [check_no_compiler_messages powerpc_hard_double object {
2866 #ifdef _SOFT_DOUBLE
2867 #error soft double
2868 #else
2869 int dummy;
2870 #endif
2872 } else {
2873 return 0
2877 # Return 1 if this is a PowerPC target supporting -maltivec.
2879 proc check_effective_target_powerpc_altivec_ok { } {
2880 if { ([istarget powerpc*-*-*]
2881 && ![istarget powerpc-*-linux*paired*])
2882 || [istarget rs6000-*-*] } {
2883 # AltiVec is not supported on AIX before 5.3.
2884 if { [istarget powerpc*-*-aix4*]
2885 || [istarget powerpc*-*-aix5.1*]
2886 || [istarget powerpc*-*-aix5.2*] } {
2887 return 0
2889 return [check_no_compiler_messages powerpc_altivec_ok object {
2890 int dummy;
2891 } "-maltivec"]
2892 } else {
2893 return 0
2897 # Return 1 if this is a PowerPC target supporting -mpower8-vector
2899 proc check_effective_target_powerpc_p8vector_ok { } {
2900 if { ([istarget powerpc*-*-*]
2901 && ![istarget powerpc-*-linux*paired*])
2902 || [istarget rs6000-*-*] } {
2903 # AltiVec is not supported on AIX before 5.3.
2904 if { [istarget powerpc*-*-aix4*]
2905 || [istarget powerpc*-*-aix5.1*]
2906 || [istarget powerpc*-*-aix5.2*] } {
2907 return 0
2909 return [check_no_compiler_messages powerpc_p8vector_ok object {
2910 int main (void) {
2911 #ifdef __MACH__
2912 asm volatile ("xxlorc vs0,vs0,vs0");
2913 #else
2914 asm volatile ("xxlorc 0,0,0");
2915 #endif
2916 return 0;
2918 } "-mpower8-vector"]
2919 } else {
2920 return 0
2924 # Return 1 if this is a PowerPC target supporting -mvsx
2926 proc check_effective_target_powerpc_vsx_ok { } {
2927 if { ([istarget powerpc*-*-*]
2928 && ![istarget powerpc-*-linux*paired*])
2929 || [istarget rs6000-*-*] } {
2930 # VSX is not supported on AIX before 7.1.
2931 if { [istarget powerpc*-*-aix4*]
2932 || [istarget powerpc*-*-aix5*]
2933 || [istarget powerpc*-*-aix6*] } {
2934 return 0
2936 return [check_no_compiler_messages powerpc_vsx_ok object {
2937 int main (void) {
2938 #ifdef __MACH__
2939 asm volatile ("xxlor vs0,vs0,vs0");
2940 #else
2941 asm volatile ("xxlor 0,0,0");
2942 #endif
2943 return 0;
2945 } "-mvsx"]
2946 } else {
2947 return 0
2951 # Return 1 if this is a PowerPC target supporting -mhtm
2953 proc check_effective_target_powerpc_htm_ok { } {
2954 if { ([istarget powerpc*-*-*]
2955 && ![istarget powerpc-*-linux*paired*])
2956 || [istarget rs6000-*-*] } {
2957 # HTM is not supported on AIX yet.
2958 if { [istarget powerpc*-*-aix*] } {
2959 return 0
2961 return [check_no_compiler_messages powerpc_htm_ok object {
2962 int main (void) {
2963 asm volatile ("tbegin. 0");
2964 return 0;
2966 } "-mhtm"]
2967 } else {
2968 return 0
2972 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2974 proc check_effective_target_powerpc_ppu_ok { } {
2975 if [check_effective_target_powerpc_altivec_ok] {
2976 return [check_no_compiler_messages cell_asm_available object {
2977 int main (void) {
2978 #ifdef __MACH__
2979 asm volatile ("lvlx v0,v0,v0");
2980 #else
2981 asm volatile ("lvlx 0,0,0");
2982 #endif
2983 return 0;
2986 } else {
2987 return 0
2991 # Return 1 if this is a PowerPC target that supports SPU.
2993 proc check_effective_target_powerpc_spu { } {
2994 if { [istarget powerpc*-*-linux*] } {
2995 return [check_effective_target_powerpc_altivec_ok]
2996 } else {
2997 return 0
3001 # Return 1 if this is a PowerPC SPE target. The check includes options
3002 # specified by dg-options for this test, so don't cache the result.
3004 proc check_effective_target_powerpc_spe_nocache { } {
3005 if { [istarget powerpc*-*-*] } {
3006 return [check_no_compiler_messages_nocache powerpc_spe object {
3007 #ifndef __SPE__
3008 #error not SPE
3009 #else
3010 int dummy;
3011 #endif
3012 } [current_compiler_flags]]
3013 } else {
3014 return 0
3018 # Return 1 if this is a PowerPC target with SPE enabled.
3020 proc check_effective_target_powerpc_spe { } {
3021 if { [istarget powerpc*-*-*] } {
3022 return [check_no_compiler_messages powerpc_spe object {
3023 #ifndef __SPE__
3024 #error not SPE
3025 #else
3026 int dummy;
3027 #endif
3029 } else {
3030 return 0
3034 # Return 1 if this is a PowerPC target with Altivec enabled.
3036 proc check_effective_target_powerpc_altivec { } {
3037 if { [istarget powerpc*-*-*] } {
3038 return [check_no_compiler_messages powerpc_altivec object {
3039 #ifndef __ALTIVEC__
3040 #error not Altivec
3041 #else
3042 int dummy;
3043 #endif
3045 } else {
3046 return 0
3050 # Return 1 if this is a PowerPC 405 target. The check includes options
3051 # specified by dg-options for this test, so don't cache the result.
3053 proc check_effective_target_powerpc_405_nocache { } {
3054 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3055 return [check_no_compiler_messages_nocache powerpc_405 object {
3056 #ifdef __PPC405__
3057 int dummy;
3058 #else
3059 #error not a PPC405
3060 #endif
3061 } [current_compiler_flags]]
3062 } else {
3063 return 0
3067 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3069 proc check_effective_target_powerpc_elfv2 { } {
3070 if { [istarget powerpc*-*-*] } {
3071 return [check_no_compiler_messages powerpc_elfv2 object {
3072 #if _CALL_ELF != 2
3073 #error not ELF v2 ABI
3074 #else
3075 int dummy;
3076 #endif
3078 } else {
3079 return 0
3083 # Return 1 if this is a SPU target with a toolchain that
3084 # supports automatic overlay generation.
3086 proc check_effective_target_spu_auto_overlay { } {
3087 if { [istarget spu*-*-elf*] } {
3088 return [check_no_compiler_messages spu_auto_overlay executable {
3089 int main (void) { }
3090 } "-Wl,--auto-overlay" ]
3091 } else {
3092 return 0
3096 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3097 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3098 # test environment appears to run executables on such a simulator.
3100 proc check_effective_target_ultrasparc_hw { } {
3101 return [check_runtime ultrasparc_hw {
3102 int main() { return 0; }
3103 } "-mcpu=ultrasparc"]
3106 # Return 1 if the test environment supports executing UltraSPARC VIS2
3107 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3109 proc check_effective_target_ultrasparc_vis2_hw { } {
3110 return [check_runtime ultrasparc_vis2_hw {
3111 int main() { __asm__(".word 0x81b00320"); return 0; }
3112 } "-mcpu=ultrasparc3"]
3115 # Return 1 if the test environment supports executing UltraSPARC VIS3
3116 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3118 proc check_effective_target_ultrasparc_vis3_hw { } {
3119 return [check_runtime ultrasparc_vis3_hw {
3120 int main() { __asm__(".word 0x81b00220"); return 0; }
3121 } "-mcpu=niagara3"]
3124 # Return 1 if this is a SPARC-V9 target.
3126 proc check_effective_target_sparc_v9 { } {
3127 if { [istarget sparc*-*-*] } {
3128 return [check_no_compiler_messages sparc_v9 object {
3129 int main (void) {
3130 asm volatile ("return %i7+8");
3131 return 0;
3134 } else {
3135 return 0
3139 # Return 1 if this is a SPARC target with VIS enabled.
3141 proc check_effective_target_sparc_vis { } {
3142 if { [istarget sparc*-*-*] } {
3143 return [check_no_compiler_messages sparc_vis object {
3144 #ifndef __VIS__
3145 #error not VIS
3146 #else
3147 int dummy;
3148 #endif
3150 } else {
3151 return 0
3155 # Return 1 if the target supports hardware vector shift operation.
3157 proc check_effective_target_vect_shift { } {
3158 global et_vect_shift_saved
3160 if [info exists et_vect_shift_saved] {
3161 verbose "check_effective_target_vect_shift: using cached result" 2
3162 } else {
3163 set et_vect_shift_saved 0
3164 if { ([istarget powerpc*-*-*]
3165 && ![istarget powerpc-*-linux*paired*])
3166 || [istarget ia64-*-*]
3167 || [istarget i?86-*-*]
3168 || [istarget x86_64-*-*]
3169 || [istarget aarch64*-*-*]
3170 || [check_effective_target_arm32]
3171 || ([istarget mips*-*-*]
3172 && [check_effective_target_mips_loongson]) } {
3173 set et_vect_shift_saved 1
3177 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
3178 return $et_vect_shift_saved
3181 # Return 1 if the target supports hardware vector shift operation for char.
3183 proc check_effective_target_vect_shift_char { } {
3184 global et_vect_shift_char_saved
3186 if [info exists et_vect_shift_char_saved] {
3187 verbose "check_effective_target_vect_shift_char: using cached result" 2
3188 } else {
3189 set et_vect_shift_char_saved 0
3190 if { ([istarget powerpc*-*-*]
3191 && ![istarget powerpc-*-linux*paired*])
3192 || [check_effective_target_arm32] } {
3193 set et_vect_shift_char_saved 1
3197 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
3198 return $et_vect_shift_char_saved
3201 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
3203 # This can change for different subtargets so do not cache the result.
3205 proc check_effective_target_vect_long { } {
3206 if { [istarget i?86-*-*]
3207 || (([istarget powerpc*-*-*]
3208 && ![istarget powerpc-*-linux*paired*])
3209 && [check_effective_target_ilp32])
3210 || [istarget x86_64-*-*]
3211 || [check_effective_target_arm32]
3212 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
3213 set answer 1
3214 } else {
3215 set answer 0
3218 verbose "check_effective_target_vect_long: returning $answer" 2
3219 return $answer
3222 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
3224 # This won't change for different subtargets so cache the result.
3226 proc check_effective_target_vect_float { } {
3227 global et_vect_float_saved
3229 if [info exists et_vect_float_saved] {
3230 verbose "check_effective_target_vect_float: using cached result" 2
3231 } else {
3232 set et_vect_float_saved 0
3233 if { [istarget i?86-*-*]
3234 || [istarget powerpc*-*-*]
3235 || [istarget spu-*-*]
3236 || [istarget mips-sde-elf]
3237 || [istarget mipsisa64*-*-*]
3238 || [istarget x86_64-*-*]
3239 || [istarget ia64-*-*]
3240 || [istarget aarch64*-*-*]
3241 || [check_effective_target_arm32] } {
3242 set et_vect_float_saved 1
3246 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
3247 return $et_vect_float_saved
3250 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
3252 # This won't change for different subtargets so cache the result.
3254 proc check_effective_target_vect_double { } {
3255 global et_vect_double_saved
3257 if [info exists et_vect_double_saved] {
3258 verbose "check_effective_target_vect_double: using cached result" 2
3259 } else {
3260 set et_vect_double_saved 0
3261 if { [istarget i?86-*-*]
3262 || [istarget aarch64*-*-*]
3263 || [istarget x86_64-*-*] } {
3264 if { [check_no_compiler_messages vect_double assembly {
3265 #ifdef __tune_atom__
3266 # error No double vectorizer support.
3267 #endif
3268 }] } {
3269 set et_vect_double_saved 1
3270 } else {
3271 set et_vect_double_saved 0
3273 } elseif { [istarget spu-*-*] } {
3274 set et_vect_double_saved 1
3278 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
3279 return $et_vect_double_saved
3282 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
3284 # This won't change for different subtargets so cache the result.
3286 proc check_effective_target_vect_long_long { } {
3287 global et_vect_long_long_saved
3289 if [info exists et_vect_long_long_saved] {
3290 verbose "check_effective_target_vect_long_long: using cached result" 2
3291 } else {
3292 set et_vect_long_long_saved 0
3293 if { [istarget i?86-*-*]
3294 || [istarget x86_64-*-*] } {
3295 set et_vect_long_long_saved 1
3299 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3300 return $et_vect_long_long_saved
3304 # Return 1 if the target plus current options does not support a vector
3305 # max instruction on "int", 0 otherwise.
3307 # This won't change for different subtargets so cache the result.
3309 proc check_effective_target_vect_no_int_max { } {
3310 global et_vect_no_int_max_saved
3312 if [info exists et_vect_no_int_max_saved] {
3313 verbose "check_effective_target_vect_no_int_max: using cached result" 2
3314 } else {
3315 set et_vect_no_int_max_saved 0
3316 if { [istarget sparc*-*-*]
3317 || [istarget spu-*-*]
3318 || [istarget alpha*-*-*]
3319 || ([istarget mips*-*-*]
3320 && [check_effective_target_mips_loongson]) } {
3321 set et_vect_no_int_max_saved 1
3324 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
3325 return $et_vect_no_int_max_saved
3328 # Return 1 if the target plus current options does not support a vector
3329 # add instruction on "int", 0 otherwise.
3331 # This won't change for different subtargets so cache the result.
3333 proc check_effective_target_vect_no_int_add { } {
3334 global et_vect_no_int_add_saved
3336 if [info exists et_vect_no_int_add_saved] {
3337 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3338 } else {
3339 set et_vect_no_int_add_saved 0
3340 # Alpha only supports vector add on V8QI and V4HI.
3341 if { [istarget alpha*-*-*] } {
3342 set et_vect_no_int_add_saved 1
3345 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3346 return $et_vect_no_int_add_saved
3349 # Return 1 if the target plus current options does not support vector
3350 # bitwise instructions, 0 otherwise.
3352 # This won't change for different subtargets so cache the result.
3354 proc check_effective_target_vect_no_bitwise { } {
3355 global et_vect_no_bitwise_saved
3357 if [info exists et_vect_no_bitwise_saved] {
3358 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3359 } else {
3360 set et_vect_no_bitwise_saved 0
3362 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3363 return $et_vect_no_bitwise_saved
3366 # Return 1 if the target plus current options supports vector permutation,
3367 # 0 otherwise.
3369 # This won't change for different subtargets so cache the result.
3371 proc check_effective_target_vect_perm { } {
3372 global et_vect_perm
3374 if [info exists et_vect_perm_saved] {
3375 verbose "check_effective_target_vect_perm: using cached result" 2
3376 } else {
3377 set et_vect_perm_saved 0
3378 if { [is-effective-target arm_neon_ok]
3379 || [istarget aarch64*-*-*]
3380 || [istarget powerpc*-*-*]
3381 || [istarget spu-*-*]
3382 || [istarget i?86-*-*]
3383 || [istarget x86_64-*-*]
3384 || ([istarget mips*-*-*]
3385 && [check_effective_target_mpaired_single]) } {
3386 set et_vect_perm_saved 1
3389 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3390 return $et_vect_perm_saved
3393 # Return 1 if the target plus current options supports vector permutation
3394 # on byte-sized elements, 0 otherwise.
3396 # This won't change for different subtargets so cache the result.
3398 proc check_effective_target_vect_perm_byte { } {
3399 global et_vect_perm_byte
3401 if [info exists et_vect_perm_byte_saved] {
3402 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3403 } else {
3404 set et_vect_perm_byte_saved 0
3405 if { ([is-effective-target arm_neon_ok]
3406 && [is-effective-target arm_little_endian])
3407 || [istarget aarch64*-*-*]
3408 || [istarget powerpc*-*-*]
3409 || [istarget spu-*-*] } {
3410 set et_vect_perm_byte_saved 1
3413 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3414 return $et_vect_perm_byte_saved
3417 # Return 1 if the target plus current options supports vector permutation
3418 # on short-sized elements, 0 otherwise.
3420 # This won't change for different subtargets so cache the result.
3422 proc check_effective_target_vect_perm_short { } {
3423 global et_vect_perm_short
3425 if [info exists et_vect_perm_short_saved] {
3426 verbose "check_effective_target_vect_perm_short: using cached result" 2
3427 } else {
3428 set et_vect_perm_short_saved 0
3429 if { ([is-effective-target arm_neon_ok]
3430 && [is-effective-target arm_little_endian])
3431 || [istarget aarch64*-*-*]
3432 || [istarget powerpc*-*-*]
3433 || [istarget spu-*-*] } {
3434 set et_vect_perm_short_saved 1
3437 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3438 return $et_vect_perm_short_saved
3441 # Return 1 if the target plus current options supports a vector
3442 # widening summation of *short* args into *int* result, 0 otherwise.
3444 # This won't change for different subtargets so cache the result.
3446 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3447 global et_vect_widen_sum_hi_to_si_pattern
3449 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3450 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3451 } else {
3452 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3453 if { [istarget powerpc*-*-*]
3454 || [istarget ia64-*-*] } {
3455 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3458 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3459 return $et_vect_widen_sum_hi_to_si_pattern_saved
3462 # Return 1 if the target plus current options supports a vector
3463 # widening summation of *short* args into *int* result, 0 otherwise.
3464 # A target can also support this widening summation if it can support
3465 # promotion (unpacking) from shorts to ints.
3467 # This won't change for different subtargets so cache the result.
3469 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3470 global et_vect_widen_sum_hi_to_si
3472 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3473 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3474 } else {
3475 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3476 if { [istarget powerpc*-*-*]
3477 || [istarget ia64-*-*] } {
3478 set et_vect_widen_sum_hi_to_si_saved 1
3481 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3482 return $et_vect_widen_sum_hi_to_si_saved
3485 # Return 1 if the target plus current options supports a vector
3486 # widening summation of *char* args into *short* result, 0 otherwise.
3487 # A target can also support this widening summation if it can support
3488 # promotion (unpacking) from chars to shorts.
3490 # This won't change for different subtargets so cache the result.
3492 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3493 global et_vect_widen_sum_qi_to_hi
3495 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3496 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3497 } else {
3498 set et_vect_widen_sum_qi_to_hi_saved 0
3499 if { [check_effective_target_vect_unpack]
3500 || [check_effective_target_arm_neon_ok]
3501 || [istarget ia64-*-*] } {
3502 set et_vect_widen_sum_qi_to_hi_saved 1
3505 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3506 return $et_vect_widen_sum_qi_to_hi_saved
3509 # Return 1 if the target plus current options supports a vector
3510 # widening summation of *char* args into *int* result, 0 otherwise.
3512 # This won't change for different subtargets so cache the result.
3514 proc check_effective_target_vect_widen_sum_qi_to_si { } {
3515 global et_vect_widen_sum_qi_to_si
3517 if [info exists et_vect_widen_sum_qi_to_si_saved] {
3518 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3519 } else {
3520 set et_vect_widen_sum_qi_to_si_saved 0
3521 if { [istarget powerpc*-*-*] } {
3522 set et_vect_widen_sum_qi_to_si_saved 1
3525 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3526 return $et_vect_widen_sum_qi_to_si_saved
3529 # Return 1 if the target plus current options supports a vector
3530 # widening multiplication of *char* args into *short* result, 0 otherwise.
3531 # A target can also support this widening multplication if it can support
3532 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
3533 # multiplication of shorts).
3535 # This won't change for different subtargets so cache the result.
3538 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3539 global et_vect_widen_mult_qi_to_hi
3541 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3542 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3543 } else {
3544 if { [check_effective_target_vect_unpack]
3545 && [check_effective_target_vect_short_mult] } {
3546 set et_vect_widen_mult_qi_to_hi_saved 1
3547 } else {
3548 set et_vect_widen_mult_qi_to_hi_saved 0
3550 if { [istarget powerpc*-*-*]
3551 || [istarget aarch64*-*-*]
3552 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3553 set et_vect_widen_mult_qi_to_hi_saved 1
3556 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3557 return $et_vect_widen_mult_qi_to_hi_saved
3560 # Return 1 if the target plus current options supports a vector
3561 # widening multiplication of *short* args into *int* result, 0 otherwise.
3562 # A target can also support this widening multplication if it can support
3563 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3564 # multiplication of ints).
3566 # This won't change for different subtargets so cache the result.
3569 proc check_effective_target_vect_widen_mult_hi_to_si { } {
3570 global et_vect_widen_mult_hi_to_si
3572 if [info exists et_vect_widen_mult_hi_to_si_saved] {
3573 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3574 } else {
3575 if { [check_effective_target_vect_unpack]
3576 && [check_effective_target_vect_int_mult] } {
3577 set et_vect_widen_mult_hi_to_si_saved 1
3578 } else {
3579 set et_vect_widen_mult_hi_to_si_saved 0
3581 if { [istarget powerpc*-*-*]
3582 || [istarget spu-*-*]
3583 || [istarget ia64-*-*]
3584 || [istarget aarch64*-*-*]
3585 || [istarget i?86-*-*]
3586 || [istarget x86_64-*-*]
3587 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3588 set et_vect_widen_mult_hi_to_si_saved 1
3591 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3592 return $et_vect_widen_mult_hi_to_si_saved
3595 # Return 1 if the target plus current options supports a vector
3596 # widening multiplication of *char* args into *short* result, 0 otherwise.
3598 # This won't change for different subtargets so cache the result.
3600 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3601 global et_vect_widen_mult_qi_to_hi_pattern
3603 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3604 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3605 } else {
3606 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3607 if { [istarget powerpc*-*-*]
3608 || ([istarget arm*-*-*]
3609 && [check_effective_target_arm_neon_ok]
3610 && [check_effective_target_arm_little_endian]) } {
3611 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3614 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3615 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3618 # Return 1 if the target plus current options supports a vector
3619 # widening multiplication of *short* args into *int* result, 0 otherwise.
3621 # This won't change for different subtargets so cache the result.
3623 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3624 global et_vect_widen_mult_hi_to_si_pattern
3626 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3627 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3628 } else {
3629 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3630 if { [istarget powerpc*-*-*]
3631 || [istarget spu-*-*]
3632 || [istarget ia64-*-*]
3633 || [istarget i?86-*-*]
3634 || [istarget x86_64-*-*]
3635 || ([istarget arm*-*-*]
3636 && [check_effective_target_arm_neon_ok]
3637 && [check_effective_target_arm_little_endian]) } {
3638 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3641 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3642 return $et_vect_widen_mult_hi_to_si_pattern_saved
3645 # Return 1 if the target plus current options supports a vector
3646 # widening shift, 0 otherwise.
3648 # This won't change for different subtargets so cache the result.
3650 proc check_effective_target_vect_widen_shift { } {
3651 global et_vect_widen_shift_saved
3653 if [info exists et_vect_shift_saved] {
3654 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3655 } else {
3656 set et_vect_widen_shift_saved 0
3657 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3658 set et_vect_widen_shift_saved 1
3661 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3662 return $et_vect_widen_shift_saved
3665 # Return 1 if the target plus current options supports a vector
3666 # dot-product of signed chars, 0 otherwise.
3668 # This won't change for different subtargets so cache the result.
3670 proc check_effective_target_vect_sdot_qi { } {
3671 global et_vect_sdot_qi
3673 if [info exists et_vect_sdot_qi_saved] {
3674 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3675 } else {
3676 set et_vect_sdot_qi_saved 0
3677 if { [istarget ia64-*-*] } {
3678 set et_vect_udot_qi_saved 1
3681 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3682 return $et_vect_sdot_qi_saved
3685 # Return 1 if the target plus current options supports a vector
3686 # dot-product of unsigned chars, 0 otherwise.
3688 # This won't change for different subtargets so cache the result.
3690 proc check_effective_target_vect_udot_qi { } {
3691 global et_vect_udot_qi
3693 if [info exists et_vect_udot_qi_saved] {
3694 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3695 } else {
3696 set et_vect_udot_qi_saved 0
3697 if { [istarget powerpc*-*-*]
3698 || [istarget ia64-*-*] } {
3699 set et_vect_udot_qi_saved 1
3702 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3703 return $et_vect_udot_qi_saved
3706 # Return 1 if the target plus current options supports a vector
3707 # dot-product of signed shorts, 0 otherwise.
3709 # This won't change for different subtargets so cache the result.
3711 proc check_effective_target_vect_sdot_hi { } {
3712 global et_vect_sdot_hi
3714 if [info exists et_vect_sdot_hi_saved] {
3715 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3716 } else {
3717 set et_vect_sdot_hi_saved 0
3718 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3719 || [istarget ia64-*-*]
3720 || [istarget i?86-*-*]
3721 || [istarget x86_64-*-*] } {
3722 set et_vect_sdot_hi_saved 1
3725 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3726 return $et_vect_sdot_hi_saved
3729 # Return 1 if the target plus current options supports a vector
3730 # dot-product of unsigned shorts, 0 otherwise.
3732 # This won't change for different subtargets so cache the result.
3734 proc check_effective_target_vect_udot_hi { } {
3735 global et_vect_udot_hi
3737 if [info exists et_vect_udot_hi_saved] {
3738 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3739 } else {
3740 set et_vect_udot_hi_saved 0
3741 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3742 set et_vect_udot_hi_saved 1
3745 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3746 return $et_vect_udot_hi_saved
3750 # Return 1 if the target plus current options supports a vector
3751 # demotion (packing) of shorts (to chars) and ints (to shorts)
3752 # using modulo arithmetic, 0 otherwise.
3754 # This won't change for different subtargets so cache the result.
3756 proc check_effective_target_vect_pack_trunc { } {
3757 global et_vect_pack_trunc
3759 if [info exists et_vect_pack_trunc_saved] {
3760 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3761 } else {
3762 set et_vect_pack_trunc_saved 0
3763 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3764 || [istarget i?86-*-*]
3765 || [istarget x86_64-*-*]
3766 || [istarget aarch64*-*-*]
3767 || [istarget spu-*-*]
3768 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3769 && [check_effective_target_arm_little_endian]) } {
3770 set et_vect_pack_trunc_saved 1
3773 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3774 return $et_vect_pack_trunc_saved
3777 # Return 1 if the target plus current options supports a vector
3778 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3780 # This won't change for different subtargets so cache the result.
3782 proc check_effective_target_vect_unpack { } {
3783 global et_vect_unpack
3785 if [info exists et_vect_unpack_saved] {
3786 verbose "check_effective_target_vect_unpack: using cached result" 2
3787 } else {
3788 set et_vect_unpack_saved 0
3789 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3790 || [istarget i?86-*-*]
3791 || [istarget x86_64-*-*]
3792 || [istarget spu-*-*]
3793 || [istarget ia64-*-*]
3794 || [istarget aarch64*-*-*]
3795 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3796 && [check_effective_target_arm_little_endian]) } {
3797 set et_vect_unpack_saved 1
3800 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3801 return $et_vect_unpack_saved
3804 # Return 1 if the target plus current options does not guarantee
3805 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3807 # This won't change for different subtargets so cache the result.
3809 proc check_effective_target_unaligned_stack { } {
3810 global et_unaligned_stack_saved
3812 if [info exists et_unaligned_stack_saved] {
3813 verbose "check_effective_target_unaligned_stack: using cached result" 2
3814 } else {
3815 set et_unaligned_stack_saved 0
3817 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3818 return $et_unaligned_stack_saved
3821 # Return 1 if the target plus current options does not support a vector
3822 # alignment mechanism, 0 otherwise.
3824 # This won't change for different subtargets so cache the result.
3826 proc check_effective_target_vect_no_align { } {
3827 global et_vect_no_align_saved
3829 if [info exists et_vect_no_align_saved] {
3830 verbose "check_effective_target_vect_no_align: using cached result" 2
3831 } else {
3832 set et_vect_no_align_saved 0
3833 if { [istarget mipsisa64*-*-*]
3834 || [istarget mips-sde-elf]
3835 || [istarget sparc*-*-*]
3836 || [istarget ia64-*-*]
3837 || [check_effective_target_arm_vect_no_misalign]
3838 || ([istarget mips*-*-*]
3839 && [check_effective_target_mips_loongson]) } {
3840 set et_vect_no_align_saved 1
3843 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3844 return $et_vect_no_align_saved
3847 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3849 # This won't change for different subtargets so cache the result.
3851 proc check_effective_target_vect_hw_misalign { } {
3852 global et_vect_hw_misalign_saved
3854 if [info exists et_vect_hw_misalign_saved] {
3855 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3856 } else {
3857 set et_vect_hw_misalign_saved 0
3858 if { ([istarget x86_64-*-*]
3859 || [istarget aarch64*-*-*]
3860 || [istarget i?86-*-*]) } {
3861 set et_vect_hw_misalign_saved 1
3864 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3865 return $et_vect_hw_misalign_saved
3869 # Return 1 if arrays are aligned to the vector alignment
3870 # boundary, 0 otherwise.
3872 # This won't change for different subtargets so cache the result.
3874 proc check_effective_target_vect_aligned_arrays { } {
3875 global et_vect_aligned_arrays
3877 if [info exists et_vect_aligned_arrays_saved] {
3878 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3879 } else {
3880 set et_vect_aligned_arrays_saved 0
3881 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3882 if { ([is-effective-target lp64]
3883 && ( ![check_avx_available]
3884 || [check_prefer_avx128])) } {
3885 set et_vect_aligned_arrays_saved 1
3888 if [istarget spu-*-*] {
3889 set et_vect_aligned_arrays_saved 1
3892 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3893 return $et_vect_aligned_arrays_saved
3896 # Return 1 if types of size 32 bit or less are naturally aligned
3897 # (aligned to their type-size), 0 otherwise.
3899 # This won't change for different subtargets so cache the result.
3901 proc check_effective_target_natural_alignment_32 { } {
3902 global et_natural_alignment_32
3904 if [info exists et_natural_alignment_32_saved] {
3905 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3906 } else {
3907 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3908 set et_natural_alignment_32_saved 1
3909 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3910 set et_natural_alignment_32_saved 0
3913 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3914 return $et_natural_alignment_32_saved
3917 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3918 # type-size), 0 otherwise.
3920 # This won't change for different subtargets so cache the result.
3922 proc check_effective_target_natural_alignment_64 { } {
3923 global et_natural_alignment_64
3925 if [info exists et_natural_alignment_64_saved] {
3926 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3927 } else {
3928 set et_natural_alignment_64_saved 0
3929 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3930 || [istarget spu-*-*] } {
3931 set et_natural_alignment_64_saved 1
3934 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3935 return $et_natural_alignment_64_saved
3938 # Return 1 if all vector types are naturally aligned (aligned to their
3939 # type-size), 0 otherwise.
3941 # This won't change for different subtargets so cache the result.
3943 proc check_effective_target_vect_natural_alignment { } {
3944 global et_vect_natural_alignment
3946 if [info exists et_vect_natural_alignment_saved] {
3947 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
3948 } else {
3949 set et_vect_natural_alignment_saved 1
3950 if { [check_effective_target_arm_eabi] } {
3951 set et_vect_natural_alignment_saved 0
3954 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
3955 return $et_vect_natural_alignment_saved
3958 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3960 # This won't change for different subtargets so cache the result.
3962 proc check_effective_target_vector_alignment_reachable { } {
3963 global et_vector_alignment_reachable
3965 if [info exists et_vector_alignment_reachable_saved] {
3966 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3967 } else {
3968 if { [check_effective_target_vect_aligned_arrays]
3969 || [check_effective_target_natural_alignment_32] } {
3970 set et_vector_alignment_reachable_saved 1
3971 } else {
3972 set et_vector_alignment_reachable_saved 0
3975 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3976 return $et_vector_alignment_reachable_saved
3979 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3981 # This won't change for different subtargets so cache the result.
3983 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3984 global et_vector_alignment_reachable_for_64bit
3986 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3987 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3988 } else {
3989 if { [check_effective_target_vect_aligned_arrays]
3990 || [check_effective_target_natural_alignment_64] } {
3991 set et_vector_alignment_reachable_for_64bit_saved 1
3992 } else {
3993 set et_vector_alignment_reachable_for_64bit_saved 0
3996 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3997 return $et_vector_alignment_reachable_for_64bit_saved
4000 # Return 1 if the target only requires element alignment for vector accesses
4002 proc check_effective_target_vect_element_align { } {
4003 global et_vect_element_align
4005 if [info exists et_vect_element_align] {
4006 verbose "check_effective_target_vect_element_align: using cached result" 2
4007 } else {
4008 set et_vect_element_align 0
4009 if { ([istarget arm*-*-*]
4010 && ![check_effective_target_arm_vect_no_misalign])
4011 || [check_effective_target_vect_hw_misalign] } {
4012 set et_vect_element_align 1
4016 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4017 return $et_vect_element_align
4020 # Return 1 if the target supports vector conditional operations, 0 otherwise.
4022 proc check_effective_target_vect_condition { } {
4023 global et_vect_cond_saved
4025 if [info exists et_vect_cond_saved] {
4026 verbose "check_effective_target_vect_cond: using cached result" 2
4027 } else {
4028 set et_vect_cond_saved 0
4029 if { [istarget aarch64*-*-*]
4030 || [istarget powerpc*-*-*]
4031 || [istarget ia64-*-*]
4032 || [istarget i?86-*-*]
4033 || [istarget spu-*-*]
4034 || [istarget x86_64-*-*]
4035 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4036 set et_vect_cond_saved 1
4040 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
4041 return $et_vect_cond_saved
4044 # Return 1 if the target supports vector conditional operations where
4045 # the comparison has different type from the lhs, 0 otherwise.
4047 proc check_effective_target_vect_cond_mixed { } {
4048 global et_vect_cond_mixed_saved
4050 if [info exists et_vect_cond_mixed_saved] {
4051 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
4052 } else {
4053 set et_vect_cond_mixed_saved 0
4054 if { [istarget i?86-*-*]
4055 || [istarget x86_64-*-*]
4056 || [istarget powerpc*-*-*] } {
4057 set et_vect_cond_mixed_saved 1
4061 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
4062 return $et_vect_cond_mixed_saved
4065 # Return 1 if the target supports vector char multiplication, 0 otherwise.
4067 proc check_effective_target_vect_char_mult { } {
4068 global et_vect_char_mult_saved
4070 if [info exists et_vect_char_mult_saved] {
4071 verbose "check_effective_target_vect_char_mult: using cached result" 2
4072 } else {
4073 set et_vect_char_mult_saved 0
4074 if { [istarget aarch64*-*-*]
4075 || [istarget ia64-*-*]
4076 || [istarget i?86-*-*]
4077 || [istarget x86_64-*-*]
4078 || [check_effective_target_arm32] } {
4079 set et_vect_char_mult_saved 1
4083 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
4084 return $et_vect_char_mult_saved
4087 # Return 1 if the target supports vector short multiplication, 0 otherwise.
4089 proc check_effective_target_vect_short_mult { } {
4090 global et_vect_short_mult_saved
4092 if [info exists et_vect_short_mult_saved] {
4093 verbose "check_effective_target_vect_short_mult: using cached result" 2
4094 } else {
4095 set et_vect_short_mult_saved 0
4096 if { [istarget ia64-*-*]
4097 || [istarget spu-*-*]
4098 || [istarget i?86-*-*]
4099 || [istarget x86_64-*-*]
4100 || [istarget powerpc*-*-*]
4101 || [istarget aarch64*-*-*]
4102 || [check_effective_target_arm32]
4103 || ([istarget mips*-*-*]
4104 && [check_effective_target_mips_loongson]) } {
4105 set et_vect_short_mult_saved 1
4109 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
4110 return $et_vect_short_mult_saved
4113 # Return 1 if the target supports vector int multiplication, 0 otherwise.
4115 proc check_effective_target_vect_int_mult { } {
4116 global et_vect_int_mult_saved
4118 if [info exists et_vect_int_mult_saved] {
4119 verbose "check_effective_target_vect_int_mult: using cached result" 2
4120 } else {
4121 set et_vect_int_mult_saved 0
4122 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4123 || [istarget spu-*-*]
4124 || [istarget i?86-*-*]
4125 || [istarget x86_64-*-*]
4126 || [istarget ia64-*-*]
4127 || [istarget aarch64*-*-*]
4128 || [check_effective_target_arm32] } {
4129 set et_vect_int_mult_saved 1
4133 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
4134 return $et_vect_int_mult_saved
4137 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
4139 proc check_effective_target_vect_extract_even_odd { } {
4140 global et_vect_extract_even_odd_saved
4142 if [info exists et_vect_extract_even_odd_saved] {
4143 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
4144 } else {
4145 set et_vect_extract_even_odd_saved 0
4146 if { [istarget aarch64*-*-*]
4147 || [istarget powerpc*-*-*]
4148 || [is-effective-target arm_neon_ok]
4149 || [istarget i?86-*-*]
4150 || [istarget x86_64-*-*]
4151 || [istarget ia64-*-*]
4152 || [istarget spu-*-*]
4153 || ([istarget mips*-*-*]
4154 && [check_effective_target_mpaired_single]) } {
4155 set et_vect_extract_even_odd_saved 1
4159 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
4160 return $et_vect_extract_even_odd_saved
4163 # Return 1 if the target supports vector interleaving, 0 otherwise.
4165 proc check_effective_target_vect_interleave { } {
4166 global et_vect_interleave_saved
4168 if [info exists et_vect_interleave_saved] {
4169 verbose "check_effective_target_vect_interleave: using cached result" 2
4170 } else {
4171 set et_vect_interleave_saved 0
4172 if { [istarget aarch64*-*-*]
4173 || [istarget powerpc*-*-*]
4174 || [is-effective-target arm_neon_ok]
4175 || [istarget i?86-*-*]
4176 || [istarget x86_64-*-*]
4177 || [istarget ia64-*-*]
4178 || [istarget spu-*-*]
4179 || ([istarget mips*-*-*]
4180 && [check_effective_target_mpaired_single]) } {
4181 set et_vect_interleave_saved 1
4185 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
4186 return $et_vect_interleave_saved
4189 foreach N {2 3 4 8} {
4190 eval [string map [list N $N] {
4191 # Return 1 if the target supports 2-vector interleaving
4192 proc check_effective_target_vect_stridedN { } {
4193 global et_vect_stridedN_saved
4195 if [info exists et_vect_stridedN_saved] {
4196 verbose "check_effective_target_vect_stridedN: using cached result" 2
4197 } else {
4198 set et_vect_stridedN_saved 0
4199 if { (N & -N) == N
4200 && [check_effective_target_vect_interleave]
4201 && [check_effective_target_vect_extract_even_odd] } {
4202 set et_vect_stridedN_saved 1
4204 if { ([istarget arm*-*-*]
4205 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
4206 set et_vect_stridedN_saved 1
4210 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
4211 return $et_vect_stridedN_saved
4216 # Return 1 if the target supports multiple vector sizes
4218 proc check_effective_target_vect_multiple_sizes { } {
4219 global et_vect_multiple_sizes_saved
4221 set et_vect_multiple_sizes_saved 0
4222 if { ([istarget aarch64*-*-*]
4223 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
4224 set et_vect_multiple_sizes_saved 1
4226 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4227 if { ([check_avx_available] && ![check_prefer_avx128]) } {
4228 set et_vect_multiple_sizes_saved 1
4232 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
4233 return $et_vect_multiple_sizes_saved
4236 # Return 1 if the target supports vectors of 64 bits.
4238 proc check_effective_target_vect64 { } {
4239 global et_vect64_saved
4241 if [info exists et_vect64_saved] {
4242 verbose "check_effective_target_vect64: using cached result" 2
4243 } else {
4244 set et_vect64_saved 0
4245 if { ([istarget arm*-*-*]
4246 && [check_effective_target_arm_neon_ok]
4247 && [check_effective_target_arm_little_endian]) } {
4248 set et_vect64_saved 1
4252 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
4253 return $et_vect64_saved
4256 # Return 1 if the target supports vector copysignf calls.
4258 proc check_effective_target_vect_call_copysignf { } {
4259 global et_vect_call_copysignf_saved
4261 if [info exists et_vect_call_copysignf_saved] {
4262 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
4263 } else {
4264 set et_vect_call_copysignf_saved 0
4265 if { [istarget i?86-*-*]
4266 || [istarget x86_64-*-*]
4267 || [istarget powerpc*-*-*] } {
4268 set et_vect_call_copysignf_saved 1
4272 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
4273 return $et_vect_call_copysignf_saved
4276 # Return 1 if the target supports vector sqrtf calls.
4278 proc check_effective_target_vect_call_sqrtf { } {
4279 global et_vect_call_sqrtf_saved
4281 if [info exists et_vect_call_sqrtf_saved] {
4282 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
4283 } else {
4284 set et_vect_call_sqrtf_saved 0
4285 if { [istarget aarch64*-*-*]
4286 || [istarget i?86-*-*]
4287 || [istarget x86_64-*-*]
4288 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
4289 set et_vect_call_sqrtf_saved 1
4293 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
4294 return $et_vect_call_sqrtf_saved
4297 # Return 1 if the target supports vector lrint calls.
4299 proc check_effective_target_vect_call_lrint { } {
4300 set et_vect_call_lrint 0
4301 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
4302 set et_vect_call_lrint 1
4305 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4306 return $et_vect_call_lrint
4309 # Return 1 if the target supports vector btrunc calls.
4311 proc check_effective_target_vect_call_btrunc { } {
4312 global et_vect_call_btrunc_saved
4314 if [info exists et_vect_call_btrunc_saved] {
4315 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4316 } else {
4317 set et_vect_call_btrunc_saved 0
4318 if { [istarget aarch64*-*-*] } {
4319 set et_vect_call_btrunc_saved 1
4323 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4324 return $et_vect_call_btrunc_saved
4327 # Return 1 if the target supports vector btruncf calls.
4329 proc check_effective_target_vect_call_btruncf { } {
4330 global et_vect_call_btruncf_saved
4332 if [info exists et_vect_call_btruncf_saved] {
4333 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4334 } else {
4335 set et_vect_call_btruncf_saved 0
4336 if { [istarget aarch64*-*-*] } {
4337 set et_vect_call_btruncf_saved 1
4341 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4342 return $et_vect_call_btruncf_saved
4345 # Return 1 if the target supports vector ceil calls.
4347 proc check_effective_target_vect_call_ceil { } {
4348 global et_vect_call_ceil_saved
4350 if [info exists et_vect_call_ceil_saved] {
4351 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4352 } else {
4353 set et_vect_call_ceil_saved 0
4354 if { [istarget aarch64*-*-*] } {
4355 set et_vect_call_ceil_saved 1
4359 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4360 return $et_vect_call_ceil_saved
4363 # Return 1 if the target supports vector ceilf calls.
4365 proc check_effective_target_vect_call_ceilf { } {
4366 global et_vect_call_ceilf_saved
4368 if [info exists et_vect_call_ceilf_saved] {
4369 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4370 } else {
4371 set et_vect_call_ceilf_saved 0
4372 if { [istarget aarch64*-*-*] } {
4373 set et_vect_call_ceilf_saved 1
4377 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4378 return $et_vect_call_ceilf_saved
4381 # Return 1 if the target supports vector floor calls.
4383 proc check_effective_target_vect_call_floor { } {
4384 global et_vect_call_floor_saved
4386 if [info exists et_vect_call_floor_saved] {
4387 verbose "check_effective_target_vect_call_floor: using cached result" 2
4388 } else {
4389 set et_vect_call_floor_saved 0
4390 if { [istarget aarch64*-*-*] } {
4391 set et_vect_call_floor_saved 1
4395 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4396 return $et_vect_call_floor_saved
4399 # Return 1 if the target supports vector floorf calls.
4401 proc check_effective_target_vect_call_floorf { } {
4402 global et_vect_call_floorf_saved
4404 if [info exists et_vect_call_floorf_saved] {
4405 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4406 } else {
4407 set et_vect_call_floorf_saved 0
4408 if { [istarget aarch64*-*-*] } {
4409 set et_vect_call_floorf_saved 1
4413 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4414 return $et_vect_call_floorf_saved
4417 # Return 1 if the target supports vector lceil calls.
4419 proc check_effective_target_vect_call_lceil { } {
4420 global et_vect_call_lceil_saved
4422 if [info exists et_vect_call_lceil_saved] {
4423 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4424 } else {
4425 set et_vect_call_lceil_saved 0
4426 if { [istarget aarch64*-*-*] } {
4427 set et_vect_call_lceil_saved 1
4431 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4432 return $et_vect_call_lceil_saved
4435 # Return 1 if the target supports vector lfloor calls.
4437 proc check_effective_target_vect_call_lfloor { } {
4438 global et_vect_call_lfloor_saved
4440 if [info exists et_vect_call_lfloor_saved] {
4441 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4442 } else {
4443 set et_vect_call_lfloor_saved 0
4444 if { [istarget aarch64*-*-*] } {
4445 set et_vect_call_lfloor_saved 1
4449 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4450 return $et_vect_call_lfloor_saved
4453 # Return 1 if the target supports vector nearbyint calls.
4455 proc check_effective_target_vect_call_nearbyint { } {
4456 global et_vect_call_nearbyint_saved
4458 if [info exists et_vect_call_nearbyint_saved] {
4459 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
4460 } else {
4461 set et_vect_call_nearbyint_saved 0
4462 if { [istarget aarch64*-*-*] } {
4463 set et_vect_call_nearbyint_saved 1
4467 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4468 return $et_vect_call_nearbyint_saved
4471 # Return 1 if the target supports vector nearbyintf calls.
4473 proc check_effective_target_vect_call_nearbyintf { } {
4474 global et_vect_call_nearbyintf_saved
4476 if [info exists et_vect_call_nearbyintf_saved] {
4477 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
4478 } else {
4479 set et_vect_call_nearbyintf_saved 0
4480 if { [istarget aarch64*-*-*] } {
4481 set et_vect_call_nearbyintf_saved 1
4485 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4486 return $et_vect_call_nearbyintf_saved
4489 # Return 1 if the target supports vector round calls.
4491 proc check_effective_target_vect_call_round { } {
4492 global et_vect_call_round_saved
4494 if [info exists et_vect_call_round_saved] {
4495 verbose "check_effective_target_vect_call_round: using cached result" 2
4496 } else {
4497 set et_vect_call_round_saved 0
4498 if { [istarget aarch64*-*-*] } {
4499 set et_vect_call_round_saved 1
4503 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
4504 return $et_vect_call_round_saved
4507 # Return 1 if the target supports vector roundf calls.
4509 proc check_effective_target_vect_call_roundf { } {
4510 global et_vect_call_roundf_saved
4512 if [info exists et_vect_call_roundf_saved] {
4513 verbose "check_effective_target_vect_call_roundf: using cached result" 2
4514 } else {
4515 set et_vect_call_roundf_saved 0
4516 if { [istarget aarch64*-*-*] } {
4517 set et_vect_call_roundf_saved 1
4521 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
4522 return $et_vect_call_roundf_saved
4525 # Return 1 if the target supports section-anchors
4527 proc check_effective_target_section_anchors { } {
4528 global et_section_anchors_saved
4530 if [info exists et_section_anchors_saved] {
4531 verbose "check_effective_target_section_anchors: using cached result" 2
4532 } else {
4533 set et_section_anchors_saved 0
4534 if { [istarget powerpc*-*-*]
4535 || [istarget arm*-*-*] } {
4536 set et_section_anchors_saved 1
4540 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
4541 return $et_section_anchors_saved
4544 # Return 1 if the target supports atomic operations on "int_128" values.
4546 proc check_effective_target_sync_int_128 { } {
4547 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4548 && ![is-effective-target ia32] } {
4549 return 1
4550 } else {
4551 return 0
4555 # Return 1 if the target supports atomic operations on "int_128" values
4556 # and can execute them.
4558 proc check_effective_target_sync_int_128_runtime { } {
4559 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4560 && ![is-effective-target ia32] } {
4561 return [check_cached_effective_target sync_int_128_available {
4562 check_runtime_nocache sync_int_128_available {
4563 #include "cpuid.h"
4564 int main ()
4566 unsigned int eax, ebx, ecx, edx;
4567 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4568 return !(ecx & bit_CMPXCHG16B);
4569 return 1;
4571 } ""
4573 } else {
4574 return 0
4578 # Return 1 if the target supports atomic operations on "long long".
4580 # Note: 32bit x86 targets require -march=pentium in dg-options.
4582 proc check_effective_target_sync_long_long { } {
4583 if { [istarget x86_64-*-*]
4584 || [istarget i?86-*-*])
4585 || [istarget arm*-*-*]
4586 || [istarget alpha*-*-*]
4587 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
4588 return 1
4589 } else {
4590 return 0
4594 # Return 1 if the target supports atomic operations on "long long"
4595 # and can execute them.
4597 # Note: 32bit x86 targets require -march=pentium in dg-options.
4599 proc check_effective_target_sync_long_long_runtime { } {
4600 if { [istarget x86_64-*-*]
4601 || [istarget i?86-*-*] } {
4602 return [check_cached_effective_target sync_long_long_available {
4603 check_runtime_nocache sync_long_long_available {
4604 #include "cpuid.h"
4605 int main ()
4607 unsigned int eax, ebx, ecx, edx;
4608 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4609 return !(edx & bit_CMPXCHG8B);
4610 return 1;
4612 } ""
4614 } elseif { [istarget arm*-*-linux-*] } {
4615 return [check_runtime sync_longlong_runtime {
4616 #include <stdlib.h>
4617 int main ()
4619 long long l1;
4621 if (sizeof (long long) != 8)
4622 exit (1);
4624 /* Just check for native; checking for kernel fallback is tricky. */
4625 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
4627 exit (0);
4629 } "" ]
4630 } elseif { [istarget alpha*-*-*] } {
4631 return 1
4632 } elseif { ([istarget sparc*-*-*]
4633 && [check_effective_target_lp64]
4634 && [check_effective_target_ultrasparc_hw]) } {
4635 return 1
4636 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
4637 return 1
4638 } else {
4639 return 0
4643 # Return 1 if the target supports atomic operations on "int" and "long".
4645 proc check_effective_target_sync_int_long { } {
4646 global et_sync_int_long_saved
4648 if [info exists et_sync_int_long_saved] {
4649 verbose "check_effective_target_sync_int_long: using cached result" 2
4650 } else {
4651 set et_sync_int_long_saved 0
4652 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4653 # load-reserved/store-conditional instructions.
4654 if { [istarget ia64-*-*]
4655 || [istarget i?86-*-*]
4656 || [istarget x86_64-*-*]
4657 || [istarget aarch64*-*-*]
4658 || [istarget alpha*-*-*]
4659 || [istarget arm*-*-linux-*]
4660 || [istarget bfin*-*linux*]
4661 || [istarget hppa*-*linux*]
4662 || [istarget s390*-*-*]
4663 || [istarget powerpc*-*-*]
4664 || [istarget crisv32-*-*] || [istarget cris-*-*]
4665 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4666 || [check_effective_target_mips_llsc] } {
4667 set et_sync_int_long_saved 1
4671 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
4672 return $et_sync_int_long_saved
4675 # Return 1 if the target supports atomic operations on "char" and "short".
4677 proc check_effective_target_sync_char_short { } {
4678 global et_sync_char_short_saved
4680 if [info exists et_sync_char_short_saved] {
4681 verbose "check_effective_target_sync_char_short: using cached result" 2
4682 } else {
4683 set et_sync_char_short_saved 0
4684 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4685 # load-reserved/store-conditional instructions.
4686 if { [istarget aarch64*-*-*]
4687 || [istarget ia64-*-*]
4688 || [istarget i?86-*-*]
4689 || [istarget x86_64-*-*]
4690 || [istarget alpha*-*-*]
4691 || [istarget arm*-*-linux-*]
4692 || [istarget hppa*-*linux*]
4693 || [istarget s390*-*-*]
4694 || [istarget powerpc*-*-*]
4695 || [istarget crisv32-*-*] || [istarget cris-*-*]
4696 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4697 || [check_effective_target_mips_llsc] } {
4698 set et_sync_char_short_saved 1
4702 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
4703 return $et_sync_char_short_saved
4706 # Return 1 if the target uses a ColdFire FPU.
4708 proc check_effective_target_coldfire_fpu { } {
4709 return [check_no_compiler_messages coldfire_fpu assembly {
4710 #ifndef __mcffpu__
4711 #error FOO
4712 #endif
4716 # Return true if this is a uClibc target.
4718 proc check_effective_target_uclibc {} {
4719 return [check_no_compiler_messages uclibc object {
4720 #include <features.h>
4721 #if !defined (__UCLIBC__)
4722 #error FOO
4723 #endif
4727 # Return true if this is a uclibc target and if the uclibc feature
4728 # described by __$feature__ is not present.
4730 proc check_missing_uclibc_feature {feature} {
4731 return [check_no_compiler_messages $feature object "
4732 #include <features.h>
4733 #if !defined (__UCLIBC) || defined (__${feature}__)
4734 #error FOO
4735 #endif
4739 # Return true if this is a Newlib target.
4741 proc check_effective_target_newlib {} {
4742 return [check_no_compiler_messages newlib object {
4743 #include <newlib.h>
4747 # Return 1 if
4748 # (a) an error of a few ULP is expected in string to floating-point
4749 # conversion functions; and
4750 # (b) overflow is not always detected correctly by those functions.
4752 proc check_effective_target_lax_strtofp {} {
4753 # By default, assume that all uClibc targets suffer from this.
4754 return [check_effective_target_uclibc]
4757 # Return 1 if this is a target for which wcsftime is a dummy
4758 # function that always returns 0.
4760 proc check_effective_target_dummy_wcsftime {} {
4761 # By default, assume that all uClibc targets suffer from this.
4762 return [check_effective_target_uclibc]
4765 # Return 1 if constructors with initialization priority arguments are
4766 # supposed on this target.
4768 proc check_effective_target_init_priority {} {
4769 return [check_no_compiler_messages init_priority assembly "
4770 void f() __attribute__((constructor (1000)));
4771 void f() \{\}
4775 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
4776 # This can be used with any check_* proc that takes no argument and
4777 # returns only 1 or 0. It could be used with check_* procs that take
4778 # arguments with keywords that pass particular arguments.
4780 proc is-effective-target { arg } {
4781 set selected 0
4782 if { [info procs check_effective_target_${arg}] != [list] } {
4783 set selected [check_effective_target_${arg}]
4784 } else {
4785 switch $arg {
4786 "vmx_hw" { set selected [check_vmx_hw_available] }
4787 "vsx_hw" { set selected [check_vsx_hw_available] }
4788 "p8vector_hw" { set selected [check_p8vector_hw_available] }
4789 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
4790 "dfp_hw" { set selected [check_dfp_hw_available] }
4791 "named_sections" { set selected [check_named_sections_available] }
4792 "gc_sections" { set selected [check_gc_sections_available] }
4793 "cxa_atexit" { set selected [check_cxa_atexit_available] }
4794 default { error "unknown effective target keyword `$arg'" }
4797 verbose "is-effective-target: $arg $selected" 2
4798 return $selected
4801 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
4803 proc is-effective-target-keyword { arg } {
4804 if { [info procs check_effective_target_${arg}] != [list] } {
4805 return 1
4806 } else {
4807 # These have different names for their check_* procs.
4808 switch $arg {
4809 "vmx_hw" { return 1 }
4810 "vsx_hw" { return 1 }
4811 "p8vector_hw" { return 1 }
4812 "ppc_recip_hw" { return 1 }
4813 "dfp_hw" { return 1 }
4814 "named_sections" { return 1 }
4815 "gc_sections" { return 1 }
4816 "cxa_atexit" { return 1 }
4817 default { return 0 }
4822 # Return 1 if target default to short enums
4824 proc check_effective_target_short_enums { } {
4825 return [check_no_compiler_messages short_enums assembly {
4826 enum foo { bar };
4827 int s[sizeof (enum foo) == 1 ? 1 : -1];
4831 # Return 1 if target supports merging string constants at link time.
4833 proc check_effective_target_string_merging { } {
4834 return [check_no_messages_and_pattern string_merging \
4835 "rodata\\.str" assembly {
4836 const char *var = "String";
4837 } {-O2}]
4840 # Return 1 if target has the basic signed and unsigned types in
4841 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
4842 # working <stdint.h> for all targets.
4844 proc check_effective_target_stdint_types { } {
4845 return [check_no_compiler_messages stdint_types assembly {
4846 #include <stdint.h>
4847 int8_t a; int16_t b; int32_t c; int64_t d;
4848 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4852 # Return 1 if target has the basic signed and unsigned types in
4853 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
4854 # these types agree with those in the header, as some systems have
4855 # only <inttypes.h>.
4857 proc check_effective_target_inttypes_types { } {
4858 return [check_no_compiler_messages inttypes_types assembly {
4859 #include <inttypes.h>
4860 int8_t a; int16_t b; int32_t c; int64_t d;
4861 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4865 # Return 1 if programs are intended to be run on a simulator
4866 # (i.e. slowly) rather than hardware (i.e. fast).
4868 proc check_effective_target_simulator { } {
4870 # All "src/sim" simulators set this one.
4871 if [board_info target exists is_simulator] {
4872 return [board_info target is_simulator]
4875 # The "sid" simulators don't set that one, but at least they set
4876 # this one.
4877 if [board_info target exists slow_simulator] {
4878 return [board_info target slow_simulator]
4881 return 0
4884 # Return 1 if programs are intended to be run on hardware rather than
4885 # on a simulator
4887 proc check_effective_target_hw { } {
4889 # All "src/sim" simulators set this one.
4890 if [board_info target exists is_simulator] {
4891 if [board_info target is_simulator] {
4892 return 0
4893 } else {
4894 return 1
4898 # The "sid" simulators don't set that one, but at least they set
4899 # this one.
4900 if [board_info target exists slow_simulator] {
4901 if [board_info target slow_simulator] {
4902 return 0
4903 } else {
4904 return 1
4908 return 1
4911 # Return 1 if the target is a VxWorks kernel.
4913 proc check_effective_target_vxworks_kernel { } {
4914 return [check_no_compiler_messages vxworks_kernel assembly {
4915 #if !defined __vxworks || defined __RTP__
4916 #error NO
4917 #endif
4921 # Return 1 if the target is a VxWorks RTP.
4923 proc check_effective_target_vxworks_rtp { } {
4924 return [check_no_compiler_messages vxworks_rtp assembly {
4925 #if !defined __vxworks || !defined __RTP__
4926 #error NO
4927 #endif
4931 # Return 1 if the target is expected to provide wide character support.
4933 proc check_effective_target_wchar { } {
4934 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4935 return 0
4937 return [check_no_compiler_messages wchar assembly {
4938 #include <wchar.h>
4942 # Return 1 if the target has <pthread.h>.
4944 proc check_effective_target_pthread_h { } {
4945 return [check_no_compiler_messages pthread_h assembly {
4946 #include <pthread.h>
4950 # Return 1 if the target can truncate a file from a file-descriptor,
4951 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4952 # chsize. We test for a trivially functional truncation; no stubs.
4953 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4954 # different function to be used.
4956 proc check_effective_target_fd_truncate { } {
4957 set prog {
4958 #define _FILE_OFFSET_BITS 64
4959 #include <unistd.h>
4960 #include <stdio.h>
4961 #include <stdlib.h>
4962 int main ()
4964 FILE *f = fopen ("tst.tmp", "wb");
4965 int fd;
4966 const char t[] = "test writing more than ten characters";
4967 char s[11];
4968 int status = 0;
4969 fd = fileno (f);
4970 write (fd, t, sizeof (t) - 1);
4971 lseek (fd, 0, 0);
4972 if (ftruncate (fd, 10) != 0)
4973 status = 1;
4974 close (fd);
4975 fclose (f);
4976 if (status)
4978 unlink ("tst.tmp");
4979 exit (status);
4981 f = fopen ("tst.tmp", "rb");
4982 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4983 status = 1;
4984 fclose (f);
4985 unlink ("tst.tmp");
4986 exit (status);
4990 if { [check_runtime ftruncate $prog] } {
4991 return 1;
4994 regsub "ftruncate" $prog "chsize" prog
4995 return [check_runtime chsize $prog]
4998 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
5000 proc add_options_for_c99_runtime { flags } {
5001 if { [istarget *-*-solaris2*] } {
5002 return "$flags -std=c99"
5004 if { [istarget powerpc-*-darwin*] } {
5005 return "$flags -mmacosx-version-min=10.3"
5007 return $flags
5010 # Add to FLAGS all the target-specific flags needed to enable
5011 # full IEEE compliance mode.
5013 proc add_options_for_ieee { flags } {
5014 if { [istarget alpha*-*-*]
5015 || [istarget sh*-*-*] } {
5016 return "$flags -mieee"
5018 if { [istarget rx-*-*] } {
5019 return "$flags -mnofpu"
5021 return $flags
5024 # Add to FLAGS the flags needed to enable functions to bind locally
5025 # when using pic/PIC passes in the testsuite.
5027 proc add_options_for_bind_pic_locally { flags } {
5028 if {[check_no_compiler_messages using_pic2 assembly {
5029 #if __PIC__ != 2
5030 #error FOO
5031 #endif
5032 }]} {
5033 return "$flags -fPIE"
5035 if {[check_no_compiler_messages using_pic1 assembly {
5036 #if __PIC__ != 1
5037 #error FOO
5038 #endif
5039 }]} {
5040 return "$flags -fpie"
5043 return $flags
5046 # Add to FLAGS the flags needed to enable 64-bit vectors.
5048 proc add_options_for_double_vectors { flags } {
5049 if [is-effective-target arm_neon_ok] {
5050 return "$flags -mvectorize-with-neon-double"
5053 return $flags
5056 # Return 1 if the target provides a full C99 runtime.
5058 proc check_effective_target_c99_runtime { } {
5059 return [check_cached_effective_target c99_runtime {
5060 global srcdir
5062 set file [open "$srcdir/gcc.dg/builtins-config.h"]
5063 set contents [read $file]
5064 close $file
5065 append contents {
5066 #ifndef HAVE_C99_RUNTIME
5067 #error FOO
5068 #endif
5070 check_no_compiler_messages_nocache c99_runtime assembly \
5071 $contents [add_options_for_c99_runtime ""]
5075 # Return 1 if target wchar_t is at least 4 bytes.
5077 proc check_effective_target_4byte_wchar_t { } {
5078 return [check_no_compiler_messages 4byte_wchar_t object {
5079 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
5083 # Return 1 if the target supports automatic stack alignment.
5085 proc check_effective_target_automatic_stack_alignment { } {
5086 # Ordinarily x86 supports automatic stack alignment ...
5087 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
5088 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
5089 # ... except Win64 SEH doesn't. Succeed for Win32 though.
5090 return [check_effective_target_ilp32];
5092 return 1;
5094 return 0;
5097 # Return true if we are compiling for AVX target.
5099 proc check_avx_available { } {
5100 if { [check_no_compiler_messages avx_available assembly {
5101 #ifndef __AVX__
5102 #error unsupported
5103 #endif
5104 } ""] } {
5105 return 1;
5107 return 0;
5110 # Return true if 32- and 16-bytes vectors are available.
5112 proc check_effective_target_vect_sizes_32B_16B { } {
5113 return [check_avx_available];
5116 # Return true if 128-bits vectors are preferred even if 256-bits vectors
5117 # are available.
5119 proc check_prefer_avx128 { } {
5120 if ![check_avx_available] {
5121 return 0;
5123 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
5124 float a[1024],b[1024],c[1024];
5125 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
5126 } "-O2 -ftree-vectorize"]
5130 # Return 1 if avx instructions can be compiled.
5132 proc check_effective_target_avx { } {
5133 return [check_no_compiler_messages avx object {
5134 void _mm256_zeroall (void)
5136 __builtin_ia32_vzeroall ();
5138 } "-O2 -mavx" ]
5141 # Return 1 if sse instructions can be compiled.
5142 proc check_effective_target_sse { } {
5143 return [check_no_compiler_messages sse object {
5144 int main ()
5146 __builtin_ia32_stmxcsr ();
5147 return 0;
5149 } "-O2 -msse" ]
5152 # Return 1 if sse2 instructions can be compiled.
5153 proc check_effective_target_sse2 { } {
5154 return [check_no_compiler_messages sse2 object {
5155 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
5157 __m128i _mm_srli_si128 (__m128i __A, int __N)
5159 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
5161 } "-O2 -msse2" ]
5164 # Return 1 if F16C instructions can be compiled.
5166 proc check_effective_target_f16c { } {
5167 return [check_no_compiler_messages f16c object {
5168 #include "immintrin.h"
5169 float
5170 foo (unsigned short val)
5172 return _cvtsh_ss (val);
5174 } "-O2 -mf16c" ]
5177 # Return 1 if C wchar_t type is compatible with char16_t.
5179 proc check_effective_target_wchar_t_char16_t_compatible { } {
5180 return [check_no_compiler_messages wchar_t_char16_t object {
5181 __WCHAR_TYPE__ wc;
5182 __CHAR16_TYPE__ *p16 = &wc;
5183 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5187 # Return 1 if C wchar_t type is compatible with char32_t.
5189 proc check_effective_target_wchar_t_char32_t_compatible { } {
5190 return [check_no_compiler_messages wchar_t_char32_t object {
5191 __WCHAR_TYPE__ wc;
5192 __CHAR32_TYPE__ *p32 = &wc;
5193 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
5197 # Return 1 if pow10 function exists.
5199 proc check_effective_target_pow10 { } {
5200 return [check_runtime pow10 {
5201 #include <math.h>
5202 int main () {
5203 double x;
5204 x = pow10 (1);
5205 return 0;
5207 } "-lm" ]
5210 # Return 1 if current options generate DFP instructions, 0 otherwise.
5212 proc check_effective_target_hard_dfp {} {
5213 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
5214 typedef float d64 __attribute__((mode(DD)));
5215 d64 x, y, z;
5216 void foo (void) { z = x + y; }
5220 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
5221 # for strchr etc. functions.
5223 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
5224 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
5225 #include <string.h>
5226 #include <wchar.h>
5227 #if !defined(__cplusplus) \
5228 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
5229 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
5230 ISO C++ correct string.h and wchar.h protos not supported.
5231 #else
5232 int i;
5233 #endif
5237 # Return 1 if GNU as is used.
5239 proc check_effective_target_gas { } {
5240 global use_gas_saved
5241 global tool
5243 if {![info exists use_gas_saved]} {
5244 # Check if the as used by gcc is GNU as.
5245 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
5246 # Provide /dev/null as input, otherwise gas times out reading from
5247 # stdin.
5248 set status [remote_exec host "$gcc_as" "-v /dev/null"]
5249 set as_output [lindex $status 1]
5250 if { [ string first "GNU" $as_output ] >= 0 } {
5251 set use_gas_saved 1
5252 } else {
5253 set use_gas_saved 0
5256 return $use_gas_saved
5259 # Return 1 if GNU ld is used.
5261 proc check_effective_target_gld { } {
5262 global use_gld_saved
5263 global tool
5265 if {![info exists use_gld_saved]} {
5266 # Check if the ld used by gcc is GNU ld.
5267 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
5268 set status [remote_exec host "$gcc_ld" "--version"]
5269 set ld_output [lindex $status 1]
5270 if { [ string first "GNU" $ld_output ] >= 0 } {
5271 set use_gld_saved 1
5272 } else {
5273 set use_gld_saved 0
5276 return $use_gld_saved
5279 # Return 1 if the compiler has been configure with link-time optimization
5280 # (LTO) support.
5282 proc check_effective_target_lto { } {
5283 global ENABLE_LTO
5284 return [info exists ENABLE_LTO]
5287 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
5289 proc check_effective_target_maybe_x32 { } {
5290 return [check_no_compiler_messages maybe_x32 object {
5291 void foo (void) {}
5292 } "-mx32 -maddress-mode=short"]
5295 # Return 1 if this target supports the -fsplit-stack option, 0
5296 # otherwise.
5298 proc check_effective_target_split_stack {} {
5299 return [check_no_compiler_messages split_stack object {
5300 void foo (void) { }
5301 } "-fsplit-stack"]
5304 # Return 1 if this target supports the -masm=intel option, 0
5305 # otherwise
5307 proc check_effective_target_masm_intel {} {
5308 return [check_no_compiler_messages masm_intel object {
5309 extern void abort (void);
5310 } "-masm=intel"]
5313 # Return 1 if the language for the compiler under test is C.
5315 proc check_effective_target_c { } {
5316 global tool
5317 if [string match $tool "gcc"] {
5318 return 1
5320 return 0
5323 # Return 1 if the language for the compiler under test is C++.
5325 proc check_effective_target_c++ { } {
5326 global tool
5327 if [string match $tool "g++"] {
5328 return 1
5330 return 0
5333 # Check which language standard is active by checking for the presence of
5334 # one of the C++11 -std flags. This assumes that the default for the
5335 # compiler is C++98, and that there will never be multiple -std= arguments
5336 # on the command line.
5337 proc check_effective_target_c++11 { } {
5338 if ![check_effective_target_c++] {
5339 return 0
5341 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
5344 proc check_effective_target_c++1y { } {
5345 if ![check_effective_target_c++] {
5346 return 0
5348 return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }]
5351 proc check_effective_target_c++98 { } {
5352 if ![check_effective_target_c++] {
5353 return 0
5355 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }]
5358 # Return 1 if expensive testcases should be run.
5360 proc check_effective_target_run_expensive_tests { } {
5361 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
5362 return 1
5364 return 0
5367 # Returns 1 if "mempcpy" is available on the target system.
5369 proc check_effective_target_mempcpy {} {
5370 return [check_function_available "mempcpy"]
5373 # Check whether the vectorizer tests are supported by the target and
5374 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
5375 # Set dg-do-what-default to either compile or run, depending on target
5376 # capabilities. Return 1 if vectorizer tests are supported by
5377 # target, 0 otherwise.
5379 proc check_vect_support_and_set_flags { } {
5380 global DEFAULT_VECTCFLAGS
5381 global dg-do-what-default
5383 if [istarget powerpc-*paired*] {
5384 lappend DEFAULT_VECTCFLAGS "-mpaired"
5385 if [check_750cl_hw_available] {
5386 set dg-do-what-default run
5387 } else {
5388 set dg-do-what-default compile
5390 } elseif [istarget powerpc*-*-*] {
5391 # Skip targets not supporting -maltivec.
5392 if ![is-effective-target powerpc_altivec_ok] {
5393 return 0
5396 lappend DEFAULT_VECTCFLAGS "-maltivec"
5397 if [check_p8vector_hw_available] {
5398 lappend DEFAULT_VECTCFLAGS "-mpower8-vector" "-mno-allow-movmisalign"
5399 } elseif [check_vsx_hw_available] {
5400 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
5403 if [check_vmx_hw_available] {
5404 set dg-do-what-default run
5405 } else {
5406 if [is-effective-target ilp32] {
5407 # Specify a cpu that supports VMX for compile-only tests.
5408 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
5410 set dg-do-what-default compile
5412 } elseif { [istarget spu-*-*] } {
5413 set dg-do-what-default run
5414 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5415 lappend DEFAULT_VECTCFLAGS "-msse2"
5416 if { [check_effective_target_sse2_runtime] } {
5417 set dg-do-what-default run
5418 } else {
5419 set dg-do-what-default compile
5421 } elseif { [istarget mips*-*-*]
5422 && ([check_effective_target_mpaired_single]
5423 || [check_effective_target_mips_loongson])
5424 && [check_effective_target_nomips16] } {
5425 if { [check_effective_target_mpaired_single] } {
5426 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
5428 set dg-do-what-default run
5429 } elseif [istarget sparc*-*-*] {
5430 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
5431 if [check_effective_target_ultrasparc_hw] {
5432 set dg-do-what-default run
5433 } else {
5434 set dg-do-what-default compile
5436 } elseif [istarget alpha*-*-*] {
5437 # Alpha's vectorization capabilities are extremely limited.
5438 # It's more effort than its worth disabling all of the tests
5439 # that it cannot pass. But if you actually want to see what
5440 # does work, command out the return.
5441 return 0
5443 lappend DEFAULT_VECTCFLAGS "-mmax"
5444 if [check_alpha_max_hw_available] {
5445 set dg-do-what-default run
5446 } else {
5447 set dg-do-what-default compile
5449 } elseif [istarget ia64-*-*] {
5450 set dg-do-what-default run
5451 } elseif [is-effective-target arm_neon_ok] {
5452 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
5453 # NEON does not support denormals, so is not used for vectorization by
5454 # default to avoid loss of precision. We must pass -ffast-math to test
5455 # vectorization of float operations.
5456 lappend DEFAULT_VECTCFLAGS "-ffast-math"
5457 if [is-effective-target arm_neon_hw] {
5458 set dg-do-what-default run
5459 } else {
5460 set dg-do-what-default compile
5462 } elseif [istarget "aarch64*-*-*"] {
5463 set dg-do-what-default run
5464 } else {
5465 return 0
5468 return 1
5471 proc check_effective_target_non_strict_align {} {
5472 return [check_no_compiler_messages non_strict_align assembly {
5473 char *y;
5474 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
5475 c *z;
5476 void foo(void) { z = (c *) y; }
5477 } "-Wcast-align"]
5480 # Return 1 if the target has <ucontext.h>.
5482 proc check_effective_target_ucontext_h { } {
5483 return [check_no_compiler_messages ucontext_h assembly {
5484 #include <ucontext.h>
5488 proc check_effective_target_aarch64_tiny { } {
5489 if { [istarget aarch64*-*-*] } {
5490 return [check_no_compiler_messages aarch64_tiny object {
5491 #ifdef __AARCH64_CMODEL_TINY__
5492 int dummy;
5493 #else
5494 #error target not AArch64 tiny code model
5495 #endif
5497 } else {
5498 return 0
5502 proc check_effective_target_aarch64_small { } {
5503 if { [istarget aarch64*-*-*] } {
5504 return [check_no_compiler_messages aarch64_small object {
5505 #ifdef __AARCH64_CMODEL_SMALL__
5506 int dummy;
5507 #else
5508 #error target not AArch64 small code model
5509 #endif
5511 } else {
5512 return 0
5516 proc check_effective_target_aarch64_large { } {
5517 if { [istarget aarch64*-*-*] } {
5518 return [check_no_compiler_messages aarch64_large object {
5519 #ifdef __AARCH64_CMODEL_LARGE__
5520 int dummy;
5521 #else
5522 #error target not AArch64 large code model
5523 #endif
5525 } else {
5526 return 0
5530 # Return 1 if <fenv.h> is available with all the standard IEEE
5531 # exceptions and floating-point exceptions are raised by arithmetic
5532 # operations. (If the target requires special options for "inexact"
5533 # exceptions, those need to be specified in the testcases.)
5535 proc check_effective_target_fenv_exceptions {} {
5536 return [check_runtime fenv_exceptions {
5537 #include <fenv.h>
5538 #include <stdlib.h>
5539 #ifndef FE_DIVBYZERO
5540 # error Missing FE_DIVBYZERO
5541 #endif
5542 #ifndef FE_INEXACT
5543 # error Missing FE_INEXACT
5544 #endif
5545 #ifndef FE_INVALID
5546 # error Missing FE_INVALID
5547 #endif
5548 #ifndef FE_OVERFLOW
5549 # error Missing FE_OVERFLOW
5550 #endif
5551 #ifndef FE_UNDERFLOW
5552 # error Missing FE_UNDERFLOW
5553 #endif
5554 volatile float a = 0.0f, r;
5556 main (void)
5558 r = a / a;
5559 if (fetestexcept (FE_INVALID))
5560 exit (0);
5561 else
5562 abort ();
5564 } "-std=gnu99"]