OSDN Git Service

* lib/target-supports.exp (check_effective_target_dfp_nocache,
[pf3gnuchains/gcc-fork.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 #
25 # BASENAME is a basename to use for temporary files.
26 # TYPE is the type of compilation to perform (see target_compile).
27 # CONTENTS gives the contents of the input file.
28 # The rest is optional:
29 # OPTIONS: additional compiler options to use.
30 proc get_compiler_messages {basename type contents args} {
31     global tool
32
33     if { [llength $args] > 0 } {
34         set options "additional_flags=[lindex $args 0]"
35     } else {
36         set options ""
37     }
38
39     set src ${basename}[pid].c
40     switch $type {
41         assembly { set output ${basename}[pid].s }
42         object { set output ${basename}[pid].o }
43     }
44     set f [open $src "w"]
45     puts $f $contents
46     close $f
47     set lines [${tool}_target_compile $src $output $type "$options"]
48     file delete $src
49     remote_file build delete $output
50
51     return $lines
52 }
53
54 proc current_target_name { } {
55     global target_info
56     if [info exists target_info(target,name)] {
57         set answer $target_info(target,name)
58     } else {
59         set answer ""
60     }
61     return $answer
62 }
63
64 ###############################
65 # proc check_weak_available { }
66 ###############################
67
68 # weak symbols are only supported in some configs/object formats
69 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
70
71 proc check_weak_available { } {
72     global target_triplet
73     global target_cpu
74
75     # All mips targets should support it
76
77     if { [ string first "mips" $target_cpu ] >= 0 } {
78         return 1
79     }
80
81     # All solaris2 targets should support it
82
83     if { [regexp ".*-solaris2.*" $target_triplet] } {
84         return 1
85     }
86
87     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
88
89     if { [regexp "alpha.*osf.*" $target_triplet] } {
90         return 1
91     }
92
93     # Windows targets Cygwin and MingW32 support it
94
95     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
96         return 1
97     }
98
99     # HP-UX 10.X doesn't support it
100
101     if { [regexp "hppa.*hpux10" $target_triplet] } {
102         return 0
103     }
104
105     # ELF and ECOFF support it. a.out does with gas/gld but may also with
106     # other linkers, so we should try it
107
108     set objformat [gcc_target_object_format]
109
110     switch $objformat {
111         elf      { return 1 }
112         ecoff    { return 1 }
113         a.out    { return 1 }
114         mach-o   { return 1 }
115         som      { return 1 }
116         unknown  { return -1 }
117         default  { return 0 }
118     }
119 }
120
121 ###############################
122 # proc check_visibility_available { what_kind }
123 ###############################
124
125 # The visibility attribute is only support in some object formats
126 # This proc returns 1 if it is supported, 0 if not.
127 # The argument is the kind of visibility, default/protected/hidden/internal.
128
129 proc check_visibility_available { what_kind } {
130     global visibility_available_saved
131     global tool
132     global target_triplet
133
134     # On NetWare, support makes no sense.
135     if { [istarget *-*-netware*] } {
136         return 0
137     }
138
139     if [string match "" $what_kind] { set what_kind "hidden" }
140
141     if { [info exists visibility_available_saved] } {
142         verbose "Saved result is <$visibility_available_saved>" 1
143         if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
144             return 1
145         } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
146             return 0
147         }
148     }
149
150     set lines [get_compiler_messages visibility object "
151         void f() __attribute__((visibility(\"$what_kind\")));
152         void f() {}
153     "]
154     if [string match "" $lines] then {
155         set answer 1
156         lappend visibility_available_saved $what_kind
157     } else {
158         set answer 0
159         lappend visibility_available_saved "!$what_kind"
160     }
161     return $answer
162 }
163
164 ###############################
165 # proc check_alias_available { }
166 ###############################
167
168 # Determine if the target toolchain supports the alias attribute.
169
170 # Returns 2 if the target supports aliases.  Returns 1 if the target
171 # only supports weak aliased.  Returns 0 if the target does not
172 # support aliases at all.  Returns -1 if support for aliases could not
173 # be determined.
174
175 proc check_alias_available { } {
176     global alias_available_saved
177     global tool
178
179     if [info exists alias_available_saved] {
180         verbose "check_alias_available  returning saved $alias_available_saved" 2
181     } else {
182         set src alias[pid].c
183         set obj alias[pid].o
184         verbose "check_alias_available  compiling testfile $src" 2
185         set f [open $src "w"]
186         # Compile a small test program.  The definition of "g" is
187         # necessary to keep the Solaris assembler from complaining
188         # about the program.
189         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
190         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
191         close $f
192         set lines [${tool}_target_compile $src $obj object ""]
193         file delete $src
194         remote_file build delete $obj
195
196         if [string match "" $lines] then {
197             # No error messages, everything is OK.
198             set alias_available_saved 2
199         } else {
200             if [regexp "alias definitions not supported" $lines] {
201                 verbose "check_alias_available  target does not support aliases" 2
202
203                 set objformat [gcc_target_object_format]
204
205                 if { $objformat == "elf" } {
206                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
207                     set alias_available_saved -1
208                 } else {
209                     set alias_available_saved 0
210                 }
211             } else {
212                 if [regexp "only weak aliases are supported" $lines] {
213                 verbose "check_alias_available  target supports only weak aliases" 2
214                 set alias_available_saved 1
215                 } else {
216                     set alias_available_saved -1
217                 }
218             }
219         }
220
221         verbose "check_alias_available  returning $alias_available_saved" 2
222     }
223
224     return $alias_available_saved
225 }
226
227 # Returns true if --gc-sections is supported on the target.
228
229 proc check_gc_sections_available { } {
230     global gc_sections_available_saved
231     global tool
232
233     if {![info exists gc_sections_available_saved]} {
234         # Some targets don't support gc-sections despite whatever's
235         # advertised by ld's options.
236         if { [istarget alpha*-*-*]
237              || [istarget ia64-*-*] } {
238             set gc_sections_available_saved 0
239             return 0
240         }
241
242         # Check if the ld used by gcc supports --gc-sections.
243         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
244         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
245         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
246         set ld_output [remote_exec host "$gcc_ld" "--help"]
247         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
248             set gc_sections_available_saved 1
249         } else {
250             set gc_sections_available_saved 0
251         }
252     }
253     return $gc_sections_available_saved
254 }
255
256 # Return true if profiling is supported on the target.
257
258 proc check_profiling_available { test_what } {
259     global profiling_available_saved
260
261     verbose "Profiling argument is <$test_what>" 1
262
263     # These conditions depend on the argument so examine them before
264     # looking at the cache variable.
265
266     # Support for -p on solaris2 relies on mcrt1.o which comes with the
267     # vendor compiler.  We cannot reliably predict the directory where the
268     # vendor compiler (and thus mcrt1.o) is installed so we can't
269     # necessarily find mcrt1.o even if we have it.
270     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
271         return 0
272     }
273
274     # Support for -p on irix relies on libprof1.a which doesn't appear to
275     # exist on any irix6 system currently posting testsuite results.
276     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
277     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
278     if { [istarget mips*-*-irix*]
279     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
280         return 0
281     }
282
283     # At present, there is no profiling support on NetWare.
284     if { [istarget *-*-netware*] } {
285         return 0
286     }
287
288     # Now examine the cache variable.
289     if {![info exists profiling_available_saved]} {
290         # Some targets don't have any implementation of __bb_init_func or are
291         # missing other needed machinery.
292         if { [istarget mmix-*-*]
293              || [istarget arm*-*-eabi*]
294              || [istarget arm*-*-elf]
295              || [istarget arm*-*-symbianelf*]
296              || [istarget powerpc-*-eabi*]
297              || [istarget strongarm*-*-elf]
298              || [istarget xscale*-*-elf]
299              || [istarget cris-*-*]
300              || [istarget h8300-*-*]
301              || [istarget mips*-*-elf]
302              || [istarget xtensa-*-elf]
303              || [istarget *-*-windiss] } {
304             set profiling_available_saved 0
305         } else {
306             set profiling_available_saved 1
307         }
308     }
309
310     return $profiling_available_saved
311 }
312
313 # Return 1 if target has packed layout of structure members by
314 # default, 0 otherwise.  Note that this is slightly different than
315 # whether the target has "natural alignment": both attributes may be
316 # false.
317
318 proc check_effective_target_default_packed { } {
319     global et_default_packed_saved
320     global et_default_packed_target_name
321
322     if { ![info exists et_default_packed_target_name] } {
323         set et_default_packed_target_name ""
324     }
325
326     # If the target has changed since we set the cached value, clear it.
327     set current_target [current_target_name]
328     if { $current_target != $et_default_packed_target_name } {
329         verbose "check_effective_target_default_packed: `$et_default_packed_target_name'" 2
330         set et_default_packed_target_name $current_target
331         if [info exists et_default_packed_saved] {
332             verbose "check_effective_target_default_packed: removing cached result" 2
333             unset et_default_packed_saved
334         }
335     }
336
337     if [info exists et_default_packed_saved] {
338         verbose "check_effective_target_default_packed: using cached result" 2
339     } else {
340         verbose "check_effective_target_default_packed: compiling source" 2
341
342         set et_default_packed_saved \
343             [string match "" [get_compiler_messages default_packed assembly {
344             struct x { char a; long b; } c;
345             int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
346         } ]]
347
348     }
349     verbose "check_effective_target_default_packed: returning $et_default_packed_saved" 2
350     return $et_default_packed_saved
351 }
352
353 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
354 # documentation, where the test also comes from.
355
356 proc check_effective_target_pcc_bitfield_type_matters { } {
357     global et_pcc_bitfield_type_matters_saved
358     global et_pcc_bitfield_type_matters_target_name
359
360     if { ![info exists et_pcc_bitfield_type_matters_target_name] } {
361         set et_pcc_bitfield_type_matters_target_name ""
362     }
363
364     # If the target has changed since we set the cached value, clear it.
365     set current_target [current_target_name]
366     if { $current_target != $et_pcc_bitfield_type_matters_target_name } {
367         verbose "check_effective_target_pcc_bitfield_type_matters: `$et_pcc_bitfield_type_matters_target_name'" 2
368         set et_pcc_bitfield_type_matters_target_name $current_target
369         if [info exists et_pcc_bitfield_type_matters_saved] {
370             verbose "check_effective_target_pcc_bitfield_type_matters: removing cached result" 2
371             unset et_pcc_bitfield_type_matters_saved
372         }
373     }
374
375     if [info exists et_pcc_bitfield_type_matters_saved] {
376         verbose "check_effective_target_pcc_bitfield_type_matters: using cached result" 2
377     } else {
378         verbose "check_effective_target_pcc_bitfield_type_matters: compiling source" 2
379
380         # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
381         # bitfields, but let's stick to the example code from the docs.
382         set et_pcc_bitfield_type_matters_saved \
383             [string match "" [get_compiler_messages pcc_bitfield_type_matters assembly {
384             struct foo1 { char x; char :0; char y; };
385             struct foo2 { char x; int :0; char y; };
386             int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
387         } ]]
388     }
389     verbose "check_effective_target_pcc_bitfield_type_matters: returning $et_pcc_bitfield_type_matters_saved" 2
390     return $et_pcc_bitfield_type_matters_saved
391 }
392
393 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
394 #
395 # This won't change for different subtargets so cache the result.
396
397 proc check_effective_target_tls {} {
398     global et_tls_saved
399
400     if [info exists et_tls_saved] {
401         verbose "check_effective_target_tls: using cached result" 2
402     } else {
403         set et_tls_saved 1
404
405         set src tls[pid].c
406         set asm tls[pid].S
407         verbose "check_effective_target_tls: compiling testfile $src" 2
408         set f [open $src "w"]
409         # Compile a small test program.
410         puts $f "__thread int i;\n"
411         close $f
412
413         # Test for thread-local data supported by the platform.
414         set comp_output \
415             [target_compile $src $asm assembly ""]
416         file delete $src
417         if { [string match "*not supported*" $comp_output] } {
418             set et_tls_saved 0
419         }
420         remove-build-file $asm
421     }
422     verbose "check_effective_target_tls: returning $et_tls_saved" 2
423     return $et_tls_saved
424 }
425
426 # Return 1 if TLS executables can run correctly, 0 otherwise.
427 #
428 # This won't change for different subtargets so cache the result.
429
430 proc check_effective_target_tls_runtime {} {
431     global et_tls_runtime_saved
432
433     if [info exists et_tls_runtime_saved] {
434         verbose "check_effective_target_tls_runtime: using cached result" 2
435     } else {
436         set et_tls_runtime_saved 0
437
438         set src tls_runtime[pid].c
439         set exe tls_runtime[pid].x
440         verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
441         set f [open $src "w"]
442         # Compile a small test program.
443         puts $f "__thread int thr = 0;\n"
444         puts $f "int main(void)\n {\n return thr;\n}"
445         close $f
446
447         set comp_output \
448             [target_compile $src $exe executable ""]
449         file delete $src
450
451         if [string match "" $comp_output] then {
452             # No error messages, everything is OK.
453
454             set result [remote_load target "./$exe" "" ""]
455             set status [lindex $result 0]
456             remote_file build delete $exe
457
458             verbose "check_effective_target_tls_runtime status is <$status>" 2
459
460             if { $status == "pass" } {
461                 set et_tls_runtime_saved 1
462             }
463
464             verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
465         }
466     }
467
468     return $et_tls_runtime_saved
469 }
470
471 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
472 # emitted, 0 otherwise.  Whether a shared library can actually be built is
473 # out of scope for this test.
474 #
475 # When the target name changes, replace the cached result.
476
477 proc check_effective_target_fpic { } {
478     global et_fpic_saved
479     global et_fpic_target_name
480
481     if { ![info exists et_fpic_target_name] } {
482         set et_fpic_target_name ""
483     }
484
485     # If the target has changed since we set the cached value, clear it.
486     set current_target [current_target_name]
487     if { $current_target != $et_fpic_target_name } {
488         verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
489         set et_fpic_target_name $current_target
490         if [info exists et_fpic_saved] {
491             verbose "check_effective_target_fpic: removing cached result" 2
492             unset et_fpic_saved
493         }
494     }
495
496     if [info exists et_fpic_saved] {
497         verbose "check_effective_target_fpic: using cached result" 2
498     } else {
499         verbose "check_effective_target_fpic: compiling source" 2
500
501         # Note that M68K has a multilib that supports -fpic but not
502         # -fPIC, so we need to check both.  We test with a program that
503         # requires GOT references.
504         set et_fpic_saved [string match "" [get_compiler_messages fpic object {
505             extern int foo (void); extern int bar;
506             int baz (void) { return foo () + bar; }
507         } "-fpic"]]
508
509         if { $et_fpic_saved != 0 } {
510             set et_fpic_saved [string match "" [get_compiler_messages fpic object {
511                 extern int foo (void); extern int bar;
512                 int baz (void) { return foo () + bar; }
513             } "-fPIC"]]
514         }
515     }
516     verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
517     return $et_fpic_saved
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 # This proc does not cache results, because the answer may vary
566 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
567 # the same test run.
568 proc check_named_sections_available { } {
569     verbose "check_named_sections_available: compiling source" 2
570     set answer [string match "" [get_compiler_messages named object {
571         int __attribute__ ((section("whatever"))) foo;
572     }]]
573     verbose "check_named_sections_available: returning $answer" 2
574     return $answer
575 }
576
577 # Return 1 if the target supports Fortran real kinds larger than real(8),
578 # 0 otherwise.
579 #
580 # When the target name changes, replace the cached result.
581
582 proc check_effective_target_fortran_large_real { } {
583     global et_fortran_large_real_saved
584     global et_fortran_large_real_target_name
585     global tool
586
587     if { ![info exists et_fortran_large_real_target_name] } {
588         set et_fortran_large_real_target_name ""
589     }
590
591     # If the target has changed since we set the cached value, clear it.
592     set current_target [current_target_name]
593     if { $current_target != $et_fortran_large_real_target_name } {
594         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
595         set et_fortran_large_real_target_name $current_target
596         if [info exists et_fortran_large_real_saved] {
597             verbose "check_effective_target_fortran_large_real: removing cached result" 2
598             unset et_fortran_large_real_saved
599         }
600     }
601
602     if [info exists et_fortran_large_real_saved] {
603         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
604     } else {
605         set et_fortran_large_real_saved 0
606
607         # Set up, compile, and execute a test program using large real
608         # kinds.  Include the current process ID in the file names to
609         # prevent conflicts with invocations for multiple testsuites.
610         set src real[pid].f90
611         set exe real[pid].x
612
613         set f [open $src "w"]
614         puts $f "integer,parameter :: k = &"
615         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
616         puts $f "real(kind=k) :: x"
617         puts $f "x = cos (x);"
618         puts $f "end"
619         close $f
620
621         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
622         set lines [${tool}_target_compile $src $exe executable ""]
623         file delete $src
624
625         if [string match "" $lines] then {
626             # No error message, compilation succeeded.
627             set et_fortran_large_real_saved 1
628         }
629     }
630
631     return $et_fortran_large_real_saved
632 }
633
634 # Return 1 if the target supports Fortran integer kinds larger than
635 # integer(8), 0 otherwise.
636 #
637 # When the target name changes, replace the cached result.
638
639 proc check_effective_target_fortran_large_int { } {
640     global et_fortran_large_int_saved
641     global et_fortran_large_int_target_name
642     global tool
643
644     if { ![info exists et_fortran_large_int_target_name] } {
645         set et_fortran_large_int_target_name ""
646     }
647
648     # If the target has changed since we set the cached value, clear it.
649     set current_target [current_target_name]
650     if { $current_target != $et_fortran_large_int_target_name } {
651         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
652         set et_fortran_large_int_target_name $current_target
653         if [info exists et_fortran_large_int_saved] {
654             verbose "check_effective_target_fortran_large_int: removing cached result" 2
655             unset et_fortran_large_int_saved
656         }
657     }
658
659     if [info exists et_fortran_large_int_saved] {
660         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
661     } else {
662         set et_fortran_large_int_saved 0
663
664         # Set up, compile, and execute a test program using large integer
665         # kinds.  Include the current process ID in the file names to
666         # prevent conflicts with invocations for multiple testsuites.
667         set src int[pid].f90
668         set exe int[pid].x
669
670         set f [open $src "w"]
671         puts $f "integer,parameter :: k = &"
672         puts $f "  selected_int_kind (range (0_8) + 1)"
673         puts $f "integer(kind=k) :: i"
674         puts $f "end"
675         close $f
676
677         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
678         set lines [${tool}_target_compile $src $exe executable ""]
679         file delete $src
680
681         if [string match "" $lines] then {
682             # No error message, compilation succeeded.
683             set et_fortran_large_int_saved 1
684         }
685     }
686
687     return $et_fortran_large_int_saved
688 }
689
690 # Return 1 if we can statically link libgfortran, 0 otherwise.
691 #
692 # When the target name changes, replace the cached result.
693
694 proc check_effective_target_static_libgfortran { } {
695     global et_static_libgfortran
696     global et_static_libgfortran_target_name
697     global tool
698
699     if { ![info exists et_static_libgfortran_target_name] } {
700        set et_static_libgfortran_target_name ""
701     }
702
703     # If the target has changed since we set the cached value, clear it.
704     set current_target [current_target_name]
705     if { $current_target != $et_static_libgfortran_target_name } {
706        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
707        set et_static_libgfortran_target_name $current_target
708        if [info exists et_static_libgfortran_saved] {
709            verbose "check_effective_target_static_libgfortran: removing cached result" 2
710            unset et_static_libgfortran_saved
711        }
712     }
713
714     if [info exists et_static_libgfortran_saved] {
715        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
716     } else {
717        set et_static_libgfortran_saved 0
718
719        # Set up, compile, and execute a test program using static linking.
720        # Include the current process ID in the file names to prevent
721        # conflicts with invocations for multiple testsuites.
722        set opts "additional_flags=-static"
723        set src static[pid].f
724        set exe static[pid].x
725
726        set f [open $src "w"]
727        puts $f "      print *, 'test'"
728        puts $f "      end"
729        close $f
730
731        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
732        set lines [${tool}_target_compile $src $exe executable "$opts"]
733        file delete $src
734
735        if [string match "" $lines] then {
736            # No error message, compilation succeeded.
737            set et_static_libgfortran_saved 1
738        }
739     }
740
741     return $et_static_libgfortran_saved
742 }
743
744 # Return 1 if the target supports executing AltiVec instructions, 0
745 # otherwise.  Cache the result.
746
747 proc check_vmx_hw_available { } {
748     global vmx_hw_available_saved
749     global tool
750
751     if [info exists vmx_hw_available_saved] {
752         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
753     } else {
754         set vmx_hw_available_saved 0
755
756         # Some simulators are known to not support VMX instructions.
757         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
758             verbose "check_hw_available  returning 0" 2
759             return $vmx_hw_available_saved
760         }
761
762         # Set up, compile, and execute a test program containing VMX
763         # instructions.  Include the current process ID in the file
764         # names to prevent conflicts with invocations for multiple
765         # testsuites.
766         set src vmx[pid].c
767         set exe vmx[pid].x
768
769         set f [open $src "w"]
770         puts $f "int main() {"
771         puts $f "#ifdef __MACH__"
772         puts $f "  asm volatile (\"vor v0,v0,v0\");"
773         puts $f "#else"
774         puts $f "  asm volatile (\"vor 0,0,0\");"
775         puts $f "#endif"
776         puts $f "  return 0; }"
777         close $f
778
779         # Most targets don't require special flags for this test case, but
780         # Darwin does.
781         if [istarget *-*-darwin*] {
782           set opts "additional_flags=-maltivec"
783         } else {
784           set opts ""
785         }
786
787         verbose "check_vmx_hw_available  compiling testfile $src" 2
788         set lines [${tool}_target_compile $src $exe executable "$opts"]
789         file delete $src
790
791         if [string match "" $lines] then {
792             # No error message, compilation succeeded.
793             set result [${tool}_load "./$exe" "" ""]
794             set status [lindex $result 0]
795             remote_file build delete $exe
796             verbose "check_vmx_hw_available testfile status is <$status>" 2
797
798             if { $status == "pass" } then {
799                 set vmx_hw_available_saved 1
800             }
801         } else {
802             verbose "check_vmx_hw_availalble testfile compilation failed" 2
803         }
804     }
805
806     return $vmx_hw_available_saved
807 }
808
809 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
810 # complex float arguments.  This affects gfortran tests that call cabsf
811 # in libm built by an earlier compiler.  Return 1 if libm uses the same
812 # argument passing as the compiler under test, 0 otherwise.
813 #
814 # When the target name changes, replace the cached result.
815
816 proc check_effective_target_broken_cplxf_arg { } {
817     global et_broken_cplxf_arg_saved
818     global et_broken_cplxf_arg_target_name
819     global tool
820
821     # Skip the work for targets known not to be affected.
822     if { ![istarget powerpc64-*-linux*] } {
823         return 0
824     } elseif { [is-effective-target ilp32] } {
825         return 0
826     }
827
828     if { ![info exists et_broken_cplxf_arg_target_name] } {
829         set et_broken_cplxf_arg_target_name ""
830     }
831
832     # If the target has changed since we set the cached value, clear it.
833     set current_target [current_target_name]
834     if { $current_target != $et_broken_cplxf_arg_target_name } {
835         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
836         set et_broken_cplxf_arg_target_name $current_target
837         if [info exists et_broken_cplxf_arg_saved] {
838             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
839             unset et_broken_cplxf_arg_saved
840         }
841     }
842
843     if [info exists et_broken_cplxf_arg_saved] {
844         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
845     } else {
846         set et_broken_cplxf_arg_saved 0
847         # This is only known to affect one target.
848         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
849             set et_broken_cplxf_arg_saved 0
850             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
851             return $et_broken_cplxf_arg_saved
852         }
853
854         # Set up, compile, and execute a C test program that calls cabsf.
855         set src cabsf[pid].c
856         set exe cabsf[pid].x
857
858         set f [open $src "w"]
859         puts $f "#include <complex.h>"
860         puts $f "extern void abort (void);"
861         puts $f "float fabsf (float);"
862         puts $f "float cabsf (_Complex float);"
863         puts $f "int main ()"
864         puts $f "{"
865         puts $f "  _Complex float cf;"
866         puts $f "  float f;"
867         puts $f "  cf = 3 + 4.0fi;"
868         puts $f "  f = cabsf (cf);"
869         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
870         puts $f "  return 0;"
871         puts $f "}"
872         close $f
873
874         set lines [${tool}_target_compile $src $exe executable "-lm"]
875         file delete $src
876
877         if [string match "" $lines] {
878             # No error message, compilation succeeded.
879             set result [${tool}_load "./$exe" "" ""]
880             set status [lindex $result 0]
881             remote_file build delete $exe
882
883             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
884
885             if { $status != "pass" } {
886                 set et_broken_cplxf_arg_saved 1
887             }
888         } else {
889             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
890         }
891     }
892     return $et_broken_cplxf_arg_saved
893 }
894
895 proc check_alpha_max_hw_available { } {
896     global alpha_max_hw_available_saved
897     global tool
898
899     if [info exists alpha_max_hw_available_saved] {
900         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
901     } else {
902         set alpha_max_hw_available_saved 0
903
904         # Set up, compile, and execute a test program probing bit 8 of the
905         # architecture mask, which indicates presence of MAX instructions.
906         set src max[pid].c
907         set exe max[pid].x
908
909         set f [open $src "w"]
910         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
911         close $f
912
913         verbose "check_alpha_max_hw_available compiling testfile $src" 2
914         set lines [${tool}_target_compile $src $exe executable ""]
915         file delete $src
916
917         if [string match "" $lines] then {
918             # No error message, compilation succeeded.
919             set result [${tool}_load "./$exe" "" ""]
920             set status [lindex $result 0]
921             remote_file build delete $exe
922             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
923
924             if { $status == "pass" } then {
925                 set alpha_max_hw_available_saved 1
926             }
927         } else {
928             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
929         }
930     }
931
932     return $alpha_max_hw_available_saved
933 }
934
935 # Returns true iff the FUNCTION is available on the target system.
936 # (This is essentially a Tcl implementation of Autoconf's
937 # AC_CHECK_FUNC.)
938
939 proc check_function_available { function } {
940     set var "${function}_available_saved"
941     global $var
942     global tool
943
944     if {![info exists $var]} {
945         # Assume it exists.
946         set $var 1
947         # Check to make sure.
948         set src "function[pid].c"
949         set exe "function[pid].exe"
950
951         set f [open $src "w"]
952         puts $f "int main () { $function (); }"
953         close $f
954
955         set lines [${tool}_target_compile $src $exe executable ""]
956         file delete $src
957         file delete $exe
958
959         if {![string match "" $lines]} then {
960             set $var 0
961             verbose -log "$function is not available"
962         } else {
963             verbose -log "$function is available"
964         }
965     }
966
967     eval return \$$var
968 }
969
970 # Returns true iff "fork" is available on the target system.
971
972 proc check_fork_available {} {
973     return [check_function_available "fork"]
974 }
975
976 # Returns true iff "mkfifo" is available on the target system.
977
978 proc check_mkfifo_available {} {
979     if {[istarget *-*-cygwin*]} {
980        # Cygwin has mkfifo, but support is incomplete.
981        return 0
982      }
983
984     return [check_function_available "mkfifo"]
985 }
986
987 # Return 1 if we're generating 32-bit code using default options, 0
988 # otherwise.
989 #
990 # When the target name changes, replace the cached result.
991
992 proc check_effective_target_ilp32 { } {
993     global et_ilp32_saved
994     global et_ilp32_target_name
995
996     if { ![info exists et_ilp32_target_name] } {
997         set et_ilp32_target_name ""
998     }
999
1000     # If the target has changed since we set the cached value, clear it.
1001     set current_target [current_target_name]
1002     if { $current_target != $et_ilp32_target_name } {
1003         verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
1004         set et_ilp32_target_name $current_target
1005         if { [info exists et_ilp32_saved] } {
1006             verbose "check_effective_target_ilp32: removing cached result" 2
1007             unset et_ilp32_saved
1008         }
1009     }
1010
1011     if [info exists et_ilp32_saved] {
1012         verbose "check-effective_target_ilp32: using cached result" 2
1013     } else {
1014         verbose "check_effective_target_ilp32: compiling source" 2
1015         set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
1016             int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
1017         }]]
1018     }
1019     verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
1020     return $et_ilp32_saved
1021 }
1022
1023 # Return 1 if we're generating 64-bit code using default options, 0
1024 # otherwise.
1025 #
1026 # When the target name changes, replace the cached result.
1027
1028 proc check_effective_target_lp64 { } {
1029     global et_lp64_saved
1030     global et_lp64_target_name
1031
1032     if { ![info exists et_lp64_target_name] } {
1033         set et_lp64_target_name ""
1034     }
1035
1036     # If the target has changed since we set the cached value, clear it.
1037     set current_target [current_target_name]
1038     if { $current_target != $et_lp64_target_name } {
1039         verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
1040         set et_lp64_target_name $current_target
1041         if [info exists et_lp64_saved] {
1042             verbose "check_effective_target_lp64: removing cached result" 2
1043             unset et_lp64_saved
1044         }
1045     }
1046
1047     if [info exists et_lp64_saved] {
1048         verbose "check_effective_target_lp64: using cached result" 2
1049     } else {
1050         verbose "check_effective_target_lp64: compiling source" 2
1051         set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
1052             int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
1053         }]]
1054     }
1055     verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
1056     return $et_lp64_saved
1057 }
1058
1059 # Return 1 if the target supports compiling decimal floating point,
1060 # 0 otherwise.
1061
1062 proc check_effective_target_dfp_nocache { } {
1063     verbose "check_effective_target_dfp_nocache: compiling source" 2
1064     set ret [string match "" [get_compiler_messages dfp object {
1065         _Decimal32 x; _Decimal64 y; _Decimal128 z;
1066     }]]
1067     verbose "check_effective_target_dfp_nocache: returning $ret" 2
1068     return $ret
1069 }
1070
1071 proc check_effective_target_dfprt_nocache { } {
1072     global tool
1073
1074     set ret 0
1075
1076     verbose "check_effective_target_dfprt_nocache: compiling source" 2
1077     # Set up, compile, and execute a test program containing decimal
1078     # float operations.
1079     set src dfprt[pid].c
1080     set exe dfprt[pid].x
1081
1082     set f [open $src "w"]
1083     puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
1084     puts $f "int main () { z = x + y; return 0; }"
1085     close $f
1086
1087     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
1088     set lines [${tool}_target_compile $src $exe executable ""]
1089     file delete $src
1090
1091     if [string match "" $lines] then {
1092         # No error message, compilation succeeded.
1093         set result [${tool}_load "./$exe" "" ""]
1094         set status [lindex $result 0]
1095         remote_file build delete $exe
1096         verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
1097         if { $status == "pass" } then {
1098             set ret 1
1099         }
1100     }
1101     return $ret
1102     verbose "check_effective_target_dfprt_nocache: returning $ret" 2
1103 }
1104
1105 # Return 1 if the target supports compiling Decimal Floating Point,
1106 # 0 otherwise.
1107 #
1108 # This won't change for different subtargets so cache the result.
1109
1110 proc check_effective_target_dfp { } {
1111     global et_dfp_saved
1112
1113     if [info exists et_dfp_saved] {
1114         verbose "check_effective_target_dfp: using cached result" 2
1115     } else {
1116         set et_dfp_saved [check_effective_target_dfp_nocache]
1117     }
1118     verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1119     return $et_dfp_saved
1120 }
1121
1122 # Return 1 if the target supports linking and executing Decimal Floating
1123 # Point, # 0 otherwise.
1124 #
1125 # This won't change for different subtargets so cache the result.
1126
1127 proc check_effective_target_dfprt { } {
1128     global et_dfprt_saved
1129     global tool
1130
1131     if [info exists et_dfprt_saved] {
1132         verbose "check_effective_target_dfprt: using cached result" 2
1133     } else {
1134         set et_dfprt_saved [check_effective_target_dfprt_nocache]
1135     }
1136     verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1137     return $et_dfprt_saved
1138 }
1139
1140 # Return 1 if the target needs a command line argument to enable a SIMD
1141 # instruction set.
1142 #
1143 # This won't change for different subtargets so cache the result.
1144
1145 proc check_effective_target_vect_cmdline_needed { } {
1146     global et_vect_cmdline_needed_saved
1147
1148     if [info exists et_vect_cmdline_needed_saved] {
1149         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1150     } else {
1151         set et_vect_cmdline_needed_saved 1
1152         if { [istarget ia64-*-*]
1153               || [istarget x86_64-*-*] } {
1154            set et_vect_cmdline_needed_saved 0
1155         }
1156     }
1157
1158     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1159     return $et_vect_cmdline_needed_saved
1160 }
1161
1162 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1163 #
1164 # This won't change for different subtargets so cache the result.
1165
1166 proc check_effective_target_vect_int { } {
1167     global et_vect_int_saved
1168
1169     if [info exists et_vect_int_saved] {
1170         verbose "check_effective_target_vect_int: using cached result" 2
1171     } else {
1172         set et_vect_int_saved 0
1173         if { [istarget i?86-*-*]
1174               || [istarget powerpc*-*-*]
1175               || [istarget x86_64-*-*]
1176               || [istarget sparc*-*-*]
1177               || [istarget alpha*-*-*]
1178               || [istarget ia64-*-*] } {
1179            set et_vect_int_saved 1
1180         }
1181     }
1182
1183     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1184     return $et_vect_int_saved
1185 }
1186
1187 # Return 1 is this is an arm target using 32-bit instructions
1188 proc check_effective_target_arm32 { } {
1189     global et_arm32_saved
1190     global et_arm32_target_name
1191     global compiler_flags
1192
1193     if { ![info exists et_arm32_target_name] } {
1194         set et_arm32_target_name ""
1195     }
1196
1197     # If the target has changed since we set the cached value, clear it.
1198     set current_target [current_target_name]
1199     if { $current_target != $et_arm32_target_name } {
1200         verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1201         set et_arm32_target_name $current_target
1202         if { [info exists et_arm32_saved] } {
1203             verbose "check_effective_target_arm32: removing cached result" 2
1204             unset et_arm32_saved
1205         }
1206     }
1207
1208     if [info exists et_arm32_saved] {
1209         verbose "check-effective_target_arm32: using cached result" 2
1210     } else {
1211         set et_arm32_saved 0
1212         if { [istarget arm-*-*]
1213               || [istarget strongarm*-*-*]
1214               || [istarget xscale-*-*] } {
1215             if ![string match "*-mthumb *" $compiler_flags] {
1216                 set et_arm32_saved 1
1217             }
1218         }
1219     }
1220     verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1221     return $et_arm32_saved
1222 }
1223
1224 # Return 1 if the target supports hardware vector shift operation.
1225
1226 proc check_effective_target_vect_shift { } {
1227     global et_vect_shift_saved
1228
1229     if [info exists et_vect_shift_saved] {
1230         verbose "check_effective_target_vect_shift: using cached result" 2
1231     } else {
1232         set et_vect_shift_saved 0
1233         if { [istarget powerpc*-*-*]
1234              || [istarget ia64-*-*]
1235              || [istarget i?86-*-*]
1236              || [istarget x86_64-*-*] } {
1237            set et_vect_shift_saved 1
1238         }
1239     }
1240
1241     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1242     return $et_vect_shift_saved
1243 }
1244
1245 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1246 #
1247 # This can change for different subtargets so do not cache the result.
1248
1249 proc check_effective_target_vect_long { } {
1250     if { [istarget i?86-*-*]
1251          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1252          || [istarget x86_64-*-*]
1253          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1254         set answer 1
1255     } else {
1256         set answer 0
1257     }
1258
1259     verbose "check_effective_target_vect_long: returning $answer" 2
1260     return $answer
1261 }
1262
1263 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1264 #
1265 # This won't change for different subtargets so cache the result.
1266
1267 proc check_effective_target_vect_float { } {
1268     global et_vect_float_saved
1269
1270     if [info exists et_vect_float_saved] {
1271         verbose "check_effective_target_vect_float: using cached result" 2
1272     } else {
1273         set et_vect_float_saved 0
1274         if { [istarget i?86-*-*]
1275               || [istarget powerpc*-*-*]
1276               || [istarget mipsisa64*-*-*]
1277               || [istarget x86_64-*-*]
1278               || [istarget ia64-*-*] } {
1279            set et_vect_float_saved 1
1280         }
1281     }
1282
1283     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1284     return $et_vect_float_saved
1285 }
1286
1287 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1288 #
1289 # This won't change for different subtargets so cache the result.
1290
1291 proc check_effective_target_vect_double { } {
1292     global et_vect_double_saved
1293
1294     if [info exists et_vect_double_saved] {
1295         verbose "check_effective_target_vect_double: using cached result" 2
1296     } else {
1297         set et_vect_double_saved 0
1298         if { [istarget i?86-*-*]
1299               || [istarget x86_64-*-*] } {
1300            set et_vect_double_saved 1
1301         }
1302     }
1303
1304     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1305     return $et_vect_double_saved
1306 }
1307
1308 # Return 1 if the target plus current options does not support a vector
1309 # max instruction on "int", 0 otherwise.
1310 #
1311 # This won't change for different subtargets so cache the result.
1312
1313 proc check_effective_target_vect_no_int_max { } {
1314     global et_vect_no_int_max_saved
1315
1316     if [info exists et_vect_no_int_max_saved] {
1317         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1318     } else {
1319         set et_vect_no_int_max_saved 0
1320         if { [istarget sparc*-*-*]
1321              || [istarget alpha*-*-*] } {
1322             set et_vect_no_int_max_saved 1
1323         }
1324     }
1325     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1326     return $et_vect_no_int_max_saved
1327 }
1328
1329 # Return 1 if the target plus current options does not support a vector
1330 # add instruction on "int", 0 otherwise.
1331 #
1332 # This won't change for different subtargets so cache the result.
1333
1334 proc check_effective_target_vect_no_int_add { } {
1335     global et_vect_no_int_add_saved
1336
1337     if [info exists et_vect_no_int_add_saved] {
1338         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1339     } else {
1340         set et_vect_no_int_add_saved 0
1341         # Alpha only supports vector add on V8QI and V4HI.
1342         if { [istarget alpha*-*-*] } {
1343             set et_vect_no_int_add_saved 1
1344         }
1345     }
1346     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1347     return $et_vect_no_int_add_saved
1348 }
1349
1350 # Return 1 if the target plus current options does not support vector
1351 # bitwise instructions, 0 otherwise.
1352 #
1353 # This won't change for different subtargets so cache the result.
1354
1355 proc check_effective_target_vect_no_bitwise { } {
1356     global et_vect_no_bitwise_saved
1357
1358     if [info exists et_vect_no_bitwise_saved] {
1359         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1360     } else {
1361         set et_vect_no_bitwise_saved 0
1362     }
1363     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1364     return $et_vect_no_bitwise_saved
1365 }
1366
1367 # Return 1 if the target plus current options does not support a vector
1368 # alignment mechanism, 0 otherwise.
1369 #
1370 # This won't change for different subtargets so cache the result.
1371
1372 proc check_effective_target_vect_no_align { } {
1373     global et_vect_no_align_saved
1374
1375     if [info exists et_vect_no_align_saved] {
1376         verbose "check_effective_target_vect_no_align: using cached result" 2
1377     } else {
1378         set et_vect_no_align_saved 0
1379         if { [istarget mipsisa64*-*-*]
1380              || [istarget sparc*-*-*]
1381              || [istarget ia64-*-*] } {
1382             set et_vect_no_align_saved 1
1383         }
1384     }
1385     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1386     return $et_vect_no_align_saved
1387 }
1388
1389 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1390
1391 proc check_effective_target_vect_condition { } {
1392     global et_vect_cond_saved
1393
1394     if [info exists et_vect_cond_saved] {
1395         verbose "check_effective_target_vect_cond: using cached result" 2
1396     } else {
1397         set et_vect_cond_saved 0
1398         if { [istarget powerpc*-*-*]
1399              || [istarget ia64-*-*]
1400              || [istarget i?86-*-*]
1401              || [istarget x86_64-*-*] } {
1402            set et_vect_cond_saved 1
1403         }
1404     }
1405
1406     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1407     return $et_vect_cond_saved
1408 }
1409
1410 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1411
1412 proc check_effective_target_vect_int_mult { } {
1413     global et_vect_int_mult_saved
1414
1415     if [info exists et_vect_int_mult_saved] {
1416         verbose "check_effective_target_vect_int_mult: using cached result" 2
1417     } else {
1418         set et_vect_int_mult_saved 0
1419         if { [istarget powerpc*-*-*]
1420              || [istarget i?86-*-*]
1421              || [istarget x86_64-*-*] } {
1422            set et_vect_int_mult_saved 1
1423         }
1424     }
1425
1426     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1427     return $et_vect_int_mult_saved
1428 }
1429
1430 # Return 1 if the target supports atomic operations on "int" and "long".
1431
1432 proc check_effective_target_sync_int_long { } {
1433     global et_sync_int_long_saved
1434
1435     if [info exists et_sync_int_long_saved] {
1436         verbose "check_effective_target_sync_int_long: using cached result" 2
1437     } else {
1438         set et_sync_int_long_saved 0
1439 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1440 # load-reserved/store-conditional instructions.
1441         if { [istarget ia64-*-*]
1442              || [istarget i?86-*-*]
1443              || [istarget x86_64-*-*]
1444              || [istarget alpha*-*-*] 
1445              || [istarget s390*-*-*] 
1446              || [istarget powerpc*-*-*]
1447              || [istarget sparc64-*-*]
1448              || [istarget sparcv9-*-*] } {
1449            set et_sync_int_long_saved 1
1450         }
1451     }
1452
1453     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1454     return $et_sync_int_long_saved
1455 }
1456
1457 # Return 1 if the target supports atomic operations on "char" and "short".
1458
1459 proc check_effective_target_sync_char_short { } {
1460     global et_sync_char_short_saved
1461
1462     if [info exists et_sync_char_short_saved] {
1463         verbose "check_effective_target_sync_char_short: using cached result" 2
1464     } else {
1465         set et_sync_char_short_saved 0
1466 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1467 # load-reserved/store-conditional instructions.
1468         if { [istarget ia64-*-*]
1469              || [istarget i?86-*-*]
1470              || [istarget x86_64-*-*]
1471              || [istarget alpha*-*-*] 
1472              || [istarget s390*-*-*] 
1473              || [istarget powerpc*-*-*]
1474              || [istarget sparc64-*-*]
1475              || [istarget sparcv9-*-*] } {
1476            set et_sync_char_short_saved 1
1477         }
1478     }
1479
1480     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1481     return $et_sync_char_short_saved
1482 }
1483
1484 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1485 # This can be used with any check_* proc that takes no argument and
1486 # returns only 1 or 0.  It could be used with check_* procs that take
1487 # arguments with keywords that pass particular arguments.
1488
1489 proc is-effective-target { arg } {
1490     set selected 0
1491     if { [info procs check_effective_target_${arg}] != [list] } {
1492         set selected [check_effective_target_${arg}]
1493     } else {
1494         switch $arg {
1495           "vmx_hw"         { set selected [check_vmx_hw_available] }
1496           "named_sections" { set selected [check_named_sections_available] }
1497           "gc_sections"    { set selected [check_gc_sections_available] }
1498           default          { error "unknown effective target keyword `$arg'" }
1499         }
1500     }
1501     verbose "is-effective-target: $arg $selected" 2
1502     return $selected
1503 }
1504
1505 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1506
1507 proc is-effective-target-keyword { arg } {
1508     if { [info procs check_effective_target_${arg}] != [list] } {
1509         return 1
1510     } else {
1511         # These have different names for their check_* procs.
1512         switch $arg {
1513           "vmx_hw"         { return 1 }
1514           "named_sections" { return 1 }
1515           "gc_sections"    { return 1 }
1516           default          { return 0 }
1517         }
1518     }
1519 }