]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/lib/target-supports.exp
gcc/
[thirdparty/gcc.git] / gcc / testsuite / lib / target-supports.exp
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006
2 # Free Software Foundation, Inc.
3
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 2 of the License, or
7 # (at your option) any later version.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 # Please email any bugs, comments, and/or additions to this file to:
19 # gcc-patches@gcc.gnu.org
20
21 # This file defines procs for determining features supported by the target.
22
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.
26 #
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
38
39 if { [llength $args] > 0 } {
40 set options "additional_flags=[lindex $args 0]"
41 } else {
42 set options ""
43 }
44
45 set src ${basename}[pid].c
46 switch $type {
47 assembly { set output ${basename}[pid].s }
48 object { set output ${basename}[pid].o }
49 }
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
55
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"
67 }
68 close $chan
69 set result [list $lines $text]
70 }
71 } else {
72 set result $lines
73 }
74
75 remote_file build delete $output
76 return $result
77 }
78
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 ""
85 }
86 return $answer
87 }
88
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
95
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]]
103 }
104 set value $et_cache($prop,value)
105 verbose "check_no_compiler_messages $prop: returning $value for $target" 2
106 return $value
107 }
108
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
113
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]]]
123 }
124 set value $et_cache($prop,value)
125 verbose "check_no_messages_and_pattern $prop: returning $value for $target" 2
126 return $value
127 }
128
129 ###############################
130 # proc check_weak_available { }
131 ###############################
132
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
135
136 proc check_weak_available { } {
137 global target_triplet
138 global target_cpu
139
140 # All mips targets should support it
141
142 if { [ string first "mips" $target_cpu ] >= 0 } {
143 return 1
144 }
145
146 # All solaris2 targets should support it
147
148 if { [regexp ".*-solaris2.*" $target_triplet] } {
149 return 1
150 }
151
152 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
153
154 if { [regexp "alpha.*osf.*" $target_triplet] } {
155 return 1
156 }
157
158 # Windows targets Cygwin and MingW32 support it
159
160 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
161 return 1
162 }
163
164 # HP-UX 10.X doesn't support it
165
166 if { [regexp "hppa.*hpux10" $target_triplet] } {
167 return 0
168 }
169
170 # ELF and ECOFF support it. a.out does with gas/gld but may also with
171 # other linkers, so we should try it
172
173 set objformat [gcc_target_object_format]
174
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 }
183 }
184 }
185
186 ###############################
187 # proc check_visibility_available { what_kind }
188 ###############################
189
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.
193
194 proc check_visibility_available { what_kind } {
195 global tool
196 global target_triplet
197
198 # On NetWare, support makes no sense.
199 if { [istarget *-*-netware*] } {
200 return 0
201 }
202
203 if [string match "" $what_kind] { set what_kind "hidden" }
204
205 return [check_no_compiler_messages visibility_available_$what_kind object "
206 void f() __attribute__((visibility(\"$what_kind\")));
207 void f() {}
208 "]
209 }
210
211 ###############################
212 # proc check_alias_available { }
213 ###############################
214
215 # Determine if the target toolchain supports the alias attribute.
216
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.
221
222 proc check_alias_available { } {
223 global alias_available_saved
224 global tool
225
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
242
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
249
250 set objformat [gcc_target_object_format]
251
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
257 }
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
264 }
265 }
266 }
267
268 verbose "check_alias_available returning $alias_available_saved" 2
269 }
270
271 return $alias_available_saved
272 }
273
274 # Returns true if --gc-sections is supported on the target.
275
276 proc check_gc_sections_available { } {
277 global gc_sections_available_saved
278 global tool
279
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
287 }
288
289 # Check if the ld used by gcc supports --gc-sections.
290 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
291 regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
292 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
293 set ld_output [remote_exec host "$gcc_ld" "--help"]
294 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
295 set gc_sections_available_saved 1
296 } else {
297 set gc_sections_available_saved 0
298 }
299 }
300 return $gc_sections_available_saved
301 }
302
303 # Return true if profiling is supported on the target.
304
305 proc check_profiling_available { test_what } {
306 global profiling_available_saved
307
308 verbose "Profiling argument is <$test_what>" 1
309
310 # These conditions depend on the argument so examine them before
311 # looking at the cache variable.
312
313 # Support for -p on solaris2 relies on mcrt1.o which comes with the
314 # vendor compiler. We cannot reliably predict the directory where the
315 # vendor compiler (and thus mcrt1.o) is installed so we can't
316 # necessarily find mcrt1.o even if we have it.
317 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
318 return 0
319 }
320
321 # Support for -p on irix relies on libprof1.a which doesn't appear to
322 # exist on any irix6 system currently posting testsuite results.
323 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
324 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
325 if { [istarget mips*-*-irix*]
326 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
327 return 0
328 }
329
330 # At present, there is no profiling support on NetWare.
331 if { [istarget *-*-netware*] } {
332 return 0
333 }
334
335 # Now examine the cache variable.
336 if {![info exists profiling_available_saved]} {
337 # Some targets don't have any implementation of __bb_init_func or are
338 # missing other needed machinery.
339 if { [istarget mmix-*-*]
340 || [istarget arm*-*-eabi*]
341 || [istarget arm*-*-elf]
342 || [istarget arm*-*-symbianelf*]
343 || [istarget powerpc-*-eabi*]
344 || [istarget strongarm*-*-elf]
345 || [istarget xscale*-*-elf]
346 || [istarget cris-*-*]
347 || [istarget h8300-*-*]
348 || [istarget m32c-*-elf]
349 || [istarget m68k-*-elf]
350 || [istarget mips*-*-elf]
351 || [istarget xtensa-*-elf]
352 || [istarget *-*-windiss] } {
353 set profiling_available_saved 0
354 } else {
355 set profiling_available_saved 1
356 }
357 }
358
359 return $profiling_available_saved
360 }
361
362 # Return 1 if target has packed layout of structure members by
363 # default, 0 otherwise. Note that this is slightly different than
364 # whether the target has "natural alignment": both attributes may be
365 # false.
366
367 proc check_effective_target_default_packed { } {
368 return [check_no_compiler_messages default_packed assembly {
369 struct x { char a; long b; } c;
370 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
371 }]
372 }
373
374 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
375 # documentation, where the test also comes from.
376
377 proc check_effective_target_pcc_bitfield_type_matters { } {
378 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
379 # bitfields, but let's stick to the example code from the docs.
380 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
381 struct foo1 { char x; char :0; char y; };
382 struct foo2 { char x; int :0; char y; };
383 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
384 }]
385 }
386
387 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
388 #
389 # This won't change for different subtargets so cache the result.
390
391 proc check_effective_target_tls {} {
392 global et_tls_saved
393 global tool
394
395 if [info exists et_tls_saved] {
396 verbose "check_effective_target_tls: using cached result" 2
397 } else {
398 set et_tls_saved 1
399
400 set src tls[pid].c
401 set asm tls[pid].S
402 verbose "check_effective_target_tls: compiling testfile $src" 2
403 set f [open $src "w"]
404 # Compile a small test program.
405 puts $f "__thread int i;\n"
406 close $f
407
408 # Test for thread-local data supported by the platform.
409 set comp_output [${tool}_target_compile $src $asm assembly ""]
410 file delete $src
411 if { [string match "*not supported*" $comp_output] } {
412 set et_tls_saved 0
413 } else {
414 set fd [open $asm r]
415 set text [read $fd]
416 close $fd
417 if { [string match "*emutls*" $text]} {
418 set et_tls_saved 0
419 } else {
420 set et_tls_saved 1
421 }
422 }
423 remove-build-file $asm
424 }
425 verbose "check_effective_target_tls: returning $et_tls_saved" 2
426 return $et_tls_saved
427 }
428
429 # Return 1 if TLS executables can run correctly, 0 otherwise.
430 #
431 # This won't change for different subtargets so cache the result.
432
433 proc check_effective_target_tls_runtime {} {
434 global et_tls_runtime_saved
435 global tool
436
437 if [info exists et_tls_runtime_saved] {
438 verbose "check_effective_target_tls_runtime: using cached result" 2
439 } else {
440 set et_tls_runtime_saved 0
441
442 set src tls_runtime[pid].c
443 set exe tls_runtime[pid].x
444 verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
445 set f [open $src "w"]
446 # Compile a small test program.
447 puts $f "__thread int thr = 0;\n"
448 puts $f "int main(void)\n {\n return thr;\n}"
449 close $f
450
451 set comp_output \
452 [${tool}_target_compile $src $exe executable ""]
453 file delete $src
454
455 if [string match "" $comp_output] then {
456 # No error messages, everything is OK.
457
458 set result [remote_load target "./$exe" "" ""]
459 set status [lindex $result 0]
460 remote_file build delete $exe
461
462 verbose "check_effective_target_tls_runtime status is <$status>" 2
463
464 if { $status == "pass" } {
465 set et_tls_runtime_saved 1
466 }
467
468 verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
469 }
470 }
471
472 return $et_tls_runtime_saved
473 }
474
475 # Return 1 if compilation with -fopenmp is error-free for trivial
476 # code, 0 otherwise.
477
478 proc check_effective_target_fopenmp {} {
479 return [check_no_compiler_messages fopenmp object {
480 void foo (void) { }
481 } "-fopenmp"]
482 }
483
484 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
485 # for trivial code, 0 otherwise.
486
487 proc check_effective_target_freorder {} {
488 return [check_no_compiler_messages freorder object {
489 void foo (void) { }
490 } "-freorder-blocks-and-partition"]
491 }
492
493 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
494 # emitted, 0 otherwise. Whether a shared library can actually be built is
495 # out of scope for this test.
496
497 proc check_effective_target_fpic { } {
498 # Note that M68K has a multilib that supports -fpic but not
499 # -fPIC, so we need to check both. We test with a program that
500 # requires GOT references.
501 foreach arg {fpic fPIC} {
502 if [check_no_compiler_messages $arg object {
503 extern int foo (void); extern int bar;
504 int baz (void) { return foo () + bar; }
505 } "-$arg"] {
506 return 1
507 }
508 }
509 return 0
510 }
511
512 # Return true if the target supports -mpaired-single (as used on MIPS).
513
514 proc check_effective_target_mpaired_single { } {
515 return [check_no_compiler_messages mpaired_single object {
516 void foo (void) { }
517 } "-mpaired-single"]
518 }
519
520 # Return true if iconv is supported on the target. In particular IBM1047.
521
522 proc check_iconv_available { test_what } {
523 global tool
524 global libiconv
525
526 set result ""
527
528 set src iconv[pid].c
529 set exe iconv[pid].x
530 verbose "check_iconv_available compiling testfile $src" 2
531 set f [open $src "w"]
532 # Compile a small test program.
533 puts $f "#include <iconv.h>\n"
534 puts $f "int main (void)\n {\n iconv_t cd; \n"
535 puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
536 puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
537 puts $f "return 0;\n}"
538 close $f
539
540 # If the tool configuration file has not set libiconv, try "-liconv"
541 if { ![info exists libiconv] } {
542 set libiconv "-liconv"
543 }
544 set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
545 file delete $src
546
547 if [string match "" $lines] then {
548 # No error messages, everything is OK.
549
550 set result [${tool}_load "./$exe" "" ""]
551 set status [lindex $result 0]
552 remote_file build delete $exe
553
554 verbose "check_iconv_available status is <$status>" 2
555
556 if { $status == "pass" } then {
557 return 1
558 }
559 }
560
561 return 0
562 }
563
564 # Return true if named sections are supported on this target.
565
566 proc check_named_sections_available { } {
567 return [check_no_compiler_messages named_sections assembly {
568 int __attribute__ ((section("whatever"))) foo;
569 }]
570 }
571
572 # Return 1 if the target supports Fortran real kinds larger than real(8),
573 # 0 otherwise.
574 #
575 # When the target name changes, replace the cached result.
576
577 proc check_effective_target_fortran_large_real { } {
578 global et_fortran_large_real_saved
579 global et_fortran_large_real_target_name
580 global tool
581
582 if { ![info exists et_fortran_large_real_target_name] } {
583 set et_fortran_large_real_target_name ""
584 }
585
586 # If the target has changed since we set the cached value, clear it.
587 set current_target [current_target_name]
588 if { $current_target != $et_fortran_large_real_target_name } {
589 verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
590 set et_fortran_large_real_target_name $current_target
591 if [info exists et_fortran_large_real_saved] {
592 verbose "check_effective_target_fortran_large_real: removing cached result" 2
593 unset et_fortran_large_real_saved
594 }
595 }
596
597 if [info exists et_fortran_large_real_saved] {
598 verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
599 } else {
600 set et_fortran_large_real_saved 0
601
602 # Set up, compile, and execute a test program using large real
603 # kinds. Include the current process ID in the file names to
604 # prevent conflicts with invocations for multiple testsuites.
605 set src real[pid].f90
606 set exe real[pid].x
607
608 set f [open $src "w"]
609 puts $f "integer,parameter :: k = &"
610 puts $f " selected_real_kind (precision (0.0_8) + 1)"
611 puts $f "real(kind=k) :: x"
612 puts $f "x = cos (x);"
613 puts $f "end"
614 close $f
615
616 verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
617 set lines [${tool}_target_compile $src $exe executable ""]
618 file delete $src
619
620 if [string match "" $lines] then {
621 # No error message, compilation succeeded.
622 set et_fortran_large_real_saved 1
623 }
624 }
625
626 return $et_fortran_large_real_saved
627 }
628
629 # Return 1 if the target supports Fortran integer kinds larger than
630 # integer(8), 0 otherwise.
631 #
632 # When the target name changes, replace the cached result.
633
634 proc check_effective_target_fortran_large_int { } {
635 global et_fortran_large_int_saved
636 global et_fortran_large_int_target_name
637 global tool
638
639 if { ![info exists et_fortran_large_int_target_name] } {
640 set et_fortran_large_int_target_name ""
641 }
642
643 # If the target has changed since we set the cached value, clear it.
644 set current_target [current_target_name]
645 if { $current_target != $et_fortran_large_int_target_name } {
646 verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
647 set et_fortran_large_int_target_name $current_target
648 if [info exists et_fortran_large_int_saved] {
649 verbose "check_effective_target_fortran_large_int: removing cached result" 2
650 unset et_fortran_large_int_saved
651 }
652 }
653
654 if [info exists et_fortran_large_int_saved] {
655 verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
656 } else {
657 set et_fortran_large_int_saved 0
658
659 # Set up, compile, and execute a test program using large integer
660 # kinds. Include the current process ID in the file names to
661 # prevent conflicts with invocations for multiple testsuites.
662 set src int[pid].f90
663 set exe int[pid].x
664
665 set f [open $src "w"]
666 puts $f "integer,parameter :: k = &"
667 puts $f " selected_int_kind (range (0_8) + 1)"
668 puts $f "integer(kind=k) :: i"
669 puts $f "end"
670 close $f
671
672 verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
673 set lines [${tool}_target_compile $src $exe executable ""]
674 file delete $src
675
676 if [string match "" $lines] then {
677 # No error message, compilation succeeded.
678 set et_fortran_large_int_saved 1
679 }
680 }
681
682 return $et_fortran_large_int_saved
683 }
684
685 # Return 1 if we can statically link libgfortran, 0 otherwise.
686 #
687 # When the target name changes, replace the cached result.
688
689 proc check_effective_target_static_libgfortran { } {
690 global et_static_libgfortran
691 global et_static_libgfortran_target_name
692 global tool
693
694 if { ![info exists et_static_libgfortran_target_name] } {
695 set et_static_libgfortran_target_name ""
696 }
697
698 # If the target has changed since we set the cached value, clear it.
699 set current_target [current_target_name]
700 if { $current_target != $et_static_libgfortran_target_name } {
701 verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
702 set et_static_libgfortran_target_name $current_target
703 if [info exists et_static_libgfortran_saved] {
704 verbose "check_effective_target_static_libgfortran: removing cached result" 2
705 unset et_static_libgfortran_saved
706 }
707 }
708
709 if [info exists et_static_libgfortran_saved] {
710 verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
711 } else {
712 set et_static_libgfortran_saved 0
713
714 # Set up, compile, and execute a test program using static linking.
715 # Include the current process ID in the file names to prevent
716 # conflicts with invocations for multiple testsuites.
717 set opts "additional_flags=-static"
718 set src static[pid].f
719 set exe static[pid].x
720
721 set f [open $src "w"]
722 puts $f " print *, 'test'"
723 puts $f " end"
724 close $f
725
726 verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
727 set lines [${tool}_target_compile $src $exe executable "$opts"]
728 file delete $src
729
730 if [string match "" $lines] then {
731 # No error message, compilation succeeded.
732 set et_static_libgfortran_saved 1
733 }
734 }
735
736 return $et_static_libgfortran_saved
737 }
738
739 # Return 1 if the target supports executing AltiVec instructions, 0
740 # otherwise. Cache the result.
741
742 proc check_vmx_hw_available { } {
743 global vmx_hw_available_saved
744 global tool
745
746 if [info exists vmx_hw_available_saved] {
747 verbose "check_hw_available returning saved $vmx_hw_available_saved" 2
748 } else {
749 set vmx_hw_available_saved 0
750
751 # Some simulators are known to not support VMX instructions.
752 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
753 verbose "check_hw_available returning 0" 2
754 return $vmx_hw_available_saved
755 }
756
757 # Set up, compile, and execute a test program containing VMX
758 # instructions. Include the current process ID in the file
759 # names to prevent conflicts with invocations for multiple
760 # testsuites.
761 set src vmx[pid].c
762 set exe vmx[pid].x
763
764 set f [open $src "w"]
765 puts $f "int main() {"
766 puts $f "#ifdef __MACH__"
767 puts $f " asm volatile (\"vor v0,v0,v0\");"
768 puts $f "#else"
769 puts $f " asm volatile (\"vor 0,0,0\");"
770 puts $f "#endif"
771 puts $f " return 0; }"
772 close $f
773
774 # Most targets don't require special flags for this test case, but
775 # Darwin does.
776 if [istarget *-*-darwin*] {
777 set opts "additional_flags=-maltivec"
778 } else {
779 set opts ""
780 }
781
782 verbose "check_vmx_hw_available compiling testfile $src" 2
783 set lines [${tool}_target_compile $src $exe executable "$opts"]
784 file delete $src
785
786 if [string match "" $lines] then {
787 # No error message, compilation succeeded.
788 set result [${tool}_load "./$exe" "" ""]
789 set status [lindex $result 0]
790 remote_file build delete $exe
791 verbose "check_vmx_hw_available testfile status is <$status>" 2
792
793 if { $status == "pass" } then {
794 set vmx_hw_available_saved 1
795 }
796 } else {
797 verbose "check_vmx_hw_availalble testfile compilation failed" 2
798 }
799 }
800
801 return $vmx_hw_available_saved
802 }
803
804 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
805 # complex float arguments. This affects gfortran tests that call cabsf
806 # in libm built by an earlier compiler. Return 1 if libm uses the same
807 # argument passing as the compiler under test, 0 otherwise.
808 #
809 # When the target name changes, replace the cached result.
810
811 proc check_effective_target_broken_cplxf_arg { } {
812 global et_broken_cplxf_arg_saved
813 global et_broken_cplxf_arg_target_name
814 global tool
815
816 # Skip the work for targets known not to be affected.
817 if { ![istarget powerpc64-*-linux*] } {
818 return 0
819 } elseif { [is-effective-target ilp32] } {
820 return 0
821 }
822
823 if { ![info exists et_broken_cplxf_arg_target_name] } {
824 set et_broken_cplxf_arg_target_name ""
825 }
826
827 # If the target has changed since we set the cached value, clear it.
828 set current_target [current_target_name]
829 if { $current_target != $et_broken_cplxf_arg_target_name } {
830 verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
831 set et_broken_cplxf_arg_target_name $current_target
832 if [info exists et_broken_cplxf_arg_saved] {
833 verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
834 unset et_broken_cplxf_arg_saved
835 }
836 }
837
838 if [info exists et_broken_cplxf_arg_saved] {
839 verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
840 } else {
841 set et_broken_cplxf_arg_saved 0
842 # This is only known to affect one target.
843 if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
844 set et_broken_cplxf_arg_saved 0
845 verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
846 return $et_broken_cplxf_arg_saved
847 }
848
849 # Set up, compile, and execute a C test program that calls cabsf.
850 set src cabsf[pid].c
851 set exe cabsf[pid].x
852
853 set f [open $src "w"]
854 puts $f "#include <complex.h>"
855 puts $f "extern void abort (void);"
856 puts $f "float fabsf (float);"
857 puts $f "float cabsf (_Complex float);"
858 puts $f "int main ()"
859 puts $f "{"
860 puts $f " _Complex float cf;"
861 puts $f " float f;"
862 puts $f " cf = 3 + 4.0fi;"
863 puts $f " f = cabsf (cf);"
864 puts $f " if (fabsf (f - 5.0) > 0.0001) abort ();"
865 puts $f " return 0;"
866 puts $f "}"
867 close $f
868
869 set lines [${tool}_target_compile $src $exe executable "-lm"]
870 file delete $src
871
872 if [string match "" $lines] {
873 # No error message, compilation succeeded.
874 set result [${tool}_load "./$exe" "" ""]
875 set status [lindex $result 0]
876 remote_file build delete $exe
877
878 verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
879
880 if { $status != "pass" } {
881 set et_broken_cplxf_arg_saved 1
882 }
883 } else {
884 verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
885 }
886 }
887 return $et_broken_cplxf_arg_saved
888 }
889
890 proc check_alpha_max_hw_available { } {
891 global alpha_max_hw_available_saved
892 global tool
893
894 if [info exists alpha_max_hw_available_saved] {
895 verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
896 } else {
897 set alpha_max_hw_available_saved 0
898
899 # Set up, compile, and execute a test program probing bit 8 of the
900 # architecture mask, which indicates presence of MAX instructions.
901 set src max[pid].c
902 set exe max[pid].x
903
904 set f [open $src "w"]
905 puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
906 close $f
907
908 verbose "check_alpha_max_hw_available compiling testfile $src" 2
909 set lines [${tool}_target_compile $src $exe executable ""]
910 file delete $src
911
912 if [string match "" $lines] then {
913 # No error message, compilation succeeded.
914 set result [${tool}_load "./$exe" "" ""]
915 set status [lindex $result 0]
916 remote_file build delete $exe
917 verbose "check_alpha_max_hw_available testfile status is <$status>" 2
918
919 if { $status == "pass" } then {
920 set alpha_max_hw_available_saved 1
921 }
922 } else {
923 verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
924 }
925 }
926
927 return $alpha_max_hw_available_saved
928 }
929
930 # Returns true iff the FUNCTION is available on the target system.
931 # (This is essentially a Tcl implementation of Autoconf's
932 # AC_CHECK_FUNC.)
933
934 proc check_function_available { function } {
935 set var "${function}_available_saved"
936 global $var
937 global tool
938
939 if {![info exists $var]} {
940 # Assume it exists.
941 set $var 1
942 # Check to make sure.
943 set src "function[pid].c"
944 set exe "function[pid].exe"
945
946 set f [open $src "w"]
947 puts $f "int main () { $function (); }"
948 close $f
949
950 set lines [${tool}_target_compile $src $exe executable ""]
951 file delete $src
952 file delete $exe
953
954 if {![string match "" $lines]} then {
955 set $var 0
956 verbose -log "$function is not available"
957 } else {
958 verbose -log "$function is available"
959 }
960 }
961
962 eval return \$$var
963 }
964
965 # Returns true iff "fork" is available on the target system.
966
967 proc check_fork_available {} {
968 return [check_function_available "fork"]
969 }
970
971 # Returns true iff "mkfifo" is available on the target system.
972
973 proc check_mkfifo_available {} {
974 if {[istarget *-*-cygwin*]} {
975 # Cygwin has mkfifo, but support is incomplete.
976 return 0
977 }
978
979 return [check_function_available "mkfifo"]
980 }
981
982 # Returns true iff "__cxa_atexit" is used on the target system.
983
984 proc check_cxa_atexit_available { } {
985 global et_cxa_atexit
986 global et_cxa_atexit_target_name
987 global tool
988
989 if { ![info exists et_cxa_atexit_target_name] } {
990 set et_cxa_atexit_target_name ""
991 }
992
993 # If the target has changed since we set the cached value, clear it.
994 set current_target [current_target_name]
995 if { $current_target != $et_cxa_atexit_target_name } {
996 verbose "check_cxa_atexit_available: `$et_cxa_atexit_target_name'" 2
997 set et_cxa_atexit_target_name $current_target
998 if [info exists et_cxa_atexit] {
999 verbose "check_cxa_atexit_available: removing cached result" 2
1000 unset et_cxa_atexit
1001 }
1002 }
1003
1004 if [info exists et_cxa_atexit] {
1005 verbose "check_cxa_atexit_available: using cached result" 2
1006 } else {
1007 set et_cxa_atexit 0
1008
1009 # Set up, compile, and execute a C++ test program that depends
1010 # on correct ordering of static object destructors. This is
1011 # indicative of the presence and use of __cxa_atexit.
1012 set src cxaatexit[pid].cc
1013 set exe cxaatexit[pid].x
1014
1015 set f [open $src "w"]
1016 puts $f "#include <stdlib.h>"
1017 puts $f "static unsigned int count;"
1018 puts $f "struct X"
1019 puts $f "{"
1020 puts $f " X() { count = 1; }"
1021 puts $f " ~X()"
1022 puts $f " {"
1023 puts $f " if (count != 3)"
1024 puts $f " exit(1);"
1025 puts $f " count = 4;"
1026 puts $f " }"
1027 puts $f "};"
1028 puts $f "void f()"
1029 puts $f "{"
1030 puts $f " static X x;"
1031 puts $f "}"
1032 puts $f "struct Y"
1033 puts $f "{"
1034 puts $f " Y() { f(); count = 2; }"
1035 puts $f " ~Y()"
1036 puts $f " {"
1037 puts $f " if (count != 2)"
1038 puts $f " exit(1);"
1039 puts $f " count = 3;"
1040 puts $f " }"
1041 puts $f "};"
1042 puts $f "Y y;"
1043 puts $f "int main()"
1044 puts $f "{ return 0; }"
1045 close $f
1046
1047 set lines [${tool}_target_compile $src $exe executable ""]
1048 file delete $src
1049
1050 if [string match "" $lines] {
1051 # No error message, compilation succeeded.
1052 set result [${tool}_load "./$exe" "" ""]
1053 set status [lindex $result 0]
1054 remote_file build delete $exe
1055
1056 verbose "check_cxa_atexit_available: status is <$status>" 2
1057
1058 if { $status == "pass" } {
1059 set et_cxa_atexit 1
1060 }
1061 } else {
1062 verbose "check_cxa_atexit_available: compilation failed" 2
1063 }
1064 }
1065 return $et_cxa_atexit
1066 }
1067
1068
1069 # Return 1 if we're generating 32-bit code using default options, 0
1070 # otherwise.
1071
1072 proc check_effective_target_ilp32 { } {
1073 return [check_no_compiler_messages ilp32 object {
1074 int dummy[sizeof (int) == 4
1075 && sizeof (void *) == 4
1076 && sizeof (long) == 4 ? 1 : -1];
1077 }]
1078 }
1079
1080 # Return 1 if we're generating 32-bit or larger integers using default
1081 # options, 0 otherwise.
1082
1083 proc check_effective_target_int32plus { } {
1084 return [check_no_compiler_messages int32plus object {
1085 int dummy[sizeof (int) >= 4 ? 1 : -1];
1086 }]
1087 }
1088
1089 # Return 1 if we're generating 32-bit or larger pointers using default
1090 # options, 0 otherwise.
1091
1092 proc check_effective_target_ptr32plus { } {
1093 return [check_no_compiler_messages ptr32plus object {
1094 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1095 }]
1096 }
1097
1098 # Return 1 if we support 32-bit or larger array and structure sizes
1099 # using default options, 0 otherwise.
1100
1101 proc check_effective_target_size32plus { } {
1102 return [check_no_compiler_messages size32plus object {
1103 char dummy[65537];
1104 }]
1105 }
1106
1107 # Returns 1 if we're generating 16-bit or smaller integers with the
1108 # default options, 0 otherwise.
1109
1110 proc check_effective_target_int16 { } {
1111 return [check_no_compiler_messages int16 object {
1112 int dummy[sizeof (int) < 4 ? 1 : -1];
1113 }]
1114 }
1115
1116 # Return 1 if we're generating 64-bit code using default options, 0
1117 # otherwise.
1118
1119 proc check_effective_target_lp64 { } {
1120 return [check_no_compiler_messages lp64 object {
1121 int dummy[sizeof (int) == 4
1122 && sizeof (void *) == 8
1123 && sizeof (long) == 8 ? 1 : -1];
1124 }]
1125 }
1126
1127 # Return 1 if the target supports compiling decimal floating point,
1128 # 0 otherwise.
1129
1130 proc check_effective_target_dfp_nocache { } {
1131 verbose "check_effective_target_dfp_nocache: compiling source" 2
1132 set ret [string match "" [get_compiler_messages dfp 0 object {
1133 _Decimal32 x; _Decimal64 y; _Decimal128 z;
1134 }]]
1135 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1136 return $ret
1137 }
1138
1139 proc check_effective_target_dfprt_nocache { } {
1140 global tool
1141
1142 set ret 0
1143
1144 verbose "check_effective_target_dfprt_nocache: compiling source" 2
1145 # Set up, compile, and execute a test program containing decimal
1146 # float operations.
1147 set src dfprt[pid].c
1148 set exe dfprt[pid].x
1149
1150 set f [open $src "w"]
1151 puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1152 puts $f "int main () { z = x + y; return 0; }"
1153 close $f
1154
1155 verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1156 set lines [${tool}_target_compile $src $exe executable ""]
1157 file delete $src
1158
1159 if [string match "" $lines] then {
1160 # No error message, compilation succeeded.
1161 set result [${tool}_load "./$exe" "" ""]
1162 set status [lindex $result 0]
1163 remote_file build delete $exe
1164 verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1165 if { $status == "pass" } then {
1166 set ret 1
1167 }
1168 }
1169 return $ret
1170 verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1171 }
1172
1173 # Return 1 if the target supports compiling Decimal Floating Point,
1174 # 0 otherwise.
1175 #
1176 # This won't change for different subtargets so cache the result.
1177
1178 proc check_effective_target_dfp { } {
1179 global et_dfp_saved
1180
1181 if [info exists et_dfp_saved] {
1182 verbose "check_effective_target_dfp: using cached result" 2
1183 } else {
1184 set et_dfp_saved [check_effective_target_dfp_nocache]
1185 }
1186 verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1187 return $et_dfp_saved
1188 }
1189
1190 # Return 1 if the target supports linking and executing Decimal Floating
1191 # Point, # 0 otherwise.
1192 #
1193 # This won't change for different subtargets so cache the result.
1194
1195 proc check_effective_target_dfprt { } {
1196 global et_dfprt_saved
1197 global tool
1198
1199 if [info exists et_dfprt_saved] {
1200 verbose "check_effective_target_dfprt: using cached result" 2
1201 } else {
1202 set et_dfprt_saved [check_effective_target_dfprt_nocache]
1203 }
1204 verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1205 return $et_dfprt_saved
1206 }
1207
1208 # Return 1 if the target needs a command line argument to enable a SIMD
1209 # instruction set.
1210 #
1211 # This won't change for different subtargets so cache the result.
1212
1213 proc check_effective_target_vect_cmdline_needed { } {
1214 global et_vect_cmdline_needed_saved
1215
1216 if [info exists et_vect_cmdline_needed_saved] {
1217 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1218 } else {
1219 set et_vect_cmdline_needed_saved 1
1220 if { [istarget ia64-*-*]
1221 || [istarget x86_64-*-*] } {
1222 set et_vect_cmdline_needed_saved 0
1223 }
1224 }
1225
1226 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1227 return $et_vect_cmdline_needed_saved
1228 }
1229
1230 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1231 #
1232 # This won't change for different subtargets so cache the result.
1233
1234 proc check_effective_target_vect_int { } {
1235 global et_vect_int_saved
1236
1237 if [info exists et_vect_int_saved] {
1238 verbose "check_effective_target_vect_int: using cached result" 2
1239 } else {
1240 set et_vect_int_saved 0
1241 if { [istarget i?86-*-*]
1242 || [istarget powerpc*-*-*]
1243 || [istarget x86_64-*-*]
1244 || [istarget sparc*-*-*]
1245 || [istarget alpha*-*-*]
1246 || [istarget ia64-*-*] } {
1247 set et_vect_int_saved 1
1248 }
1249 }
1250
1251 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1252 return $et_vect_int_saved
1253 }
1254
1255 # Return 1 is this is an arm target using 32-bit instructions
1256 proc check_effective_target_arm32 { } {
1257 global et_arm32_saved
1258 global et_arm32_target_name
1259 global compiler_flags
1260
1261 if { ![info exists et_arm32_target_name] } {
1262 set et_arm32_target_name ""
1263 }
1264
1265 # If the target has changed since we set the cached value, clear it.
1266 set current_target [current_target_name]
1267 if { $current_target != $et_arm32_target_name } {
1268 verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1269 set et_arm32_target_name $current_target
1270 if { [info exists et_arm32_saved] } {
1271 verbose "check_effective_target_arm32: removing cached result" 2
1272 unset et_arm32_saved
1273 }
1274 }
1275
1276 if [info exists et_arm32_saved] {
1277 verbose "check-effective_target_arm32: using cached result" 2
1278 } else {
1279 set et_arm32_saved 0
1280 if { [istarget arm-*-*]
1281 || [istarget strongarm*-*-*]
1282 || [istarget xscale-*-*] } {
1283 if ![string match "*-mthumb *" $compiler_flags] {
1284 set et_arm32_saved 1
1285 }
1286 }
1287 }
1288 verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1289 return $et_arm32_saved
1290 }
1291
1292 # Return 1 if this is a PowerPC target with floating-point registers.
1293
1294 proc check_effective_target_powerpc_fprs { } {
1295 if { [istarget powerpc*-*-*]
1296 || [istarget rs6000-*-*] } {
1297 return [check_no_compiler_messages powerpc_fprs object {
1298 #ifdef __NO_FPRS__
1299 #error no FPRs
1300 #else
1301 int dummy;
1302 #endif
1303 }]
1304 } else {
1305 return 0
1306 }
1307 }
1308
1309 # Return 1 if this is a PowerPC target supporting -maltivec.
1310
1311 proc check_effective_target_powerpc_altivec_ok { } {
1312 if { [istarget powerpc*-*-*]
1313 || [istarget rs6000-*-*] } {
1314 # AltiVec is not supported on Aix.
1315 if { [istarget powerpc*-*-aix*] } {
1316 return 0
1317 }
1318 return [check_no_compiler_messages powerpc_altivec_ok object {
1319 int dummy;
1320 } "-maltivec"]
1321 } else {
1322 return 0
1323 }
1324 }
1325
1326 # Return 1 if the target supports hardware vector shift operation.
1327
1328 proc check_effective_target_vect_shift { } {
1329 global et_vect_shift_saved
1330
1331 if [info exists et_vect_shift_saved] {
1332 verbose "check_effective_target_vect_shift: using cached result" 2
1333 } else {
1334 set et_vect_shift_saved 0
1335 if { [istarget powerpc*-*-*]
1336 || [istarget ia64-*-*]
1337 || [istarget i?86-*-*]
1338 || [istarget x86_64-*-*] } {
1339 set et_vect_shift_saved 1
1340 }
1341 }
1342
1343 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1344 return $et_vect_shift_saved
1345 }
1346
1347 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1348 #
1349 # This can change for different subtargets so do not cache the result.
1350
1351 proc check_effective_target_vect_long { } {
1352 if { [istarget i?86-*-*]
1353 || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1354 || [istarget x86_64-*-*]
1355 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1356 set answer 1
1357 } else {
1358 set answer 0
1359 }
1360
1361 verbose "check_effective_target_vect_long: returning $answer" 2
1362 return $answer
1363 }
1364
1365 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1366 #
1367 # This won't change for different subtargets so cache the result.
1368
1369 proc check_effective_target_vect_float { } {
1370 global et_vect_float_saved
1371
1372 if [info exists et_vect_float_saved] {
1373 verbose "check_effective_target_vect_float: using cached result" 2
1374 } else {
1375 set et_vect_float_saved 0
1376 if { [istarget i?86-*-*]
1377 || [istarget powerpc*-*-*]
1378 || [istarget mipsisa64*-*-*]
1379 || [istarget x86_64-*-*]
1380 || [istarget ia64-*-*] } {
1381 set et_vect_float_saved 1
1382 }
1383 }
1384
1385 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1386 return $et_vect_float_saved
1387 }
1388
1389 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1390 #
1391 # This won't change for different subtargets so cache the result.
1392
1393 proc check_effective_target_vect_double { } {
1394 global et_vect_double_saved
1395
1396 if [info exists et_vect_double_saved] {
1397 verbose "check_effective_target_vect_double: using cached result" 2
1398 } else {
1399 set et_vect_double_saved 0
1400 if { [istarget i?86-*-*]
1401 || [istarget x86_64-*-*] } {
1402 set et_vect_double_saved 1
1403 }
1404 }
1405
1406 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1407 return $et_vect_double_saved
1408 }
1409
1410 # Return 1 if the target plus current options does not support a vector
1411 # max instruction on "int", 0 otherwise.
1412 #
1413 # This won't change for different subtargets so cache the result.
1414
1415 proc check_effective_target_vect_no_int_max { } {
1416 global et_vect_no_int_max_saved
1417
1418 if [info exists et_vect_no_int_max_saved] {
1419 verbose "check_effective_target_vect_no_int_max: using cached result" 2
1420 } else {
1421 set et_vect_no_int_max_saved 0
1422 if { [istarget sparc*-*-*]
1423 || [istarget alpha*-*-*] } {
1424 set et_vect_no_int_max_saved 1
1425 }
1426 }
1427 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1428 return $et_vect_no_int_max_saved
1429 }
1430
1431 # Return 1 if the target plus current options does not support a vector
1432 # add instruction on "int", 0 otherwise.
1433 #
1434 # This won't change for different subtargets so cache the result.
1435
1436 proc check_effective_target_vect_no_int_add { } {
1437 global et_vect_no_int_add_saved
1438
1439 if [info exists et_vect_no_int_add_saved] {
1440 verbose "check_effective_target_vect_no_int_add: using cached result" 2
1441 } else {
1442 set et_vect_no_int_add_saved 0
1443 # Alpha only supports vector add on V8QI and V4HI.
1444 if { [istarget alpha*-*-*] } {
1445 set et_vect_no_int_add_saved 1
1446 }
1447 }
1448 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1449 return $et_vect_no_int_add_saved
1450 }
1451
1452 # Return 1 if the target plus current options does not support vector
1453 # bitwise instructions, 0 otherwise.
1454 #
1455 # This won't change for different subtargets so cache the result.
1456
1457 proc check_effective_target_vect_no_bitwise { } {
1458 global et_vect_no_bitwise_saved
1459
1460 if [info exists et_vect_no_bitwise_saved] {
1461 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1462 } else {
1463 set et_vect_no_bitwise_saved 0
1464 }
1465 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1466 return $et_vect_no_bitwise_saved
1467 }
1468
1469 # Return 1 if the target plus current options supports a vector
1470 # widening summation of *short* args into *int* result, 0 otherwise.
1471 #
1472 # This won't change for different subtargets so cache the result.
1473
1474 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1475 global et_vect_widen_sum_hi_to_si
1476
1477 if [info exists et_vect_widen_sum_hi_to_si_saved] {
1478 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1479 } else {
1480 set et_vect_widen_sum_hi_to_si_saved 0
1481 if { [istarget powerpc*-*-*]
1482 || [istarget ia64-*-*] } {
1483 set et_vect_widen_sum_hi_to_si_saved 1
1484 }
1485 }
1486 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1487 return $et_vect_widen_sum_hi_to_si_saved
1488 }
1489
1490 # Return 1 if the target plus current options supports a vector
1491 # widening summation of *char* args into *short* result, 0 otherwise.
1492 #
1493 # This won't change for different subtargets so cache the result.
1494
1495 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1496 global et_vect_widen_sum_qi_to_hi
1497
1498 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1499 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1500 } else {
1501 set et_vect_widen_sum_qi_to_hi_saved 0
1502 if { [istarget ia64-*-*] } {
1503 set et_vect_widen_sum_qi_to_hi_saved 1
1504 }
1505 }
1506 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1507 return $et_vect_widen_sum_qi_to_hi_saved
1508 }
1509
1510 # Return 1 if the target plus current options supports a vector
1511 # widening summation of *char* args into *int* result, 0 otherwise.
1512 #
1513 # This won't change for different subtargets so cache the result.
1514
1515 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1516 global et_vect_widen_sum_qi_to_si
1517
1518 if [info exists et_vect_widen_sum_qi_to_si_saved] {
1519 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1520 } else {
1521 set et_vect_widen_sum_qi_to_si_saved 0
1522 if { [istarget powerpc*-*-*] } {
1523 set et_vect_widen_sum_qi_to_si_saved 1
1524 }
1525 }
1526 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1527 return $et_vect_widen_sum_qi_to_si_saved
1528 }
1529
1530 # Return 1 if the target plus current options supports a vector
1531 # widening summation, 0 otherwise.
1532 #
1533 # This won't change for different subtargets so cache the result.
1534
1535 proc check_effective_target_vect_widen_sum { } {
1536 global et_vect_widen_sum
1537
1538 if [info exists et_vect_widen_sum_saved] {
1539 verbose "check_effective_target_vect_widen_sum: using cached result" 2
1540 } else {
1541 set et_vect_widen_sum_saved 0
1542 if { [istarget powerpc*-*-*]
1543 || [istarget ia64-*-*] } {
1544 set et_vect_widen_sum_saved 1
1545 }
1546 }
1547 verbose "check_effective_target_vect_widen_sum: returning $et_vect_widen_sum_saved" 2
1548 return $et_vect_widen_sum_saved
1549 }
1550
1551 # Return 1 if the target plus current options supports a vector
1552 # dot-product of signed chars, 0 otherwise.
1553 #
1554 # This won't change for different subtargets so cache the result.
1555
1556 proc check_effective_target_vect_sdot_qi { } {
1557 global et_vect_sdot_qi
1558
1559 if [info exists et_vect_sdot_qi_saved] {
1560 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1561 } else {
1562 set et_vect_sdot_qi_saved 0
1563 if { [istarget ia64-*-*] } {
1564 set et_vect_sdot_qi_saved 1
1565 }
1566 }
1567 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1568 return $et_vect_sdot_qi_saved
1569 }
1570
1571 # Return 1 if the target plus current options supports a vector
1572 # dot-product of unsigned chars, 0 otherwise.
1573 #
1574 # This won't change for different subtargets so cache the result.
1575
1576 proc check_effective_target_vect_udot_qi { } {
1577 global et_vect_udot_qi
1578
1579 if [info exists et_vect_udot_qi_saved] {
1580 verbose "check_effective_target_vect_udot_qi: using cached result" 2
1581 } else {
1582 set et_vect_udot_qi_saved 0
1583 if { [istarget powerpc*-*-*]
1584 || [istarget ia64-*-*] } {
1585 set et_vect_udot_qi_saved 1
1586 }
1587 }
1588 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1589 return $et_vect_udot_qi_saved
1590 }
1591
1592 # Return 1 if the target plus current options supports a vector
1593 # dot-product of signed shorts, 0 otherwise.
1594 #
1595 # This won't change for different subtargets so cache the result.
1596
1597 proc check_effective_target_vect_sdot_hi { } {
1598 global et_vect_sdot_hi
1599
1600 if [info exists et_vect_sdot_hi_saved] {
1601 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1602 } else {
1603 set et_vect_sdot_hi_saved 0
1604 if { [istarget powerpc*-*-*]
1605 || [istarget i?86-*-*]
1606 || [istarget x86_64-*-*]
1607 || [istarget ia64-*-*] } {
1608 set et_vect_sdot_hi_saved 1
1609 }
1610 }
1611 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1612 return $et_vect_sdot_hi_saved
1613 }
1614
1615 # Return 1 if the target plus current options supports a vector
1616 # dot-product of unsigned shorts, 0 otherwise.
1617 #
1618 # This won't change for different subtargets so cache the result.
1619
1620 proc check_effective_target_vect_udot_hi { } {
1621 global et_vect_udot_hi
1622
1623 if [info exists et_vect_udot_hi_saved] {
1624 verbose "check_effective_target_vect_udot_hi: using cached result" 2
1625 } else {
1626 set et_vect_udot_hi_saved 0
1627 if { [istarget powerpc*-*-*] } {
1628 set et_vect_udot_hi_saved 1
1629 }
1630 }
1631 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1632 return $et_vect_udot_hi_saved
1633 }
1634
1635
1636 # Return 1 if the target plus current options does not support a vector
1637 # alignment mechanism, 0 otherwise.
1638 #
1639 # This won't change for different subtargets so cache the result.
1640
1641 proc check_effective_target_vect_no_align { } {
1642 global et_vect_no_align_saved
1643
1644 if [info exists et_vect_no_align_saved] {
1645 verbose "check_effective_target_vect_no_align: using cached result" 2
1646 } else {
1647 set et_vect_no_align_saved 0
1648 if { [istarget mipsisa64*-*-*]
1649 || [istarget sparc*-*-*]
1650 || [istarget ia64-*-*] } {
1651 set et_vect_no_align_saved 1
1652 }
1653 }
1654 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1655 return $et_vect_no_align_saved
1656 }
1657
1658 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1659
1660 proc check_effective_target_vect_condition { } {
1661 global et_vect_cond_saved
1662
1663 if [info exists et_vect_cond_saved] {
1664 verbose "check_effective_target_vect_cond: using cached result" 2
1665 } else {
1666 set et_vect_cond_saved 0
1667 if { [istarget powerpc*-*-*]
1668 || [istarget ia64-*-*]
1669 || [istarget i?86-*-*]
1670 || [istarget x86_64-*-*] } {
1671 set et_vect_cond_saved 1
1672 }
1673 }
1674
1675 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1676 return $et_vect_cond_saved
1677 }
1678
1679 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1680
1681 proc check_effective_target_vect_char_mult { } {
1682 global et_vect_char_mult_saved
1683
1684 if [info exists et_vect_char_mult_saved] {
1685 verbose "check_effective_target_vect_char_mult: using cached result" 2
1686 } else {
1687 set et_vect_char_mult_saved 0
1688 if { [istarget ia64-*-*]
1689 || [istarget i?86-*-*]
1690 || [istarget x86_64-*-*] } {
1691 set et_vect_char_mult_saved 1
1692 }
1693 }
1694
1695 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1696 return $et_vect_char_mult_saved
1697 }
1698
1699 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1700
1701 proc check_effective_target_vect_short_mult { } {
1702 global et_vect_short_mult_saved
1703
1704 if [info exists et_vect_short_mult_saved] {
1705 verbose "check_effective_target_vect_short_mult: using cached result" 2
1706 } else {
1707 set et_vect_short_mult_saved 0
1708 if { [istarget ia64-*-*]
1709 || [istarget i?86-*-*]
1710 || [istarget x86_64-*-*] } {
1711 set et_vect_short_mult_saved 1
1712 }
1713 }
1714
1715 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1716 return $et_vect_short_mult_saved
1717 }
1718
1719 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1720
1721 proc check_effective_target_vect_int_mult { } {
1722 global et_vect_int_mult_saved
1723
1724 if [info exists et_vect_int_mult_saved] {
1725 verbose "check_effective_target_vect_int_mult: using cached result" 2
1726 } else {
1727 set et_vect_int_mult_saved 0
1728 if { [istarget powerpc*-*-*]
1729 || [istarget i?86-*-*]
1730 || [istarget x86_64-*-*] } {
1731 set et_vect_int_mult_saved 1
1732 }
1733 }
1734
1735 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1736 return $et_vect_int_mult_saved
1737 }
1738
1739 # Return 1 if the target supports section-anchors
1740
1741 proc check_effective_target_section_anchors { } {
1742 global et_section_anchors_saved
1743
1744 if [info exists et_section_anchors_saved] {
1745 verbose "check_effective_target_section_anchors: using cached result" 2
1746 } else {
1747 set et_section_anchors_saved 0
1748 if { [istarget powerpc*-*-*] } {
1749 set et_section_anchors_saved 1
1750 }
1751 }
1752
1753 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
1754 return $et_section_anchors_saved
1755 }
1756
1757 # Return 1 if the target supports atomic operations on "int" and "long".
1758
1759 proc check_effective_target_sync_int_long { } {
1760 global et_sync_int_long_saved
1761
1762 if [info exists et_sync_int_long_saved] {
1763 verbose "check_effective_target_sync_int_long: using cached result" 2
1764 } else {
1765 set et_sync_int_long_saved 0
1766 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1767 # load-reserved/store-conditional instructions.
1768 if { [istarget ia64-*-*]
1769 || [istarget i?86-*-*]
1770 || [istarget x86_64-*-*]
1771 || [istarget alpha*-*-*]
1772 || [istarget s390*-*-*]
1773 || [istarget powerpc*-*-*]
1774 || [istarget sparc64-*-*]
1775 || [istarget sparcv9-*-*] } {
1776 set et_sync_int_long_saved 1
1777 }
1778 }
1779
1780 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1781 return $et_sync_int_long_saved
1782 }
1783
1784 # Return 1 if the target supports atomic operations on "char" and "short".
1785
1786 proc check_effective_target_sync_char_short { } {
1787 global et_sync_char_short_saved
1788
1789 if [info exists et_sync_char_short_saved] {
1790 verbose "check_effective_target_sync_char_short: using cached result" 2
1791 } else {
1792 set et_sync_char_short_saved 0
1793 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1794 # load-reserved/store-conditional instructions.
1795 if { [istarget ia64-*-*]
1796 || [istarget i?86-*-*]
1797 || [istarget x86_64-*-*]
1798 || [istarget alpha*-*-*]
1799 || [istarget s390*-*-*]
1800 || [istarget powerpc*-*-*]
1801 || [istarget sparc64-*-*]
1802 || [istarget sparcv9-*-*] } {
1803 set et_sync_char_short_saved 1
1804 }
1805 }
1806
1807 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1808 return $et_sync_char_short_saved
1809 }
1810
1811 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1812 # This can be used with any check_* proc that takes no argument and
1813 # returns only 1 or 0. It could be used with check_* procs that take
1814 # arguments with keywords that pass particular arguments.
1815
1816 proc is-effective-target { arg } {
1817 set selected 0
1818 if { [info procs check_effective_target_${arg}] != [list] } {
1819 set selected [check_effective_target_${arg}]
1820 } else {
1821 switch $arg {
1822 "vmx_hw" { set selected [check_vmx_hw_available] }
1823 "named_sections" { set selected [check_named_sections_available] }
1824 "gc_sections" { set selected [check_gc_sections_available] }
1825 "cxa_atexit" { set selected [check_cxa_atexit_available] }
1826 default { error "unknown effective target keyword `$arg'" }
1827 }
1828 }
1829 verbose "is-effective-target: $arg $selected" 2
1830 return $selected
1831 }
1832
1833 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1834
1835 proc is-effective-target-keyword { arg } {
1836 if { [info procs check_effective_target_${arg}] != [list] } {
1837 return 1
1838 } else {
1839 # These have different names for their check_* procs.
1840 switch $arg {
1841 "vmx_hw" { return 1 }
1842 "named_sections" { return 1 }
1843 "gc_sections" { return 1 }
1844 "cxa_atexit" { return 1 }
1845 default { return 0 }
1846 }
1847 }
1848 }
1849
1850 # Return 1 if target default to short enums
1851
1852 proc check_effective_target_short_enums { } {
1853 return [check_no_compiler_messages short_enums assembly {
1854 enum foo { bar };
1855 int s[sizeof (enum foo) == 1 ? 1 : -1];
1856 }]
1857 }
1858
1859 # Return 1 if target supports merging string constants at link time.
1860
1861 proc check_effective_target_string_merging { } {
1862 return [check_no_messages_and_pattern string_merging \
1863 "rodata\\.str" assembly {
1864 const char *var = "String";
1865 } {-O2}]
1866 }