sourcebuild.texi (dg-add-c99-runtime-options): Document.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob8bbb141ec105e3b9271bcdfff0c57ae4ebd0d4b0
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007
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 some code and return the messages printed by the compiler,
24 # and optionally the contents for assembly files. Either a string or
25 # a list of two strings are returned, depending on WANT_OUTPUT.
27 # BASENAME is a basename to use for temporary files.
28 # WANT_OUTPUT is a flag which is 0 to request returning just the
29 # compiler messages, or 1 to return the messages and the contents
30 # of the assembly file. TYPE should be "assembly" if WANT_OUTPUT
31 # is set.
32 # TYPE is the type of compilation to perform (see target_compile).
33 # CONTENTS gives the contents of the input file.
34 # The rest is optional:
35 # OPTIONS: additional compiler options to use.
36 proc get_compiler_messages {basename want_output type contents args} {
37 global tool
39 if { [llength $args] > 0 } {
40 set options [list "additional_flags=[lindex $args 0]"]
41 } else {
42 set options ""
45 set src ${basename}[pid].c
46 switch $type {
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
50 set f [open $src "w"]
51 puts $f $contents
52 close $f
53 set lines [${tool}_target_compile $src $output $type "$options"]
54 file delete $src
56 if { $want_output } {
57 if { $type != "assembly" } {
58 error "WANT_OUTPUT can only be used with assembly output"
59 } elseif { ![string match "" $lines] } {
60 # An error occurred.
61 set result [list $lines ""]
62 } else {
63 set text ""
64 set chan [open "$output"]
65 while {[gets $chan line] >= 0} {
66 append text "$line\n"
68 close $chan
69 set result [list $lines $text]
71 } else {
72 set result $lines
75 remote_file build delete $output
76 return $result
79 proc current_target_name { } {
80 global target_info
81 if [info exists target_info(target,name)] {
82 set answer $target_info(target,name)
83 } else {
84 set answer ""
86 return $answer
89 # Implement an effective-target check for property PROP by invoking
90 # the compiler and seeing if it prints any messages. Assume that the
91 # property holds if the compiler doesn't print anything. The other
92 # arguments are as for get_compiler_messages, starting with TYPE.
93 proc check_no_compiler_messages {prop args} {
94 global et_cache
96 set target [current_target_name]
97 if {![info exists et_cache($prop,target)]
98 || $et_cache($prop,target) != $target} {
99 verbose "check_no_compiler_messages $prop: compiling source for $target" 2
100 set et_cache($prop,target) $target
101 set et_cache($prop,value) \
102 [string match "" [eval get_compiler_messages $prop 0 $args]]
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
106 return $value
109 # Similar to check_no_compiler_messages, but also verify that the regular
110 # expression PATTERN matches the compiler's output.
111 proc check_no_messages_and_pattern {prop pattern args} {
112 global et_cache
114 set target [current_target_name]
115 if {![info exists et_cache($prop,target)]
116 || $et_cache($prop,target) != $target} {
117 verbose "check_no_messages_and_pattern $prop: compiling source for $target" 2
118 set et_cache($prop,target) $target
119 set results [eval get_compiler_messages $prop 1 $args]
120 set et_cache($prop,value) \
121 [expr [string match "" [lindex $results 0]] \
122 && [regexp $pattern [lindex $results 1]]]
124 set value $et_cache($prop,value)
125 verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
126 return $value
129 ###############################
130 # proc check_weak_available { }
131 ###############################
133 # weak symbols are only supported in some configs/object formats
134 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
136 proc check_weak_available { } {
137 global target_triplet
138 global target_cpu
140 # All mips targets should support it
142 if { [ string first "mips" $target_cpu ] >= 0 } {
143 return 1
146 # All solaris2 targets should support it
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
149 return 1
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
155 return 1
158 # Windows targets Cygwin and MingW32 support it
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
161 return 1
164 # HP-UX 10.X doesn't support it
166 if { [istarget "hppa*-*-hpux10*"] } {
167 return 0
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
173 set objformat [gcc_target_object_format]
175 switch $objformat {
176 elf { return 1 }
177 ecoff { return 1 }
178 a.out { return 1 }
179 mach-o { return 1 }
180 som { return 1 }
181 unknown { return -1 }
182 default { return 0 }
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
190 # The visibility attribute is only support in some object formats
191 # This proc returns 1 if it is supported, 0 if not.
192 # The argument is the kind of visibility, default/protected/hidden/internal.
194 proc check_visibility_available { what_kind } {
195 global tool
196 global target_triplet
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
200 return 0
203 if [string match "" $what_kind] { set what_kind "hidden" }
205 return [check_no_compiler_messages visibility_available_$what_kind object "
206 void f() __attribute__((visibility(\"$what_kind\")));
207 void f() {}
211 ###############################
212 # proc check_alias_available { }
213 ###############################
215 # Determine if the target toolchain supports the alias attribute.
217 # Returns 2 if the target supports aliases. Returns 1 if the target
218 # only supports weak aliased. Returns 0 if the target does not
219 # support aliases at all. Returns -1 if support for aliases could not
220 # be determined.
222 proc check_alias_available { } {
223 global alias_available_saved
224 global tool
226 if [info exists alias_available_saved] {
227 verbose "check_alias_available returning saved $alias_available_saved" 2
228 } else {
229 set src alias[pid].c
230 set obj alias[pid].o
231 verbose "check_alias_available compiling testfile $src" 2
232 set f [open $src "w"]
233 # Compile a small test program. The definition of "g" is
234 # necessary to keep the Solaris assembler from complaining
235 # about the program.
236 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
237 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
238 close $f
239 set lines [${tool}_target_compile $src $obj object ""]
240 file delete $src
241 remote_file build delete $obj
243 if [string match "" $lines] then {
244 # No error messages, everything is OK.
245 set alias_available_saved 2
246 } else {
247 if [regexp "alias definitions not supported" $lines] {
248 verbose "check_alias_available target does not support aliases" 2
250 set objformat [gcc_target_object_format]
252 if { $objformat == "elf" } {
253 verbose "check_alias_available but target uses ELF format, so it ought to" 2
254 set alias_available_saved -1
255 } else {
256 set alias_available_saved 0
258 } else {
259 if [regexp "only weak aliases are supported" $lines] {
260 verbose "check_alias_available target supports only weak aliases" 2
261 set alias_available_saved 1
262 } else {
263 set alias_available_saved -1
268 verbose "check_alias_available returning $alias_available_saved" 2
271 return $alias_available_saved
274 # Returns true if --gc-sections is supported on the target.
276 proc check_gc_sections_available { } {
277 global gc_sections_available_saved
278 global tool
280 if {![info exists gc_sections_available_saved]} {
281 # Some targets don't support gc-sections despite whatever's
282 # advertised by ld's options.
283 if { [istarget alpha*-*-*]
284 || [istarget ia64-*-*] } {
285 set gc_sections_available_saved 0
286 return 0
289 # elf2flt uses -q (--emit-relocs), which is incompatible with
290 # --gc-sections.
291 if { [board_info target exists ldflags]
292 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
293 set gc_sections_available_saved 0
294 return 0
297 # VxWorks kernel modules are relocatable objects linked with -r,
298 # while RTP executables are linked with -q (--emit-relocs).
299 # Both of these options are incompatible with --gc-sections.
300 if { [istarget *-*-vxworks*] } {
301 set gc_sections_available_saved 0
302 return 0
305 # Check if the ld used by gcc supports --gc-sections.
306 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
307 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
308 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
309 set ld_output [remote_exec host "$gcc_ld" "--help"]
310 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
311 set gc_sections_available_saved 1
312 } else {
313 set gc_sections_available_saved 0
316 return $gc_sections_available_saved
319 # Return true if profiling is supported on the target.
321 proc check_profiling_available { test_what } {
322 global profiling_available_saved
324 verbose "Profiling argument is <$test_what>" 1
326 # These conditions depend on the argument so examine them before
327 # looking at the cache variable.
329 # Support for -p on solaris2 relies on mcrt1.o which comes with the
330 # vendor compiler. We cannot reliably predict the directory where the
331 # vendor compiler (and thus mcrt1.o) is installed so we can't
332 # necessarily find mcrt1.o even if we have it.
333 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
334 return 0
337 # Support for -p on irix relies on libprof1.a which doesn't appear to
338 # exist on any irix6 system currently posting testsuite results.
339 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
340 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
341 if { [istarget mips*-*-irix*]
342 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
343 return 0
346 # At present, there is no profiling support on NetWare.
347 if { [istarget *-*-netware*] } {
348 return 0
351 # uClibc does not have gcrt1.o.
352 if { [check_effective_target_uclibc]
353 && ([lindex $test_what 1] == "-p"
354 || [lindex $test_what 1] == "-pg") } {
355 return 0
358 # Now examine the cache variable.
359 if {![info exists profiling_available_saved]} {
360 # Some targets don't have any implementation of __bb_init_func or are
361 # missing other needed machinery.
362 if { [istarget mmix-*-*]
363 || [istarget arm*-*-eabi*]
364 || [istarget arm*-*-elf]
365 || [istarget arm*-*-symbianelf*]
366 || [istarget bfin-*-*]
367 || [istarget powerpc-*-eabi*]
368 || [istarget strongarm*-*-elf]
369 || [istarget xscale*-*-elf]
370 || [istarget cris-*-*]
371 || [istarget fido-*-elf]
372 || [istarget h8300-*-*]
373 || [istarget m32c-*-elf]
374 || [istarget m68k-*-elf]
375 || [istarget m68k-*-uclinux*]
376 || [istarget mips*-*-elf*]
377 || [istarget xtensa-*-elf]
378 || [istarget *-*-vxworks*]
379 || [istarget *-*-windiss] } {
380 set profiling_available_saved 0
381 } else {
382 set profiling_available_saved 1
386 return $profiling_available_saved
389 # Return 1 if target has packed layout of structure members by
390 # default, 0 otherwise. Note that this is slightly different than
391 # whether the target has "natural alignment": both attributes may be
392 # false.
394 proc check_effective_target_default_packed { } {
395 return [check_no_compiler_messages default_packed assembly {
396 struct x { char a; long b; } c;
397 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
401 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
402 # documentation, where the test also comes from.
404 proc check_effective_target_pcc_bitfield_type_matters { } {
405 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
406 # bitfields, but let's stick to the example code from the docs.
407 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
408 struct foo1 { char x; char :0; char y; };
409 struct foo2 { char x; int :0; char y; };
410 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
414 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
416 # This won't change for different subtargets so cache the result.
418 proc check_effective_target_tls {} {
419 global et_tls_saved
420 global tool
422 if [info exists et_tls_saved] {
423 verbose "check_effective_target_tls: using cached result" 2
424 } else {
425 set et_tls_saved 0
427 set src tls[pid].c
428 set asm tls[pid].S
429 verbose "check_effective_target_tls: compiling testfile $src" 2
430 set f [open $src "w"]
431 # Compile a small test program. Make sure that we test accesses
432 # as well as declarations.
433 puts $f "__thread int i;\n"
434 puts $f "int f (void) { return i; }\n"
435 puts $f "void g (int j) { i = j; }\n"
436 close $f
438 # Test for thread-local data supported by the platform.
439 set comp_output \
440 [${tool}_target_compile $src $asm assembly ""]
441 file delete $src
442 if { [string match "" $comp_output] } {
443 # No error messages, everything is OK.
444 set et_tls_saved 1
446 remove-build-file $asm
448 verbose "check_effective_target_tls: returning $et_tls_saved" 2
449 return $et_tls_saved
452 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
454 # This won't change for different subtargets so cache the result.
456 proc check_effective_target_tls_native {} {
457 global et_tls_native_saved
458 global tool
460 if [info exists et_tls_saved] {
461 verbose "check_effective_target_tls_native: using cached result" 2
462 } else {
463 set et_tls_native_saved 0
465 set src tls[pid].c
466 set asm tls[pid].S
467 verbose "check_effective_target_tls_native: compiling testfile $src" 2
468 set f [open $src "w"]
469 # Compile a small test program. Make sure that we test accesses
470 # as well as declarations.
471 puts $f "__thread int i;\n"
472 puts $f "int f (void) { return i; }\n"
473 puts $f "void g (int j) { i = j; }\n"
474 close $f
476 # Test for thread-local data supported by the platform.
477 set comp_output [${tool}_target_compile $src $asm assembly ""]
478 file delete $src
479 if { [string match "" $comp_output] } {
480 # No error messages, everything is OK.
481 set fd [open $asm r]
482 set text [read $fd]
483 close $fd
484 if { [string match "*emutls*" $text]} {
485 set et_tls_native_saved 0
486 } else {
487 set et_tls_native_saved 1
490 remove-build-file $asm
492 verbose "check_effective_target_tls_native: returning $et_tls_native_saved" 2
493 return $et_tls_native_saved
496 # Return 1 if TLS executables can run correctly, 0 otherwise.
498 # This won't change for different subtargets so cache the result.
500 proc check_effective_target_tls_runtime {} {
501 global et_tls_runtime_saved
502 global tool
504 if [info exists et_tls_runtime_saved] {
505 verbose "check_effective_target_tls_runtime: using cached result" 2
506 } else {
507 set et_tls_runtime_saved 0
509 set src tls_runtime[pid].c
510 set exe tls_runtime[pid].x
511 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
512 set f [open $src "w"]
513 # Compile a small test program.
514 puts $f "__thread int thr = 0;\n"
515 puts $f "int main(void)\n {\n return thr;\n}"
516 close $f
518 set comp_output \
519 [${tool}_target_compile $src $exe executable ""]
520 file delete $src
522 if [string match "" $comp_output] then {
523 # No error messages, everything is OK.
525 set result [remote_load target "./$exe" "" ""]
526 set status [lindex $result 0]
527 remote_file build delete $exe
529 verbose "check_effective_target_tls_runtime status is <$status>" 2
531 if { $status == "pass" } {
532 set et_tls_runtime_saved 1
535 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
539 return $et_tls_runtime_saved
542 # Return 1 if compilation with -fopenmp is error-free for trivial
543 # code, 0 otherwise.
545 proc check_effective_target_fopenmp {} {
546 return [check_no_compiler_messages fopenmp object {
547 void foo (void) { }
548 } "-fopenmp"]
551 # Return 1 if the target supports -fstack-protector
552 proc check_effective_target_fstack_protector {} {
553 global tool
554 set result ""
556 set src stack_prot[pid].c
557 set exe stack_prot[pid].x
559 verbose "check_effective_target_fstack_protector compiling testfile $src" 2
561 set f [open $src "w"]
562 # Compile a small test program.
563 puts $f "int main (void)\n { return 0; }\n"
564 close $f
566 set opts "additional_flags=-fstack-protector"
567 set lines [${tool}_target_compile $src $exe executable "$opts" ]
568 file delete $src
570 if [string match "" $lines] then {
571 # No error messages, everything is OK.
572 set result [${tool}_load "./$exe" "" ""]
573 set status [lindex $result 0]
574 remote_file build delete $exe
575 verbose "check_iconv_available status is <$status>" 2
577 if { $status == "pass" } then {
578 return 1
581 return 0
584 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
585 # for trivial code, 0 otherwise.
587 proc check_effective_target_freorder {} {
588 return [check_no_compiler_messages freorder object {
589 void foo (void) { }
590 } "-freorder-blocks-and-partition"]
593 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
594 # emitted, 0 otherwise. Whether a shared library can actually be built is
595 # out of scope for this test.
597 proc check_effective_target_fpic { } {
598 # Note that M68K has a multilib that supports -fpic but not
599 # -fPIC, so we need to check both. We test with a program that
600 # requires GOT references.
601 foreach arg {fpic fPIC} {
602 if [check_no_compiler_messages $arg object {
603 extern int foo (void); extern int bar;
604 int baz (void) { return foo () + bar; }
605 } "-$arg"] {
606 return 1
609 return 0
612 # Return true if the target supports -mpaired-single (as used on MIPS).
614 proc check_effective_target_mpaired_single { } {
615 return [check_no_compiler_messages mpaired_single object {
616 void foo (void) { }
617 } "-mpaired-single"]
620 # Return true if the target is a 64-bit MIPS target.
622 proc check_effective_target_mips64 { } {
623 return [check_no_compiler_messages mips64 assembly {
624 #ifndef __mips64
625 #error FOO
626 #endif
630 # Return 1 if the current multilib does not generate PIC by default.
632 proc check_effective_target_nonpic { } {
633 return [check_no_compiler_messages nonpic assembly {
634 #if __PIC__
635 #error FOO
636 #endif
640 # Return 1 if the target does not use a status wrapper.
642 proc check_effective_target_unwrapped { } {
643 if { [target_info needs_status_wrapper] != "" \
644 && [target_info needs_status_wrapper] != "0" } {
645 return 0
647 return 1
650 # Return true if iconv is supported on the target. In particular IBM1047.
652 proc check_iconv_available { test_what } {
653 global tool
654 global libiconv
656 set result ""
658 set src iconv[pid].c
659 set exe iconv[pid].x
660 verbose "check_iconv_available compiling testfile $src" 2
661 set f [open $src "w"]
662 # Compile a small test program.
663 puts $f "#include <iconv.h>\n"
664 puts $f "int main (void)\n {\n iconv_t cd; \n"
665 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
666 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
667 puts $f "return 0;\n}"
668 close $f
670 # If the tool configuration file has not set libiconv, try "-liconv"
671 if { ![info exists libiconv] } {
672 set libiconv "-liconv"
674 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
675 file delete $src
677 if [string match "" $lines] then {
678 # No error messages, everything is OK.
680 set result [${tool}_load "./$exe" "" ""]
681 set status [lindex $result 0]
682 remote_file build delete $exe
684 verbose "check_iconv_available status is <$status>" 2
686 if { $status == "pass" } then {
687 return 1
691 return 0
694 # Return true if named sections are supported on this target.
696 proc check_named_sections_available { } {
697 return [check_no_compiler_messages named_sections assembly {
698 int __attribute__ ((section("whatever"))) foo;
702 # Return 1 if the target supports Fortran real kinds larger than real(8),
703 # 0 otherwise.
705 # When the target name changes, replace the cached result.
707 proc check_effective_target_fortran_large_real { } {
708 global et_fortran_large_real_saved
709 global et_fortran_large_real_target_name
710 global tool
712 if { ![info exists et_fortran_large_real_target_name] } {
713 set et_fortran_large_real_target_name ""
716 # If the target has changed since we set the cached value, clear it.
717 set current_target [current_target_name]
718 if { $current_target != $et_fortran_large_real_target_name } {
719 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
720 set et_fortran_large_real_target_name $current_target
721 if [info exists et_fortran_large_real_saved] {
722 verbose "check_effective_target_fortran_large_real: removing cached result" 2
723 unset et_fortran_large_real_saved
727 if [info exists et_fortran_large_real_saved] {
728 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
729 } else {
730 set et_fortran_large_real_saved 0
732 # Set up, compile, and execute a test program using large real
733 # kinds. Include the current process ID in the file names to
734 # prevent conflicts with invocations for multiple testsuites.
735 set src real[pid].f90
736 set exe real[pid].x
738 set f [open $src "w"]
739 puts $f "integer,parameter :: k = &"
740 puts $f " selected_real_kind (precision (0.0_8) + 1)"
741 puts $f "real(kind=k) :: x"
742 puts $f "x = cos (x);"
743 puts $f "end"
744 close $f
746 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
747 set lines [${tool}_target_compile $src $exe executable ""]
748 file delete $src
750 if [string match "" $lines] then {
751 # No error message, compilation succeeded.
752 remote_file build delete $exe
753 set et_fortran_large_real_saved 1
757 return $et_fortran_large_real_saved
760 # Return 1 if the target supports Fortran integer kinds larger than
761 # integer(8), 0 otherwise.
763 # When the target name changes, replace the cached result.
765 proc check_effective_target_fortran_large_int { } {
766 global et_fortran_large_int_saved
767 global et_fortran_large_int_target_name
768 global tool
770 if { ![info exists et_fortran_large_int_target_name] } {
771 set et_fortran_large_int_target_name ""
774 # If the target has changed since we set the cached value, clear it.
775 set current_target [current_target_name]
776 if { $current_target != $et_fortran_large_int_target_name } {
777 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
778 set et_fortran_large_int_target_name $current_target
779 if [info exists et_fortran_large_int_saved] {
780 verbose "check_effective_target_fortran_large_int: removing cached result" 2
781 unset et_fortran_large_int_saved
785 if [info exists et_fortran_large_int_saved] {
786 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
787 } else {
788 set et_fortran_large_int_saved 0
790 # Set up, compile, and execute a test program using large integer
791 # kinds. Include the current process ID in the file names to
792 # prevent conflicts with invocations for multiple testsuites.
793 set src int[pid].f90
794 set exe int[pid].x
796 set f [open $src "w"]
797 puts $f "integer,parameter :: k = &"
798 puts $f " selected_int_kind (range (0_8) + 1)"
799 puts $f "integer(kind=k) :: i"
800 puts $f "end"
801 close $f
803 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
804 set lines [${tool}_target_compile $src $exe executable ""]
805 file delete $src
807 if [string match "" $lines] then {
808 # No error message, compilation succeeded.
809 remote_file build delete $exe
810 set et_fortran_large_int_saved 1
814 return $et_fortran_large_int_saved
817 # Return 1 if we can statically link libgfortran, 0 otherwise.
819 # When the target name changes, replace the cached result.
821 proc check_effective_target_static_libgfortran { } {
822 global et_static_libgfortran
823 global et_static_libgfortran_target_name
824 global tool
826 if { ![info exists et_static_libgfortran_target_name] } {
827 set et_static_libgfortran_target_name ""
830 # If the target has changed since we set the cached value, clear it.
831 set current_target [current_target_name]
832 if { $current_target != $et_static_libgfortran_target_name } {
833 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
834 set et_static_libgfortran_target_name $current_target
835 if [info exists et_static_libgfortran_saved] {
836 verbose "check_effective_target_static_libgfortran: removing cached result" 2
837 unset et_static_libgfortran_saved
841 if [info exists et_static_libgfortran_saved] {
842 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
843 } else {
844 set et_static_libgfortran_saved 0
846 # Set up, compile, and execute a test program using static linking.
847 # Include the current process ID in the file names to prevent
848 # conflicts with invocations for multiple testsuites.
849 set opts "additional_flags=-static"
850 set src static[pid].f
851 set exe static[pid].x
853 set f [open $src "w"]
854 puts $f " print *, 'test'"
855 puts $f " end"
856 close $f
858 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
859 set lines [${tool}_target_compile $src $exe executable "$opts"]
860 file delete $src
862 if [string match "" $lines] then {
863 # No error message, compilation succeeded.
864 remote_file build delete $exe
865 set et_static_libgfortran_saved 1
869 return $et_static_libgfortran_saved
872 # Return 1 if the target supports executing AltiVec instructions, 0
873 # otherwise. Cache the result.
875 proc check_vmx_hw_available { } {
876 global vmx_hw_available_saved
877 global tool
879 if [info exists vmx_hw_available_saved] {
880 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
881 } else {
882 set vmx_hw_available_saved 0
884 # Some simulators are known to not support VMX instructions.
885 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
886 verbose "check_hw_available returning 0" 2
887 return $vmx_hw_available_saved
890 # Set up, compile, and execute a test program containing VMX
891 # instructions. Include the current process ID in the file
892 # names to prevent conflicts with invocations for multiple
893 # testsuites.
894 set src vmx[pid].c
895 set exe vmx[pid].x
897 set f [open $src "w"]
898 puts $f "int main() {"
899 puts $f "#ifdef __MACH__"
900 puts $f " asm volatile (\"vor v0,v0,v0\");"
901 puts $f "#else"
902 puts $f " asm volatile (\"vor 0,0,0\");"
903 puts $f "#endif"
904 puts $f " return 0; }"
905 close $f
907 # Most targets don't require special flags for this test case, but
908 # Darwin does.
909 if [istarget *-*-darwin*] {
910 set opts "additional_flags=-maltivec"
911 } else {
912 set opts ""
915 verbose "check_vmx_hw_available compiling testfile $src" 2
916 set lines [${tool}_target_compile $src $exe executable "$opts"]
917 file delete $src
919 if [string match "" $lines] then {
920 # No error message, compilation succeeded.
921 set result [${tool}_load "./$exe" "" ""]
922 set status [lindex $result 0]
923 remote_file build delete $exe
924 verbose "check_vmx_hw_available testfile status is <$status>" 2
926 if { $status == "pass" } then {
927 set vmx_hw_available_saved 1
929 } else {
930 verbose "check_vmx_hw_availalble testfile compilation failed" 2
934 return $vmx_hw_available_saved
937 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
938 # complex float arguments. This affects gfortran tests that call cabsf
939 # in libm built by an earlier compiler. Return 1 if libm uses the same
940 # argument passing as the compiler under test, 0 otherwise.
942 # When the target name changes, replace the cached result.
944 proc check_effective_target_broken_cplxf_arg { } {
945 global et_broken_cplxf_arg_saved
946 global et_broken_cplxf_arg_target_name
947 global tool
949 # Skip the work for targets known not to be affected.
950 if { ![istarget powerpc64-*-linux*] } {
951 return 0
952 } elseif { [is-effective-target ilp32] } {
953 return 0
956 if { ![info exists et_broken_cplxf_arg_target_name] } {
957 set et_broken_cplxf_arg_target_name ""
960 # If the target has changed since we set the cached value, clear it.
961 set current_target [current_target_name]
962 if { $current_target != $et_broken_cplxf_arg_target_name } {
963 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
964 set et_broken_cplxf_arg_target_name $current_target
965 if [info exists et_broken_cplxf_arg_saved] {
966 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
967 unset et_broken_cplxf_arg_saved
971 if [info exists et_broken_cplxf_arg_saved] {
972 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
973 } else {
974 set et_broken_cplxf_arg_saved 0
975 # This is only known to affect one target.
976 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
977 set et_broken_cplxf_arg_saved 0
978 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
979 return $et_broken_cplxf_arg_saved
982 # Set up, compile, and execute a C test program that calls cabsf.
983 set src cabsf[pid].c
984 set exe cabsf[pid].x
986 set f [open $src "w"]
987 puts $f "#include <complex.h>"
988 puts $f "extern void abort (void);"
989 puts $f "float fabsf (float);"
990 puts $f "float cabsf (_Complex float);"
991 puts $f "int main ()"
992 puts $f "{"
993 puts $f " _Complex float cf;"
994 puts $f " float f;"
995 puts $f " cf = 3 + 4.0fi;"
996 puts $f " f = cabsf (cf);"
997 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
998 puts $f " return 0;"
999 puts $f "}"
1000 close $f
1002 set lines [${tool}_target_compile $src $exe executable "-lm"]
1003 file delete $src
1005 if [string match "" $lines] {
1006 # No error message, compilation succeeded.
1007 set result [${tool}_load "./$exe" "" ""]
1008 set status [lindex $result 0]
1009 remote_file build delete $exe
1011 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1013 if { $status != "pass" } {
1014 set et_broken_cplxf_arg_saved 1
1016 } else {
1017 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1020 return $et_broken_cplxf_arg_saved
1023 proc check_alpha_max_hw_available { } {
1024 global alpha_max_hw_available_saved
1025 global tool
1027 if [info exists alpha_max_hw_available_saved] {
1028 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1029 } else {
1030 set alpha_max_hw_available_saved 0
1032 # Set up, compile, and execute a test program probing bit 8 of the
1033 # architecture mask, which indicates presence of MAX instructions.
1034 set src max[pid].c
1035 set exe max[pid].x
1037 set f [open $src "w"]
1038 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1039 close $f
1041 verbose "check_alpha_max_hw_available compiling testfile $src" 2
1042 set lines [${tool}_target_compile $src $exe executable ""]
1043 file delete $src
1045 if [string match "" $lines] then {
1046 # No error message, compilation succeeded.
1047 set result [${tool}_load "./$exe" "" ""]
1048 set status [lindex $result 0]
1049 remote_file build delete $exe
1050 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1052 if { $status == "pass" } then {
1053 set alpha_max_hw_available_saved 1
1055 } else {
1056 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1060 return $alpha_max_hw_available_saved
1063 # Returns true iff the FUNCTION is available on the target system.
1064 # (This is essentially a Tcl implementation of Autoconf's
1065 # AC_CHECK_FUNC.)
1067 proc check_function_available { function } {
1068 set var "${function}_available_saved"
1069 global $var
1070 global tool
1072 if {![info exists $var]} {
1073 # Assume it exists.
1074 set $var 1
1075 # Check to make sure.
1076 set src "function[pid].c"
1077 set exe "function[pid].exe"
1079 set f [open $src "w"]
1080 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1081 puts $f "char $function ();\n"
1082 puts $f "int main () { $function (); }"
1083 close $f
1085 set lines [${tool}_target_compile $src $exe executable ""]
1086 file delete $src
1087 file delete $exe
1089 if {![string match "" $lines]} then {
1090 set $var 0
1091 verbose -log "$function is not available"
1092 } else {
1093 verbose -log "$function is available"
1097 eval return \$$var
1100 # Returns true iff "fork" is available on the target system.
1102 proc check_fork_available {} {
1103 return [check_function_available "fork"]
1106 # Returns true iff "mkfifo" is available on the target system.
1108 proc check_mkfifo_available {} {
1109 if {[istarget *-*-cygwin*]} {
1110 # Cygwin has mkfifo, but support is incomplete.
1111 return 0
1114 return [check_function_available "mkfifo"]
1117 # Returns true iff "__cxa_atexit" is used on the target system.
1119 proc check_cxa_atexit_available { } {
1120 global et_cxa_atexit
1121 global et_cxa_atexit_target_name
1122 global tool
1124 if { ![info exists et_cxa_atexit_target_name] } {
1125 set et_cxa_atexit_target_name ""
1128 # If the target has changed since we set the cached value, clear it.
1129 set current_target [current_target_name]
1130 if { $current_target != $et_cxa_atexit_target_name } {
1131 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1132 set et_cxa_atexit_target_name $current_target
1133 if [info exists et_cxa_atexit] {
1134 verbose "check_cxa_atexit_available: removing cached result" 2
1135 unset et_cxa_atexit
1139 if [info exists et_cxa_atexit] {
1140 verbose "check_cxa_atexit_available: using cached result" 2
1141 } elseif { [istarget "hppa*-*-hpux10*"] } {
1142 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1143 set et_cxa_atexit 0
1144 } else {
1145 set et_cxa_atexit 0
1147 # Set up, compile, and execute a C++ test program that depends
1148 # on correct ordering of static object destructors. This is
1149 # indicative of the presence and use of __cxa_atexit.
1150 set src cxaatexit[pid].cc
1151 set exe cxaatexit[pid].x
1153 set f [open $src "w"]
1154 puts $f "#include <stdlib.h>"
1155 puts $f "static unsigned int count;"
1156 puts $f "struct X"
1157 puts $f "{"
1158 puts $f " X() { count = 1; }"
1159 puts $f " ~X()"
1160 puts $f " {"
1161 puts $f " if (count != 3)"
1162 puts $f " exit(1);"
1163 puts $f " count = 4;"
1164 puts $f " }"
1165 puts $f "};"
1166 puts $f "void f()"
1167 puts $f "{"
1168 puts $f " static X x;"
1169 puts $f "}"
1170 puts $f "struct Y"
1171 puts $f "{"
1172 puts $f " Y() { f(); count = 2; }"
1173 puts $f " ~Y()"
1174 puts $f " {"
1175 puts $f " if (count != 2)"
1176 puts $f " exit(1);"
1177 puts $f " count = 3;"
1178 puts $f " }"
1179 puts $f "};"
1180 puts $f "Y y;"
1181 puts $f "int main()"
1182 puts $f "{ return 0; }"
1183 close $f
1185 set lines [${tool}_target_compile $src $exe executable ""]
1186 file delete $src
1188 if [string match "" $lines] {
1189 # No error message, compilation succeeded.
1190 set result [${tool}_load "./$exe" "" ""]
1191 set status [lindex $result 0]
1192 remote_file build delete $exe
1194 verbose "check_cxa_atexit_available: status is <$status>" 2
1196 if { $status == "pass" } {
1197 set et_cxa_atexit 1
1199 } else {
1200 verbose "check_cxa_atexit_available: compilation failed" 2
1203 return $et_cxa_atexit
1207 # Return 1 if we're generating 32-bit code using default options, 0
1208 # otherwise.
1210 proc check_effective_target_ilp32 { } {
1211 return [check_no_compiler_messages ilp32 object {
1212 int dummy[sizeof (int) == 4
1213 && sizeof (void *) == 4
1214 && sizeof (long) == 4 ? 1 : -1];
1218 # Return 1 if we're generating 32-bit or larger integers using default
1219 # options, 0 otherwise.
1221 proc check_effective_target_int32plus { } {
1222 return [check_no_compiler_messages int32plus object {
1223 int dummy[sizeof (int) >= 4 ? 1 : -1];
1227 # Return 1 if we're generating 32-bit or larger pointers using default
1228 # options, 0 otherwise.
1230 proc check_effective_target_ptr32plus { } {
1231 return [check_no_compiler_messages ptr32plus object {
1232 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1236 # Return 1 if we support 32-bit or larger array and structure sizes
1237 # using default options, 0 otherwise.
1239 proc check_effective_target_size32plus { } {
1240 return [check_no_compiler_messages size32plus object {
1241 char dummy[65537];
1245 # Returns 1 if we're generating 16-bit or smaller integers with the
1246 # default options, 0 otherwise.
1248 proc check_effective_target_int16 { } {
1249 return [check_no_compiler_messages int16 object {
1250 int dummy[sizeof (int) < 4 ? 1 : -1];
1254 # Return 1 if we're generating 64-bit code using default options, 0
1255 # otherwise.
1257 proc check_effective_target_lp64 { } {
1258 return [check_no_compiler_messages lp64 object {
1259 int dummy[sizeof (int) == 4
1260 && sizeof (void *) == 8
1261 && sizeof (long) == 8 ? 1 : -1];
1265 # Return 1 if the target supports long double larger than double,
1266 # 0 otherwise.
1268 proc check_effective_target_large_long_double { } {
1269 return [check_no_compiler_messages large_long_double object {
1270 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1274 # Return 1 if the target supports compiling fixed-point,
1275 # 0 otherwise.
1277 proc check_effective_target_fixed_point { } {
1278 return [check_no_compiler_messages fixed_point object {
1279 _Sat _Fract x; _Sat _Accum y;
1283 # Return 1 if the target supports compiling decimal floating point,
1284 # 0 otherwise.
1286 proc check_effective_target_dfp_nocache { } {
1287 verbose "check_effective_target_dfp_nocache: compiling source" 2
1288 set ret [string match "" [get_compiler_messages dfp 0 object {
1289 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1291 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1292 return $ret
1295 proc check_effective_target_dfprt_nocache { } {
1296 global tool
1298 set ret 0
1300 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1301 # Set up, compile, and execute a test program containing decimal
1302 # float operations.
1303 set src dfprt[pid].c
1304 set exe dfprt[pid].x
1306 set f [open $src "w"]
1307 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1308 puts $f "int main () { z = x + y; return 0; }"
1309 close $f
1311 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1312 set lines [${tool}_target_compile $src $exe executable ""]
1313 file delete $src
1315 if [string match "" $lines] then {
1316 # No error message, compilation succeeded.
1317 set result [${tool}_load "./$exe" "" ""]
1318 set status [lindex $result 0]
1319 remote_file build delete $exe
1320 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1321 if { $status == "pass" } then {
1322 set ret 1
1325 return $ret
1326 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1329 # Return 1 if the target supports compiling Decimal Floating Point,
1330 # 0 otherwise.
1332 # This won't change for different subtargets so cache the result.
1334 proc check_effective_target_dfp { } {
1335 global et_dfp_saved
1337 if [info exists et_dfp_saved] {
1338 verbose "check_effective_target_dfp: using cached result" 2
1339 } else {
1340 set et_dfp_saved [check_effective_target_dfp_nocache]
1342 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1343 return $et_dfp_saved
1346 # Return 1 if the target supports linking and executing Decimal Floating
1347 # Point, # 0 otherwise.
1349 # This won't change for different subtargets so cache the result.
1351 proc check_effective_target_dfprt { } {
1352 global et_dfprt_saved
1353 global tool
1355 if [info exists et_dfprt_saved] {
1356 verbose "check_effective_target_dfprt: using cached result" 2
1357 } else {
1358 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1360 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1361 return $et_dfprt_saved
1364 # Return 1 if the target needs a command line argument to enable a SIMD
1365 # instruction set.
1367 proc check_effective_target_vect_cmdline_needed { } {
1368 global et_vect_cmdline_needed_saved
1369 global et_vect_cmdline_needed_target_name
1371 if { ![info exists et_vect_cmdline_needed_target_name] } {
1372 set et_vect_cmdline_needed_target_name ""
1375 # If the target has changed since we set the cached value, clear it.
1376 set current_target [current_target_name]
1377 if { $current_target != $et_vect_cmdline_needed_target_name } {
1378 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1379 set et_vect_cmdline_needed_target_name $current_target
1380 if { [info exists et_vect_cmdline_needed_saved] } {
1381 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1382 unset et_vect_cmdline_needed_saved
1386 if [info exists et_vect_cmdline_needed_saved] {
1387 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1388 } else {
1389 set et_vect_cmdline_needed_saved 1
1390 if { [istarget ia64-*-*]
1391 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1392 && [check_effective_target_lp64])
1393 || ([istarget powerpc*-*-*]
1394 && ([check_effective_target_powerpc_spe]
1395 || [check_effective_target_powerpc_altivec]))} {
1396 set et_vect_cmdline_needed_saved 0
1400 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1401 return $et_vect_cmdline_needed_saved
1404 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1406 # This won't change for different subtargets so cache the result.
1408 proc check_effective_target_vect_int { } {
1409 global et_vect_int_saved
1411 if [info exists et_vect_int_saved] {
1412 verbose "check_effective_target_vect_int: using cached result" 2
1413 } else {
1414 set et_vect_int_saved 0
1415 if { [istarget i?86-*-*]
1416 || [istarget powerpc*-*-*]
1417 || [istarget spu-*-*]
1418 || [istarget x86_64-*-*]
1419 || [istarget sparc*-*-*]
1420 || [istarget alpha*-*-*]
1421 || [istarget ia64-*-*] } {
1422 set et_vect_int_saved 1
1426 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1427 return $et_vect_int_saved
1430 # Return 1 if the target supports int->float conversion
1433 proc check_effective_target_vect_intfloat_cvt { } {
1434 global et_vect_intfloat_cvt_saved
1436 if [info exists et_vect_intfloat_cvt_saved] {
1437 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1438 } else {
1439 set et_vect_intfloat_cvt_saved 0
1440 if { [istarget i?86-*-*]
1441 || [istarget powerpc*-*-*]
1442 || [istarget x86_64-*-*] } {
1443 set et_vect_intfloat_cvt_saved 1
1447 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1448 return $et_vect_intfloat_cvt_saved
1452 # Return 1 if the target supports float->int conversion
1455 proc check_effective_target_vect_floatint_cvt { } {
1456 global et_vect_floatint_cvt_saved
1458 if [info exists et_vect_floatint_cvt_saved] {
1459 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1460 } else {
1461 set et_vect_floatint_cvt_saved 0
1462 if { [istarget i?86-*-*]
1463 || [istarget x86_64-*-*] } {
1464 set et_vect_floatint_cvt_saved 1
1468 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1469 return $et_vect_floatint_cvt_saved
1473 # Return 1 is this is an arm target using 32-bit instructions
1474 proc check_effective_target_arm32 { } {
1475 return [check_no_compiler_messages arm32 assembly {
1476 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1477 #error FOO
1478 #endif
1482 # Return 1 if this is an ARM target supporting -mfpu=vfp
1483 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1484 # options.
1486 proc check_effective_target_arm_vfp_ok { } {
1487 if { [check_effective_target_arm32] } {
1488 return [check_no_compiler_messages arm_vfp_ok object {
1489 int dummy;
1490 } "-mfpu=vfp -mfloat-abi=softfp"]
1491 } else {
1492 return 0
1496 # Return 1 if this is an ARM target supporting -mfpu=neon
1497 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1498 # options.
1500 proc check_effective_target_arm_neon_ok { } {
1501 if { [check_effective_target_arm32] } {
1502 return [check_no_compiler_messages arm_neon_ok object {
1503 int dummy;
1504 } "-mfpu=neon -mfloat-abi=softfp"]
1505 } else {
1506 return 0
1510 # Return 1 if the target supports executing NEON instructions, 0
1511 # otherwise. Cache the result.
1513 proc check_effective_target_arm_neon_hw { } {
1514 global arm_neon_hw_available_saved
1515 global tool
1517 if [info exists arm_neon_hw_available_saved] {
1518 verbose "check_arm_neon_hw_available returning saved $arm_neon_hw_avail
1519 able_saved" 2
1520 } else {
1521 set arm_neon_hw_available_saved 0
1523 # Set up, compile, and execute a test program containing NEON
1524 # instructions. Include the current process ID in the file
1525 # names to prevent conflicts with invocations for multiple
1526 # testsuites.
1527 set src neon[pid].c
1528 set exe neon[pid].x
1530 set f [open $src "w"]
1531 puts $f "int main() {"
1532 puts $f " long long a = 0, b = 1;"
1533 puts $f " asm (\"vorr %P0, %P1, %P2\""
1534 puts $f " : \"=w\" (a)"
1535 puts $f " : \"0\" (a), \"w\" (b));"
1536 puts $f " return (a != 1);"
1537 puts $f "}"
1538 close $f
1540 set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1542 verbose "check_arm_neon_hw_available compiling testfile $src" 2
1543 set lines [${tool}_target_compile $src $exe executable "$opts"]
1544 file delete $src
1546 if [string match "" $lines] then {
1547 # No error message, compilation succeeded.
1548 set result [${tool}_load "./$exe" "" ""]
1549 set status [lindex $result 0]
1550 remote_file build delete $exe
1551 verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1553 if { $status == "pass" } then {
1554 set arm_neon_hw_available_saved 1
1556 } else {
1557 verbose "check_arm_neon_hw_available testfile compilation failed" 2
1561 return $arm_neon_hw_available_saved
1564 # Return 1 if this is a PowerPC target with floating-point registers.
1566 proc check_effective_target_powerpc_fprs { } {
1567 if { [istarget powerpc*-*-*]
1568 || [istarget rs6000-*-*] } {
1569 return [check_no_compiler_messages powerpc_fprs object {
1570 #ifdef __NO_FPRS__
1571 #error no FPRs
1572 #else
1573 int dummy;
1574 #endif
1576 } else {
1577 return 0
1581 # Return 1 if this is a PowerPC target supporting -maltivec.
1583 proc check_effective_target_powerpc_altivec_ok { } {
1584 if { [istarget powerpc*-*-*]
1585 || [istarget rs6000-*-*] } {
1586 # AltiVec is not supported on Aix.
1587 if { [istarget powerpc*-*-aix*] } {
1588 return 0
1590 return [check_no_compiler_messages powerpc_altivec_ok object {
1591 int dummy;
1592 } "-maltivec"]
1593 } else {
1594 return 0
1598 # Return 1 if this is a PowerPC target with SPE enabled.
1600 proc check_effective_target_powerpc_spe { } {
1601 if { [istarget powerpc*-*-*] } {
1602 return [check_no_compiler_messages powerpc_spe object {
1603 #ifndef __SPE__
1604 #error not SPE
1605 #else
1606 int dummy;
1607 #endif
1609 } else {
1610 return 0
1614 # Return 1 if this is a PowerPC target with Altivec enabled.
1616 proc check_effective_target_powerpc_altivec { } {
1617 if { [istarget powerpc*-*-*] } {
1618 return [check_no_compiler_messages powerpc_altivec object {
1619 #ifndef __ALTIVEC__
1620 #error not Altivec
1621 #else
1622 int dummy;
1623 #endif
1625 } else {
1626 return 0
1630 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1631 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1632 # test environment appears to run executables on such a simulator.
1634 proc check_effective_target_ultrasparc_hw { } {
1635 global et_ultrasparc_hw_saved
1636 global tool
1638 if [info exists et_ultrasparc_hw_saved] {
1639 verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1640 } else {
1641 set et_ultrasparc_hw_saved 0
1643 # Set up, compile, and execute a simple test program. The
1644 # program will be compiled with -mcpu=ultrasparc to instruct the
1645 # assembler to produce EM_SPARC32PLUS executables.
1646 set src svect[pid].c
1647 set exe svect[pid].x
1649 set f [open $src "w"]
1650 puts $f "int main() { return 0; }"
1651 close $f
1653 verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1654 set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1655 file delete $src
1657 if [string match "" $lines] then {
1658 # No error message, compilation succeeded.
1659 set result [${tool}_load "./$exe" "" ""]
1660 set status [lindex $result 0]
1661 remote_file build delete $exe
1662 verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1664 if { $status == "pass" } then {
1665 set et_ultrasparc_hw_saved 1
1667 } else {
1668 verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1672 return $et_ultrasparc_hw_saved
1675 # Return 1 if the target supports hardware vector shift operation.
1677 proc check_effective_target_vect_shift { } {
1678 global et_vect_shift_saved
1680 if [info exists et_vect_shift_saved] {
1681 verbose "check_effective_target_vect_shift: using cached result" 2
1682 } else {
1683 set et_vect_shift_saved 0
1684 if { [istarget powerpc*-*-*]
1685 || [istarget ia64-*-*]
1686 || [istarget i?86-*-*]
1687 || [istarget x86_64-*-*] } {
1688 set et_vect_shift_saved 1
1692 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1693 return $et_vect_shift_saved
1696 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1698 # This can change for different subtargets so do not cache the result.
1700 proc check_effective_target_vect_long { } {
1701 if { [istarget i?86-*-*]
1702 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1703 || [istarget x86_64-*-*]
1704 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1705 set answer 1
1706 } else {
1707 set answer 0
1710 verbose "check_effective_target_vect_long: returning $answer" 2
1711 return $answer
1714 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1716 # This won't change for different subtargets so cache the result.
1718 proc check_effective_target_vect_float { } {
1719 global et_vect_float_saved
1721 if [info exists et_vect_float_saved] {
1722 verbose "check_effective_target_vect_float: using cached result" 2
1723 } else {
1724 set et_vect_float_saved 0
1725 if { [istarget i?86-*-*]
1726 || [istarget powerpc*-*-*]
1727 || [istarget spu-*-*]
1728 || [istarget mipsisa64*-*-*]
1729 || [istarget x86_64-*-*]
1730 || [istarget ia64-*-*] } {
1731 set et_vect_float_saved 1
1735 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1736 return $et_vect_float_saved
1739 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1741 # This won't change for different subtargets so cache the result.
1743 proc check_effective_target_vect_double { } {
1744 global et_vect_double_saved
1746 if [info exists et_vect_double_saved] {
1747 verbose "check_effective_target_vect_double: using cached result" 2
1748 } else {
1749 set et_vect_double_saved 0
1750 if { [istarget i?86-*-*]
1751 || [istarget x86_64-*-*]
1752 || [istarget spu-*-*] } {
1753 set et_vect_double_saved 1
1757 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1758 return $et_vect_double_saved
1761 # Return 1 if the target plus current options does not support a vector
1762 # max instruction on "int", 0 otherwise.
1764 # This won't change for different subtargets so cache the result.
1766 proc check_effective_target_vect_no_int_max { } {
1767 global et_vect_no_int_max_saved
1769 if [info exists et_vect_no_int_max_saved] {
1770 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1771 } else {
1772 set et_vect_no_int_max_saved 0
1773 if { [istarget sparc*-*-*]
1774 || [istarget spu-*-*]
1775 || [istarget alpha*-*-*] } {
1776 set et_vect_no_int_max_saved 1
1779 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1780 return $et_vect_no_int_max_saved
1783 # Return 1 if the target plus current options does not support a vector
1784 # add instruction on "int", 0 otherwise.
1786 # This won't change for different subtargets so cache the result.
1788 proc check_effective_target_vect_no_int_add { } {
1789 global et_vect_no_int_add_saved
1791 if [info exists et_vect_no_int_add_saved] {
1792 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1793 } else {
1794 set et_vect_no_int_add_saved 0
1795 # Alpha only supports vector add on V8QI and V4HI.
1796 if { [istarget alpha*-*-*] } {
1797 set et_vect_no_int_add_saved 1
1800 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1801 return $et_vect_no_int_add_saved
1804 # Return 1 if the target plus current options does not support vector
1805 # bitwise instructions, 0 otherwise.
1807 # This won't change for different subtargets so cache the result.
1809 proc check_effective_target_vect_no_bitwise { } {
1810 global et_vect_no_bitwise_saved
1812 if [info exists et_vect_no_bitwise_saved] {
1813 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1814 } else {
1815 set et_vect_no_bitwise_saved 0
1817 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1818 return $et_vect_no_bitwise_saved
1821 # Return 1 if the target plus current options supports a vector
1822 # widening summation of *short* args into *int* result, 0 otherwise.
1823 # A target can also support this widening summation if it can support
1824 # promotion (unpacking) from shorts to ints.
1826 # This won't change for different subtargets so cache the result.
1828 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1829 global et_vect_widen_sum_hi_to_si
1831 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1832 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1833 } else {
1834 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1835 if { [istarget powerpc*-*-*]
1836 || [istarget ia64-*-*] } {
1837 set et_vect_widen_sum_hi_to_si_saved 1
1840 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1841 return $et_vect_widen_sum_hi_to_si_saved
1844 # Return 1 if the target plus current options supports a vector
1845 # widening summation of *char* args into *short* result, 0 otherwise.
1846 # A target can also support this widening summation if it can support
1847 # promotion (unpacking) from chars to shorts.
1849 # This won't change for different subtargets so cache the result.
1851 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1852 global et_vect_widen_sum_qi_to_hi
1854 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1855 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1856 } else {
1857 set et_vect_widen_sum_qi_to_hi_saved 0
1858 if { [check_effective_target_vect_unpack]
1859 || [istarget ia64-*-*] } {
1860 set et_vect_widen_sum_qi_to_hi_saved 1
1863 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1864 return $et_vect_widen_sum_qi_to_hi_saved
1867 # Return 1 if the target plus current options supports a vector
1868 # widening summation of *char* args into *int* result, 0 otherwise.
1870 # This won't change for different subtargets so cache the result.
1872 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1873 global et_vect_widen_sum_qi_to_si
1875 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1876 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1877 } else {
1878 set et_vect_widen_sum_qi_to_si_saved 0
1879 if { [istarget powerpc*-*-*] } {
1880 set et_vect_widen_sum_qi_to_si_saved 1
1883 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1884 return $et_vect_widen_sum_qi_to_si_saved
1887 # Return 1 if the target plus current options supports a vector
1888 # widening multiplication of *char* args into *short* result, 0 otherwise.
1889 # A target can also support this widening multplication if it can support
1890 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1891 # multiplication of shorts).
1893 # This won't change for different subtargets so cache the result.
1896 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1897 global et_vect_widen_mult_qi_to_hi
1899 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1900 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1901 } else {
1902 if { [check_effective_target_vect_unpack]
1903 && [check_effective_target_vect_short_mult] } {
1904 set et_vect_widen_mult_qi_to_hi_saved 1
1905 } else {
1906 set et_vect_widen_mult_qi_to_hi_saved 0
1908 if { [istarget powerpc*-*-*] } {
1909 set et_vect_widen_mult_qi_to_hi_saved 1
1912 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1913 return $et_vect_widen_mult_qi_to_hi_saved
1916 # Return 1 if the target plus current options supports a vector
1917 # widening multiplication of *short* args into *int* result, 0 otherwise.
1918 # A target can also support this widening multplication if it can support
1919 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1920 # multiplication of ints).
1922 # This won't change for different subtargets so cache the result.
1925 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1926 global et_vect_widen_mult_hi_to_si
1928 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1929 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1930 } else {
1931 if { [check_effective_target_vect_unpack]
1932 && [check_effective_target_vect_int_mult] } {
1933 set et_vect_widen_mult_hi_to_si_saved 1
1934 } else {
1935 set et_vect_widen_mult_hi_to_si_saved 0
1937 if { [istarget powerpc*-*-*]
1938 || [istarget spu-*-*]
1939 || [istarget i?86-*-*]
1940 || [istarget x86_64-*-*] } {
1941 set et_vect_widen_mult_hi_to_si_saved 1
1944 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1945 return $et_vect_widen_mult_hi_to_si_saved
1948 # Return 1 if the target plus current options supports a vector
1949 # dot-product of signed chars, 0 otherwise.
1951 # This won't change for different subtargets so cache the result.
1953 proc check_effective_target_vect_sdot_qi { } {
1954 global et_vect_sdot_qi
1956 if [info exists et_vect_sdot_qi_saved] {
1957 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1958 } else {
1959 set et_vect_sdot_qi_saved 0
1961 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1962 return $et_vect_sdot_qi_saved
1965 # Return 1 if the target plus current options supports a vector
1966 # dot-product of unsigned chars, 0 otherwise.
1968 # This won't change for different subtargets so cache the result.
1970 proc check_effective_target_vect_udot_qi { } {
1971 global et_vect_udot_qi
1973 if [info exists et_vect_udot_qi_saved] {
1974 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1975 } else {
1976 set et_vect_udot_qi_saved 0
1977 if { [istarget powerpc*-*-*] } {
1978 set et_vect_udot_qi_saved 1
1981 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1982 return $et_vect_udot_qi_saved
1985 # Return 1 if the target plus current options supports a vector
1986 # dot-product of signed shorts, 0 otherwise.
1988 # This won't change for different subtargets so cache the result.
1990 proc check_effective_target_vect_sdot_hi { } {
1991 global et_vect_sdot_hi
1993 if [info exists et_vect_sdot_hi_saved] {
1994 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1995 } else {
1996 set et_vect_sdot_hi_saved 0
1997 if { [istarget powerpc*-*-*]
1998 || [istarget i?86-*-*]
1999 || [istarget x86_64-*-*] } {
2000 set et_vect_sdot_hi_saved 1
2003 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2004 return $et_vect_sdot_hi_saved
2007 # Return 1 if the target plus current options supports a vector
2008 # dot-product of unsigned shorts, 0 otherwise.
2010 # This won't change for different subtargets so cache the result.
2012 proc check_effective_target_vect_udot_hi { } {
2013 global et_vect_udot_hi
2015 if [info exists et_vect_udot_hi_saved] {
2016 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2017 } else {
2018 set et_vect_udot_hi_saved 0
2019 if { [istarget powerpc*-*-*] } {
2020 set et_vect_udot_hi_saved 1
2023 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2024 return $et_vect_udot_hi_saved
2028 # Return 1 if the target plus current options supports a vector
2029 # demotion (packing) of shorts (to chars) and ints (to shorts)
2030 # using modulo arithmetic, 0 otherwise.
2032 # This won't change for different subtargets so cache the result.
2034 proc check_effective_target_vect_pack_trunc { } {
2035 global et_vect_pack_trunc
2037 if [info exists et_vect_pack_trunc_saved] {
2038 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2039 } else {
2040 set et_vect_pack_trunc_saved 0
2041 if { [istarget powerpc*-*-*]
2042 || [istarget i?86-*-*]
2043 || [istarget x86_64-*-*] } {
2044 set et_vect_pack_trunc_saved 1
2047 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2048 return $et_vect_pack_trunc_saved
2051 # Return 1 if the target plus current options supports a vector
2052 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2054 # This won't change for different subtargets so cache the result.
2056 proc check_effective_target_vect_unpack { } {
2057 global et_vect_unpack
2059 if [info exists et_vect_unpack_saved] {
2060 verbose "check_effective_target_vect_unpack: using cached result" 2
2061 } else {
2062 set et_vect_unpack_saved 0
2063 if { [istarget powerpc*-*-*]
2064 || [istarget i?86-*-*]
2065 || [istarget x86_64-*-*] } {
2066 set et_vect_unpack_saved 1
2069 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2070 return $et_vect_unpack_saved
2073 # Return 1 if the target plus current options does not support a vector
2074 # alignment mechanism, 0 otherwise.
2076 # This won't change for different subtargets so cache the result.
2078 proc check_effective_target_vect_no_align { } {
2079 global et_vect_no_align_saved
2081 if [info exists et_vect_no_align_saved] {
2082 verbose "check_effective_target_vect_no_align: using cached result" 2
2083 } else {
2084 set et_vect_no_align_saved 0
2085 if { [istarget mipsisa64*-*-*]
2086 || [istarget sparc*-*-*]
2087 || [istarget ia64-*-*] } {
2088 set et_vect_no_align_saved 1
2091 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2092 return $et_vect_no_align_saved
2095 # Return 1 if arrays are aligned to the vector alignment
2096 # boundary, 0 otherwise.
2098 # This won't change for different subtargets so cache the result.
2100 proc check_effective_target_vect_aligned_arrays { } {
2101 global et_vect_aligned_arrays
2103 if [info exists et_vect_aligned_arrays_saved] {
2104 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2105 } else {
2106 set et_vect_aligned_arrays_saved 0
2107 if { ([istarget x86_64-*-*]
2108 || [istarget i?86-*-*]) && [is-effective-target lp64] } {
2109 set et_vect_aligned_arrays_saved 1
2112 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2113 return $et_vect_aligned_arrays_saved
2116 # Return 1 if types are naturally aligned (aligned to their type-size),
2117 # 0 otherwise.
2119 # This won't change for different subtargets so cache the result.
2121 proc check_effective_target_natural_alignment { } {
2122 global et_natural_alignment
2124 if [info exists et_natural_alignment_saved] {
2125 verbose "check_effective_target_natural_alignment: using cached result" 2
2126 } else {
2127 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2128 set et_natural_alignment_saved 1
2129 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2130 set et_natural_alignment_saved 0
2133 verbose "check_effective_target_natural_alignment: returning $et_natural_alignment_saved" 2
2134 return $et_natural_alignment_saved
2137 # Return 1 if vector alignment is reachable, 0 otherwise.
2139 # This won't change for different subtargets so cache the result.
2141 proc check_effective_target_vector_alignment_reachable { } {
2142 global et_vector_alignment_reachable
2144 if [info exists et_vector_alignment_reachable_saved] {
2145 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2146 } else {
2147 if { [check_effective_target_vect_aligned_arrays]
2148 || [check_effective_target_natural_alignment] } {
2149 set et_vector_alignment_reachable_saved 1
2150 } else {
2151 set et_vector_alignment_reachable_saved 0
2154 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2155 return $et_vector_alignment_reachable_saved
2158 # Return 1 if vector alignment for soubles is reachable, 0 otherwise.
2160 # This won't change for different subtargets so cache the result.
2162 proc check_effective_target_vector_alignment_reachable_for_double { } {
2163 global et_vector_alignment_reachable_for_double
2165 if [info exists et_vector_alignment_reachable_for_double_saved] {
2166 verbose "check_effective_target_vector_alignment_reachable_for_double: using cached result" 2
2167 } else {
2168 if { [check_effective_target_vect_aligned_arrays] } {
2169 set et_vector_alignment_reachable_for_double_saved 1
2170 } else {
2171 set et_vector_alignment_reachable_for_double_saved 0
2174 verbose "check_effective_target_vector_alignment_reachable_for_double: returning $et_vector_alignment_reachable_for_double_saved" 2
2175 return $et_vector_alignment_reachable_for_double_saved
2178 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2180 proc check_effective_target_vect_condition { } {
2181 global et_vect_cond_saved
2183 if [info exists et_vect_cond_saved] {
2184 verbose "check_effective_target_vect_cond: using cached result" 2
2185 } else {
2186 set et_vect_cond_saved 0
2187 if { [istarget powerpc*-*-*]
2188 || [istarget ia64-*-*]
2189 || [istarget i?86-*-*]
2190 || [istarget spu-*-*]
2191 || [istarget x86_64-*-*] } {
2192 set et_vect_cond_saved 1
2196 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2197 return $et_vect_cond_saved
2200 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2202 proc check_effective_target_vect_char_mult { } {
2203 global et_vect_char_mult_saved
2205 if [info exists et_vect_char_mult_saved] {
2206 verbose "check_effective_target_vect_char_mult: using cached result" 2
2207 } else {
2208 set et_vect_char_mult_saved 0
2209 if { [istarget ia64-*-*]
2210 || [istarget i?86-*-*]
2211 || [istarget x86_64-*-*] } {
2212 set et_vect_char_mult_saved 1
2216 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2217 return $et_vect_char_mult_saved
2220 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2222 proc check_effective_target_vect_short_mult { } {
2223 global et_vect_short_mult_saved
2225 if [info exists et_vect_short_mult_saved] {
2226 verbose "check_effective_target_vect_short_mult: using cached result" 2
2227 } else {
2228 set et_vect_short_mult_saved 0
2229 if { [istarget ia64-*-*]
2230 || [istarget i?86-*-*]
2231 || [istarget x86_64-*-*] } {
2232 set et_vect_short_mult_saved 1
2236 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2237 return $et_vect_short_mult_saved
2240 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2242 proc check_effective_target_vect_int_mult { } {
2243 global et_vect_int_mult_saved
2245 if [info exists et_vect_int_mult_saved] {
2246 verbose "check_effective_target_vect_int_mult: using cached result" 2
2247 } else {
2248 set et_vect_int_mult_saved 0
2249 if { [istarget powerpc*-*-*]
2250 || [istarget spu-*-*]
2251 || [istarget i?86-*-*]
2252 || [istarget x86_64-*-*] } {
2253 set et_vect_int_mult_saved 1
2257 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2258 return $et_vect_int_mult_saved
2261 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2263 proc check_effective_target_vect_extract_even_odd { } {
2264 global et_vect_extract_even_odd_saved
2266 if [info exists et_vect_extract_even_odd_saved] {
2267 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2268 } else {
2269 set et_vect_extract_even_odd_saved 0
2270 if { [istarget powerpc*-*-*] } {
2271 set et_vect_extract_even_odd_saved 1
2275 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2276 return $et_vect_extract_even_odd_saved
2279 # Return 1 if the target supports vector interleaving, 0 otherwise.
2281 proc check_effective_target_vect_interleave { } {
2282 global et_vect_interleave_saved
2284 if [info exists et_vect_interleave_saved] {
2285 verbose "check_effective_target_vect_interleave: using cached result" 2
2286 } else {
2287 set et_vect_interleave_saved 0
2288 if { [istarget powerpc*-*-*]
2289 || [istarget i?86-*-*]
2290 || [istarget x86_64-*-*] } {
2291 set et_vect_interleave_saved 1
2295 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2296 return $et_vect_interleave_saved
2299 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2300 proc check_effective_target_vect_strided { } {
2301 global et_vect_strided_saved
2303 if [info exists et_vect_strided_saved] {
2304 verbose "check_effective_target_vect_strided: using cached result" 2
2305 } else {
2306 set et_vect_strided_saved 0
2307 if { [check_effective_target_vect_interleave]
2308 && [check_effective_target_vect_extract_even_odd] } {
2309 set et_vect_strided_saved 1
2313 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2314 return $et_vect_strided_saved
2317 # Return 1 if the target supports section-anchors
2319 proc check_effective_target_section_anchors { } {
2320 global et_section_anchors_saved
2322 if [info exists et_section_anchors_saved] {
2323 verbose "check_effective_target_section_anchors: using cached result" 2
2324 } else {
2325 set et_section_anchors_saved 0
2326 if { [istarget powerpc*-*-*] } {
2327 set et_section_anchors_saved 1
2331 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2332 return $et_section_anchors_saved
2335 # Return 1 if the target supports atomic operations on "int" and "long".
2337 proc check_effective_target_sync_int_long { } {
2338 global et_sync_int_long_saved
2340 if [info exists et_sync_int_long_saved] {
2341 verbose "check_effective_target_sync_int_long: using cached result" 2
2342 } else {
2343 set et_sync_int_long_saved 0
2344 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2345 # load-reserved/store-conditional instructions.
2346 if { [istarget ia64-*-*]
2347 || [istarget i?86-*-*]
2348 || [istarget x86_64-*-*]
2349 || [istarget alpha*-*-*]
2350 || [istarget s390*-*-*]
2351 || [istarget powerpc*-*-*]
2352 || [istarget sparc64-*-*]
2353 || [istarget sparcv9-*-*] } {
2354 set et_sync_int_long_saved 1
2358 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2359 return $et_sync_int_long_saved
2362 # Return 1 if the target supports atomic operations on "char" and "short".
2364 proc check_effective_target_sync_char_short { } {
2365 global et_sync_char_short_saved
2367 if [info exists et_sync_char_short_saved] {
2368 verbose "check_effective_target_sync_char_short: using cached result" 2
2369 } else {
2370 set et_sync_char_short_saved 0
2371 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2372 # load-reserved/store-conditional instructions.
2373 if { [istarget ia64-*-*]
2374 || [istarget i?86-*-*]
2375 || [istarget x86_64-*-*]
2376 || [istarget alpha*-*-*]
2377 || [istarget s390*-*-*]
2378 || [istarget powerpc*-*-*]
2379 || [istarget sparc64-*-*]
2380 || [istarget sparcv9-*-*] } {
2381 set et_sync_char_short_saved 1
2385 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2386 return $et_sync_char_short_saved
2389 # Return 1 if the target uses a ColdFire FPU.
2391 proc check_effective_target_coldfire_fpu { } {
2392 return [check_no_compiler_messages coldfire_fpu assembly {
2393 #ifndef __mcffpu__
2394 #error FOO
2395 #endif
2399 # Return true if this is a uClibc target.
2401 proc check_effective_target_uclibc {} {
2402 return [check_no_compiler_messages uclibc object {
2403 #include <features.h>
2404 #if !defined (__UCLIBC__)
2405 #error FOO
2406 #endif
2410 # Return true if this is a uclibc target and if the uclibc feature
2411 # described by __$feature__ is not present.
2413 proc check_missing_uclibc_feature {feature} {
2414 return [check_no_compiler_messages $feature object "
2415 #include <features.h>
2416 #if !defined (__UCLIBC) || defined (__${feature}__)
2417 #error FOO
2418 #endif
2422 # Return true if this is a Newlib target.
2424 proc check_effective_target_newlib {} {
2425 return [check_no_compiler_messages newlib object {
2426 #include <newlib.h>
2430 # Return 1 if
2431 # (a) an error of a few ULP is expected in string to floating-point
2432 # conversion functions; and
2433 # (b) overflow is not always detected correctly by those functions.
2435 proc check_effective_target_lax_strtofp {} {
2436 # By default, assume that all uClibc targets suffer from this.
2437 return [check_effective_target_uclibc]
2440 # Return 1 if this is a target for which wcsftime is a dummy
2441 # function that always returns 0.
2443 proc check_effective_target_dummy_wcsftime {} {
2444 # By default, assume that all uClibc targets suffer from this.
2445 return [check_effective_target_uclibc]
2448 # Return 1 if constructors with initialization priority arguments are
2449 # supposed on this target.
2451 proc check_effective_target_init_priority {} {
2452 return [check_no_compiler_messages init_priority assembly "
2453 void f() __attribute__((constructor (1000)));
2454 void f() \{\}
2458 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2459 # This can be used with any check_* proc that takes no argument and
2460 # returns only 1 or 0. It could be used with check_* procs that take
2461 # arguments with keywords that pass particular arguments.
2463 proc is-effective-target { arg } {
2464 set selected 0
2465 if { [info procs check_effective_target_${arg}] != [list] } {
2466 set selected [check_effective_target_${arg}]
2467 } else {
2468 switch $arg {
2469 "vmx_hw" { set selected [check_vmx_hw_available] }
2470 "named_sections" { set selected [check_named_sections_available] }
2471 "gc_sections" { set selected [check_gc_sections_available] }
2472 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2473 default { error "unknown effective target keyword `$arg'" }
2476 verbose "is-effective-target: $arg $selected" 2
2477 return $selected
2480 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2482 proc is-effective-target-keyword { arg } {
2483 if { [info procs check_effective_target_${arg}] != [list] } {
2484 return 1
2485 } else {
2486 # These have different names for their check_* procs.
2487 switch $arg {
2488 "vmx_hw" { return 1 }
2489 "named_sections" { return 1 }
2490 "gc_sections" { return 1 }
2491 "cxa_atexit" { return 1 }
2492 default { return 0 }
2497 # Return 1 if target default to short enums
2499 proc check_effective_target_short_enums { } {
2500 return [check_no_compiler_messages short_enums assembly {
2501 enum foo { bar };
2502 int s[sizeof (enum foo) == 1 ? 1 : -1];
2506 # Return 1 if target supports merging string constants at link time.
2508 proc check_effective_target_string_merging { } {
2509 return [check_no_messages_and_pattern string_merging \
2510 "rodata\\.str" assembly {
2511 const char *var = "String";
2512 } {-O2}]
2515 # Return 1 if target has the basic signed and unsigned types in
2516 # <stdint.h>, 0 otherwise.
2518 proc check_effective_target_stdint_types { } {
2519 return [check_no_compiler_messages stdint_types assembly {
2520 #include <stdint.h>
2521 int8_t a; int16_t b; int32_t c; int64_t d;
2522 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2526 # Return 1 if programs are intended to be run on a simulator
2527 # (i.e. slowly) rather than hardware (i.e. fast).
2529 proc check_effective_target_simulator { } {
2531 # All "src/sim" simulators set this one.
2532 if [board_info target exists is_simulator] {
2533 return [board_info target is_simulator]
2536 # The "sid" simulators don't set that one, but at least they set
2537 # this one.
2538 if [board_info target exists slow_simulator] {
2539 return [board_info target slow_simulator]
2542 return 0
2545 # Return 1 if the target is a VxWorks RTP.
2547 proc check_effective_target_vxworks_kernel { } {
2548 return [check_no_compiler_messages vxworks_kernel assembly {
2549 #if !defined __vxworks || defined __RTP__
2550 #error NO
2551 #endif
2555 # Return 1 if the target is expected to provide wide character support.
2557 proc check_effective_target_wchar { } {
2558 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2559 return 0
2561 return [check_no_compiler_messages wchar assembly {
2562 #include <wchar.h>
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