Merge trunk version 195707 into gupc branch.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob2bc1accc50f17fd72bb9859cb10f4ca613f373ab
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 # We don't yet support profiling for AArch64.
491 if { [istarget aarch64*-*-*]
492 && ([lindex $test_what 1] == "-p"
493 || [lindex $test_what 1] == "-pg") } {
494 return 0
497 # cygwin does not support -p.
498 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
499 return 0
502 # uClibc does not have gcrt1.o.
503 if { [check_effective_target_uclibc]
504 && ($test_what == "-p" || $test_what == "-pg") } {
505 return 0
508 # Now examine the cache variable.
509 if {![info exists profiling_available_saved]} {
510 # Some targets don't have any implementation of __bb_init_func or are
511 # missing other needed machinery.
512 if { [istarget aarch64*-*-elf]
513 || [istarget am3*-*-linux*]
514 || [istarget arm*-*-eabi*]
515 || [istarget arm*-*-elf]
516 || [istarget arm*-*-symbianelf*]
517 || [istarget avr-*-*]
518 || [istarget bfin-*-*]
519 || [istarget cris-*-*]
520 || [istarget crisv32-*-*]
521 || [istarget fido-*-elf]
522 || [istarget h8300-*-*]
523 || [istarget lm32-*-*]
524 || [istarget m32c-*-elf]
525 || [istarget m68k-*-elf]
526 || [istarget m68k-*-uclinux*]
527 || [istarget mep-*-elf]
528 || [istarget mips*-*-elf*]
529 || [istarget mmix-*-*]
530 || [istarget mn10300-*-elf*]
531 || [istarget moxie-*-elf*]
532 || [istarget picochip-*-*]
533 || [istarget powerpc-*-eabi*]
534 || [istarget powerpc-*-elf]
535 || [istarget rx-*-*]
536 || [istarget tic6x-*-elf]
537 || [istarget xstormy16-*]
538 || [istarget xtensa*-*-elf]
539 || [istarget *-*-rtems*]
540 || [istarget *-*-vxworks*] } {
541 set profiling_available_saved 0
542 } else {
543 set profiling_available_saved 1
547 return $profiling_available_saved
550 # Check to see if a target is "freestanding". This is as per the definition
551 # in Section 4 of C99 standard. Effectively, it is a target which supports no
552 # extra headers or libraries other than what is considered essential.
553 proc check_effective_target_freestanding { } {
554 if { [istarget picochip-*-*] } then {
555 return 1
556 } else {
557 return 0
561 # Return 1 if target has packed layout of structure members by
562 # default, 0 otherwise. Note that this is slightly different than
563 # whether the target has "natural alignment": both attributes may be
564 # false.
566 proc check_effective_target_default_packed { } {
567 return [check_no_compiler_messages default_packed assembly {
568 struct x { char a; long b; } c;
569 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
573 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
574 # documentation, where the test also comes from.
576 proc check_effective_target_pcc_bitfield_type_matters { } {
577 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
578 # bitfields, but let's stick to the example code from the docs.
579 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
580 struct foo1 { char x; char :0; char y; };
581 struct foo2 { char x; int :0; char y; };
582 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
586 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
588 proc add_options_for_tls { flags } {
589 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
590 # libthread, so always pass -pthread for native TLS. Same for AIX.
591 # Need to duplicate native TLS check from
592 # check_effective_target_tls_native to avoid recursion.
593 if { ([istarget *-*-solaris2.9*] || [istarget powerpc-ibm-aix*]) &&
594 [check_no_messages_and_pattern tls_native "!emutls" assembly {
595 __thread int i;
596 int f (void) { return i; }
597 void g (int j) { i = j; }
598 }] } {
599 return "$flags -pthread"
601 return $flags
604 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
606 proc check_effective_target_tls {} {
607 return [check_no_compiler_messages tls assembly {
608 __thread int i;
609 int f (void) { return i; }
610 void g (int j) { i = j; }
614 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
616 proc check_effective_target_tls_native {} {
617 # VxWorks uses emulated TLS machinery, but with non-standard helper
618 # functions, so we fail to automatically detect it.
619 if { [istarget *-*-vxworks*] } {
620 return 0
623 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
624 __thread int i;
625 int f (void) { return i; }
626 void g (int j) { i = j; }
630 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
632 proc check_effective_target_tls_emulated {} {
633 # VxWorks uses emulated TLS machinery, but with non-standard helper
634 # functions, so we fail to automatically detect it.
635 if { [istarget *-*-vxworks*] } {
636 return 1
639 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
640 __thread int i;
641 int f (void) { return i; }
642 void g (int j) { i = j; }
646 # Return 1 if TLS executables can run correctly, 0 otherwise.
648 proc check_effective_target_tls_runtime {} {
649 return [check_runtime tls_runtime {
650 __thread int thr = 0;
651 int main (void) { return thr; }
652 } [add_options_for_tls ""]]
655 # Return 1 if atomic compare-and-swap is supported on 'int'
657 proc check_effective_target_cas_char {} {
658 return [check_no_compiler_messages cas_char assembly {
659 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
660 #error unsupported
661 #endif
662 } ""]
665 proc check_effective_target_cas_int {} {
666 return [check_no_compiler_messages cas_int assembly {
667 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
668 /* ok */
669 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
670 /* ok */
671 #else
672 #error unsupported
673 #endif
674 } ""]
677 # Return 1 if -ffunction-sections is supported, 0 otherwise.
679 proc check_effective_target_function_sections {} {
680 # Darwin has its own scheme and silently accepts -ffunction-sections.
681 if { [istarget *-*-darwin*] } {
682 return 0
685 return [check_no_compiler_messages functionsections assembly {
686 void foo (void) { }
687 } "-ffunction-sections"]
690 # Return 1 if instruction scheduling is available, 0 otherwise.
692 proc check_effective_target_scheduling {} {
693 return [check_no_compiler_messages scheduling object {
694 void foo (void) { }
695 } "-fschedule-insns"]
698 # Return 1 if compilation with -fgraphite is error-free for trivial
699 # code, 0 otherwise.
701 proc check_effective_target_fgraphite {} {
702 return [check_no_compiler_messages fgraphite object {
703 void foo (void) { }
704 } "-O1 -fgraphite"]
707 # Return 1 if compilation with -fopenmp is error-free for trivial
708 # code, 0 otherwise.
710 proc check_effective_target_fopenmp {} {
711 return [check_no_compiler_messages fopenmp object {
712 void foo (void) { }
713 } "-fopenmp"]
716 # Return 1 if compilation with -fgnu-tm is error-free for trivial
717 # code, 0 otherwise.
719 proc check_effective_target_fgnu_tm {} {
720 return [check_no_compiler_messages fgnu_tm object {
721 void foo (void) { }
722 } "-fgnu-tm"]
725 # Return 1 if the target supports mmap, 0 otherwise.
727 proc check_effective_target_mmap {} {
728 return [check_function_available "mmap"]
731 # Return 1 if the target supports dlopen, 0 otherwise.
732 proc check_effective_target_dlopen {} {
733 return [check_function_available "dlopen"]
736 # Return 1 if the target supports clone, 0 otherwise.
737 proc check_effective_target_clone {} {
738 return [check_function_available "clone"]
741 # Return 1 if the target supports setrlimit, 0 otherwise.
742 proc check_effective_target_setrlimit {} {
743 # Darwin has non-posix compliant RLIMIT_AS
744 if { [istarget *-*-darwin*] } {
745 return 0
747 return [check_function_available "setrlimit"]
750 # Return 1 if the target supports swapcontext, 0 otherwise.
751 proc check_effective_target_swapcontext {} {
752 return [check_no_compiler_messages swapcontext executable {
753 #include <ucontext.h>
754 int main (void)
756 ucontext_t orig_context,child_context;
757 if (swapcontext(&child_context, &orig_context) < 0) { }
762 # Return 1 if compilation with -pthread is error-free for trivial
763 # code, 0 otherwise.
765 proc check_effective_target_pthread {} {
766 return [check_no_compiler_messages pthread object {
767 void foo (void) { }
768 } "-pthread"]
771 # Return 1 if compilation with -mpe-aligned-commons is error-free
772 # for trivial code, 0 otherwise.
774 proc check_effective_target_pe_aligned_commons {} {
775 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
776 return [check_no_compiler_messages pe_aligned_commons object {
777 int foo;
778 } "-mpe-aligned-commons"]
780 return 0
783 # Return 1 if the target supports -static
784 proc check_effective_target_static {} {
785 return [check_no_compiler_messages static executable {
786 int main (void) { return 0; }
787 } "-static"]
790 # Return 1 if the target supports -fstack-protector
791 proc check_effective_target_fstack_protector {} {
792 return [check_runtime fstack_protector {
793 int main (void) { return 0; }
794 } "-fstack-protector"]
797 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
798 # for trivial code, 0 otherwise.
800 proc check_effective_target_freorder {} {
801 return [check_no_compiler_messages freorder object {
802 void foo (void) { }
803 } "-freorder-blocks-and-partition"]
806 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
807 # emitted, 0 otherwise. Whether a shared library can actually be built is
808 # out of scope for this test.
810 proc check_effective_target_fpic { } {
811 # Note that M68K has a multilib that supports -fpic but not
812 # -fPIC, so we need to check both. We test with a program that
813 # requires GOT references.
814 foreach arg {fpic fPIC} {
815 if [check_no_compiler_messages $arg object {
816 extern int foo (void); extern int bar;
817 int baz (void) { return foo () + bar; }
818 } "-$arg"] {
819 return 1
822 return 0
825 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
827 proc check_effective_target_pie { } {
828 if { [istarget *-*-darwin\[912\]*]
829 || [istarget *-*-linux*] } {
830 return 1;
832 return 0
835 # Return true if the target supports -mpaired-single (as used on MIPS).
837 proc check_effective_target_mpaired_single { } {
838 return [check_no_compiler_messages mpaired_single object {
839 void foo (void) { }
840 } "-mpaired-single"]
843 # Return true if the target has access to FPU instructions.
845 proc check_effective_target_hard_float { } {
846 if { [istarget mips*-*-*] } {
847 return [check_no_compiler_messages hard_float assembly {
848 #if (defined __mips_soft_float || defined __mips16)
849 #error FOO
850 #endif
854 # This proc is actually checking the availabilty of FPU
855 # support for doubles, so on the RX we must fail if the
856 # 64-bit double multilib has been selected.
857 if { [istarget rx-*-*] } {
858 return 0
859 # return [check_no_compiler_messages hard_float assembly {
860 #if defined __RX_64_BIT_DOUBLES__
861 #error FOO
862 #endif
863 # }]
866 # The generic test equates hard_float with "no call for adding doubles".
867 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
868 double a (double b, double c) { return b + c; }
872 # Return true if the target is a 64-bit MIPS target.
874 proc check_effective_target_mips64 { } {
875 return [check_no_compiler_messages mips64 assembly {
876 #ifndef __mips64
877 #error FOO
878 #endif
882 # Return true if the target is a MIPS target that does not produce
883 # MIPS16 code.
885 proc check_effective_target_nomips16 { } {
886 return [check_no_compiler_messages nomips16 object {
887 #ifndef __mips
888 #error FOO
889 #else
890 /* A cheap way of testing for -mflip-mips16. */
891 void foo (void) { asm ("addiu $20,$20,1"); }
892 void bar (void) { asm ("addiu $20,$20,1"); }
893 #endif
897 # Add the options needed for MIPS16 function attributes. At the moment,
898 # we don't support MIPS16 PIC.
900 proc add_options_for_mips16_attribute { flags } {
901 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
904 # Return true if we can force a mode that allows MIPS16 code generation.
905 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
906 # for o32 and o64.
908 proc check_effective_target_mips16_attribute { } {
909 return [check_no_compiler_messages mips16_attribute assembly {
910 #ifdef PIC
911 #error FOO
912 #endif
913 #if defined __mips_hard_float \
914 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
915 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
916 #error FOO
917 #endif
918 } [add_options_for_mips16_attribute ""]]
921 # Return 1 if the target supports long double larger than double when
922 # using the new ABI, 0 otherwise.
924 proc check_effective_target_mips_newabi_large_long_double { } {
925 return [check_no_compiler_messages mips_newabi_large_long_double object {
926 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
927 } "-mabi=64"]
930 # Return true if the target is a MIPS target that has access
931 # to the LL and SC instructions.
933 proc check_effective_target_mips_llsc { } {
934 if { ![istarget mips*-*-*] } {
935 return 0
937 # Assume that these instructions are always implemented for
938 # non-elf* targets, via emulation if necessary.
939 if { ![istarget *-*-elf*] } {
940 return 1
942 # Otherwise assume LL/SC support for everything but MIPS I.
943 return [check_no_compiler_messages mips_llsc assembly {
944 #if __mips == 1
945 #error FOO
946 #endif
950 # Return true if the target is a MIPS target that uses in-place relocations.
952 proc check_effective_target_mips_rel { } {
953 if { ![istarget mips*-*-*] } {
954 return 0
956 return [check_no_compiler_messages mips_rel object {
957 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
958 || (defined _ABI64 && _MIPS_SIM == _ABI64)
959 #error FOO
960 #endif
964 # Return true if the target is a MIPS target that uses the EABI.
966 proc check_effective_target_mips_eabi { } {
967 if { ![istarget mips*-*-*] } {
968 return 0
970 return [check_no_compiler_messages mips_eabi object {
971 #ifndef __mips_eabi
972 #error FOO
973 #endif
977 # Return 1 if the current multilib does not generate PIC by default.
979 proc check_effective_target_nonpic { } {
980 return [check_no_compiler_messages nonpic assembly {
981 #if __PIC__
982 #error FOO
983 #endif
987 # Return 1 if the target does not use a status wrapper.
989 proc check_effective_target_unwrapped { } {
990 if { [target_info needs_status_wrapper] != "" \
991 && [target_info needs_status_wrapper] != "0" } {
992 return 0
994 return 1
997 # Return true if iconv is supported on the target. In particular IBM1047.
999 proc check_iconv_available { test_what } {
1000 global libiconv
1002 # If the tool configuration file has not set libiconv, try "-liconv"
1003 if { ![info exists libiconv] } {
1004 set libiconv "-liconv"
1006 set test_what [lindex $test_what 1]
1007 return [check_runtime_nocache $test_what [subst {
1008 #include <iconv.h>
1009 int main (void)
1011 iconv_t cd;
1013 cd = iconv_open ("$test_what", "UTF-8");
1014 if (cd == (iconv_t) -1)
1015 return 1;
1016 return 0;
1018 }] $libiconv]
1021 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1023 proc check_ascii_locale_available { } {
1024 return 1
1027 # Return true if named sections are supported on this target.
1029 proc check_named_sections_available { } {
1030 return [check_no_compiler_messages named_sections assembly {
1031 int __attribute__ ((section("whatever"))) foo;
1035 # Return true if the "naked" function attribute is supported on this target.
1037 proc check_effective_target_naked_functions { } {
1038 return [check_no_compiler_messages naked_functions assembly {
1039 void f() __attribute__((naked));
1043 # Return 1 if the target supports Fortran real kinds larger than real(8),
1044 # 0 otherwise.
1046 # When the target name changes, replace the cached result.
1048 proc check_effective_target_fortran_large_real { } {
1049 return [check_no_compiler_messages fortran_large_real executable {
1050 ! Fortran
1051 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1052 real(kind=k) :: x
1053 x = cos (x)
1058 # Return 1 if the target supports Fortran real kind real(16),
1059 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1060 # this checks for Real(16) only; the other returned real(10) if
1061 # both real(10) and real(16) are available.
1063 # When the target name changes, replace the cached result.
1065 proc check_effective_target_fortran_real_16 { } {
1066 return [check_no_compiler_messages fortran_real_16 executable {
1067 ! Fortran
1068 real(kind=16) :: x
1069 x = cos (x)
1075 # Return 1 if the target supports SQRT for the largest floating-point
1076 # type. (Some targets lack the libm support for this FP type.)
1077 # On most targets, this check effectively checks either whether sqrtl is
1078 # available or on __float128 systems whether libquadmath is installed,
1079 # which provides sqrtq.
1081 # When the target name changes, replace the cached result.
1083 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1084 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1085 ! Fortran
1086 use iso_fortran_env, only: real_kinds
1087 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1088 real(kind=maxFP), volatile :: x
1089 x = 2.0_maxFP
1090 x = sqrt (x)
1096 # Return 1 if the target supports Fortran integer kinds larger than
1097 # integer(8), 0 otherwise.
1099 # When the target name changes, replace the cached result.
1101 proc check_effective_target_fortran_large_int { } {
1102 return [check_no_compiler_messages fortran_large_int executable {
1103 ! Fortran
1104 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1105 integer(kind=k) :: i
1110 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1112 # When the target name changes, replace the cached result.
1114 proc check_effective_target_fortran_integer_16 { } {
1115 return [check_no_compiler_messages fortran_integer_16 executable {
1116 ! Fortran
1117 integer(16) :: i
1122 # Return 1 if we can statically link libgfortran, 0 otherwise.
1124 # When the target name changes, replace the cached result.
1126 proc check_effective_target_static_libgfortran { } {
1127 return [check_no_compiler_messages static_libgfortran executable {
1128 ! Fortran
1129 print *, 'test'
1131 } "-static"]
1134 proc check_linker_plugin_available { } {
1135 return [check_no_compiler_messages_nocache linker_plugin executable {
1136 int main() { return 0; }
1137 } "-flto -fuse-linker-plugin"]
1140 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1141 # otherwise. Cache the result.
1143 proc check_750cl_hw_available { } {
1144 return [check_cached_effective_target 750cl_hw_available {
1145 # If this is not the right target then we can skip the test.
1146 if { ![istarget powerpc-*paired*] } {
1147 expr 0
1148 } else {
1149 check_runtime_nocache 750cl_hw_available {
1150 int main()
1152 #ifdef __MACH__
1153 asm volatile ("ps_mul v0,v0,v0");
1154 #else
1155 asm volatile ("ps_mul 0,0,0");
1156 #endif
1157 return 0;
1159 } "-mpaired"
1164 # Return 1 if the target OS supports running SSE executables, 0
1165 # otherwise. Cache the result.
1167 proc check_sse_os_support_available { } {
1168 return [check_cached_effective_target sse_os_support_available {
1169 # If this is not the right target then we can skip the test.
1170 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1171 expr 0
1172 } elseif { [istarget i?86-*-solaris2*] } {
1173 # The Solaris 2 kernel doesn't save and restore SSE registers
1174 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1175 check_runtime_nocache sse_os_support_available {
1176 int main ()
1178 asm volatile ("movaps %xmm0,%xmm0");
1179 return 0;
1181 } "-msse"
1182 } else {
1183 expr 1
1188 # Return 1 if the target OS supports running AVX executables, 0
1189 # otherwise. Cache the result.
1191 proc check_avx_os_support_available { } {
1192 return [check_cached_effective_target avx_os_support_available {
1193 # If this is not the right target then we can skip the test.
1194 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1195 expr 0
1196 } else {
1197 # Check that OS has AVX and SSE saving enabled.
1198 check_runtime_nocache avx_os_support_available {
1199 int main ()
1201 unsigned int eax, edx;
1203 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1204 return (eax & 6) != 6;
1206 } ""
1211 # Return 1 if the target supports executing SSE instructions, 0
1212 # otherwise. Cache the result.
1214 proc check_sse_hw_available { } {
1215 return [check_cached_effective_target sse_hw_available {
1216 # If this is not the right target then we can skip the test.
1217 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1218 expr 0
1219 } else {
1220 check_runtime_nocache sse_hw_available {
1221 #include "cpuid.h"
1222 int main ()
1224 unsigned int eax, ebx, ecx, edx;
1225 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1226 return !(edx & bit_SSE);
1227 return 1;
1229 } ""
1234 # Return 1 if the target supports executing SSE2 instructions, 0
1235 # otherwise. Cache the result.
1237 proc check_sse2_hw_available { } {
1238 return [check_cached_effective_target sse2_hw_available {
1239 # If this is not the right target then we can skip the test.
1240 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1241 expr 0
1242 } else {
1243 check_runtime_nocache sse2_hw_available {
1244 #include "cpuid.h"
1245 int main ()
1247 unsigned int eax, ebx, ecx, edx;
1248 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1249 return !(edx & bit_SSE2);
1250 return 1;
1252 } ""
1257 # Return 1 if the target supports executing AVX instructions, 0
1258 # otherwise. Cache the result.
1260 proc check_avx_hw_available { } {
1261 return [check_cached_effective_target avx_hw_available {
1262 # If this is not the right target then we can skip the test.
1263 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1264 expr 0
1265 } else {
1266 check_runtime_nocache avx_hw_available {
1267 #include "cpuid.h"
1268 int main ()
1270 unsigned int eax, ebx, ecx, edx;
1271 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1272 return ((ecx & (bit_AVX | bit_OSXSAVE))
1273 != (bit_AVX | bit_OSXSAVE));
1274 return 1;
1276 } ""
1281 # Return 1 if the target supports running SSE executables, 0 otherwise.
1283 proc check_effective_target_sse_runtime { } {
1284 if { [check_effective_target_sse]
1285 && [check_sse_hw_available]
1286 && [check_sse_os_support_available] } {
1287 return 1
1289 return 0
1292 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1294 proc check_effective_target_sse2_runtime { } {
1295 if { [check_effective_target_sse2]
1296 && [check_sse2_hw_available]
1297 && [check_sse_os_support_available] } {
1298 return 1
1300 return 0
1303 # Return 1 if the target supports running AVX executables, 0 otherwise.
1305 proc check_effective_target_avx_runtime { } {
1306 if { [check_effective_target_avx]
1307 && [check_avx_hw_available]
1308 && [check_avx_os_support_available] } {
1309 return 1
1311 return 0
1314 # Return 1 if the target supports executing VSX instructions, 0
1315 # otherwise. Cache the result.
1317 proc check_vsx_hw_available { } {
1318 return [check_cached_effective_target vsx_hw_available {
1319 # Some simulators are known to not support VSX instructions.
1320 # For now, disable on Darwin
1321 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1322 expr 0
1323 } else {
1324 set options "-mvsx"
1325 check_runtime_nocache vsx_hw_available {
1326 int main()
1328 #ifdef __MACH__
1329 asm volatile ("xxlor vs0,vs0,vs0");
1330 #else
1331 asm volatile ("xxlor 0,0,0");
1332 #endif
1333 return 0;
1335 } $options
1340 # Return 1 if the target supports executing AltiVec instructions, 0
1341 # otherwise. Cache the result.
1343 proc check_vmx_hw_available { } {
1344 return [check_cached_effective_target vmx_hw_available {
1345 # Some simulators are known to not support VMX instructions.
1346 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1347 expr 0
1348 } else {
1349 # Most targets don't require special flags for this test case, but
1350 # Darwin does. Just to be sure, make sure VSX is not enabled for
1351 # the altivec tests.
1352 if { [istarget *-*-darwin*]
1353 || [istarget *-*-aix*] } {
1354 set options "-maltivec -mno-vsx"
1355 } else {
1356 set options "-mno-vsx"
1358 check_runtime_nocache vmx_hw_available {
1359 int main()
1361 #ifdef __MACH__
1362 asm volatile ("vor v0,v0,v0");
1363 #else
1364 asm volatile ("vor 0,0,0");
1365 #endif
1366 return 0;
1368 } $options
1373 proc check_ppc_recip_hw_available { } {
1374 return [check_cached_effective_target ppc_recip_hw_available {
1375 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1376 # For now, disable on Darwin
1377 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1378 expr 0
1379 } else {
1380 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1381 check_runtime_nocache ppc_recip_hw_available {
1382 volatile double d_recip, d_rsqrt, d_four = 4.0;
1383 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1384 int main()
1386 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1387 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1388 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1389 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1390 return 0;
1392 } $options
1397 # Return 1 if the target supports executing AltiVec and Cell PPU
1398 # instructions, 0 otherwise. Cache the result.
1400 proc check_effective_target_cell_hw { } {
1401 return [check_cached_effective_target cell_hw_available {
1402 # Some simulators are known to not support VMX and PPU instructions.
1403 if { [istarget powerpc-*-eabi*] } {
1404 expr 0
1405 } else {
1406 # Most targets don't require special flags for this test
1407 # case, but Darwin and AIX do.
1408 if { [istarget *-*-darwin*]
1409 || [istarget *-*-aix*] } {
1410 set options "-maltivec -mcpu=cell"
1411 } else {
1412 set options "-mcpu=cell"
1414 check_runtime_nocache cell_hw_available {
1415 int main()
1417 #ifdef __MACH__
1418 asm volatile ("vor v0,v0,v0");
1419 asm volatile ("lvlx v0,r0,r0");
1420 #else
1421 asm volatile ("vor 0,0,0");
1422 asm volatile ("lvlx 0,0,0");
1423 #endif
1424 return 0;
1426 } $options
1431 # Return 1 if the target supports executing 64-bit instructions, 0
1432 # otherwise. Cache the result.
1434 proc check_effective_target_powerpc64 { } {
1435 global powerpc64_available_saved
1436 global tool
1438 if [info exists powerpc64_available_saved] {
1439 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1440 } else {
1441 set powerpc64_available_saved 0
1443 # Some simulators are known to not support powerpc64 instructions.
1444 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1445 verbose "check_effective_target_powerpc64 returning 0" 2
1446 return $powerpc64_available_saved
1449 # Set up, compile, and execute a test program containing a 64-bit
1450 # instruction. Include the current process ID in the file
1451 # names to prevent conflicts with invocations for multiple
1452 # testsuites.
1453 set src ppc[pid].c
1454 set exe ppc[pid].x
1456 set f [open $src "w"]
1457 puts $f "int main() {"
1458 puts $f "#ifdef __MACH__"
1459 puts $f " asm volatile (\"extsw r0,r0\");"
1460 puts $f "#else"
1461 puts $f " asm volatile (\"extsw 0,0\");"
1462 puts $f "#endif"
1463 puts $f " return 0; }"
1464 close $f
1466 set opts "additional_flags=-mcpu=G5"
1468 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1469 set lines [${tool}_target_compile $src $exe executable "$opts"]
1470 file delete $src
1472 if [string match "" $lines] then {
1473 # No error message, compilation succeeded.
1474 set result [${tool}_load "./$exe" "" ""]
1475 set status [lindex $result 0]
1476 remote_file build delete $exe
1477 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1479 if { $status == "pass" } then {
1480 set powerpc64_available_saved 1
1482 } else {
1483 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1487 return $powerpc64_available_saved
1490 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1491 # complex float arguments. This affects gfortran tests that call cabsf
1492 # in libm built by an earlier compiler. Return 1 if libm uses the same
1493 # argument passing as the compiler under test, 0 otherwise.
1495 # When the target name changes, replace the cached result.
1497 proc check_effective_target_broken_cplxf_arg { } {
1498 return [check_cached_effective_target broken_cplxf_arg {
1499 # Skip the work for targets known not to be affected.
1500 if { ![istarget powerpc64-*-linux*] } {
1501 expr 0
1502 } elseif { ![is-effective-target lp64] } {
1503 expr 0
1504 } else {
1505 check_runtime_nocache broken_cplxf_arg {
1506 #include <complex.h>
1507 extern void abort (void);
1508 float fabsf (float);
1509 float cabsf (_Complex float);
1510 int main ()
1512 _Complex float cf;
1513 float f;
1514 cf = 3 + 4.0fi;
1515 f = cabsf (cf);
1516 if (fabsf (f - 5.0) > 0.0001)
1517 abort ();
1518 return 0;
1520 } "-lm"
1525 # Return 1 is this is a TI C6X target supporting C67X instructions
1526 proc check_effective_target_ti_c67x { } {
1527 return [check_no_compiler_messages ti_c67x assembly {
1528 #if !defined(_TMS320C6700)
1529 #error FOO
1530 #endif
1534 # Return 1 is this is a TI C6X target supporting C64X+ instructions
1535 proc check_effective_target_ti_c64xp { } {
1536 return [check_no_compiler_messages ti_c64xp assembly {
1537 #if !defined(_TMS320C6400_PLUS)
1538 #error FOO
1539 #endif
1544 proc check_alpha_max_hw_available { } {
1545 return [check_runtime alpha_max_hw_available {
1546 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1550 # Returns true iff the FUNCTION is available on the target system.
1551 # (This is essentially a Tcl implementation of Autoconf's
1552 # AC_CHECK_FUNC.)
1554 proc check_function_available { function } {
1555 return [check_no_compiler_messages ${function}_available \
1556 executable [subst {
1557 #ifdef __cplusplus
1558 extern "C"
1559 #endif
1560 char $function ();
1561 int main () { $function (); }
1562 }] "-fno-builtin" ]
1565 # Returns true iff "fork" is available on the target system.
1567 proc check_fork_available {} {
1568 return [check_function_available "fork"]
1571 # Returns true iff "mkfifo" is available on the target system.
1573 proc check_mkfifo_available {} {
1574 if { [istarget *-*-cygwin*] } {
1575 # Cygwin has mkfifo, but support is incomplete.
1576 return 0
1579 return [check_function_available "mkfifo"]
1582 # Returns true iff "__cxa_atexit" is used on the target system.
1584 proc check_cxa_atexit_available { } {
1585 return [check_cached_effective_target cxa_atexit_available {
1586 if { [istarget hppa*-*-hpux10*] } {
1587 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1588 expr 0
1589 } elseif { [istarget *-*-vxworks] } {
1590 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1591 expr 0
1592 } else {
1593 check_runtime_nocache cxa_atexit_available {
1594 // C++
1595 #include <stdlib.h>
1596 static unsigned int count;
1597 struct X
1599 X() { count = 1; }
1600 ~X()
1602 if (count != 3)
1603 exit(1);
1604 count = 4;
1607 void f()
1609 static X x;
1611 struct Y
1613 Y() { f(); count = 2; }
1614 ~Y()
1616 if (count != 2)
1617 exit(1);
1618 count = 3;
1621 Y y;
1622 int main() { return 0; }
1628 proc check_effective_target_objc2 { } {
1629 return [check_no_compiler_messages objc2 object {
1630 #ifdef __OBJC2__
1631 int dummy[1];
1632 #else
1633 #error
1634 #endif
1638 proc check_effective_target_next_runtime { } {
1639 return [check_no_compiler_messages objc2 object {
1640 #ifdef __NEXT_RUNTIME__
1641 int dummy[1];
1642 #else
1643 #error
1644 #endif
1648 # Return 1 if we're generating 32-bit code using default options, 0
1649 # otherwise.
1651 proc check_effective_target_ilp32 { } {
1652 return [check_no_compiler_messages ilp32 object {
1653 int dummy[sizeof (int) == 4
1654 && sizeof (void *) == 4
1655 && sizeof (long) == 4 ? 1 : -1];
1659 # Return 1 if we're generating ia32 code using default options, 0
1660 # otherwise.
1662 proc check_effective_target_ia32 { } {
1663 return [check_no_compiler_messages ia32 object {
1664 int dummy[sizeof (int) == 4
1665 && sizeof (void *) == 4
1666 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
1670 # Return 1 if we're generating x32 code using default options, 0
1671 # otherwise.
1673 proc check_effective_target_x32 { } {
1674 return [check_no_compiler_messages x32 object {
1675 int dummy[sizeof (int) == 4
1676 && sizeof (void *) == 4
1677 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
1681 # Return 1 if we're generating 32-bit or larger integers using default
1682 # options, 0 otherwise.
1684 proc check_effective_target_int32plus { } {
1685 return [check_no_compiler_messages int32plus object {
1686 int dummy[sizeof (int) >= 4 ? 1 : -1];
1690 # Return 1 if we're generating 32-bit or larger pointers using default
1691 # options, 0 otherwise.
1693 proc check_effective_target_ptr32plus { } {
1694 return [check_no_compiler_messages ptr32plus object {
1695 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1699 # Return 1 if we support 32-bit or larger array and structure sizes
1700 # using default options, 0 otherwise.
1702 proc check_effective_target_size32plus { } {
1703 return [check_no_compiler_messages size32plus object {
1704 char dummy[65537];
1708 # Returns 1 if we're generating 16-bit or smaller integers with the
1709 # default options, 0 otherwise.
1711 proc check_effective_target_int16 { } {
1712 return [check_no_compiler_messages int16 object {
1713 int dummy[sizeof (int) < 4 ? 1 : -1];
1717 # Return 1 if we're generating 64-bit code using default options, 0
1718 # otherwise.
1720 proc check_effective_target_lp64 { } {
1721 return [check_no_compiler_messages lp64 object {
1722 int dummy[sizeof (int) == 4
1723 && sizeof (void *) == 8
1724 && sizeof (long) == 8 ? 1 : -1];
1728 # Return 1 if we're generating 64-bit code using default llp64 options,
1729 # 0 otherwise.
1731 proc check_effective_target_llp64 { } {
1732 return [check_no_compiler_messages llp64 object {
1733 int dummy[sizeof (int) == 4
1734 && sizeof (void *) == 8
1735 && sizeof (long long) == 8
1736 && sizeof (long) == 4 ? 1 : -1];
1740 # Return 1 if long and int have different sizes,
1741 # 0 otherwise.
1743 proc check_effective_target_long_neq_int { } {
1744 return [check_no_compiler_messages long_ne_int object {
1745 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
1749 # Return 1 if the target supports long double larger than double,
1750 # 0 otherwise.
1752 proc check_effective_target_large_long_double { } {
1753 return [check_no_compiler_messages large_long_double object {
1754 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1758 # Return 1 if the target supports double larger than float,
1759 # 0 otherwise.
1761 proc check_effective_target_large_double { } {
1762 return [check_no_compiler_messages large_double object {
1763 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1767 # Return 1 if the target supports double of 64 bits,
1768 # 0 otherwise.
1770 proc check_effective_target_double64 { } {
1771 return [check_no_compiler_messages double64 object {
1772 int dummy[sizeof(double) == 8 ? 1 : -1];
1776 # Return 1 if the target supports double of at least 64 bits,
1777 # 0 otherwise.
1779 proc check_effective_target_double64plus { } {
1780 return [check_no_compiler_messages double64plus object {
1781 int dummy[sizeof(double) >= 8 ? 1 : -1];
1785 # Return 1 if the target supports 'w' suffix on floating constant
1786 # 0 otherwise.
1788 proc check_effective_target_has_w_floating_suffix { } {
1789 set opts ""
1790 if [check_effective_target_c++] {
1791 append opts "-std=gnu++03"
1793 return [check_no_compiler_messages w_fp_suffix object {
1794 float dummy = 1.0w;
1795 } "$opts"]
1798 # Return 1 if the target supports 'q' suffix on floating constant
1799 # 0 otherwise.
1801 proc check_effective_target_has_q_floating_suffix { } {
1802 set opts ""
1803 if [check_effective_target_c++] {
1804 append opts "-std=gnu++03"
1806 return [check_no_compiler_messages q_fp_suffix object {
1807 float dummy = 1.0q;
1808 } "$opts"]
1810 # Return 1 if the target supports compiling fixed-point,
1811 # 0 otherwise.
1813 proc check_effective_target_fixed_point { } {
1814 return [check_no_compiler_messages fixed_point object {
1815 _Sat _Fract x; _Sat _Accum y;
1819 # Return 1 if the target supports compiling decimal floating point,
1820 # 0 otherwise.
1822 proc check_effective_target_dfp_nocache { } {
1823 verbose "check_effective_target_dfp_nocache: compiling source" 2
1824 set ret [check_no_compiler_messages_nocache dfp object {
1825 float x __attribute__((mode(DD)));
1827 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1828 return $ret
1831 proc check_effective_target_dfprt_nocache { } {
1832 return [check_runtime_nocache dfprt {
1833 typedef float d64 __attribute__((mode(DD)));
1834 d64 x = 1.2df, y = 2.3dd, z;
1835 int main () { z = x + y; return 0; }
1839 # Return 1 if the target supports compiling Decimal Floating Point,
1840 # 0 otherwise.
1842 # This won't change for different subtargets so cache the result.
1844 proc check_effective_target_dfp { } {
1845 return [check_cached_effective_target dfp {
1846 check_effective_target_dfp_nocache
1850 # Return 1 if the target supports linking and executing Decimal Floating
1851 # Point, 0 otherwise.
1853 # This won't change for different subtargets so cache the result.
1855 proc check_effective_target_dfprt { } {
1856 return [check_cached_effective_target dfprt {
1857 check_effective_target_dfprt_nocache
1861 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1863 proc check_effective_target_ucn_nocache { } {
1864 # -std=c99 is only valid for C
1865 if [check_effective_target_c] {
1866 set ucnopts "-std=c99"
1868 append ucnopts " -fextended-identifiers"
1869 verbose "check_effective_target_ucn_nocache: compiling source" 2
1870 set ret [check_no_compiler_messages_nocache ucn object {
1871 int \u00C0;
1872 } $ucnopts]
1873 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1874 return $ret
1877 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1879 # This won't change for different subtargets, so cache the result.
1881 proc check_effective_target_ucn { } {
1882 return [check_cached_effective_target ucn {
1883 check_effective_target_ucn_nocache
1887 # Return 1 if the target needs a command line argument to enable a SIMD
1888 # instruction set.
1890 proc check_effective_target_vect_cmdline_needed { } {
1891 global et_vect_cmdline_needed_saved
1892 global et_vect_cmdline_needed_target_name
1894 if { ![info exists et_vect_cmdline_needed_target_name] } {
1895 set et_vect_cmdline_needed_target_name ""
1898 # If the target has changed since we set the cached value, clear it.
1899 set current_target [current_target_name]
1900 if { $current_target != $et_vect_cmdline_needed_target_name } {
1901 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1902 set et_vect_cmdline_needed_target_name $current_target
1903 if { [info exists et_vect_cmdline_needed_saved] } {
1904 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1905 unset et_vect_cmdline_needed_saved
1909 if [info exists et_vect_cmdline_needed_saved] {
1910 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1911 } else {
1912 set et_vect_cmdline_needed_saved 1
1913 if { [istarget alpha*-*-*]
1914 || [istarget ia64-*-*]
1915 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1916 && ([check_effective_target_x32]
1917 || [check_effective_target_lp64]))
1918 || ([istarget powerpc*-*-*]
1919 && ([check_effective_target_powerpc_spe]
1920 || [check_effective_target_powerpc_altivec]))
1921 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
1922 || [istarget spu-*-*]
1923 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1924 set et_vect_cmdline_needed_saved 0
1928 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1929 return $et_vect_cmdline_needed_saved
1932 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1934 # This won't change for different subtargets so cache the result.
1936 proc check_effective_target_vect_int { } {
1937 global et_vect_int_saved
1939 if [info exists et_vect_int_saved] {
1940 verbose "check_effective_target_vect_int: using cached result" 2
1941 } else {
1942 set et_vect_int_saved 0
1943 if { [istarget i?86-*-*]
1944 || ([istarget powerpc*-*-*]
1945 && ![istarget powerpc-*-linux*paired*])
1946 || [istarget spu-*-*]
1947 || [istarget x86_64-*-*]
1948 || [istarget sparc*-*-*]
1949 || [istarget alpha*-*-*]
1950 || [istarget ia64-*-*]
1951 || [istarget aarch64*-*-*]
1952 || [check_effective_target_arm32]
1953 || ([istarget mips*-*-*]
1954 && [check_effective_target_mips_loongson]) } {
1955 set et_vect_int_saved 1
1959 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1960 return $et_vect_int_saved
1963 # Return 1 if the target supports signed int->float conversion
1966 proc check_effective_target_vect_intfloat_cvt { } {
1967 global et_vect_intfloat_cvt_saved
1969 if [info exists et_vect_intfloat_cvt_saved] {
1970 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1971 } else {
1972 set et_vect_intfloat_cvt_saved 0
1973 if { [istarget i?86-*-*]
1974 || ([istarget powerpc*-*-*]
1975 && ![istarget powerpc-*-linux*paired*])
1976 || [istarget x86_64-*-*]
1977 || ([istarget arm*-*-*]
1978 && [check_effective_target_arm_neon_ok])} {
1979 set et_vect_intfloat_cvt_saved 1
1983 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1984 return $et_vect_intfloat_cvt_saved
1987 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1989 proc check_effective_target_int128 { } {
1990 return [check_no_compiler_messages int128 object {
1991 int dummy[
1992 #ifndef __SIZEOF_INT128__
1994 #else
1996 #endif
2001 # Return 1 if the target supports unsigned int->float conversion
2004 proc check_effective_target_vect_uintfloat_cvt { } {
2005 global et_vect_uintfloat_cvt_saved
2007 if [info exists et_vect_uintfloat_cvt_saved] {
2008 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2009 } else {
2010 set et_vect_uintfloat_cvt_saved 0
2011 if { [istarget i?86-*-*]
2012 || ([istarget powerpc*-*-*]
2013 && ![istarget powerpc-*-linux*paired*])
2014 || [istarget x86_64-*-*]
2015 || ([istarget arm*-*-*]
2016 && [check_effective_target_arm_neon_ok])} {
2017 set et_vect_uintfloat_cvt_saved 1
2021 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2022 return $et_vect_uintfloat_cvt_saved
2026 # Return 1 if the target supports signed float->int conversion
2029 proc check_effective_target_vect_floatint_cvt { } {
2030 global et_vect_floatint_cvt_saved
2032 if [info exists et_vect_floatint_cvt_saved] {
2033 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2034 } else {
2035 set et_vect_floatint_cvt_saved 0
2036 if { [istarget i?86-*-*]
2037 || ([istarget powerpc*-*-*]
2038 && ![istarget powerpc-*-linux*paired*])
2039 || [istarget x86_64-*-*]
2040 || ([istarget arm*-*-*]
2041 && [check_effective_target_arm_neon_ok])} {
2042 set et_vect_floatint_cvt_saved 1
2046 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2047 return $et_vect_floatint_cvt_saved
2050 # Return 1 if the target supports unsigned float->int conversion
2053 proc check_effective_target_vect_floatuint_cvt { } {
2054 global et_vect_floatuint_cvt_saved
2056 if [info exists et_vect_floatuint_cvt_saved] {
2057 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2058 } else {
2059 set et_vect_floatuint_cvt_saved 0
2060 if { ([istarget powerpc*-*-*]
2061 && ![istarget powerpc-*-linux*paired*])
2062 || ([istarget arm*-*-*]
2063 && [check_effective_target_arm_neon_ok])} {
2064 set et_vect_floatuint_cvt_saved 1
2068 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2069 return $et_vect_floatuint_cvt_saved
2072 # Return 1 if this is a AArch64 target supporting big endian
2073 proc check_effective_target_aarch64_big_endian { } {
2074 return [check_no_compiler_messages aarch64_big_endian assembly {
2075 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2076 #error FOO
2077 #endif
2081 # Return 1 is this is an arm target using 32-bit instructions
2082 proc check_effective_target_arm32 { } {
2083 return [check_no_compiler_messages arm32 assembly {
2084 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2085 #error FOO
2086 #endif
2090 # Return 1 is this is an arm target not using Thumb
2091 proc check_effective_target_arm_nothumb { } {
2092 return [check_no_compiler_messages arm_nothumb assembly {
2093 #if (defined(__thumb__) || defined(__thumb2__))
2094 #error FOO
2095 #endif
2099 # Return 1 if this is a little-endian ARM target
2100 proc check_effective_target_arm_little_endian { } {
2101 return [check_no_compiler_messages arm_little_endian assembly {
2102 #if !defined(__arm__) || !defined(__ARMEL__)
2103 #error FOO
2104 #endif
2108 # Return 1 if this is an ARM target that only supports aligned vector accesses
2109 proc check_effective_target_arm_vect_no_misalign { } {
2110 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2111 #if !defined(__arm__) \
2112 || (defined(__ARMEL__) \
2113 && (!defined(__thumb__) || defined(__thumb2__)))
2114 #error FOO
2115 #endif
2120 # Return 1 if this is an ARM target supporting -mfpu=vfp
2121 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2122 # options.
2124 proc check_effective_target_arm_vfp_ok { } {
2125 if { [check_effective_target_arm32] } {
2126 return [check_no_compiler_messages arm_vfp_ok object {
2127 int dummy;
2128 } "-mfpu=vfp -mfloat-abi=softfp"]
2129 } else {
2130 return 0
2134 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2135 # -mfloat-abi=softfp.
2136 proc check_effective_target_arm_v8_vfp_ok {} {
2137 if { [check_effective_target_arm32] } {
2138 return [check_no_compiler_messages arm_v8_vfp_ok object {
2139 int foo (void)
2141 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2142 return 0;
2144 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2145 } else {
2146 return 0
2150 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
2151 # -mfloat-abi=softfp
2152 proc check_effective_target_arm_v8_neon_ok {} {
2153 if { [check_effective_target_arm32] } {
2154 return [check_no_compiler_messages arm_v8_neon_ok object {
2155 int foo (void)
2157 __asm__ volatile ("vrintn.f32 q0, q0");
2158 return 0;
2160 } "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"]
2161 } else {
2162 return 0
2166 # Return 1 if this is an ARM target supporting -mfpu=vfp
2167 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2168 # options.
2170 proc check_effective_target_arm_hard_vfp_ok { } {
2171 if { [check_effective_target_arm32]
2172 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2173 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2174 int main() { return 0;}
2175 } "-mfpu=vfp -mfloat-abi=hard"]
2176 } else {
2177 return 0
2181 # Return 1 if this is an ARM target that supports DSP multiply with
2182 # current multilib flags.
2184 proc check_effective_target_arm_dsp { } {
2185 return [check_no_compiler_messages arm_dsp assembly {
2186 #ifndef __ARM_FEATURE_DSP
2187 #error not DSP
2188 #endif
2189 int i;
2193 # Return 1 if this is an ARM target that supports unaligned word/halfword
2194 # load/store instructions.
2196 proc check_effective_target_arm_unaligned { } {
2197 return [check_no_compiler_messages arm_unaligned assembly {
2198 #ifndef __ARM_FEATURE_UNALIGNED
2199 #error no unaligned support
2200 #endif
2201 int i;
2205 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2206 # or -mfloat-abi=hard, but if one is already specified by the
2207 # multilib, use it. Similarly, if a -mfpu option already enables
2208 # NEON, do not add -mfpu=neon.
2210 proc add_options_for_arm_neon { flags } {
2211 if { ! [check_effective_target_arm_neon_ok] } {
2212 return "$flags"
2214 global et_arm_neon_flags
2215 return "$flags $et_arm_neon_flags"
2218 proc add_options_for_arm_v8_vfp { flags } {
2219 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2220 return "$flags"
2222 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2225 proc add_options_for_arm_v8_neon { flags } {
2226 if { ! [check_effective_target_arm_v8_neon_ok] } {
2227 return "$flags"
2229 return "$flags -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=softfp"
2232 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2233 # or -mfloat-abi=hard, but if one is already specified by the
2234 # multilib, use it. Similarly, if a -mfpu option already enables
2235 # NEON, do not add -mfpu=neon.
2237 proc add_options_for_arm_neonv2 { flags } {
2238 if { ! [check_effective_target_arm_neonv2_ok] } {
2239 return "$flags"
2241 global et_arm_neonv2_flags
2242 return "$flags $et_arm_neonv2_flags"
2245 # Return 1 if this is an ARM target supporting -mfpu=neon
2246 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2247 # incompatible with these options. Also set et_arm_neon_flags to the
2248 # best options to add.
2250 proc check_effective_target_arm_neon_ok_nocache { } {
2251 global et_arm_neon_flags
2252 set et_arm_neon_flags ""
2253 if { [check_effective_target_arm32] } {
2254 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
2255 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2256 #include "arm_neon.h"
2257 int dummy;
2258 } "$flags"] } {
2259 set et_arm_neon_flags $flags
2260 return 1
2265 return 0
2268 proc check_effective_target_arm_neon_ok { } {
2269 return [check_cached_effective_target arm_neon_ok \
2270 check_effective_target_arm_neon_ok_nocache]
2273 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
2274 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2275 # incompatible with these options. Also set et_arm_neonv2_flags to the
2276 # best options to add.
2278 proc check_effective_target_arm_neonv2_ok_nocache { } {
2279 global et_arm_neonv2_flags
2280 set et_arm_neonv2_flags ""
2281 if { [check_effective_target_arm32] } {
2282 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
2283 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
2284 #include "arm_neon.h"
2285 float32x2_t
2286 foo (float32x2_t a, float32x2_t b, float32x2_t c)
2288 return vfma_f32 (a, b, c);
2290 } "$flags"] } {
2291 set et_arm_neonv2_flags $flags
2292 return 1
2297 return 0
2300 proc check_effective_target_arm_neonv2_ok { } {
2301 return [check_cached_effective_target arm_neonv2_ok \
2302 check_effective_target_arm_neonv2_ok_nocache]
2305 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2306 # or -mfloat-abi=hard, but if one is already specified by the
2307 # multilib, use it.
2309 proc add_options_for_arm_fp16 { flags } {
2310 if { ! [check_effective_target_arm_fp16_ok] } {
2311 return "$flags"
2313 global et_arm_fp16_flags
2314 return "$flags $et_arm_fp16_flags"
2317 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
2318 # Skip multilibs that are incompatible with these options and set
2319 # et_arm_fp16_flags to the best options to add.
2321 proc check_effective_target_arm_fp16_ok_nocache { } {
2322 global et_arm_fp16_flags
2323 set et_arm_fp16_flags ""
2324 if { ! [check_effective_target_arm32] } {
2325 return 0;
2327 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
2328 # Multilib flags would override -mfpu.
2329 return 0
2331 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
2332 # Must generate floating-point instructions.
2333 return 0
2335 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
2336 # The existing -mfpu value is OK; use it, but add softfp.
2337 set et_arm_fp16_flags "-mfloat-abi=softfp"
2338 return 1;
2340 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
2341 # macro to check for this support.
2342 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
2343 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
2344 int dummy;
2345 } "$flags"] } {
2346 set et_arm_fp16_flags "$flags"
2347 return 1
2350 return 0
2353 proc check_effective_target_arm_fp16_ok { } {
2354 return [check_cached_effective_target arm_fp16_ok \
2355 check_effective_target_arm_fp16_ok_nocache]
2358 # Creates a series of routines that return 1 if the given architecture
2359 # can be selected and a routine to give the flags to select that architecture
2360 # Note: Extra flags may be added to disable options from newer compilers
2361 # (Thumb in particular - but others may be added in the future)
2362 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
2363 # /* { dg-add-options arm_arch_v5 } */
2364 # /* { dg-require-effective-target arm_arch_v5_multilib } */
2365 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
2366 v4t "-march=armv4t" __ARM_ARCH_4T__
2367 v5 "-march=armv5 -marm" __ARM_ARCH_5__
2368 v5t "-march=armv5t" __ARM_ARCH_5T__
2369 v5te "-march=armv5te" __ARM_ARCH_5TE__
2370 v6 "-march=armv6" __ARM_ARCH_6__
2371 v6k "-march=armv6k" __ARM_ARCH_6K__
2372 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
2373 v6z "-march=armv6z" __ARM_ARCH_6Z__
2374 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
2375 v7a "-march=armv7-a" __ARM_ARCH_7A__
2376 v7r "-march=armv7-r" __ARM_ARCH_7R__
2377 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
2378 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
2379 v8a "-march=armv8-a" __ARM_ARCH_8A__ } {
2380 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
2381 proc check_effective_target_arm_arch_FUNC_ok { } {
2382 if { [ string match "*-marm*" "FLAG" ] &&
2383 ![check_effective_target_arm_arm_ok] } {
2384 return 0
2386 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
2387 #if !defined (DEF)
2388 #error FOO
2389 #endif
2390 } "FLAG" ]
2393 proc add_options_for_arm_arch_FUNC { flags } {
2394 return "$flags FLAG"
2397 proc check_effective_target_arm_arch_FUNC_multilib { } {
2398 return [check_runtime arm_arch_FUNC_multilib {
2400 main (void)
2402 return 0;
2404 } [add_options_for_arm_arch_FUNC ""]]
2409 # Return 1 if this is an ARM target where -marm causes ARM to be
2410 # used (not Thumb)
2412 proc check_effective_target_arm_arm_ok { } {
2413 return [check_no_compiler_messages arm_arm_ok assembly {
2414 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
2415 #error FOO
2416 #endif
2417 } "-marm"]
2421 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
2422 # used.
2424 proc check_effective_target_arm_thumb1_ok { } {
2425 return [check_no_compiler_messages arm_thumb1_ok assembly {
2426 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2427 #error FOO
2428 #endif
2429 } "-mthumb"]
2432 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
2433 # used.
2435 proc check_effective_target_arm_thumb2_ok { } {
2436 return [check_no_compiler_messages arm_thumb2_ok assembly {
2437 #if !defined(__thumb2__)
2438 #error FOO
2439 #endif
2440 } "-mthumb"]
2443 # Return 1 if this is an ARM target where Thumb-1 is used without options
2444 # added by the test.
2446 proc check_effective_target_arm_thumb1 { } {
2447 return [check_no_compiler_messages arm_thumb1 assembly {
2448 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
2449 #error not thumb1
2450 #endif
2451 int i;
2452 } ""]
2455 # Return 1 if this is an ARM target where Thumb-2 is used without options
2456 # added by the test.
2458 proc check_effective_target_arm_thumb2 { } {
2459 return [check_no_compiler_messages arm_thumb2 assembly {
2460 #if !defined(__thumb2__)
2461 #error FOO
2462 #endif
2463 int i;
2464 } ""]
2467 # Return 1 if this is an ARM cortex-M profile cpu
2469 proc check_effective_target_arm_cortex_m { } {
2470 return [check_no_compiler_messages arm_cortex_m assembly {
2471 #if !defined(__ARM_ARCH_7M__) \
2472 && !defined (__ARM_ARCH_7EM__) \
2473 && !defined (__ARM_ARCH_6M__)
2474 #error FOO
2475 #endif
2476 int i;
2477 } "-mthumb"]
2480 # Return 1 if the target supports executing NEON instructions, 0
2481 # otherwise. Cache the result.
2483 proc check_effective_target_arm_neon_hw { } {
2484 return [check_runtime arm_neon_hw_available {
2486 main (void)
2488 long long a = 0, b = 1;
2489 asm ("vorr %P0, %P1, %P2"
2490 : "=w" (a)
2491 : "0" (a), "w" (b));
2492 return (a != 1);
2494 } [add_options_for_arm_neon ""]]
2497 proc check_effective_target_arm_neonv2_hw { } {
2498 return [check_runtime arm_neon_hwv2_available {
2499 #include "arm_neon.h"
2501 main (void)
2503 float32x2_t a, b, c;
2504 asm ("vfma.f32 %P0, %P1, %P2"
2505 : "=w" (a)
2506 : "w" (b), "w" (c));
2507 return 0;
2509 } [add_options_for_arm_neonv2 ""]]
2512 # Return 1 if this is a ARM target with NEON enabled.
2514 proc check_effective_target_arm_neon { } {
2515 if { [check_effective_target_arm32] } {
2516 return [check_no_compiler_messages arm_neon object {
2517 #ifndef __ARM_NEON__
2518 #error not NEON
2519 #else
2520 int dummy;
2521 #endif
2523 } else {
2524 return 0
2528 proc check_effective_target_arm_neonv2 { } {
2529 if { [check_effective_target_arm32] } {
2530 return [check_no_compiler_messages arm_neon object {
2531 #ifndef __ARM_NEON__
2532 #error not NEON
2533 #else
2534 #ifndef __ARM_FEATURE_FMA
2535 #error not NEONv2
2536 #else
2537 int dummy;
2538 #endif
2539 #endif
2541 } else {
2542 return 0
2546 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
2547 # the Loongson vector modes.
2549 proc check_effective_target_mips_loongson { } {
2550 return [check_no_compiler_messages loongson assembly {
2551 #if !defined(__mips_loongson_vector_rev)
2552 #error FOO
2553 #endif
2557 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2558 # Architecture.
2560 proc check_effective_target_arm_eabi { } {
2561 return [check_no_compiler_messages arm_eabi object {
2562 #ifndef __ARM_EABI__
2563 #error not EABI
2564 #else
2565 int dummy;
2566 #endif
2570 # Return 1 if this is an ARM target that adheres to the hard-float variant of
2571 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
2573 proc check_effective_target_arm_hf_eabi { } {
2574 return [check_no_compiler_messages arm_hf_eabi object {
2575 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
2576 #error not hard-float EABI
2577 #else
2578 int dummy;
2579 #endif
2583 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2584 # Some multilibs may be incompatible with this option.
2586 proc check_effective_target_arm_iwmmxt_ok { } {
2587 if { [check_effective_target_arm32] } {
2588 return [check_no_compiler_messages arm_iwmmxt_ok object {
2589 int dummy;
2590 } "-mcpu=iwmmxt"]
2591 } else {
2592 return 0
2596 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
2597 # for an ARM target.
2598 proc check_effective_target_arm_prefer_ldrd_strd { } {
2599 if { ![check_effective_target_arm32] } {
2600 return 0;
2603 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
2604 void foo (int *p) { p[0] = 1; p[1] = 0;}
2605 } "-O2 -mthumb" ]
2608 # Return 1 if this is a PowerPC target with floating-point registers.
2610 proc check_effective_target_powerpc_fprs { } {
2611 if { [istarget powerpc*-*-*]
2612 || [istarget rs6000-*-*] } {
2613 return [check_no_compiler_messages powerpc_fprs object {
2614 #ifdef __NO_FPRS__
2615 #error no FPRs
2616 #else
2617 int dummy;
2618 #endif
2620 } else {
2621 return 0
2625 # Return 1 if this is a PowerPC target with hardware double-precision
2626 # floating point.
2628 proc check_effective_target_powerpc_hard_double { } {
2629 if { [istarget powerpc*-*-*]
2630 || [istarget rs6000-*-*] } {
2631 return [check_no_compiler_messages powerpc_hard_double object {
2632 #ifdef _SOFT_DOUBLE
2633 #error soft double
2634 #else
2635 int dummy;
2636 #endif
2638 } else {
2639 return 0
2643 # Return 1 if this is a PowerPC target supporting -maltivec.
2645 proc check_effective_target_powerpc_altivec_ok { } {
2646 if { ([istarget powerpc*-*-*]
2647 && ![istarget powerpc-*-linux*paired*])
2648 || [istarget rs6000-*-*] } {
2649 # AltiVec is not supported on AIX before 5.3.
2650 if { [istarget powerpc*-*-aix4*]
2651 || [istarget powerpc*-*-aix5.1*]
2652 || [istarget powerpc*-*-aix5.2*] } {
2653 return 0
2655 return [check_no_compiler_messages powerpc_altivec_ok object {
2656 int dummy;
2657 } "-maltivec"]
2658 } else {
2659 return 0
2663 # Return 1 if this is a PowerPC target supporting -mvsx
2665 proc check_effective_target_powerpc_vsx_ok { } {
2666 if { ([istarget powerpc*-*-*]
2667 && ![istarget powerpc-*-linux*paired*])
2668 || [istarget rs6000-*-*] } {
2669 # VSX is not supported on AIX before 7.1.
2670 if { [istarget powerpc*-*-aix4*]
2671 || [istarget powerpc*-*-aix5*]
2672 || [istarget powerpc*-*-aix6*] } {
2673 return 0
2675 return [check_no_compiler_messages powerpc_vsx_ok object {
2676 int main (void) {
2677 #ifdef __MACH__
2678 asm volatile ("xxlor vs0,vs0,vs0");
2679 #else
2680 asm volatile ("xxlor 0,0,0");
2681 #endif
2682 return 0;
2684 } "-mvsx"]
2685 } else {
2686 return 0
2690 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2692 proc check_effective_target_powerpc_ppu_ok { } {
2693 if [check_effective_target_powerpc_altivec_ok] {
2694 return [check_no_compiler_messages cell_asm_available object {
2695 int main (void) {
2696 #ifdef __MACH__
2697 asm volatile ("lvlx v0,v0,v0");
2698 #else
2699 asm volatile ("lvlx 0,0,0");
2700 #endif
2701 return 0;
2704 } else {
2705 return 0
2709 # Return 1 if this is a PowerPC target that supports SPU.
2711 proc check_effective_target_powerpc_spu { } {
2712 if { [istarget powerpc*-*-linux*] } {
2713 return [check_effective_target_powerpc_altivec_ok]
2714 } else {
2715 return 0
2719 # Return 1 if this is a PowerPC SPE target. The check includes options
2720 # specified by dg-options for this test, so don't cache the result.
2722 proc check_effective_target_powerpc_spe_nocache { } {
2723 if { [istarget powerpc*-*-*] } {
2724 return [check_no_compiler_messages_nocache powerpc_spe object {
2725 #ifndef __SPE__
2726 #error not SPE
2727 #else
2728 int dummy;
2729 #endif
2730 } [current_compiler_flags]]
2731 } else {
2732 return 0
2736 # Return 1 if this is a PowerPC target with SPE enabled.
2738 proc check_effective_target_powerpc_spe { } {
2739 if { [istarget powerpc*-*-*] } {
2740 return [check_no_compiler_messages powerpc_spe object {
2741 #ifndef __SPE__
2742 #error not SPE
2743 #else
2744 int dummy;
2745 #endif
2747 } else {
2748 return 0
2752 # Return 1 if this is a PowerPC target with Altivec enabled.
2754 proc check_effective_target_powerpc_altivec { } {
2755 if { [istarget powerpc*-*-*] } {
2756 return [check_no_compiler_messages powerpc_altivec object {
2757 #ifndef __ALTIVEC__
2758 #error not Altivec
2759 #else
2760 int dummy;
2761 #endif
2763 } else {
2764 return 0
2768 # Return 1 if this is a PowerPC 405 target. The check includes options
2769 # specified by dg-options for this test, so don't cache the result.
2771 proc check_effective_target_powerpc_405_nocache { } {
2772 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2773 return [check_no_compiler_messages_nocache powerpc_405 object {
2774 #ifdef __PPC405__
2775 int dummy;
2776 #else
2777 #error not a PPC405
2778 #endif
2779 } [current_compiler_flags]]
2780 } else {
2781 return 0
2785 # Return 1 if this is a SPU target with a toolchain that
2786 # supports automatic overlay generation.
2788 proc check_effective_target_spu_auto_overlay { } {
2789 if { [istarget spu*-*-elf*] } {
2790 return [check_no_compiler_messages spu_auto_overlay executable {
2791 int main (void) { }
2792 } "-Wl,--auto-overlay" ]
2793 } else {
2794 return 0
2798 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2799 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2800 # test environment appears to run executables on such a simulator.
2802 proc check_effective_target_ultrasparc_hw { } {
2803 return [check_runtime ultrasparc_hw {
2804 int main() { return 0; }
2805 } "-mcpu=ultrasparc"]
2808 # Return 1 if the test environment supports executing UltraSPARC VIS2
2809 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
2811 proc check_effective_target_ultrasparc_vis2_hw { } {
2812 return [check_runtime ultrasparc_vis2_hw {
2813 int main() { __asm__(".word 0x81b00320"); return 0; }
2814 } "-mcpu=ultrasparc3"]
2817 # Return 1 if the test environment supports executing UltraSPARC VIS3
2818 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
2820 proc check_effective_target_ultrasparc_vis3_hw { } {
2821 return [check_runtime ultrasparc_vis3_hw {
2822 int main() { __asm__(".word 0x81b00220"); return 0; }
2823 } "-mcpu=niagara3"]
2826 # Return 1 if this is a SPARC-V9 target.
2828 proc check_effective_target_sparc_v9 { } {
2829 if { [istarget sparc*-*-*] } {
2830 return [check_no_compiler_messages sparc_v9 object {
2831 int main (void) {
2832 asm volatile ("return %i7+8");
2833 return 0;
2836 } else {
2837 return 0
2841 # Return 1 if this is a SPARC target with VIS enabled.
2843 proc check_effective_target_sparc_vis { } {
2844 if { [istarget sparc*-*-*] } {
2845 return [check_no_compiler_messages sparc_vis object {
2846 #ifndef __VIS__
2847 #error not VIS
2848 #else
2849 int dummy;
2850 #endif
2852 } else {
2853 return 0
2857 # Return 1 if the target supports hardware vector shift operation.
2859 proc check_effective_target_vect_shift { } {
2860 global et_vect_shift_saved
2862 if [info exists et_vect_shift_saved] {
2863 verbose "check_effective_target_vect_shift: using cached result" 2
2864 } else {
2865 set et_vect_shift_saved 0
2866 if { ([istarget powerpc*-*-*]
2867 && ![istarget powerpc-*-linux*paired*])
2868 || [istarget ia64-*-*]
2869 || [istarget i?86-*-*]
2870 || [istarget x86_64-*-*]
2871 || [istarget aarch64*-*-*]
2872 || [check_effective_target_arm32]
2873 || ([istarget mips*-*-*]
2874 && [check_effective_target_mips_loongson]) } {
2875 set et_vect_shift_saved 1
2879 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2880 return $et_vect_shift_saved
2883 # Return 1 if the target supports hardware vector shift operation for char.
2885 proc check_effective_target_vect_shift_char { } {
2886 global et_vect_shift_char_saved
2888 if [info exists et_vect_shift_char_saved] {
2889 verbose "check_effective_target_vect_shift_char: using cached result" 2
2890 } else {
2891 set et_vect_shift_char_saved 0
2892 if { ([istarget powerpc*-*-*]
2893 && ![istarget powerpc-*-linux*paired*])
2894 || [check_effective_target_arm32] } {
2895 set et_vect_shift_char_saved 1
2899 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
2900 return $et_vect_shift_char_saved
2903 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2905 # This can change for different subtargets so do not cache the result.
2907 proc check_effective_target_vect_long { } {
2908 if { [istarget i?86-*-*]
2909 || (([istarget powerpc*-*-*]
2910 && ![istarget powerpc-*-linux*paired*])
2911 && [check_effective_target_ilp32])
2912 || [istarget x86_64-*-*]
2913 || [check_effective_target_arm32]
2914 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2915 set answer 1
2916 } else {
2917 set answer 0
2920 verbose "check_effective_target_vect_long: returning $answer" 2
2921 return $answer
2924 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2926 # This won't change for different subtargets so cache the result.
2928 proc check_effective_target_vect_float { } {
2929 global et_vect_float_saved
2931 if [info exists et_vect_float_saved] {
2932 verbose "check_effective_target_vect_float: using cached result" 2
2933 } else {
2934 set et_vect_float_saved 0
2935 if { [istarget i?86-*-*]
2936 || [istarget powerpc*-*-*]
2937 || [istarget spu-*-*]
2938 || [istarget mips-sde-elf]
2939 || [istarget mipsisa64*-*-*]
2940 || [istarget x86_64-*-*]
2941 || [istarget ia64-*-*]
2942 || [istarget aarch64*-*-*]
2943 || [check_effective_target_arm32] } {
2944 set et_vect_float_saved 1
2948 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2949 return $et_vect_float_saved
2952 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2954 # This won't change for different subtargets so cache the result.
2956 proc check_effective_target_vect_double { } {
2957 global et_vect_double_saved
2959 if [info exists et_vect_double_saved] {
2960 verbose "check_effective_target_vect_double: using cached result" 2
2961 } else {
2962 set et_vect_double_saved 0
2963 if { [istarget i?86-*-*]
2964 || [istarget aarch64*-*-*]
2965 || [istarget x86_64-*-*] } {
2966 if { [check_no_compiler_messages vect_double assembly {
2967 #ifdef __tune_atom__
2968 # error No double vectorizer support.
2969 #endif
2970 }] } {
2971 set et_vect_double_saved 1
2972 } else {
2973 set et_vect_double_saved 0
2975 } elseif { [istarget spu-*-*] } {
2976 set et_vect_double_saved 1
2980 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2981 return $et_vect_double_saved
2984 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2986 # This won't change for different subtargets so cache the result.
2988 proc check_effective_target_vect_long_long { } {
2989 global et_vect_long_long_saved
2991 if [info exists et_vect_long_long_saved] {
2992 verbose "check_effective_target_vect_long_long: using cached result" 2
2993 } else {
2994 set et_vect_long_long_saved 0
2995 if { [istarget i?86-*-*]
2996 || [istarget x86_64-*-*] } {
2997 set et_vect_long_long_saved 1
3001 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
3002 return $et_vect_long_long_saved
3006 # Return 1 if the target plus current options does not support a vector
3007 # max instruction on "int", 0 otherwise.
3009 # This won't change for different subtargets so cache the result.
3011 proc check_effective_target_vect_no_int_max { } {
3012 global et_vect_no_int_max_saved
3014 if [info exists et_vect_no_int_max_saved] {
3015 verbose "check_effective_target_vect_no_int_max: using cached result" 2
3016 } else {
3017 set et_vect_no_int_max_saved 0
3018 if { [istarget sparc*-*-*]
3019 || [istarget spu-*-*]
3020 || [istarget alpha*-*-*]
3021 || ([istarget mips*-*-*]
3022 && [check_effective_target_mips_loongson]) } {
3023 set et_vect_no_int_max_saved 1
3026 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
3027 return $et_vect_no_int_max_saved
3030 # Return 1 if the target plus current options does not support a vector
3031 # add instruction on "int", 0 otherwise.
3033 # This won't change for different subtargets so cache the result.
3035 proc check_effective_target_vect_no_int_add { } {
3036 global et_vect_no_int_add_saved
3038 if [info exists et_vect_no_int_add_saved] {
3039 verbose "check_effective_target_vect_no_int_add: using cached result" 2
3040 } else {
3041 set et_vect_no_int_add_saved 0
3042 # Alpha only supports vector add on V8QI and V4HI.
3043 if { [istarget alpha*-*-*] } {
3044 set et_vect_no_int_add_saved 1
3047 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
3048 return $et_vect_no_int_add_saved
3051 # Return 1 if the target plus current options does not support vector
3052 # bitwise instructions, 0 otherwise.
3054 # This won't change for different subtargets so cache the result.
3056 proc check_effective_target_vect_no_bitwise { } {
3057 global et_vect_no_bitwise_saved
3059 if [info exists et_vect_no_bitwise_saved] {
3060 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
3061 } else {
3062 set et_vect_no_bitwise_saved 0
3064 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
3065 return $et_vect_no_bitwise_saved
3068 # Return 1 if the target plus current options supports vector permutation,
3069 # 0 otherwise.
3071 # This won't change for different subtargets so cache the result.
3073 proc check_effective_target_vect_perm { } {
3074 global et_vect_perm
3076 if [info exists et_vect_perm_saved] {
3077 verbose "check_effective_target_vect_perm: using cached result" 2
3078 } else {
3079 set et_vect_perm_saved 0
3080 if { [is-effective-target arm_neon_ok]
3081 || [istarget aarch64*-*-*]
3082 || [istarget powerpc*-*-*]
3083 || [istarget spu-*-*]
3084 || [istarget i?86-*-*]
3085 || [istarget x86_64-*-*]
3086 || ([istarget mips*-*-*]
3087 && [check_effective_target_mpaired_single]) } {
3088 set et_vect_perm_saved 1
3091 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
3092 return $et_vect_perm_saved
3095 # Return 1 if the target plus current options supports vector permutation
3096 # on byte-sized elements, 0 otherwise.
3098 # This won't change for different subtargets so cache the result.
3100 proc check_effective_target_vect_perm_byte { } {
3101 global et_vect_perm_byte
3103 if [info exists et_vect_perm_byte_saved] {
3104 verbose "check_effective_target_vect_perm_byte: using cached result" 2
3105 } else {
3106 set et_vect_perm_byte_saved 0
3107 if { ([is-effective-target arm_neon_ok]
3108 && [is-effective-target arm_little_endian])
3109 || [istarget aarch64*-*-*]
3110 || [istarget powerpc*-*-*]
3111 || [istarget spu-*-*] } {
3112 set et_vect_perm_byte_saved 1
3115 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
3116 return $et_vect_perm_byte_saved
3119 # Return 1 if the target plus current options supports vector permutation
3120 # on short-sized elements, 0 otherwise.
3122 # This won't change for different subtargets so cache the result.
3124 proc check_effective_target_vect_perm_short { } {
3125 global et_vect_perm_short
3127 if [info exists et_vect_perm_short_saved] {
3128 verbose "check_effective_target_vect_perm_short: using cached result" 2
3129 } else {
3130 set et_vect_perm_short_saved 0
3131 if { ([is-effective-target arm_neon_ok]
3132 && [is-effective-target arm_little_endian])
3133 || [istarget aarch64*-*-*]
3134 || [istarget powerpc*-*-*]
3135 || [istarget spu-*-*] } {
3136 set et_vect_perm_short_saved 1
3139 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
3140 return $et_vect_perm_short_saved
3143 # Return 1 if the target plus current options supports a vector
3144 # widening summation of *short* args into *int* result, 0 otherwise.
3146 # This won't change for different subtargets so cache the result.
3148 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
3149 global et_vect_widen_sum_hi_to_si_pattern
3151 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
3152 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
3153 } else {
3154 set et_vect_widen_sum_hi_to_si_pattern_saved 0
3155 if { [istarget powerpc*-*-*]
3156 || [istarget ia64-*-*] } {
3157 set et_vect_widen_sum_hi_to_si_pattern_saved 1
3160 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
3161 return $et_vect_widen_sum_hi_to_si_pattern_saved
3164 # Return 1 if the target plus current options supports a vector
3165 # widening summation of *short* args into *int* result, 0 otherwise.
3166 # A target can also support this widening summation if it can support
3167 # promotion (unpacking) from shorts to ints.
3169 # This won't change for different subtargets so cache the result.
3171 proc check_effective_target_vect_widen_sum_hi_to_si { } {
3172 global et_vect_widen_sum_hi_to_si
3174 if [info exists et_vect_widen_sum_hi_to_si_saved] {
3175 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
3176 } else {
3177 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
3178 if { [istarget powerpc*-*-*]
3179 || [istarget ia64-*-*] } {
3180 set et_vect_widen_sum_hi_to_si_saved 1
3183 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
3184 return $et_vect_widen_sum_hi_to_si_saved
3187 # Return 1 if the target plus current options supports a vector
3188 # widening summation of *char* args into *short* result, 0 otherwise.
3189 # A target can also support this widening summation if it can support
3190 # promotion (unpacking) from chars to shorts.
3192 # This won't change for different subtargets so cache the result.
3194 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
3195 global et_vect_widen_sum_qi_to_hi
3197 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
3198 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
3199 } else {
3200 set et_vect_widen_sum_qi_to_hi_saved 0
3201 if { [check_effective_target_vect_unpack]
3202 || [check_effective_target_arm_neon_ok]
3203 || [istarget ia64-*-*] } {
3204 set et_vect_widen_sum_qi_to_hi_saved 1
3207 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
3208 return $et_vect_widen_sum_qi_to_hi_saved
3211 # Return 1 if the target plus current options supports a vector
3212 # widening summation of *char* args into *int* result, 0 otherwise.
3214 # This won't change for different subtargets so cache the result.
3216 proc check_effective_target_vect_widen_sum_qi_to_si { } {
3217 global et_vect_widen_sum_qi_to_si
3219 if [info exists et_vect_widen_sum_qi_to_si_saved] {
3220 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
3221 } else {
3222 set et_vect_widen_sum_qi_to_si_saved 0
3223 if { [istarget powerpc*-*-*] } {
3224 set et_vect_widen_sum_qi_to_si_saved 1
3227 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
3228 return $et_vect_widen_sum_qi_to_si_saved
3231 # Return 1 if the target plus current options supports a vector
3232 # widening multiplication of *char* args into *short* result, 0 otherwise.
3233 # A target can also support this widening multplication if it can support
3234 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
3235 # multiplication of shorts).
3237 # This won't change for different subtargets so cache the result.
3240 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
3241 global et_vect_widen_mult_qi_to_hi
3243 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
3244 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
3245 } else {
3246 if { [check_effective_target_vect_unpack]
3247 && [check_effective_target_vect_short_mult] } {
3248 set et_vect_widen_mult_qi_to_hi_saved 1
3249 } else {
3250 set et_vect_widen_mult_qi_to_hi_saved 0
3252 if { [istarget powerpc*-*-*]
3253 || [istarget aarch64*-*-*]
3254 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3255 set et_vect_widen_mult_qi_to_hi_saved 1
3258 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
3259 return $et_vect_widen_mult_qi_to_hi_saved
3262 # Return 1 if the target plus current options supports a vector
3263 # widening multiplication of *short* args into *int* result, 0 otherwise.
3264 # A target can also support this widening multplication if it can support
3265 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
3266 # multiplication of ints).
3268 # This won't change for different subtargets so cache the result.
3271 proc check_effective_target_vect_widen_mult_hi_to_si { } {
3272 global et_vect_widen_mult_hi_to_si
3274 if [info exists et_vect_widen_mult_hi_to_si_saved] {
3275 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
3276 } else {
3277 if { [check_effective_target_vect_unpack]
3278 && [check_effective_target_vect_int_mult] } {
3279 set et_vect_widen_mult_hi_to_si_saved 1
3280 } else {
3281 set et_vect_widen_mult_hi_to_si_saved 0
3283 if { [istarget powerpc*-*-*]
3284 || [istarget spu-*-*]
3285 || [istarget ia64-*-*]
3286 || [istarget aarch64*-*-*]
3287 || [istarget i?86-*-*]
3288 || [istarget x86_64-*-*]
3289 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3290 set et_vect_widen_mult_hi_to_si_saved 1
3293 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
3294 return $et_vect_widen_mult_hi_to_si_saved
3297 # Return 1 if the target plus current options supports a vector
3298 # widening multiplication of *char* args into *short* result, 0 otherwise.
3300 # This won't change for different subtargets so cache the result.
3302 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
3303 global et_vect_widen_mult_qi_to_hi_pattern
3305 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
3306 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
3307 } else {
3308 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
3309 if { [istarget powerpc*-*-*]
3310 || ([istarget arm*-*-*]
3311 && [check_effective_target_arm_neon_ok]
3312 && [check_effective_target_arm_little_endian]) } {
3313 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
3316 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
3317 return $et_vect_widen_mult_qi_to_hi_pattern_saved
3320 # Return 1 if the target plus current options supports a vector
3321 # widening multiplication of *short* args into *int* result, 0 otherwise.
3323 # This won't change for different subtargets so cache the result.
3325 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
3326 global et_vect_widen_mult_hi_to_si_pattern
3328 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
3329 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
3330 } else {
3331 set et_vect_widen_mult_hi_to_si_pattern_saved 0
3332 if { [istarget powerpc*-*-*]
3333 || [istarget spu-*-*]
3334 || [istarget ia64-*-*]
3335 || [istarget i?86-*-*]
3336 || [istarget x86_64-*-*]
3337 || ([istarget arm*-*-*]
3338 && [check_effective_target_arm_neon_ok]
3339 && [check_effective_target_arm_little_endian]) } {
3340 set et_vect_widen_mult_hi_to_si_pattern_saved 1
3343 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
3344 return $et_vect_widen_mult_hi_to_si_pattern_saved
3347 # Return 1 if the target plus current options supports a vector
3348 # widening shift, 0 otherwise.
3350 # This won't change for different subtargets so cache the result.
3352 proc check_effective_target_vect_widen_shift { } {
3353 global et_vect_widen_shift_saved
3355 if [info exists et_vect_shift_saved] {
3356 verbose "check_effective_target_vect_widen_shift: using cached result" 2
3357 } else {
3358 set et_vect_widen_shift_saved 0
3359 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3360 set et_vect_widen_shift_saved 1
3363 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
3364 return $et_vect_widen_shift_saved
3367 # Return 1 if the target plus current options supports a vector
3368 # dot-product of signed chars, 0 otherwise.
3370 # This won't change for different subtargets so cache the result.
3372 proc check_effective_target_vect_sdot_qi { } {
3373 global et_vect_sdot_qi
3375 if [info exists et_vect_sdot_qi_saved] {
3376 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
3377 } else {
3378 set et_vect_sdot_qi_saved 0
3379 if { [istarget ia64-*-*] } {
3380 set et_vect_udot_qi_saved 1
3383 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
3384 return $et_vect_sdot_qi_saved
3387 # Return 1 if the target plus current options supports a vector
3388 # dot-product of unsigned chars, 0 otherwise.
3390 # This won't change for different subtargets so cache the result.
3392 proc check_effective_target_vect_udot_qi { } {
3393 global et_vect_udot_qi
3395 if [info exists et_vect_udot_qi_saved] {
3396 verbose "check_effective_target_vect_udot_qi: using cached result" 2
3397 } else {
3398 set et_vect_udot_qi_saved 0
3399 if { [istarget powerpc*-*-*]
3400 || [istarget ia64-*-*] } {
3401 set et_vect_udot_qi_saved 1
3404 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
3405 return $et_vect_udot_qi_saved
3408 # Return 1 if the target plus current options supports a vector
3409 # dot-product of signed shorts, 0 otherwise.
3411 # This won't change for different subtargets so cache the result.
3413 proc check_effective_target_vect_sdot_hi { } {
3414 global et_vect_sdot_hi
3416 if [info exists et_vect_sdot_hi_saved] {
3417 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
3418 } else {
3419 set et_vect_sdot_hi_saved 0
3420 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3421 || [istarget ia64-*-*]
3422 || [istarget i?86-*-*]
3423 || [istarget x86_64-*-*] } {
3424 set et_vect_sdot_hi_saved 1
3427 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
3428 return $et_vect_sdot_hi_saved
3431 # Return 1 if the target plus current options supports a vector
3432 # dot-product of unsigned shorts, 0 otherwise.
3434 # This won't change for different subtargets so cache the result.
3436 proc check_effective_target_vect_udot_hi { } {
3437 global et_vect_udot_hi
3439 if [info exists et_vect_udot_hi_saved] {
3440 verbose "check_effective_target_vect_udot_hi: using cached result" 2
3441 } else {
3442 set et_vect_udot_hi_saved 0
3443 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
3444 set et_vect_udot_hi_saved 1
3447 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
3448 return $et_vect_udot_hi_saved
3452 # Return 1 if the target plus current options supports a vector
3453 # demotion (packing) of shorts (to chars) and ints (to shorts)
3454 # using modulo arithmetic, 0 otherwise.
3456 # This won't change for different subtargets so cache the result.
3458 proc check_effective_target_vect_pack_trunc { } {
3459 global et_vect_pack_trunc
3461 if [info exists et_vect_pack_trunc_saved] {
3462 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
3463 } else {
3464 set et_vect_pack_trunc_saved 0
3465 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3466 || [istarget i?86-*-*]
3467 || [istarget x86_64-*-*]
3468 || [istarget aarch64*-*-*]
3469 || [istarget spu-*-*]
3470 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3471 && [check_effective_target_arm_little_endian]) } {
3472 set et_vect_pack_trunc_saved 1
3475 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
3476 return $et_vect_pack_trunc_saved
3479 # Return 1 if the target plus current options supports a vector
3480 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
3482 # This won't change for different subtargets so cache the result.
3484 proc check_effective_target_vect_unpack { } {
3485 global et_vect_unpack
3487 if [info exists et_vect_unpack_saved] {
3488 verbose "check_effective_target_vect_unpack: using cached result" 2
3489 } else {
3490 set et_vect_unpack_saved 0
3491 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
3492 || [istarget i?86-*-*]
3493 || [istarget x86_64-*-*]
3494 || [istarget spu-*-*]
3495 || [istarget ia64-*-*]
3496 || [istarget aarch64*-*-*]
3497 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
3498 && [check_effective_target_arm_little_endian]) } {
3499 set et_vect_unpack_saved 1
3502 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
3503 return $et_vect_unpack_saved
3506 # Return 1 if the target plus current options does not guarantee
3507 # that its STACK_BOUNDARY is >= the reguired vector alignment.
3509 # This won't change for different subtargets so cache the result.
3511 proc check_effective_target_unaligned_stack { } {
3512 global et_unaligned_stack_saved
3514 if [info exists et_unaligned_stack_saved] {
3515 verbose "check_effective_target_unaligned_stack: using cached result" 2
3516 } else {
3517 set et_unaligned_stack_saved 0
3519 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
3520 return $et_unaligned_stack_saved
3523 # Return 1 if the target plus current options does not support a vector
3524 # alignment mechanism, 0 otherwise.
3526 # This won't change for different subtargets so cache the result.
3528 proc check_effective_target_vect_no_align { } {
3529 global et_vect_no_align_saved
3531 if [info exists et_vect_no_align_saved] {
3532 verbose "check_effective_target_vect_no_align: using cached result" 2
3533 } else {
3534 set et_vect_no_align_saved 0
3535 if { [istarget mipsisa64*-*-*]
3536 || [istarget mips-sde-elf]
3537 || [istarget sparc*-*-*]
3538 || [istarget ia64-*-*]
3539 || [check_effective_target_arm_vect_no_misalign]
3540 || ([istarget mips*-*-*]
3541 && [check_effective_target_mips_loongson]) } {
3542 set et_vect_no_align_saved 1
3545 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
3546 return $et_vect_no_align_saved
3549 # Return 1 if the target supports a vector misalign access, 0 otherwise.
3551 # This won't change for different subtargets so cache the result.
3553 proc check_effective_target_vect_hw_misalign { } {
3554 global et_vect_hw_misalign_saved
3556 if [info exists et_vect_hw_misalign_saved] {
3557 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
3558 } else {
3559 set et_vect_hw_misalign_saved 0
3560 if { ([istarget x86_64-*-*]
3561 || [istarget aarch64*-*-*]
3562 || [istarget i?86-*-*]) } {
3563 set et_vect_hw_misalign_saved 1
3566 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
3567 return $et_vect_hw_misalign_saved
3571 # Return 1 if arrays are aligned to the vector alignment
3572 # boundary, 0 otherwise.
3574 # This won't change for different subtargets so cache the result.
3576 proc check_effective_target_vect_aligned_arrays { } {
3577 global et_vect_aligned_arrays
3579 if [info exists et_vect_aligned_arrays_saved] {
3580 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
3581 } else {
3582 set et_vect_aligned_arrays_saved 0
3583 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3584 if { ([is-effective-target lp64]
3585 && ( ![check_avx_available]
3586 || [check_prefer_avx128])) } {
3587 set et_vect_aligned_arrays_saved 1
3590 if [istarget spu-*-*] {
3591 set et_vect_aligned_arrays_saved 1
3594 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
3595 return $et_vect_aligned_arrays_saved
3598 # Return 1 if types of size 32 bit or less are naturally aligned
3599 # (aligned to their type-size), 0 otherwise.
3601 # This won't change for different subtargets so cache the result.
3603 proc check_effective_target_natural_alignment_32 { } {
3604 global et_natural_alignment_32
3606 if [info exists et_natural_alignment_32_saved] {
3607 verbose "check_effective_target_natural_alignment_32: using cached result" 2
3608 } else {
3609 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
3610 set et_natural_alignment_32_saved 1
3611 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
3612 set et_natural_alignment_32_saved 0
3615 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
3616 return $et_natural_alignment_32_saved
3619 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
3620 # type-size), 0 otherwise.
3622 # This won't change for different subtargets so cache the result.
3624 proc check_effective_target_natural_alignment_64 { } {
3625 global et_natural_alignment_64
3627 if [info exists et_natural_alignment_64_saved] {
3628 verbose "check_effective_target_natural_alignment_64: using cached result" 2
3629 } else {
3630 set et_natural_alignment_64_saved 0
3631 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
3632 || [istarget spu-*-*] } {
3633 set et_natural_alignment_64_saved 1
3636 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
3637 return $et_natural_alignment_64_saved
3640 # Return 1 if all vector types are naturally aligned (aligned to their
3641 # type-size), 0 otherwise.
3643 # This won't change for different subtargets so cache the result.
3645 proc check_effective_target_vect_natural_alignment { } {
3646 global et_vect_natural_alignment
3648 if [info exists et_vect_natural_alignment_saved] {
3649 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
3650 } else {
3651 set et_vect_natural_alignment_saved 1
3652 if { [check_effective_target_arm_eabi] } {
3653 set et_vect_natural_alignment_saved 0
3656 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
3657 return $et_vect_natural_alignment_saved
3660 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
3662 # This won't change for different subtargets so cache the result.
3664 proc check_effective_target_vector_alignment_reachable { } {
3665 global et_vector_alignment_reachable
3667 if [info exists et_vector_alignment_reachable_saved] {
3668 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
3669 } else {
3670 if { [check_effective_target_vect_aligned_arrays]
3671 || [check_effective_target_natural_alignment_32] } {
3672 set et_vector_alignment_reachable_saved 1
3673 } else {
3674 set et_vector_alignment_reachable_saved 0
3677 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
3678 return $et_vector_alignment_reachable_saved
3681 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
3683 # This won't change for different subtargets so cache the result.
3685 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
3686 global et_vector_alignment_reachable_for_64bit
3688 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
3689 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
3690 } else {
3691 if { [check_effective_target_vect_aligned_arrays]
3692 || [check_effective_target_natural_alignment_64] } {
3693 set et_vector_alignment_reachable_for_64bit_saved 1
3694 } else {
3695 set et_vector_alignment_reachable_for_64bit_saved 0
3698 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
3699 return $et_vector_alignment_reachable_for_64bit_saved
3702 # Return 1 if the target only requires element alignment for vector accesses
3704 proc check_effective_target_vect_element_align { } {
3705 global et_vect_element_align
3707 if [info exists et_vect_element_align] {
3708 verbose "check_effective_target_vect_element_align: using cached result" 2
3709 } else {
3710 set et_vect_element_align 0
3711 if { ([istarget arm*-*-*]
3712 && ![check_effective_target_arm_vect_no_misalign])
3713 || [check_effective_target_vect_hw_misalign] } {
3714 set et_vect_element_align 1
3718 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
3719 return $et_vect_element_align
3722 # Return 1 if the target supports vector conditional operations, 0 otherwise.
3724 proc check_effective_target_vect_condition { } {
3725 global et_vect_cond_saved
3727 if [info exists et_vect_cond_saved] {
3728 verbose "check_effective_target_vect_cond: using cached result" 2
3729 } else {
3730 set et_vect_cond_saved 0
3731 if { [istarget aarch64*-*-*]
3732 || [istarget powerpc*-*-*]
3733 || [istarget ia64-*-*]
3734 || [istarget i?86-*-*]
3735 || [istarget spu-*-*]
3736 || [istarget x86_64-*-*]
3737 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
3738 set et_vect_cond_saved 1
3742 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
3743 return $et_vect_cond_saved
3746 # Return 1 if the target supports vector conditional operations where
3747 # the comparison has different type from the lhs, 0 otherwise.
3749 proc check_effective_target_vect_cond_mixed { } {
3750 global et_vect_cond_mixed_saved
3752 if [info exists et_vect_cond_mixed_saved] {
3753 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
3754 } else {
3755 set et_vect_cond_mixed_saved 0
3756 if { [istarget i?86-*-*]
3757 || [istarget x86_64-*-*]
3758 || [istarget powerpc*-*-*] } {
3759 set et_vect_cond_mixed_saved 1
3763 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
3764 return $et_vect_cond_mixed_saved
3767 # Return 1 if the target supports vector char multiplication, 0 otherwise.
3769 proc check_effective_target_vect_char_mult { } {
3770 global et_vect_char_mult_saved
3772 if [info exists et_vect_char_mult_saved] {
3773 verbose "check_effective_target_vect_char_mult: using cached result" 2
3774 } else {
3775 set et_vect_char_mult_saved 0
3776 if { [istarget aarch64*-*-*]
3777 || [istarget ia64-*-*]
3778 || [istarget i?86-*-*]
3779 || [istarget x86_64-*-*]
3780 || [check_effective_target_arm32] } {
3781 set et_vect_char_mult_saved 1
3785 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
3786 return $et_vect_char_mult_saved
3789 # Return 1 if the target supports vector short multiplication, 0 otherwise.
3791 proc check_effective_target_vect_short_mult { } {
3792 global et_vect_short_mult_saved
3794 if [info exists et_vect_short_mult_saved] {
3795 verbose "check_effective_target_vect_short_mult: using cached result" 2
3796 } else {
3797 set et_vect_short_mult_saved 0
3798 if { [istarget ia64-*-*]
3799 || [istarget spu-*-*]
3800 || [istarget i?86-*-*]
3801 || [istarget x86_64-*-*]
3802 || [istarget powerpc*-*-*]
3803 || [istarget aarch64*-*-*]
3804 || [check_effective_target_arm32]
3805 || ([istarget mips*-*-*]
3806 && [check_effective_target_mips_loongson]) } {
3807 set et_vect_short_mult_saved 1
3811 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
3812 return $et_vect_short_mult_saved
3815 # Return 1 if the target supports vector int multiplication, 0 otherwise.
3817 proc check_effective_target_vect_int_mult { } {
3818 global et_vect_int_mult_saved
3820 if [info exists et_vect_int_mult_saved] {
3821 verbose "check_effective_target_vect_int_mult: using cached result" 2
3822 } else {
3823 set et_vect_int_mult_saved 0
3824 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
3825 || [istarget spu-*-*]
3826 || [istarget i?86-*-*]
3827 || [istarget x86_64-*-*]
3828 || [istarget ia64-*-*]
3829 || [istarget aarch64*-*-*]
3830 || [check_effective_target_arm32] } {
3831 set et_vect_int_mult_saved 1
3835 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
3836 return $et_vect_int_mult_saved
3839 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
3841 proc check_effective_target_vect_extract_even_odd { } {
3842 global et_vect_extract_even_odd_saved
3844 if [info exists et_vect_extract_even_odd_saved] {
3845 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
3846 } else {
3847 set et_vect_extract_even_odd_saved 0
3848 if { [istarget aarch64*-*-*]
3849 || [istarget powerpc*-*-*]
3850 || [is-effective-target arm_neon_ok]
3851 || [istarget i?86-*-*]
3852 || [istarget x86_64-*-*]
3853 || [istarget ia64-*-*]
3854 || [istarget spu-*-*]
3855 || ([istarget mips*-*-*]
3856 && [check_effective_target_mpaired_single]) } {
3857 set et_vect_extract_even_odd_saved 1
3861 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
3862 return $et_vect_extract_even_odd_saved
3865 # Return 1 if the target supports vector interleaving, 0 otherwise.
3867 proc check_effective_target_vect_interleave { } {
3868 global et_vect_interleave_saved
3870 if [info exists et_vect_interleave_saved] {
3871 verbose "check_effective_target_vect_interleave: using cached result" 2
3872 } else {
3873 set et_vect_interleave_saved 0
3874 if { [istarget aarch64*-*-*]
3875 || [istarget powerpc*-*-*]
3876 || [is-effective-target arm_neon_ok]
3877 || [istarget i?86-*-*]
3878 || [istarget x86_64-*-*]
3879 || [istarget ia64-*-*]
3880 || [istarget spu-*-*]
3881 || ([istarget mips*-*-*]
3882 && [check_effective_target_mpaired_single]) } {
3883 set et_vect_interleave_saved 1
3887 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3888 return $et_vect_interleave_saved
3891 foreach N {2 3 4 8} {
3892 eval [string map [list N $N] {
3893 # Return 1 if the target supports 2-vector interleaving
3894 proc check_effective_target_vect_stridedN { } {
3895 global et_vect_stridedN_saved
3897 if [info exists et_vect_stridedN_saved] {
3898 verbose "check_effective_target_vect_stridedN: using cached result" 2
3899 } else {
3900 set et_vect_stridedN_saved 0
3901 if { (N & -N) == N
3902 && [check_effective_target_vect_interleave]
3903 && [check_effective_target_vect_extract_even_odd] } {
3904 set et_vect_stridedN_saved 1
3906 if { ([istarget arm*-*-*]
3907 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
3908 set et_vect_stridedN_saved 1
3912 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
3913 return $et_vect_stridedN_saved
3918 # Return 1 if the target supports multiple vector sizes
3920 proc check_effective_target_vect_multiple_sizes { } {
3921 global et_vect_multiple_sizes_saved
3923 set et_vect_multiple_sizes_saved 0
3924 if { ([istarget aarch64*-*-*]
3925 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
3926 set et_vect_multiple_sizes_saved 1
3928 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
3929 if { ([check_avx_available] && ![check_prefer_avx128]) } {
3930 set et_vect_multiple_sizes_saved 1
3934 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
3935 return $et_vect_multiple_sizes_saved
3938 # Return 1 if the target supports vectors of 64 bits.
3940 proc check_effective_target_vect64 { } {
3941 global et_vect64_saved
3943 if [info exists et_vect64_saved] {
3944 verbose "check_effective_target_vect64: using cached result" 2
3945 } else {
3946 set et_vect64_saved 0
3947 if { ([istarget arm*-*-*]
3948 && [check_effective_target_arm_neon_ok]
3949 && [check_effective_target_arm_little_endian]) } {
3950 set et_vect64_saved 1
3954 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
3955 return $et_vect64_saved
3958 # Return 1 if the target supports vector copysignf calls.
3960 proc check_effective_target_vect_call_copysignf { } {
3961 global et_vect_call_copysignf_saved
3963 if [info exists et_vect_call_copysignf_saved] {
3964 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
3965 } else {
3966 set et_vect_call_copysignf_saved 0
3967 if { [istarget i?86-*-*]
3968 || [istarget x86_64-*-*]
3969 || [istarget powerpc*-*-*] } {
3970 set et_vect_call_copysignf_saved 1
3974 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
3975 return $et_vect_call_copysignf_saved
3978 # Return 1 if the target supports vector sqrtf calls.
3980 proc check_effective_target_vect_call_sqrtf { } {
3981 global et_vect_call_sqrtf_saved
3983 if [info exists et_vect_call_sqrtf_saved] {
3984 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
3985 } else {
3986 set et_vect_call_sqrtf_saved 0
3987 if { [istarget aarch64*-*-*]
3988 || [istarget i?86-*-*]
3989 || [istarget x86_64-*-*]
3990 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
3991 set et_vect_call_sqrtf_saved 1
3995 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
3996 return $et_vect_call_sqrtf_saved
3999 # Return 1 if the target supports vector lrint calls.
4001 proc check_effective_target_vect_call_lrint { } {
4002 set et_vect_call_lrint 0
4003 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) && [check_effective_target_ilp32] } {
4004 set et_vect_call_lrint 1
4007 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
4008 return $et_vect_call_lrint
4011 # Return 1 if the target supports vector btrunc calls.
4013 proc check_effective_target_vect_call_btrunc { } {
4014 global et_vect_call_btrunc_saved
4016 if [info exists et_vect_call_btrunc_saved] {
4017 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
4018 } else {
4019 set et_vect_call_btrunc_saved 0
4020 if { [istarget aarch64*-*-*] } {
4021 set et_vect_call_btrunc_saved 1
4025 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
4026 return $et_vect_call_btrunc_saved
4029 # Return 1 if the target supports vector btruncf calls.
4031 proc check_effective_target_vect_call_btruncf { } {
4032 global et_vect_call_btruncf_saved
4034 if [info exists et_vect_call_btruncf_saved] {
4035 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
4036 } else {
4037 set et_vect_call_btruncf_saved 0
4038 if { [istarget aarch64*-*-*] } {
4039 set et_vect_call_btruncf_saved 1
4043 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
4044 return $et_vect_call_btruncf_saved
4047 # Return 1 if the target supports vector ceil calls.
4049 proc check_effective_target_vect_call_ceil { } {
4050 global et_vect_call_ceil_saved
4052 if [info exists et_vect_call_ceil_saved] {
4053 verbose "check_effective_target_vect_call_ceil: using cached result" 2
4054 } else {
4055 set et_vect_call_ceil_saved 0
4056 if { [istarget aarch64*-*-*] } {
4057 set et_vect_call_ceil_saved 1
4061 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
4062 return $et_vect_call_ceil_saved
4065 # Return 1 if the target supports vector ceilf calls.
4067 proc check_effective_target_vect_call_ceilf { } {
4068 global et_vect_call_ceilf_saved
4070 if [info exists et_vect_call_ceilf_saved] {
4071 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
4072 } else {
4073 set et_vect_call_ceilf_saved 0
4074 if { [istarget aarch64*-*-*] } {
4075 set et_vect_call_ceilf_saved 1
4079 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
4080 return $et_vect_call_ceilf_saved
4083 # Return 1 if the target supports vector floor calls.
4085 proc check_effective_target_vect_call_floor { } {
4086 global et_vect_call_floor_saved
4088 if [info exists et_vect_call_floor_saved] {
4089 verbose "check_effective_target_vect_call_floor: using cached result" 2
4090 } else {
4091 set et_vect_call_floor_saved 0
4092 if { [istarget aarch64*-*-*] } {
4093 set et_vect_call_floor_saved 1
4097 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
4098 return $et_vect_call_floor_saved
4101 # Return 1 if the target supports vector floorf calls.
4103 proc check_effective_target_vect_call_floorf { } {
4104 global et_vect_call_floorf_saved
4106 if [info exists et_vect_call_floorf_saved] {
4107 verbose "check_effective_target_vect_call_floorf: using cached result" 2
4108 } else {
4109 set et_vect_call_floorf_saved 0
4110 if { [istarget aarch64*-*-*] } {
4111 set et_vect_call_floorf_saved 1
4115 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
4116 return $et_vect_call_floorf_saved
4119 # Return 1 if the target supports vector lceil calls.
4121 proc check_effective_target_vect_call_lceil { } {
4122 global et_vect_call_lceil_saved
4124 if [info exists et_vect_call_lceil_saved] {
4125 verbose "check_effective_target_vect_call_lceil: using cached result" 2
4126 } else {
4127 set et_vect_call_lceil_saved 0
4128 if { [istarget aarch64*-*-*] } {
4129 set et_vect_call_lceil_saved 1
4133 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
4134 return $et_vect_call_lceil_saved
4137 # Return 1 if the target supports vector lfloor calls.
4139 proc check_effective_target_vect_call_lfloor { } {
4140 global et_vect_call_lfloor_saved
4142 if [info exists et_vect_call_lfloor_saved] {
4143 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
4144 } else {
4145 set et_vect_call_lfloor_saved 0
4146 if { [istarget aarch64*-*-*] } {
4147 set et_vect_call_lfloor_saved 1
4151 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
4152 return $et_vect_call_lfloor_saved
4155 # Return 1 if the target supports vector nearbyint calls.
4157 proc check_effective_target_vect_call_nearbyint { } {
4158 global et_vect_call_nearbyint_saved
4160 if [info exists et_vect_call_nearbyint_saved] {
4161 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
4162 } else {
4163 set et_vect_call_nearbyint_saved 0
4164 if { [istarget aarch64*-*-*] } {
4165 set et_vect_call_nearbyint_saved 1
4169 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
4170 return $et_vect_call_nearbyint_saved
4173 # Return 1 if the target supports vector nearbyintf calls.
4175 proc check_effective_target_vect_call_nearbyintf { } {
4176 global et_vect_call_nearbyintf_saved
4178 if [info exists et_vect_call_nearbyintf_saved] {
4179 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
4180 } else {
4181 set et_vect_call_nearbyintf_saved 0
4182 if { [istarget aarch64*-*-*] } {
4183 set et_vect_call_nearbyintf_saved 1
4187 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
4188 return $et_vect_call_nearbyintf_saved
4191 # Return 1 if the target supports vector round calls.
4193 proc check_effective_target_vect_call_round { } {
4194 global et_vect_call_round_saved
4196 if [info exists et_vect_call_round_saved] {
4197 verbose "check_effective_target_vect_call_round: using cached result" 2
4198 } else {
4199 set et_vect_call_round_saved 0
4200 if { [istarget aarch64*-*-*] } {
4201 set et_vect_call_round_saved 1
4205 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
4206 return $et_vect_call_round_saved
4209 # Return 1 if the target supports vector roundf calls.
4211 proc check_effective_target_vect_call_roundf { } {
4212 global et_vect_call_roundf_saved
4214 if [info exists et_vect_call_roundf_saved] {
4215 verbose "check_effective_target_vect_call_roundf: using cached result" 2
4216 } else {
4217 set et_vect_call_roundf_saved 0
4218 if { [istarget aarch64*-*-*] } {
4219 set et_vect_call_roundf_saved 1
4223 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
4224 return $et_vect_call_roundf_saved
4227 # Return 1 if the target supports section-anchors
4229 proc check_effective_target_section_anchors { } {
4230 global et_section_anchors_saved
4232 if [info exists et_section_anchors_saved] {
4233 verbose "check_effective_target_section_anchors: using cached result" 2
4234 } else {
4235 set et_section_anchors_saved 0
4236 if { [istarget powerpc*-*-*]
4237 || [istarget arm*-*-*] } {
4238 set et_section_anchors_saved 1
4242 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
4243 return $et_section_anchors_saved
4246 # Return 1 if the target supports atomic operations on "int_128" values.
4248 proc check_effective_target_sync_int_128 { } {
4249 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4250 && ![is-effective-target ia32] } {
4251 return 1
4252 } else {
4253 return 0
4257 # Return 1 if the target supports atomic operations on "int_128" values
4258 # and can execute them.
4260 proc check_effective_target_sync_int_128_runtime { } {
4261 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
4262 && ![is-effective-target ia32] } {
4263 return [check_cached_effective_target sync_int_128_available {
4264 check_runtime_nocache sync_int_128_available {
4265 #include "cpuid.h"
4266 int main ()
4268 unsigned int eax, ebx, ecx, edx;
4269 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4270 return !(ecx & bit_CMPXCHG16B);
4271 return 1;
4273 } ""
4275 } else {
4276 return 0
4280 # Return 1 if the target supports atomic operations on "long long".
4282 # Note: 32bit x86 targets require -march=pentium in dg-options.
4284 proc check_effective_target_sync_long_long { } {
4285 if { [istarget x86_64-*-*]
4286 || [istarget i?86-*-*])
4287 || [istarget arm*-*-*]
4288 || [istarget alpha*-*-*]
4289 || ([istarget sparc*-*-*] && [check_effective_target_lp64]) } {
4290 return 1
4291 } else {
4292 return 0
4296 # Return 1 if the target supports atomic operations on "long long"
4297 # and can execute them.
4299 # Note: 32bit x86 targets require -march=pentium in dg-options.
4301 proc check_effective_target_sync_long_long_runtime { } {
4302 if { [istarget x86_64-*-*]
4303 || [istarget i?86-*-*] } {
4304 return [check_cached_effective_target sync_long_long_available {
4305 check_runtime_nocache sync_long_long_available {
4306 #include "cpuid.h"
4307 int main ()
4309 unsigned int eax, ebx, ecx, edx;
4310 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
4311 return !(edx & bit_CMPXCHG8B);
4312 return 1;
4314 } ""
4316 } elseif { [istarget arm*-*-linux-*] } {
4317 return [check_runtime sync_longlong_runtime {
4318 #include <stdlib.h>
4319 int main ()
4321 long long l1;
4323 if (sizeof (long long) != 8)
4324 exit (1);
4326 /* Just check for native; checking for kernel fallback is tricky. */
4327 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
4329 exit (0);
4331 } "" ]
4332 } elseif { [istarget alpha*-*-*] } {
4333 return 1
4334 } elseif { ([istarget sparc*-*-*]
4335 && [check_effective_target_lp64]
4336 && [check_effective_target_ultrasparc_hw]) } {
4337 return 1
4338 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
4339 return 1
4340 } else {
4341 return 0
4345 # Return 1 if the target supports atomic operations on "int" and "long".
4347 proc check_effective_target_sync_int_long { } {
4348 global et_sync_int_long_saved
4350 if [info exists et_sync_int_long_saved] {
4351 verbose "check_effective_target_sync_int_long: using cached result" 2
4352 } else {
4353 set et_sync_int_long_saved 0
4354 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4355 # load-reserved/store-conditional instructions.
4356 if { [istarget ia64-*-*]
4357 || [istarget i?86-*-*]
4358 || [istarget x86_64-*-*]
4359 || [istarget aarch64*-*-*]
4360 || [istarget alpha*-*-*]
4361 || [istarget arm*-*-linux-*]
4362 || [istarget bfin*-*linux*]
4363 || [istarget hppa*-*linux*]
4364 || [istarget s390*-*-*]
4365 || [istarget powerpc*-*-*]
4366 || [istarget crisv32-*-*] || [istarget cris-*-*]
4367 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4368 || [check_effective_target_mips_llsc] } {
4369 set et_sync_int_long_saved 1
4373 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
4374 return $et_sync_int_long_saved
4377 # Return 1 if the target supports atomic operations on "char" and "short".
4379 proc check_effective_target_sync_char_short { } {
4380 global et_sync_char_short_saved
4382 if [info exists et_sync_char_short_saved] {
4383 verbose "check_effective_target_sync_char_short: using cached result" 2
4384 } else {
4385 set et_sync_char_short_saved 0
4386 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
4387 # load-reserved/store-conditional instructions.
4388 if { [istarget aarch64*-*-*]
4389 || [istarget ia64-*-*]
4390 || [istarget i?86-*-*]
4391 || [istarget x86_64-*-*]
4392 || [istarget alpha*-*-*]
4393 || [istarget arm*-*-linux-*]
4394 || [istarget hppa*-*linux*]
4395 || [istarget s390*-*-*]
4396 || [istarget powerpc*-*-*]
4397 || [istarget crisv32-*-*] || [istarget cris-*-*]
4398 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
4399 || [check_effective_target_mips_llsc] } {
4400 set et_sync_char_short_saved 1
4404 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
4405 return $et_sync_char_short_saved
4408 # Return 1 if the target uses a ColdFire FPU.
4410 proc check_effective_target_coldfire_fpu { } {
4411 return [check_no_compiler_messages coldfire_fpu assembly {
4412 #ifndef __mcffpu__
4413 #error FOO
4414 #endif
4418 # Return true if this is a uClibc target.
4420 proc check_effective_target_uclibc {} {
4421 return [check_no_compiler_messages uclibc object {
4422 #include <features.h>
4423 #if !defined (__UCLIBC__)
4424 #error FOO
4425 #endif
4429 # Return true if this is a uclibc target and if the uclibc feature
4430 # described by __$feature__ is not present.
4432 proc check_missing_uclibc_feature {feature} {
4433 return [check_no_compiler_messages $feature object "
4434 #include <features.h>
4435 #if !defined (__UCLIBC) || defined (__${feature}__)
4436 #error FOO
4437 #endif
4441 # Return true if this is a Newlib target.
4443 proc check_effective_target_newlib {} {
4444 return [check_no_compiler_messages newlib object {
4445 #include <newlib.h>
4449 # Return 1 if
4450 # (a) an error of a few ULP is expected in string to floating-point
4451 # conversion functions; and
4452 # (b) overflow is not always detected correctly by those functions.
4454 proc check_effective_target_lax_strtofp {} {
4455 # By default, assume that all uClibc targets suffer from this.
4456 return [check_effective_target_uclibc]
4459 # Return 1 if this is a target for which wcsftime is a dummy
4460 # function that always returns 0.
4462 proc check_effective_target_dummy_wcsftime {} {
4463 # By default, assume that all uClibc targets suffer from this.
4464 return [check_effective_target_uclibc]
4467 # Return 1 if constructors with initialization priority arguments are
4468 # supposed on this target.
4470 proc check_effective_target_init_priority {} {
4471 return [check_no_compiler_messages init_priority assembly "
4472 void f() __attribute__((constructor (1000)));
4473 void f() \{\}
4477 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
4478 # This can be used with any check_* proc that takes no argument and
4479 # returns only 1 or 0. It could be used with check_* procs that take
4480 # arguments with keywords that pass particular arguments.
4482 proc is-effective-target { arg } {
4483 set selected 0
4484 if { [info procs check_effective_target_${arg}] != [list] } {
4485 set selected [check_effective_target_${arg}]
4486 } else {
4487 switch $arg {
4488 "vmx_hw" { set selected [check_vmx_hw_available] }
4489 "vsx_hw" { set selected [check_vsx_hw_available] }
4490 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
4491 "named_sections" { set selected [check_named_sections_available] }
4492 "gc_sections" { set selected [check_gc_sections_available] }
4493 "cxa_atexit" { set selected [check_cxa_atexit_available] }
4494 default { error "unknown effective target keyword `$arg'" }
4497 verbose "is-effective-target: $arg $selected" 2
4498 return $selected
4501 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
4503 proc is-effective-target-keyword { arg } {
4504 if { [info procs check_effective_target_${arg}] != [list] } {
4505 return 1
4506 } else {
4507 # These have different names for their check_* procs.
4508 switch $arg {
4509 "vmx_hw" { return 1 }
4510 "vsx_hw" { return 1 }
4511 "ppc_recip_hw" { return 1 }
4512 "named_sections" { return 1 }
4513 "gc_sections" { return 1 }
4514 "cxa_atexit" { return 1 }
4515 default { return 0 }
4520 # Return 1 if target default to short enums
4522 proc check_effective_target_short_enums { } {
4523 return [check_no_compiler_messages short_enums assembly {
4524 enum foo { bar };
4525 int s[sizeof (enum foo) == 1 ? 1 : -1];
4529 # Return 1 if target supports merging string constants at link time.
4531 proc check_effective_target_string_merging { } {
4532 return [check_no_messages_and_pattern string_merging \
4533 "rodata\\.str" assembly {
4534 const char *var = "String";
4535 } {-O2}]
4538 # Return 1 if target has the basic signed and unsigned types in
4539 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
4540 # working <stdint.h> for all targets.
4542 proc check_effective_target_stdint_types { } {
4543 return [check_no_compiler_messages stdint_types assembly {
4544 #include <stdint.h>
4545 int8_t a; int16_t b; int32_t c; int64_t d;
4546 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4550 # Return 1 if target has the basic signed and unsigned types in
4551 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
4552 # these types agree with those in the header, as some systems have
4553 # only <inttypes.h>.
4555 proc check_effective_target_inttypes_types { } {
4556 return [check_no_compiler_messages inttypes_types assembly {
4557 #include <inttypes.h>
4558 int8_t a; int16_t b; int32_t c; int64_t d;
4559 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
4563 # Return 1 if programs are intended to be run on a simulator
4564 # (i.e. slowly) rather than hardware (i.e. fast).
4566 proc check_effective_target_simulator { } {
4568 # All "src/sim" simulators set this one.
4569 if [board_info target exists is_simulator] {
4570 return [board_info target is_simulator]
4573 # The "sid" simulators don't set that one, but at least they set
4574 # this one.
4575 if [board_info target exists slow_simulator] {
4576 return [board_info target slow_simulator]
4579 return 0
4582 # Return 1 if the target is a VxWorks kernel.
4584 proc check_effective_target_vxworks_kernel { } {
4585 return [check_no_compiler_messages vxworks_kernel assembly {
4586 #if !defined __vxworks || defined __RTP__
4587 #error NO
4588 #endif
4592 # Return 1 if the target is a VxWorks RTP.
4594 proc check_effective_target_vxworks_rtp { } {
4595 return [check_no_compiler_messages vxworks_rtp assembly {
4596 #if !defined __vxworks || !defined __RTP__
4597 #error NO
4598 #endif
4602 # Return 1 if the target is expected to provide wide character support.
4604 proc check_effective_target_wchar { } {
4605 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
4606 return 0
4608 return [check_no_compiler_messages wchar assembly {
4609 #include <wchar.h>
4613 # Return 1 if the target has <pthread.h>.
4615 proc check_effective_target_pthread_h { } {
4616 return [check_no_compiler_messages pthread_h assembly {
4617 #include <pthread.h>
4621 # Return 1 if the target can truncate a file from a file-descriptor,
4622 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
4623 # chsize. We test for a trivially functional truncation; no stubs.
4624 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
4625 # different function to be used.
4627 proc check_effective_target_fd_truncate { } {
4628 set prog {
4629 #define _FILE_OFFSET_BITS 64
4630 #include <unistd.h>
4631 #include <stdio.h>
4632 #include <stdlib.h>
4633 int main ()
4635 FILE *f = fopen ("tst.tmp", "wb");
4636 int fd;
4637 const char t[] = "test writing more than ten characters";
4638 char s[11];
4639 int status = 0;
4640 fd = fileno (f);
4641 write (fd, t, sizeof (t) - 1);
4642 lseek (fd, 0, 0);
4643 if (ftruncate (fd, 10) != 0)
4644 status = 1;
4645 close (fd);
4646 fclose (f);
4647 if (status)
4649 unlink ("tst.tmp");
4650 exit (status);
4652 f = fopen ("tst.tmp", "rb");
4653 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
4654 status = 1;
4655 fclose (f);
4656 unlink ("tst.tmp");
4657 exit (status);
4661 if { [check_runtime ftruncate $prog] } {
4662 return 1;
4665 regsub "ftruncate" $prog "chsize" prog
4666 return [check_runtime chsize $prog]
4669 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
4671 proc add_options_for_c99_runtime { flags } {
4672 if { [istarget *-*-solaris2*] } {
4673 return "$flags -std=c99"
4675 if { [istarget powerpc-*-darwin*] } {
4676 return "$flags -mmacosx-version-min=10.3"
4678 return $flags
4681 # Add to FLAGS all the target-specific flags needed to enable
4682 # full IEEE compliance mode.
4684 proc add_options_for_ieee { flags } {
4685 if { [istarget alpha*-*-*]
4686 || [istarget sh*-*-*] } {
4687 return "$flags -mieee"
4689 if { [istarget rx-*-*] } {
4690 return "$flags -mnofpu"
4692 return $flags
4695 # Add to FLAGS the flags needed to enable functions to bind locally
4696 # when using pic/PIC passes in the testsuite.
4698 proc add_options_for_bind_pic_locally { flags } {
4699 if {[check_no_compiler_messages using_pic2 assembly {
4700 #if __PIC__ != 2
4701 #error FOO
4702 #endif
4703 }]} {
4704 return "$flags -fPIE"
4706 if {[check_no_compiler_messages using_pic1 assembly {
4707 #if __PIC__ != 1
4708 #error FOO
4709 #endif
4710 }]} {
4711 return "$flags -fpie"
4714 return $flags
4717 # Add to FLAGS the flags needed to enable 64-bit vectors.
4719 proc add_options_for_double_vectors { flags } {
4720 if [is-effective-target arm_neon_ok] {
4721 return "$flags -mvectorize-with-neon-double"
4724 return $flags
4727 # Add to FLAGS the flags needed to disable inlining of
4728 # UPC run-time access routines.
4730 proc add_options_for_upc_library_calls { flags } {
4731 return "$flags -fno-upc-inline-lib"
4734 # Check if UPC struct pts build
4736 proc check_effective_target_upc_struct_pts { } {
4737 return [check_no_compiler_messages upc_struct_pts object {
4738 #include <upc.h>
4739 #ifndef __UPC_PTS_STRUCT_REP__
4740 # error struct PTS is not supported
4741 #endif
4745 # Check if UPC packed pts build
4747 proc check_effective_target_upc_packed_pts { } {
4748 return [check_no_compiler_messages upc_packed_pts object {
4749 #include <upc.h>
4750 #ifndef __UPC_PTS_PACKED_REP__
4751 # error packed PTS is not supported
4752 #endif
4756 # Return 1 if the target provides a full C99 runtime.
4758 proc check_effective_target_c99_runtime { } {
4759 return [check_cached_effective_target c99_runtime {
4760 global srcdir
4762 set file [open "$srcdir/gcc.dg/builtins-config.h"]
4763 set contents [read $file]
4764 close $file
4765 append contents {
4766 #ifndef HAVE_C99_RUNTIME
4767 #error FOO
4768 #endif
4770 check_no_compiler_messages_nocache c99_runtime assembly \
4771 $contents [add_options_for_c99_runtime ""]
4775 # Return 1 if target wchar_t is at least 4 bytes.
4777 proc check_effective_target_4byte_wchar_t { } {
4778 return [check_no_compiler_messages 4byte_wchar_t object {
4779 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
4783 # Return 1 if the target supports automatic stack alignment.
4785 proc check_effective_target_automatic_stack_alignment { } {
4786 # Ordinarily x86 supports automatic stack alignment ...
4787 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
4788 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
4789 # ... except Win64 SEH doesn't. Succeed for Win32 though.
4790 return [check_effective_target_ilp32];
4792 return 1;
4794 return 0;
4797 # Return true if we are compiling for AVX target.
4799 proc check_avx_available { } {
4800 if { [check_no_compiler_messages avx_available assembly {
4801 #ifndef __AVX__
4802 #error unsupported
4803 #endif
4804 } ""] } {
4805 return 1;
4807 return 0;
4810 # Return true if 32- and 16-bytes vectors are available.
4812 proc check_effective_target_vect_sizes_32B_16B { } {
4813 return [check_avx_available];
4816 # Return true if 128-bits vectors are preferred even if 256-bits vectors
4817 # are available.
4819 proc check_prefer_avx128 { } {
4820 if ![check_avx_available] {
4821 return 0;
4823 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
4824 float a[1024],b[1024],c[1024];
4825 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
4826 } "-O2 -ftree-vectorize"]
4830 # Return 1 if avx instructions can be compiled.
4832 proc check_effective_target_avx { } {
4833 return [check_no_compiler_messages avx object {
4834 void _mm256_zeroall (void)
4836 __builtin_ia32_vzeroall ();
4838 } "-O2 -mavx" ]
4841 # Return 1 if sse instructions can be compiled.
4842 proc check_effective_target_sse { } {
4843 return [check_no_compiler_messages sse object {
4844 int main ()
4846 __builtin_ia32_stmxcsr ();
4847 return 0;
4849 } "-O2 -msse" ]
4852 # Return 1 if sse2 instructions can be compiled.
4853 proc check_effective_target_sse2 { } {
4854 return [check_no_compiler_messages sse2 object {
4855 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
4857 __m128i _mm_srli_si128 (__m128i __A, int __N)
4859 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
4861 } "-O2 -msse2" ]
4864 # Return 1 if F16C instructions can be compiled.
4866 proc check_effective_target_f16c { } {
4867 return [check_no_compiler_messages f16c object {
4868 #include "immintrin.h"
4869 float
4870 foo (unsigned short val)
4872 return _cvtsh_ss (val);
4874 } "-O2 -mf16c" ]
4877 # Return 1 if C wchar_t type is compatible with char16_t.
4879 proc check_effective_target_wchar_t_char16_t_compatible { } {
4880 return [check_no_compiler_messages wchar_t_char16_t object {
4881 __WCHAR_TYPE__ wc;
4882 __CHAR16_TYPE__ *p16 = &wc;
4883 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4887 # Return 1 if C wchar_t type is compatible with char32_t.
4889 proc check_effective_target_wchar_t_char32_t_compatible { } {
4890 return [check_no_compiler_messages wchar_t_char32_t object {
4891 __WCHAR_TYPE__ wc;
4892 __CHAR32_TYPE__ *p32 = &wc;
4893 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
4897 # Return 1 if pow10 function exists.
4899 proc check_effective_target_pow10 { } {
4900 return [check_runtime pow10 {
4901 #include <math.h>
4902 int main () {
4903 double x;
4904 x = pow10 (1);
4905 return 0;
4907 } "-lm" ]
4910 # Return 1 if current options generate DFP instructions, 0 otherwise.
4912 proc check_effective_target_hard_dfp {} {
4913 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
4914 typedef float d64 __attribute__((mode(DD)));
4915 d64 x, y, z;
4916 void foo (void) { z = x + y; }
4920 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
4921 # for strchr etc. functions.
4923 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
4924 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
4925 #include <string.h>
4926 #include <wchar.h>
4927 #if !defined(__cplusplus) \
4928 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
4929 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
4930 ISO C++ correct string.h and wchar.h protos not supported.
4931 #else
4932 int i;
4933 #endif
4937 # Return 1 if GNU as is used.
4939 proc check_effective_target_gas { } {
4940 global use_gas_saved
4941 global tool
4943 if {![info exists use_gas_saved]} {
4944 # Check if the as used by gcc is GNU as.
4945 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
4946 # Provide /dev/null as input, otherwise gas times out reading from
4947 # stdin.
4948 set status [remote_exec host "$gcc_as" "-v /dev/null"]
4949 set as_output [lindex $status 1]
4950 if { [ string first "GNU" $as_output ] >= 0 } {
4951 set use_gas_saved 1
4952 } else {
4953 set use_gas_saved 0
4956 return $use_gas_saved
4959 # Return 1 if GNU ld is used.
4961 proc check_effective_target_gld { } {
4962 global use_gld_saved
4963 global tool
4965 if {![info exists use_gld_saved]} {
4966 # Check if the ld used by gcc is GNU ld.
4967 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
4968 set status [remote_exec host "$gcc_ld" "--version"]
4969 set ld_output [lindex $status 1]
4970 if { [ string first "GNU" $ld_output ] >= 0 } {
4971 set use_gld_saved 1
4972 } else {
4973 set use_gld_saved 0
4976 return $use_gld_saved
4979 # Return 1 if the compiler has been configure with link-time optimization
4980 # (LTO) support.
4982 proc check_effective_target_lto { } {
4983 global ENABLE_LTO
4984 return [info exists ENABLE_LTO]
4987 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
4989 proc check_effective_target_maybe_x32 { } {
4990 return [check_no_compiler_messages maybe_x32 object {
4991 void foo (void) {}
4992 } "-mx32 -maddress-mode=short"]
4995 # Return 1 if this target supports the -fsplit-stack option, 0
4996 # otherwise.
4998 proc check_effective_target_split_stack {} {
4999 return [check_no_compiler_messages split_stack object {
5000 void foo (void) { }
5001 } "-fsplit-stack"]
5004 # Return 1 if this target supports the -masm=intel option, 0
5005 # otherwise
5007 proc check_effective_target_masm_intel {} {
5008 return [check_no_compiler_messages masm_intel object {
5009 extern void abort (void);
5010 } "-masm=intel"]
5013 # Return 1 if the language for the compiler under test is C.
5015 proc check_effective_target_c { } {
5016 global tool
5017 if [string match $tool "gcc"] {
5018 return 1
5020 return 0
5023 # Return 1 if the language for the compiler under test is C++.
5025 proc check_effective_target_c++ { } {
5026 global tool
5027 if [string match $tool "g++"] {
5028 return 1
5030 return 0
5033 # Check which language standard is active by checking for the presence of
5034 # one of the C++11 -std flags. This assumes that the default for the
5035 # compiler is C++98, and that there will never be multiple -std= arguments
5036 # on the command line.
5037 proc check_effective_target_c++11 { } {
5038 if ![check_effective_target_c++] {
5039 return 0
5041 return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
5044 proc check_effective_target_c++1y { } {
5045 if ![check_effective_target_c++] {
5046 return 0
5048 return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }]
5051 proc check_effective_target_c++98 { } {
5052 if ![check_effective_target_c++] {
5053 return 0
5055 return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }]
5058 # Return 1 if expensive testcases should be run.
5060 proc check_effective_target_run_expensive_tests { } {
5061 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
5062 return 1
5064 return 0
5067 # Returns 1 if "mempcpy" is available on the target system.
5069 proc check_effective_target_mempcpy {} {
5070 return [check_function_available "mempcpy"]
5073 # Check whether the vectorizer tests are supported by the target and
5074 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
5075 # Set dg-do-what-default to either compile or run, depending on target
5076 # capabilities. Return 1 if vectorizer tests are supported by
5077 # target, 0 otherwise.
5079 proc check_vect_support_and_set_flags { } {
5080 global DEFAULT_VECTCFLAGS
5081 global dg-do-what-default
5083 if [istarget powerpc-*paired*] {
5084 lappend DEFAULT_VECTCFLAGS "-mpaired"
5085 if [check_750cl_hw_available] {
5086 set dg-do-what-default run
5087 } else {
5088 set dg-do-what-default compile
5090 } elseif [istarget powerpc*-*-*] {
5091 # Skip targets not supporting -maltivec.
5092 if ![is-effective-target powerpc_altivec_ok] {
5093 return 0
5096 lappend DEFAULT_VECTCFLAGS "-maltivec"
5097 if [check_vsx_hw_available] {
5098 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
5101 if [check_vmx_hw_available] {
5102 set dg-do-what-default run
5103 } else {
5104 if [is-effective-target ilp32] {
5105 # Specify a cpu that supports VMX for compile-only tests.
5106 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
5108 set dg-do-what-default compile
5110 } elseif { [istarget spu-*-*] } {
5111 set dg-do-what-default run
5112 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
5113 lappend DEFAULT_VECTCFLAGS "-msse2"
5114 if { [check_effective_target_sse2_runtime] } {
5115 set dg-do-what-default run
5116 } else {
5117 set dg-do-what-default compile
5119 } elseif { [istarget mips*-*-*]
5120 && ([check_effective_target_mpaired_single]
5121 || [check_effective_target_mips_loongson])
5122 && [check_effective_target_nomips16] } {
5123 if { [check_effective_target_mpaired_single] } {
5124 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
5126 set dg-do-what-default run
5127 } elseif [istarget sparc*-*-*] {
5128 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
5129 if [check_effective_target_ultrasparc_hw] {
5130 set dg-do-what-default run
5131 } else {
5132 set dg-do-what-default compile
5134 } elseif [istarget alpha*-*-*] {
5135 # Alpha's vectorization capabilities are extremely limited.
5136 # It's more effort than its worth disabling all of the tests
5137 # that it cannot pass. But if you actually want to see what
5138 # does work, command out the return.
5139 return 0
5141 lappend DEFAULT_VECTCFLAGS "-mmax"
5142 if [check_alpha_max_hw_available] {
5143 set dg-do-what-default run
5144 } else {
5145 set dg-do-what-default compile
5147 } elseif [istarget ia64-*-*] {
5148 set dg-do-what-default run
5149 } elseif [is-effective-target arm_neon_ok] {
5150 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
5151 # NEON does not support denormals, so is not used for vectorization by
5152 # default to avoid loss of precision. We must pass -ffast-math to test
5153 # vectorization of float operations.
5154 lappend DEFAULT_VECTCFLAGS "-ffast-math"
5155 if [is-effective-target arm_neon_hw] {
5156 set dg-do-what-default run
5157 } else {
5158 set dg-do-what-default compile
5160 } elseif [istarget "aarch64*-*-*"] {
5161 set dg-do-what-default run
5162 } else {
5163 return 0
5166 return 1
5169 proc check_effective_target_non_strict_align {} {
5170 return [check_no_compiler_messages non_strict_align assembly {
5171 char *y;
5172 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
5173 c *z;
5174 void foo(void) { z = (c *) y; }
5175 } "-Wcast-align"]
5178 # Return 1 if the target has <ucontext.h>.
5180 proc check_effective_target_ucontext_h { } {
5181 return [check_no_compiler_messages ucontext_h assembly {
5182 #include <ucontext.h>
5186 proc check_effective_target_aarch64_tiny { } {
5187 if { [istarget aarch64*-*-*] } {
5188 return [check_no_compiler_messages aarch64_tiny object {
5189 #ifdef __AARCH64_CMODEL_TINY__
5190 int dummy;
5191 #else
5192 #error target not AArch64 tiny code model
5193 #endif
5195 } else {
5196 return 0
5200 proc check_effective_target_aarch64_small { } {
5201 if { [istarget aarch64*-*-*] } {
5202 return [check_no_compiler_messages aarch64_small object {
5203 #ifdef __AARCH64_CMODEL_SMALL__
5204 int dummy;
5205 #else
5206 #error target not AArch64 small code model
5207 #endif
5209 } else {
5210 return 0
5214 proc check_effective_target_aarch64_large { } {
5215 if { [istarget aarch64*-*-*] } {
5216 return [check_no_compiler_messages aarch64_large object {
5217 #ifdef __AARCH64_CMODEL_LARGE__
5218 int dummy;
5219 #else
5220 #error target not AArch64 large code model
5221 #endif
5223 } else {
5224 return 0