OSDN Git Service

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