2010-07-27 Paolo Carlini <paolo.carlini@oracle.com>
[official-gcc/alias-decl.git] / gcc / testsuite / lib / target-supports.exp
blobb3123442837ec4801330a41612bdcbc6b0897423
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
21 # This file defines procs for determining features supported by the target.
23 # Try to compile the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
32 # Assume by default that CONTENTS is C code.
33 # Otherwise, code should contain:
34 # "// C++" for c++,
35 # "! Fortran" for Fortran code,
36 # "/* ObjC", for ObjC
37 # and "// ObjC++" for ObjC++
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
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 default {
55 switch -- $tool {
56 "objc" { set src ${basename}[pid].m }
57 "obj-c++" { set src ${basename}[pid].mm }
58 default { set src ${basename}[pid].c }
63 set compile_type $type
64 switch -glob $type {
65 assembly { set output ${basename}[pid].s }
66 object { set output ${basename}[pid].o }
67 executable { set output ${basename}[pid].exe }
68 "rtl-*" {
69 set output ${basename}[pid].s
70 lappend options "additional_flags=-fdump-$type"
71 set compile_type assembly
74 set f [open $src "w"]
75 puts $f $contents
76 close $f
77 set lines [${tool}_target_compile $src $output $compile_type "$options"]
78 file delete $src
80 set scan_output $output
81 # Don't try folding this into the switch above; calling "glob" before the
82 # file is created won't work.
83 if [regexp "rtl-(.*)" $type dummy rtl_type] {
84 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
85 file delete $output
88 return [list $lines $scan_output]
91 proc current_target_name { } {
92 global target_info
93 if [info exists target_info(target,name)] {
94 set answer $target_info(target,name)
95 } else {
96 set answer ""
98 return $answer
101 # Implement an effective-target check for property PROP by invoking
102 # the Tcl command ARGS and seeing if it returns true.
104 proc check_cached_effective_target { prop args } {
105 global et_cache
107 set target [current_target_name]
108 if {![info exists et_cache($prop,target)]
109 || $et_cache($prop,target) != $target} {
110 verbose "check_cached_effective_target $prop: checking $target" 2
111 set et_cache($prop,target) $target
112 set et_cache($prop,value) [uplevel eval $args]
114 set value $et_cache($prop,value)
115 verbose "check_cached_effective_target $prop: returning $value for $target" 2
116 return $value
119 # Like check_compile, but delete the output file and return true if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache {args} {
122 set result [eval check_compile $args]
123 set lines [lindex $result 0]
124 set output [lindex $result 1]
125 remote_file build delete $output
126 return [string match "" $lines]
129 # Like check_no_compiler_messages_nocache, but cache the result.
130 # PROP is the property we're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133 return [check_cached_effective_target $prop {
134 eval [list check_no_compiler_messages_nocache $prop] $args
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP, otherwise they satisfy it
142 # if they do match regular expression PATTERN. (PATTERN can start
143 # with something like "[!]" if the regular expression needs to match
144 # "!" as the first character.)
146 # Delete the output file before returning. The other arguments are
147 # as for check_compile.
148 proc check_no_messages_and_pattern_nocache {basename pattern args} {
149 global tool
151 set result [eval [list check_compile $basename] $args]
152 set lines [lindex $result 0]
153 set output [lindex $result 1]
155 set ok 0
156 if { [string match "" $lines] } {
157 set chan [open "$output"]
158 set invert [regexp {^!(.*)} $pattern dummy pattern]
159 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
160 close $chan
163 remote_file build delete $output
164 return $ok
167 # Like check_no_messages_and_pattern_nocache, but cache the result.
168 # PROP is the property we're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171 return [check_cached_effective_target $prop {
172 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
176 # Try to compile and run an executable from code CONTENTS. Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense. The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
181 global tool
183 set result [eval [list check_compile $basename executable $contents] $args]
184 set lines [lindex $result 0]
185 set output [lindex $result 1]
187 set ok 0
188 if { [string match "" $lines] } {
189 # No error messages, everything is OK.
190 set result [remote_load target "./$output" "" ""]
191 set status [lindex $result 0]
192 verbose "check_runtime_nocache $basename: status is <$status>" 2
193 if { $status == "pass" } {
194 set ok 1
197 remote_file build delete $output
198 return $ok
201 # Like check_runtime_nocache, but cache the result. PROP is the
202 # property we're checking, and doubles as a prefix for temporary
203 # filenames.
204 proc check_runtime {prop args} {
205 global tool
207 return [check_cached_effective_target $prop {
208 eval [list check_runtime_nocache $prop] $args
212 ###############################
213 # proc check_weak_available { }
214 ###############################
216 # weak symbols are only supported in some configs/object formats
217 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
219 proc check_weak_available { } {
220 global target_triplet
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 { [regexp ".*-solaris2.*" $target_triplet] } {
232 return 1
235 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
237 if { [regexp "alpha.*osf.*" $target_triplet] } {
238 return 1
241 # Windows targets Cygwin and MingW32 support it
243 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
244 return 1
247 # HP-UX 10.X doesn't support it
249 if { [istarget "hppa*-*-hpux10*"] } {
250 return 0
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
256 set objformat [gcc_target_object_format]
258 switch $objformat {
259 elf { return 1 }
260 ecoff { return 1 }
261 a.out { return 1 }
262 mach-o { return 1 }
263 som { return 1 }
264 unknown { return -1 }
265 default { return 0 }
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
276 proc check_weak_override_available { } {
277 if { [istarget "*-*-mingw*"] } {
278 return 0
280 return [check_weak_available]
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
291 proc check_visibility_available { what_kind } {
292 global tool
293 global target_triplet
295 # On NetWare, support makes no sense.
296 if { [istarget *-*-netware*] } {
297 return 0
300 if [string match "" $what_kind] { set what_kind "hidden" }
302 return [check_no_compiler_messages visibility_available_$what_kind object "
303 void f() __attribute__((visibility(\"$what_kind\")));
304 void f() {}
308 ###############################
309 # proc check_alias_available { }
310 ###############################
312 # Determine if the target toolchain supports the alias attribute.
314 # Returns 2 if the target supports aliases. Returns 1 if the target
315 # only supports weak aliased. Returns 0 if the target does not
316 # support aliases at all. Returns -1 if support for aliases could not
317 # be determined.
319 proc check_alias_available { } {
320 global alias_available_saved
321 global tool
323 if [info exists alias_available_saved] {
324 verbose "check_alias_available returning saved $alias_available_saved" 2
325 } else {
326 set src alias[pid].c
327 set obj alias[pid].o
328 verbose "check_alias_available compiling testfile $src" 2
329 set f [open $src "w"]
330 # Compile a small test program. The definition of "g" is
331 # necessary to keep the Solaris assembler from complaining
332 # about the program.
333 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
335 close $f
336 set lines [${tool}_target_compile $src $obj object ""]
337 file delete $src
338 remote_file build delete $obj
340 if [string match "" $lines] then {
341 # No error messages, everything is OK.
342 set alias_available_saved 2
343 } else {
344 if [regexp "alias definitions not supported" $lines] {
345 verbose "check_alias_available target does not support aliases" 2
347 set objformat [gcc_target_object_format]
349 if { $objformat == "elf" } {
350 verbose "check_alias_available but target uses ELF format, so it ought to" 2
351 set alias_available_saved -1
352 } else {
353 set alias_available_saved 0
355 } else {
356 if [regexp "only weak aliases are supported" $lines] {
357 verbose "check_alias_available target supports only weak aliases" 2
358 set alias_available_saved 1
359 } else {
360 set alias_available_saved -1
365 verbose "check_alias_available returning $alias_available_saved" 2
368 return $alias_available_saved
371 # Returns true if --gc-sections is supported on the target.
373 proc check_gc_sections_available { } {
374 global gc_sections_available_saved
375 global tool
377 if {![info exists gc_sections_available_saved]} {
378 # Some targets don't support gc-sections despite whatever's
379 # advertised by ld's options.
380 if { [istarget alpha*-*-*]
381 || [istarget ia64-*-*] } {
382 set gc_sections_available_saved 0
383 return 0
386 # elf2flt uses -q (--emit-relocs), which is incompatible with
387 # --gc-sections.
388 if { [board_info target exists ldflags]
389 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
390 set gc_sections_available_saved 0
391 return 0
394 # VxWorks kernel modules are relocatable objects linked with -r,
395 # while RTP executables are linked with -q (--emit-relocs).
396 # Both of these options are incompatible with --gc-sections.
397 if { [istarget *-*-vxworks*] } {
398 set gc_sections_available_saved 0
399 return 0
402 # Check if the ld used by gcc supports --gc-sections.
403 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
404 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
405 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
406 set ld_output [remote_exec host "$gcc_ld" "--help"]
407 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
408 set gc_sections_available_saved 1
409 } else {
410 set gc_sections_available_saved 0
413 return $gc_sections_available_saved
416 # Return 1 if according to target_info struct and explicit target list
417 # target is supposed to support trampolines.
419 proc check_effective_target_trampolines { } {
420 if [target_info exists no_trampolines] {
421 return 0
423 if { [istarget avr-*-*]
424 || [istarget hppa2.0w-hp-hpux11.23]
425 || [istarget hppa64-hp-hpux11.23] } {
426 return 0;
428 return 1
431 # Return 1 if according to target_info struct and explicit target list
432 # target is supposed to keep null pointer checks. This could be due to
433 # use of option fno-delete-null-pointer-checks or hardwired in target.
435 proc check_effective_target_keeps_null_pointer_checks { } {
436 if [target_info exists keeps_null_pointer_checks] {
437 return 1
439 if { [istarget avr-*-*] } {
440 return 1;
442 return 0
445 # Return true if profiling is supported on the target.
447 proc check_profiling_available { test_what } {
448 global profiling_available_saved
450 verbose "Profiling argument is <$test_what>" 1
452 # These conditions depend on the argument so examine them before
453 # looking at the cache variable.
455 # Support for -p on solaris2 relies on mcrt1.o which comes with the
456 # vendor compiler. We cannot reliably predict the directory where the
457 # vendor compiler (and thus mcrt1.o) is installed so we can't
458 # necessarily find mcrt1.o even if we have it.
459 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
460 return 0
463 # Support for -p on irix relies on libprof1.a which doesn't appear to
464 # exist on any irix6 system currently posting testsuite results.
465 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
466 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
467 if { [istarget mips*-*-irix*]
468 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
469 return 0
472 # We don't yet support profiling for MIPS16.
473 if { [istarget mips*-*-*]
474 && ![check_effective_target_nomips16]
475 && ([lindex $test_what 1] == "-p"
476 || [lindex $test_what 1] == "-pg") } {
477 return 0
480 # MinGW does not support -p.
481 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
482 return 0
485 # cygwin does not support -p.
486 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
487 return 0
490 # uClibc does not have gcrt1.o.
491 if { [check_effective_target_uclibc]
492 && ([lindex $test_what 1] == "-p"
493 || [lindex $test_what 1] == "-pg") } {
494 return 0
497 # Now examine the cache variable.
498 if {![info exists profiling_available_saved]} {
499 # Some targets don't have any implementation of __bb_init_func or are
500 # missing other needed machinery.
501 if { [istarget mmix-*-*]
502 || [istarget arm*-*-eabi*]
503 || [istarget picochip-*-*]
504 || [istarget *-*-netware*]
505 || [istarget arm*-*-elf]
506 || [istarget arm*-*-symbianelf*]
507 || [istarget avr-*-*]
508 || [istarget bfin-*-*]
509 || [istarget powerpc-*-eabi*]
510 || [istarget powerpc-*-elf]
511 || [istarget cris-*-*]
512 || [istarget crisv32-*-*]
513 || [istarget fido-*-elf]
514 || [istarget h8300-*-*]
515 || [istarget lm32-*-*]
516 || [istarget m32c-*-elf]
517 || [istarget m68k-*-elf]
518 || [istarget m68k-*-uclinux*]
519 || [istarget mep-*-elf]
520 || [istarget mips*-*-elf*]
521 || [istarget moxie-*-elf*]
522 || [istarget rx-*-*]
523 || [istarget xstormy16-*]
524 || [istarget xtensa*-*-elf]
525 || [istarget *-*-rtems*]
526 || [istarget *-*-vxworks*] } {
527 set profiling_available_saved 0
528 } else {
529 set profiling_available_saved 1
533 return $profiling_available_saved
536 # Check to see if a target is "freestanding". This is as per the definition
537 # in Section 4 of C99 standard. Effectively, it is a target which supports no
538 # extra headers or libraries other than what is considered essential.
539 proc check_effective_target_freestanding { } {
540 if { [istarget picochip-*-*] } then {
541 return 1
542 } else {
543 return 0
547 # Return 1 if target has packed layout of structure members by
548 # default, 0 otherwise. Note that this is slightly different than
549 # whether the target has "natural alignment": both attributes may be
550 # false.
552 proc check_effective_target_default_packed { } {
553 return [check_no_compiler_messages default_packed assembly {
554 struct x { char a; long b; } c;
555 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
559 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
560 # documentation, where the test also comes from.
562 proc check_effective_target_pcc_bitfield_type_matters { } {
563 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
564 # bitfields, but let's stick to the example code from the docs.
565 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
566 struct foo1 { char x; char :0; char y; };
567 struct foo2 { char x; int :0; char y; };
568 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
572 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
574 proc add_options_for_tls { flags } {
575 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
576 # libthread, so always pass -pthread for native TLS.
577 # Need to duplicate native TLS check from
578 # check_effective_target_tls_native to avoid recursion.
579 if { [istarget *-*-solaris2.\[89\]*] &&
580 [check_no_messages_and_pattern tls_native "!emutls" assembly {
581 __thread int i;
582 int f (void) { return i; }
583 void g (int j) { i = j; }
584 }] } {
585 return "$flags -pthread"
587 return $flags
590 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
592 proc check_effective_target_tls {} {
593 return [check_no_compiler_messages tls assembly {
594 __thread int i;
595 int f (void) { return i; }
596 void g (int j) { i = j; }
600 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
602 proc check_effective_target_tls_native {} {
603 # VxWorks uses emulated TLS machinery, but with non-standard helper
604 # functions, so we fail to automatically detect it.
605 global target_triplet
606 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
607 return 0
610 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
611 __thread int i;
612 int f (void) { return i; }
613 void g (int j) { i = j; }
617 # Return 1 if TLS executables can run correctly, 0 otherwise.
619 proc check_effective_target_tls_runtime {} {
620 return [check_runtime tls_runtime {
621 __thread int thr = 0;
622 int main (void) { return thr; }
626 # Return 1 if compilation with -fgraphite is error-free for trivial
627 # code, 0 otherwise.
629 proc check_effective_target_fgraphite {} {
630 return [check_no_compiler_messages fgraphite object {
631 void foo (void) { }
632 } "-O1 -fgraphite"]
635 # Return 1 if compilation with -fopenmp is error-free for trivial
636 # code, 0 otherwise.
638 proc check_effective_target_fopenmp {} {
639 return [check_no_compiler_messages fopenmp object {
640 void foo (void) { }
641 } "-fopenmp"]
644 # Return 1 if compilation with -pthread is error-free for trivial
645 # code, 0 otherwise.
647 proc check_effective_target_pthread {} {
648 return [check_no_compiler_messages pthread object {
649 void foo (void) { }
650 } "-pthread"]
653 # Return 1 if compilation with -mpe-aligned-commons is error-free
654 # for trivial code, 0 otherwise.
656 proc check_effective_target_pe_aligned_commons {} {
657 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
658 return [check_no_compiler_messages pe_aligned_commons object {
659 int foo;
660 } "-mpe-aligned-commons"]
662 return 0
665 # Return 1 if the target supports -static
666 proc check_effective_target_static {} {
667 return [check_no_compiler_messages static executable {
668 int main (void) { return 0; }
669 } "-static"]
672 # Return 1 if the target supports -fstack-protector
673 proc check_effective_target_fstack_protector {} {
674 return [check_runtime fstack_protector {
675 int main (void) { return 0; }
676 } "-fstack-protector"]
679 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
680 # for trivial code, 0 otherwise.
682 proc check_effective_target_freorder {} {
683 return [check_no_compiler_messages freorder object {
684 void foo (void) { }
685 } "-freorder-blocks-and-partition"]
688 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
689 # emitted, 0 otherwise. Whether a shared library can actually be built is
690 # out of scope for this test.
692 proc check_effective_target_fpic { } {
693 # Note that M68K has a multilib that supports -fpic but not
694 # -fPIC, so we need to check both. We test with a program that
695 # requires GOT references.
696 foreach arg {fpic fPIC} {
697 if [check_no_compiler_messages $arg object {
698 extern int foo (void); extern int bar;
699 int baz (void) { return foo () + bar; }
700 } "-$arg"] {
701 return 1
704 return 0
707 # Return true if the target supports -mpaired-single (as used on MIPS).
709 proc check_effective_target_mpaired_single { } {
710 return [check_no_compiler_messages mpaired_single object {
711 void foo (void) { }
712 } "-mpaired-single"]
715 # Return true if the target has access to FPU instructions.
717 proc check_effective_target_hard_float { } {
718 if { [istarget mips*-*-*] } {
719 return [check_no_compiler_messages hard_float assembly {
720 #if (defined __mips_soft_float || defined __mips16)
721 #error FOO
722 #endif
726 # This proc is actually checking the availabilty of FPU
727 # support for doubles, so on the RX we must fail if the
728 # 64-bit double multilib has been selected.
729 if { [istarget rx-*-*] } {
730 return 0
731 # return [check_no_compiler_messages hard_float assembly {
732 #if defined __RX_64_BIT_DOUBLES__
733 #error FOO
734 #endif
735 # }]
738 # The generic test equates hard_float with "no call for adding doubles".
739 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
740 double a (double b, double c) { return b + c; }
744 # Return true if the target is a 64-bit MIPS target.
746 proc check_effective_target_mips64 { } {
747 return [check_no_compiler_messages mips64 assembly {
748 #ifndef __mips64
749 #error FOO
750 #endif
754 # Return true if the target is a MIPS target that does not produce
755 # MIPS16 code.
757 proc check_effective_target_nomips16 { } {
758 return [check_no_compiler_messages nomips16 object {
759 #ifndef __mips
760 #error FOO
761 #else
762 /* A cheap way of testing for -mflip-mips16. */
763 void foo (void) { asm ("addiu $20,$20,1"); }
764 void bar (void) { asm ("addiu $20,$20,1"); }
765 #endif
769 # Add the options needed for MIPS16 function attributes. At the moment,
770 # we don't support MIPS16 PIC.
772 proc add_options_for_mips16_attribute { flags } {
773 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
776 # Return true if we can force a mode that allows MIPS16 code generation.
777 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
778 # for o32 and o64.
780 proc check_effective_target_mips16_attribute { } {
781 return [check_no_compiler_messages mips16_attribute assembly {
782 #ifdef PIC
783 #error FOO
784 #endif
785 #if defined __mips_hard_float \
786 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
787 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
788 #error FOO
789 #endif
790 } [add_options_for_mips16_attribute ""]]
793 # Return 1 if the target supports long double larger than double when
794 # using the new ABI, 0 otherwise.
796 proc check_effective_target_mips_newabi_large_long_double { } {
797 return [check_no_compiler_messages mips_newabi_large_long_double object {
798 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
799 } "-mabi=64"]
802 # Return 1 if the current multilib does not generate PIC by default.
804 proc check_effective_target_nonpic { } {
805 return [check_no_compiler_messages nonpic assembly {
806 #if __PIC__
807 #error FOO
808 #endif
812 # Return 1 if the target does not use a status wrapper.
814 proc check_effective_target_unwrapped { } {
815 if { [target_info needs_status_wrapper] != "" \
816 && [target_info needs_status_wrapper] != "0" } {
817 return 0
819 return 1
822 # Return true if iconv is supported on the target. In particular IBM1047.
824 proc check_iconv_available { test_what } {
825 global libiconv
827 # If the tool configuration file has not set libiconv, try "-liconv"
828 if { ![info exists libiconv] } {
829 set libiconv "-liconv"
831 set test_what [lindex $test_what 1]
832 return [check_runtime_nocache $test_what [subst {
833 #include <iconv.h>
834 int main (void)
836 iconv_t cd;
838 cd = iconv_open ("$test_what", "UTF-8");
839 if (cd == (iconv_t) -1)
840 return 1;
841 return 0;
843 }] $libiconv]
846 # Return true if named sections are supported on this target.
848 proc check_named_sections_available { } {
849 return [check_no_compiler_messages named_sections assembly {
850 int __attribute__ ((section("whatever"))) foo;
854 # Return 1 if the target supports Fortran real kinds larger than real(8),
855 # 0 otherwise.
857 # When the target name changes, replace the cached result.
859 proc check_effective_target_fortran_large_real { } {
860 return [check_no_compiler_messages fortran_large_real executable {
861 ! Fortran
862 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
863 real(kind=k) :: x
864 x = cos (x)
869 # Return 1 if the target supports Fortran integer kinds larger than
870 # integer(8), 0 otherwise.
872 # When the target name changes, replace the cached result.
874 proc check_effective_target_fortran_large_int { } {
875 return [check_no_compiler_messages fortran_large_int executable {
876 ! Fortran
877 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
878 integer(kind=k) :: i
883 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
885 # When the target name changes, replace the cached result.
887 proc check_effective_target_fortran_integer_16 { } {
888 return [check_no_compiler_messages fortran_integer_16 executable {
889 ! Fortran
890 integer(16) :: i
895 # Return 1 if we can statically link libgfortran, 0 otherwise.
897 # When the target name changes, replace the cached result.
899 proc check_effective_target_static_libgfortran { } {
900 return [check_no_compiler_messages static_libgfortran executable {
901 ! Fortran
902 print *, 'test'
904 } "-static"]
907 proc check_linker_plugin_available { } {
908 return [check_no_compiler_messages_nocache linker_plugin executable {
909 int main() { return 0; }
910 } "-flto -fuse-linker-plugin"]
913 # Return 1 if the target supports executing 750CL paired-single instructions, 0
914 # otherwise. Cache the result.
916 proc check_750cl_hw_available { } {
917 return [check_cached_effective_target 750cl_hw_available {
918 # If this is not the right target then we can skip the test.
919 if { ![istarget powerpc-*paired*] } {
920 expr 0
921 } else {
922 check_runtime_nocache 750cl_hw_available {
923 int main()
925 #ifdef __MACH__
926 asm volatile ("ps_mul v0,v0,v0");
927 #else
928 asm volatile ("ps_mul 0,0,0");
929 #endif
930 return 0;
932 } "-mpaired"
937 # Return 1 if the target OS supports running SSE executables, 0
938 # otherwise. Cache the result.
940 proc check_sse_os_support_available { } {
941 return [check_cached_effective_target sse_os_support_available {
942 # If this is not the right target then we can skip the test.
943 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
944 expr 0
945 } elseif { [istarget i?86-*-solaris2*] } {
946 # The Solaris 2 kernel doesn't save and restore SSE registers
947 # before Solaris 9 4/04. Before that, executables die with SIGILL.
948 check_runtime_nocache sse_os_support_available {
949 int main ()
951 __asm__ volatile ("movss %xmm2,%xmm1");
952 return 0;
954 } "-msse"
955 } else {
956 expr 1
961 # Return 1 if the target supports executing SSE instructions, 0
962 # otherwise. Cache the result.
964 proc check_sse_hw_available { } {
965 return [check_cached_effective_target sse_hw_available {
966 # If this is not the right target then we can skip the test.
967 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
968 expr 0
969 } else {
970 check_runtime_nocache sse_hw_available {
971 #include "cpuid.h"
972 int main ()
974 unsigned int eax, ebx, ecx, edx;
975 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
976 return !(edx & bit_SSE);
977 return 1;
979 } ""
984 # Return 1 if the target supports executing SSE2 instructions, 0
985 # otherwise. Cache the result.
987 proc check_sse2_hw_available { } {
988 return [check_cached_effective_target sse2_hw_available {
989 # If this is not the right target then we can skip the test.
990 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
991 expr 0
992 } else {
993 check_runtime_nocache sse2_hw_available {
994 #include "cpuid.h"
995 int main ()
997 unsigned int eax, ebx, ecx, edx;
998 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
999 return !(edx & bit_SSE2);
1000 return 1;
1002 } ""
1007 # Return 1 if the target supports executing AVX instructions, 0
1008 # otherwise. Cache the result.
1010 proc check_avx_hw_available { } {
1011 return [check_cached_effective_target avx_hw_available {
1012 # If this is not the right target then we can skip the test.
1013 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1014 expr 0
1015 } else {
1016 check_runtime_nocache avx_hw_available {
1017 #include "cpuid.h"
1018 int main ()
1020 unsigned int eax, ebx, ecx, edx;
1021 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1022 return ((ecx & (bit_AVX | bit_OSXSAVE))
1023 != (bit_AVX | bit_OSXSAVE));
1024 return 1;
1026 } ""
1031 # Return 1 if the target supports running SSE executables, 0 otherwise.
1033 proc check_effective_target_sse_runtime { } {
1034 if { [check_effective_target_sse]
1035 && [check_sse_hw_available]
1036 && [check_sse_os_support_available] } {
1037 return 1
1039 return 0
1042 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1044 proc check_effective_target_sse2_runtime { } {
1045 if { [check_effective_target_sse2]
1046 && [check_sse2_hw_available]
1047 && [check_sse_os_support_available] } {
1048 return 1
1050 return 0
1053 # Return 1 if the target supports running AVX executables, 0 otherwise.
1055 proc check_effective_target_avx_runtime { } {
1056 if { [check_effective_target_avx]
1057 && [check_avx_hw_available] } {
1058 return 1
1060 return 0
1063 # Return 1 if the target supports executing VSX instructions, 0
1064 # otherwise. Cache the result.
1066 proc check_vsx_hw_available { } {
1067 return [check_cached_effective_target vsx_hw_available {
1068 # Some simulators are known to not support VSX instructions.
1069 # For now, disable on Darwin
1070 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1071 expr 0
1072 } else {
1073 set options "-mvsx"
1074 check_runtime_nocache vsx_hw_available {
1075 int main()
1077 #ifdef __MACH__
1078 asm volatile ("xxlor vs0,vs0,vs0");
1079 #else
1080 asm volatile ("xxlor 0,0,0");
1081 #endif
1082 return 0;
1084 } $options
1089 # Return 1 if the target supports executing AltiVec instructions, 0
1090 # otherwise. Cache the result.
1092 proc check_vmx_hw_available { } {
1093 return [check_cached_effective_target vmx_hw_available {
1094 # Some simulators are known to not support VMX instructions.
1095 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1096 expr 0
1097 } else {
1098 # Most targets don't require special flags for this test case, but
1099 # Darwin does. Just to be sure, make sure VSX is not enabled for
1100 # the altivec tests.
1101 if { [istarget *-*-darwin*]
1102 || [istarget *-*-aix*] } {
1103 set options "-maltivec -mno-vsx"
1104 } else {
1105 set options "-mno-vsx"
1107 check_runtime_nocache vmx_hw_available {
1108 int main()
1110 #ifdef __MACH__
1111 asm volatile ("vor v0,v0,v0");
1112 #else
1113 asm volatile ("vor 0,0,0");
1114 #endif
1115 return 0;
1117 } $options
1122 proc check_ppc_recip_hw_available { } {
1123 return [check_cached_effective_target ppc_recip_hw_available {
1124 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1125 # For now, disable on Darwin
1126 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1127 expr 0
1128 } else {
1129 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1130 check_runtime_nocache ppc_recip_hw_available {
1131 volatile double d_recip, d_rsqrt, d_four = 4.0;
1132 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1133 int main()
1135 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1136 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1137 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1138 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1139 return 0;
1141 } $options
1146 # Return 1 if the target supports executing AltiVec and Cell PPU
1147 # instructions, 0 otherwise. Cache the result.
1149 proc check_effective_target_cell_hw { } {
1150 return [check_cached_effective_target cell_hw_available {
1151 # Some simulators are known to not support VMX and PPU instructions.
1152 if { [istarget powerpc-*-eabi*] } {
1153 expr 0
1154 } else {
1155 # Most targets don't require special flags for this test
1156 # case, but Darwin and AIX do.
1157 if { [istarget *-*-darwin*]
1158 || [istarget *-*-aix*] } {
1159 set options "-maltivec -mcpu=cell"
1160 } else {
1161 set options "-mcpu=cell"
1163 check_runtime_nocache cell_hw_available {
1164 int main()
1166 #ifdef __MACH__
1167 asm volatile ("vor v0,v0,v0");
1168 asm volatile ("lvlx v0,r0,r0");
1169 #else
1170 asm volatile ("vor 0,0,0");
1171 asm volatile ("lvlx 0,0,0");
1172 #endif
1173 return 0;
1175 } $options
1180 # Return 1 if the target supports executing 64-bit instructions, 0
1181 # otherwise. Cache the result.
1183 proc check_effective_target_powerpc64 { } {
1184 global powerpc64_available_saved
1185 global tool
1187 if [info exists powerpc64_available_saved] {
1188 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1189 } else {
1190 set powerpc64_available_saved 0
1192 # Some simulators are known to not support powerpc64 instructions.
1193 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1194 verbose "check_effective_target_powerpc64 returning 0" 2
1195 return $powerpc64_available_saved
1198 # Set up, compile, and execute a test program containing a 64-bit
1199 # instruction. Include the current process ID in the file
1200 # names to prevent conflicts with invocations for multiple
1201 # testsuites.
1202 set src ppc[pid].c
1203 set exe ppc[pid].x
1205 set f [open $src "w"]
1206 puts $f "int main() {"
1207 puts $f "#ifdef __MACH__"
1208 puts $f " asm volatile (\"extsw r0,r0\");"
1209 puts $f "#else"
1210 puts $f " asm volatile (\"extsw 0,0\");"
1211 puts $f "#endif"
1212 puts $f " return 0; }"
1213 close $f
1215 set opts "additional_flags=-mcpu=G5"
1217 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1218 set lines [${tool}_target_compile $src $exe executable "$opts"]
1219 file delete $src
1221 if [string match "" $lines] then {
1222 # No error message, compilation succeeded.
1223 set result [${tool}_load "./$exe" "" ""]
1224 set status [lindex $result 0]
1225 remote_file build delete $exe
1226 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1228 if { $status == "pass" } then {
1229 set powerpc64_available_saved 1
1231 } else {
1232 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1236 return $powerpc64_available_saved
1239 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1240 # complex float arguments. This affects gfortran tests that call cabsf
1241 # in libm built by an earlier compiler. Return 1 if libm uses the same
1242 # argument passing as the compiler under test, 0 otherwise.
1244 # When the target name changes, replace the cached result.
1246 proc check_effective_target_broken_cplxf_arg { } {
1247 return [check_cached_effective_target broken_cplxf_arg {
1248 # Skip the work for targets known not to be affected.
1249 if { ![istarget powerpc64-*-linux*] } {
1250 expr 0
1251 } elseif { ![is-effective-target lp64] } {
1252 expr 0
1253 } else {
1254 check_runtime_nocache broken_cplxf_arg {
1255 #include <complex.h>
1256 extern void abort (void);
1257 float fabsf (float);
1258 float cabsf (_Complex float);
1259 int main ()
1261 _Complex float cf;
1262 float f;
1263 cf = 3 + 4.0fi;
1264 f = cabsf (cf);
1265 if (fabsf (f - 5.0) > 0.0001)
1266 abort ();
1267 return 0;
1269 } "-lm"
1274 proc check_alpha_max_hw_available { } {
1275 return [check_runtime alpha_max_hw_available {
1276 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1280 # Returns true iff the FUNCTION is available on the target system.
1281 # (This is essentially a Tcl implementation of Autoconf's
1282 # AC_CHECK_FUNC.)
1284 proc check_function_available { function } {
1285 return [check_no_compiler_messages ${function}_available \
1286 executable [subst {
1287 #ifdef __cplusplus
1288 extern "C"
1289 #endif
1290 char $function ();
1291 int main () { $function (); }
1295 # Returns true iff "fork" is available on the target system.
1297 proc check_fork_available {} {
1298 return [check_function_available "fork"]
1301 # Returns true iff "mkfifo" is available on the target system.
1303 proc check_mkfifo_available {} {
1304 if {[istarget *-*-cygwin*]} {
1305 # Cygwin has mkfifo, but support is incomplete.
1306 return 0
1309 return [check_function_available "mkfifo"]
1312 # Returns true iff "__cxa_atexit" is used on the target system.
1314 proc check_cxa_atexit_available { } {
1315 return [check_cached_effective_target cxa_atexit_available {
1316 if { [istarget "hppa*-*-hpux10*"] } {
1317 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1318 expr 0
1319 } elseif { [istarget "*-*-vxworks"] } {
1320 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1321 expr 0
1322 } else {
1323 check_runtime_nocache cxa_atexit_available {
1324 // C++
1325 #include <stdlib.h>
1326 static unsigned int count;
1327 struct X
1329 X() { count = 1; }
1330 ~X()
1332 if (count != 3)
1333 exit(1);
1334 count = 4;
1337 void f()
1339 static X x;
1341 struct Y
1343 Y() { f(); count = 2; }
1344 ~Y()
1346 if (count != 2)
1347 exit(1);
1348 count = 3;
1351 Y y;
1352 int main() { return 0; }
1358 proc check_effective_target_objc2 { } {
1359 return [check_no_compiler_messages objc2 object {
1360 #ifdef __OBJC2__
1361 int dummy[1];
1362 #else
1363 #error
1364 #endif
1368 proc check_effective_target_next_runtime { } {
1369 return [check_no_compiler_messages objc2 object {
1370 #ifdef __NEXT_RUNTIME__
1371 int dummy[1];
1372 #else
1373 #error
1374 #endif
1378 # Return 1 if we're generating 32-bit code using default options, 0
1379 # otherwise.
1381 proc check_effective_target_ilp32 { } {
1382 return [check_no_compiler_messages ilp32 object {
1383 int dummy[sizeof (int) == 4
1384 && sizeof (void *) == 4
1385 && sizeof (long) == 4 ? 1 : -1];
1389 # Return 1 if we're generating 32-bit or larger integers using default
1390 # options, 0 otherwise.
1392 proc check_effective_target_int32plus { } {
1393 return [check_no_compiler_messages int32plus object {
1394 int dummy[sizeof (int) >= 4 ? 1 : -1];
1398 # Return 1 if we're generating 32-bit or larger pointers using default
1399 # options, 0 otherwise.
1401 proc check_effective_target_ptr32plus { } {
1402 return [check_no_compiler_messages ptr32plus object {
1403 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1407 # Return 1 if we support 32-bit or larger array and structure sizes
1408 # using default options, 0 otherwise.
1410 proc check_effective_target_size32plus { } {
1411 return [check_no_compiler_messages size32plus object {
1412 char dummy[65537];
1416 # Returns 1 if we're generating 16-bit or smaller integers with the
1417 # default options, 0 otherwise.
1419 proc check_effective_target_int16 { } {
1420 return [check_no_compiler_messages int16 object {
1421 int dummy[sizeof (int) < 4 ? 1 : -1];
1425 # Return 1 if we're generating 64-bit code using default options, 0
1426 # otherwise.
1428 proc check_effective_target_lp64 { } {
1429 return [check_no_compiler_messages lp64 object {
1430 int dummy[sizeof (int) == 4
1431 && sizeof (void *) == 8
1432 && sizeof (long) == 8 ? 1 : -1];
1436 # Return 1 if we're generating 64-bit code using default llp64 options,
1437 # 0 otherwise.
1439 proc check_effective_target_llp64 { } {
1440 return [check_no_compiler_messages llp64 object {
1441 int dummy[sizeof (int) == 4
1442 && sizeof (void *) == 8
1443 && sizeof (long long) == 8
1444 && sizeof (long) == 4 ? 1 : -1];
1448 # Return 1 if the target supports long double larger than double,
1449 # 0 otherwise.
1451 proc check_effective_target_large_long_double { } {
1452 return [check_no_compiler_messages large_long_double object {
1453 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1457 # Return 1 if the target supports double larger than float,
1458 # 0 otherwise.
1460 proc check_effective_target_large_double { } {
1461 return [check_no_compiler_messages large_double object {
1462 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1466 # Return 1 if the target supports double of 64 bits,
1467 # 0 otherwise.
1469 proc check_effective_target_double64 { } {
1470 return [check_no_compiler_messages double64 object {
1471 int dummy[sizeof(double) == 8 ? 1 : -1];
1475 # Return 1 if the target supports double of at least 64 bits,
1476 # 0 otherwise.
1478 proc check_effective_target_double64plus { } {
1479 return [check_no_compiler_messages double64plus object {
1480 int dummy[sizeof(double) >= 8 ? 1 : -1];
1484 # Return 1 if the target supports compiling fixed-point,
1485 # 0 otherwise.
1487 proc check_effective_target_fixed_point { } {
1488 return [check_no_compiler_messages fixed_point object {
1489 _Sat _Fract x; _Sat _Accum y;
1493 # Return 1 if the target supports compiling decimal floating point,
1494 # 0 otherwise.
1496 proc check_effective_target_dfp_nocache { } {
1497 verbose "check_effective_target_dfp_nocache: compiling source" 2
1498 set ret [check_no_compiler_messages_nocache dfp object {
1499 float x __attribute__((mode(DD)));
1501 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1502 return $ret
1505 proc check_effective_target_dfprt_nocache { } {
1506 return [check_runtime_nocache dfprt {
1507 typedef float d64 __attribute__((mode(DD)));
1508 d64 x = 1.2df, y = 2.3dd, z;
1509 int main () { z = x + y; return 0; }
1513 # Return 1 if the target supports compiling Decimal Floating Point,
1514 # 0 otherwise.
1516 # This won't change for different subtargets so cache the result.
1518 proc check_effective_target_dfp { } {
1519 return [check_cached_effective_target dfp {
1520 check_effective_target_dfp_nocache
1524 # Return 1 if the target supports linking and executing Decimal Floating
1525 # Point, 0 otherwise.
1527 # This won't change for different subtargets so cache the result.
1529 proc check_effective_target_dfprt { } {
1530 return [check_cached_effective_target dfprt {
1531 check_effective_target_dfprt_nocache
1535 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1537 proc check_effective_target_ucn_nocache { } {
1538 # -std=c99 is only valid for C
1539 if [check_effective_target_c] {
1540 set ucnopts "-std=c99"
1542 append ucnopts " -fextended-identifiers"
1543 verbose "check_effective_target_ucn_nocache: compiling source" 2
1544 set ret [check_no_compiler_messages_nocache ucn object {
1545 int \u00C0;
1546 } $ucnopts]
1547 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1548 return $ret
1551 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1553 # This won't change for different subtargets, so cache the result.
1555 proc check_effective_target_ucn { } {
1556 return [check_cached_effective_target ucn {
1557 check_effective_target_ucn_nocache
1561 # Return 1 if the target needs a command line argument to enable a SIMD
1562 # instruction set.
1564 proc check_effective_target_vect_cmdline_needed { } {
1565 global et_vect_cmdline_needed_saved
1566 global et_vect_cmdline_needed_target_name
1568 if { ![info exists et_vect_cmdline_needed_target_name] } {
1569 set et_vect_cmdline_needed_target_name ""
1572 # If the target has changed since we set the cached value, clear it.
1573 set current_target [current_target_name]
1574 if { $current_target != $et_vect_cmdline_needed_target_name } {
1575 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1576 set et_vect_cmdline_needed_target_name $current_target
1577 if { [info exists et_vect_cmdline_needed_saved] } {
1578 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1579 unset et_vect_cmdline_needed_saved
1583 if [info exists et_vect_cmdline_needed_saved] {
1584 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1585 } else {
1586 set et_vect_cmdline_needed_saved 1
1587 if { [istarget alpha*-*-*]
1588 || [istarget ia64-*-*]
1589 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1590 && [check_effective_target_lp64])
1591 || ([istarget powerpc*-*-*]
1592 && ([check_effective_target_powerpc_spe]
1593 || [check_effective_target_powerpc_altivec]))
1594 || [istarget spu-*-*]
1595 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1596 set et_vect_cmdline_needed_saved 0
1600 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1601 return $et_vect_cmdline_needed_saved
1604 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1606 # This won't change for different subtargets so cache the result.
1608 proc check_effective_target_vect_int { } {
1609 global et_vect_int_saved
1611 if [info exists et_vect_int_saved] {
1612 verbose "check_effective_target_vect_int: using cached result" 2
1613 } else {
1614 set et_vect_int_saved 0
1615 if { [istarget i?86-*-*]
1616 || ([istarget powerpc*-*-*]
1617 && ![istarget powerpc-*-linux*paired*])
1618 || [istarget spu-*-*]
1619 || [istarget x86_64-*-*]
1620 || [istarget sparc*-*-*]
1621 || [istarget alpha*-*-*]
1622 || [istarget ia64-*-*]
1623 || [check_effective_target_arm32] } {
1624 set et_vect_int_saved 1
1628 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1629 return $et_vect_int_saved
1632 # Return 1 if the target supports signed int->float conversion
1635 proc check_effective_target_vect_intfloat_cvt { } {
1636 global et_vect_intfloat_cvt_saved
1638 if [info exists et_vect_intfloat_cvt_saved] {
1639 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1640 } else {
1641 set et_vect_intfloat_cvt_saved 0
1642 if { [istarget i?86-*-*]
1643 || ([istarget powerpc*-*-*]
1644 && ![istarget powerpc-*-linux*paired*])
1645 || [istarget x86_64-*-*] } {
1646 set et_vect_intfloat_cvt_saved 1
1650 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1651 return $et_vect_intfloat_cvt_saved
1654 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1656 proc check_effective_target_int128 { } {
1657 return [check_no_compiler_messages int128 object {
1658 int dummy[
1659 #ifndef __SIZEOF_INT128__
1661 #else
1663 #endif
1668 # Return 1 if the target supports unsigned int->float conversion
1671 proc check_effective_target_vect_uintfloat_cvt { } {
1672 global et_vect_uintfloat_cvt_saved
1674 if [info exists et_vect_uintfloat_cvt_saved] {
1675 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1676 } else {
1677 set et_vect_uintfloat_cvt_saved 0
1678 if { [istarget i?86-*-*]
1679 || ([istarget powerpc*-*-*]
1680 && ![istarget powerpc-*-linux*paired*])
1681 || [istarget x86_64-*-*] } {
1682 set et_vect_uintfloat_cvt_saved 1
1686 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1687 return $et_vect_uintfloat_cvt_saved
1691 # Return 1 if the target supports signed float->int conversion
1694 proc check_effective_target_vect_floatint_cvt { } {
1695 global et_vect_floatint_cvt_saved
1697 if [info exists et_vect_floatint_cvt_saved] {
1698 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1699 } else {
1700 set et_vect_floatint_cvt_saved 0
1701 if { [istarget i?86-*-*]
1702 || ([istarget powerpc*-*-*]
1703 && ![istarget powerpc-*-linux*paired*])
1704 || [istarget x86_64-*-*] } {
1705 set et_vect_floatint_cvt_saved 1
1709 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1710 return $et_vect_floatint_cvt_saved
1713 # Return 1 if the target supports unsigned float->int conversion
1716 proc check_effective_target_vect_floatuint_cvt { } {
1717 global et_vect_floatuint_cvt_saved
1719 if [info exists et_vect_floatuint_cvt_saved] {
1720 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1721 } else {
1722 set et_vect_floatuint_cvt_saved 0
1723 if { ([istarget powerpc*-*-*]
1724 && ![istarget powerpc-*-linux*paired*]) } {
1725 set et_vect_floatuint_cvt_saved 1
1729 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1730 return $et_vect_floatuint_cvt_saved
1733 # Return 1 is this is an arm target using 32-bit instructions
1734 proc check_effective_target_arm32 { } {
1735 return [check_no_compiler_messages arm32 assembly {
1736 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1737 #error FOO
1738 #endif
1742 # Return 1 if this is an ARM target supporting -mfpu=vfp
1743 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1744 # options.
1746 proc check_effective_target_arm_vfp_ok { } {
1747 if { [check_effective_target_arm32] } {
1748 return [check_no_compiler_messages arm_vfp_ok object {
1749 int dummy;
1750 } "-mfpu=vfp -mfloat-abi=softfp"]
1751 } else {
1752 return 0
1756 # Return 1 if this is an ARM target supporting -mfpu=vfp
1757 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1758 # options.
1760 proc check_effective_target_arm_hard_vfp_ok { } {
1761 if { [check_effective_target_arm32] } {
1762 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1763 int main() { return 0;}
1764 } "-mfpu=vfp -mfloat-abi=hard"]
1765 } else {
1766 return 0
1770 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1771 # or -mfloat-abi=hard, but if one is already specified by the
1772 # multilib, use it. Similarly, if a -mfpu option already enables
1773 # NEON, do not add -mfpu=neon.
1775 proc add_options_for_arm_neon { flags } {
1776 if { ! [check_effective_target_arm_neon_ok] } {
1777 return "$flags"
1779 global et_arm_neon_flags
1780 return "$flags $et_arm_neon_flags"
1783 # Return 1 if this is an ARM target supporting -mfpu=neon
1784 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1785 # incompatible with these options. Also set et_arm_neon_flags to the
1786 # best options to add.
1788 proc check_effective_target_arm_neon_ok_nocache { } {
1789 global et_arm_neon_flags
1790 set et_arm_neon_flags ""
1791 if { [check_effective_target_arm32] } {
1792 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1793 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1794 #include "arm_neon.h"
1795 int dummy;
1796 } "$flags"] } {
1797 set et_arm_neon_flags $flags
1798 return 1
1803 return 0
1806 proc check_effective_target_arm_neon_ok { } {
1807 return [check_cached_effective_target arm_neon_ok \
1808 check_effective_target_arm_neon_ok_nocache]
1811 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1812 # or -mfloat-abi=hard, but if one is already specified by the
1813 # multilib, use it.
1815 proc add_options_for_arm_neon_fp16 { flags } {
1816 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1817 return "$flags"
1819 global et_arm_neon_fp16_flags
1820 return "$flags $et_arm_neon_fp16_flags"
1823 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1824 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1825 # incompatible with these options. Also set et_arm_neon_flags to the
1826 # best options to add.
1828 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1829 global et_arm_neon_fp16_flags
1830 set et_arm_neon_fp16_flags ""
1831 if { [check_effective_target_arm32] } {
1832 # Always add -mfpu=neon-fp16, since there is no preprocessor
1833 # macro for FP16 support.
1834 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1835 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1836 #include "arm_neon.h"
1837 int dummy;
1838 } "$flags"] } {
1839 set et_arm_neon_fp16_flags $flags
1840 return 1
1845 return 0
1848 proc check_effective_target_arm_neon_fp16_ok { } {
1849 return [check_cached_effective_target arm_neon_fp16_ok \
1850 check_effective_target_arm_neon_fp16_ok_nocache]
1853 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1854 # used.
1856 proc check_effective_target_arm_thumb1_ok { } {
1857 return [check_no_compiler_messages arm_thumb1_ok assembly {
1858 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1859 #error FOO
1860 #endif
1861 } "-mthumb"]
1864 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1865 # used.
1867 proc check_effective_target_arm_thumb2_ok { } {
1868 return [check_no_compiler_messages arm_thumb2_ok assembly {
1869 #if !defined(__thumb2__)
1870 #error FOO
1871 #endif
1872 } "-mthumb"]
1875 # Return 1 if the target supports executing NEON instructions, 0
1876 # otherwise. Cache the result.
1878 proc check_effective_target_arm_neon_hw { } {
1879 return [check_runtime arm_neon_hw_available {
1881 main (void)
1883 long long a = 0, b = 1;
1884 asm ("vorr %P0, %P1, %P2"
1885 : "=w" (a)
1886 : "0" (a), "w" (b));
1887 return (a != 1);
1889 } [add_options_for_arm_neon ""]]
1892 # Return 1 if this is a ARM target with NEON enabled.
1894 proc check_effective_target_arm_neon { } {
1895 if { [check_effective_target_arm32] } {
1896 return [check_no_compiler_messages arm_neon object {
1897 #ifndef __ARM_NEON__
1898 #error not NEON
1899 #else
1900 int dummy;
1901 #endif
1903 } else {
1904 return 0
1908 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1909 # the Loongson vector modes.
1911 proc check_effective_target_mips_loongson { } {
1912 return [check_no_compiler_messages loongson assembly {
1913 #if !defined(__mips_loongson_vector_rev)
1914 #error FOO
1915 #endif
1919 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
1920 # Architecture.
1922 proc check_effective_target_arm_eabi { } {
1923 return [check_no_compiler_messages arm_eabi object {
1924 #ifndef __ARM_EABI__
1925 #error not EABI
1926 #else
1927 int dummy;
1928 #endif
1932 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
1933 # Some multilibs may be incompatible with this option.
1935 proc check_effective_target_arm_iwmmxt_ok { } {
1936 if { [check_effective_target_arm32] } {
1937 return [check_no_compiler_messages arm_iwmmxt_ok object {
1938 int dummy;
1939 } "-mcpu=iwmmxt"]
1940 } else {
1941 return 0
1945 # Return 1 if this is a PowerPC target with floating-point registers.
1947 proc check_effective_target_powerpc_fprs { } {
1948 if { [istarget powerpc*-*-*]
1949 || [istarget rs6000-*-*] } {
1950 return [check_no_compiler_messages powerpc_fprs object {
1951 #ifdef __NO_FPRS__
1952 #error no FPRs
1953 #else
1954 int dummy;
1955 #endif
1957 } else {
1958 return 0
1962 # Return 1 if this is a PowerPC target with hardware double-precision
1963 # floating point.
1965 proc check_effective_target_powerpc_hard_double { } {
1966 if { [istarget powerpc*-*-*]
1967 || [istarget rs6000-*-*] } {
1968 return [check_no_compiler_messages powerpc_hard_double object {
1969 #ifdef _SOFT_DOUBLE
1970 #error soft double
1971 #else
1972 int dummy;
1973 #endif
1975 } else {
1976 return 0
1980 # Return 1 if this is a PowerPC target supporting -maltivec.
1982 proc check_effective_target_powerpc_altivec_ok { } {
1983 if { ([istarget powerpc*-*-*]
1984 && ![istarget powerpc-*-linux*paired*])
1985 || [istarget rs6000-*-*] } {
1986 # AltiVec is not supported on AIX before 5.3.
1987 if { [istarget powerpc*-*-aix4*]
1988 || [istarget powerpc*-*-aix5.1*]
1989 || [istarget powerpc*-*-aix5.2*] } {
1990 return 0
1992 return [check_no_compiler_messages powerpc_altivec_ok object {
1993 int dummy;
1994 } "-maltivec"]
1995 } else {
1996 return 0
2000 # Return 1 if this is a PowerPC target supporting -mvsx
2002 proc check_effective_target_powerpc_vsx_ok { } {
2003 if { ([istarget powerpc*-*-*]
2004 && ![istarget powerpc-*-linux*paired*])
2005 || [istarget rs6000-*-*] } {
2006 # AltiVec is not supported on AIX before 5.3.
2007 if { [istarget powerpc*-*-aix4*]
2008 || [istarget powerpc*-*-aix5.1*]
2009 || [istarget powerpc*-*-aix5.2*] } {
2010 return 0
2012 return [check_no_compiler_messages powerpc_vsx_ok object {
2013 int main (void) {
2014 #ifdef __MACH__
2015 asm volatile ("xxlor vs0,vs0,vs0");
2016 #else
2017 asm volatile ("xxlor 0,0,0");
2018 #endif
2019 return 0;
2021 } "-mvsx"]
2022 } else {
2023 return 0
2027 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2029 proc check_effective_target_powerpc_ppu_ok { } {
2030 if [check_effective_target_powerpc_altivec_ok] {
2031 return [check_no_compiler_messages cell_asm_available object {
2032 int main (void) {
2033 #ifdef __MACH__
2034 asm volatile ("lvlx v0,v0,v0");
2035 #else
2036 asm volatile ("lvlx 0,0,0");
2037 #endif
2038 return 0;
2041 } else {
2042 return 0
2046 # Return 1 if this is a PowerPC target that supports SPU.
2048 proc check_effective_target_powerpc_spu { } {
2049 if [istarget powerpc*-*-linux*] {
2050 return [check_effective_target_powerpc_altivec_ok]
2051 } else {
2052 return 0
2056 # Return 1 if this is a PowerPC SPE target. The check includes options
2057 # specified by dg-options for this test, so don't cache the result.
2059 proc check_effective_target_powerpc_spe_nocache { } {
2060 if { [istarget powerpc*-*-*] } {
2061 return [check_no_compiler_messages_nocache powerpc_spe object {
2062 #ifndef __SPE__
2063 #error not SPE
2064 #else
2065 int dummy;
2066 #endif
2067 } [current_compiler_flags]]
2068 } else {
2069 return 0
2073 # Return 1 if this is a PowerPC target with SPE enabled.
2075 proc check_effective_target_powerpc_spe { } {
2076 if { [istarget powerpc*-*-*] } {
2077 return [check_no_compiler_messages powerpc_spe object {
2078 #ifndef __SPE__
2079 #error not SPE
2080 #else
2081 int dummy;
2082 #endif
2084 } else {
2085 return 0
2089 # Return 1 if this is a PowerPC target with Altivec enabled.
2091 proc check_effective_target_powerpc_altivec { } {
2092 if { [istarget powerpc*-*-*] } {
2093 return [check_no_compiler_messages powerpc_altivec object {
2094 #ifndef __ALTIVEC__
2095 #error not Altivec
2096 #else
2097 int dummy;
2098 #endif
2100 } else {
2101 return 0
2105 # Return 1 if this is a PowerPC 405 target. The check includes options
2106 # specified by dg-options for this test, so don't cache the result.
2108 proc check_effective_target_powerpc_405_nocache { } {
2109 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2110 return [check_no_compiler_messages_nocache powerpc_405 object {
2111 #ifdef __PPC405__
2112 int dummy;
2113 #else
2114 #error not a PPC405
2115 #endif
2116 } [current_compiler_flags]]
2117 } else {
2118 return 0
2122 # Return 1 if this is a SPU target with a toolchain that
2123 # supports automatic overlay generation.
2125 proc check_effective_target_spu_auto_overlay { } {
2126 if { [istarget spu*-*-elf*] } {
2127 return [check_no_compiler_messages spu_auto_overlay executable {
2128 int main (void) { }
2129 } "-Wl,--auto-overlay" ]
2130 } else {
2131 return 0
2135 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2136 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2137 # test environment appears to run executables on such a simulator.
2139 proc check_effective_target_ultrasparc_hw { } {
2140 return [check_runtime ultrasparc_hw {
2141 int main() { return 0; }
2142 } "-mcpu=ultrasparc"]
2145 # Return 1 if the target supports hardware vector shift operation.
2147 proc check_effective_target_vect_shift { } {
2148 global et_vect_shift_saved
2150 if [info exists et_vect_shift_saved] {
2151 verbose "check_effective_target_vect_shift: using cached result" 2
2152 } else {
2153 set et_vect_shift_saved 0
2154 if { ([istarget powerpc*-*-*]
2155 && ![istarget powerpc-*-linux*paired*])
2156 || [istarget ia64-*-*]
2157 || [istarget i?86-*-*]
2158 || [istarget x86_64-*-*]
2159 || [check_effective_target_arm32] } {
2160 set et_vect_shift_saved 1
2164 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2165 return $et_vect_shift_saved
2168 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2170 # This can change for different subtargets so do not cache the result.
2172 proc check_effective_target_vect_long { } {
2173 if { [istarget i?86-*-*]
2174 || (([istarget powerpc*-*-*]
2175 && ![istarget powerpc-*-linux*paired*])
2176 && [check_effective_target_ilp32])
2177 || [istarget x86_64-*-*]
2178 || [check_effective_target_arm32]
2179 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2180 set answer 1
2181 } else {
2182 set answer 0
2185 verbose "check_effective_target_vect_long: returning $answer" 2
2186 return $answer
2189 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2191 # This won't change for different subtargets so cache the result.
2193 proc check_effective_target_vect_float { } {
2194 global et_vect_float_saved
2196 if [info exists et_vect_float_saved] {
2197 verbose "check_effective_target_vect_float: using cached result" 2
2198 } else {
2199 set et_vect_float_saved 0
2200 if { [istarget i?86-*-*]
2201 || [istarget powerpc*-*-*]
2202 || [istarget spu-*-*]
2203 || [istarget mipsisa64*-*-*]
2204 || [istarget x86_64-*-*]
2205 || [istarget ia64-*-*]
2206 || [check_effective_target_arm32] } {
2207 set et_vect_float_saved 1
2211 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2212 return $et_vect_float_saved
2215 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2217 # This won't change for different subtargets so cache the result.
2219 proc check_effective_target_vect_double { } {
2220 global et_vect_double_saved
2222 if [info exists et_vect_double_saved] {
2223 verbose "check_effective_target_vect_double: using cached result" 2
2224 } else {
2225 set et_vect_double_saved 0
2226 if { [istarget i?86-*-*]
2227 || [istarget x86_64-*-*]
2228 || [istarget spu-*-*] } {
2229 set et_vect_double_saved 1
2233 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2234 return $et_vect_double_saved
2237 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2239 # This won't change for different subtargets so cache the result.
2241 proc check_effective_target_vect_long_long { } {
2242 global et_vect_long_long_saved
2244 if [info exists et_vect_long_long_saved] {
2245 verbose "check_effective_target_vect_long_long: using cached result" 2
2246 } else {
2247 set et_vect_long_long_saved 0
2248 if { [istarget i?86-*-*]
2249 || [istarget x86_64-*-*] } {
2250 set et_vect_long_long_saved 1
2254 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2255 return $et_vect_long_long_saved
2259 # Return 1 if the target plus current options does not support a vector
2260 # max instruction on "int", 0 otherwise.
2262 # This won't change for different subtargets so cache the result.
2264 proc check_effective_target_vect_no_int_max { } {
2265 global et_vect_no_int_max_saved
2267 if [info exists et_vect_no_int_max_saved] {
2268 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2269 } else {
2270 set et_vect_no_int_max_saved 0
2271 if { [istarget sparc*-*-*]
2272 || [istarget spu-*-*]
2273 || [istarget alpha*-*-*] } {
2274 set et_vect_no_int_max_saved 1
2277 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2278 return $et_vect_no_int_max_saved
2281 # Return 1 if the target plus current options does not support a vector
2282 # add instruction on "int", 0 otherwise.
2284 # This won't change for different subtargets so cache the result.
2286 proc check_effective_target_vect_no_int_add { } {
2287 global et_vect_no_int_add_saved
2289 if [info exists et_vect_no_int_add_saved] {
2290 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2291 } else {
2292 set et_vect_no_int_add_saved 0
2293 # Alpha only supports vector add on V8QI and V4HI.
2294 if { [istarget alpha*-*-*] } {
2295 set et_vect_no_int_add_saved 1
2298 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2299 return $et_vect_no_int_add_saved
2302 # Return 1 if the target plus current options does not support vector
2303 # bitwise instructions, 0 otherwise.
2305 # This won't change for different subtargets so cache the result.
2307 proc check_effective_target_vect_no_bitwise { } {
2308 global et_vect_no_bitwise_saved
2310 if [info exists et_vect_no_bitwise_saved] {
2311 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2312 } else {
2313 set et_vect_no_bitwise_saved 0
2315 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2316 return $et_vect_no_bitwise_saved
2319 # Return 1 if the target plus current options supports vector permutation,
2320 # 0 otherwise.
2322 # This won't change for different subtargets so cache the result.
2324 proc check_effective_target_vect_perm { } {
2325 global et_vect_perm
2327 if [info exists et_vect_perm_saved] {
2328 verbose "check_effective_target_vect_perm: using cached result" 2
2329 } else {
2330 set et_vect_perm_saved 0
2331 if { [istarget powerpc*-*-*]
2332 || [istarget spu-*-*] } {
2333 set et_vect_perm_saved 1
2336 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2337 return $et_vect_perm_saved
2340 # Return 1 if the target plus current options supports a vector
2341 # widening summation of *short* args into *int* result, 0 otherwise.
2343 # This won't change for different subtargets so cache the result.
2345 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2346 global et_vect_widen_sum_hi_to_si_pattern
2348 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2349 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2350 } else {
2351 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2352 if { [istarget powerpc*-*-*] } {
2353 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2356 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2357 return $et_vect_widen_sum_hi_to_si_pattern_saved
2360 # Return 1 if the target plus current options supports a vector
2361 # widening summation of *short* args into *int* result, 0 otherwise.
2362 # A target can also support this widening summation if it can support
2363 # promotion (unpacking) from shorts to ints.
2365 # This won't change for different subtargets so cache the result.
2367 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2368 global et_vect_widen_sum_hi_to_si
2370 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2371 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2372 } else {
2373 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2374 if { [istarget powerpc*-*-*]
2375 || [istarget ia64-*-*] } {
2376 set et_vect_widen_sum_hi_to_si_saved 1
2379 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2380 return $et_vect_widen_sum_hi_to_si_saved
2383 # Return 1 if the target plus current options supports a vector
2384 # widening summation of *char* args into *short* result, 0 otherwise.
2385 # A target can also support this widening summation if it can support
2386 # promotion (unpacking) from chars to shorts.
2388 # This won't change for different subtargets so cache the result.
2390 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2391 global et_vect_widen_sum_qi_to_hi
2393 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2394 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2395 } else {
2396 set et_vect_widen_sum_qi_to_hi_saved 0
2397 if { [check_effective_target_vect_unpack]
2398 || [istarget ia64-*-*] } {
2399 set et_vect_widen_sum_qi_to_hi_saved 1
2402 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2403 return $et_vect_widen_sum_qi_to_hi_saved
2406 # Return 1 if the target plus current options supports a vector
2407 # widening summation of *char* args into *int* result, 0 otherwise.
2409 # This won't change for different subtargets so cache the result.
2411 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2412 global et_vect_widen_sum_qi_to_si
2414 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2415 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2416 } else {
2417 set et_vect_widen_sum_qi_to_si_saved 0
2418 if { [istarget powerpc*-*-*] } {
2419 set et_vect_widen_sum_qi_to_si_saved 1
2422 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2423 return $et_vect_widen_sum_qi_to_si_saved
2426 # Return 1 if the target plus current options supports a vector
2427 # widening multiplication of *char* args into *short* result, 0 otherwise.
2428 # A target can also support this widening multplication if it can support
2429 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2430 # multiplication of shorts).
2432 # This won't change for different subtargets so cache the result.
2435 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2436 global et_vect_widen_mult_qi_to_hi
2438 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2439 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2440 } else {
2441 if { [check_effective_target_vect_unpack]
2442 && [check_effective_target_vect_short_mult] } {
2443 set et_vect_widen_mult_qi_to_hi_saved 1
2444 } else {
2445 set et_vect_widen_mult_qi_to_hi_saved 0
2447 if { [istarget powerpc*-*-*] } {
2448 set et_vect_widen_mult_qi_to_hi_saved 1
2451 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2452 return $et_vect_widen_mult_qi_to_hi_saved
2455 # Return 1 if the target plus current options supports a vector
2456 # widening multiplication of *short* args into *int* result, 0 otherwise.
2457 # A target can also support this widening multplication if it can support
2458 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2459 # multiplication of ints).
2461 # This won't change for different subtargets so cache the result.
2464 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2465 global et_vect_widen_mult_hi_to_si
2467 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2468 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2469 } else {
2470 if { [check_effective_target_vect_unpack]
2471 && [check_effective_target_vect_int_mult] } {
2472 set et_vect_widen_mult_hi_to_si_saved 1
2473 } else {
2474 set et_vect_widen_mult_hi_to_si_saved 0
2476 if { [istarget powerpc*-*-*]
2477 || [istarget spu-*-*]
2478 || [istarget i?86-*-*]
2479 || [istarget x86_64-*-*] } {
2480 set et_vect_widen_mult_hi_to_si_saved 1
2483 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2484 return $et_vect_widen_mult_hi_to_si_saved
2487 # Return 1 if the target plus current options supports a vector
2488 # dot-product of signed chars, 0 otherwise.
2490 # This won't change for different subtargets so cache the result.
2492 proc check_effective_target_vect_sdot_qi { } {
2493 global et_vect_sdot_qi
2495 if [info exists et_vect_sdot_qi_saved] {
2496 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2497 } else {
2498 set et_vect_sdot_qi_saved 0
2500 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2501 return $et_vect_sdot_qi_saved
2504 # Return 1 if the target plus current options supports a vector
2505 # dot-product of unsigned chars, 0 otherwise.
2507 # This won't change for different subtargets so cache the result.
2509 proc check_effective_target_vect_udot_qi { } {
2510 global et_vect_udot_qi
2512 if [info exists et_vect_udot_qi_saved] {
2513 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2514 } else {
2515 set et_vect_udot_qi_saved 0
2516 if { [istarget powerpc*-*-*] } {
2517 set et_vect_udot_qi_saved 1
2520 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2521 return $et_vect_udot_qi_saved
2524 # Return 1 if the target plus current options supports a vector
2525 # dot-product of signed shorts, 0 otherwise.
2527 # This won't change for different subtargets so cache the result.
2529 proc check_effective_target_vect_sdot_hi { } {
2530 global et_vect_sdot_hi
2532 if [info exists et_vect_sdot_hi_saved] {
2533 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2534 } else {
2535 set et_vect_sdot_hi_saved 0
2536 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2537 || [istarget i?86-*-*]
2538 || [istarget x86_64-*-*] } {
2539 set et_vect_sdot_hi_saved 1
2542 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2543 return $et_vect_sdot_hi_saved
2546 # Return 1 if the target plus current options supports a vector
2547 # dot-product of unsigned shorts, 0 otherwise.
2549 # This won't change for different subtargets so cache the result.
2551 proc check_effective_target_vect_udot_hi { } {
2552 global et_vect_udot_hi
2554 if [info exists et_vect_udot_hi_saved] {
2555 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2556 } else {
2557 set et_vect_udot_hi_saved 0
2558 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2559 set et_vect_udot_hi_saved 1
2562 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2563 return $et_vect_udot_hi_saved
2567 # Return 1 if the target plus current options supports a vector
2568 # demotion (packing) of shorts (to chars) and ints (to shorts)
2569 # using modulo arithmetic, 0 otherwise.
2571 # This won't change for different subtargets so cache the result.
2573 proc check_effective_target_vect_pack_trunc { } {
2574 global et_vect_pack_trunc
2576 if [info exists et_vect_pack_trunc_saved] {
2577 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2578 } else {
2579 set et_vect_pack_trunc_saved 0
2580 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2581 || [istarget i?86-*-*]
2582 || [istarget x86_64-*-*]
2583 || [istarget spu-*-*] } {
2584 set et_vect_pack_trunc_saved 1
2587 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2588 return $et_vect_pack_trunc_saved
2591 # Return 1 if the target plus current options supports a vector
2592 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2594 # This won't change for different subtargets so cache the result.
2596 proc check_effective_target_vect_unpack { } {
2597 global et_vect_unpack
2599 if [info exists et_vect_unpack_saved] {
2600 verbose "check_effective_target_vect_unpack: using cached result" 2
2601 } else {
2602 set et_vect_unpack_saved 0
2603 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2604 || [istarget i?86-*-*]
2605 || [istarget x86_64-*-*]
2606 || [istarget spu-*-*] } {
2607 set et_vect_unpack_saved 1
2610 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2611 return $et_vect_unpack_saved
2614 # Return 1 if the target plus current options does not guarantee
2615 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2617 # This won't change for different subtargets so cache the result.
2619 proc check_effective_target_unaligned_stack { } {
2620 global et_unaligned_stack_saved
2622 if [info exists et_unaligned_stack_saved] {
2623 verbose "check_effective_target_unaligned_stack: using cached result" 2
2624 } else {
2625 set et_unaligned_stack_saved 0
2627 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2628 return $et_unaligned_stack_saved
2631 # Return 1 if the target plus current options does not support a vector
2632 # alignment mechanism, 0 otherwise.
2634 # This won't change for different subtargets so cache the result.
2636 proc check_effective_target_vect_no_align { } {
2637 global et_vect_no_align_saved
2639 if [info exists et_vect_no_align_saved] {
2640 verbose "check_effective_target_vect_no_align: using cached result" 2
2641 } else {
2642 set et_vect_no_align_saved 0
2643 if { [istarget mipsisa64*-*-*]
2644 || [istarget sparc*-*-*]
2645 || [istarget ia64-*-*]
2646 || [check_effective_target_arm32] } {
2647 set et_vect_no_align_saved 1
2650 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2651 return $et_vect_no_align_saved
2654 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2656 # This won't change for different subtargets so cache the result.
2658 proc check_effective_target_vect_hw_misalign { } {
2659 global et_vect_hw_misalign_saved
2661 if [info exists et_vect_hw_misalign_saved] {
2662 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2663 } else {
2664 set et_vect_hw_misalign_saved 0
2665 if { ([istarget x86_64-*-*]
2666 || [istarget i?86-*-*]) } {
2667 set et_vect_hw_misalign_saved 1
2670 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2671 return $et_vect_hw_misalign_saved
2675 # Return 1 if arrays are aligned to the vector alignment
2676 # boundary, 0 otherwise.
2678 # This won't change for different subtargets so cache the result.
2680 proc check_effective_target_vect_aligned_arrays { } {
2681 global et_vect_aligned_arrays
2683 if [info exists et_vect_aligned_arrays_saved] {
2684 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2685 } else {
2686 set et_vect_aligned_arrays_saved 0
2687 if { (([istarget x86_64-*-*]
2688 || [istarget i?86-*-*]) && [is-effective-target lp64])
2689 || [istarget spu-*-*] } {
2690 set et_vect_aligned_arrays_saved 1
2693 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2694 return $et_vect_aligned_arrays_saved
2697 # Return 1 if types of size 32 bit or less are naturally aligned
2698 # (aligned to their type-size), 0 otherwise.
2700 # This won't change for different subtargets so cache the result.
2702 proc check_effective_target_natural_alignment_32 { } {
2703 global et_natural_alignment_32
2705 if [info exists et_natural_alignment_32_saved] {
2706 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2707 } else {
2708 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2709 set et_natural_alignment_32_saved 1
2710 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2711 set et_natural_alignment_32_saved 0
2714 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2715 return $et_natural_alignment_32_saved
2718 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2719 # type-size), 0 otherwise.
2721 # This won't change for different subtargets so cache the result.
2723 proc check_effective_target_natural_alignment_64 { } {
2724 global et_natural_alignment_64
2726 if [info exists et_natural_alignment_64_saved] {
2727 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2728 } else {
2729 set et_natural_alignment_64_saved 0
2730 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2731 || [istarget spu-*-*] } {
2732 set et_natural_alignment_64_saved 1
2735 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2736 return $et_natural_alignment_64_saved
2739 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2741 # This won't change for different subtargets so cache the result.
2743 proc check_effective_target_vector_alignment_reachable { } {
2744 global et_vector_alignment_reachable
2746 if [info exists et_vector_alignment_reachable_saved] {
2747 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2748 } else {
2749 if { [check_effective_target_vect_aligned_arrays]
2750 || [check_effective_target_natural_alignment_32] } {
2751 set et_vector_alignment_reachable_saved 1
2752 } else {
2753 set et_vector_alignment_reachable_saved 0
2756 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2757 return $et_vector_alignment_reachable_saved
2760 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2762 # This won't change for different subtargets so cache the result.
2764 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2765 global et_vector_alignment_reachable_for_64bit
2767 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2768 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2769 } else {
2770 if { [check_effective_target_vect_aligned_arrays]
2771 || [check_effective_target_natural_alignment_64] } {
2772 set et_vector_alignment_reachable_for_64bit_saved 1
2773 } else {
2774 set et_vector_alignment_reachable_for_64bit_saved 0
2777 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2778 return $et_vector_alignment_reachable_for_64bit_saved
2781 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2783 proc check_effective_target_vect_condition { } {
2784 global et_vect_cond_saved
2786 if [info exists et_vect_cond_saved] {
2787 verbose "check_effective_target_vect_cond: using cached result" 2
2788 } else {
2789 set et_vect_cond_saved 0
2790 if { [istarget powerpc*-*-*]
2791 || [istarget ia64-*-*]
2792 || [istarget i?86-*-*]
2793 || [istarget spu-*-*]
2794 || [istarget x86_64-*-*] } {
2795 set et_vect_cond_saved 1
2799 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2800 return $et_vect_cond_saved
2803 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2805 proc check_effective_target_vect_char_mult { } {
2806 global et_vect_char_mult_saved
2808 if [info exists et_vect_char_mult_saved] {
2809 verbose "check_effective_target_vect_char_mult: using cached result" 2
2810 } else {
2811 set et_vect_char_mult_saved 0
2812 if { [istarget ia64-*-*]
2813 || [istarget i?86-*-*]
2814 || [istarget x86_64-*-*] } {
2815 set et_vect_char_mult_saved 1
2819 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2820 return $et_vect_char_mult_saved
2823 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2825 proc check_effective_target_vect_short_mult { } {
2826 global et_vect_short_mult_saved
2828 if [info exists et_vect_short_mult_saved] {
2829 verbose "check_effective_target_vect_short_mult: using cached result" 2
2830 } else {
2831 set et_vect_short_mult_saved 0
2832 if { [istarget ia64-*-*]
2833 || [istarget spu-*-*]
2834 || [istarget i?86-*-*]
2835 || [istarget x86_64-*-*]
2836 || [istarget powerpc*-*-*]
2837 || [check_effective_target_arm32] } {
2838 set et_vect_short_mult_saved 1
2842 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2843 return $et_vect_short_mult_saved
2846 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2848 proc check_effective_target_vect_int_mult { } {
2849 global et_vect_int_mult_saved
2851 if [info exists et_vect_int_mult_saved] {
2852 verbose "check_effective_target_vect_int_mult: using cached result" 2
2853 } else {
2854 set et_vect_int_mult_saved 0
2855 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2856 || [istarget spu-*-*]
2857 || [istarget i?86-*-*]
2858 || [istarget x86_64-*-*]
2859 || [check_effective_target_arm32] } {
2860 set et_vect_int_mult_saved 1
2864 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2865 return $et_vect_int_mult_saved
2868 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2870 proc check_effective_target_vect_extract_even_odd { } {
2871 global et_vect_extract_even_odd_saved
2873 if [info exists et_vect_extract_even_odd_saved] {
2874 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2875 } else {
2876 set et_vect_extract_even_odd_saved 0
2877 if { [istarget powerpc*-*-*]
2878 || [istarget i?86-*-*]
2879 || [istarget x86_64-*-*]
2880 || [istarget spu-*-*] } {
2881 set et_vect_extract_even_odd_saved 1
2885 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2886 return $et_vect_extract_even_odd_saved
2889 # Return 1 if the target supports vector even/odd elements extraction of
2890 # vectors with SImode elements or larger, 0 otherwise.
2892 proc check_effective_target_vect_extract_even_odd_wide { } {
2893 global et_vect_extract_even_odd_wide_saved
2895 if [info exists et_vect_extract_even_odd_wide_saved] {
2896 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2897 } else {
2898 set et_vect_extract_even_odd_wide_saved 0
2899 if { [istarget powerpc*-*-*]
2900 || [istarget i?86-*-*]
2901 || [istarget x86_64-*-*]
2902 || [istarget spu-*-*] } {
2903 set et_vect_extract_even_odd_wide_saved 1
2907 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2908 return $et_vect_extract_even_odd_wide_saved
2911 # Return 1 if the target supports vector interleaving, 0 otherwise.
2913 proc check_effective_target_vect_interleave { } {
2914 global et_vect_interleave_saved
2916 if [info exists et_vect_interleave_saved] {
2917 verbose "check_effective_target_vect_interleave: using cached result" 2
2918 } else {
2919 set et_vect_interleave_saved 0
2920 if { [istarget powerpc*-*-*]
2921 || [istarget i?86-*-*]
2922 || [istarget x86_64-*-*]
2923 || [istarget spu-*-*] } {
2924 set et_vect_interleave_saved 1
2928 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2929 return $et_vect_interleave_saved
2932 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2933 proc check_effective_target_vect_strided { } {
2934 global et_vect_strided_saved
2936 if [info exists et_vect_strided_saved] {
2937 verbose "check_effective_target_vect_strided: using cached result" 2
2938 } else {
2939 set et_vect_strided_saved 0
2940 if { [check_effective_target_vect_interleave]
2941 && [check_effective_target_vect_extract_even_odd] } {
2942 set et_vect_strided_saved 1
2946 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2947 return $et_vect_strided_saved
2950 # Return 1 if the target supports vector interleaving and extract even/odd
2951 # for wide element types, 0 otherwise.
2952 proc check_effective_target_vect_strided_wide { } {
2953 global et_vect_strided_wide_saved
2955 if [info exists et_vect_strided_wide_saved] {
2956 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2957 } else {
2958 set et_vect_strided_wide_saved 0
2959 if { [check_effective_target_vect_interleave]
2960 && [check_effective_target_vect_extract_even_odd_wide] } {
2961 set et_vect_strided_wide_saved 1
2965 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2966 return $et_vect_strided_wide_saved
2969 # Return 1 if the target supports section-anchors
2971 proc check_effective_target_section_anchors { } {
2972 global et_section_anchors_saved
2974 if [info exists et_section_anchors_saved] {
2975 verbose "check_effective_target_section_anchors: using cached result" 2
2976 } else {
2977 set et_section_anchors_saved 0
2978 if { [istarget powerpc*-*-*]
2979 || [istarget arm*-*-*] } {
2980 set et_section_anchors_saved 1
2984 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2985 return $et_section_anchors_saved
2988 # Return 1 if the target supports atomic operations on "int" and "long".
2990 proc check_effective_target_sync_int_long { } {
2991 global et_sync_int_long_saved
2993 if [info exists et_sync_int_long_saved] {
2994 verbose "check_effective_target_sync_int_long: using cached result" 2
2995 } else {
2996 set et_sync_int_long_saved 0
2997 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2998 # load-reserved/store-conditional instructions.
2999 if { [istarget ia64-*-*]
3000 || [istarget i?86-*-*]
3001 || [istarget x86_64-*-*]
3002 || [istarget alpha*-*-*]
3003 || [istarget bfin*-*linux*]
3004 || [istarget s390*-*-*]
3005 || [istarget powerpc*-*-*]
3006 || [istarget sparc64-*-*]
3007 || [istarget sparcv9-*-*]
3008 || [istarget mips*-*-*] } {
3009 set et_sync_int_long_saved 1
3013 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3014 return $et_sync_int_long_saved
3017 # Return 1 if the target supports atomic operations on "char" and "short".
3019 proc check_effective_target_sync_char_short { } {
3020 global et_sync_char_short_saved
3022 if [info exists et_sync_char_short_saved] {
3023 verbose "check_effective_target_sync_char_short: using cached result" 2
3024 } else {
3025 set et_sync_char_short_saved 0
3026 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3027 # load-reserved/store-conditional instructions.
3028 if { [istarget ia64-*-*]
3029 || [istarget i?86-*-*]
3030 || [istarget x86_64-*-*]
3031 || [istarget alpha*-*-*]
3032 || [istarget s390*-*-*]
3033 || [istarget powerpc*-*-*]
3034 || [istarget sparc64-*-*]
3035 || [istarget sparcv9-*-*]
3036 || [istarget mips*-*-*] } {
3037 set et_sync_char_short_saved 1
3041 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3042 return $et_sync_char_short_saved
3045 # Return 1 if the target uses a ColdFire FPU.
3047 proc check_effective_target_coldfire_fpu { } {
3048 return [check_no_compiler_messages coldfire_fpu assembly {
3049 #ifndef __mcffpu__
3050 #error FOO
3051 #endif
3055 # Return true if this is a uClibc target.
3057 proc check_effective_target_uclibc {} {
3058 return [check_no_compiler_messages uclibc object {
3059 #include <features.h>
3060 #if !defined (__UCLIBC__)
3061 #error FOO
3062 #endif
3066 # Return true if this is a uclibc target and if the uclibc feature
3067 # described by __$feature__ is not present.
3069 proc check_missing_uclibc_feature {feature} {
3070 return [check_no_compiler_messages $feature object "
3071 #include <features.h>
3072 #if !defined (__UCLIBC) || defined (__${feature}__)
3073 #error FOO
3074 #endif
3078 # Return true if this is a Newlib target.
3080 proc check_effective_target_newlib {} {
3081 return [check_no_compiler_messages newlib object {
3082 #include <newlib.h>
3086 # Return 1 if
3087 # (a) an error of a few ULP is expected in string to floating-point
3088 # conversion functions; and
3089 # (b) overflow is not always detected correctly by those functions.
3091 proc check_effective_target_lax_strtofp {} {
3092 # By default, assume that all uClibc targets suffer from this.
3093 return [check_effective_target_uclibc]
3096 # Return 1 if this is a target for which wcsftime is a dummy
3097 # function that always returns 0.
3099 proc check_effective_target_dummy_wcsftime {} {
3100 # By default, assume that all uClibc targets suffer from this.
3101 return [check_effective_target_uclibc]
3104 # Return 1 if constructors with initialization priority arguments are
3105 # supposed on this target.
3107 proc check_effective_target_init_priority {} {
3108 return [check_no_compiler_messages init_priority assembly "
3109 void f() __attribute__((constructor (1000)));
3110 void f() \{\}
3114 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3115 # This can be used with any check_* proc that takes no argument and
3116 # returns only 1 or 0. It could be used with check_* procs that take
3117 # arguments with keywords that pass particular arguments.
3119 proc is-effective-target { arg } {
3120 set selected 0
3121 if { [info procs check_effective_target_${arg}] != [list] } {
3122 set selected [check_effective_target_${arg}]
3123 } else {
3124 switch $arg {
3125 "vmx_hw" { set selected [check_vmx_hw_available] }
3126 "vsx_hw" { set selected [check_vsx_hw_available] }
3127 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3128 "named_sections" { set selected [check_named_sections_available] }
3129 "gc_sections" { set selected [check_gc_sections_available] }
3130 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3131 default { error "unknown effective target keyword `$arg'" }
3134 verbose "is-effective-target: $arg $selected" 2
3135 return $selected
3138 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3140 proc is-effective-target-keyword { arg } {
3141 if { [info procs check_effective_target_${arg}] != [list] } {
3142 return 1
3143 } else {
3144 # These have different names for their check_* procs.
3145 switch $arg {
3146 "vmx_hw" { return 1 }
3147 "vsx_hw" { return 1 }
3148 "ppc_recip_hw" { return 1 }
3149 "named_sections" { return 1 }
3150 "gc_sections" { return 1 }
3151 "cxa_atexit" { return 1 }
3152 default { return 0 }
3157 # Return 1 if target default to short enums
3159 proc check_effective_target_short_enums { } {
3160 return [check_no_compiler_messages short_enums assembly {
3161 enum foo { bar };
3162 int s[sizeof (enum foo) == 1 ? 1 : -1];
3166 # Return 1 if target supports merging string constants at link time.
3168 proc check_effective_target_string_merging { } {
3169 return [check_no_messages_and_pattern string_merging \
3170 "rodata\\.str" assembly {
3171 const char *var = "String";
3172 } {-O2}]
3175 # Return 1 if target has the basic signed and unsigned types in
3176 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3177 # working <stdint.h> for all targets.
3179 proc check_effective_target_stdint_types { } {
3180 return [check_no_compiler_messages stdint_types assembly {
3181 #include <stdint.h>
3182 int8_t a; int16_t b; int32_t c; int64_t d;
3183 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3187 # Return 1 if target has the basic signed and unsigned types in
3188 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3189 # these types agree with those in the header, as some systems have
3190 # only <inttypes.h>.
3192 proc check_effective_target_inttypes_types { } {
3193 return [check_no_compiler_messages inttypes_types assembly {
3194 #include <inttypes.h>
3195 int8_t a; int16_t b; int32_t c; int64_t d;
3196 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3200 # Return 1 if programs are intended to be run on a simulator
3201 # (i.e. slowly) rather than hardware (i.e. fast).
3203 proc check_effective_target_simulator { } {
3205 # All "src/sim" simulators set this one.
3206 if [board_info target exists is_simulator] {
3207 return [board_info target is_simulator]
3210 # The "sid" simulators don't set that one, but at least they set
3211 # this one.
3212 if [board_info target exists slow_simulator] {
3213 return [board_info target slow_simulator]
3216 return 0
3219 # Return 1 if the target is a VxWorks kernel.
3221 proc check_effective_target_vxworks_kernel { } {
3222 return [check_no_compiler_messages vxworks_kernel assembly {
3223 #if !defined __vxworks || defined __RTP__
3224 #error NO
3225 #endif
3229 # Return 1 if the target is a VxWorks RTP.
3231 proc check_effective_target_vxworks_rtp { } {
3232 return [check_no_compiler_messages vxworks_rtp assembly {
3233 #if !defined __vxworks || !defined __RTP__
3234 #error NO
3235 #endif
3239 # Return 1 if the target is expected to provide wide character support.
3241 proc check_effective_target_wchar { } {
3242 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3243 return 0
3245 return [check_no_compiler_messages wchar assembly {
3246 #include <wchar.h>
3250 # Return 1 if the target has <pthread.h>.
3252 proc check_effective_target_pthread_h { } {
3253 return [check_no_compiler_messages pthread_h assembly {
3254 #include <pthread.h>
3258 # Return 1 if the target can truncate a file from a file-descriptor,
3259 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3260 # chsize. We test for a trivially functional truncation; no stubs.
3261 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3262 # different function to be used.
3264 proc check_effective_target_fd_truncate { } {
3265 set prog {
3266 #define _FILE_OFFSET_BITS 64
3267 #include <unistd.h>
3268 #include <stdio.h>
3269 #include <stdlib.h>
3270 int main ()
3272 FILE *f = fopen ("tst.tmp", "wb");
3273 int fd;
3274 const char t[] = "test writing more than ten characters";
3275 char s[11];
3276 fd = fileno (f);
3277 write (fd, t, sizeof (t) - 1);
3278 lseek (fd, 0, 0);
3279 if (ftruncate (fd, 10) != 0)
3280 exit (1);
3281 close (fd);
3282 f = fopen ("tst.tmp", "rb");
3283 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3284 exit (1);
3285 exit (0);
3289 if { [check_runtime ftruncate $prog] } {
3290 return 1;
3293 regsub "ftruncate" $prog "chsize" prog
3294 return [check_runtime chsize $prog]
3297 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3299 proc add_options_for_c99_runtime { flags } {
3300 if { [istarget *-*-solaris2*] } {
3301 return "$flags -std=c99"
3303 if { [istarget powerpc-*-darwin*] } {
3304 return "$flags -mmacosx-version-min=10.3"
3306 return $flags
3309 # Add to FLAGS all the target-specific flags needed to enable
3310 # full IEEE compliance mode.
3312 proc add_options_for_ieee { flags } {
3313 if { [istarget "alpha*-*-*"]
3314 || [istarget "sh*-*-*"] } {
3315 return "$flags -mieee"
3317 return $flags
3320 # Add to FLAGS the flags needed to enable functions to bind locally
3321 # when using pic/PIC passes in the testsuite.
3323 proc add_options_for_bind_pic_locally { flags } {
3324 if {[check_no_compiler_messages using_pic2 assembly {
3325 #if __PIC__ != 2
3326 #error FOO
3327 #endif
3328 }]} {
3329 return "$flags -fPIE"
3331 if {[check_no_compiler_messages using_pic1 assembly {
3332 #if __PIC__ != 1
3333 #error FOO
3334 #endif
3335 }]} {
3336 return "$flags -fpie"
3339 return $flags
3342 # Return 1 if the target provides a full C99 runtime.
3344 proc check_effective_target_c99_runtime { } {
3345 return [check_cached_effective_target c99_runtime {
3346 global srcdir
3348 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3349 set contents [read $file]
3350 close $file
3351 append contents {
3352 #ifndef HAVE_C99_RUNTIME
3353 #error FOO
3354 #endif
3356 check_no_compiler_messages_nocache c99_runtime assembly \
3357 $contents [add_options_for_c99_runtime ""]
3361 # Return 1 if target wchar_t is at least 4 bytes.
3363 proc check_effective_target_4byte_wchar_t { } {
3364 return [check_no_compiler_messages 4byte_wchar_t object {
3365 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3369 # Return 1 if the target supports automatic stack alignment.
3371 proc check_effective_target_automatic_stack_alignment { } {
3372 if { [istarget i?86*-*-*]
3373 || [istarget x86_64-*-*] } then {
3374 return 1
3375 } else {
3376 return 0
3380 # Return 1 if avx instructions can be compiled.
3382 proc check_effective_target_avx { } {
3383 return [check_no_compiler_messages avx object {
3384 void _mm256_zeroall (void)
3386 __builtin_ia32_vzeroall ();
3388 } "-O2 -mavx" ]
3391 # Return 1 if sse instructions can be compiled.
3392 proc check_effective_target_sse { } {
3393 return [check_no_compiler_messages sse object {
3394 int main ()
3396 __builtin_ia32_stmxcsr ();
3397 return 0;
3399 } "-O2 -msse" ]
3402 # Return 1 if sse2 instructions can be compiled.
3403 proc check_effective_target_sse2 { } {
3404 return [check_no_compiler_messages sse2 object {
3405 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3407 __m128i _mm_srli_si128 (__m128i __A, int __N)
3409 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3411 } "-O2 -msse2" ]
3414 # Return 1 if F16C instructions can be compiled.
3416 proc check_effective_target_f16c { } {
3417 return [check_no_compiler_messages f16c object {
3418 #include "immintrin.h"
3419 float
3420 foo (unsigned short val)
3422 return _cvtsh_ss (val);
3424 } "-O2 -mf16c" ]
3427 # Return 1 if C wchar_t type is compatible with char16_t.
3429 proc check_effective_target_wchar_t_char16_t_compatible { } {
3430 return [check_no_compiler_messages wchar_t_char16_t object {
3431 __WCHAR_TYPE__ wc;
3432 __CHAR16_TYPE__ *p16 = &wc;
3433 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3437 # Return 1 if C wchar_t type is compatible with char32_t.
3439 proc check_effective_target_wchar_t_char32_t_compatible { } {
3440 return [check_no_compiler_messages wchar_t_char32_t object {
3441 __WCHAR_TYPE__ wc;
3442 __CHAR32_TYPE__ *p32 = &wc;
3443 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3447 # Return 1 if pow10 function exists.
3449 proc check_effective_target_pow10 { } {
3450 return [check_runtime pow10 {
3451 #include <math.h>
3452 int main () {
3453 double x;
3454 x = pow10 (1);
3455 return 0;
3457 } "-lm" ]
3460 # Return 1 if current options generate DFP instructions, 0 otherwise.
3462 proc check_effective_target_hard_dfp {} {
3463 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3464 typedef float d64 __attribute__((mode(DD)));
3465 d64 x, y, z;
3466 void foo (void) { z = x + y; }
3470 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3471 # for strchr etc. functions.
3473 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3474 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3475 #include <string.h>
3476 #include <wchar.h>
3477 #if !defined(__cplusplus) \
3478 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3479 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3480 ISO C++ correct string.h and wchar.h protos not supported.
3481 #else
3482 int i;
3483 #endif
3487 # Return 1 if GNU as is used.
3489 proc check_effective_target_gas { } {
3490 global use_gas_saved
3491 global tool
3493 if {![info exists use_gas_saved]} {
3494 # Check if the as used by gcc is GNU as.
3495 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3496 # Provide /dev/null as input, otherwise gas times out reading from
3497 # stdin.
3498 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3499 set as_output [lindex $status 1]
3500 if { [ string first "GNU" $as_output ] >= 0 } {
3501 set use_gas_saved 1
3502 } else {
3503 set use_gas_saved 0
3506 return $use_gas_saved
3509 # Return 1 if the compiler has been configure with link-time optimization
3510 # (LTO) support.
3512 proc check_effective_target_lto { } {
3513 global ENABLE_LTO
3514 return [info exists ENABLE_LTO]
3517 # Return 1 if the language for the compiler under test is C.
3519 proc check_effective_target_c { } {
3520 global tool
3521 if [string match $tool "gcc"] {
3522 return 1
3524 return 0
3527 # Return 1 if the language for the compiler under test is C++.
3529 proc check_effective_target_c++ { } {
3530 global tool
3531 if [string match $tool "g++"] {
3532 return 1
3534 return 0