OSDN Git Service

Index: ChangeLog
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / lib / target-supports.exp
1 #   Copyright (C) 1999, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile some code and return the messages printed by the compiler.
23 #
24 # BASENAME is a basename to use for temporary files.
25 # TYPE is the type of compilation to perform (see target_compile).
26 # CONTENTS gives the contents of the input file.
27 # The rest is optional:
28 # OPTIONS: additional compiler options to use.
29 proc get_compiler_messages {basename type contents args} {
30     global tool
31
32     if { [llength $args] > 0 } {
33         set options "additional_flags=[lindex $args 0]"
34     } else {
35         set options ""
36     }
37
38     set src ${basename}[pid].c
39     switch $type {
40         assembly { set output ${basename}[pid].s }
41         object { set output ${basename}[pid].o }
42     }
43     set f [open $src "w"]
44     puts $f $contents
45     close $f
46     set lines [${tool}_target_compile $src $output $type "$options"]
47     file delete $src
48     remote_file build delete $output
49
50     return $lines
51 }
52
53 proc current_target_name { } {
54     global target_info
55     if [info exists target_info(target,name)] {
56         set answer $target_info(target,name)
57     } else {
58         set answer ""
59     }
60     return $answer
61 }
62
63 ###############################
64 # proc check_weak_available { }
65 ###############################
66
67 # weak symbols are only supported in some configs/object formats
68 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
69
70 proc check_weak_available { } {
71     global target_triplet
72     global target_cpu
73
74     # All mips targets should support it
75
76     if { [ string first "mips" $target_cpu ] >= 0 } {
77         return 1
78     }
79
80     # All solaris2 targets should support it
81
82     if { [regexp ".*-solaris2.*" $target_triplet] } {
83         return 1
84     }
85
86     # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
87
88     if { [regexp "alpha.*osf.*" $target_triplet] } {
89         return 1
90     }
91
92     # Windows targets Cygwin and MingW32 support it
93
94     if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
95         return 1
96     }
97
98     # HP-UX 10.X doesn't support it
99
100     if { [regexp "hppa.*hpux10" $target_triplet] } {
101         return 0
102     }
103
104     # ELF and ECOFF support it. a.out does with gas/gld but may also with
105     # other linkers, so we should try it
106
107     set objformat [gcc_target_object_format]
108
109     switch $objformat {
110         elf      { return 1 }
111         ecoff    { return 1 }
112         a.out    { return 1 }
113         mach-o   { return 1 }
114         som      { return 1 }
115         unknown  { return -1 }
116         default  { return 0 }
117     }
118 }
119
120 ###############################
121 # proc check_visibility_available { what_kind }
122 ###############################
123
124 # The visibility attribute is only support in some object formats
125 # This proc returns 1 if it is supported, 0 if not.
126 # The argument is the kind of visibility, default/protected/hidden/internal.
127
128 proc check_visibility_available { what_kind } {
129     global visibility_available_saved
130     global tool
131     global target_triplet
132
133     # On NetWare, support makes no sense.
134     if { [string match "*-*-netware*" $target_triplet] } {
135         return 0
136     }
137
138     if [string match "" $what_kind] { set what_kind "hidden" }
139
140     if { [info exists visibility_available_saved] } {
141         verbose "Saved result is <$visibility_available_saved>" 1
142         if { [ lsearch -exact $visibility_available_saved $what_kind ] != -1 } {
143             return 1
144         } elseif { [ lsearch -exact $visibility_available_saved "!$what_kind" ] != -1 } {
145             return 0
146         }
147     }
148
149     set lines [get_compiler_messages visibility object "
150         void f() __attribute__((visibility(\"$what_kind\")));
151         void f() {}
152     "]
153     if [string match "" $lines] then {
154         set answer 1
155         lappend visibility_available_saved $what_kind
156     } else {
157         set answer 0
158         lappend visibility_available_saved "!$what_kind"
159     }
160     return $answer
161 }
162
163 ###############################
164 # proc check_alias_available { }
165 ###############################
166
167 # Determine if the target toolchain supports the alias attribute.
168
169 # Returns 2 if the target supports aliases.  Returns 1 if the target
170 # only supports weak aliased.  Returns 0 if the target does not
171 # support aliases at all.  Returns -1 if support for aliases could not
172 # be determined.
173
174 proc check_alias_available { } {
175     global alias_available_saved
176     global tool
177
178     if [info exists alias_available_saved] {
179         verbose "check_alias_available  returning saved $alias_available_saved" 2
180     } else {
181         set src alias[pid].c
182         set obj alias[pid].o
183         verbose "check_alias_available  compiling testfile $src" 2
184         set f [open $src "w"]
185         # Compile a small test program.  The definition of "g" is
186         # necessary to keep the Solaris assembler from complaining
187         # about the program.
188         puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
189         puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
190         close $f
191         set lines [${tool}_target_compile $src $obj object ""]
192         file delete $src
193         remote_file build delete $obj
194
195         if [string match "" $lines] then {
196             # No error messages, everything is OK.
197             set alias_available_saved 2
198         } else {
199             if [regexp "alias definitions not supported" $lines] {
200                 verbose "check_alias_available  target does not support aliases" 2
201
202                 set objformat [gcc_target_object_format]
203
204                 if { $objformat == "elf" } {
205                     verbose "check_alias_available  but target uses ELF format, so it ought to" 2
206                     set alias_available_saved -1
207                 } else {
208                     set alias_available_saved 0
209                 }
210             } else {
211                 if [regexp "only weak aliases are supported" $lines] {
212                 verbose "check_alias_available  target supports only weak aliases" 2
213                 set alias_available_saved 1
214                 } else {
215                     set alias_available_saved -1
216                 }
217             }
218         }
219
220         verbose "check_alias_available  returning $alias_available_saved" 2
221     }
222
223     return $alias_available_saved
224 }
225
226 # Returns true if --gc-sections is supported on the target.
227
228 proc check_gc_sections_available { } {
229     global gc_sections_available_saved
230     global tool
231
232     if {![info exists gc_sections_available_saved]} {
233         # Some targets don't support gc-sections despite whatever's
234         # advertised by ld's options.
235         if { [istarget alpha*-*-*]
236              || [istarget ia64-*-*] } {
237             set gc_sections_available_saved 0
238             return 0
239         }
240
241         # Check if the ld used by gcc supports --gc-sections.
242         set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
243         regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
244         set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
245         set ld_output [remote_exec host "$gcc_ld" "--help"]
246         if { [ string first "--gc-sections" $ld_output ] >= 0 } {
247             set gc_sections_available_saved 1
248         } else {
249             set gc_sections_available_saved 0
250         }
251     }
252     return $gc_sections_available_saved
253 }
254
255 # Return true if profiling is supported on the target.
256
257 proc check_profiling_available { test_what } {
258     global profiling_available_saved
259
260     verbose "Profiling argument is <$test_what>" 1
261
262     # These conditions depend on the argument so examine them before
263     # looking at the cache variable.
264
265     # Support for -p on solaris2 relies on mcrt1.o which comes with the
266     # vendor compiler.  We cannot reliably predict the directory where the
267     # vendor compiler (and thus mcrt1.o) is installed so we can't
268     # necessarily find mcrt1.o even if we have it.
269     if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
270         return 0
271     }
272
273     # Support for -p on irix relies on libprof1.a which doesn't appear to
274     # exist on any irix6 system currently posting testsuite results.
275     # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
276     # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
277     if { [istarget mips*-*-irix*]
278     && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
279         return 0
280     }
281
282     # Now examine the cache variable.
283     if {![info exists profiling_available_saved]} {
284         # Some targets don't have any implementation of __bb_init_func or are
285         # missing other needed machinery.
286         if { [istarget mmix-*-*]
287              || [istarget arm*-*-eabi*]
288              || [istarget arm*-*-elf]
289              || [istarget arm*-*-symbianelf*]
290              || [istarget powerpc-*-eabi*]
291              || [istarget strongarm*-*-elf]
292              || [istarget xscale*-*-elf]
293              || [istarget cris-*-*]
294              || [istarget h8300-*-*]
295              || [istarget mips*-*-elf]
296              || [istarget *-*-windiss] } {
297             set profiling_available_saved 0
298         } else {
299             set profiling_available_saved 1
300         }
301     }
302
303     return $profiling_available_saved
304 }
305
306 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
307 # emitted, 0 otherwise.  Whether a shared library can actually be built is
308 # out of scope for this test.
309 #
310 # When the target name changes, replace the cached result.
311
312 proc check_effective_target_fpic { } {
313     global et_fpic_saved
314     global et_fpic_target_name
315
316     if { ![info exists et_fpic_target_name] } {
317         set et_fpic_target_name ""
318     }
319
320     # If the target has changed since we set the cached value, clear it.
321     set current_target [current_target_name]
322     if { $current_target != $et_fpic_target_name } {
323         verbose "check_effective_target_fpic: `$et_fpic_target_name'" 2
324         set et_fpic_target_name $current_target
325         if [info exists et_fpic_saved] {
326             verbose "check_effective_target_fpic: removing cached result" 2
327             unset et_fpic_saved
328         }
329     }
330
331     if [info exists et_fpic_saved] {
332         verbose "check_effective_target_fpic: using cached result" 2
333     } else {
334         verbose "check_effective_target_fpic: compiling source" 2
335
336         # Note that M68K has a multilib that supports -fpic but not
337         # -fPIC, so we need to check both.  We test with a program that
338         # requires GOT references.
339         set et_fpic_saved [string match "" [get_compiler_messages fpic object {
340             extern int foo (void); extern int bar;
341             int baz (void) { return foo () + bar; }
342         } "-fpic"]]
343
344         if { $et_fpic_saved != 0 } {
345             set et_fpic_saved [string match "" [get_compiler_messages fpic object {
346                 extern int foo (void); extern int bar;
347                 int baz (void) { return foo () + bar; }
348             } "-fPIC"]]
349         }
350     }
351     verbose "check_effective_target_fpic: returning $et_fpic_saved" 2
352     return $et_fpic_saved
353 }
354
355 # Return true if iconv is supported on the target. In particular IBM1047.
356
357 proc check_iconv_available { test_what } {
358     global tool
359     global libiconv
360
361     set result ""
362
363     set src iconv[pid].c
364     set exe iconv[pid].x
365     verbose "check_iconv_available compiling testfile $src" 2
366     set f [open $src "w"]
367     # Compile a small test program.
368     puts $f "#include <iconv.h>\n"
369     puts $f "int main (void)\n {\n iconv_t cd; \n"
370     puts $f "cd = iconv_open (\"[lindex $test_what 1]\", \"UTF-8\");\n"
371     puts $f "if (cd == (iconv_t) -1)\n return 1;\n"
372     puts $f "return 0;\n}"
373     close $f
374
375     # If the tool configuration file has not set libiconv, try "-liconv"
376     if { ![info exists libiconv] } {
377         set libiconv "-liconv"
378     }
379     set lines [${tool}_target_compile $src $exe executable "libs=$libiconv" ]
380     file delete $src
381
382     if [string match "" $lines] then {
383         # No error messages, everything is OK.
384
385         set result [${tool}_load "./$exe" "" ""]
386         set status [lindex $result 0]
387         remote_file build delete $exe
388
389         verbose "check_iconv_available status is <$status>" 2
390
391         if { $status == "pass" } then {
392             return 1
393         }
394     }
395
396     return 0
397 }
398
399 # Return true if named sections are supported on this target.
400 # This proc does not cache results, because the answer may vary
401 # when cycling over subtarget options (e.g. irix o32/n32/n64) in
402 # the same test run.
403 proc check_named_sections_available { } {
404     verbose "check_named_sections_available: compiling source" 2
405     set answer [string match "" [get_compiler_messages named object {
406         int __attribute__ ((section("whatever"))) foo;
407     }]]
408     verbose "check_named_sections_available: returning $answer" 2
409     return $answer
410 }
411
412 # Return 1 if the target supports executing AltiVec instructions, 0
413 # otherwise.  Cache the result.
414
415 proc check_vmx_hw_available { } {
416     global vmx_hw_available_saved
417     global tool
418
419     if [info exists vmx_hw_available_saved] {
420         verbose "check_hw_available  returning saved $vmx_hw_available_saved" 2
421     } else {
422         set vmx_hw_available_saved 0
423
424         # Some simulators are known to not support VMX instructions.
425         if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
426             verbose "check_hw_available  returning 0" 2
427             return $vmx_hw_available_saved
428         }
429
430         # Set up, compile, and execute a test program containing VMX
431         # instructions.  Include the current process ID in the file
432         # names to prevent conflicts with invocations for multiple
433         # testsuites.
434         set src vmx[pid].c
435         set exe vmx[pid].x
436
437         set f [open $src "w"]
438         puts $f "int main() {"
439         puts $f "#ifdef __MACH__"
440         puts $f "  asm volatile (\"vor v0,v0,v0\");"
441         puts $f "#else"
442         puts $f "  asm volatile (\"vor 0,0,0\");"
443         puts $f "#endif"
444         puts $f "  return 0; }"
445         close $f
446
447         # Most targets don't require special flags for this test case, but
448         # Darwin does.
449         if [istarget *-*-darwin*] {
450           set opts "additional_flags=-maltivec"
451         } else {
452           set opts ""
453         }
454
455         verbose "check_vmx_hw_available  compiling testfile $src" 2
456         set lines [${tool}_target_compile $src $exe executable "$opts"]
457         file delete $src
458
459         if [string match "" $lines] then {
460             # No error message, compilation succeeded.
461             set result [${tool}_load "./$exe" "" ""]
462             set status [lindex $result 0]
463             remote_file build delete $exe
464             verbose "check_vmx_hw_available testfile status is <$status>" 2
465
466             if { $status == "pass" } then {
467                 set vmx_hw_available_saved 1
468             }
469         } else {
470             verbose "check_vmx_hw_availalble testfile compilation failed" 2
471         }
472     }
473
474     return $vmx_hw_available_saved
475 }
476
477 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
478 # complex float arguments.  This affects gfortran tests that call cabsf
479 # in libm built by an earlier compiler.  Return 1 if libm uses the same
480 # argument passing as the compiler under test, 0 otherwise.
481 #
482 # When the target name changes, replace the cached result.
483
484 proc check_effective_target_broken_cplxf_arg { } {
485     global et_broken_cplxf_arg_saved
486     global et_broken_cplxf_arg_target_name
487     global tool
488
489     # Skip the work for targets known not to be affected.
490     if { ![istarget powerpc64-*-linux*] } {
491         return 0
492     } elseif { [is-effective-target ilp32] } {
493         return 0
494     }
495
496     if { ![info exists et_broken_cplxf_arg_target_name] } {
497         set et_broken_cplxf_arg_target_name ""
498     }
499
500     # If the target has changed since we set the cached value, clear it.
501     set current_target [current_target_name]
502     if { $current_target != $et_broken_cplxf_arg_target_name } {
503         verbose "check_effective_target_broken_cplxf_arg: `$et_broken_cplxf_arg_target_name'" 2
504         set et_broken_cplxf_arg_target_name $current_target
505         if [info exists et_broken_cplxf_arg_saved] {
506             verbose "check_effective_target_broken_cplxf_arg: removing cached result" 2
507             unset et_broken_cplxf_arg_saved
508         }
509     }
510
511     if [info exists et_broken_cplxf_arg_saved] {
512         verbose "check_effective_target_broken_cplxf_arg: using cached result" 2
513     } else {
514         set et_broken_cplxf_arg_saved 0
515         # This is only known to affect one target.
516         if { ![istarget powerpc64-*-linux*] || ![is-effective-target lp64] } {
517             set et_broken_cplxf_arg_saved 0
518             verbose "check_effective_target_broken_cplxf_arg: caching 0" 2
519             return $et_broken_cplxf_arg_saved
520         }
521
522         # Set up, compile, and execute a C test program that calls cabsf.
523         set src cabsf[pid].c
524         set exe cabsf[pid].x
525
526         set f [open $src "w"]
527         puts $f "#include <complex.h>"
528         puts $f "extern void abort (void);"
529         puts $f "float fabsf (float);"
530         puts $f "float cabsf (_Complex float);"
531         puts $f "int main ()"
532         puts $f "{"
533         puts $f "  _Complex float cf;"
534         puts $f "  float f;"
535         puts $f "  cf = 3 + 4.0fi;"
536         puts $f "  f = cabsf (cf);"
537         puts $f "  if (fabsf (f - 5.0) > 0.0001) abort ();"
538         puts $f "  return 0;"
539         puts $f "}"
540         close $f
541
542         set lines [${tool}_target_compile $src $exe executable "-lm"]
543         file delete $src
544
545         if [string match "" $lines] {
546             # No error message, compilation succeeded.
547             set result [${tool}_load "./$exe" "" ""]
548             set status [lindex $result 0]
549             remote_file build delete $exe
550
551             verbose "check_effective_target_broken_cplxf_arg: status is <$status>" 2
552
553             if { $status != "pass" } {
554                 set et_broken_cplxf_arg_saved 1
555             }
556         } else {
557             verbose "check_effective_target_broken_cplxf_arg: compilation failed" 2
558         }
559     }
560     return $et_broken_cplxf_arg_saved
561 }
562
563 proc check_alpha_max_hw_available { } {
564     global alpha_max_hw_available_saved
565     global tool
566
567     if [info exists alpha_max_hw_available_saved] {
568         verbose "check_alpha_max_hw_available returning saved $alpha_max_hw_available_saved" 2
569     } else {
570         set alpha_max_hw_available_saved 0
571
572         # Set up, compile, and execute a test program probing bit 8 of the
573         # architecture mask, which indicates presence of MAX instructions.
574         set src max[pid].c
575         set exe max[pid].x
576
577         set f [open $src "w"]
578         puts $f "int main() { return __builtin_alpha_amask(1<<8) != 0; }"
579         close $f
580
581         verbose "check_alpha_max_hw_available compiling testfile $src" 2
582         set lines [${tool}_target_compile $src $exe executable ""]
583         file delete $src
584
585         if [string match "" $lines] then {
586             # No error message, compilation succeeded.
587             set result [${tool}_load "./$exe" "" ""]
588             set status [lindex $result 0]
589             remote_file build delete $exe
590             verbose "check_alpha_max_hw_available testfile status is <$status>" 2
591
592             if { $status == "pass" } then {
593                 set alpha_max_hw_available_saved 1
594             }
595         } else {
596             verbose "check_alpha_max_hw_availalble testfile compilation failed" 2
597         }
598     }
599
600     return $alpha_max_hw_available_saved
601 }
602
603 # Return 1 if we're generating 32-bit code using default options, 0
604 # otherwise.
605 #
606 # When the target name changes, replace the cached result.
607
608 proc check_effective_target_ilp32 { } {
609     global et_ilp32_saved
610     global et_ilp32_target_name
611
612     if { ![info exists et_ilp32_target_name] } {
613         set et_ilp32_target_name ""
614     }
615
616     # If the target has changed since we set the cached value, clear it.
617     set current_target [current_target_name]
618     if { $current_target != $et_ilp32_target_name } {
619         verbose "check_effective_target_ilp32: `$et_ilp32_target_name' `$current_target'" 2
620         set et_ilp32_target_name $current_target
621         if { [info exists et_ilp32_saved] } {
622             verbose "check_effective_target_ilp32: removing cached result" 2
623             unset et_ilp32_saved
624         }
625     }
626
627     if [info exists et_ilp32_saved] {
628         verbose "check-effective_target_ilp32: using cached result" 2
629     } else {
630         verbose "check_effective_target_ilp32: compiling source" 2
631         set et_ilp32_saved [string match "" [get_compiler_messages ilp32 object {
632             int dummy[(sizeof (int) == 4 && sizeof (void *) == 4 && sizeof (long) == 4 ) ? 1 : -1];
633         }]]
634     }
635     verbose "check_effective_target_ilp32: returning $et_ilp32_saved" 2
636     return $et_ilp32_saved
637 }
638
639 # Return 1 if we're generating 64-bit code using default options, 0
640 # otherwise.
641 #
642 # When the target name changes, replace the cached result.
643
644 proc check_effective_target_lp64 { } {
645     global et_lp64_saved
646     global et_lp64_target_name
647
648     if { ![info exists et_lp64_target_name] } {
649         set et_lp64_target_name ""
650     }
651
652     # If the target has changed since we set the cached value, clear it.
653     set current_target [current_target_name]
654     if { $current_target != $et_lp64_target_name } {
655         verbose "check_effective_target_lp64: `$et_lp64_target_name' `$current_target'" 2
656         set et_lp64_target_name $current_target
657         if [info exists et_lp64_saved] {
658             verbose "check_effective_target_lp64: removing cached result" 2
659             unset et_lp64_saved
660         }
661     }
662
663     if [info exists et_lp64_saved] {
664         verbose "check_effective_target_lp64: using cached result" 2
665     } else {
666         verbose "check_effective_target_lp64: compiling source" 2
667         set et_lp64_saved [string match "" [get_compiler_messages lp64 object {
668             int dummy[(sizeof (int) == 4 && sizeof (void *) == 8 && sizeof (long) == 8 ) ? 1 : -1];
669         }]]
670     }
671     verbose "check_effective_target_lp64: returning $et_lp64_saved" 2
672     return $et_lp64_saved
673 }
674
675 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
676 #
677 # This won't change for different subtargets so cache the result.
678
679 proc check_effective_target_vect_int { } {
680     global et_vect_int_saved
681
682     if [info exists et_vect_int_saved] {
683         verbose "check_effective_target_vect_int: using cached result" 2
684     } else {
685         set et_vect_int_saved 0
686         if { [istarget i?86-*-*]
687               || [istarget powerpc*-*-*]
688               || [istarget x86_64-*-*]
689               || [istarget sparc*-*-*]
690               || [istarget alpha*-*-*]
691               || [istarget ia64-*-*] } {
692            set et_vect_int_saved 1
693         }
694     }
695
696     verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
697     return $et_vect_int_saved
698 }
699
700 # Return 1 if the target supports hardware vector shift operation.
701
702 proc check_effective_target_vect_shift { } {
703     if { [istarget powerpc*-*-*] } {
704         set answer 1
705     } else {
706         set answer 0
707     }
708
709     verbose "check_effective_target_vect_shift: returning $answer" 2
710     return $answer
711 }
712
713 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
714 #
715 # This can change for different subtargets so do not cache the result.
716
717 proc check_effective_target_vect_long { } {
718     if { [istarget i?86-*-*]
719          || ([istarget powerpc*-*-*] && [check_effective_target_ilp32])
720          || [istarget x86_64-*-*]
721          || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
722         set answer 1
723     } else {
724         set answer 0
725     }
726
727     verbose "check_effective_target_vect_long: returning $answer" 2
728     return $answer
729 }
730
731 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
732 #
733 # This won't change for different subtargets so cache the result.
734
735 proc check_effective_target_vect_float { } {
736     global et_vect_float_saved
737
738     if [info exists et_vect_float_saved] {
739         verbose "check_effective_target_vect_float: using cached result" 2
740     } else {
741         set et_vect_float_saved 0
742         if { [istarget i?86-*-*]
743               || [istarget powerpc*-*-*]
744               || [istarget mipsisa64*-*-*]
745               || [istarget x86_64-*-*]
746               || [istarget ia64-*-*] } {
747            set et_vect_float_saved 1
748         }
749     }
750
751     verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
752     return $et_vect_float_saved
753 }
754
755 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
756 #
757 # This won't change for different subtargets so cache the result.
758
759 proc check_effective_target_vect_double { } {
760     global et_vect_double_saved
761
762     if [info exists et_vect_double_saved] {
763         verbose "check_effective_target_vect_double: using cached result" 2
764     } else {
765         set et_vect_double_saved 0
766         if { [istarget i?86-*-*]
767               || [istarget x86_64-*-*] } {
768            set et_vect_double_saved 1
769         }
770     }
771
772     verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
773     return $et_vect_double_saved
774 }
775
776 # Return 1 if the target plus current options does not support a vector
777 # max instruction, 0 otherwise.
778 #
779 # This won't change for different subtargets so cache the result.
780
781 proc check_effective_target_vect_no_max { } {
782     global et_vect_no_max_saved
783
784     if [info exists et_vect_no_max_saved] {
785         verbose "check_effective_target_vect_no_max: using cached result" 2
786     } else {
787         set et_vect_no_max_saved 0
788         if { [istarget i?86-*-*]
789              || [istarget x86_64-*-*]
790              || [istarget sparc*-*-*]
791              || [istarget alpha*-*-*] } {
792             set et_vect_no_max_saved 1
793         }
794     }
795     verbose "check_effective_target_vect_no_max: returning $et_vect_no_max_saved" 2
796     return $et_vect_no_max_saved
797 }
798
799 # Return 1 if the target plus current options does not support vector
800 # bitwise instructions, 0 otherwise.
801 #
802 # This won't change for different subtargets so cache the result.
803
804 proc check_effective_target_vect_no_bitwise { } {
805     global et_vect_no_bitwise_saved
806
807     if [info exists et_vect_no_bitwise_saved] {
808         verbose "check_effective_target_vect_no_bitwise: using cached result" 2
809     } else {
810         set et_vect_no_bitwise_saved 0
811     }
812     verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
813     return $et_vect_no_bitwise_saved
814 }
815
816 # Return 1 if the target plus current options does not support a vector
817 # alignment mechanism, 0 otherwise.
818 #
819 # This won't change for different subtargets so cache the result.
820
821 proc check_effective_target_vect_no_align { } {
822     global et_vect_no_align_saved
823
824     if [info exists et_vect_no_align_saved] {
825         verbose "check_effective_target_vect_no_align: using cached result" 2
826     } else {
827         set et_vect_no_align_saved 0
828         if { [istarget mipsisa64*-*-*]
829              || [istarget sparc*-*-*]
830              || [istarget ia64-*-*] } {
831             set et_vect_no_align_saved 1
832         }
833     }
834     verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
835     return $et_vect_no_align_saved
836 }
837
838 # Return 1 if the target supports vector conditional operations, 0 otherwise.
839
840 proc check_effective_target_vect_condition { } {
841     global et_vect_cond_saved
842
843     if [info exists et_vect_int_cond] {
844         verbose "check_effective_target_vect_cond: using cached result" 2
845     } else {
846         set et_vect_cond_saved 0
847         if { [istarget powerpc*-*-*]
848              || [istarget ia64-*-*]
849              || [istarget i?86-*-*]
850              || [istarget x86_64-*-*] } {
851            set et_vect_cond_saved 1
852         }
853     }
854
855     verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
856     return $et_vect_cond_saved
857 }
858
859 # Return 1 if the target supports vector int multiplication, 0 otherwise.
860
861 proc check_effective_target_vect_int_mult { } {
862     global et_vect_int_mult_saved
863
864     if [info exists et_vect_int_mult_saved] {
865         verbose "check_effective_target_vect_int_mult: using cached result" 2
866     } else {
867         set et_vect_int_mult_saved 0
868         if { [istarget powerpc*-*-*] } {
869            set et_vect_int_mult_saved 1
870         }
871     }
872
873     verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
874     return $et_vect_int_mult_saved
875 }
876
877 # Return 1 if the target supports atomic operations on "int" and "long".
878
879 proc check_effective_target_sync_int_long { } {
880     global et_sync_int_long_saved
881
882     if [info exists et_sync_int_long_saved] {
883         verbose "check_effective_target_sync_int_long: using cached result" 2
884     } else {
885         set et_sync_int_long_saved 0
886 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
887 # load-reserved/store-conditional instructions.
888         if { [istarget ia64-*-*]
889              || [istarget i?86-*-*]
890              || [istarget x86_64-*-*]
891              || [istarget alpha*-*-*] 
892              || [istarget powerpc*-*-*] } {
893            set et_sync_int_long_saved 1
894         }
895     }
896
897     verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
898     return $et_sync_int_long_saved
899 }
900
901 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
902 # This can be used with any check_* proc that takes no argument and
903 # returns only 1 or 0.  It could be used with check_* procs that take
904 # arguments with keywords that pass particular arguments.
905
906 proc is-effective-target { arg } {
907     set selected 0
908     if { [info procs check_effective_target_${arg}] != [list] } {
909         set selected [check_effective_target_${arg}]
910     } else {
911         switch $arg {
912           "vmx_hw"         { set selected [check_vmx_hw_available] }
913           "named_sections" { set selected [check_named_sections_available] }
914           "gc_sections"    { set selected [check_gc_sections_available] }
915           default          { error "unknown effective target keyword `$arg'" }
916         }
917     }
918     verbose "is-effective-target: $arg $selected" 2
919     return $selected
920 }
921
922 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
923
924 proc is-effective-target-keyword { arg } {
925     if { [info procs check_effective_target_${arg}] != [list] } {
926         return 1
927     } else {
928         # These have different names for their check_* procs.
929         switch $arg {
930           "vmx_hw"         { return 1 }
931           "named_sections" { return 1 }
932           "gc_sections"    { return 1 }
933           default          { return 0 }
934         }
935     }
936 }