* lib/target-supports.exp (check_effective_target_hard_dfp): New.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
bloba297480a62a81d100238b91d2bc74551b388271f
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008
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. C++ code should contain
33 # "// C++" and Fortran code should contain "! Fortran".
34 proc check_compile {basename type contents args} {
35 global tool
37 if { [llength $args] > 0 } {
38 set options [list "additional_flags=[lindex $args 0]"]
39 } else {
40 set options ""
42 switch -glob -- $contents {
43 "*! Fortran*" { set src ${basename}[pid].f90 }
44 "*// C++*" { set src ${basename}[pid].cc }
45 default { set src ${basename}[pid].c }
47 set compile_type $type
48 switch -glob $type {
49 assembly { set output ${basename}[pid].s }
50 object { set output ${basename}[pid].o }
51 executable { set output ${basename}[pid].exe }
52 "rtl-*" {
53 set output ${basename}[pid].s
54 lappend options "additional_flags=-fdump-$type"
55 set compile_type assembly
58 set f [open $src "w"]
59 puts $f $contents
60 close $f
61 set lines [${tool}_target_compile $src $output $compile_type "$options"]
62 file delete $src
64 set scan_output $output
65 # Don't try folding this into the switch above; calling "glob" before the
66 # file is created won't work.
67 if [regexp "rtl-(.*)" $type dummy rtl_type] {
68 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
69 file delete $output
72 return [list $lines $scan_output]
75 proc current_target_name { } {
76 global target_info
77 if [info exists target_info(target,name)] {
78 set answer $target_info(target,name)
79 } else {
80 set answer ""
82 return $answer
85 # Implement an effective-target check for property PROP by invoking
86 # the Tcl command ARGS and seeing if it returns true.
88 proc check_cached_effective_target { prop args } {
89 global et_cache
91 set target [current_target_name]
92 if {![info exists et_cache($prop,target)]
93 || $et_cache($prop,target) != $target} {
94 verbose "check_cached_effective_target $prop: checking $target" 2
95 set et_cache($prop,target) $target
96 set et_cache($prop,value) [uplevel eval $args]
98 set value $et_cache($prop,value)
99 verbose "check_cached_effective_target $prop: returning $value for $target" 2
100 return $value
103 # Like check_compile, but delete the output file and return true if the
104 # compiler printed no messages.
105 proc check_no_compiler_messages_nocache {args} {
106 set result [eval check_compile $args]
107 set lines [lindex $result 0]
108 set output [lindex $result 1]
109 remote_file build delete $output
110 return [string match "" $lines]
113 # Like check_no_compiler_messages_nocache, but cache the result.
114 # PROP is the property we're checking, and doubles as a prefix for
115 # temporary filenames.
116 proc check_no_compiler_messages {prop args} {
117 return [check_cached_effective_target $prop {
118 eval [list check_no_compiler_messages_nocache $prop] $args
122 # Like check_compile, but return true if the compiler printed no
123 # messages and if the contents of the output file satisfy PATTERN.
124 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
125 # don't match regular expression REGEXP, otherwise they satisfy it
126 # if they do match regular expression PATTERN. (PATTERN can start
127 # with something like "[!]" if the regular expression needs to match
128 # "!" as the first character.)
130 # Delete the output file before returning. The other arguments are
131 # as for check_compile.
132 proc check_no_messages_and_pattern_nocache {basename pattern args} {
133 global tool
135 set result [eval [list check_compile $basename] $args]
136 set lines [lindex $result 0]
137 set output [lindex $result 1]
139 set ok 0
140 if { [string match "" $lines] } {
141 set chan [open "$output"]
142 set invert [regexp {^!(.*)} $pattern dummy pattern]
143 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
144 close $chan
147 remote_file build delete $output
148 return $ok
151 # Like check_no_messages_and_pattern_nocache, but cache the result.
152 # PROP is the property we're checking, and doubles as a prefix for
153 # temporary filenames.
154 proc check_no_messages_and_pattern {prop pattern args} {
155 return [check_cached_effective_target $prop {
156 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
160 # Try to compile and run an executable from code CONTENTS. Return true
161 # if the compiler reports no messages and if execution "passes" in the
162 # usual DejaGNU sense. The arguments are as for check_compile, with
163 # TYPE implicitly being "executable".
164 proc check_runtime_nocache {basename contents args} {
165 global tool
167 set result [eval [list check_compile $basename executable $contents] $args]
168 set lines [lindex $result 0]
169 set output [lindex $result 1]
171 set ok 0
172 if { [string match "" $lines] } {
173 # No error messages, everything is OK.
174 set result [remote_load target "./$output" "" ""]
175 set status [lindex $result 0]
176 verbose "check_runtime_nocache $basename: status is <$status>" 2
177 if { $status == "pass" } {
178 set ok 1
181 remote_file build delete $output
182 return $ok
185 # Like check_runtime_nocache, but cache the result. PROP is the
186 # property we're checking, and doubles as a prefix for temporary
187 # filenames.
188 proc check_runtime {prop args} {
189 global tool
191 return [check_cached_effective_target $prop {
192 eval [list check_runtime_nocache $prop] $args
196 ###############################
197 # proc check_weak_available { }
198 ###############################
200 # weak symbols are only supported in some configs/object formats
201 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
203 proc check_weak_available { } {
204 global target_triplet
205 global target_cpu
207 # All mips targets should support it
209 if { [ string first "mips" $target_cpu ] >= 0 } {
210 return 1
213 # All solaris2 targets should support it
215 if { [regexp ".*-solaris2.*" $target_triplet] } {
216 return 1
219 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
221 if { [regexp "alpha.*osf.*" $target_triplet] } {
222 return 1
225 # Windows targets Cygwin and MingW32 support it
227 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
228 return 1
231 # HP-UX 10.X doesn't support it
233 if { [istarget "hppa*-*-hpux10*"] } {
234 return 0
237 # ELF and ECOFF support it. a.out does with gas/gld but may also with
238 # other linkers, so we should try it
240 set objformat [gcc_target_object_format]
242 switch $objformat {
243 elf { return 1 }
244 ecoff { return 1 }
245 a.out { return 1 }
246 mach-o { return 1 }
247 som { return 1 }
248 unknown { return -1 }
249 default { return 0 }
253 ###############################
254 # proc check_visibility_available { what_kind }
255 ###############################
257 # The visibility attribute is only support in some object formats
258 # This proc returns 1 if it is supported, 0 if not.
259 # The argument is the kind of visibility, default/protected/hidden/internal.
261 proc check_visibility_available { what_kind } {
262 global tool
263 global target_triplet
265 # On NetWare, support makes no sense.
266 if { [istarget *-*-netware*] } {
267 return 0
270 if [string match "" $what_kind] { set what_kind "hidden" }
272 return [check_no_compiler_messages visibility_available_$what_kind object "
273 void f() __attribute__((visibility(\"$what_kind\")));
274 void f() {}
278 ###############################
279 # proc check_alias_available { }
280 ###############################
282 # Determine if the target toolchain supports the alias attribute.
284 # Returns 2 if the target supports aliases. Returns 1 if the target
285 # only supports weak aliased. Returns 0 if the target does not
286 # support aliases at all. Returns -1 if support for aliases could not
287 # be determined.
289 proc check_alias_available { } {
290 global alias_available_saved
291 global tool
293 if [info exists alias_available_saved] {
294 verbose "check_alias_available returning saved $alias_available_saved" 2
295 } else {
296 set src alias[pid].c
297 set obj alias[pid].o
298 verbose "check_alias_available compiling testfile $src" 2
299 set f [open $src "w"]
300 # Compile a small test program. The definition of "g" is
301 # necessary to keep the Solaris assembler from complaining
302 # about the program.
303 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
304 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
305 close $f
306 set lines [${tool}_target_compile $src $obj object ""]
307 file delete $src
308 remote_file build delete $obj
310 if [string match "" $lines] then {
311 # No error messages, everything is OK.
312 set alias_available_saved 2
313 } else {
314 if [regexp "alias definitions not supported" $lines] {
315 verbose "check_alias_available target does not support aliases" 2
317 set objformat [gcc_target_object_format]
319 if { $objformat == "elf" } {
320 verbose "check_alias_available but target uses ELF format, so it ought to" 2
321 set alias_available_saved -1
322 } else {
323 set alias_available_saved 0
325 } else {
326 if [regexp "only weak aliases are supported" $lines] {
327 verbose "check_alias_available target supports only weak aliases" 2
328 set alias_available_saved 1
329 } else {
330 set alias_available_saved -1
335 verbose "check_alias_available returning $alias_available_saved" 2
338 return $alias_available_saved
341 # Returns true if --gc-sections is supported on the target.
343 proc check_gc_sections_available { } {
344 global gc_sections_available_saved
345 global tool
347 if {![info exists gc_sections_available_saved]} {
348 # Some targets don't support gc-sections despite whatever's
349 # advertised by ld's options.
350 if { [istarget alpha*-*-*]
351 || [istarget ia64-*-*] } {
352 set gc_sections_available_saved 0
353 return 0
356 # elf2flt uses -q (--emit-relocs), which is incompatible with
357 # --gc-sections.
358 if { [board_info target exists ldflags]
359 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
360 set gc_sections_available_saved 0
361 return 0
364 # VxWorks kernel modules are relocatable objects linked with -r,
365 # while RTP executables are linked with -q (--emit-relocs).
366 # Both of these options are incompatible with --gc-sections.
367 if { [istarget *-*-vxworks*] } {
368 set gc_sections_available_saved 0
369 return 0
372 # Check if the ld used by gcc supports --gc-sections.
373 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
374 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
375 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
376 set ld_output [remote_exec host "$gcc_ld" "--help"]
377 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
378 set gc_sections_available_saved 1
379 } else {
380 set gc_sections_available_saved 0
383 return $gc_sections_available_saved
386 # Return 1 if according to target_info struct and explicit target list
387 # target is supposed to support trampolines.
389 proc check_effective_target_trampolines { } {
390 if [target_info exists no_trampolines] {
391 return 0
393 if { [istarget avr-*-*]
394 || [istarget hppa2.0w-hp-hpux11.23]
395 || [istarget hppa64-hp-hpux11.23] } {
396 return 0;
398 return 1
401 # Return 1 if according to target_info struct and explicit target list
402 # target is supposed to keep null pointer checks. This could be due to
403 # use of option fno-delete-null-pointer-checks or hardwired in target.
405 proc check_effective_target_keeps_null_pointer_checks { } {
406 if [target_info exists keeps_null_pointer_checks] {
407 return 1
409 if { [istarget avr-*-*] } {
410 return 1;
412 return 0
415 # Return true if profiling is supported on the target.
417 proc check_profiling_available { test_what } {
418 global profiling_available_saved
420 verbose "Profiling argument is <$test_what>" 1
422 # These conditions depend on the argument so examine them before
423 # looking at the cache variable.
425 # Support for -p on solaris2 relies on mcrt1.o which comes with the
426 # vendor compiler. We cannot reliably predict the directory where the
427 # vendor compiler (and thus mcrt1.o) is installed so we can't
428 # necessarily find mcrt1.o even if we have it.
429 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
430 return 0
433 # Support for -p on irix relies on libprof1.a which doesn't appear to
434 # exist on any irix6 system currently posting testsuite results.
435 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
436 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
437 if { [istarget mips*-*-irix*]
438 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
439 return 0
442 # We don't yet support profiling for MIPS16.
443 if { [istarget mips*-*-*]
444 && ![check_effective_target_nomips16]
445 && ([lindex $test_what 1] == "-p"
446 || [lindex $test_what 1] == "-pg") } {
447 return 0
450 # MinGW does not support -p.
451 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
452 return 0
455 # At present, there is no profiling support on NetWare.
456 if { [istarget *-*-netware*] } {
457 return 0
460 # uClibc does not have gcrt1.o.
461 if { [check_effective_target_uclibc]
462 && ([lindex $test_what 1] == "-p"
463 || [lindex $test_what 1] == "-pg") } {
464 return 0
467 # Now examine the cache variable.
468 if {![info exists profiling_available_saved]} {
469 # Some targets don't have any implementation of __bb_init_func or are
470 # missing other needed machinery.
471 if { [istarget mmix-*-*]
472 || [istarget arm*-*-eabi*]
473 || [istarget arm*-*-elf]
474 || [istarget arm*-*-symbianelf*]
475 || [istarget avr-*-*]
476 || [istarget bfin-*-*]
477 || [istarget powerpc-*-eabi*]
478 || [istarget cris-*-*]
479 || [istarget crisv32-*-*]
480 || [istarget fido-*-elf]
481 || [istarget h8300-*-*]
482 || [istarget m32c-*-elf]
483 || [istarget m68k-*-elf]
484 || [istarget m68k-*-uclinux*]
485 || [istarget mips*-*-elf*]
486 || [istarget xstormy16-*]
487 || [istarget xtensa*-*-elf]
488 || [istarget *-*-vxworks*] } {
489 set profiling_available_saved 0
490 } else {
491 set profiling_available_saved 1
495 return $profiling_available_saved
498 # Return 1 if target has packed layout of structure members by
499 # default, 0 otherwise. Note that this is slightly different than
500 # whether the target has "natural alignment": both attributes may be
501 # false.
503 proc check_effective_target_default_packed { } {
504 return [check_no_compiler_messages default_packed assembly {
505 struct x { char a; long b; } c;
506 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
510 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
511 # documentation, where the test also comes from.
513 proc check_effective_target_pcc_bitfield_type_matters { } {
514 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
515 # bitfields, but let's stick to the example code from the docs.
516 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
517 struct foo1 { char x; char :0; char y; };
518 struct foo2 { char x; int :0; char y; };
519 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
523 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
525 # This won't change for different subtargets so cache the result.
527 proc check_effective_target_tls {} {
528 return [check_no_compiler_messages tls assembly {
529 __thread int i;
530 int f (void) { return i; }
531 void g (int j) { i = j; }
535 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
537 # This won't change for different subtargets so cache the result.
539 proc check_effective_target_tls_native {} {
540 # VxWorks uses emulated TLS machinery, but with non-standard helper
541 # functions, so we fail to automatically detect it.
542 global target_triplet
543 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
544 return 0
547 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
548 __thread int i;
549 int f (void) { return i; }
550 void g (int j) { i = j; }
554 # Return 1 if TLS executables can run correctly, 0 otherwise.
556 # This won't change for different subtargets so cache the result.
558 proc check_effective_target_tls_runtime {} {
559 return [check_runtime tls_runtime {
560 __thread int thr = 0;
561 int main (void) { return thr; }
565 # Return 1 if compilation with -fgraphite is error-free for trivial
566 # code, 0 otherwise.
568 proc check_effective_target_fgraphite {} {
569 return [check_no_compiler_messages fgraphite object {
570 void foo (void) { }
571 } "-O1 -fgraphite"]
574 # Return 1 if compilation with -fopenmp is error-free for trivial
575 # code, 0 otherwise.
577 proc check_effective_target_fopenmp {} {
578 return [check_no_compiler_messages fopenmp object {
579 void foo (void) { }
580 } "-fopenmp"]
583 # Return 1 if compilation with -pthread is error-free for trivial
584 # code, 0 otherwise.
586 proc check_effective_target_pthread {} {
587 return [check_no_compiler_messages pthread object {
588 void foo (void) { }
589 } "-pthread"]
592 # Return 1 if the target supports -fstack-protector
593 proc check_effective_target_fstack_protector {} {
594 return [check_runtime fstack_protector {
595 int main (void) { return 0; }
596 } "-fstack-protector"]
599 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
600 # for trivial code, 0 otherwise.
602 proc check_effective_target_freorder {} {
603 return [check_no_compiler_messages freorder object {
604 void foo (void) { }
605 } "-freorder-blocks-and-partition"]
608 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
609 # emitted, 0 otherwise. Whether a shared library can actually be built is
610 # out of scope for this test.
612 proc check_effective_target_fpic { } {
613 # Note that M68K has a multilib that supports -fpic but not
614 # -fPIC, so we need to check both. We test with a program that
615 # requires GOT references.
616 foreach arg {fpic fPIC} {
617 if [check_no_compiler_messages $arg object {
618 extern int foo (void); extern int bar;
619 int baz (void) { return foo () + bar; }
620 } "-$arg"] {
621 return 1
624 return 0
627 # Return true if the target supports -mpaired-single (as used on MIPS).
629 proc check_effective_target_mpaired_single { } {
630 return [check_no_compiler_messages mpaired_single object {
631 void foo (void) { }
632 } "-mpaired-single"]
635 # Return true if the target has access to FPU instructions.
637 proc check_effective_target_hard_float { } {
638 if { [istarget mips*-*-*] } {
639 return [check_no_compiler_messages hard_float assembly {
640 #if (defined __mips_soft_float || defined __mips16)
641 #error FOO
642 #endif
646 # The generic test equates hard_float with "no call for adding doubles".
647 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
648 double a (double b, double c) { return b + c; }
652 # Return true if the target is a 64-bit MIPS target.
654 proc check_effective_target_mips64 { } {
655 return [check_no_compiler_messages mips64 assembly {
656 #ifndef __mips64
657 #error FOO
658 #endif
662 # Return true if the target is a MIPS target that does not produce
663 # MIPS16 code.
665 proc check_effective_target_nomips16 { } {
666 return [check_no_compiler_messages nomips16 object {
667 #ifndef __mips
668 #error FOO
669 #else
670 /* A cheap way of testing for -mflip-mips16. */
671 void foo (void) { asm ("addiu $20,$20,1"); }
672 void bar (void) { asm ("addiu $20,$20,1"); }
673 #endif
677 # Add the options needed for MIPS16 function attributes. At the moment,
678 # we don't support MIPS16 PIC.
680 proc add_options_for_mips16_attribute { flags } {
681 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
684 # Return true if we can force a mode that allows MIPS16 code generation.
685 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
686 # for o32 and o64.
688 proc check_effective_target_mips16_attribute { } {
689 return [check_no_compiler_messages mips16_attribute assembly {
690 #ifdef PIC
691 #error FOO
692 #endif
693 #if defined __mips_hard_float \
694 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
695 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
696 #error FOO
697 #endif
698 } [add_options_for_mips16_attribute ""]]
701 # Return 1 if the current multilib does not generate PIC by default.
703 proc check_effective_target_nonpic { } {
704 return [check_no_compiler_messages nonpic assembly {
705 #if __PIC__
706 #error FOO
707 #endif
711 # Return 1 if the target does not use a status wrapper.
713 proc check_effective_target_unwrapped { } {
714 if { [target_info needs_status_wrapper] != "" \
715 && [target_info needs_status_wrapper] != "0" } {
716 return 0
718 return 1
721 # Return true if iconv is supported on the target. In particular IBM1047.
723 proc check_iconv_available { test_what } {
724 global libiconv
726 # If the tool configuration file has not set libiconv, try "-liconv"
727 if { ![info exists libiconv] } {
728 set libiconv "-liconv"
730 set test_what [lindex $test_what 1]
731 return [check_runtime_nocache $test_what [subst {
732 #include <iconv.h>
733 int main (void)
735 iconv_t cd;
737 cd = iconv_open ("$test_what", "UTF-8");
738 if (cd == (iconv_t) -1)
739 return 1;
740 return 0;
742 }] $libiconv]
745 # Return true if named sections are supported on this target.
747 proc check_named_sections_available { } {
748 return [check_no_compiler_messages named_sections assembly {
749 int __attribute__ ((section("whatever"))) foo;
753 # Return 1 if the target supports Fortran real kinds larger than real(8),
754 # 0 otherwise.
756 # When the target name changes, replace the cached result.
758 proc check_effective_target_fortran_large_real { } {
759 return [check_no_compiler_messages fortran_large_real executable {
760 ! Fortran
761 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
762 real(kind=k) :: x
763 x = cos (x)
768 # Return 1 if the target supports Fortran integer kinds larger than
769 # integer(8), 0 otherwise.
771 # When the target name changes, replace the cached result.
773 proc check_effective_target_fortran_large_int { } {
774 return [check_no_compiler_messages fortran_large_int executable {
775 ! Fortran
776 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
777 integer(kind=k) :: i
782 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
784 # When the target name changes, replace the cached result.
786 proc check_effective_target_fortran_integer_16 { } {
787 return [check_no_compiler_messages fortran_integer_16 executable {
788 ! Fortran
789 integer(16) :: i
794 # Return 1 if we can statically link libgfortran, 0 otherwise.
796 # When the target name changes, replace the cached result.
798 proc check_effective_target_static_libgfortran { } {
799 return [check_no_compiler_messages static_libgfortran executable {
800 ! Fortran
801 print *, 'test'
803 } "-static"]
806 # Return 1 if the target supports executing 750CL paired-single instructions, 0
807 # otherwise. Cache the result.
809 proc check_750cl_hw_available { } {
810 return [check_cached_effective_target 750cl_hw_available {
811 # If this is not the right target then we can skip the test.
812 if { ![istarget powerpc-*paired*] } {
813 expr 0
814 } else {
815 check_runtime_nocache 750cl_hw_available {
816 int main()
818 #ifdef __MACH__
819 asm volatile ("ps_mul v0,v0,v0");
820 #else
821 asm volatile ("ps_mul 0,0,0");
822 #endif
823 return 0;
825 } "-mpaired"
830 # Return 1 if the target supports executing SSE2 instructions, 0
831 # otherwise. Cache the result.
833 proc check_sse2_hw_available { } {
834 return [check_cached_effective_target sse2_hw_available {
835 # If this is not the right target then we can skip the test.
836 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
837 expr 0
838 } else {
839 check_runtime_nocache sse2_hw_available {
840 #include "cpuid.h"
841 int main ()
843 unsigned int eax, ebx, ecx, edx = 0;
844 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
845 return !(edx & bit_SSE2);
846 return 1;
848 } ""
853 # Return 1 if the target supports executing AltiVec instructions, 0
854 # otherwise. Cache the result.
856 proc check_vmx_hw_available { } {
857 return [check_cached_effective_target vmx_hw_available {
858 # Some simulators are known to not support VMX instructions.
859 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
860 expr 0
861 } else {
862 # Most targets don't require special flags for this test case, but
863 # Darwin does.
864 if { [istarget *-*-darwin*]
865 || [istarget *-*-aix*] } {
866 set options "-maltivec"
867 } else {
868 set options ""
870 check_runtime_nocache vmx_hw_available {
871 int main()
873 #ifdef __MACH__
874 asm volatile ("vor v0,v0,v0");
875 #else
876 asm volatile ("vor 0,0,0");
877 #endif
878 return 0;
880 } $options
885 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
886 # complex float arguments. This affects gfortran tests that call cabsf
887 # in libm built by an earlier compiler. Return 1 if libm uses the same
888 # argument passing as the compiler under test, 0 otherwise.
890 # When the target name changes, replace the cached result.
892 proc check_effective_target_broken_cplxf_arg { } {
893 return [check_cached_effective_target broken_cplxf_arg {
894 # Skip the work for targets known not to be affected.
895 if { ![istarget powerpc64-*-linux*] } {
896 expr 0
897 } elseif { ![is-effective-target lp64] } {
898 expr 0
899 } else {
900 check_runtime_nocache broken_cplxf_arg {
901 #include <complex.h>
902 extern void abort (void);
903 float fabsf (float);
904 float cabsf (_Complex float);
905 int main ()
907 _Complex float cf;
908 float f;
909 cf = 3 + 4.0fi;
910 f = cabsf (cf);
911 if (fabsf (f - 5.0) > 0.0001)
912 abort ();
913 return 0;
915 } "-lm"
920 proc check_alpha_max_hw_available { } {
921 return [check_runtime alpha_max_hw_available {
922 int main() { return __builtin_alpha_amask(1<<8) != 0; }
926 # Returns true iff the FUNCTION is available on the target system.
927 # (This is essentially a Tcl implementation of Autoconf's
928 # AC_CHECK_FUNC.)
930 proc check_function_available { function } {
931 return [check_no_compiler_messages ${function}_available \
932 executable [subst {
933 #ifdef __cplusplus
934 extern "C"
935 #endif
936 char $function ();
937 int main () { $function (); }
941 # Returns true iff "fork" is available on the target system.
943 proc check_fork_available {} {
944 return [check_function_available "fork"]
947 # Returns true iff "mkfifo" is available on the target system.
949 proc check_mkfifo_available {} {
950 if {[istarget *-*-cygwin*]} {
951 # Cygwin has mkfifo, but support is incomplete.
952 return 0
955 return [check_function_available "mkfifo"]
958 # Returns true iff "__cxa_atexit" is used on the target system.
960 proc check_cxa_atexit_available { } {
961 return [check_cached_effective_target cxa_atexit_available {
962 if { [istarget "hppa*-*-hpux10*"] } {
963 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
964 expr 0
965 } else {
966 check_runtime_nocache cxa_atexit_available {
967 // C++
968 #include <stdlib.h>
969 static unsigned int count;
970 struct X
972 X() { count = 1; }
973 ~X()
975 if (count != 3)
976 exit(1);
977 count = 4;
980 void f()
982 static X x;
984 struct Y
986 Y() { f(); count = 2; }
987 ~Y()
989 if (count != 2)
990 exit(1);
991 count = 3;
994 Y y;
995 int main() { return 0; }
1002 # Return 1 if we're generating 32-bit code using default options, 0
1003 # otherwise.
1005 proc check_effective_target_ilp32 { } {
1006 return [check_no_compiler_messages ilp32 object {
1007 int dummy[sizeof (int) == 4
1008 && sizeof (void *) == 4
1009 && sizeof (long) == 4 ? 1 : -1];
1013 # Return 1 if we're generating 32-bit or larger integers using default
1014 # options, 0 otherwise.
1016 proc check_effective_target_int32plus { } {
1017 return [check_no_compiler_messages int32plus object {
1018 int dummy[sizeof (int) >= 4 ? 1 : -1];
1022 # Return 1 if we're generating 32-bit or larger pointers using default
1023 # options, 0 otherwise.
1025 proc check_effective_target_ptr32plus { } {
1026 return [check_no_compiler_messages ptr32plus object {
1027 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1031 # Return 1 if we support 32-bit or larger array and structure sizes
1032 # using default options, 0 otherwise.
1034 proc check_effective_target_size32plus { } {
1035 return [check_no_compiler_messages size32plus object {
1036 char dummy[65537];
1040 # Returns 1 if we're generating 16-bit or smaller integers with the
1041 # default options, 0 otherwise.
1043 proc check_effective_target_int16 { } {
1044 return [check_no_compiler_messages int16 object {
1045 int dummy[sizeof (int) < 4 ? 1 : -1];
1049 # Return 1 if we're generating 64-bit code using default options, 0
1050 # otherwise.
1052 proc check_effective_target_lp64 { } {
1053 return [check_no_compiler_messages lp64 object {
1054 int dummy[sizeof (int) == 4
1055 && sizeof (void *) == 8
1056 && sizeof (long) == 8 ? 1 : -1];
1060 # Return 1 if we're generating 64-bit code using default llp64 options,
1061 # 0 otherwise.
1063 proc check_effective_target_llp64 { } {
1064 return [check_no_compiler_messages llp64 object {
1065 int dummy[sizeof (int) == 4
1066 && sizeof (void *) == 8
1067 && sizeof (long long) == 8
1068 && sizeof (long) == 4 ? 1 : -1];
1072 # Return 1 if the target supports long double larger than double,
1073 # 0 otherwise.
1075 proc check_effective_target_large_long_double { } {
1076 return [check_no_compiler_messages large_long_double object {
1077 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1081 # Return 1 if the target supports compiling fixed-point,
1082 # 0 otherwise.
1084 proc check_effective_target_fixed_point { } {
1085 return [check_no_compiler_messages fixed_point object {
1086 _Sat _Fract x; _Sat _Accum y;
1090 # Return 1 if the target supports compiling decimal floating point,
1091 # 0 otherwise.
1093 proc check_effective_target_dfp_nocache { } {
1094 verbose "check_effective_target_dfp_nocache: compiling source" 2
1095 set ret [check_no_compiler_messages_nocache dfp object {
1096 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1098 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1099 return $ret
1102 proc check_effective_target_dfprt_nocache { } {
1103 return [check_runtime_nocache dfprt {
1104 _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;
1105 int main () { z = x + y; return 0; }
1109 # Return 1 if the target supports compiling Decimal Floating Point,
1110 # 0 otherwise.
1112 # This won't change for different subtargets so cache the result.
1114 proc check_effective_target_dfp { } {
1115 return [check_cached_effective_target dfp {
1116 check_effective_target_dfp_nocache
1120 # Return 1 if the target supports linking and executing Decimal Floating
1121 # Point, # 0 otherwise.
1123 # This won't change for different subtargets so cache the result.
1125 proc check_effective_target_dfprt { } {
1126 return [check_cached_effective_target dfprt {
1127 check_effective_target_dfprt_nocache
1131 # Return 1 if the target needs a command line argument to enable a SIMD
1132 # instruction set.
1134 proc check_effective_target_vect_cmdline_needed { } {
1135 global et_vect_cmdline_needed_saved
1136 global et_vect_cmdline_needed_target_name
1138 if { ![info exists et_vect_cmdline_needed_target_name] } {
1139 set et_vect_cmdline_needed_target_name ""
1142 # If the target has changed since we set the cached value, clear it.
1143 set current_target [current_target_name]
1144 if { $current_target != $et_vect_cmdline_needed_target_name } {
1145 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1146 set et_vect_cmdline_needed_target_name $current_target
1147 if { [info exists et_vect_cmdline_needed_saved] } {
1148 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1149 unset et_vect_cmdline_needed_saved
1153 if [info exists et_vect_cmdline_needed_saved] {
1154 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1155 } else {
1156 set et_vect_cmdline_needed_saved 1
1157 if { [istarget ia64-*-*]
1158 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1159 && [check_effective_target_lp64])
1160 || ([istarget powerpc*-*-*]
1161 && ([check_effective_target_powerpc_spe]
1162 || [check_effective_target_powerpc_altivec]))
1163 || [istarget spu-*-*]
1164 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1165 set et_vect_cmdline_needed_saved 0
1169 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1170 return $et_vect_cmdline_needed_saved
1173 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1175 # This won't change for different subtargets so cache the result.
1177 proc check_effective_target_vect_int { } {
1178 global et_vect_int_saved
1180 if [info exists et_vect_int_saved] {
1181 verbose "check_effective_target_vect_int: using cached result" 2
1182 } else {
1183 set et_vect_int_saved 0
1184 if { [istarget i?86-*-*]
1185 || ([istarget powerpc*-*-*]
1186 && ![istarget powerpc-*-linux*paired*])
1187 || [istarget spu-*-*]
1188 || [istarget x86_64-*-*]
1189 || [istarget sparc*-*-*]
1190 || [istarget alpha*-*-*]
1191 || [istarget ia64-*-*]
1192 || [check_effective_target_arm32] } {
1193 set et_vect_int_saved 1
1197 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1198 return $et_vect_int_saved
1201 # Return 1 if the target supports int->float conversion
1204 proc check_effective_target_vect_intfloat_cvt { } {
1205 global et_vect_intfloat_cvt_saved
1207 if [info exists et_vect_intfloat_cvt_saved] {
1208 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1209 } else {
1210 set et_vect_intfloat_cvt_saved 0
1211 if { [istarget i?86-*-*]
1212 || ([istarget powerpc*-*-*]
1213 && ![istarget powerpc-*-linux*paired*])
1214 || [istarget x86_64-*-*] } {
1215 set et_vect_intfloat_cvt_saved 1
1219 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1220 return $et_vect_intfloat_cvt_saved
1224 # Return 1 if the target supports float->int conversion
1227 proc check_effective_target_vect_floatint_cvt { } {
1228 global et_vect_floatint_cvt_saved
1230 if [info exists et_vect_floatint_cvt_saved] {
1231 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1232 } else {
1233 set et_vect_floatint_cvt_saved 0
1234 if { [istarget i?86-*-*]
1235 || ([istarget powerpc*-*-*]
1236 && ![istarget powerpc-*-linux*paired*])
1237 || [istarget x86_64-*-*] } {
1238 set et_vect_floatint_cvt_saved 1
1242 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1243 return $et_vect_floatint_cvt_saved
1246 # Return 1 is this is an arm target using 32-bit instructions
1247 proc check_effective_target_arm32 { } {
1248 return [check_no_compiler_messages arm32 assembly {
1249 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1250 #error FOO
1251 #endif
1255 # Return 1 if this is an ARM target supporting -mfpu=vfp
1256 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1257 # options.
1259 proc check_effective_target_arm_vfp_ok { } {
1260 if { [check_effective_target_arm32] } {
1261 return [check_no_compiler_messages arm_vfp_ok object {
1262 int dummy;
1263 } "-mfpu=vfp -mfloat-abi=softfp"]
1264 } else {
1265 return 0
1269 # Return 1 if this is an ARM target supporting -mfpu=neon
1270 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1271 # options.
1273 proc check_effective_target_arm_neon_ok { } {
1274 if { [check_effective_target_arm32] } {
1275 return [check_no_compiler_messages arm_neon_ok object {
1276 int dummy;
1277 } "-mfpu=neon -mfloat-abi=softfp"]
1278 } else {
1279 return 0
1283 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1284 # used.
1286 proc check_effective_target_arm_thumb1_ok { } {
1287 return [check_no_compiler_messages arm_thumb1_ok assembly {
1288 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1289 #error FOO
1290 #endif
1291 } "-mthumb"]
1294 # Return 1 if the target supports executing NEON instructions, 0
1295 # otherwise. Cache the result.
1297 proc check_effective_target_arm_neon_hw { } {
1298 return [check_runtime arm_neon_hw_available {
1300 main (void)
1302 long long a = 0, b = 1;
1303 asm ("vorr %P0, %P1, %P2"
1304 : "=w" (a)
1305 : "0" (a), "w" (b));
1306 return (a != 1);
1308 } "-mfpu=neon -mfloat-abi=softfp"]
1311 # Return 1 if this is a ARM target with NEON enabled.
1313 proc check_effective_target_arm_neon { } {
1314 if { [check_effective_target_arm32] } {
1315 return [check_no_compiler_messages arm_neon object {
1316 #ifndef __ARM_NEON__
1317 #error not NEON
1318 #else
1319 int dummy;
1320 #endif
1322 } else {
1323 return 0
1327 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1328 # the Loongson vector modes.
1330 proc check_effective_target_mips_loongson { } {
1331 return [check_no_compiler_messages loongson assembly {
1332 #if !defined(__mips_loongson_vector_rev)
1333 #error FOO
1334 #endif
1338 # Return 1 if this is a PowerPC target with floating-point registers.
1340 proc check_effective_target_powerpc_fprs { } {
1341 if { [istarget powerpc*-*-*]
1342 || [istarget rs6000-*-*] } {
1343 return [check_no_compiler_messages powerpc_fprs object {
1344 #ifdef __NO_FPRS__
1345 #error no FPRs
1346 #else
1347 int dummy;
1348 #endif
1350 } else {
1351 return 0
1355 # Return 1 if this is a PowerPC target with hardware double-precision
1356 # floating point.
1358 proc check_effective_target_powerpc_hard_double { } {
1359 if { [istarget powerpc*-*-*]
1360 || [istarget rs6000-*-*] } {
1361 return [check_no_compiler_messages powerpc_hard_double object {
1362 #ifdef _SOFT_DOUBLE
1363 #error soft double
1364 #else
1365 int dummy;
1366 #endif
1368 } else {
1369 return 0
1373 # Return 1 if this is a PowerPC target supporting -maltivec.
1375 proc check_effective_target_powerpc_altivec_ok { } {
1376 if { ([istarget powerpc*-*-*]
1377 && ![istarget powerpc-*-linux*paired*])
1378 || [istarget rs6000-*-*] } {
1379 # AltiVec is not supported on AIX before 5.3.
1380 if { [istarget powerpc*-*-aix4*]
1381 || [istarget powerpc*-*-aix5.1*]
1382 || [istarget powerpc*-*-aix5.2*] } {
1383 return 0
1385 return [check_no_compiler_messages powerpc_altivec_ok object {
1386 int dummy;
1387 } "-maltivec"]
1388 } else {
1389 return 0
1393 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
1395 proc check_effective_target_powerpc_ppu_ok { } {
1396 if [check_effective_target_powerpc_altivec_ok] {
1397 return [check_no_compiler_messages cell_asm_available object {
1398 int main (void) {
1399 #ifdef __MACH__
1400 asm volatile ("lvlx v0,v0,v0");
1401 #else
1402 asm volatile ("lvlx 0,0,0");
1403 #endif
1404 return 0;
1407 } else {
1408 return 0
1412 # Return 1 if this is a PowerPC target that supports SPU.
1414 proc check_effective_target_powerpc_spu { } {
1415 if [istarget powerpc*-*-linux*] {
1416 return [check_effective_target_powerpc_altivec_ok]
1417 } else {
1418 return 0
1422 # Return 1 if this is a PowerPC target with SPE enabled.
1424 proc check_effective_target_powerpc_spe { } {
1425 if { [istarget powerpc*-*-*] } {
1426 return [check_no_compiler_messages powerpc_spe object {
1427 #ifndef __SPE__
1428 #error not SPE
1429 #else
1430 int dummy;
1431 #endif
1433 } else {
1434 return 0
1438 # Return 1 if this is a PowerPC target with Altivec enabled.
1440 proc check_effective_target_powerpc_altivec { } {
1441 if { [istarget powerpc*-*-*] } {
1442 return [check_no_compiler_messages powerpc_altivec object {
1443 #ifndef __ALTIVEC__
1444 #error not Altivec
1445 #else
1446 int dummy;
1447 #endif
1449 } else {
1450 return 0
1454 # Return 1 if this is a SPU target with a toolchain that
1455 # supports automatic overlay generation.
1457 proc check_effective_target_spu_auto_overlay { } {
1458 if { [istarget spu*-*-elf*] } {
1459 return [check_no_compiler_messages spu_auto_overlay executable {
1460 int main (void) { }
1461 } "-Wl,--auto-overlay" ]
1462 } else {
1463 return 0
1467 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1468 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1469 # test environment appears to run executables on such a simulator.
1471 proc check_effective_target_ultrasparc_hw { } {
1472 return [check_runtime ultrasparc_hw {
1473 int main() { return 0; }
1474 } "-mcpu=ultrasparc"]
1477 # Return 1 if the target supports hardware vector shift operation.
1479 proc check_effective_target_vect_shift { } {
1480 global et_vect_shift_saved
1482 if [info exists et_vect_shift_saved] {
1483 verbose "check_effective_target_vect_shift: using cached result" 2
1484 } else {
1485 set et_vect_shift_saved 0
1486 if { ([istarget powerpc*-*-*]
1487 && ![istarget powerpc-*-linux*paired*])
1488 || [istarget ia64-*-*]
1489 || [istarget i?86-*-*]
1490 || [istarget x86_64-*-*]
1491 || [check_effective_target_arm32] } {
1492 set et_vect_shift_saved 1
1496 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1497 return $et_vect_shift_saved
1500 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1502 # This can change for different subtargets so do not cache the result.
1504 proc check_effective_target_vect_long { } {
1505 if { [istarget i?86-*-*]
1506 || (([istarget powerpc*-*-*]
1507 && ![istarget powerpc-*-linux*paired*])
1508 && [check_effective_target_ilp32])
1509 || [istarget x86_64-*-*]
1510 || [check_effective_target_arm32]
1511 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1512 set answer 1
1513 } else {
1514 set answer 0
1517 verbose "check_effective_target_vect_long: returning $answer" 2
1518 return $answer
1521 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1523 # This won't change for different subtargets so cache the result.
1525 proc check_effective_target_vect_float { } {
1526 global et_vect_float_saved
1528 if [info exists et_vect_float_saved] {
1529 verbose "check_effective_target_vect_float: using cached result" 2
1530 } else {
1531 set et_vect_float_saved 0
1532 if { [istarget i?86-*-*]
1533 || [istarget powerpc*-*-*]
1534 || [istarget spu-*-*]
1535 || [istarget mipsisa64*-*-*]
1536 || [istarget x86_64-*-*]
1537 || [istarget ia64-*-*]
1538 || [check_effective_target_arm32] } {
1539 set et_vect_float_saved 1
1543 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1544 return $et_vect_float_saved
1547 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1549 # This won't change for different subtargets so cache the result.
1551 proc check_effective_target_vect_double { } {
1552 global et_vect_double_saved
1554 if [info exists et_vect_double_saved] {
1555 verbose "check_effective_target_vect_double: using cached result" 2
1556 } else {
1557 set et_vect_double_saved 0
1558 if { [istarget i?86-*-*]
1559 || [istarget x86_64-*-*]
1560 || [istarget spu-*-*] } {
1561 set et_vect_double_saved 1
1565 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1566 return $et_vect_double_saved
1569 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
1571 # This won't change for different subtargets so cache the result.
1573 proc check_effective_target_vect_long_long { } {
1574 global et_vect_long_long_saved
1576 if [info exists et_vect_long_long_saved] {
1577 verbose "check_effective_target_vect_long_long: using cached result" 2
1578 } else {
1579 set et_vect_long_long_saved 0
1580 if { [istarget i?86-*-*]
1581 || [istarget x86_64-*-*] } {
1582 set et_vect_long_long_saved 1
1586 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
1587 return $et_vect_long_long_saved
1591 # Return 1 if the target plus current options does not support a vector
1592 # max instruction on "int", 0 otherwise.
1594 # This won't change for different subtargets so cache the result.
1596 proc check_effective_target_vect_no_int_max { } {
1597 global et_vect_no_int_max_saved
1599 if [info exists et_vect_no_int_max_saved] {
1600 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1601 } else {
1602 set et_vect_no_int_max_saved 0
1603 if { [istarget sparc*-*-*]
1604 || [istarget spu-*-*]
1605 || [istarget alpha*-*-*] } {
1606 set et_vect_no_int_max_saved 1
1609 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1610 return $et_vect_no_int_max_saved
1613 # Return 1 if the target plus current options does not support a vector
1614 # add instruction on "int", 0 otherwise.
1616 # This won't change for different subtargets so cache the result.
1618 proc check_effective_target_vect_no_int_add { } {
1619 global et_vect_no_int_add_saved
1621 if [info exists et_vect_no_int_add_saved] {
1622 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1623 } else {
1624 set et_vect_no_int_add_saved 0
1625 # Alpha only supports vector add on V8QI and V4HI.
1626 if { [istarget alpha*-*-*] } {
1627 set et_vect_no_int_add_saved 1
1630 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1631 return $et_vect_no_int_add_saved
1634 # Return 1 if the target plus current options does not support vector
1635 # bitwise instructions, 0 otherwise.
1637 # This won't change for different subtargets so cache the result.
1639 proc check_effective_target_vect_no_bitwise { } {
1640 global et_vect_no_bitwise_saved
1642 if [info exists et_vect_no_bitwise_saved] {
1643 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1644 } else {
1645 set et_vect_no_bitwise_saved 0
1647 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1648 return $et_vect_no_bitwise_saved
1651 # Return 1 if the target plus current options supports vector permutation,
1652 # 0 otherwise.
1654 # This won't change for different subtargets so cache the result.
1656 proc check_effective_target_vect_perm { } {
1657 global et_vect_perm
1659 if [info exists et_vect_perm_saved] {
1660 verbose "check_effective_target_vect_perm: using cached result" 2
1661 } else {
1662 set et_vect_perm_saved 0
1663 if { [istarget powerpc*-*-*]
1664 || [istarget spu-*-*] } {
1665 set et_vect_perm_saved 1
1668 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
1669 return $et_vect_perm_saved
1673 # Return 1 if the target plus current options supports a vector
1674 # widening summation of *short* args into *int* result, 0 otherwise.
1675 # A target can also support this widening summation if it can support
1676 # promotion (unpacking) from shorts to ints.
1678 # This won't change for different subtargets so cache the result.
1680 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1681 global et_vect_widen_sum_hi_to_si
1683 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1684 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1685 } else {
1686 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1687 if { [istarget powerpc*-*-*]
1688 || [istarget ia64-*-*] } {
1689 set et_vect_widen_sum_hi_to_si_saved 1
1692 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1693 return $et_vect_widen_sum_hi_to_si_saved
1696 # Return 1 if the target plus current options supports a vector
1697 # widening summation of *char* args into *short* result, 0 otherwise.
1698 # A target can also support this widening summation if it can support
1699 # promotion (unpacking) from chars to shorts.
1701 # This won't change for different subtargets so cache the result.
1703 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1704 global et_vect_widen_sum_qi_to_hi
1706 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1707 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1708 } else {
1709 set et_vect_widen_sum_qi_to_hi_saved 0
1710 if { [check_effective_target_vect_unpack]
1711 || [istarget ia64-*-*] } {
1712 set et_vect_widen_sum_qi_to_hi_saved 1
1715 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1716 return $et_vect_widen_sum_qi_to_hi_saved
1719 # Return 1 if the target plus current options supports a vector
1720 # widening summation of *char* args into *int* result, 0 otherwise.
1722 # This won't change for different subtargets so cache the result.
1724 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1725 global et_vect_widen_sum_qi_to_si
1727 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1728 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1729 } else {
1730 set et_vect_widen_sum_qi_to_si_saved 0
1731 if { [istarget powerpc*-*-*] } {
1732 set et_vect_widen_sum_qi_to_si_saved 1
1735 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1736 return $et_vect_widen_sum_qi_to_si_saved
1739 # Return 1 if the target plus current options supports a vector
1740 # widening multiplication of *char* args into *short* result, 0 otherwise.
1741 # A target can also support this widening multplication if it can support
1742 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1743 # multiplication of shorts).
1745 # This won't change for different subtargets so cache the result.
1748 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1749 global et_vect_widen_mult_qi_to_hi
1751 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1752 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1753 } else {
1754 if { [check_effective_target_vect_unpack]
1755 && [check_effective_target_vect_short_mult] } {
1756 set et_vect_widen_mult_qi_to_hi_saved 1
1757 } else {
1758 set et_vect_widen_mult_qi_to_hi_saved 0
1760 if { [istarget powerpc*-*-*] } {
1761 set et_vect_widen_mult_qi_to_hi_saved 1
1764 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1765 return $et_vect_widen_mult_qi_to_hi_saved
1768 # Return 1 if the target plus current options supports a vector
1769 # widening multiplication of *short* args into *int* result, 0 otherwise.
1770 # A target can also support this widening multplication if it can support
1771 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1772 # multiplication of ints).
1774 # This won't change for different subtargets so cache the result.
1777 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1778 global et_vect_widen_mult_hi_to_si
1780 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1781 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1782 } else {
1783 if { [check_effective_target_vect_unpack]
1784 && [check_effective_target_vect_int_mult] } {
1785 set et_vect_widen_mult_hi_to_si_saved 1
1786 } else {
1787 set et_vect_widen_mult_hi_to_si_saved 0
1789 if { [istarget powerpc*-*-*]
1790 || [istarget spu-*-*]
1791 || [istarget i?86-*-*]
1792 || [istarget x86_64-*-*] } {
1793 set et_vect_widen_mult_hi_to_si_saved 1
1796 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1797 return $et_vect_widen_mult_hi_to_si_saved
1800 # Return 1 if the target plus current options supports a vector
1801 # dot-product of signed chars, 0 otherwise.
1803 # This won't change for different subtargets so cache the result.
1805 proc check_effective_target_vect_sdot_qi { } {
1806 global et_vect_sdot_qi
1808 if [info exists et_vect_sdot_qi_saved] {
1809 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1810 } else {
1811 set et_vect_sdot_qi_saved 0
1813 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1814 return $et_vect_sdot_qi_saved
1817 # Return 1 if the target plus current options supports a vector
1818 # dot-product of unsigned chars, 0 otherwise.
1820 # This won't change for different subtargets so cache the result.
1822 proc check_effective_target_vect_udot_qi { } {
1823 global et_vect_udot_qi
1825 if [info exists et_vect_udot_qi_saved] {
1826 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1827 } else {
1828 set et_vect_udot_qi_saved 0
1829 if { [istarget powerpc*-*-*] } {
1830 set et_vect_udot_qi_saved 1
1833 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1834 return $et_vect_udot_qi_saved
1837 # Return 1 if the target plus current options supports a vector
1838 # dot-product of signed shorts, 0 otherwise.
1840 # This won't change for different subtargets so cache the result.
1842 proc check_effective_target_vect_sdot_hi { } {
1843 global et_vect_sdot_hi
1845 if [info exists et_vect_sdot_hi_saved] {
1846 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1847 } else {
1848 set et_vect_sdot_hi_saved 0
1849 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1850 || [istarget i?86-*-*]
1851 || [istarget x86_64-*-*] } {
1852 set et_vect_sdot_hi_saved 1
1855 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1856 return $et_vect_sdot_hi_saved
1859 # Return 1 if the target plus current options supports a vector
1860 # dot-product of unsigned shorts, 0 otherwise.
1862 # This won't change for different subtargets so cache the result.
1864 proc check_effective_target_vect_udot_hi { } {
1865 global et_vect_udot_hi
1867 if [info exists et_vect_udot_hi_saved] {
1868 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1869 } else {
1870 set et_vect_udot_hi_saved 0
1871 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
1872 set et_vect_udot_hi_saved 1
1875 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1876 return $et_vect_udot_hi_saved
1880 # Return 1 if the target plus current options supports a vector
1881 # demotion (packing) of shorts (to chars) and ints (to shorts)
1882 # using modulo arithmetic, 0 otherwise.
1884 # This won't change for different subtargets so cache the result.
1886 proc check_effective_target_vect_pack_trunc { } {
1887 global et_vect_pack_trunc
1889 if [info exists et_vect_pack_trunc_saved] {
1890 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
1891 } else {
1892 set et_vect_pack_trunc_saved 0
1893 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
1894 || [istarget i?86-*-*]
1895 || [istarget x86_64-*-*]
1896 || [istarget spu-*-*] } {
1897 set et_vect_pack_trunc_saved 1
1900 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
1901 return $et_vect_pack_trunc_saved
1904 # Return 1 if the target plus current options supports a vector
1905 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
1907 # This won't change for different subtargets so cache the result.
1909 proc check_effective_target_vect_unpack { } {
1910 global et_vect_unpack
1912 if [info exists et_vect_unpack_saved] {
1913 verbose "check_effective_target_vect_unpack: using cached result" 2
1914 } else {
1915 set et_vect_unpack_saved 0
1916 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
1917 || [istarget i?86-*-*]
1918 || [istarget x86_64-*-*]
1919 || [istarget spu-*-*] } {
1920 set et_vect_unpack_saved 1
1923 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
1924 return $et_vect_unpack_saved
1927 # Return 1 if the target plus current options does not guarantee
1928 # that its STACK_BOUNDARY is >= the reguired vector alignment.
1930 # This won't change for different subtargets so cache the result.
1932 proc check_effective_target_unaligned_stack { } {
1933 global et_unaligned_stack_saved
1935 if [info exists et_unaligned_stack_saved] {
1936 verbose "check_effective_target_unaligned_stack: using cached result" 2
1937 } else {
1938 set et_unaligned_stack_saved 0
1940 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
1941 return $et_unaligned_stack_saved
1944 # Return 1 if the target plus current options does not support a vector
1945 # alignment mechanism, 0 otherwise.
1947 # This won't change for different subtargets so cache the result.
1949 proc check_effective_target_vect_no_align { } {
1950 global et_vect_no_align_saved
1952 if [info exists et_vect_no_align_saved] {
1953 verbose "check_effective_target_vect_no_align: using cached result" 2
1954 } else {
1955 set et_vect_no_align_saved 0
1956 if { [istarget mipsisa64*-*-*]
1957 || [istarget sparc*-*-*]
1958 || [istarget ia64-*-*]
1959 || [check_effective_target_arm32] } {
1960 set et_vect_no_align_saved 1
1963 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1964 return $et_vect_no_align_saved
1967 # Return 1 if arrays are aligned to the vector alignment
1968 # boundary, 0 otherwise.
1970 # This won't change for different subtargets so cache the result.
1972 proc check_effective_target_vect_aligned_arrays { } {
1973 global et_vect_aligned_arrays
1975 if [info exists et_vect_aligned_arrays_saved] {
1976 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
1977 } else {
1978 set et_vect_aligned_arrays_saved 0
1979 if { (([istarget x86_64-*-*]
1980 || [istarget i?86-*-*]) && [is-effective-target lp64])
1981 || [istarget spu-*-*] } {
1982 set et_vect_aligned_arrays_saved 1
1985 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
1986 return $et_vect_aligned_arrays_saved
1989 # Return 1 if types of size 32 bit or less are naturally aligned
1990 # (aligned to their type-size), 0 otherwise.
1992 # This won't change for different subtargets so cache the result.
1994 proc check_effective_target_natural_alignment_32 { } {
1995 global et_natural_alignment_32
1997 if [info exists et_natural_alignment_32_saved] {
1998 verbose "check_effective_target_natural_alignment_32: using cached result" 2
1999 } else {
2000 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2001 set et_natural_alignment_32_saved 1
2002 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2003 set et_natural_alignment_32_saved 0
2006 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2007 return $et_natural_alignment_32_saved
2010 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2011 # type-size), 0 otherwise.
2013 # This won't change for different subtargets so cache the result.
2015 proc check_effective_target_natural_alignment_64 { } {
2016 global et_natural_alignment_64
2018 if [info exists et_natural_alignment_64_saved] {
2019 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2020 } else {
2021 set et_natural_alignment_64_saved 0
2022 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2023 || [istarget spu-*-*] } {
2024 set et_natural_alignment_64_saved 1
2027 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2028 return $et_natural_alignment_64_saved
2031 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2033 # This won't change for different subtargets so cache the result.
2035 proc check_effective_target_vector_alignment_reachable { } {
2036 global et_vector_alignment_reachable
2038 if [info exists et_vector_alignment_reachable_saved] {
2039 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2040 } else {
2041 if { [check_effective_target_vect_aligned_arrays]
2042 || [check_effective_target_natural_alignment_32] } {
2043 set et_vector_alignment_reachable_saved 1
2044 } else {
2045 set et_vector_alignment_reachable_saved 0
2048 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2049 return $et_vector_alignment_reachable_saved
2052 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2054 # This won't change for different subtargets so cache the result.
2056 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2057 global et_vector_alignment_reachable_for_64bit
2059 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2060 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2061 } else {
2062 if { [check_effective_target_vect_aligned_arrays]
2063 || [check_effective_target_natural_alignment_64] } {
2064 set et_vector_alignment_reachable_for_64bit_saved 1
2065 } else {
2066 set et_vector_alignment_reachable_for_64bit_saved 0
2069 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2070 return $et_vector_alignment_reachable_for_64bit_saved
2073 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2075 proc check_effective_target_vect_condition { } {
2076 global et_vect_cond_saved
2078 if [info exists et_vect_cond_saved] {
2079 verbose "check_effective_target_vect_cond: using cached result" 2
2080 } else {
2081 set et_vect_cond_saved 0
2082 if { [istarget powerpc*-*-*]
2083 || [istarget ia64-*-*]
2084 || [istarget i?86-*-*]
2085 || [istarget spu-*-*]
2086 || [istarget x86_64-*-*] } {
2087 set et_vect_cond_saved 1
2091 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2092 return $et_vect_cond_saved
2095 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2097 proc check_effective_target_vect_char_mult { } {
2098 global et_vect_char_mult_saved
2100 if [info exists et_vect_char_mult_saved] {
2101 verbose "check_effective_target_vect_char_mult: using cached result" 2
2102 } else {
2103 set et_vect_char_mult_saved 0
2104 if { [istarget ia64-*-*]
2105 || [istarget i?86-*-*]
2106 || [istarget x86_64-*-*] } {
2107 set et_vect_char_mult_saved 1
2111 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2112 return $et_vect_char_mult_saved
2115 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2117 proc check_effective_target_vect_short_mult { } {
2118 global et_vect_short_mult_saved
2120 if [info exists et_vect_short_mult_saved] {
2121 verbose "check_effective_target_vect_short_mult: using cached result" 2
2122 } else {
2123 set et_vect_short_mult_saved 0
2124 if { [istarget ia64-*-*]
2125 || [istarget spu-*-*]
2126 || [istarget i?86-*-*]
2127 || [istarget x86_64-*-*]
2128 || [istarget powerpc*-*-*] } {
2129 set et_vect_short_mult_saved 1
2133 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2134 return $et_vect_short_mult_saved
2137 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2139 proc check_effective_target_vect_int_mult { } {
2140 global et_vect_int_mult_saved
2142 if [info exists et_vect_int_mult_saved] {
2143 verbose "check_effective_target_vect_int_mult: using cached result" 2
2144 } else {
2145 set et_vect_int_mult_saved 0
2146 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2147 || [istarget spu-*-*]
2148 || [istarget i?86-*-*]
2149 || [istarget x86_64-*-*]
2150 || [check_effective_target_arm32] } {
2151 set et_vect_int_mult_saved 1
2155 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2156 return $et_vect_int_mult_saved
2159 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2161 proc check_effective_target_vect_extract_even_odd { } {
2162 global et_vect_extract_even_odd_saved
2164 if [info exists et_vect_extract_even_odd_saved] {
2165 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2166 } else {
2167 set et_vect_extract_even_odd_saved 0
2168 if { [istarget powerpc*-*-*]
2169 || [istarget spu-*-*] } {
2170 set et_vect_extract_even_odd_saved 1
2174 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2175 return $et_vect_extract_even_odd_saved
2178 # Return 1 if the target supports vector even/odd elements extraction of
2179 # vectors with SImode elements or larger, 0 otherwise.
2181 proc check_effective_target_vect_extract_even_odd_wide { } {
2182 global et_vect_extract_even_odd_wide_saved
2184 if [info exists et_vect_extract_even_odd_wide_saved] {
2185 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2186 } else {
2187 set et_vect_extract_even_odd_wide_saved 0
2188 if { [istarget powerpc*-*-*]
2189 || [istarget i?86-*-*]
2190 || [istarget x86_64-*-*]
2191 || [istarget spu-*-*] } {
2192 set et_vect_extract_even_odd_wide_saved 1
2196 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
2197 return $et_vect_extract_even_odd_wide_saved
2200 # Return 1 if the target supports vector interleaving, 0 otherwise.
2202 proc check_effective_target_vect_interleave { } {
2203 global et_vect_interleave_saved
2205 if [info exists et_vect_interleave_saved] {
2206 verbose "check_effective_target_vect_interleave: using cached result" 2
2207 } else {
2208 set et_vect_interleave_saved 0
2209 if { [istarget powerpc*-*-*]
2210 || [istarget i?86-*-*]
2211 || [istarget x86_64-*-*]
2212 || [istarget spu-*-*] } {
2213 set et_vect_interleave_saved 1
2217 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2218 return $et_vect_interleave_saved
2221 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2222 proc check_effective_target_vect_strided { } {
2223 global et_vect_strided_saved
2225 if [info exists et_vect_strided_saved] {
2226 verbose "check_effective_target_vect_strided: using cached result" 2
2227 } else {
2228 set et_vect_strided_saved 0
2229 if { [check_effective_target_vect_interleave]
2230 && [check_effective_target_vect_extract_even_odd] } {
2231 set et_vect_strided_saved 1
2235 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2236 return $et_vect_strided_saved
2239 # Return 1 if the target supports vector interleaving and extract even/odd
2240 # for wide element types, 0 otherwise.
2241 proc check_effective_target_vect_strided_wide { } {
2242 global et_vect_strided_wide_saved
2244 if [info exists et_vect_strided_wide_saved] {
2245 verbose "check_effective_target_vect_strided_wide: using cached result" 2
2246 } else {
2247 set et_vect_strided_wide_saved 0
2248 if { [check_effective_target_vect_interleave]
2249 && [check_effective_target_vect_extract_even_odd_wide] } {
2250 set et_vect_strided_wide_saved 1
2254 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
2255 return $et_vect_strided_wide_saved
2258 # Return 1 if the target supports section-anchors
2260 proc check_effective_target_section_anchors { } {
2261 global et_section_anchors_saved
2263 if [info exists et_section_anchors_saved] {
2264 verbose "check_effective_target_section_anchors: using cached result" 2
2265 } else {
2266 set et_section_anchors_saved 0
2267 if { [istarget powerpc*-*-*] } {
2268 set et_section_anchors_saved 1
2272 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2273 return $et_section_anchors_saved
2276 # Return 1 if the target supports atomic operations on "int" and "long".
2278 proc check_effective_target_sync_int_long { } {
2279 global et_sync_int_long_saved
2281 if [info exists et_sync_int_long_saved] {
2282 verbose "check_effective_target_sync_int_long: using cached result" 2
2283 } else {
2284 set et_sync_int_long_saved 0
2285 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2286 # load-reserved/store-conditional instructions.
2287 if { [istarget ia64-*-*]
2288 || [istarget i?86-*-*]
2289 || [istarget x86_64-*-*]
2290 || [istarget alpha*-*-*]
2291 || [istarget s390*-*-*]
2292 || [istarget powerpc*-*-*]
2293 || [istarget sparc64-*-*]
2294 || [istarget sparcv9-*-*]
2295 || [istarget mips*-*-*] } {
2296 set et_sync_int_long_saved 1
2300 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2301 return $et_sync_int_long_saved
2304 # Return 1 if the target supports atomic operations on "char" and "short".
2306 proc check_effective_target_sync_char_short { } {
2307 global et_sync_char_short_saved
2309 if [info exists et_sync_char_short_saved] {
2310 verbose "check_effective_target_sync_char_short: using cached result" 2
2311 } else {
2312 set et_sync_char_short_saved 0
2313 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2314 # load-reserved/store-conditional instructions.
2315 if { [istarget ia64-*-*]
2316 || [istarget i?86-*-*]
2317 || [istarget x86_64-*-*]
2318 || [istarget alpha*-*-*]
2319 || [istarget s390*-*-*]
2320 || [istarget powerpc*-*-*]
2321 || [istarget sparc64-*-*]
2322 || [istarget sparcv9-*-*]
2323 || [istarget mips*-*-*] } {
2324 set et_sync_char_short_saved 1
2328 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2329 return $et_sync_char_short_saved
2332 # Return 1 if the target uses a ColdFire FPU.
2334 proc check_effective_target_coldfire_fpu { } {
2335 return [check_no_compiler_messages coldfire_fpu assembly {
2336 #ifndef __mcffpu__
2337 #error FOO
2338 #endif
2342 # Return true if this is a uClibc target.
2344 proc check_effective_target_uclibc {} {
2345 return [check_no_compiler_messages uclibc object {
2346 #include <features.h>
2347 #if !defined (__UCLIBC__)
2348 #error FOO
2349 #endif
2353 # Return true if this is a uclibc target and if the uclibc feature
2354 # described by __$feature__ is not present.
2356 proc check_missing_uclibc_feature {feature} {
2357 return [check_no_compiler_messages $feature object "
2358 #include <features.h>
2359 #if !defined (__UCLIBC) || defined (__${feature}__)
2360 #error FOO
2361 #endif
2365 # Return true if this is a Newlib target.
2367 proc check_effective_target_newlib {} {
2368 return [check_no_compiler_messages newlib object {
2369 #include <newlib.h>
2373 # Return 1 if
2374 # (a) an error of a few ULP is expected in string to floating-point
2375 # conversion functions; and
2376 # (b) overflow is not always detected correctly by those functions.
2378 proc check_effective_target_lax_strtofp {} {
2379 # By default, assume that all uClibc targets suffer from this.
2380 return [check_effective_target_uclibc]
2383 # Return 1 if this is a target for which wcsftime is a dummy
2384 # function that always returns 0.
2386 proc check_effective_target_dummy_wcsftime {} {
2387 # By default, assume that all uClibc targets suffer from this.
2388 return [check_effective_target_uclibc]
2391 # Return 1 if constructors with initialization priority arguments are
2392 # supposed on this target.
2394 proc check_effective_target_init_priority {} {
2395 return [check_no_compiler_messages init_priority assembly "
2396 void f() __attribute__((constructor (1000)));
2397 void f() \{\}
2401 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2402 # This can be used with any check_* proc that takes no argument and
2403 # returns only 1 or 0. It could be used with check_* procs that take
2404 # arguments with keywords that pass particular arguments.
2406 proc is-effective-target { arg } {
2407 set selected 0
2408 if { [info procs check_effective_target_${arg}] != [list] } {
2409 set selected [check_effective_target_${arg}]
2410 } else {
2411 switch $arg {
2412 "vmx_hw" { set selected [check_vmx_hw_available] }
2413 "named_sections" { set selected [check_named_sections_available] }
2414 "gc_sections" { set selected [check_gc_sections_available] }
2415 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2416 default { error "unknown effective target keyword `$arg'" }
2419 verbose "is-effective-target: $arg $selected" 2
2420 return $selected
2423 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2425 proc is-effective-target-keyword { arg } {
2426 if { [info procs check_effective_target_${arg}] != [list] } {
2427 return 1
2428 } else {
2429 # These have different names for their check_* procs.
2430 switch $arg {
2431 "vmx_hw" { return 1 }
2432 "named_sections" { return 1 }
2433 "gc_sections" { return 1 }
2434 "cxa_atexit" { return 1 }
2435 default { return 0 }
2440 # Return 1 if target default to short enums
2442 proc check_effective_target_short_enums { } {
2443 return [check_no_compiler_messages short_enums assembly {
2444 enum foo { bar };
2445 int s[sizeof (enum foo) == 1 ? 1 : -1];
2449 # Return 1 if target supports merging string constants at link time.
2451 proc check_effective_target_string_merging { } {
2452 return [check_no_messages_and_pattern string_merging \
2453 "rodata\\.str" assembly {
2454 const char *var = "String";
2455 } {-O2}]
2458 # Return 1 if target has the basic signed and unsigned types in
2459 # <stdint.h>, 0 otherwise.
2461 proc check_effective_target_stdint_types { } {
2462 return [check_no_compiler_messages stdint_types assembly {
2463 #include <stdint.h>
2464 int8_t a; int16_t b; int32_t c; int64_t d;
2465 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2469 # Return 1 if programs are intended to be run on a simulator
2470 # (i.e. slowly) rather than hardware (i.e. fast).
2472 proc check_effective_target_simulator { } {
2474 # All "src/sim" simulators set this one.
2475 if [board_info target exists is_simulator] {
2476 return [board_info target is_simulator]
2479 # The "sid" simulators don't set that one, but at least they set
2480 # this one.
2481 if [board_info target exists slow_simulator] {
2482 return [board_info target slow_simulator]
2485 return 0
2488 # Return 1 if the target is a VxWorks kernel.
2490 proc check_effective_target_vxworks_kernel { } {
2491 return [check_no_compiler_messages vxworks_kernel assembly {
2492 #if !defined __vxworks || defined __RTP__
2493 #error NO
2494 #endif
2498 # Return 1 if the target is a VxWorks RTP.
2500 proc check_effective_target_vxworks_rtp { } {
2501 return [check_no_compiler_messages vxworks_rtp assembly {
2502 #if !defined __vxworks || !defined __RTP__
2503 #error NO
2504 #endif
2508 # Return 1 if the target is expected to provide wide character support.
2510 proc check_effective_target_wchar { } {
2511 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2512 return 0
2514 return [check_no_compiler_messages wchar assembly {
2515 #include <wchar.h>
2519 # Return 1 if the target has <pthread.h>.
2521 proc check_effective_target_pthread_h { } {
2522 return [check_no_compiler_messages pthread_h assembly {
2523 #include <pthread.h>
2527 # Return 1 if the target can truncate a file from a file-descriptor,
2528 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
2529 # chsize. We test for a trivially functional truncation; no stubs.
2530 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
2531 # different function to be used.
2533 proc check_effective_target_fd_truncate { } {
2534 set prog {
2535 #define _FILE_OFFSET_BITS 64
2536 #include <unistd.h>
2537 #include <stdio.h>
2538 #include <stdlib.h>
2539 int main ()
2541 FILE *f = fopen ("tst.tmp", "wb");
2542 int fd;
2543 const char t[] = "test writing more than ten characters";
2544 char s[11];
2545 fd = fileno (f);
2546 write (fd, t, sizeof (t) - 1);
2547 lseek (fd, 0, 0);
2548 if (ftruncate (fd, 10) != 0)
2549 exit (1);
2550 close (fd);
2551 f = fopen ("tst.tmp", "rb");
2552 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
2553 exit (1);
2554 exit (0);
2558 if { [check_runtime ftruncate $prog] } {
2559 return 1;
2562 regsub "ftruncate" $prog "chsize" prog
2563 return [check_runtime chsize $prog]
2566 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2568 proc add_options_for_c99_runtime { flags } {
2569 if { [istarget *-*-solaris2*] } {
2570 return "$flags -std=c99"
2572 if { [istarget powerpc-*-darwin*] } {
2573 return "$flags -mmacosx-version-min=10.3"
2575 return $flags
2578 # Return 1 if the target provides a full C99 runtime.
2580 proc check_effective_target_c99_runtime { } {
2581 return [check_cached_effective_target c99_runtime {
2582 global srcdir
2584 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2585 set contents [read $file]
2586 close $file
2587 append contents {
2588 #ifndef HAVE_C99_RUNTIME
2589 #error FOO
2590 #endif
2592 check_no_compiler_messages_nocache c99_runtime assembly \
2593 $contents [add_options_for_c99_runtime ""]
2597 # Return 1 if target wchar_t is at least 4 bytes.
2599 proc check_effective_target_4byte_wchar_t { } {
2600 return [check_no_compiler_messages 4byte_wchar_t object {
2601 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
2605 # Return 1 if the target supports automatic stack alignment.
2607 proc check_effective_target_automatic_stack_alignment { } {
2608 if { [istarget i?86*-*-*]
2609 || [istarget x86_64-*-*] } then {
2610 return 1
2611 } else {
2612 return 0
2616 # Return 1 if avx instructions can be compiled.
2618 proc check_effective_target_avx { } {
2619 return [check_no_compiler_messages avx object {
2620 void _mm256_zeroall (void)
2622 __builtin_ia32_vzeroall ();
2624 } "-O2 -mavx" ]
2627 # Return 1 if C wchar_t type is compatible with char16_t.
2629 proc check_effective_target_wchar_t_char16_t_compatible { } {
2630 return [check_no_compiler_messages wchar_t_char16_t object {
2631 __WCHAR_TYPE__ wc;
2632 __CHAR16_TYPE__ *p16 = &wc;
2633 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2637 # Return 1 if C wchar_t type is compatible with char32_t.
2639 proc check_effective_target_wchar_t_char32_t_compatible { } {
2640 return [check_no_compiler_messages wchar_t_char32_t object {
2641 __WCHAR_TYPE__ wc;
2642 __CHAR32_TYPE__ *p32 = &wc;
2643 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
2647 # Return 1 if pow10 function exists.
2649 proc check_effective_target_pow10 { } {
2650 return [check_runtime pow10 {
2651 #include <math.h>
2652 int main () {
2653 double x;
2654 x = pow10 (1);
2655 return 0;
2657 } "-lm" ]
2660 # Return 1 if current options generate DFP instructions, 0 otherwise.
2662 proc check_effective_target_hard_dfp {} {
2663 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
2664 _Decimal64 x, y, z;
2665 void foo (void) { z = x + y; }