mips.h (ISA_HAS_DSP, [...]): New macros.
[official-gcc.git] / gcc / testsuite / lib / target-supports.exp
blob07a1dc9f1eebca10a841985279a1b139c9ca62d1
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 Tcl command ARGS and seeing if it returns true.
92 proc check_cached_effective_target { prop args } {
93 global et_cache
95 set target [current_target_name]
96 if {![info exists et_cache($prop,target)]
97 || $et_cache($prop,target) != $target} {
98 verbose "check_cached_effective_target $prop: checking $target" 2
99 set et_cache($prop,target) $target
100 set et_cache($prop,value) [uplevel eval $args]
102 set value $et_cache($prop,value)
103 verbose "check_cached_effective_target $prop: returning $value for $target" 2
104 return $value
107 # Implement an effective-target check for property PROP by invoking
108 # the compiler and seeing if it prints any messages. Assume that the
109 # property holds if the compiler doesn't print anything. The other
110 # arguments are as for get_compiler_messages, starting with TYPE.
111 proc check_no_compiler_messages {prop args} {
112 return [check_cached_effective_target $prop {
113 string match "" [eval get_compiler_messages $prop 0 $args]
117 # Similar to check_no_compiler_messages, but also verify that the regular
118 # expression PATTERN matches the compiler's output.
119 proc check_no_messages_and_pattern {prop pattern args} {
120 return [check_cached_effective_target $prop {
121 set results [eval get_compiler_messages $prop 1 $args]
122 expr { [string match "" [lindex $results 0]]
123 && [regexp $pattern [lindex $results 1]] }
127 ###############################
128 # proc check_weak_available { }
129 ###############################
131 # weak symbols are only supported in some configs/object formats
132 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
134 proc check_weak_available { } {
135 global target_triplet
136 global target_cpu
138 # All mips targets should support it
140 if { [ string first "mips" $target_cpu ] >= 0 } {
141 return 1
144 # All solaris2 targets should support it
146 if { [regexp ".*-solaris2.*" $target_triplet] } {
147 return 1
150 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
152 if { [regexp "alpha.*osf.*" $target_triplet] } {
153 return 1
156 # Windows targets Cygwin and MingW32 support it
158 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
159 return 1
162 # HP-UX 10.X doesn't support it
164 if { [istarget "hppa*-*-hpux10*"] } {
165 return 0
168 # ELF and ECOFF support it. a.out does with gas/gld but may also with
169 # other linkers, so we should try it
171 set objformat [gcc_target_object_format]
173 switch $objformat {
174 elf { return 1 }
175 ecoff { return 1 }
176 a.out { return 1 }
177 mach-o { return 1 }
178 som { return 1 }
179 unknown { return -1 }
180 default { return 0 }
184 ###############################
185 # proc check_visibility_available { what_kind }
186 ###############################
188 # The visibility attribute is only support in some object formats
189 # This proc returns 1 if it is supported, 0 if not.
190 # The argument is the kind of visibility, default/protected/hidden/internal.
192 proc check_visibility_available { what_kind } {
193 global tool
194 global target_triplet
196 # On NetWare, support makes no sense.
197 if { [istarget *-*-netware*] } {
198 return 0
201 if [string match "" $what_kind] { set what_kind "hidden" }
203 return [check_no_compiler_messages visibility_available_$what_kind object "
204 void f() __attribute__((visibility(\"$what_kind\")));
205 void f() {}
209 ###############################
210 # proc check_alias_available { }
211 ###############################
213 # Determine if the target toolchain supports the alias attribute.
215 # Returns 2 if the target supports aliases. Returns 1 if the target
216 # only supports weak aliased. Returns 0 if the target does not
217 # support aliases at all. Returns -1 if support for aliases could not
218 # be determined.
220 proc check_alias_available { } {
221 global alias_available_saved
222 global tool
224 if [info exists alias_available_saved] {
225 verbose "check_alias_available returning saved $alias_available_saved" 2
226 } else {
227 set src alias[pid].c
228 set obj alias[pid].o
229 verbose "check_alias_available compiling testfile $src" 2
230 set f [open $src "w"]
231 # Compile a small test program. The definition of "g" is
232 # necessary to keep the Solaris assembler from complaining
233 # about the program.
234 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
235 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
236 close $f
237 set lines [${tool}_target_compile $src $obj object ""]
238 file delete $src
239 remote_file build delete $obj
241 if [string match "" $lines] then {
242 # No error messages, everything is OK.
243 set alias_available_saved 2
244 } else {
245 if [regexp "alias definitions not supported" $lines] {
246 verbose "check_alias_available target does not support aliases" 2
248 set objformat [gcc_target_object_format]
250 if { $objformat == "elf" } {
251 verbose "check_alias_available but target uses ELF format, so it ought to" 2
252 set alias_available_saved -1
253 } else {
254 set alias_available_saved 0
256 } else {
257 if [regexp "only weak aliases are supported" $lines] {
258 verbose "check_alias_available target supports only weak aliases" 2
259 set alias_available_saved 1
260 } else {
261 set alias_available_saved -1
266 verbose "check_alias_available returning $alias_available_saved" 2
269 return $alias_available_saved
272 # Returns true if --gc-sections is supported on the target.
274 proc check_gc_sections_available { } {
275 global gc_sections_available_saved
276 global tool
278 if {![info exists gc_sections_available_saved]} {
279 # Some targets don't support gc-sections despite whatever's
280 # advertised by ld's options.
281 if { [istarget alpha*-*-*]
282 || [istarget ia64-*-*] } {
283 set gc_sections_available_saved 0
284 return 0
287 # elf2flt uses -q (--emit-relocs), which is incompatible with
288 # --gc-sections.
289 if { [board_info target exists ldflags]
290 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
291 set gc_sections_available_saved 0
292 return 0
295 # VxWorks kernel modules are relocatable objects linked with -r,
296 # while RTP executables are linked with -q (--emit-relocs).
297 # Both of these options are incompatible with --gc-sections.
298 if { [istarget *-*-vxworks*] } {
299 set gc_sections_available_saved 0
300 return 0
303 # Check if the ld used by gcc supports --gc-sections.
304 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
305 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
306 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
307 set ld_output [remote_exec host "$gcc_ld" "--help"]
308 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
309 set gc_sections_available_saved 1
310 } else {
311 set gc_sections_available_saved 0
314 return $gc_sections_available_saved
317 # Return true if profiling is supported on the target.
319 proc check_profiling_available { test_what } {
320 global profiling_available_saved
322 verbose "Profiling argument is <$test_what>" 1
324 # These conditions depend on the argument so examine them before
325 # looking at the cache variable.
327 # Support for -p on solaris2 relies on mcrt1.o which comes with the
328 # vendor compiler. We cannot reliably predict the directory where the
329 # vendor compiler (and thus mcrt1.o) is installed so we can't
330 # necessarily find mcrt1.o even if we have it.
331 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
332 return 0
335 # Support for -p on irix relies on libprof1.a which doesn't appear to
336 # exist on any irix6 system currently posting testsuite results.
337 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
338 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
339 if { [istarget mips*-*-irix*]
340 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
341 return 0
344 # At present, there is no profiling support on NetWare.
345 if { [istarget *-*-netware*] } {
346 return 0
349 # uClibc does not have gcrt1.o.
350 if { [check_effective_target_uclibc]
351 && ([lindex $test_what 1] == "-p"
352 || [lindex $test_what 1] == "-pg") } {
353 return 0
356 # Now examine the cache variable.
357 if {![info exists profiling_available_saved]} {
358 # Some targets don't have any implementation of __bb_init_func or are
359 # missing other needed machinery.
360 if { [istarget mmix-*-*]
361 || [istarget arm*-*-eabi*]
362 || [istarget arm*-*-elf]
363 || [istarget arm*-*-symbianelf*]
364 || [istarget bfin-*-*]
365 || [istarget powerpc-*-eabi*]
366 || [istarget strongarm*-*-elf]
367 || [istarget xscale*-*-elf]
368 || [istarget cris-*-*]
369 || [istarget fido-*-elf]
370 || [istarget h8300-*-*]
371 || [istarget m32c-*-elf]
372 || [istarget m68k-*-elf]
373 || [istarget m68k-*-uclinux*]
374 || [istarget mips*-*-elf*]
375 || [istarget xtensa-*-elf]
376 || [istarget *-*-vxworks*]
377 || [istarget *-*-windiss] } {
378 set profiling_available_saved 0
379 } else {
380 set profiling_available_saved 1
384 return $profiling_available_saved
387 # Return 1 if target has packed layout of structure members by
388 # default, 0 otherwise. Note that this is slightly different than
389 # whether the target has "natural alignment": both attributes may be
390 # false.
392 proc check_effective_target_default_packed { } {
393 return [check_no_compiler_messages default_packed assembly {
394 struct x { char a; long b; } c;
395 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
399 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
400 # documentation, where the test also comes from.
402 proc check_effective_target_pcc_bitfield_type_matters { } {
403 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
404 # bitfields, but let's stick to the example code from the docs.
405 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
406 struct foo1 { char x; char :0; char y; };
407 struct foo2 { char x; int :0; char y; };
408 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
412 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
414 # This won't change for different subtargets so cache the result.
416 proc check_effective_target_tls {} {
417 global et_tls_saved
418 global tool
420 if [info exists et_tls_saved] {
421 verbose "check_effective_target_tls: using cached result" 2
422 } else {
423 set et_tls_saved 0
425 set src tls[pid].c
426 set asm tls[pid].S
427 verbose "check_effective_target_tls: compiling testfile $src" 2
428 set f [open $src "w"]
429 # Compile a small test program. Make sure that we test accesses
430 # as well as declarations.
431 puts $f "__thread int i;\n"
432 puts $f "int f (void) { return i; }\n"
433 puts $f "void g (int j) { i = j; }\n"
434 close $f
436 # Test for thread-local data supported by the platform.
437 set comp_output \
438 [${tool}_target_compile $src $asm assembly ""]
439 file delete $src
440 if { [string match "" $comp_output] } {
441 # No error messages, everything is OK.
442 set et_tls_saved 1
444 remove-build-file $asm
446 verbose "check_effective_target_tls: returning $et_tls_saved" 2
447 return $et_tls_saved
450 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
452 # This won't change for different subtargets so cache the result.
454 proc check_effective_target_tls_native {} {
455 global et_tls_native_saved
456 global tool
458 if [info exists et_tls_saved] {
459 verbose "check_effective_target_tls_native: using cached result" 2
460 } else {
461 set et_tls_native_saved 0
463 set src tls[pid].c
464 set asm tls[pid].S
465 verbose "check_effective_target_tls_native: compiling testfile $src" 2
466 set f [open $src "w"]
467 # Compile a small test program. Make sure that we test accesses
468 # as well as declarations.
469 puts $f "__thread int i;\n"
470 puts $f "int f (void) { return i; }\n"
471 puts $f "void g (int j) { i = j; }\n"
472 close $f
474 # Test for thread-local data supported by the platform.
475 set comp_output [${tool}_target_compile $src $asm assembly ""]
476 file delete $src
477 if { [string match "" $comp_output] } {
478 # No error messages, everything is OK.
479 set fd [open $asm r]
480 set text [read $fd]
481 close $fd
482 if { [string match "*emutls*" $text]} {
483 set et_tls_native_saved 0
484 } else {
485 set et_tls_native_saved 1
488 remove-build-file $asm
490 verbose "check_effective_target_tls_native: returning $et_tls_native_saved" 2
491 return $et_tls_native_saved
494 # Return 1 if TLS executables can run correctly, 0 otherwise.
496 # This won't change for different subtargets so cache the result.
498 proc check_effective_target_tls_runtime {} {
499 global et_tls_runtime_saved
500 global tool
502 if [info exists et_tls_runtime_saved] {
503 verbose "check_effective_target_tls_runtime: using cached result" 2
504 } else {
505 set et_tls_runtime_saved 0
507 set src tls_runtime[pid].c
508 set exe tls_runtime[pid].x
509 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
510 set f [open $src "w"]
511 # Compile a small test program.
512 puts $f "__thread int thr = 0;\n"
513 puts $f "int main(void)\n {\n return thr;\n}"
514 close $f
516 set comp_output \
517 [${tool}_target_compile $src $exe executable ""]
518 file delete $src
520 if [string match "" $comp_output] then {
521 # No error messages, everything is OK.
523 set result [remote_load target "./$exe" "" ""]
524 set status [lindex $result 0]
525 remote_file build delete $exe
527 verbose "check_effective_target_tls_runtime status is <$status>" 2
529 if { $status == "pass" } {
530 set et_tls_runtime_saved 1
533 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
537 return $et_tls_runtime_saved
540 # Return 1 if compilation with -fopenmp is error-free for trivial
541 # code, 0 otherwise.
543 proc check_effective_target_fopenmp {} {
544 return [check_no_compiler_messages fopenmp object {
545 void foo (void) { }
546 } "-fopenmp"]
549 # Return 1 if the target supports -fstack-protector
550 proc check_effective_target_fstack_protector {} {
551 global tool
552 set result ""
554 set src stack_prot[pid].c
555 set exe stack_prot[pid].x
557 verbose "check_effective_target_fstack_protector compiling testfile $src" 2
559 set f [open $src "w"]
560 # Compile a small test program.
561 puts $f "int main (void)\n { return 0; }\n"
562 close $f
564 set opts "additional_flags=-fstack-protector"
565 set lines [${tool}_target_compile $src $exe executable "$opts" ]
566 file delete $src
568 if [string match "" $lines] then {
569 # No error messages, everything is OK.
570 set result [${tool}_load "./$exe" "" ""]
571 set status [lindex $result 0]
572 remote_file build delete $exe
573 verbose "check_iconv_available status is <$status>" 2
575 if { $status == "pass" } then {
576 return 1
579 return 0
582 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
583 # for trivial code, 0 otherwise.
585 proc check_effective_target_freorder {} {
586 return [check_no_compiler_messages freorder object {
587 void foo (void) { }
588 } "-freorder-blocks-and-partition"]
591 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
592 # emitted, 0 otherwise. Whether a shared library can actually be built is
593 # out of scope for this test.
595 proc check_effective_target_fpic { } {
596 # Note that M68K has a multilib that supports -fpic but not
597 # -fPIC, so we need to check both. We test with a program that
598 # requires GOT references.
599 foreach arg {fpic fPIC} {
600 if [check_no_compiler_messages $arg object {
601 extern int foo (void); extern int bar;
602 int baz (void) { return foo () + bar; }
603 } "-$arg"] {
604 return 1
607 return 0
610 # Return true if the target supports -mpaired-single (as used on MIPS).
612 proc check_effective_target_mpaired_single { } {
613 return [check_no_compiler_messages mpaired_single object {
614 void foo (void) { }
615 } "-mpaired-single"]
618 # Return true if the target is a 64-bit MIPS target.
620 proc check_effective_target_mips64 { } {
621 return [check_no_compiler_messages mips64 assembly {
622 #ifndef __mips64
623 #error FOO
624 #endif
628 # Return true if the target is a MIPS target that does not produce
629 # MIPS16 code.
631 proc check_effective_target_nomips16 { } {
632 return [check_no_compiler_messages nomips16 object {
633 #ifndef __mips
634 #error FOO
635 #else
636 /* A cheap way of testing for -mflip-mips16. */
637 void foo (void) { asm ("addiu $20,$20,1"); }
638 void bar (void) { asm ("addiu $20,$20,1"); }
639 #endif
643 # Add the options needed for MIPS16 function attributes. At the moment,
644 # we don't support MIPS16 PIC.
646 proc add_options_for_mips16_attribute { flags } {
647 return "$flags -mno-abicalls -fno-pic"
650 # Return true if we can force a mode that allows MIPS16 code generation.
652 proc check_effective_target_mips16_attribute { } {
653 return [check_no_compiler_messages mips16_attribute assembly {
654 #if __PIC__
655 #error FOO
656 #endif
657 } [add_options_for_mips16_attribute ""]]
660 # Return 1 if the current multilib does not generate PIC by default.
662 proc check_effective_target_nonpic { } {
663 return [check_no_compiler_messages nonpic assembly {
664 #if __PIC__
665 #error FOO
666 #endif
670 # Return 1 if the target does not use a status wrapper.
672 proc check_effective_target_unwrapped { } {
673 if { [target_info needs_status_wrapper] != "" \
674 && [target_info needs_status_wrapper] != "0" } {
675 return 0
677 return 1
680 # Return true if iconv is supported on the target. In particular IBM1047.
682 proc check_iconv_available { test_what } {
683 global tool
684 global libiconv
686 set result ""
688 set src iconv[pid].c
689 set exe iconv[pid].x
690 verbose "check_iconv_available compiling testfile $src" 2
691 set f [open $src "w"]
692 # Compile a small test program.
693 puts $f "#include <iconv.h>\n"
694 puts $f "int main (void)\n {\n iconv_t cd; \n"
695 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
696 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
697 puts $f "return 0;\n}"
698 close $f
700 # If the tool configuration file has not set libiconv, try "-liconv"
701 if { ![info exists libiconv] } {
702 set libiconv "-liconv"
704 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
705 file delete $src
707 if [string match "" $lines] then {
708 # No error messages, everything is OK.
710 set result [${tool}_load "./$exe" "" ""]
711 set status [lindex $result 0]
712 remote_file build delete $exe
714 verbose "check_iconv_available status is <$status>" 2
716 if { $status == "pass" } then {
717 return 1
721 return 0
724 # Return true if named sections are supported on this target.
726 proc check_named_sections_available { } {
727 return [check_no_compiler_messages named_sections assembly {
728 int __attribute__ ((section("whatever"))) foo;
732 # Return 1 if the target supports Fortran real kinds larger than real(8),
733 # 0 otherwise.
735 # When the target name changes, replace the cached result.
737 proc check_effective_target_fortran_large_real { } {
738 global et_fortran_large_real_saved
739 global et_fortran_large_real_target_name
740 global tool
742 if { ![info exists et_fortran_large_real_target_name] } {
743 set et_fortran_large_real_target_name ""
746 # If the target has changed since we set the cached value, clear it.
747 set current_target [current_target_name]
748 if { $current_target != $et_fortran_large_real_target_name } {
749 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
750 set et_fortran_large_real_target_name $current_target
751 if [info exists et_fortran_large_real_saved] {
752 verbose "check_effective_target_fortran_large_real: removing cached result" 2
753 unset et_fortran_large_real_saved
757 if [info exists et_fortran_large_real_saved] {
758 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
759 } else {
760 set et_fortran_large_real_saved 0
762 # Set up, compile, and execute a test program using large real
763 # kinds. Include the current process ID in the file names to
764 # prevent conflicts with invocations for multiple testsuites.
765 set src real[pid].f90
766 set exe real[pid].x
768 set f [open $src "w"]
769 puts $f "integer,parameter :: k = &"
770 puts $f " selected_real_kind (precision (0.0_8) + 1)"
771 puts $f "real(kind=k) :: x"
772 puts $f "x = cos (x);"
773 puts $f "end"
774 close $f
776 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
777 set lines [${tool}_target_compile $src $exe executable ""]
778 file delete $src
780 if [string match "" $lines] then {
781 # No error message, compilation succeeded.
782 remote_file build delete $exe
783 set et_fortran_large_real_saved 1
787 return $et_fortran_large_real_saved
790 # Return 1 if the target supports Fortran integer kinds larger than
791 # integer(8), 0 otherwise.
793 # When the target name changes, replace the cached result.
795 proc check_effective_target_fortran_large_int { } {
796 global et_fortran_large_int_saved
797 global et_fortran_large_int_target_name
798 global tool
800 if { ![info exists et_fortran_large_int_target_name] } {
801 set et_fortran_large_int_target_name ""
804 # If the target has changed since we set the cached value, clear it.
805 set current_target [current_target_name]
806 if { $current_target != $et_fortran_large_int_target_name } {
807 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
808 set et_fortran_large_int_target_name $current_target
809 if [info exists et_fortran_large_int_saved] {
810 verbose "check_effective_target_fortran_large_int: removing cached result" 2
811 unset et_fortran_large_int_saved
815 if [info exists et_fortran_large_int_saved] {
816 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
817 } else {
818 set et_fortran_large_int_saved 0
820 # Set up, compile, and execute a test program using large integer
821 # kinds. Include the current process ID in the file names to
822 # prevent conflicts with invocations for multiple testsuites.
823 set src int[pid].f90
824 set exe int[pid].x
826 set f [open $src "w"]
827 puts $f "integer,parameter :: k = &"
828 puts $f " selected_int_kind (range (0_8) + 1)"
829 puts $f "integer(kind=k) :: i"
830 puts $f "end"
831 close $f
833 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
834 set lines [${tool}_target_compile $src $exe executable ""]
835 file delete $src
837 if [string match "" $lines] then {
838 # No error message, compilation succeeded.
839 remote_file build delete $exe
840 set et_fortran_large_int_saved 1
844 return $et_fortran_large_int_saved
847 # Return 1 if we can statically link libgfortran, 0 otherwise.
849 # When the target name changes, replace the cached result.
851 proc check_effective_target_static_libgfortran { } {
852 global et_static_libgfortran
853 global et_static_libgfortran_target_name
854 global tool
856 if { ![info exists et_static_libgfortran_target_name] } {
857 set et_static_libgfortran_target_name ""
860 # If the target has changed since we set the cached value, clear it.
861 set current_target [current_target_name]
862 if { $current_target != $et_static_libgfortran_target_name } {
863 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
864 set et_static_libgfortran_target_name $current_target
865 if [info exists et_static_libgfortran_saved] {
866 verbose "check_effective_target_static_libgfortran: removing cached result" 2
867 unset et_static_libgfortran_saved
871 if [info exists et_static_libgfortran_saved] {
872 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
873 } else {
874 set et_static_libgfortran_saved 0
876 # Set up, compile, and execute a test program using static linking.
877 # Include the current process ID in the file names to prevent
878 # conflicts with invocations for multiple testsuites.
879 set opts "additional_flags=-static"
880 set src static[pid].f
881 set exe static[pid].x
883 set f [open $src "w"]
884 puts $f " print *, 'test'"
885 puts $f " end"
886 close $f
888 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
889 set lines [${tool}_target_compile $src $exe executable "$opts"]
890 file delete $src
892 if [string match "" $lines] then {
893 # No error message, compilation succeeded.
894 remote_file build delete $exe
895 set et_static_libgfortran_saved 1
899 return $et_static_libgfortran_saved
902 # Return 1 if the target supports executing AltiVec instructions, 0
903 # otherwise. Cache the result.
905 proc check_vmx_hw_available { } {
906 global vmx_hw_available_saved
907 global tool
909 if [info exists vmx_hw_available_saved] {
910 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
911 } else {
912 set vmx_hw_available_saved 0
914 # Some simulators are known to not support VMX instructions.
915 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
916 verbose "check_hw_available returning 0" 2
917 return $vmx_hw_available_saved
920 # Set up, compile, and execute a test program containing VMX
921 # instructions. Include the current process ID in the file
922 # names to prevent conflicts with invocations for multiple
923 # testsuites.
924 set src vmx[pid].c
925 set exe vmx[pid].x
927 set f [open $src "w"]
928 puts $f "int main() {"
929 puts $f "#ifdef __MACH__"
930 puts $f " asm volatile (\"vor v0,v0,v0\");"
931 puts $f "#else"
932 puts $f " asm volatile (\"vor 0,0,0\");"
933 puts $f "#endif"
934 puts $f " return 0; }"
935 close $f
937 # Most targets don't require special flags for this test case, but
938 # Darwin does.
939 if [istarget *-*-darwin*] {
940 set opts "additional_flags=-maltivec"
941 } else {
942 set opts ""
945 verbose "check_vmx_hw_available compiling testfile $src" 2
946 set lines [${tool}_target_compile $src $exe executable "$opts"]
947 file delete $src
949 if [string match "" $lines] then {
950 # No error message, compilation succeeded.
951 set result [${tool}_load "./$exe" "" ""]
952 set status [lindex $result 0]
953 remote_file build delete $exe
954 verbose "check_vmx_hw_available testfile status is <$status>" 2
956 if { $status == "pass" } then {
957 set vmx_hw_available_saved 1
959 } else {
960 verbose "check_vmx_hw_availalble testfile compilation failed" 2
964 return $vmx_hw_available_saved
967 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
968 # complex float arguments. This affects gfortran tests that call cabsf
969 # in libm built by an earlier compiler. Return 1 if libm uses the same
970 # argument passing as the compiler under test, 0 otherwise.
972 # When the target name changes, replace the cached result.
974 proc check_effective_target_broken_cplxf_arg { } {
975 global et_broken_cplxf_arg_saved
976 global et_broken_cplxf_arg_target_name
977 global tool
979 # Skip the work for targets known not to be affected.
980 if { ![istarget powerpc64-*-linux*] } {
981 return 0
982 } elseif { [is-effective-target ilp32] } {
983 return 0
986 if { ![info exists et_broken_cplxf_arg_target_name] } {
987 set et_broken_cplxf_arg_target_name ""
990 # If the target has changed since we set the cached value, clear it.
991 set current_target [current_target_name]
992 if { $current_target != $et_broken_cplxf_arg_target_name } {
993 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
994 set et_broken_cplxf_arg_target_name $current_target
995 if [info exists et_broken_cplxf_arg_saved] {
996 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
997 unset et_broken_cplxf_arg_saved
1001 if [info exists et_broken_cplxf_arg_saved] {
1002 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
1003 } else {
1004 set et_broken_cplxf_arg_saved 0
1005 # This is only known to affect one target.
1006 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
1007 set et_broken_cplxf_arg_saved 0
1008 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
1009 return $et_broken_cplxf_arg_saved
1012 # Set up, compile, and execute a C test program that calls cabsf.
1013 set src cabsf[pid].c
1014 set exe cabsf[pid].x
1016 set f [open $src "w"]
1017 puts $f "#include <complex.h>"
1018 puts $f "extern void abort (void);"
1019 puts $f "float fabsf (float);"
1020 puts $f "float cabsf (_Complex float);"
1021 puts $f "int main ()"
1022 puts $f "{"
1023 puts $f " _Complex float cf;"
1024 puts $f " float f;"
1025 puts $f " cf = 3 + 4.0fi;"
1026 puts $f " f = cabsf (cf);"
1027 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
1028 puts $f " return 0;"
1029 puts $f "}"
1030 close $f
1032 set lines [${tool}_target_compile $src $exe executable "-lm"]
1033 file delete $src
1035 if [string match "" $lines] {
1036 # No error message, compilation succeeded.
1037 set result [${tool}_load "./$exe" "" ""]
1038 set status [lindex $result 0]
1039 remote_file build delete $exe
1041 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
1043 if { $status != "pass" } {
1044 set et_broken_cplxf_arg_saved 1
1046 } else {
1047 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
1050 return $et_broken_cplxf_arg_saved
1053 proc check_alpha_max_hw_available { } {
1054 global alpha_max_hw_available_saved
1055 global tool
1057 if [info exists alpha_max_hw_available_saved] {
1058 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
1059 } else {
1060 set alpha_max_hw_available_saved 0
1062 # Set up, compile, and execute a test program probing bit 8 of the
1063 # architecture mask, which indicates presence of MAX instructions.
1064 set src max[pid].c
1065 set exe max[pid].x
1067 set f [open $src "w"]
1068 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
1069 close $f
1071 verbose "check_alpha_max_hw_available compiling testfile $src" 2
1072 set lines [${tool}_target_compile $src $exe executable ""]
1073 file delete $src
1075 if [string match "" $lines] then {
1076 # No error message, compilation succeeded.
1077 set result [${tool}_load "./$exe" "" ""]
1078 set status [lindex $result 0]
1079 remote_file build delete $exe
1080 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
1082 if { $status == "pass" } then {
1083 set alpha_max_hw_available_saved 1
1085 } else {
1086 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
1090 return $alpha_max_hw_available_saved
1093 # Returns true iff the FUNCTION is available on the target system.
1094 # (This is essentially a Tcl implementation of Autoconf's
1095 # AC_CHECK_FUNC.)
1097 proc check_function_available { function } {
1098 set var "${function}_available_saved"
1099 global $var
1100 global tool
1102 if {![info exists $var]} {
1103 # Assume it exists.
1104 set $var 1
1105 # Check to make sure.
1106 set src "function[pid].c"
1107 set exe "function[pid].exe"
1109 set f [open $src "w"]
1110 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
1111 puts $f "char $function ();\n"
1112 puts $f "int main () { $function (); }"
1113 close $f
1115 set lines [${tool}_target_compile $src $exe executable ""]
1116 file delete $src
1117 file delete $exe
1119 if {![string match "" $lines]} then {
1120 set $var 0
1121 verbose -log "$function is not available"
1122 } else {
1123 verbose -log "$function is available"
1127 eval return \$$var
1130 # Returns true iff "fork" is available on the target system.
1132 proc check_fork_available {} {
1133 return [check_function_available "fork"]
1136 # Returns true iff "mkfifo" is available on the target system.
1138 proc check_mkfifo_available {} {
1139 if {[istarget *-*-cygwin*]} {
1140 # Cygwin has mkfifo, but support is incomplete.
1141 return 0
1144 return [check_function_available "mkfifo"]
1147 # Returns true iff "__cxa_atexit" is used on the target system.
1149 proc check_cxa_atexit_available { } {
1150 global et_cxa_atexit
1151 global et_cxa_atexit_target_name
1152 global tool
1154 if { ![info exists et_cxa_atexit_target_name] } {
1155 set et_cxa_atexit_target_name ""
1158 # If the target has changed since we set the cached value, clear it.
1159 set current_target [current_target_name]
1160 if { $current_target != $et_cxa_atexit_target_name } {
1161 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
1162 set et_cxa_atexit_target_name $current_target
1163 if [info exists et_cxa_atexit] {
1164 verbose "check_cxa_atexit_available: removing cached result" 2
1165 unset et_cxa_atexit
1169 if [info exists et_cxa_atexit] {
1170 verbose "check_cxa_atexit_available: using cached result" 2
1171 } elseif { [istarget "hppa*-*-hpux10*"] } {
1172 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1173 set et_cxa_atexit 0
1174 } else {
1175 set et_cxa_atexit 0
1177 # Set up, compile, and execute a C++ test program that depends
1178 # on correct ordering of static object destructors. This is
1179 # indicative of the presence and use of __cxa_atexit.
1180 set src cxaatexit[pid].cc
1181 set exe cxaatexit[pid].x
1183 set f [open $src "w"]
1184 puts $f "#include <stdlib.h>"
1185 puts $f "static unsigned int count;"
1186 puts $f "struct X"
1187 puts $f "{"
1188 puts $f " X() { count = 1; }"
1189 puts $f " ~X()"
1190 puts $f " {"
1191 puts $f " if (count != 3)"
1192 puts $f " exit(1);"
1193 puts $f " count = 4;"
1194 puts $f " }"
1195 puts $f "};"
1196 puts $f "void f()"
1197 puts $f "{"
1198 puts $f " static X x;"
1199 puts $f "}"
1200 puts $f "struct Y"
1201 puts $f "{"
1202 puts $f " Y() { f(); count = 2; }"
1203 puts $f " ~Y()"
1204 puts $f " {"
1205 puts $f " if (count != 2)"
1206 puts $f " exit(1);"
1207 puts $f " count = 3;"
1208 puts $f " }"
1209 puts $f "};"
1210 puts $f "Y y;"
1211 puts $f "int main()"
1212 puts $f "{ return 0; }"
1213 close $f
1215 set lines [${tool}_target_compile $src $exe executable ""]
1216 file delete $src
1218 if [string match "" $lines] {
1219 # No error message, compilation succeeded.
1220 set result [${tool}_load "./$exe" "" ""]
1221 set status [lindex $result 0]
1222 remote_file build delete $exe
1224 verbose "check_cxa_atexit_available: status is <$status>" 2
1226 if { $status == "pass" } {
1227 set et_cxa_atexit 1
1229 } else {
1230 verbose "check_cxa_atexit_available: compilation failed" 2
1233 return $et_cxa_atexit
1237 # Return 1 if we're generating 32-bit code using default options, 0
1238 # otherwise.
1240 proc check_effective_target_ilp32 { } {
1241 return [check_no_compiler_messages ilp32 object {
1242 int dummy[sizeof (int) == 4
1243 && sizeof (void *) == 4
1244 && sizeof (long) == 4 ? 1 : -1];
1248 # Return 1 if we're generating 32-bit or larger integers using default
1249 # options, 0 otherwise.
1251 proc check_effective_target_int32plus { } {
1252 return [check_no_compiler_messages int32plus object {
1253 int dummy[sizeof (int) >= 4 ? 1 : -1];
1257 # Return 1 if we're generating 32-bit or larger pointers using default
1258 # options, 0 otherwise.
1260 proc check_effective_target_ptr32plus { } {
1261 return [check_no_compiler_messages ptr32plus object {
1262 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1266 # Return 1 if we support 32-bit or larger array and structure sizes
1267 # using default options, 0 otherwise.
1269 proc check_effective_target_size32plus { } {
1270 return [check_no_compiler_messages size32plus object {
1271 char dummy[65537];
1275 # Returns 1 if we're generating 16-bit or smaller integers with the
1276 # default options, 0 otherwise.
1278 proc check_effective_target_int16 { } {
1279 return [check_no_compiler_messages int16 object {
1280 int dummy[sizeof (int) < 4 ? 1 : -1];
1284 # Return 1 if we're generating 64-bit code using default options, 0
1285 # otherwise.
1287 proc check_effective_target_lp64 { } {
1288 return [check_no_compiler_messages lp64 object {
1289 int dummy[sizeof (int) == 4
1290 && sizeof (void *) == 8
1291 && sizeof (long) == 8 ? 1 : -1];
1295 # Return 1 if the target supports long double larger than double,
1296 # 0 otherwise.
1298 proc check_effective_target_large_long_double { } {
1299 return [check_no_compiler_messages large_long_double object {
1300 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1304 # Return 1 if the target supports compiling fixed-point,
1305 # 0 otherwise.
1307 proc check_effective_target_fixed_point { } {
1308 return [check_no_compiler_messages fixed_point object {
1309 _Sat _Fract x; _Sat _Accum y;
1313 # Return 1 if the target supports compiling decimal floating point,
1314 # 0 otherwise.
1316 proc check_effective_target_dfp_nocache { } {
1317 verbose "check_effective_target_dfp_nocache: compiling source" 2
1318 set ret [string match "" [get_compiler_messages dfp 0 object {
1319 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1321 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1322 return $ret
1325 proc check_effective_target_dfprt_nocache { } {
1326 global tool
1328 set ret 0
1330 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1331 # Set up, compile, and execute a test program containing decimal
1332 # float operations.
1333 set src dfprt[pid].c
1334 set exe dfprt[pid].x
1336 set f [open $src "w"]
1337 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1338 puts $f "int main () { z = x + y; return 0; }"
1339 close $f
1341 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1342 set lines [${tool}_target_compile $src $exe executable ""]
1343 file delete $src
1345 if [string match "" $lines] then {
1346 # No error message, compilation succeeded.
1347 set result [${tool}_load "./$exe" "" ""]
1348 set status [lindex $result 0]
1349 remote_file build delete $exe
1350 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1351 if { $status == "pass" } then {
1352 set ret 1
1355 return $ret
1356 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1359 # Return 1 if the target supports compiling Decimal Floating Point,
1360 # 0 otherwise.
1362 # This won't change for different subtargets so cache the result.
1364 proc check_effective_target_dfp { } {
1365 global et_dfp_saved
1367 if [info exists et_dfp_saved] {
1368 verbose "check_effective_target_dfp: using cached result" 2
1369 } else {
1370 set et_dfp_saved [check_effective_target_dfp_nocache]
1372 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1373 return $et_dfp_saved
1376 # Return 1 if the target supports linking and executing Decimal Floating
1377 # Point, # 0 otherwise.
1379 # This won't change for different subtargets so cache the result.
1381 proc check_effective_target_dfprt { } {
1382 global et_dfprt_saved
1383 global tool
1385 if [info exists et_dfprt_saved] {
1386 verbose "check_effective_target_dfprt: using cached result" 2
1387 } else {
1388 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1390 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1391 return $et_dfprt_saved
1394 # Return 1 if the target needs a command line argument to enable a SIMD
1395 # instruction set.
1397 proc check_effective_target_vect_cmdline_needed { } {
1398 global et_vect_cmdline_needed_saved
1399 global et_vect_cmdline_needed_target_name
1401 if { ![info exists et_vect_cmdline_needed_target_name] } {
1402 set et_vect_cmdline_needed_target_name ""
1405 # If the target has changed since we set the cached value, clear it.
1406 set current_target [current_target_name]
1407 if { $current_target != $et_vect_cmdline_needed_target_name } {
1408 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1409 set et_vect_cmdline_needed_target_name $current_target
1410 if { [info exists et_vect_cmdline_needed_saved] } {
1411 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1412 unset et_vect_cmdline_needed_saved
1416 if [info exists et_vect_cmdline_needed_saved] {
1417 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1418 } else {
1419 set et_vect_cmdline_needed_saved 1
1420 if { [istarget ia64-*-*]
1421 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1422 && [check_effective_target_lp64])
1423 || ([istarget powerpc*-*-*]
1424 && ([check_effective_target_powerpc_spe]
1425 || [check_effective_target_powerpc_altivec]))} {
1426 set et_vect_cmdline_needed_saved 0
1430 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1431 return $et_vect_cmdline_needed_saved
1434 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1436 # This won't change for different subtargets so cache the result.
1438 proc check_effective_target_vect_int { } {
1439 global et_vect_int_saved
1441 if [info exists et_vect_int_saved] {
1442 verbose "check_effective_target_vect_int: using cached result" 2
1443 } else {
1444 set et_vect_int_saved 0
1445 if { [istarget i?86-*-*]
1446 || [istarget powerpc*-*-*]
1447 || [istarget spu-*-*]
1448 || [istarget x86_64-*-*]
1449 || [istarget sparc*-*-*]
1450 || [istarget alpha*-*-*]
1451 || [istarget ia64-*-*] } {
1452 set et_vect_int_saved 1
1456 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1457 return $et_vect_int_saved
1460 # Return 1 if the target supports int->float conversion
1463 proc check_effective_target_vect_intfloat_cvt { } {
1464 global et_vect_intfloat_cvt_saved
1466 if [info exists et_vect_intfloat_cvt_saved] {
1467 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1468 } else {
1469 set et_vect_intfloat_cvt_saved 0
1470 if { [istarget i?86-*-*]
1471 || [istarget powerpc*-*-*]
1472 || [istarget x86_64-*-*] } {
1473 set et_vect_intfloat_cvt_saved 1
1477 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1478 return $et_vect_intfloat_cvt_saved
1482 # Return 1 if the target supports float->int conversion
1485 proc check_effective_target_vect_floatint_cvt { } {
1486 global et_vect_floatint_cvt_saved
1488 if [info exists et_vect_floatint_cvt_saved] {
1489 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1490 } else {
1491 set et_vect_floatint_cvt_saved 0
1492 if { [istarget i?86-*-*]
1493 || [istarget x86_64-*-*] } {
1494 set et_vect_floatint_cvt_saved 1
1498 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1499 return $et_vect_floatint_cvt_saved
1503 # Return 1 is this is an arm target using 32-bit instructions
1504 proc check_effective_target_arm32 { } {
1505 return [check_no_compiler_messages arm32 assembly {
1506 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1507 #error FOO
1508 #endif
1512 # Return 1 if this is an ARM target supporting -mfpu=vfp
1513 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1514 # options.
1516 proc check_effective_target_arm_vfp_ok { } {
1517 if { [check_effective_target_arm32] } {
1518 return [check_no_compiler_messages arm_vfp_ok object {
1519 int dummy;
1520 } "-mfpu=vfp -mfloat-abi=softfp"]
1521 } else {
1522 return 0
1526 # Return 1 if this is an ARM target supporting -mfpu=neon
1527 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1528 # options.
1530 proc check_effective_target_arm_neon_ok { } {
1531 if { [check_effective_target_arm32] } {
1532 return [check_no_compiler_messages arm_neon_ok object {
1533 int dummy;
1534 } "-mfpu=neon -mfloat-abi=softfp"]
1535 } else {
1536 return 0
1540 # Return 1 if the target supports executing NEON instructions, 0
1541 # otherwise. Cache the result.
1543 proc check_effective_target_arm_neon_hw { } {
1544 global arm_neon_hw_available_saved
1545 global tool
1547 if [info exists arm_neon_hw_available_saved] {
1548 verbose "check_arm_neon_hw_available returning saved $arm_neon_hw_avail
1549 able_saved" 2
1550 } else {
1551 set arm_neon_hw_available_saved 0
1553 # Set up, compile, and execute a test program containing NEON
1554 # instructions. Include the current process ID in the file
1555 # names to prevent conflicts with invocations for multiple
1556 # testsuites.
1557 set src neon[pid].c
1558 set exe neon[pid].x
1560 set f [open $src "w"]
1561 puts $f "int main() {"
1562 puts $f " long long a = 0, b = 1;"
1563 puts $f " asm (\"vorr %P0, %P1, %P2\""
1564 puts $f " : \"=w\" (a)"
1565 puts $f " : \"0\" (a), \"w\" (b));"
1566 puts $f " return (a != 1);"
1567 puts $f "}"
1568 close $f
1570 set opts "additional_flags=-mfpu=neon additional_flags=-mfloat-abi=softfp"
1572 verbose "check_arm_neon_hw_available compiling testfile $src" 2
1573 set lines [${tool}_target_compile $src $exe executable "$opts"]
1574 file delete $src
1576 if [string match "" $lines] then {
1577 # No error message, compilation succeeded.
1578 set result [${tool}_load "./$exe" "" ""]
1579 set status [lindex $result 0]
1580 remote_file build delete $exe
1581 verbose "check_arm_neon_hw_available testfile status is <$status>" 2
1583 if { $status == "pass" } then {
1584 set arm_neon_hw_available_saved 1
1586 } else {
1587 verbose "check_arm_neon_hw_available testfile compilation failed" 2
1591 return $arm_neon_hw_available_saved
1594 # Return 1 if this is a PowerPC target with floating-point registers.
1596 proc check_effective_target_powerpc_fprs { } {
1597 if { [istarget powerpc*-*-*]
1598 || [istarget rs6000-*-*] } {
1599 return [check_no_compiler_messages powerpc_fprs object {
1600 #ifdef __NO_FPRS__
1601 #error no FPRs
1602 #else
1603 int dummy;
1604 #endif
1606 } else {
1607 return 0
1611 # Return 1 if this is a PowerPC target supporting -maltivec.
1613 proc check_effective_target_powerpc_altivec_ok { } {
1614 if { [istarget powerpc*-*-*]
1615 || [istarget rs6000-*-*] } {
1616 # AltiVec is not supported on Aix.
1617 if { [istarget powerpc*-*-aix*] } {
1618 return 0
1620 return [check_no_compiler_messages powerpc_altivec_ok object {
1621 int dummy;
1622 } "-maltivec"]
1623 } else {
1624 return 0
1628 # Return 1 if this is a PowerPC target with SPE enabled.
1630 proc check_effective_target_powerpc_spe { } {
1631 if { [istarget powerpc*-*-*] } {
1632 return [check_no_compiler_messages powerpc_spe object {
1633 #ifndef __SPE__
1634 #error not SPE
1635 #else
1636 int dummy;
1637 #endif
1639 } else {
1640 return 0
1644 # Return 1 if this is a PowerPC target with Altivec enabled.
1646 proc check_effective_target_powerpc_altivec { } {
1647 if { [istarget powerpc*-*-*] } {
1648 return [check_no_compiler_messages powerpc_altivec object {
1649 #ifndef __ALTIVEC__
1650 #error not Altivec
1651 #else
1652 int dummy;
1653 #endif
1655 } else {
1656 return 0
1660 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
1661 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
1662 # test environment appears to run executables on such a simulator.
1664 proc check_effective_target_ultrasparc_hw { } {
1665 global et_ultrasparc_hw_saved
1666 global tool
1668 if [info exists et_ultrasparc_hw_saved] {
1669 verbose "check_ultrasparc_hw_available returning saved $et_ultrasparc_hw_saved" 2
1670 } else {
1671 set et_ultrasparc_hw_saved 0
1673 # Set up, compile, and execute a simple test program. The
1674 # program will be compiled with -mcpu=ultrasparc to instruct the
1675 # assembler to produce EM_SPARC32PLUS executables.
1676 set src svect[pid].c
1677 set exe svect[pid].x
1679 set f [open $src "w"]
1680 puts $f "int main() { return 0; }"
1681 close $f
1683 verbose "check_ultrasparc_hw_available compiling testfile $src" 2
1684 set lines [${tool}_target_compile $src $exe executable "additional_flags=-mcpu=ultrasparc"]
1685 file delete $src
1687 if [string match "" $lines] then {
1688 # No error message, compilation succeeded.
1689 set result [${tool}_load "./$exe" "" ""]
1690 set status [lindex $result 0]
1691 remote_file build delete $exe
1692 verbose "check_ultrasparc_hw_available testfile status is <$status>" 2
1694 if { $status == "pass" } then {
1695 set et_ultrasparc_hw_saved 1
1697 } else {
1698 verbose "check_ultrasparc_hw_available testfile compilation failed" 2
1702 return $et_ultrasparc_hw_saved
1705 # Return 1 if the target supports hardware vector shift operation.
1707 proc check_effective_target_vect_shift { } {
1708 global et_vect_shift_saved
1710 if [info exists et_vect_shift_saved] {
1711 verbose "check_effective_target_vect_shift: using cached result" 2
1712 } else {
1713 set et_vect_shift_saved 0
1714 if { [istarget powerpc*-*-*]
1715 || [istarget ia64-*-*]
1716 || [istarget i?86-*-*]
1717 || [istarget x86_64-*-*] } {
1718 set et_vect_shift_saved 1
1722 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1723 return $et_vect_shift_saved
1726 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1728 # This can change for different subtargets so do not cache the result.
1730 proc check_effective_target_vect_long { } {
1731 if { [istarget i?86-*-*]
1732 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1733 || [istarget x86_64-*-*]
1734 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1735 set answer 1
1736 } else {
1737 set answer 0
1740 verbose "check_effective_target_vect_long: returning $answer" 2
1741 return $answer
1744 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1746 # This won't change for different subtargets so cache the result.
1748 proc check_effective_target_vect_float { } {
1749 global et_vect_float_saved
1751 if [info exists et_vect_float_saved] {
1752 verbose "check_effective_target_vect_float: using cached result" 2
1753 } else {
1754 set et_vect_float_saved 0
1755 if { [istarget i?86-*-*]
1756 || [istarget powerpc*-*-*]
1757 || [istarget spu-*-*]
1758 || [istarget mipsisa64*-*-*]
1759 || [istarget x86_64-*-*]
1760 || [istarget ia64-*-*] } {
1761 set et_vect_float_saved 1
1765 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1766 return $et_vect_float_saved
1769 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1771 # This won't change for different subtargets so cache the result.
1773 proc check_effective_target_vect_double { } {
1774 global et_vect_double_saved
1776 if [info exists et_vect_double_saved] {
1777 verbose "check_effective_target_vect_double: using cached result" 2
1778 } else {
1779 set et_vect_double_saved 0
1780 if { [istarget i?86-*-*]
1781 || [istarget x86_64-*-*]
1782 || [istarget spu-*-*] } {
1783 set et_vect_double_saved 1
1787 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1788 return $et_vect_double_saved
1791 # Return 1 if the target plus current options does not support a vector
1792 # max instruction on "int", 0 otherwise.
1794 # This won't change for different subtargets so cache the result.
1796 proc check_effective_target_vect_no_int_max { } {
1797 global et_vect_no_int_max_saved
1799 if [info exists et_vect_no_int_max_saved] {
1800 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1801 } else {
1802 set et_vect_no_int_max_saved 0
1803 if { [istarget sparc*-*-*]
1804 || [istarget spu-*-*]
1805 || [istarget alpha*-*-*] } {
1806 set et_vect_no_int_max_saved 1
1809 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1810 return $et_vect_no_int_max_saved
1813 # Return 1 if the target plus current options does not support a vector
1814 # add instruction on "int", 0 otherwise.
1816 # This won't change for different subtargets so cache the result.
1818 proc check_effective_target_vect_no_int_add { } {
1819 global et_vect_no_int_add_saved
1821 if [info exists et_vect_no_int_add_saved] {
1822 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1823 } else {
1824 set et_vect_no_int_add_saved 0
1825 # Alpha only supports vector add on V8QI and V4HI.
1826 if { [istarget alpha*-*-*] } {
1827 set et_vect_no_int_add_saved 1
1830 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1831 return $et_vect_no_int_add_saved
1834 # Return 1 if the target plus current options does not support vector
1835 # bitwise instructions, 0 otherwise.
1837 # This won't change for different subtargets so cache the result.
1839 proc check_effective_target_vect_no_bitwise { } {
1840 global et_vect_no_bitwise_saved
1842 if [info exists et_vect_no_bitwise_saved] {
1843 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1844 } else {
1845 set et_vect_no_bitwise_saved 0
1847 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1848 return $et_vect_no_bitwise_saved
1851 # Return 1 if the target plus current options supports a vector
1852 # widening summation of *short* args into *int* result, 0 otherwise.
1853 # A target can also support this widening summation if it can support
1854 # promotion (unpacking) from shorts to ints.
1856 # This won't change for different subtargets so cache the result.
1858 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1859 global et_vect_widen_sum_hi_to_si
1861 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1862 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1863 } else {
1864 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
1865 if { [istarget powerpc*-*-*]
1866 || [istarget ia64-*-*] } {
1867 set et_vect_widen_sum_hi_to_si_saved 1
1870 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1871 return $et_vect_widen_sum_hi_to_si_saved
1874 # Return 1 if the target plus current options supports a vector
1875 # widening summation of *char* args into *short* result, 0 otherwise.
1876 # A target can also support this widening summation if it can support
1877 # promotion (unpacking) from chars to shorts.
1879 # This won't change for different subtargets so cache the result.
1881 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1882 global et_vect_widen_sum_qi_to_hi
1884 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1885 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1886 } else {
1887 set et_vect_widen_sum_qi_to_hi_saved 0
1888 if { [check_effective_target_vect_unpack]
1889 || [istarget ia64-*-*] } {
1890 set et_vect_widen_sum_qi_to_hi_saved 1
1893 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1894 return $et_vect_widen_sum_qi_to_hi_saved
1897 # Return 1 if the target plus current options supports a vector
1898 # widening summation of *char* args into *int* result, 0 otherwise.
1900 # This won't change for different subtargets so cache the result.
1902 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1903 global et_vect_widen_sum_qi_to_si
1905 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1906 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1907 } else {
1908 set et_vect_widen_sum_qi_to_si_saved 0
1909 if { [istarget powerpc*-*-*] } {
1910 set et_vect_widen_sum_qi_to_si_saved 1
1913 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1914 return $et_vect_widen_sum_qi_to_si_saved
1917 # Return 1 if the target plus current options supports a vector
1918 # widening multiplication of *char* args into *short* result, 0 otherwise.
1919 # A target can also support this widening multplication if it can support
1920 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
1921 # multiplication of shorts).
1923 # This won't change for different subtargets so cache the result.
1926 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
1927 global et_vect_widen_mult_qi_to_hi
1929 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
1930 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
1931 } else {
1932 if { [check_effective_target_vect_unpack]
1933 && [check_effective_target_vect_short_mult] } {
1934 set et_vect_widen_mult_qi_to_hi_saved 1
1935 } else {
1936 set et_vect_widen_mult_qi_to_hi_saved 0
1938 if { [istarget powerpc*-*-*] } {
1939 set et_vect_widen_mult_qi_to_hi_saved 1
1942 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
1943 return $et_vect_widen_mult_qi_to_hi_saved
1946 # Return 1 if the target plus current options supports a vector
1947 # widening multiplication of *short* args into *int* result, 0 otherwise.
1948 # A target can also support this widening multplication if it can support
1949 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
1950 # multiplication of ints).
1952 # This won't change for different subtargets so cache the result.
1955 proc check_effective_target_vect_widen_mult_hi_to_si { } {
1956 global et_vect_widen_mult_hi_to_si
1958 if [info exists et_vect_widen_mult_hi_to_si_saved] {
1959 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
1960 } else {
1961 if { [check_effective_target_vect_unpack]
1962 && [check_effective_target_vect_int_mult] } {
1963 set et_vect_widen_mult_hi_to_si_saved 1
1964 } else {
1965 set et_vect_widen_mult_hi_to_si_saved 0
1967 if { [istarget powerpc*-*-*]
1968 || [istarget spu-*-*]
1969 || [istarget i?86-*-*]
1970 || [istarget x86_64-*-*] } {
1971 set et_vect_widen_mult_hi_to_si_saved 1
1974 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
1975 return $et_vect_widen_mult_hi_to_si_saved
1978 # Return 1 if the target plus current options supports a vector
1979 # dot-product of signed chars, 0 otherwise.
1981 # This won't change for different subtargets so cache the result.
1983 proc check_effective_target_vect_sdot_qi { } {
1984 global et_vect_sdot_qi
1986 if [info exists et_vect_sdot_qi_saved] {
1987 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1988 } else {
1989 set et_vect_sdot_qi_saved 0
1991 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1992 return $et_vect_sdot_qi_saved
1995 # Return 1 if the target plus current options supports a vector
1996 # dot-product of unsigned chars, 0 otherwise.
1998 # This won't change for different subtargets so cache the result.
2000 proc check_effective_target_vect_udot_qi { } {
2001 global et_vect_udot_qi
2003 if [info exists et_vect_udot_qi_saved] {
2004 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2005 } else {
2006 set et_vect_udot_qi_saved 0
2007 if { [istarget powerpc*-*-*] } {
2008 set et_vect_udot_qi_saved 1
2011 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2012 return $et_vect_udot_qi_saved
2015 # Return 1 if the target plus current options supports a vector
2016 # dot-product of signed shorts, 0 otherwise.
2018 # This won't change for different subtargets so cache the result.
2020 proc check_effective_target_vect_sdot_hi { } {
2021 global et_vect_sdot_hi
2023 if [info exists et_vect_sdot_hi_saved] {
2024 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2025 } else {
2026 set et_vect_sdot_hi_saved 0
2027 if { [istarget powerpc*-*-*]
2028 || [istarget i?86-*-*]
2029 || [istarget x86_64-*-*] } {
2030 set et_vect_sdot_hi_saved 1
2033 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2034 return $et_vect_sdot_hi_saved
2037 # Return 1 if the target plus current options supports a vector
2038 # dot-product of unsigned shorts, 0 otherwise.
2040 # This won't change for different subtargets so cache the result.
2042 proc check_effective_target_vect_udot_hi { } {
2043 global et_vect_udot_hi
2045 if [info exists et_vect_udot_hi_saved] {
2046 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2047 } else {
2048 set et_vect_udot_hi_saved 0
2049 if { [istarget powerpc*-*-*] } {
2050 set et_vect_udot_hi_saved 1
2053 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2054 return $et_vect_udot_hi_saved
2058 # Return 1 if the target plus current options supports a vector
2059 # demotion (packing) of shorts (to chars) and ints (to shorts)
2060 # using modulo arithmetic, 0 otherwise.
2062 # This won't change for different subtargets so cache the result.
2064 proc check_effective_target_vect_pack_trunc { } {
2065 global et_vect_pack_trunc
2067 if [info exists et_vect_pack_trunc_saved] {
2068 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2069 } else {
2070 set et_vect_pack_trunc_saved 0
2071 if { [istarget powerpc*-*-*]
2072 || [istarget i?86-*-*]
2073 || [istarget x86_64-*-*] } {
2074 set et_vect_pack_trunc_saved 1
2077 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2078 return $et_vect_pack_trunc_saved
2081 # Return 1 if the target plus current options supports a vector
2082 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2084 # This won't change for different subtargets so cache the result.
2086 proc check_effective_target_vect_unpack { } {
2087 global et_vect_unpack
2089 if [info exists et_vect_unpack_saved] {
2090 verbose "check_effective_target_vect_unpack: using cached result" 2
2091 } else {
2092 set et_vect_unpack_saved 0
2093 if { [istarget powerpc*-*-*]
2094 || [istarget i?86-*-*]
2095 || [istarget x86_64-*-*] } {
2096 set et_vect_unpack_saved 1
2099 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2100 return $et_vect_unpack_saved
2103 # Return 1 if the target plus current options does not support a vector
2104 # alignment mechanism, 0 otherwise.
2106 # This won't change for different subtargets so cache the result.
2108 proc check_effective_target_vect_no_align { } {
2109 global et_vect_no_align_saved
2111 if [info exists et_vect_no_align_saved] {
2112 verbose "check_effective_target_vect_no_align: using cached result" 2
2113 } else {
2114 set et_vect_no_align_saved 0
2115 if { [istarget mipsisa64*-*-*]
2116 || [istarget sparc*-*-*]
2117 || [istarget ia64-*-*] } {
2118 set et_vect_no_align_saved 1
2121 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2122 return $et_vect_no_align_saved
2125 # Return 1 if arrays are aligned to the vector alignment
2126 # boundary, 0 otherwise.
2128 # This won't change for different subtargets so cache the result.
2130 proc check_effective_target_vect_aligned_arrays { } {
2131 global et_vect_aligned_arrays
2133 if [info exists et_vect_aligned_arrays_saved] {
2134 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2135 } else {
2136 set et_vect_aligned_arrays_saved 0
2137 if { ([istarget x86_64-*-*]
2138 || [istarget i?86-*-*]) && [is-effective-target lp64] } {
2139 set et_vect_aligned_arrays_saved 1
2142 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2143 return $et_vect_aligned_arrays_saved
2146 # Return 1 if types are naturally aligned (aligned to their type-size),
2147 # 0 otherwise.
2149 # This won't change for different subtargets so cache the result.
2151 proc check_effective_target_natural_alignment { } {
2152 global et_natural_alignment
2154 if [info exists et_natural_alignment_saved] {
2155 verbose "check_effective_target_natural_alignment: using cached result" 2
2156 } else {
2157 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2158 set et_natural_alignment_saved 1
2159 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2160 set et_natural_alignment_saved 0
2163 verbose "check_effective_target_natural_alignment: returning $et_natural_alignment_saved" 2
2164 return $et_natural_alignment_saved
2167 # Return 1 if vector alignment is reachable, 0 otherwise.
2169 # This won't change for different subtargets so cache the result.
2171 proc check_effective_target_vector_alignment_reachable { } {
2172 global et_vector_alignment_reachable
2174 if [info exists et_vector_alignment_reachable_saved] {
2175 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2176 } else {
2177 if { [check_effective_target_vect_aligned_arrays]
2178 || [check_effective_target_natural_alignment] } {
2179 set et_vector_alignment_reachable_saved 1
2180 } else {
2181 set et_vector_alignment_reachable_saved 0
2184 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2185 return $et_vector_alignment_reachable_saved
2188 # Return 1 if vector alignment for soubles is reachable, 0 otherwise.
2190 # This won't change for different subtargets so cache the result.
2192 proc check_effective_target_vector_alignment_reachable_for_double { } {
2193 global et_vector_alignment_reachable_for_double
2195 if [info exists et_vector_alignment_reachable_for_double_saved] {
2196 verbose "check_effective_target_vector_alignment_reachable_for_double: using cached result" 2
2197 } else {
2198 if { [check_effective_target_vect_aligned_arrays] } {
2199 set et_vector_alignment_reachable_for_double_saved 1
2200 } else {
2201 set et_vector_alignment_reachable_for_double_saved 0
2204 verbose "check_effective_target_vector_alignment_reachable_for_double: returning $et_vector_alignment_reachable_for_double_saved" 2
2205 return $et_vector_alignment_reachable_for_double_saved
2208 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2210 proc check_effective_target_vect_condition { } {
2211 global et_vect_cond_saved
2213 if [info exists et_vect_cond_saved] {
2214 verbose "check_effective_target_vect_cond: using cached result" 2
2215 } else {
2216 set et_vect_cond_saved 0
2217 if { [istarget powerpc*-*-*]
2218 || [istarget ia64-*-*]
2219 || [istarget i?86-*-*]
2220 || [istarget spu-*-*]
2221 || [istarget x86_64-*-*] } {
2222 set et_vect_cond_saved 1
2226 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2227 return $et_vect_cond_saved
2230 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2232 proc check_effective_target_vect_char_mult { } {
2233 global et_vect_char_mult_saved
2235 if [info exists et_vect_char_mult_saved] {
2236 verbose "check_effective_target_vect_char_mult: using cached result" 2
2237 } else {
2238 set et_vect_char_mult_saved 0
2239 if { [istarget ia64-*-*]
2240 || [istarget i?86-*-*]
2241 || [istarget x86_64-*-*] } {
2242 set et_vect_char_mult_saved 1
2246 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2247 return $et_vect_char_mult_saved
2250 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2252 proc check_effective_target_vect_short_mult { } {
2253 global et_vect_short_mult_saved
2255 if [info exists et_vect_short_mult_saved] {
2256 verbose "check_effective_target_vect_short_mult: using cached result" 2
2257 } else {
2258 set et_vect_short_mult_saved 0
2259 if { [istarget ia64-*-*]
2260 || [istarget i?86-*-*]
2261 || [istarget x86_64-*-*] } {
2262 set et_vect_short_mult_saved 1
2266 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2267 return $et_vect_short_mult_saved
2270 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2272 proc check_effective_target_vect_int_mult { } {
2273 global et_vect_int_mult_saved
2275 if [info exists et_vect_int_mult_saved] {
2276 verbose "check_effective_target_vect_int_mult: using cached result" 2
2277 } else {
2278 set et_vect_int_mult_saved 0
2279 if { [istarget powerpc*-*-*]
2280 || [istarget spu-*-*]
2281 || [istarget i?86-*-*]
2282 || [istarget x86_64-*-*] } {
2283 set et_vect_int_mult_saved 1
2287 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2288 return $et_vect_int_mult_saved
2291 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2293 proc check_effective_target_vect_extract_even_odd { } {
2294 global et_vect_extract_even_odd_saved
2296 if [info exists et_vect_extract_even_odd_saved] {
2297 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2298 } else {
2299 set et_vect_extract_even_odd_saved 0
2300 if { [istarget powerpc*-*-*] } {
2301 set et_vect_extract_even_odd_saved 1
2305 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2306 return $et_vect_extract_even_odd_saved
2309 # Return 1 if the target supports vector interleaving, 0 otherwise.
2311 proc check_effective_target_vect_interleave { } {
2312 global et_vect_interleave_saved
2314 if [info exists et_vect_interleave_saved] {
2315 verbose "check_effective_target_vect_interleave: using cached result" 2
2316 } else {
2317 set et_vect_interleave_saved 0
2318 if { [istarget powerpc*-*-*]
2319 || [istarget i?86-*-*]
2320 || [istarget x86_64-*-*] } {
2321 set et_vect_interleave_saved 1
2325 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
2326 return $et_vect_interleave_saved
2329 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
2330 proc check_effective_target_vect_strided { } {
2331 global et_vect_strided_saved
2333 if [info exists et_vect_strided_saved] {
2334 verbose "check_effective_target_vect_strided: using cached result" 2
2335 } else {
2336 set et_vect_strided_saved 0
2337 if { [check_effective_target_vect_interleave]
2338 && [check_effective_target_vect_extract_even_odd] } {
2339 set et_vect_strided_saved 1
2343 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
2344 return $et_vect_strided_saved
2347 # Return 1 if the target supports section-anchors
2349 proc check_effective_target_section_anchors { } {
2350 global et_section_anchors_saved
2352 if [info exists et_section_anchors_saved] {
2353 verbose "check_effective_target_section_anchors: using cached result" 2
2354 } else {
2355 set et_section_anchors_saved 0
2356 if { [istarget powerpc*-*-*] } {
2357 set et_section_anchors_saved 1
2361 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
2362 return $et_section_anchors_saved
2365 # Return 1 if the target supports atomic operations on "int" and "long".
2367 proc check_effective_target_sync_int_long { } {
2368 global et_sync_int_long_saved
2370 if [info exists et_sync_int_long_saved] {
2371 verbose "check_effective_target_sync_int_long: using cached result" 2
2372 } else {
2373 set et_sync_int_long_saved 0
2374 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2375 # load-reserved/store-conditional instructions.
2376 if { [istarget ia64-*-*]
2377 || [istarget i?86-*-*]
2378 || [istarget x86_64-*-*]
2379 || [istarget alpha*-*-*]
2380 || [istarget s390*-*-*]
2381 || [istarget powerpc*-*-*]
2382 || [istarget sparc64-*-*]
2383 || [istarget sparcv9-*-*] } {
2384 set et_sync_int_long_saved 1
2388 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
2389 return $et_sync_int_long_saved
2392 # Return 1 if the target supports atomic operations on "char" and "short".
2394 proc check_effective_target_sync_char_short { } {
2395 global et_sync_char_short_saved
2397 if [info exists et_sync_char_short_saved] {
2398 verbose "check_effective_target_sync_char_short: using cached result" 2
2399 } else {
2400 set et_sync_char_short_saved 0
2401 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
2402 # load-reserved/store-conditional instructions.
2403 if { [istarget ia64-*-*]
2404 || [istarget i?86-*-*]
2405 || [istarget x86_64-*-*]
2406 || [istarget alpha*-*-*]
2407 || [istarget s390*-*-*]
2408 || [istarget powerpc*-*-*]
2409 || [istarget sparc64-*-*]
2410 || [istarget sparcv9-*-*] } {
2411 set et_sync_char_short_saved 1
2415 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
2416 return $et_sync_char_short_saved
2419 # Return 1 if the target uses a ColdFire FPU.
2421 proc check_effective_target_coldfire_fpu { } {
2422 return [check_no_compiler_messages coldfire_fpu assembly {
2423 #ifndef __mcffpu__
2424 #error FOO
2425 #endif
2429 # Return true if this is a uClibc target.
2431 proc check_effective_target_uclibc {} {
2432 return [check_no_compiler_messages uclibc object {
2433 #include <features.h>
2434 #if !defined (__UCLIBC__)
2435 #error FOO
2436 #endif
2440 # Return true if this is a uclibc target and if the uclibc feature
2441 # described by __$feature__ is not present.
2443 proc check_missing_uclibc_feature {feature} {
2444 return [check_no_compiler_messages $feature object "
2445 #include <features.h>
2446 #if !defined (__UCLIBC) || defined (__${feature}__)
2447 #error FOO
2448 #endif
2452 # Return true if this is a Newlib target.
2454 proc check_effective_target_newlib {} {
2455 return [check_no_compiler_messages newlib object {
2456 #include <newlib.h>
2460 # Return 1 if
2461 # (a) an error of a few ULP is expected in string to floating-point
2462 # conversion functions; and
2463 # (b) overflow is not always detected correctly by those functions.
2465 proc check_effective_target_lax_strtofp {} {
2466 # By default, assume that all uClibc targets suffer from this.
2467 return [check_effective_target_uclibc]
2470 # Return 1 if this is a target for which wcsftime is a dummy
2471 # function that always returns 0.
2473 proc check_effective_target_dummy_wcsftime {} {
2474 # By default, assume that all uClibc targets suffer from this.
2475 return [check_effective_target_uclibc]
2478 # Return 1 if constructors with initialization priority arguments are
2479 # supposed on this target.
2481 proc check_effective_target_init_priority {} {
2482 return [check_no_compiler_messages init_priority assembly "
2483 void f() __attribute__((constructor (1000)));
2484 void f() \{\}
2488 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
2489 # This can be used with any check_* proc that takes no argument and
2490 # returns only 1 or 0. It could be used with check_* procs that take
2491 # arguments with keywords that pass particular arguments.
2493 proc is-effective-target { arg } {
2494 set selected 0
2495 if { [info procs check_effective_target_${arg}] != [list] } {
2496 set selected [check_effective_target_${arg}]
2497 } else {
2498 switch $arg {
2499 "vmx_hw" { set selected [check_vmx_hw_available] }
2500 "named_sections" { set selected [check_named_sections_available] }
2501 "gc_sections" { set selected [check_gc_sections_available] }
2502 "cxa_atexit" { set selected [check_cxa_atexit_available] }
2503 default { error "unknown effective target keyword `$arg'" }
2506 verbose "is-effective-target: $arg $selected" 2
2507 return $selected
2510 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
2512 proc is-effective-target-keyword { arg } {
2513 if { [info procs check_effective_target_${arg}] != [list] } {
2514 return 1
2515 } else {
2516 # These have different names for their check_* procs.
2517 switch $arg {
2518 "vmx_hw" { return 1 }
2519 "named_sections" { return 1 }
2520 "gc_sections" { return 1 }
2521 "cxa_atexit" { return 1 }
2522 default { return 0 }
2527 # Return 1 if target default to short enums
2529 proc check_effective_target_short_enums { } {
2530 return [check_no_compiler_messages short_enums assembly {
2531 enum foo { bar };
2532 int s[sizeof (enum foo) == 1 ? 1 : -1];
2536 # Return 1 if target supports merging string constants at link time.
2538 proc check_effective_target_string_merging { } {
2539 return [check_no_messages_and_pattern string_merging \
2540 "rodata\\.str" assembly {
2541 const char *var = "String";
2542 } {-O2}]
2545 # Return 1 if target has the basic signed and unsigned types in
2546 # <stdint.h>, 0 otherwise.
2548 proc check_effective_target_stdint_types { } {
2549 return [check_no_compiler_messages stdint_types assembly {
2550 #include <stdint.h>
2551 int8_t a; int16_t b; int32_t c; int64_t d;
2552 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
2556 # Return 1 if programs are intended to be run on a simulator
2557 # (i.e. slowly) rather than hardware (i.e. fast).
2559 proc check_effective_target_simulator { } {
2561 # All "src/sim" simulators set this one.
2562 if [board_info target exists is_simulator] {
2563 return [board_info target is_simulator]
2566 # The "sid" simulators don't set that one, but at least they set
2567 # this one.
2568 if [board_info target exists slow_simulator] {
2569 return [board_info target slow_simulator]
2572 return 0
2575 # Return 1 if the target is a VxWorks RTP.
2577 proc check_effective_target_vxworks_kernel { } {
2578 return [check_no_compiler_messages vxworks_kernel assembly {
2579 #if !defined __vxworks || defined __RTP__
2580 #error NO
2581 #endif
2585 # Return 1 if the target is expected to provide wide character support.
2587 proc check_effective_target_wchar { } {
2588 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
2589 return 0
2591 return [check_no_compiler_messages wchar assembly {
2592 #include <wchar.h>
2596 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
2598 proc add_options_for_c99_runtime { flags } {
2599 if { [istarget *-*-solaris2*] } {
2600 return "$flags -std=c99"
2602 if { [istarget powerpc-*-darwin*] } {
2603 return "$flags -mmacosx-version-min=10.3"
2605 return $flags
2608 # Return 1 if the target provides a full C99 runtime.
2610 proc check_effective_target_c99_runtime { } {
2611 return [check_cached_effective_target c99_runtime {
2612 global srcdir
2614 set file [open "$srcdir/gcc.dg/builtins-config.h"]
2615 set contents [read $file]
2616 close $file
2617 append contents {
2618 #ifndef HAVE_C99_RUNTIME
2619 #error FOO
2620 #endif
2622 string match "" [get_compiler_messages c99_runtime 0 assembly \
2623 $contents [add_options_for_c99_runtime ""]]