OSDN Git Service

40f06982897a91cd0753ecbccaac8e4e2ec34e1b
[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 m68k-*-elf]
304              || [istarget mips*-*-elf]
305              || [istarget xtensa-*-elf]
306              || [istarget *-*-windiss] } {
307             set profiling_available_saved 0
308         } else {
309             set profiling_available_saved 1
310         }
311     }
312
313     return $profiling_available_saved
314 }
315
316 # Return 1 if target has packed layout of structure members by
317 # default, 0 otherwise.  Note that this is slightly different than
318 # whether the target has "natural alignment": both attributes may be
319 # false.
320
321 proc check_effective_target_default_packed { } {
322     return [check_no_compiler_messages default_packed assembly {
323         struct x { char a; long b; } c;
324         int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
325     }]
326 }
327
328 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined.  See
329 # documentation, where the test also comes from.
330
331 proc check_effective_target_pcc_bitfield_type_matters { } {
332     # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
333     # bitfields, but let's stick to the example code from the docs.
334     return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
335         struct foo1 { char x; char :0; char y; };
336         struct foo2 { char x; int :0; char y; };
337         int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
338     }]
339 }
340
341 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
342 #
343 # This won't change for different subtargets so cache the result.
344
345 proc check_effective_target_tls {} {
346     global et_tls_saved
347
348     if [info exists et_tls_saved] {
349         verbose "check_effective_target_tls: using cached result" 2
350     } else {
351         set et_tls_saved 1
352
353         set src tls[pid].c
354         set asm tls[pid].S
355         verbose "check_effective_target_tls: compiling testfile $src" 2
356         set f [open $src "w"]
357         # Compile a small test program.
358         puts $f "__thread int i;\n"
359         close $f
360
361         # Test for thread-local data supported by the platform.
362         set comp_output \
363             [target_compile $src $asm assembly ""]
364         file delete $src
365         if { [string match "*not supported*" $comp_output] } {
366             set et_tls_saved 0
367         }
368         remove-build-file $asm
369     }
370     verbose "check_effective_target_tls: returning $et_tls_saved" 2
371     return $et_tls_saved
372 }
373
374 # Return 1 if TLS executables can run correctly, 0 otherwise.
375 #
376 # This won't change for different subtargets so cache the result.
377
378 proc check_effective_target_tls_runtime {} {
379     global et_tls_runtime_saved
380
381     if [info exists et_tls_runtime_saved] {
382         verbose "check_effective_target_tls_runtime: using cached result" 2
383     } else {
384         set et_tls_runtime_saved 0
385
386         set src tls_runtime[pid].c
387         set exe tls_runtime[pid].x
388         verbose "check_effective_target_tls_runtime: compiling testfile $src" 2
389         set f [open $src "w"]
390         # Compile a small test program.
391         puts $f "__thread int thr = 0;\n"
392         puts $f "int main(void)\n {\n return thr;\n}"
393         close $f
394
395         set comp_output \
396             [target_compile $src $exe executable ""]
397         file delete $src
398
399         if [string match "" $comp_output] then {
400             # No error messages, everything is OK.
401
402             set result [remote_load target "./$exe" "" ""]
403             set status [lindex $result 0]
404             remote_file build delete $exe
405
406             verbose "check_effective_target_tls_runtime status is <$status>" 2
407
408             if { $status == "pass" } {
409                 set et_tls_runtime_saved 1
410             }
411
412             verbose "check_effective_target_tls_runtime: returning $et_tls_runtime_saved" 2
413         }
414     }
415
416     return $et_tls_runtime_saved
417 }
418
419 # Return 1 if compilation with -fopenmp is error-free for trivial
420 # code, 0 otherwise.
421
422 proc check_effective_target_fopenmp {} {
423     return [check_no_compiler_messages fopenmp object {
424         void foo (void) { }
425     } "-fopenmp"]
426 }
427
428 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
429 # for trivial code, 0 otherwise.
430
431 proc check_effective_target_freorder {} {
432     return [check_no_compiler_messages freorder object {
433         void foo (void) { }
434     } "-freorder-blocks-and-partition"]
435 }
436
437 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
438 # emitted, 0 otherwise.  Whether a shared library can actually be built is
439 # out of scope for this test.
440
441 proc check_effective_target_fpic { } {
442     # Note that M68K has a multilib that supports -fpic but not
443     # -fPIC, so we need to check both.  We test with a program that
444     # requires GOT references.
445     foreach arg {fpic fPIC} {
446         if [check_no_compiler_messages $arg object {
447             extern int foo (void); extern int bar;
448             int baz (void) { return foo () + bar; }
449         } "-$arg"] {
450             return 1
451         }
452     }
453     return 0
454 }
455
456 # Return true if iconv is supported on the target. In particular IBM1047.
457
458 proc check_iconv_available { test_what } {
459     global tool
460     global libiconv
461
462     set result ""
463
464     set src iconv[pid].c
465     set exe iconv[pid].x
466     verbose "check_iconv_available compiling testfile $src" 2
467     set f [open $src "w"]
468     # Compile a small test program.
469     puts $f "#include <iconv.h>\n"
470     puts $f "int main (void)\n {\n iconv_t cd; \n"
471     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
472     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
473     puts $f "return 0;\n}"
474     close $f
475
476     # If the tool configuration file has not set libiconv, try "-liconv"
477     if { ![info exists libiconv] } {
478         set libiconv "-liconv"
479     }
480     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
481     file delete $src
482
483     if [string match "" $lines] then {
484         # No error messages, everything is OK.
485
486         set result [${tool}_load "./$exe" "" ""]
487         set status [lindex $result 0]
488         remote_file build delete $exe
489
490         verbose "check_iconv_available status is <$status>" 2
491
492         if { $status == "pass" } then {
493             return 1
494         }
495     }
496
497     return 0
498 }
499
500 # Return true if named sections are supported on this target.
501
502 proc check_named_sections_available { } {
503     return [check_no_compiler_messages named_sections assembly {
504         int __attribute__ ((section("whatever"))) foo;
505     }]
506 }
507
508 # Return 1 if the target supports Fortran real kinds larger than real(8),
509 # 0 otherwise.
510 #
511 # When the target name changes, replace the cached result.
512
513 proc check_effective_target_fortran_large_real { } {
514     global et_fortran_large_real_saved
515     global et_fortran_large_real_target_name
516     global tool
517
518     if { ![info exists et_fortran_large_real_target_name] } {
519         set et_fortran_large_real_target_name ""
520     }
521
522     # If the target has changed since we set the cached value, clear it.
523     set current_target [current_target_name]
524     if { $current_target != $et_fortran_large_real_target_name } {
525         verbose "check_effective_target_fortran_large_real: `$et_fortran_large_real_target_name' `$current_target'" 2
526         set et_fortran_large_real_target_name $current_target
527         if [info exists et_fortran_large_real_saved] {
528             verbose "check_effective_target_fortran_large_real: removing cached result" 2
529             unset et_fortran_large_real_saved
530         }
531     }
532
533     if [info exists et_fortran_large_real_saved] {
534         verbose "check_effective_target_fortran_large_real returning saved $et_fortran_large_real_saved" 2
535     } else {
536         set et_fortran_large_real_saved 0
537
538         # Set up, compile, and execute a test program using large real
539         # kinds.  Include the current process ID in the file names to
540         # prevent conflicts with invocations for multiple testsuites.
541         set src real[pid].f90
542         set exe real[pid].x
543
544         set f [open $src "w"]
545         puts $f "integer,parameter :: k = &"
546         puts $f "  selected_real_kind (precision (0.0_8) + 1)"
547         puts $f "real(kind=k) :: x"
548         puts $f "x = cos (x);"
549         puts $f "end"
550         close $f
551
552         verbose "check_effective_target_fortran_large_real compiling testfile $src" 2
553         set lines [${tool}_target_compile $src $exe executable ""]
554         file delete $src
555
556         if [string match "" $lines] then {
557             # No error message, compilation succeeded.
558             set et_fortran_large_real_saved 1
559         }
560     }
561
562     return $et_fortran_large_real_saved
563 }
564
565 # Return 1 if the target supports Fortran integer kinds larger than
566 # integer(8), 0 otherwise.
567 #
568 # When the target name changes, replace the cached result.
569
570 proc check_effective_target_fortran_large_int { } {
571     global et_fortran_large_int_saved
572     global et_fortran_large_int_target_name
573     global tool
574
575     if { ![info exists et_fortran_large_int_target_name] } {
576         set et_fortran_large_int_target_name ""
577     }
578
579     # If the target has changed since we set the cached value, clear it.
580     set current_target [current_target_name]
581     if { $current_target != $et_fortran_large_int_target_name } {
582         verbose "check_effective_target_fortran_large_int: `$et_fortran_large_int_target_name' `$current_target'" 2
583         set et_fortran_large_int_target_name $current_target
584         if [info exists et_fortran_large_int_saved] {
585             verbose "check_effective_target_fortran_large_int: removing cached result" 2
586             unset et_fortran_large_int_saved
587         }
588     }
589
590     if [info exists et_fortran_large_int_saved] {
591         verbose "check_effective_target_fortran_large_int returning saved $et_fortran_large_int_saved" 2
592     } else {
593         set et_fortran_large_int_saved 0
594
595         # Set up, compile, and execute a test program using large integer
596         # kinds.  Include the current process ID in the file names to
597         # prevent conflicts with invocations for multiple testsuites.
598         set src int[pid].f90
599         set exe int[pid].x
600
601         set f [open $src "w"]
602         puts $f "integer,parameter :: k = &"
603         puts $f "  selected_int_kind (range (0_8) + 1)"
604         puts $f "integer(kind=k) :: i"
605         puts $f "end"
606         close $f
607
608         verbose "check_effective_target_fortran_large_int compiling testfile $src" 2
609         set lines [${tool}_target_compile $src $exe executable ""]
610         file delete $src
611
612         if [string match "" $lines] then {
613             # No error message, compilation succeeded.
614             set et_fortran_large_int_saved 1
615         }
616     }
617
618     return $et_fortran_large_int_saved
619 }
620
621 # Return 1 if we can statically link libgfortran, 0 otherwise.
622 #
623 # When the target name changes, replace the cached result.
624
625 proc check_effective_target_static_libgfortran { } {
626     global et_static_libgfortran
627     global et_static_libgfortran_target_name
628     global tool
629
630     if { ![info exists et_static_libgfortran_target_name] } {
631        set et_static_libgfortran_target_name ""
632     }
633
634     # If the target has changed since we set the cached value, clear it.
635     set current_target [current_target_name]
636     if { $current_target != $et_static_libgfortran_target_name } {
637        verbose "check_effective_target_static_libgfortran: `$et_static_libgfortran_target_name' `$current_target'" 2
638        set et_static_libgfortran_target_name $current_target
639        if [info exists et_static_libgfortran_saved] {
640            verbose "check_effective_target_static_libgfortran: removing cached result" 2
641            unset et_static_libgfortran_saved
642        }
643     }
644
645     if [info exists et_static_libgfortran_saved] {
646        verbose "check_effective_target_static_libgfortran returning saved $et_static_libgfortran_saved" 2
647     } else {
648        set et_static_libgfortran_saved 0
649
650        # Set up, compile, and execute a test program using static linking.
651        # Include the current process ID in the file names to prevent
652        # conflicts with invocations for multiple testsuites.
653        set opts "additional_flags=-static"
654        set src static[pid].f
655        set exe static[pid].x
656
657        set f [open $src "w"]
658        puts $f "      print *, 'test'"
659        puts $f "      end"
660        close $f
661
662        verbose "check_effective_target_static_libgfortran compiling testfile $src" 2
663        set lines [${tool}_target_compile $src $exe executable "$opts"]
664        file delete $src
665
666        if [string match "" $lines] then {
667            # No error message, compilation succeeded.
668            set et_static_libgfortran_saved 1
669        }
670     }
671
672     return $et_static_libgfortran_saved
673 }
674
675 # Return 1 if the target supports executing AltiVec instructions, 0
676 # otherwise.  Cache the result.
677
678 proc check_vmx_hw_available { } {
679     global vmx_hw_available_saved
680     global tool
681
682     if [info exists vmx_hw_available_saved] {
683         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
684     } else {
685         set vmx_hw_available_saved 0
686
687         # Some simulators are known to not support VMX instructions.
688         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
689             verbose "check_hw_available  returning 0" 2
690             return $vmx_hw_available_saved
691         }
692
693         # Set up, compile, and execute a test program containing VMX
694         # instructions.  Include the current process ID in the file
695         # names to prevent conflicts with invocations for multiple
696         # testsuites.
697         set src vmx[pid].c
698         set exe vmx[pid].x
699
700         set f [open $src "w"]
701         puts $f "int main() {"
702         puts $f "#ifdef __MACH__"
703         puts $f "  asm volatile (\"vor v0,v0,v0\");"
704         puts $f "#else"
705         puts $f "  asm volatile (\"vor 0,0,0\");"
706         puts $f "#endif"
707         puts $f "  return 0; }"
708         close $f
709
710         # Most targets don't require special flags for this test case, but
711         # Darwin does.
712         if [istarget *-*-darwin*] {
713           set opts "additional_flags=-maltivec"
714         } else {
715           set opts ""
716         }
717
718         verbose "check_vmx_hw_available  compiling testfile $src" 2
719         set lines [${tool}_target_compile $src $exe executable "$opts"]
720         file delete $src
721
722         if [string match "" $lines] then {
723             # No error message, compilation succeeded.
724             set result [${tool}_load "./$exe" "" ""]
725             set status [lindex $result 0]
726             remote_file build delete $exe
727             verbose "check_vmx_hw_available testfile status is <$status>" 2
728
729             if { $status == "pass" } then {
730                 set vmx_hw_available_saved 1
731             }
732         } else {
733             verbose "check_vmx_hw_availalble testfile compilation failed" 2
734         }
735     }
736
737     return $vmx_hw_available_saved
738 }
739
740 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
741 # complex float arguments.  This affects gfortran tests that call cabsf
742 # in libm built by an earlier compiler.  Return 1 if libm uses the same
743 # argument passing as the compiler under test, 0 otherwise.
744 #
745 # When the target name changes, replace the cached result.
746
747 proc check_effective_target_broken_cplxf_arg { } {
748     global et_broken_cplxf_arg_saved
749     global et_broken_cplxf_arg_target_name
750     global tool
751
752     # Skip the work for targets known not to be affected.
753     if { ![istarget powerpc64-*-linux*] } {
754         return 0
755     } elseif { [is-effective-target ilp32] } {
756         return 0
757     }
758
759     if { ![info exists et_broken_cplxf_arg_target_name] } {
760         set et_broken_cplxf_arg_target_name ""
761     }
762
763     # If the target has changed since we set the cached value, clear it.
764     set current_target [current_target_name]
765     if { $current_target != $et_broken_cplxf_arg_target_name } {
766         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
767         set et_broken_cplxf_arg_target_name $current_target
768         if [info exists et_broken_cplxf_arg_saved] {
769             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
770             unset et_broken_cplxf_arg_saved
771         }
772     }
773
774     if [info exists et_broken_cplxf_arg_saved] {
775         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
776     } else {
777         set et_broken_cplxf_arg_saved 0
778         # This is only known to affect one target.
779         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
780             set et_broken_cplxf_arg_saved 0
781             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
782             return $et_broken_cplxf_arg_saved
783         }
784
785         # Set up, compile, and execute a C test program that calls cabsf.
786         set src cabsf[pid].c
787         set exe cabsf[pid].x
788
789         set f [open $src "w"]
790         puts $f "#include <complex.h>"
791         puts $f "extern void abort (void);"
792         puts $f "float fabsf (float);"
793         puts $f "float cabsf (_Complex float);"
794         puts $f "int main ()"
795         puts $f "{"
796         puts $f "  _Complex float cf;"
797         puts $f "  float f;"
798         puts $f "  cf = 3 + 4.0fi;"
799         puts $f "  f = cabsf (cf);"
800         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
801         puts $f "  return 0;"
802         puts $f "}"
803         close $f
804
805         set lines [${tool}_target_compile $src $exe executable "-lm"]
806         file delete $src
807
808         if [string match "" $lines] {
809             # No error message, compilation succeeded.
810             set result [${tool}_load "./$exe" "" ""]
811             set status [lindex $result 0]
812             remote_file build delete $exe
813
814             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
815
816             if { $status != "pass" } {
817                 set et_broken_cplxf_arg_saved 1
818             }
819         } else {
820             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
821         }
822     }
823     return $et_broken_cplxf_arg_saved
824 }
825
826 proc check_alpha_max_hw_available { } {
827     global alpha_max_hw_available_saved
828     global tool
829
830     if [info exists alpha_max_hw_available_saved] {
831         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
832     } else {
833         set alpha_max_hw_available_saved 0
834
835         # Set up, compile, and execute a test program probing bit 8 of the
836         # architecture mask, which indicates presence of MAX instructions.
837         set src max[pid].c
838         set exe max[pid].x
839
840         set f [open $src "w"]
841         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
842         close $f
843
844         verbose "check_alpha_max_hw_available compiling testfile $src" 2
845         set lines [${tool}_target_compile $src $exe executable ""]
846         file delete $src
847
848         if [string match "" $lines] then {
849             # No error message, compilation succeeded.
850             set result [${tool}_load "./$exe" "" ""]
851             set status [lindex $result 0]
852             remote_file build delete $exe
853             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
854
855             if { $status == "pass" } then {
856                 set alpha_max_hw_available_saved 1
857             }
858         } else {
859             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
860         }
861     }
862
863     return $alpha_max_hw_available_saved
864 }
865
866 # Returns true iff the FUNCTION is available on the target system.
867 # (This is essentially a Tcl implementation of Autoconf's
868 # AC_CHECK_FUNC.)
869
870 proc check_function_available { function } {
871     set var "${function}_available_saved"
872     global $var
873     global tool
874
875     if {![info exists $var]} {
876         # Assume it exists.
877         set $var 1
878         # Check to make sure.
879         set src "function[pid].c"
880         set exe "function[pid].exe"
881
882         set f [open $src "w"]
883         puts $f "int main () { $function (); }"
884         close $f
885
886         set lines [${tool}_target_compile $src $exe executable ""]
887         file delete $src
888         file delete $exe
889
890         if {![string match "" $lines]} then {
891             set $var 0
892             verbose -log "$function is not available"
893         } else {
894             verbose -log "$function is available"
895         }
896     }
897
898     eval return \$$var
899 }
900
901 # Returns true iff "fork" is available on the target system.
902
903 proc check_fork_available {} {
904     return [check_function_available "fork"]
905 }
906
907 # Returns true iff "mkfifo" is available on the target system.
908
909 proc check_mkfifo_available {} {
910     if {[istarget *-*-cygwin*]} {
911        # Cygwin has mkfifo, but support is incomplete.
912        return 0
913      }
914
915     return [check_function_available "mkfifo"]
916 }
917
918 # Return 1 if we're generating 32-bit code using default options, 0
919 # otherwise.
920
921 proc check_effective_target_ilp32 { } {
922     return [check_no_compiler_messages ilp32 object {
923         int dummy[sizeof (int) == 4
924                   && sizeof (void *) == 4
925                   && sizeof (long) == 4 ? 1 : -1];
926     }]
927 }
928
929 # Return 1 if we're generating 64-bit code using default options, 0
930 # otherwise.
931
932 proc check_effective_target_lp64 { } {
933     return [check_no_compiler_messages lp64 object {
934         int dummy[sizeof (int) == 4
935                   && sizeof (void *) == 8
936                   && sizeof (long) == 8 ? 1 : -1];
937     }]
938 }
939
940 # Return 1 if the target supports compiling decimal floating point,
941 # 0 otherwise.
942
943 proc check_effective_target_dfp_nocache { } {
944     verbose "check_effective_target_dfp_nocache: compiling source" 2
945     set ret [string match "" [get_compiler_messages dfp object {
946         _Decimal32 x; _Decimal64 y; _Decimal128 z;
947     }]]
948     verbose "check_effective_target_dfp_nocache: returning $ret" 2
949     return $ret
950 }
951
952 proc check_effective_target_dfprt_nocache { } {
953     global tool
954
955     set ret 0
956
957     verbose "check_effective_target_dfprt_nocache: compiling source" 2
958     # Set up, compile, and execute a test program containing decimal
959     # float operations.
960     set src dfprt[pid].c
961     set exe dfprt[pid].x
962
963     set f [open $src "w"]
964     puts $f "_Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z;"
965     puts $f "int main () { z = x + y; return 0; }"
966     close $f
967
968     verbose "check_effective_target_dfprt_nocache: compiling testfile $src" 2
969     set lines [${tool}_target_compile $src $exe executable ""]
970     file delete $src
971
972     if [string match "" $lines] then {
973         # No error message, compilation succeeded.
974         set result [${tool}_load "./$exe" "" ""]
975         set status [lindex $result 0]
976         remote_file build delete $exe
977         verbose "check_effective_target_dfprt_nocache: testfile status is <$status>" 2
978         if { $status == "pass" } then {
979             set ret 1
980         }
981     }
982     return $ret
983     verbose "check_effective_target_dfprt_nocache: returning $ret" 2
984 }
985
986 # Return 1 if the target supports compiling Decimal Floating Point,
987 # 0 otherwise.
988 #
989 # This won't change for different subtargets so cache the result.
990
991 proc check_effective_target_dfp { } {
992     global et_dfp_saved
993
994     if [info exists et_dfp_saved] {
995         verbose "check_effective_target_dfp: using cached result" 2
996     } else {
997         set et_dfp_saved [check_effective_target_dfp_nocache]
998     }
999     verbose "check_effective_target_dfp: returning $et_dfp_saved" 2
1000     return $et_dfp_saved
1001 }
1002
1003 # Return 1 if the target supports linking and executing Decimal Floating
1004 # Point, # 0 otherwise.
1005 #
1006 # This won't change for different subtargets so cache the result.
1007
1008 proc check_effective_target_dfprt { } {
1009     global et_dfprt_saved
1010     global tool
1011
1012     if [info exists et_dfprt_saved] {
1013         verbose "check_effective_target_dfprt: using cached result" 2
1014     } else {
1015         set et_dfprt_saved [check_effective_target_dfprt_nocache]
1016     }
1017     verbose "check_effective_target_dfprt: returning $et_dfprt_saved" 2
1018     return $et_dfprt_saved
1019 }
1020
1021 # Return 1 if the target needs a command line argument to enable a SIMD
1022 # instruction set.
1023 #
1024 # This won't change for different subtargets so cache the result.
1025
1026 proc check_effective_target_vect_cmdline_needed { } {
1027     global et_vect_cmdline_needed_saved
1028
1029     if [info exists et_vect_cmdline_needed_saved] {
1030         verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1031     } else {
1032         set et_vect_cmdline_needed_saved 1
1033         if { [istarget ia64-*-*]
1034               || [istarget x86_64-*-*] } {
1035            set et_vect_cmdline_needed_saved 0
1036         }
1037     }
1038
1039     verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1040     return $et_vect_cmdline_needed_saved
1041 }
1042
1043 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1044 #
1045 # This won't change for different subtargets so cache the result.
1046
1047 proc check_effective_target_vect_int { } {
1048     global et_vect_int_saved
1049
1050     if [info exists et_vect_int_saved] {
1051         verbose "check_effective_target_vect_int: using cached result" 2
1052     } else {
1053         set et_vect_int_saved 0
1054         if { [istarget i?86-*-*]
1055               || [istarget powerpc*-*-*]
1056               || [istarget x86_64-*-*]
1057               || [istarget sparc*-*-*]
1058               || [istarget alpha*-*-*]
1059               || [istarget ia64-*-*] } {
1060            set et_vect_int_saved 1
1061         }
1062     }
1063
1064     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1065     return $et_vect_int_saved
1066 }
1067
1068 # Return 1 is this is an arm target using 32-bit instructions
1069 proc check_effective_target_arm32 { } {
1070     global et_arm32_saved
1071     global et_arm32_target_name
1072     global compiler_flags
1073
1074     if { ![info exists et_arm32_target_name] } {
1075         set et_arm32_target_name ""
1076     }
1077
1078     # If the target has changed since we set the cached value, clear it.
1079     set current_target [current_target_name]
1080     if { $current_target != $et_arm32_target_name } {
1081         verbose "check_effective_target_arm32: `$et_arm32_target_name' `$current_target'" 2
1082         set et_arm32_target_name $current_target
1083         if { [info exists et_arm32_saved] } {
1084             verbose "check_effective_target_arm32: removing cached result" 2
1085             unset et_arm32_saved
1086         }
1087     }
1088
1089     if [info exists et_arm32_saved] {
1090         verbose "check-effective_target_arm32: using cached result" 2
1091     } else {
1092         set et_arm32_saved 0
1093         if { [istarget arm-*-*]
1094               || [istarget strongarm*-*-*]
1095               || [istarget xscale-*-*] } {
1096             if ![string match "*-mthumb *" $compiler_flags] {
1097                 set et_arm32_saved 1
1098             }
1099         }
1100     }
1101     verbose "check_effective_target_arm32: returning $et_arm32_saved" 2
1102     return $et_arm32_saved
1103 }
1104
1105 # Return 1 if the target supports hardware vector shift operation.
1106
1107 proc check_effective_target_vect_shift { } {
1108     global et_vect_shift_saved
1109
1110     if [info exists et_vect_shift_saved] {
1111         verbose "check_effective_target_vect_shift: using cached result" 2
1112     } else {
1113         set et_vect_shift_saved 0
1114         if { [istarget powerpc*-*-*]
1115              || [istarget ia64-*-*]
1116              || [istarget i?86-*-*]
1117              || [istarget x86_64-*-*] } {
1118            set et_vect_shift_saved 1
1119         }
1120     }
1121
1122     verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
1123     return $et_vect_shift_saved
1124 }
1125
1126 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
1127 #
1128 # This can change for different subtargets so do not cache the result.
1129
1130 proc check_effective_target_vect_long { } {
1131     if { [istarget i?86-*-*]
1132          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
1133          || [istarget x86_64-*-*]
1134          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
1135         set answer 1
1136     } else {
1137         set answer 0
1138     }
1139
1140     verbose "check_effective_target_vect_long: returning $answer" 2
1141     return $answer
1142 }
1143
1144 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
1145 #
1146 # This won't change for different subtargets so cache the result.
1147
1148 proc check_effective_target_vect_float { } {
1149     global et_vect_float_saved
1150
1151     if [info exists et_vect_float_saved] {
1152         verbose "check_effective_target_vect_float: using cached result" 2
1153     } else {
1154         set et_vect_float_saved 0
1155         if { [istarget i?86-*-*]
1156               || [istarget powerpc*-*-*]
1157               || [istarget mipsisa64*-*-*]
1158               || [istarget x86_64-*-*]
1159               || [istarget ia64-*-*] } {
1160            set et_vect_float_saved 1
1161         }
1162     }
1163
1164     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
1165     return $et_vect_float_saved
1166 }
1167
1168 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
1169 #
1170 # This won't change for different subtargets so cache the result.
1171
1172 proc check_effective_target_vect_double { } {
1173     global et_vect_double_saved
1174
1175     if [info exists et_vect_double_saved] {
1176         verbose "check_effective_target_vect_double: using cached result" 2
1177     } else {
1178         set et_vect_double_saved 0
1179         if { [istarget i?86-*-*]
1180               || [istarget x86_64-*-*] } {
1181            set et_vect_double_saved 1
1182         }
1183     }
1184
1185     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
1186     return $et_vect_double_saved
1187 }
1188
1189 # Return 1 if the target plus current options does not support a vector
1190 # max instruction on "int", 0 otherwise.
1191 #
1192 # This won't change for different subtargets so cache the result.
1193
1194 proc check_effective_target_vect_no_int_max { } {
1195     global et_vect_no_int_max_saved
1196
1197     if [info exists et_vect_no_int_max_saved] {
1198         verbose "check_effective_target_vect_no_int_max: using cached result" 2
1199     } else {
1200         set et_vect_no_int_max_saved 0
1201         if { [istarget sparc*-*-*]
1202              || [istarget alpha*-*-*] } {
1203             set et_vect_no_int_max_saved 1
1204         }
1205     }
1206     verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
1207     return $et_vect_no_int_max_saved
1208 }
1209
1210 # Return 1 if the target plus current options does not support a vector
1211 # add instruction on "int", 0 otherwise.
1212 #
1213 # This won't change for different subtargets so cache the result.
1214
1215 proc check_effective_target_vect_no_int_add { } {
1216     global et_vect_no_int_add_saved
1217
1218     if [info exists et_vect_no_int_add_saved] {
1219         verbose "check_effective_target_vect_no_int_add: using cached result" 2
1220     } else {
1221         set et_vect_no_int_add_saved 0
1222         # Alpha only supports vector add on V8QI and V4HI.
1223         if { [istarget alpha*-*-*] } {
1224             set et_vect_no_int_add_saved 1
1225         }
1226     }
1227     verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
1228     return $et_vect_no_int_add_saved
1229 }
1230
1231 # Return 1 if the target plus current options does not support vector
1232 # bitwise instructions, 0 otherwise.
1233 #
1234 # This won't change for different subtargets so cache the result.
1235
1236 proc check_effective_target_vect_no_bitwise { } {
1237     global et_vect_no_bitwise_saved
1238
1239     if [info exists et_vect_no_bitwise_saved] {
1240         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
1241     } else {
1242         set et_vect_no_bitwise_saved 0
1243     }
1244     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
1245     return $et_vect_no_bitwise_saved
1246 }
1247
1248 # Return 1 if the target plus current options supports a vector
1249 # widening summation of *short* args into *int* result, 0 otherwise.
1250 #
1251 # This won't change for different subtargets so cache the result.
1252                                                                                                 
1253 proc check_effective_target_vect_widen_sum_hi_to_si { } {
1254     global et_vect_widen_sum_hi_to_si
1255                                                                                                 
1256     if [info exists et_vect_widen_sum_hi_to_si_saved] {
1257         verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
1258     } else {
1259         set et_vect_widen_sum_hi_to_si_saved 0
1260         if { [istarget powerpc*-*-*]
1261              || [istarget ia64-*-*] } {
1262             set et_vect_widen_sum_hi_to_si_saved 1
1263         }
1264     }
1265     verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
1266     return $et_vect_widen_sum_hi_to_si_saved
1267 }
1268
1269 # Return 1 if the target plus current options supports a vector
1270 # widening summation of *char* args into *short* result, 0 otherwise.
1271 #
1272 # This won't change for different subtargets so cache the result.
1273                                                                                                 
1274 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
1275     global et_vect_widen_sum_qi_to_hi
1276                                                                                                 
1277     if [info exists et_vect_widen_sum_qi_to_hi_saved] {
1278         verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
1279     } else {
1280         set et_vect_widen_sum_qi_to_hi_saved 0
1281         if { [istarget ia64-*-*] } {
1282             set et_vect_widen_sum_qi_to_hi_saved 1
1283         }
1284     }
1285     verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
1286     return $et_vect_widen_sum_qi_to_hi_saved
1287 }
1288
1289 # Return 1 if the target plus current options supports a vector
1290 # widening summation of *char* args into *int* result, 0 otherwise.
1291 #
1292 # This won't change for different subtargets so cache the result.
1293                                                                                                 
1294 proc check_effective_target_vect_widen_sum_qi_to_si { } {
1295     global et_vect_widen_sum_qi_to_si
1296                                                                                                 
1297     if [info exists et_vect_widen_sum_qi_to_si_saved] {
1298         verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
1299     } else {
1300         set et_vect_widen_sum_qi_to_si_saved 0
1301         if { [istarget powerpc*-*-*] } {
1302             set et_vect_widen_sum_qi_to_si_saved 1
1303         }
1304     }
1305     verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
1306     return $et_vect_widen_sum_qi_to_si_saved
1307 }
1308
1309 # Return 1 if the target plus current options supports a vector
1310 # widening summation, 0 otherwise.
1311 #
1312 # This won't change for different subtargets so cache the result.
1313                                                                                                 
1314 proc check_effective_target_vect_widen_sum { } {
1315     global et_vect_widen_sum
1316                                                                                                 
1317     if [info exists et_vect_widen_sum_saved] {
1318         verbose "check_effective_target_vect_widen_sum: using cached result" 2
1319     } else {
1320         set et_vect_widen_sum_saved 0
1321         if { [istarget powerpc*-*-*]
1322              || [istarget ia64-*-*] } {
1323             set et_vect_widen_sum_saved 1
1324         }
1325     }
1326     verbose "check_effective_target_vect_widen_sum: returning $et_vect_widen_sum_saved" 2
1327     return $et_vect_widen_sum_saved
1328 }
1329
1330 # Return 1 if the target plus current options supports a vector
1331 # dot-product of signed chars, 0 otherwise.
1332 #
1333 # This won't change for different subtargets so cache the result.
1334
1335 proc check_effective_target_vect_sdot_qi { } {
1336     global et_vect_sdot_qi
1337
1338     if [info exists et_vect_sdot_qi_saved] {
1339         verbose "check_effective_target_vect_sdot_qi: using cached result" 2
1340     } else {
1341         set et_vect_sdot_qi_saved 0
1342         if { [istarget ia64-*-*] } {
1343             set et_vect_sdot_qi_saved 1
1344         }
1345     }
1346     verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
1347     return $et_vect_sdot_qi_saved
1348 }
1349
1350 # Return 1 if the target plus current options supports a vector
1351 # dot-product of unsigned chars, 0 otherwise.
1352 #
1353 # This won't change for different subtargets so cache the result.
1354
1355 proc check_effective_target_vect_udot_qi { } {
1356     global et_vect_udot_qi
1357
1358     if [info exists et_vect_udot_qi_saved] {
1359         verbose "check_effective_target_vect_udot_qi: using cached result" 2
1360     } else {
1361         set et_vect_udot_qi_saved 0
1362         if { [istarget powerpc*-*-*]
1363              || [istarget ia64-*-*] } {
1364             set et_vect_udot_qi_saved 1
1365         }
1366     }
1367     verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
1368     return $et_vect_udot_qi_saved
1369 }
1370
1371 # Return 1 if the target plus current options supports a vector
1372 # dot-product of signed shorts, 0 otherwise.
1373 #
1374 # This won't change for different subtargets so cache the result.
1375
1376 proc check_effective_target_vect_sdot_hi { } {
1377     global et_vect_sdot_hi
1378
1379     if [info exists et_vect_sdot_hi_saved] {
1380         verbose "check_effective_target_vect_sdot_hi: using cached result" 2
1381     } else {
1382         set et_vect_sdot_hi_saved 0
1383         if { [istarget powerpc*-*-*] 
1384              || [istarget i?86-*-*]
1385              || [istarget x86_64-*-*]
1386              || [istarget ia64-*-*] } {
1387             set et_vect_sdot_hi_saved 1
1388         }
1389     }
1390     verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
1391     return $et_vect_sdot_hi_saved
1392 }
1393
1394 # Return 1 if the target plus current options supports a vector
1395 # dot-product of unsigned shorts, 0 otherwise.
1396 #
1397 # This won't change for different subtargets so cache the result.
1398
1399 proc check_effective_target_vect_udot_hi { } {
1400     global et_vect_udot_hi
1401
1402     if [info exists et_vect_udot_hi_saved] {
1403         verbose "check_effective_target_vect_udot_hi: using cached result" 2
1404     } else {
1405         set et_vect_udot_hi_saved 0
1406         if { [istarget powerpc*-*-*] } {
1407             set et_vect_udot_hi_saved 1
1408         }
1409     }
1410     verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
1411     return $et_vect_udot_hi_saved
1412 }
1413
1414
1415 # Return 1 if the target plus current options does not support a vector
1416 # alignment mechanism, 0 otherwise.
1417 #
1418 # This won't change for different subtargets so cache the result.
1419
1420 proc check_effective_target_vect_no_align { } {
1421     global et_vect_no_align_saved
1422
1423     if [info exists et_vect_no_align_saved] {
1424         verbose "check_effective_target_vect_no_align: using cached result" 2
1425     } else {
1426         set et_vect_no_align_saved 0
1427         if { [istarget mipsisa64*-*-*]
1428              || [istarget sparc*-*-*]
1429              || [istarget ia64-*-*] } {
1430             set et_vect_no_align_saved 1
1431         }
1432     }
1433     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
1434     return $et_vect_no_align_saved
1435 }
1436
1437 # Return 1 if the target supports vector conditional operations, 0 otherwise.
1438
1439 proc check_effective_target_vect_condition { } {
1440     global et_vect_cond_saved
1441
1442     if [info exists et_vect_cond_saved] {
1443         verbose "check_effective_target_vect_cond: using cached result" 2
1444     } else {
1445         set et_vect_cond_saved 0
1446         if { [istarget powerpc*-*-*]
1447              || [istarget ia64-*-*]
1448              || [istarget i?86-*-*]
1449              || [istarget x86_64-*-*] } {
1450            set et_vect_cond_saved 1
1451         }
1452     }
1453
1454     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
1455     return $et_vect_cond_saved
1456 }
1457
1458 # Return 1 if the target supports vector char multiplication, 0 otherwise.
1459
1460 proc check_effective_target_vect_char_mult { } {
1461     global et_vect_char_mult_saved
1462
1463     if [info exists et_vect_char_mult_saved] {
1464         verbose "check_effective_target_vect_char_mult: using cached result" 2
1465     } else {
1466         set et_vect_char_mult_saved 0
1467         if { [istarget ia64-*-*]
1468              || [istarget i?86-*-*]
1469              || [istarget x86_64-*-*] } {
1470            set et_vect_char_mult_saved 1
1471         }
1472     }
1473
1474     verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
1475     return $et_vect_char_mult_saved
1476 }
1477
1478 # Return 1 if the target supports vector short multiplication, 0 otherwise.
1479
1480 proc check_effective_target_vect_short_mult { } {
1481     global et_vect_short_mult_saved
1482
1483     if [info exists et_vect_short_mult_saved] {
1484         verbose "check_effective_target_vect_short_mult: using cached result" 2
1485     } else {
1486         set et_vect_short_mult_saved 0
1487         if { [istarget ia64-*-*]
1488              || [istarget i?86-*-*]
1489              || [istarget x86_64-*-*] } {
1490            set et_vect_short_mult_saved 1
1491         }
1492     }
1493
1494     verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
1495     return $et_vect_short_mult_saved
1496 }
1497
1498 # Return 1 if the target supports vector int multiplication, 0 otherwise.
1499
1500 proc check_effective_target_vect_int_mult { } {
1501     global et_vect_int_mult_saved
1502
1503     if [info exists et_vect_int_mult_saved] {
1504         verbose "check_effective_target_vect_int_mult: using cached result" 2
1505     } else {
1506         set et_vect_int_mult_saved 0
1507         if { [istarget powerpc*-*-*]
1508              || [istarget i?86-*-*]
1509              || [istarget x86_64-*-*] } {
1510            set et_vect_int_mult_saved 1
1511         }
1512     }
1513
1514     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
1515     return $et_vect_int_mult_saved
1516 }
1517
1518 # Return 1 if the target supports atomic operations on "int" and "long".
1519
1520 proc check_effective_target_sync_int_long { } {
1521     global et_sync_int_long_saved
1522
1523     if [info exists et_sync_int_long_saved] {
1524         verbose "check_effective_target_sync_int_long: using cached result" 2
1525     } else {
1526         set et_sync_int_long_saved 0
1527 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1528 # load-reserved/store-conditional instructions.
1529         if { [istarget ia64-*-*]
1530              || [istarget i?86-*-*]
1531              || [istarget x86_64-*-*]
1532              || [istarget alpha*-*-*] 
1533              || [istarget s390*-*-*] 
1534              || [istarget powerpc*-*-*]
1535              || [istarget sparc64-*-*]
1536              || [istarget sparcv9-*-*] } {
1537            set et_sync_int_long_saved 1
1538         }
1539     }
1540
1541     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
1542     return $et_sync_int_long_saved
1543 }
1544
1545 # Return 1 if the target supports atomic operations on "char" and "short".
1546
1547 proc check_effective_target_sync_char_short { } {
1548     global et_sync_char_short_saved
1549
1550     if [info exists et_sync_char_short_saved] {
1551         verbose "check_effective_target_sync_char_short: using cached result" 2
1552     } else {
1553         set et_sync_char_short_saved 0
1554 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
1555 # load-reserved/store-conditional instructions.
1556         if { [istarget ia64-*-*]
1557              || [istarget i?86-*-*]
1558              || [istarget x86_64-*-*]
1559              || [istarget alpha*-*-*] 
1560              || [istarget s390*-*-*] 
1561              || [istarget powerpc*-*-*]
1562              || [istarget sparc64-*-*]
1563              || [istarget sparcv9-*-*] } {
1564            set et_sync_char_short_saved 1
1565         }
1566     }
1567
1568     verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
1569     return $et_sync_char_short_saved
1570 }
1571
1572 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
1573 # This can be used with any check_* proc that takes no argument and
1574 # returns only 1 or 0.  It could be used with check_* procs that take
1575 # arguments with keywords that pass particular arguments.
1576
1577 proc is-effective-target { arg } {
1578     set selected 0
1579     if { [info procs check_effective_target_${arg}] != [list] } {
1580         set selected [check_effective_target_${arg}]
1581     } else {
1582         switch $arg {
1583           "vmx_hw"         { set selected [check_vmx_hw_available] }
1584           "named_sections" { set selected [check_named_sections_available] }
1585           "gc_sections"    { set selected [check_gc_sections_available] }
1586           default          { error "unknown effective target keyword `$arg'" }
1587         }
1588     }
1589     verbose "is-effective-target: $arg $selected" 2
1590     return $selected
1591 }
1592
1593 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
1594
1595 proc is-effective-target-keyword { arg } {
1596     if { [info procs check_effective_target_${arg}] != [list] } {
1597         return 1
1598     } else {
1599         # These have different names for their check_* procs.
1600         switch $arg {
1601           "vmx_hw"         { return 1 }
1602           "named_sections" { return 1 }
1603           "gc_sections"    { return 1 }
1604           default          { return 0 }
1605         }
1606     }
1607 }
1608
1609 # Return 1 if target default to short enums
1610
1611 proc check_effective_target_short_enums { } {
1612     return [check_no_compiler_messages short_enums assembly {
1613         enum foo { bar };
1614         int s[sizeof (enum foo) == 1 ? 1 : -1];
1615     }]
1616 }
1617