Disable double precision vectorizer for Atom.
[gcc.git] / gcc / testsuite / lib / target-supports.exp
1 # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
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 3 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 GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
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 the code given by CONTENTS into an output file of
24 # type TYPE, where TYPE is as for target_compile. Return a list
25 # whose first element contains the compiler messages and whose
26 # second element is the name of the output file.
27 #
28 # BASENAME is a prefix to use for source and output files.
29 # If ARGS is not empty, its first element is a string that
30 # should be added to the command line.
31 #
32 # Assume by default that CONTENTS is C code.
33 # Otherwise, code should contain:
34 # "// C++" for c++,
35 # "! Fortran" for Fortran code,
36 # "/* ObjC", for ObjC
37 # and "// ObjC++" for ObjC++
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
43
44 if { [llength $args] > 0 } {
45 set options [list "additional_flags=[lindex $args 0]"]
46 } else {
47 set options ""
48 }
49 switch -glob -- $contents {
50 "*! Fortran*" { set src ${basename}[pid].f90 }
51 "*// C++*" { set src ${basename}[pid].cc }
52 "*// ObjC++*" { set src ${basename}[pid].mm }
53 "*/* ObjC*" { set src ${basename}[pid].m }
54 default {
55 switch -- $tool {
56 "objc" { set src ${basename}[pid].m }
57 "obj-c++" { set src ${basename}[pid].mm }
58 default { set src ${basename}[pid].c }
59 }
60 }
61 }
62
63 set compile_type $type
64 switch -glob $type {
65 assembly { set output ${basename}[pid].s }
66 object { set output ${basename}[pid].o }
67 executable { set output ${basename}[pid].exe }
68 "rtl-*" {
69 set output ${basename}[pid].s
70 lappend options "additional_flags=-fdump-$type"
71 set compile_type assembly
72 }
73 }
74 set f [open $src "w"]
75 puts $f $contents
76 close $f
77 set lines [${tool}_target_compile $src $output $compile_type "$options"]
78 file delete $src
79
80 set scan_output $output
81 # Don't try folding this into the switch above; calling "glob" before the
82 # file is created won't work.
83 if [regexp "rtl-(.*)" $type dummy rtl_type] {
84 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
85 file delete $output
86 }
87
88 return [list $lines $scan_output]
89 }
90
91 proc current_target_name { } {
92 global target_info
93 if [info exists target_info(target,name)] {
94 set answer $target_info(target,name)
95 } else {
96 set answer ""
97 }
98 return $answer
99 }
100
101 # Implement an effective-target check for property PROP by invoking
102 # the Tcl command ARGS and seeing if it returns true.
103
104 proc check_cached_effective_target { prop args } {
105 global et_cache
106
107 set target [current_target_name]
108 if {![info exists et_cache($prop,target)]
109 || $et_cache($prop,target) != $target} {
110 verbose "check_cached_effective_target $prop: checking $target" 2
111 set et_cache($prop,target) $target
112 set et_cache($prop,value) [uplevel eval $args]
113 }
114 set value $et_cache($prop,value)
115 verbose "check_cached_effective_target $prop: returning $value for $target" 2
116 return $value
117 }
118
119 # Like check_compile, but delete the output file and return true if the
120 # compiler printed no messages.
121 proc check_no_compiler_messages_nocache {args} {
122 set result [eval check_compile $args]
123 set lines [lindex $result 0]
124 set output [lindex $result 1]
125 remote_file build delete $output
126 return [string match "" $lines]
127 }
128
129 # Like check_no_compiler_messages_nocache, but cache the result.
130 # PROP is the property we're checking, and doubles as a prefix for
131 # temporary filenames.
132 proc check_no_compiler_messages {prop args} {
133 return [check_cached_effective_target $prop {
134 eval [list check_no_compiler_messages_nocache $prop] $args
135 }]
136 }
137
138 # Like check_compile, but return true if the compiler printed no
139 # messages and if the contents of the output file satisfy PATTERN.
140 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
141 # don't match regular expression REGEXP, otherwise they satisfy it
142 # if they do match regular expression PATTERN. (PATTERN can start
143 # with something like "[!]" if the regular expression needs to match
144 # "!" as the first character.)
145 #
146 # Delete the output file before returning. The other arguments are
147 # as for check_compile.
148 proc check_no_messages_and_pattern_nocache {basename pattern args} {
149 global tool
150
151 set result [eval [list check_compile $basename] $args]
152 set lines [lindex $result 0]
153 set output [lindex $result 1]
154
155 set ok 0
156 if { [string match "" $lines] } {
157 set chan [open "$output"]
158 set invert [regexp {^!(.*)} $pattern dummy pattern]
159 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
160 close $chan
161 }
162
163 remote_file build delete $output
164 return $ok
165 }
166
167 # Like check_no_messages_and_pattern_nocache, but cache the result.
168 # PROP is the property we're checking, and doubles as a prefix for
169 # temporary filenames.
170 proc check_no_messages_and_pattern {prop pattern args} {
171 return [check_cached_effective_target $prop {
172 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
173 }]
174 }
175
176 # Try to compile and run an executable from code CONTENTS. Return true
177 # if the compiler reports no messages and if execution "passes" in the
178 # usual DejaGNU sense. The arguments are as for check_compile, with
179 # TYPE implicitly being "executable".
180 proc check_runtime_nocache {basename contents args} {
181 global tool
182
183 set result [eval [list check_compile $basename executable $contents] $args]
184 set lines [lindex $result 0]
185 set output [lindex $result 1]
186
187 set ok 0
188 if { [string match "" $lines] } {
189 # No error messages, everything is OK.
190 set result [remote_load target "./$output" "" ""]
191 set status [lindex $result 0]
192 verbose "check_runtime_nocache $basename: status is <$status>" 2
193 if { $status == "pass" } {
194 set ok 1
195 }
196 }
197 remote_file build delete $output
198 return $ok
199 }
200
201 # Like check_runtime_nocache, but cache the result. PROP is the
202 # property we're checking, and doubles as a prefix for temporary
203 # filenames.
204 proc check_runtime {prop args} {
205 global tool
206
207 return [check_cached_effective_target $prop {
208 eval [list check_runtime_nocache $prop] $args
209 }]
210 }
211
212 ###############################
213 # proc check_weak_available { }
214 ###############################
215
216 # weak symbols are only supported in some configs/object formats
217 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
218
219 proc check_weak_available { } {
220 global target_triplet
221 global target_cpu
222
223 # All mips targets should support it
224
225 if { [ string first "mips" $target_cpu ] >= 0 } {
226 return 1
227 }
228
229 # All solaris2 targets should support it
230
231 if { [regexp ".*-solaris2.*" $target_triplet] } {
232 return 1
233 }
234
235 # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it
236
237 if { [regexp "alpha.*osf.*" $target_triplet] } {
238 return 1
239 }
240
241 # Windows targets Cygwin and MingW32 support it
242
243 if { [regexp ".*mingw32|.*cygwin" $target_triplet] } {
244 return 1
245 }
246
247 # HP-UX 10.X doesn't support it
248
249 if { [istarget "hppa*-*-hpux10*"] } {
250 return 0
251 }
252
253 # ELF and ECOFF support it. a.out does with gas/gld but may also with
254 # other linkers, so we should try it
255
256 set objformat [gcc_target_object_format]
257
258 switch $objformat {
259 elf { return 1 }
260 ecoff { return 1 }
261 a.out { return 1 }
262 mach-o { return 1 }
263 som { return 1 }
264 unknown { return -1 }
265 default { return 0 }
266 }
267 }
268
269 ###############################
270 # proc check_weak_override_available { }
271 ###############################
272
273 # Like check_weak_available, but return 0 if weak symbol definitions
274 # cannot be overridden.
275
276 proc check_weak_override_available { } {
277 if { [istarget "*-*-mingw*"] } {
278 return 0
279 }
280 return [check_weak_available]
281 }
282
283 ###############################
284 # proc check_visibility_available { what_kind }
285 ###############################
286
287 # The visibility attribute is only support in some object formats
288 # This proc returns 1 if it is supported, 0 if not.
289 # The argument is the kind of visibility, default/protected/hidden/internal.
290
291 proc check_visibility_available { what_kind } {
292 global tool
293 global target_triplet
294
295 # On NetWare, support makes no sense.
296 if { [istarget *-*-netware*] } {
297 return 0
298 }
299
300 if [string match "" $what_kind] { set what_kind "hidden" }
301
302 return [check_no_compiler_messages visibility_available_$what_kind object "
303 void f() __attribute__((visibility(\"$what_kind\")));
304 void f() {}
305 "]
306 }
307
308 ###############################
309 # proc check_alias_available { }
310 ###############################
311
312 # Determine if the target toolchain supports the alias attribute.
313
314 # Returns 2 if the target supports aliases. Returns 1 if the target
315 # only supports weak aliased. Returns 0 if the target does not
316 # support aliases at all. Returns -1 if support for aliases could not
317 # be determined.
318
319 proc check_alias_available { } {
320 global alias_available_saved
321 global tool
322
323 if [info exists alias_available_saved] {
324 verbose "check_alias_available returning saved $alias_available_saved" 2
325 } else {
326 set src alias[pid].c
327 set obj alias[pid].o
328 verbose "check_alias_available compiling testfile $src" 2
329 set f [open $src "w"]
330 # Compile a small test program. The definition of "g" is
331 # necessary to keep the Solaris assembler from complaining
332 # about the program.
333 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
334 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
335 close $f
336 set lines [${tool}_target_compile $src $obj object ""]
337 file delete $src
338 remote_file build delete $obj
339
340 if [string match "" $lines] then {
341 # No error messages, everything is OK.
342 set alias_available_saved 2
343 } else {
344 if [regexp "alias definitions not supported" $lines] {
345 verbose "check_alias_available target does not support aliases" 2
346
347 set objformat [gcc_target_object_format]
348
349 if { $objformat == "elf" } {
350 verbose "check_alias_available but target uses ELF format, so it ought to" 2
351 set alias_available_saved -1
352 } else {
353 set alias_available_saved 0
354 }
355 } else {
356 if [regexp "only weak aliases are supported" $lines] {
357 verbose "check_alias_available target supports only weak aliases" 2
358 set alias_available_saved 1
359 } else {
360 set alias_available_saved -1
361 }
362 }
363 }
364
365 verbose "check_alias_available returning $alias_available_saved" 2
366 }
367
368 return $alias_available_saved
369 }
370
371 ###############################
372 # proc check_ifunc_available { }
373 ###############################
374
375 # Determine if the target toolchain supports the alias attribute.
376
377 # Returns 2 if the target supports aliases. Returns 1 if the target
378 # only supports weak aliased. Returns 0 if the target does not
379 # support aliases at all. Returns -1 if support for aliases could not
380 # be determined.
381
382 proc check_ifunc_available { } {
383 global ifunc_available_saved
384 global tool
385
386 if [info exists ifunc_available_saved] {
387 verbose "check_ifunc_available returning saved $ifunc_available_saved" 2
388 } else {
389 set src ifunc[pid].c
390 set obj ifunc[pid].o
391 verbose "check_ifunc_available compiling testfile $src" 2
392 set f [open $src "w"]
393 # Compile a small test program. The definition of "g" is
394 # necessary to keep the Solaris assembler from complaining
395 # about the program.
396 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
397 puts $f "void g() {} void f() __attribute__((ifunc(\"g\")));"
398 close $f
399 set lines [${tool}_target_compile $src $obj object ""]
400 file delete $src
401 remote_file build delete $obj
402
403 if [string match "" $lines] then {
404 # No error messages, everything is OK.
405 set ifunc_available_saved 2
406 } else {
407 if [regexp "ifunc is not supported" $lines] {
408 verbose "check_ifunc_available target does not support ifunc" 2
409 set ifunc_available_saved 0
410 } else {
411 set ifunc_available_saved -1
412 }
413 }
414
415 verbose "check_ifunc_available returning $ifunc_available_saved" 2
416 }
417
418 return $ifunc_available_saved
419 }
420
421 # Returns true if --gc-sections is supported on the target.
422
423 proc check_gc_sections_available { } {
424 global gc_sections_available_saved
425 global tool
426
427 if {![info exists gc_sections_available_saved]} {
428 # Some targets don't support gc-sections despite whatever's
429 # advertised by ld's options.
430 if { [istarget alpha*-*-*]
431 || [istarget ia64-*-*] } {
432 set gc_sections_available_saved 0
433 return 0
434 }
435
436 # elf2flt uses -q (--emit-relocs), which is incompatible with
437 # --gc-sections.
438 if { [board_info target exists ldflags]
439 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
440 set gc_sections_available_saved 0
441 return 0
442 }
443
444 # VxWorks kernel modules are relocatable objects linked with -r,
445 # while RTP executables are linked with -q (--emit-relocs).
446 # Both of these options are incompatible with --gc-sections.
447 if { [istarget *-*-vxworks*] } {
448 set gc_sections_available_saved 0
449 return 0
450 }
451
452 # Check if the ld used by gcc supports --gc-sections.
453 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
454 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
455 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
456 set ld_output [remote_exec host "$gcc_ld" "--help"]
457 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
458 set gc_sections_available_saved 1
459 } else {
460 set gc_sections_available_saved 0
461 }
462 }
463 return $gc_sections_available_saved
464 }
465
466 # Return 1 if according to target_info struct and explicit target list
467 # target is supposed to support trampolines.
468
469 proc check_effective_target_trampolines { } {
470 if [target_info exists no_trampolines] {
471 return 0
472 }
473 if { [istarget avr-*-*]
474 || [istarget hppa2.0w-hp-hpux11.23]
475 || [istarget hppa64-hp-hpux11.23] } {
476 return 0;
477 }
478 return 1
479 }
480
481 # Return 1 if according to target_info struct and explicit target list
482 # target is supposed to keep null pointer checks. This could be due to
483 # use of option fno-delete-null-pointer-checks or hardwired in target.
484
485 proc check_effective_target_keeps_null_pointer_checks { } {
486 if [target_info exists keeps_null_pointer_checks] {
487 return 1
488 }
489 if { [istarget avr-*-*] } {
490 return 1;
491 }
492 return 0
493 }
494
495 # Return true if profiling is supported on the target.
496
497 proc check_profiling_available { test_what } {
498 global profiling_available_saved
499
500 verbose "Profiling argument is <$test_what>" 1
501
502 # These conditions depend on the argument so examine them before
503 # looking at the cache variable.
504
505 # Support for -p on solaris2 relies on mcrt1.o which comes with the
506 # vendor compiler. We cannot reliably predict the directory where the
507 # vendor compiler (and thus mcrt1.o) is installed so we can't
508 # necessarily find mcrt1.o even if we have it.
509 if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } {
510 return 0
511 }
512
513 # Support for -p on irix relies on libprof1.a which doesn't appear to
514 # exist on any irix6 system currently posting testsuite results.
515 # Support for -pg on irix relies on gcrt1.o which doesn't exist yet.
516 # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html
517 if { [istarget mips*-*-irix*]
518 && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } {
519 return 0
520 }
521
522 # We don't yet support profiling for MIPS16.
523 if { [istarget mips*-*-*]
524 && ![check_effective_target_nomips16]
525 && ([lindex $test_what 1] == "-p"
526 || [lindex $test_what 1] == "-pg") } {
527 return 0
528 }
529
530 # MinGW does not support -p.
531 if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } {
532 return 0
533 }
534
535 # cygwin does not support -p.
536 if { [istarget *-*-cygwin*] && [lindex $test_what 1] == "-p" } {
537 return 0
538 }
539
540 # uClibc does not have gcrt1.o.
541 if { [check_effective_target_uclibc]
542 && ([lindex $test_what 1] == "-p"
543 || [lindex $test_what 1] == "-pg") } {
544 return 0
545 }
546
547 # Now examine the cache variable.
548 if {![info exists profiling_available_saved]} {
549 # Some targets don't have any implementation of __bb_init_func or are
550 # missing other needed machinery.
551 if { [istarget mmix-*-*]
552 || [istarget arm*-*-eabi*]
553 || [istarget picochip-*-*]
554 || [istarget *-*-netware*]
555 || [istarget arm*-*-elf]
556 || [istarget arm*-*-symbianelf*]
557 || [istarget avr-*-*]
558 || [istarget bfin-*-*]
559 || [istarget powerpc-*-eabi*]
560 || [istarget powerpc-*-elf]
561 || [istarget cris-*-*]
562 || [istarget crisv32-*-*]
563 || [istarget fido-*-elf]
564 || [istarget h8300-*-*]
565 || [istarget lm32-*-*]
566 || [istarget m32c-*-elf]
567 || [istarget m68k-*-elf]
568 || [istarget m68k-*-uclinux*]
569 || [istarget mep-*-elf]
570 || [istarget mips*-*-elf*]
571 || [istarget moxie-*-elf*]
572 || [istarget rx-*-*]
573 || [istarget xstormy16-*]
574 || [istarget xtensa*-*-elf]
575 || [istarget *-*-rtems*]
576 || [istarget *-*-vxworks*] } {
577 set profiling_available_saved 0
578 } else {
579 set profiling_available_saved 1
580 }
581 }
582
583 return $profiling_available_saved
584 }
585
586 # Check to see if a target is "freestanding". This is as per the definition
587 # in Section 4 of C99 standard. Effectively, it is a target which supports no
588 # extra headers or libraries other than what is considered essential.
589 proc check_effective_target_freestanding { } {
590 if { [istarget picochip-*-*] } then {
591 return 1
592 } else {
593 return 0
594 }
595 }
596
597 # Return 1 if target has packed layout of structure members by
598 # default, 0 otherwise. Note that this is slightly different than
599 # whether the target has "natural alignment": both attributes may be
600 # false.
601
602 proc check_effective_target_default_packed { } {
603 return [check_no_compiler_messages default_packed assembly {
604 struct x { char a; long b; } c;
605 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
606 }]
607 }
608
609 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
610 # documentation, where the test also comes from.
611
612 proc check_effective_target_pcc_bitfield_type_matters { } {
613 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
614 # bitfields, but let's stick to the example code from the docs.
615 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
616 struct foo1 { char x; char :0; char y; };
617 struct foo2 { char x; int :0; char y; };
618 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
619 }]
620 }
621
622 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
623
624 proc add_options_for_tls { flags } {
625 # On Solaris 8 and 9, __tls_get_addr/___tls_get_addr only lives in
626 # libthread, so always pass -pthread for native TLS.
627 # Need to duplicate native TLS check from
628 # check_effective_target_tls_native to avoid recursion.
629 if { [istarget *-*-solaris2.\[89\]*] &&
630 [check_no_messages_and_pattern tls_native "!emutls" assembly {
631 __thread int i;
632 int f (void) { return i; }
633 void g (int j) { i = j; }
634 }] } {
635 return "$flags -pthread"
636 }
637 return $flags
638 }
639
640 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
641
642 proc check_effective_target_tls {} {
643 return [check_no_compiler_messages tls assembly {
644 __thread int i;
645 int f (void) { return i; }
646 void g (int j) { i = j; }
647 }]
648 }
649
650 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
651
652 proc check_effective_target_tls_native {} {
653 # VxWorks uses emulated TLS machinery, but with non-standard helper
654 # functions, so we fail to automatically detect it.
655 global target_triplet
656 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
657 return 0
658 }
659
660 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
661 __thread int i;
662 int f (void) { return i; }
663 void g (int j) { i = j; }
664 }]
665 }
666
667 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
668
669 proc check_effective_target_tls_emulated {} {
670 # VxWorks uses emulated TLS machinery, but with non-standard helper
671 # functions, so we fail to automatically detect it.
672 global target_triplet
673 if { [regexp ".*-.*-vxworks.*" $target_triplet] } {
674 return 1
675 }
676
677 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
678 __thread int i;
679 int f (void) { return i; }
680 void g (int j) { i = j; }
681 }]
682 }
683
684 # Return 1 if TLS executables can run correctly, 0 otherwise.
685
686 proc check_effective_target_tls_runtime {} {
687 return [check_runtime tls_runtime {
688 __thread int thr = 0;
689 int main (void) { return thr; }
690 }]
691 }
692
693 # Return 1 if -ffunction-sections is supported, 0 otherwise.
694
695 proc check_effective_target_function_sections {} {
696 # Darwin has its own scheme and silently accepts -ffunction-sections.
697 global target_triplet
698 if { [regexp ".*-.*-darwin.*" $target_triplet] } {
699 return 0
700 }
701
702 return [check_no_compiler_messages functionsections assembly {
703 void foo (void) { }
704 } "-ffunction-sections"]
705 }
706
707 # Return 1 if compilation with -fgraphite is error-free for trivial
708 # code, 0 otherwise.
709
710 proc check_effective_target_fgraphite {} {
711 return [check_no_compiler_messages fgraphite object {
712 void foo (void) { }
713 } "-O1 -fgraphite"]
714 }
715
716 # Return 1 if compilation with -fopenmp is error-free for trivial
717 # code, 0 otherwise.
718
719 proc check_effective_target_fopenmp {} {
720 return [check_no_compiler_messages fopenmp object {
721 void foo (void) { }
722 } "-fopenmp"]
723 }
724
725 # Return 1 if compilation with -pthread is error-free for trivial
726 # code, 0 otherwise.
727
728 proc check_effective_target_pthread {} {
729 return [check_no_compiler_messages pthread object {
730 void foo (void) { }
731 } "-pthread"]
732 }
733
734 # Return 1 if compilation with -mpe-aligned-commons is error-free
735 # for trivial code, 0 otherwise.
736
737 proc check_effective_target_pe_aligned_commons {} {
738 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
739 return [check_no_compiler_messages pe_aligned_commons object {
740 int foo;
741 } "-mpe-aligned-commons"]
742 }
743 return 0
744 }
745
746 # Return 1 if the target supports -static
747 proc check_effective_target_static {} {
748 return [check_no_compiler_messages static executable {
749 int main (void) { return 0; }
750 } "-static"]
751 }
752
753 # Return 1 if the target supports -fstack-protector
754 proc check_effective_target_fstack_protector {} {
755 return [check_runtime fstack_protector {
756 int main (void) { return 0; }
757 } "-fstack-protector"]
758 }
759
760 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
761 # for trivial code, 0 otherwise.
762
763 proc check_effective_target_freorder {} {
764 return [check_no_compiler_messages freorder object {
765 void foo (void) { }
766 } "-freorder-blocks-and-partition"]
767 }
768
769 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
770 # emitted, 0 otherwise. Whether a shared library can actually be built is
771 # out of scope for this test.
772
773 proc check_effective_target_fpic { } {
774 # Note that M68K has a multilib that supports -fpic but not
775 # -fPIC, so we need to check both. We test with a program that
776 # requires GOT references.
777 foreach arg {fpic fPIC} {
778 if [check_no_compiler_messages $arg object {
779 extern int foo (void); extern int bar;
780 int baz (void) { return foo () + bar; }
781 } "-$arg"] {
782 return 1
783 }
784 }
785 return 0
786 }
787
788 # Return true if the target supports -mpaired-single (as used on MIPS).
789
790 proc check_effective_target_mpaired_single { } {
791 return [check_no_compiler_messages mpaired_single object {
792 void foo (void) { }
793 } "-mpaired-single"]
794 }
795
796 # Return true if the target has access to FPU instructions.
797
798 proc check_effective_target_hard_float { } {
799 if { [istarget mips*-*-*] } {
800 return [check_no_compiler_messages hard_float assembly {
801 #if (defined __mips_soft_float || defined __mips16)
802 #error FOO
803 #endif
804 }]
805 }
806
807 # This proc is actually checking the availabilty of FPU
808 # support for doubles, so on the RX we must fail if the
809 # 64-bit double multilib has been selected.
810 if { [istarget rx-*-*] } {
811 return 0
812 # return [check_no_compiler_messages hard_float assembly {
813 #if defined __RX_64_BIT_DOUBLES__
814 #error FOO
815 #endif
816 # }]
817 }
818
819 # The generic test equates hard_float with "no call for adding doubles".
820 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
821 double a (double b, double c) { return b + c; }
822 }]
823 }
824
825 # Return true if the target is a 64-bit MIPS target.
826
827 proc check_effective_target_mips64 { } {
828 return [check_no_compiler_messages mips64 assembly {
829 #ifndef __mips64
830 #error FOO
831 #endif
832 }]
833 }
834
835 # Return true if the target is a MIPS target that does not produce
836 # MIPS16 code.
837
838 proc check_effective_target_nomips16 { } {
839 return [check_no_compiler_messages nomips16 object {
840 #ifndef __mips
841 #error FOO
842 #else
843 /* A cheap way of testing for -mflip-mips16. */
844 void foo (void) { asm ("addiu $20,$20,1"); }
845 void bar (void) { asm ("addiu $20,$20,1"); }
846 #endif
847 }]
848 }
849
850 # Add the options needed for MIPS16 function attributes. At the moment,
851 # we don't support MIPS16 PIC.
852
853 proc add_options_for_mips16_attribute { flags } {
854 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
855 }
856
857 # Return true if we can force a mode that allows MIPS16 code generation.
858 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
859 # for o32 and o64.
860
861 proc check_effective_target_mips16_attribute { } {
862 return [check_no_compiler_messages mips16_attribute assembly {
863 #ifdef PIC
864 #error FOO
865 #endif
866 #if defined __mips_hard_float \
867 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
868 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
869 #error FOO
870 #endif
871 } [add_options_for_mips16_attribute ""]]
872 }
873
874 # Return 1 if the target supports long double larger than double when
875 # using the new ABI, 0 otherwise.
876
877 proc check_effective_target_mips_newabi_large_long_double { } {
878 return [check_no_compiler_messages mips_newabi_large_long_double object {
879 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
880 } "-mabi=64"]
881 }
882
883 # Return 1 if the current multilib does not generate PIC by default.
884
885 proc check_effective_target_nonpic { } {
886 return [check_no_compiler_messages nonpic assembly {
887 #if __PIC__
888 #error FOO
889 #endif
890 }]
891 }
892
893 # Return 1 if the target does not use a status wrapper.
894
895 proc check_effective_target_unwrapped { } {
896 if { [target_info needs_status_wrapper] != "" \
897 && [target_info needs_status_wrapper] != "0" } {
898 return 0
899 }
900 return 1
901 }
902
903 # Return true if iconv is supported on the target. In particular IBM1047.
904
905 proc check_iconv_available { test_what } {
906 global libiconv
907
908 # If the tool configuration file has not set libiconv, try "-liconv"
909 if { ![info exists libiconv] } {
910 set libiconv "-liconv"
911 }
912 set test_what [lindex $test_what 1]
913 return [check_runtime_nocache $test_what [subst {
914 #include <iconv.h>
915 int main (void)
916 {
917 iconv_t cd;
918
919 cd = iconv_open ("$test_what", "UTF-8");
920 if (cd == (iconv_t) -1)
921 return 1;
922 return 0;
923 }
924 }] $libiconv]
925 }
926
927 # Return true if named sections are supported on this target.
928
929 proc check_named_sections_available { } {
930 return [check_no_compiler_messages named_sections assembly {
931 int __attribute__ ((section("whatever"))) foo;
932 }]
933 }
934
935 # Return 1 if the target supports Fortran real kinds larger than real(8),
936 # 0 otherwise.
937 #
938 # When the target name changes, replace the cached result.
939
940 proc check_effective_target_fortran_large_real { } {
941 return [check_no_compiler_messages fortran_large_real executable {
942 ! Fortran
943 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
944 real(kind=k) :: x
945 x = cos (x)
946 end
947 }]
948 }
949
950 # Return 1 if the target supports Fortran integer kinds larger than
951 # integer(8), 0 otherwise.
952 #
953 # When the target name changes, replace the cached result.
954
955 proc check_effective_target_fortran_large_int { } {
956 return [check_no_compiler_messages fortran_large_int executable {
957 ! Fortran
958 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
959 integer(kind=k) :: i
960 end
961 }]
962 }
963
964 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
965 #
966 # When the target name changes, replace the cached result.
967
968 proc check_effective_target_fortran_integer_16 { } {
969 return [check_no_compiler_messages fortran_integer_16 executable {
970 ! Fortran
971 integer(16) :: i
972 end
973 }]
974 }
975
976 # Return 1 if we can statically link libgfortran, 0 otherwise.
977 #
978 # When the target name changes, replace the cached result.
979
980 proc check_effective_target_static_libgfortran { } {
981 return [check_no_compiler_messages static_libgfortran executable {
982 ! Fortran
983 print *, 'test'
984 end
985 } "-static"]
986 }
987
988 proc check_linker_plugin_available { } {
989 return [check_no_compiler_messages_nocache linker_plugin executable {
990 int main() { return 0; }
991 } "-flto -fuse-linker-plugin"]
992 }
993
994 # Return 1 if the target supports executing 750CL paired-single instructions, 0
995 # otherwise. Cache the result.
996
997 proc check_750cl_hw_available { } {
998 return [check_cached_effective_target 750cl_hw_available {
999 # If this is not the right target then we can skip the test.
1000 if { ![istarget powerpc-*paired*] } {
1001 expr 0
1002 } else {
1003 check_runtime_nocache 750cl_hw_available {
1004 int main()
1005 {
1006 #ifdef __MACH__
1007 asm volatile ("ps_mul v0,v0,v0");
1008 #else
1009 asm volatile ("ps_mul 0,0,0");
1010 #endif
1011 return 0;
1012 }
1013 } "-mpaired"
1014 }
1015 }]
1016 }
1017
1018 # Return 1 if the target OS supports running SSE executables, 0
1019 # otherwise. Cache the result.
1020
1021 proc check_sse_os_support_available { } {
1022 return [check_cached_effective_target sse_os_support_available {
1023 # If this is not the right target then we can skip the test.
1024 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1025 expr 0
1026 } elseif { [istarget i?86-*-solaris2*] } {
1027 # The Solaris 2 kernel doesn't save and restore SSE registers
1028 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1029 check_runtime_nocache sse_os_support_available {
1030 int main ()
1031 {
1032 __asm__ volatile ("movss %xmm2,%xmm1");
1033 return 0;
1034 }
1035 } "-msse"
1036 } else {
1037 expr 1
1038 }
1039 }]
1040 }
1041
1042 # Return 1 if the target supports executing SSE instructions, 0
1043 # otherwise. Cache the result.
1044
1045 proc check_sse_hw_available { } {
1046 return [check_cached_effective_target sse_hw_available {
1047 # If this is not the right target then we can skip the test.
1048 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1049 expr 0
1050 } else {
1051 check_runtime_nocache sse_hw_available {
1052 #include "cpuid.h"
1053 int main ()
1054 {
1055 unsigned int eax, ebx, ecx, edx;
1056 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1057 return !(edx & bit_SSE);
1058 return 1;
1059 }
1060 } ""
1061 }
1062 }]
1063 }
1064
1065 # Return 1 if the target supports executing SSE2 instructions, 0
1066 # otherwise. Cache the result.
1067
1068 proc check_sse2_hw_available { } {
1069 return [check_cached_effective_target sse2_hw_available {
1070 # If this is not the right target then we can skip the test.
1071 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1072 expr 0
1073 } else {
1074 check_runtime_nocache sse2_hw_available {
1075 #include "cpuid.h"
1076 int main ()
1077 {
1078 unsigned int eax, ebx, ecx, edx;
1079 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1080 return !(edx & bit_SSE2);
1081 return 1;
1082 }
1083 } ""
1084 }
1085 }]
1086 }
1087
1088 # Return 1 if the target supports executing AVX instructions, 0
1089 # otherwise. Cache the result.
1090
1091 proc check_avx_hw_available { } {
1092 return [check_cached_effective_target avx_hw_available {
1093 # If this is not the right target then we can skip the test.
1094 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1095 expr 0
1096 } else {
1097 check_runtime_nocache avx_hw_available {
1098 #include "cpuid.h"
1099 int main ()
1100 {
1101 unsigned int eax, ebx, ecx, edx;
1102 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1103 return ((ecx & (bit_AVX | bit_OSXSAVE))
1104 != (bit_AVX | bit_OSXSAVE));
1105 return 1;
1106 }
1107 } ""
1108 }
1109 }]
1110 }
1111
1112 # Return 1 if the target supports running SSE executables, 0 otherwise.
1113
1114 proc check_effective_target_sse_runtime { } {
1115 if { [check_effective_target_sse]
1116 && [check_sse_hw_available]
1117 && [check_sse_os_support_available] } {
1118 return 1
1119 }
1120 return 0
1121 }
1122
1123 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1124
1125 proc check_effective_target_sse2_runtime { } {
1126 if { [check_effective_target_sse2]
1127 && [check_sse2_hw_available]
1128 && [check_sse_os_support_available] } {
1129 return 1
1130 }
1131 return 0
1132 }
1133
1134 # Return 1 if the target supports running AVX executables, 0 otherwise.
1135
1136 proc check_effective_target_avx_runtime { } {
1137 if { [check_effective_target_avx]
1138 && [check_avx_hw_available] } {
1139 return 1
1140 }
1141 return 0
1142 }
1143
1144 # Return 1 if the target supports executing VSX instructions, 0
1145 # otherwise. Cache the result.
1146
1147 proc check_vsx_hw_available { } {
1148 return [check_cached_effective_target vsx_hw_available {
1149 # Some simulators are known to not support VSX instructions.
1150 # For now, disable on Darwin
1151 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1152 expr 0
1153 } else {
1154 set options "-mvsx"
1155 check_runtime_nocache vsx_hw_available {
1156 int main()
1157 {
1158 #ifdef __MACH__
1159 asm volatile ("xxlor vs0,vs0,vs0");
1160 #else
1161 asm volatile ("xxlor 0,0,0");
1162 #endif
1163 return 0;
1164 }
1165 } $options
1166 }
1167 }]
1168 }
1169
1170 # Return 1 if the target supports executing AltiVec instructions, 0
1171 # otherwise. Cache the result.
1172
1173 proc check_vmx_hw_available { } {
1174 return [check_cached_effective_target vmx_hw_available {
1175 # Some simulators are known to not support VMX instructions.
1176 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1177 expr 0
1178 } else {
1179 # Most targets don't require special flags for this test case, but
1180 # Darwin does. Just to be sure, make sure VSX is not enabled for
1181 # the altivec tests.
1182 if { [istarget *-*-darwin*]
1183 || [istarget *-*-aix*] } {
1184 set options "-maltivec -mno-vsx"
1185 } else {
1186 set options "-mno-vsx"
1187 }
1188 check_runtime_nocache vmx_hw_available {
1189 int main()
1190 {
1191 #ifdef __MACH__
1192 asm volatile ("vor v0,v0,v0");
1193 #else
1194 asm volatile ("vor 0,0,0");
1195 #endif
1196 return 0;
1197 }
1198 } $options
1199 }
1200 }]
1201 }
1202
1203 proc check_ppc_recip_hw_available { } {
1204 return [check_cached_effective_target ppc_recip_hw_available {
1205 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1206 # For now, disable on Darwin
1207 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1208 expr 0
1209 } else {
1210 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1211 check_runtime_nocache ppc_recip_hw_available {
1212 volatile double d_recip, d_rsqrt, d_four = 4.0;
1213 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1214 int main()
1215 {
1216 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1217 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1218 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1219 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1220 return 0;
1221 }
1222 } $options
1223 }
1224 }]
1225 }
1226
1227 # Return 1 if the target supports executing AltiVec and Cell PPU
1228 # instructions, 0 otherwise. Cache the result.
1229
1230 proc check_effective_target_cell_hw { } {
1231 return [check_cached_effective_target cell_hw_available {
1232 # Some simulators are known to not support VMX and PPU instructions.
1233 if { [istarget powerpc-*-eabi*] } {
1234 expr 0
1235 } else {
1236 # Most targets don't require special flags for this test
1237 # case, but Darwin and AIX do.
1238 if { [istarget *-*-darwin*]
1239 || [istarget *-*-aix*] } {
1240 set options "-maltivec -mcpu=cell"
1241 } else {
1242 set options "-mcpu=cell"
1243 }
1244 check_runtime_nocache cell_hw_available {
1245 int main()
1246 {
1247 #ifdef __MACH__
1248 asm volatile ("vor v0,v0,v0");
1249 asm volatile ("lvlx v0,r0,r0");
1250 #else
1251 asm volatile ("vor 0,0,0");
1252 asm volatile ("lvlx 0,0,0");
1253 #endif
1254 return 0;
1255 }
1256 } $options
1257 }
1258 }]
1259 }
1260
1261 # Return 1 if the target supports executing 64-bit instructions, 0
1262 # otherwise. Cache the result.
1263
1264 proc check_effective_target_powerpc64 { } {
1265 global powerpc64_available_saved
1266 global tool
1267
1268 if [info exists powerpc64_available_saved] {
1269 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1270 } else {
1271 set powerpc64_available_saved 0
1272
1273 # Some simulators are known to not support powerpc64 instructions.
1274 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1275 verbose "check_effective_target_powerpc64 returning 0" 2
1276 return $powerpc64_available_saved
1277 }
1278
1279 # Set up, compile, and execute a test program containing a 64-bit
1280 # instruction. Include the current process ID in the file
1281 # names to prevent conflicts with invocations for multiple
1282 # testsuites.
1283 set src ppc[pid].c
1284 set exe ppc[pid].x
1285
1286 set f [open $src "w"]
1287 puts $f "int main() {"
1288 puts $f "#ifdef __MACH__"
1289 puts $f " asm volatile (\"extsw r0,r0\");"
1290 puts $f "#else"
1291 puts $f " asm volatile (\"extsw 0,0\");"
1292 puts $f "#endif"
1293 puts $f " return 0; }"
1294 close $f
1295
1296 set opts "additional_flags=-mcpu=G5"
1297
1298 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1299 set lines [${tool}_target_compile $src $exe executable "$opts"]
1300 file delete $src
1301
1302 if [string match "" $lines] then {
1303 # No error message, compilation succeeded.
1304 set result [${tool}_load "./$exe" "" ""]
1305 set status [lindex $result 0]
1306 remote_file build delete $exe
1307 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1308
1309 if { $status == "pass" } then {
1310 set powerpc64_available_saved 1
1311 }
1312 } else {
1313 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1314 }
1315 }
1316
1317 return $powerpc64_available_saved
1318 }
1319
1320 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1321 # complex float arguments. This affects gfortran tests that call cabsf
1322 # in libm built by an earlier compiler. Return 1 if libm uses the same
1323 # argument passing as the compiler under test, 0 otherwise.
1324 #
1325 # When the target name changes, replace the cached result.
1326
1327 proc check_effective_target_broken_cplxf_arg { } {
1328 return [check_cached_effective_target broken_cplxf_arg {
1329 # Skip the work for targets known not to be affected.
1330 if { ![istarget powerpc64-*-linux*] } {
1331 expr 0
1332 } elseif { ![is-effective-target lp64] } {
1333 expr 0
1334 } else {
1335 check_runtime_nocache broken_cplxf_arg {
1336 #include <complex.h>
1337 extern void abort (void);
1338 float fabsf (float);
1339 float cabsf (_Complex float);
1340 int main ()
1341 {
1342 _Complex float cf;
1343 float f;
1344 cf = 3 + 4.0fi;
1345 f = cabsf (cf);
1346 if (fabsf (f - 5.0) > 0.0001)
1347 abort ();
1348 return 0;
1349 }
1350 } "-lm"
1351 }
1352 }]
1353 }
1354
1355 proc check_alpha_max_hw_available { } {
1356 return [check_runtime alpha_max_hw_available {
1357 int main() { return __builtin_alpha_amask(1<<8) != 0; }
1358 }]
1359 }
1360
1361 # Returns true iff the FUNCTION is available on the target system.
1362 # (This is essentially a Tcl implementation of Autoconf's
1363 # AC_CHECK_FUNC.)
1364
1365 proc check_function_available { function } {
1366 return [check_no_compiler_messages ${function}_available \
1367 executable [subst {
1368 #ifdef __cplusplus
1369 extern "C"
1370 #endif
1371 char $function ();
1372 int main () { $function (); }
1373 }]]
1374 }
1375
1376 # Returns true iff "fork" is available on the target system.
1377
1378 proc check_fork_available {} {
1379 return [check_function_available "fork"]
1380 }
1381
1382 # Returns true iff "mkfifo" is available on the target system.
1383
1384 proc check_mkfifo_available {} {
1385 if {[istarget *-*-cygwin*]} {
1386 # Cygwin has mkfifo, but support is incomplete.
1387 return 0
1388 }
1389
1390 return [check_function_available "mkfifo"]
1391 }
1392
1393 # Returns true iff "__cxa_atexit" is used on the target system.
1394
1395 proc check_cxa_atexit_available { } {
1396 return [check_cached_effective_target cxa_atexit_available {
1397 if { [istarget "hppa*-*-hpux10*"] } {
1398 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
1399 expr 0
1400 } elseif { [istarget "*-*-vxworks"] } {
1401 # vxworks doesn't have __cxa_atexit but subsequent test passes.
1402 expr 0
1403 } else {
1404 check_runtime_nocache cxa_atexit_available {
1405 // C++
1406 #include <stdlib.h>
1407 static unsigned int count;
1408 struct X
1409 {
1410 X() { count = 1; }
1411 ~X()
1412 {
1413 if (count != 3)
1414 exit(1);
1415 count = 4;
1416 }
1417 };
1418 void f()
1419 {
1420 static X x;
1421 }
1422 struct Y
1423 {
1424 Y() { f(); count = 2; }
1425 ~Y()
1426 {
1427 if (count != 2)
1428 exit(1);
1429 count = 3;
1430 }
1431 };
1432 Y y;
1433 int main() { return 0; }
1434 }
1435 }
1436 }]
1437 }
1438
1439 proc check_effective_target_objc2 { } {
1440 return [check_no_compiler_messages objc2 object {
1441 #ifdef __OBJC2__
1442 int dummy[1];
1443 #else
1444 #error
1445 #endif
1446 }]
1447 }
1448
1449 proc check_effective_target_next_runtime { } {
1450 return [check_no_compiler_messages objc2 object {
1451 #ifdef __NEXT_RUNTIME__
1452 int dummy[1];
1453 #else
1454 #error
1455 #endif
1456 }]
1457 }
1458
1459 # Return 1 if we're generating 32-bit code using default options, 0
1460 # otherwise.
1461
1462 proc check_effective_target_ilp32 { } {
1463 return [check_no_compiler_messages ilp32 object {
1464 int dummy[sizeof (int) == 4
1465 && sizeof (void *) == 4
1466 && sizeof (long) == 4 ? 1 : -1];
1467 }]
1468 }
1469
1470 # Return 1 if we're generating 32-bit or larger integers using default
1471 # options, 0 otherwise.
1472
1473 proc check_effective_target_int32plus { } {
1474 return [check_no_compiler_messages int32plus object {
1475 int dummy[sizeof (int) >= 4 ? 1 : -1];
1476 }]
1477 }
1478
1479 # Return 1 if we're generating 32-bit or larger pointers using default
1480 # options, 0 otherwise.
1481
1482 proc check_effective_target_ptr32plus { } {
1483 return [check_no_compiler_messages ptr32plus object {
1484 int dummy[sizeof (void *) >= 4 ? 1 : -1];
1485 }]
1486 }
1487
1488 # Return 1 if we support 32-bit or larger array and structure sizes
1489 # using default options, 0 otherwise.
1490
1491 proc check_effective_target_size32plus { } {
1492 return [check_no_compiler_messages size32plus object {
1493 char dummy[65537];
1494 }]
1495 }
1496
1497 # Returns 1 if we're generating 16-bit or smaller integers with the
1498 # default options, 0 otherwise.
1499
1500 proc check_effective_target_int16 { } {
1501 return [check_no_compiler_messages int16 object {
1502 int dummy[sizeof (int) < 4 ? 1 : -1];
1503 }]
1504 }
1505
1506 # Return 1 if we're generating 64-bit code using default options, 0
1507 # otherwise.
1508
1509 proc check_effective_target_lp64 { } {
1510 return [check_no_compiler_messages lp64 object {
1511 int dummy[sizeof (int) == 4
1512 && sizeof (void *) == 8
1513 && sizeof (long) == 8 ? 1 : -1];
1514 }]
1515 }
1516
1517 # Return 1 if we're generating 64-bit code using default llp64 options,
1518 # 0 otherwise.
1519
1520 proc check_effective_target_llp64 { } {
1521 return [check_no_compiler_messages llp64 object {
1522 int dummy[sizeof (int) == 4
1523 && sizeof (void *) == 8
1524 && sizeof (long long) == 8
1525 && sizeof (long) == 4 ? 1 : -1];
1526 }]
1527 }
1528
1529 # Return 1 if the target supports long double larger than double,
1530 # 0 otherwise.
1531
1532 proc check_effective_target_large_long_double { } {
1533 return [check_no_compiler_messages large_long_double object {
1534 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1535 }]
1536 }
1537
1538 # Return 1 if the target supports double larger than float,
1539 # 0 otherwise.
1540
1541 proc check_effective_target_large_double { } {
1542 return [check_no_compiler_messages large_double object {
1543 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
1544 }]
1545 }
1546
1547 # Return 1 if the target supports double of 64 bits,
1548 # 0 otherwise.
1549
1550 proc check_effective_target_double64 { } {
1551 return [check_no_compiler_messages double64 object {
1552 int dummy[sizeof(double) == 8 ? 1 : -1];
1553 }]
1554 }
1555
1556 # Return 1 if the target supports double of at least 64 bits,
1557 # 0 otherwise.
1558
1559 proc check_effective_target_double64plus { } {
1560 return [check_no_compiler_messages double64plus object {
1561 int dummy[sizeof(double) >= 8 ? 1 : -1];
1562 }]
1563 }
1564
1565 # Return 1 if the target supports compiling fixed-point,
1566 # 0 otherwise.
1567
1568 proc check_effective_target_fixed_point { } {
1569 return [check_no_compiler_messages fixed_point object {
1570 _Sat _Fract x; _Sat _Accum y;
1571 }]
1572 }
1573
1574 # Return 1 if the target supports compiling decimal floating point,
1575 # 0 otherwise.
1576
1577 proc check_effective_target_dfp_nocache { } {
1578 verbose "check_effective_target_dfp_nocache: compiling source" 2
1579 set ret [check_no_compiler_messages_nocache dfp object {
1580 float x __attribute__((mode(DD)));
1581 }]
1582 verbose "check_effective_target_dfp_nocache: returning $ret" 2
1583 return $ret
1584 }
1585
1586 proc check_effective_target_dfprt_nocache { } {
1587 return [check_runtime_nocache dfprt {
1588 typedef float d64 __attribute__((mode(DD)));
1589 d64 x = 1.2df, y = 2.3dd, z;
1590 int main () { z = x + y; return 0; }
1591 }]
1592 }
1593
1594 # Return 1 if the target supports compiling Decimal Floating Point,
1595 # 0 otherwise.
1596 #
1597 # This won't change for different subtargets so cache the result.
1598
1599 proc check_effective_target_dfp { } {
1600 return [check_cached_effective_target dfp {
1601 check_effective_target_dfp_nocache
1602 }]
1603 }
1604
1605 # Return 1 if the target supports linking and executing Decimal Floating
1606 # Point, 0 otherwise.
1607 #
1608 # This won't change for different subtargets so cache the result.
1609
1610 proc check_effective_target_dfprt { } {
1611 return [check_cached_effective_target dfprt {
1612 check_effective_target_dfprt_nocache
1613 }]
1614 }
1615
1616 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1617
1618 proc check_effective_target_ucn_nocache { } {
1619 # -std=c99 is only valid for C
1620 if [check_effective_target_c] {
1621 set ucnopts "-std=c99"
1622 }
1623 append ucnopts " -fextended-identifiers"
1624 verbose "check_effective_target_ucn_nocache: compiling source" 2
1625 set ret [check_no_compiler_messages_nocache ucn object {
1626 int \u00C0;
1627 } $ucnopts]
1628 verbose "check_effective_target_ucn_nocache: returning $ret" 2
1629 return $ret
1630 }
1631
1632 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
1633 #
1634 # This won't change for different subtargets, so cache the result.
1635
1636 proc check_effective_target_ucn { } {
1637 return [check_cached_effective_target ucn {
1638 check_effective_target_ucn_nocache
1639 }]
1640 }
1641
1642 # Return 1 if the target needs a command line argument to enable a SIMD
1643 # instruction set.
1644
1645 proc check_effective_target_vect_cmdline_needed { } {
1646 global et_vect_cmdline_needed_saved
1647 global et_vect_cmdline_needed_target_name
1648
1649 if { ![info exists et_vect_cmdline_needed_target_name] } {
1650 set et_vect_cmdline_needed_target_name ""
1651 }
1652
1653 # If the target has changed since we set the cached value, clear it.
1654 set current_target [current_target_name]
1655 if { $current_target != $et_vect_cmdline_needed_target_name } {
1656 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
1657 set et_vect_cmdline_needed_target_name $current_target
1658 if { [info exists et_vect_cmdline_needed_saved] } {
1659 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
1660 unset et_vect_cmdline_needed_saved
1661 }
1662 }
1663
1664 if [info exists et_vect_cmdline_needed_saved] {
1665 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
1666 } else {
1667 set et_vect_cmdline_needed_saved 1
1668 if { [istarget alpha*-*-*]
1669 || [istarget ia64-*-*]
1670 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
1671 && [check_effective_target_lp64])
1672 || ([istarget powerpc*-*-*]
1673 && ([check_effective_target_powerpc_spe]
1674 || [check_effective_target_powerpc_altivec]))
1675 || [istarget spu-*-*]
1676 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
1677 set et_vect_cmdline_needed_saved 0
1678 }
1679 }
1680
1681 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
1682 return $et_vect_cmdline_needed_saved
1683 }
1684
1685 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
1686 #
1687 # This won't change for different subtargets so cache the result.
1688
1689 proc check_effective_target_vect_int { } {
1690 global et_vect_int_saved
1691
1692 if [info exists et_vect_int_saved] {
1693 verbose "check_effective_target_vect_int: using cached result" 2
1694 } else {
1695 set et_vect_int_saved 0
1696 if { [istarget i?86-*-*]
1697 || ([istarget powerpc*-*-*]
1698 && ![istarget powerpc-*-linux*paired*])
1699 || [istarget spu-*-*]
1700 || [istarget x86_64-*-*]
1701 || [istarget sparc*-*-*]
1702 || [istarget alpha*-*-*]
1703 || [istarget ia64-*-*]
1704 || [check_effective_target_arm32]
1705 || ([istarget mips*-*-*]
1706 && [check_effective_target_mips_loongson]) } {
1707 set et_vect_int_saved 1
1708 }
1709 }
1710
1711 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
1712 return $et_vect_int_saved
1713 }
1714
1715 # Return 1 if the target supports signed int->float conversion
1716 #
1717
1718 proc check_effective_target_vect_intfloat_cvt { } {
1719 global et_vect_intfloat_cvt_saved
1720
1721 if [info exists et_vect_intfloat_cvt_saved] {
1722 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
1723 } else {
1724 set et_vect_intfloat_cvt_saved 0
1725 if { [istarget i?86-*-*]
1726 || ([istarget powerpc*-*-*]
1727 && ![istarget powerpc-*-linux*paired*])
1728 || [istarget x86_64-*-*] } {
1729 set et_vect_intfloat_cvt_saved 1
1730 }
1731 }
1732
1733 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
1734 return $et_vect_intfloat_cvt_saved
1735 }
1736
1737 #Return 1 if we're supporting __int128 for target, 0 otherwise.
1738
1739 proc check_effective_target_int128 { } {
1740 return [check_no_compiler_messages int128 object {
1741 int dummy[
1742 #ifndef __SIZEOF_INT128__
1743 -1
1744 #else
1745 1
1746 #endif
1747 ];
1748 }]
1749 }
1750
1751 # Return 1 if the target supports unsigned int->float conversion
1752 #
1753
1754 proc check_effective_target_vect_uintfloat_cvt { } {
1755 global et_vect_uintfloat_cvt_saved
1756
1757 if [info exists et_vect_uintfloat_cvt_saved] {
1758 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
1759 } else {
1760 set et_vect_uintfloat_cvt_saved 0
1761 if { [istarget i?86-*-*]
1762 || ([istarget powerpc*-*-*]
1763 && ![istarget powerpc-*-linux*paired*])
1764 || [istarget x86_64-*-*] } {
1765 set et_vect_uintfloat_cvt_saved 1
1766 }
1767 }
1768
1769 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
1770 return $et_vect_uintfloat_cvt_saved
1771 }
1772
1773
1774 # Return 1 if the target supports signed float->int conversion
1775 #
1776
1777 proc check_effective_target_vect_floatint_cvt { } {
1778 global et_vect_floatint_cvt_saved
1779
1780 if [info exists et_vect_floatint_cvt_saved] {
1781 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
1782 } else {
1783 set et_vect_floatint_cvt_saved 0
1784 if { [istarget i?86-*-*]
1785 || ([istarget powerpc*-*-*]
1786 && ![istarget powerpc-*-linux*paired*])
1787 || [istarget x86_64-*-*] } {
1788 set et_vect_floatint_cvt_saved 1
1789 }
1790 }
1791
1792 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
1793 return $et_vect_floatint_cvt_saved
1794 }
1795
1796 # Return 1 if the target supports unsigned float->int conversion
1797 #
1798
1799 proc check_effective_target_vect_floatuint_cvt { } {
1800 global et_vect_floatuint_cvt_saved
1801
1802 if [info exists et_vect_floatuint_cvt_saved] {
1803 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
1804 } else {
1805 set et_vect_floatuint_cvt_saved 0
1806 if { ([istarget powerpc*-*-*]
1807 && ![istarget powerpc-*-linux*paired*]) } {
1808 set et_vect_floatuint_cvt_saved 1
1809 }
1810 }
1811
1812 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
1813 return $et_vect_floatuint_cvt_saved
1814 }
1815
1816 # Return 1 is this is an arm target using 32-bit instructions
1817 proc check_effective_target_arm32 { } {
1818 return [check_no_compiler_messages arm32 assembly {
1819 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
1820 #error FOO
1821 #endif
1822 }]
1823 }
1824
1825 # Return 1 if this is an ARM target supporting -mfpu=vfp
1826 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
1827 # options.
1828
1829 proc check_effective_target_arm_vfp_ok { } {
1830 if { [check_effective_target_arm32] } {
1831 return [check_no_compiler_messages arm_vfp_ok object {
1832 int dummy;
1833 } "-mfpu=vfp -mfloat-abi=softfp"]
1834 } else {
1835 return 0
1836 }
1837 }
1838
1839 # Return 1 if this is an ARM target supporting -mfpu=vfp
1840 # -mfloat-abi=hard. Some multilibs may be incompatible with these
1841 # options.
1842
1843 proc check_effective_target_arm_hard_vfp_ok { } {
1844 if { [check_effective_target_arm32] } {
1845 return [check_no_compiler_messages arm_hard_vfp_ok executable {
1846 int main() { return 0;}
1847 } "-mfpu=vfp -mfloat-abi=hard"]
1848 } else {
1849 return 0
1850 }
1851 }
1852
1853 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1854 # or -mfloat-abi=hard, but if one is already specified by the
1855 # multilib, use it. Similarly, if a -mfpu option already enables
1856 # NEON, do not add -mfpu=neon.
1857
1858 proc add_options_for_arm_neon { flags } {
1859 if { ! [check_effective_target_arm_neon_ok] } {
1860 return "$flags"
1861 }
1862 global et_arm_neon_flags
1863 return "$flags $et_arm_neon_flags"
1864 }
1865
1866 # Return 1 if this is an ARM target supporting -mfpu=neon
1867 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1868 # incompatible with these options. Also set et_arm_neon_flags to the
1869 # best options to add.
1870
1871 proc check_effective_target_arm_neon_ok_nocache { } {
1872 global et_arm_neon_flags
1873 set et_arm_neon_flags ""
1874 if { [check_effective_target_arm32] } {
1875 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp"} {
1876 if { [check_no_compiler_messages_nocache arm_neon_ok object {
1877 #include "arm_neon.h"
1878 int dummy;
1879 } "$flags"] } {
1880 set et_arm_neon_flags $flags
1881 return 1
1882 }
1883 }
1884 }
1885
1886 return 0
1887 }
1888
1889 proc check_effective_target_arm_neon_ok { } {
1890 return [check_cached_effective_target arm_neon_ok \
1891 check_effective_target_arm_neon_ok_nocache]
1892 }
1893
1894 # Add the options needed for NEON. We need either -mfloat-abi=softfp
1895 # or -mfloat-abi=hard, but if one is already specified by the
1896 # multilib, use it.
1897
1898 proc add_options_for_arm_neon_fp16 { flags } {
1899 if { ! [check_effective_target_arm_neon_fp16_ok] } {
1900 return "$flags"
1901 }
1902 global et_arm_neon_fp16_flags
1903 return "$flags $et_arm_neon_fp16_flags"
1904 }
1905
1906 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
1907 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
1908 # incompatible with these options. Also set et_arm_neon_flags to the
1909 # best options to add.
1910
1911 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
1912 global et_arm_neon_fp16_flags
1913 set et_arm_neon_fp16_flags ""
1914 if { [check_effective_target_arm32] } {
1915 # Always add -mfpu=neon-fp16, since there is no preprocessor
1916 # macro for FP16 support.
1917 foreach flags {"-mfpu=neon-fp16" "-mfpu=neon-fp16 -mfloat-abi=softfp"} {
1918 if { [check_no_compiler_messages_nocache arm_neon_fp16_ok object {
1919 #include "arm_neon.h"
1920 int dummy;
1921 } "$flags"] } {
1922 set et_arm_neon_fp16_flags $flags
1923 return 1
1924 }
1925 }
1926 }
1927
1928 return 0
1929 }
1930
1931 proc check_effective_target_arm_neon_fp16_ok { } {
1932 return [check_cached_effective_target arm_neon_fp16_ok \
1933 check_effective_target_arm_neon_fp16_ok_nocache]
1934 }
1935
1936 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
1937 # used.
1938
1939 proc check_effective_target_arm_thumb1_ok { } {
1940 return [check_no_compiler_messages arm_thumb1_ok assembly {
1941 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
1942 #error FOO
1943 #endif
1944 } "-mthumb"]
1945 }
1946
1947 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
1948 # used.
1949
1950 proc check_effective_target_arm_thumb2_ok { } {
1951 return [check_no_compiler_messages arm_thumb2_ok assembly {
1952 #if !defined(__thumb2__)
1953 #error FOO
1954 #endif
1955 } "-mthumb"]
1956 }
1957
1958 # Return 1 if the target supports executing NEON instructions, 0
1959 # otherwise. Cache the result.
1960
1961 proc check_effective_target_arm_neon_hw { } {
1962 return [check_runtime arm_neon_hw_available {
1963 int
1964 main (void)
1965 {
1966 long long a = 0, b = 1;
1967 asm ("vorr %P0, %P1, %P2"
1968 : "=w" (a)
1969 : "0" (a), "w" (b));
1970 return (a != 1);
1971 }
1972 } [add_options_for_arm_neon ""]]
1973 }
1974
1975 # Return 1 if this is a ARM target with NEON enabled.
1976
1977 proc check_effective_target_arm_neon { } {
1978 if { [check_effective_target_arm32] } {
1979 return [check_no_compiler_messages arm_neon object {
1980 #ifndef __ARM_NEON__
1981 #error not NEON
1982 #else
1983 int dummy;
1984 #endif
1985 }]
1986 } else {
1987 return 0
1988 }
1989 }
1990
1991 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
1992 # the Loongson vector modes.
1993
1994 proc check_effective_target_mips_loongson { } {
1995 return [check_no_compiler_messages loongson assembly {
1996 #if !defined(__mips_loongson_vector_rev)
1997 #error FOO
1998 #endif
1999 }]
2000 }
2001
2002 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
2003 # Architecture.
2004
2005 proc check_effective_target_arm_eabi { } {
2006 return [check_no_compiler_messages arm_eabi object {
2007 #ifndef __ARM_EABI__
2008 #error not EABI
2009 #else
2010 int dummy;
2011 #endif
2012 }]
2013 }
2014
2015 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
2016 # Some multilibs may be incompatible with this option.
2017
2018 proc check_effective_target_arm_iwmmxt_ok { } {
2019 if { [check_effective_target_arm32] } {
2020 return [check_no_compiler_messages arm_iwmmxt_ok object {
2021 int dummy;
2022 } "-mcpu=iwmmxt"]
2023 } else {
2024 return 0
2025 }
2026 }
2027
2028 # Return 1 if this is a PowerPC target with floating-point registers.
2029
2030 proc check_effective_target_powerpc_fprs { } {
2031 if { [istarget powerpc*-*-*]
2032 || [istarget rs6000-*-*] } {
2033 return [check_no_compiler_messages powerpc_fprs object {
2034 #ifdef __NO_FPRS__
2035 #error no FPRs
2036 #else
2037 int dummy;
2038 #endif
2039 }]
2040 } else {
2041 return 0
2042 }
2043 }
2044
2045 # Return 1 if this is a PowerPC target with hardware double-precision
2046 # floating point.
2047
2048 proc check_effective_target_powerpc_hard_double { } {
2049 if { [istarget powerpc*-*-*]
2050 || [istarget rs6000-*-*] } {
2051 return [check_no_compiler_messages powerpc_hard_double object {
2052 #ifdef _SOFT_DOUBLE
2053 #error soft double
2054 #else
2055 int dummy;
2056 #endif
2057 }]
2058 } else {
2059 return 0
2060 }
2061 }
2062
2063 # Return 1 if this is a PowerPC target supporting -maltivec.
2064
2065 proc check_effective_target_powerpc_altivec_ok { } {
2066 if { ([istarget powerpc*-*-*]
2067 && ![istarget powerpc-*-linux*paired*])
2068 || [istarget rs6000-*-*] } {
2069 # AltiVec is not supported on AIX before 5.3.
2070 if { [istarget powerpc*-*-aix4*]
2071 || [istarget powerpc*-*-aix5.1*]
2072 || [istarget powerpc*-*-aix5.2*] } {
2073 return 0
2074 }
2075 return [check_no_compiler_messages powerpc_altivec_ok object {
2076 int dummy;
2077 } "-maltivec"]
2078 } else {
2079 return 0
2080 }
2081 }
2082
2083 # Return 1 if this is a PowerPC target supporting -mvsx
2084
2085 proc check_effective_target_powerpc_vsx_ok { } {
2086 if { ([istarget powerpc*-*-*]
2087 && ![istarget powerpc-*-linux*paired*])
2088 || [istarget rs6000-*-*] } {
2089 # AltiVec is not supported on AIX before 5.3.
2090 if { [istarget powerpc*-*-aix4*]
2091 || [istarget powerpc*-*-aix5.1*]
2092 || [istarget powerpc*-*-aix5.2*] } {
2093 return 0
2094 }
2095 return [check_no_compiler_messages powerpc_vsx_ok object {
2096 int main (void) {
2097 #ifdef __MACH__
2098 asm volatile ("xxlor vs0,vs0,vs0");
2099 #else
2100 asm volatile ("xxlor 0,0,0");
2101 #endif
2102 return 0;
2103 }
2104 } "-mvsx"]
2105 } else {
2106 return 0
2107 }
2108 }
2109
2110 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
2111
2112 proc check_effective_target_powerpc_ppu_ok { } {
2113 if [check_effective_target_powerpc_altivec_ok] {
2114 return [check_no_compiler_messages cell_asm_available object {
2115 int main (void) {
2116 #ifdef __MACH__
2117 asm volatile ("lvlx v0,v0,v0");
2118 #else
2119 asm volatile ("lvlx 0,0,0");
2120 #endif
2121 return 0;
2122 }
2123 }]
2124 } else {
2125 return 0
2126 }
2127 }
2128
2129 # Return 1 if this is a PowerPC target that supports SPU.
2130
2131 proc check_effective_target_powerpc_spu { } {
2132 if [istarget powerpc*-*-linux*] {
2133 return [check_effective_target_powerpc_altivec_ok]
2134 } else {
2135 return 0
2136 }
2137 }
2138
2139 # Return 1 if this is a PowerPC SPE target. The check includes options
2140 # specified by dg-options for this test, so don't cache the result.
2141
2142 proc check_effective_target_powerpc_spe_nocache { } {
2143 if { [istarget powerpc*-*-*] } {
2144 return [check_no_compiler_messages_nocache powerpc_spe object {
2145 #ifndef __SPE__
2146 #error not SPE
2147 #else
2148 int dummy;
2149 #endif
2150 } [current_compiler_flags]]
2151 } else {
2152 return 0
2153 }
2154 }
2155
2156 # Return 1 if this is a PowerPC target with SPE enabled.
2157
2158 proc check_effective_target_powerpc_spe { } {
2159 if { [istarget powerpc*-*-*] } {
2160 return [check_no_compiler_messages powerpc_spe object {
2161 #ifndef __SPE__
2162 #error not SPE
2163 #else
2164 int dummy;
2165 #endif
2166 }]
2167 } else {
2168 return 0
2169 }
2170 }
2171
2172 # Return 1 if this is a PowerPC target with Altivec enabled.
2173
2174 proc check_effective_target_powerpc_altivec { } {
2175 if { [istarget powerpc*-*-*] } {
2176 return [check_no_compiler_messages powerpc_altivec object {
2177 #ifndef __ALTIVEC__
2178 #error not Altivec
2179 #else
2180 int dummy;
2181 #endif
2182 }]
2183 } else {
2184 return 0
2185 }
2186 }
2187
2188 # Return 1 if this is a PowerPC 405 target. The check includes options
2189 # specified by dg-options for this test, so don't cache the result.
2190
2191 proc check_effective_target_powerpc_405_nocache { } {
2192 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
2193 return [check_no_compiler_messages_nocache powerpc_405 object {
2194 #ifdef __PPC405__
2195 int dummy;
2196 #else
2197 #error not a PPC405
2198 #endif
2199 } [current_compiler_flags]]
2200 } else {
2201 return 0
2202 }
2203 }
2204
2205 # Return 1 if this is a SPU target with a toolchain that
2206 # supports automatic overlay generation.
2207
2208 proc check_effective_target_spu_auto_overlay { } {
2209 if { [istarget spu*-*-elf*] } {
2210 return [check_no_compiler_messages spu_auto_overlay executable {
2211 int main (void) { }
2212 } "-Wl,--auto-overlay" ]
2213 } else {
2214 return 0
2215 }
2216 }
2217
2218 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
2219 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
2220 # test environment appears to run executables on such a simulator.
2221
2222 proc check_effective_target_ultrasparc_hw { } {
2223 return [check_runtime ultrasparc_hw {
2224 int main() { return 0; }
2225 } "-mcpu=ultrasparc"]
2226 }
2227
2228 # Return 1 if the target supports hardware vector shift operation.
2229
2230 proc check_effective_target_vect_shift { } {
2231 global et_vect_shift_saved
2232
2233 if [info exists et_vect_shift_saved] {
2234 verbose "check_effective_target_vect_shift: using cached result" 2
2235 } else {
2236 set et_vect_shift_saved 0
2237 if { ([istarget powerpc*-*-*]
2238 && ![istarget powerpc-*-linux*paired*])
2239 || [istarget ia64-*-*]
2240 || [istarget i?86-*-*]
2241 || [istarget x86_64-*-*]
2242 || [check_effective_target_arm32]
2243 || ([istarget mips*-*-*]
2244 && [check_effective_target_mips_loongson]) } {
2245 set et_vect_shift_saved 1
2246 }
2247 }
2248
2249 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
2250 return $et_vect_shift_saved
2251 }
2252
2253 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
2254 #
2255 # This can change for different subtargets so do not cache the result.
2256
2257 proc check_effective_target_vect_long { } {
2258 if { [istarget i?86-*-*]
2259 || (([istarget powerpc*-*-*]
2260 && ![istarget powerpc-*-linux*paired*])
2261 && [check_effective_target_ilp32])
2262 || [istarget x86_64-*-*]
2263 || [check_effective_target_arm32]
2264 || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
2265 set answer 1
2266 } else {
2267 set answer 0
2268 }
2269
2270 verbose "check_effective_target_vect_long: returning $answer" 2
2271 return $answer
2272 }
2273
2274 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
2275 #
2276 # This won't change for different subtargets so cache the result.
2277
2278 proc check_effective_target_vect_float { } {
2279 global et_vect_float_saved
2280
2281 if [info exists et_vect_float_saved] {
2282 verbose "check_effective_target_vect_float: using cached result" 2
2283 } else {
2284 set et_vect_float_saved 0
2285 if { [istarget i?86-*-*]
2286 || [istarget powerpc*-*-*]
2287 || [istarget spu-*-*]
2288 || [istarget mipsisa64*-*-*]
2289 || [istarget x86_64-*-*]
2290 || [istarget ia64-*-*]
2291 || [check_effective_target_arm32] } {
2292 set et_vect_float_saved 1
2293 }
2294 }
2295
2296 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
2297 return $et_vect_float_saved
2298 }
2299
2300 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
2301 #
2302 # This won't change for different subtargets so cache the result.
2303
2304 proc check_effective_target_vect_double { } {
2305 global et_vect_double_saved
2306
2307 if [info exists et_vect_double_saved] {
2308 verbose "check_effective_target_vect_double: using cached result" 2
2309 } else {
2310 set et_vect_double_saved 0
2311 if { [istarget i?86-*-*]
2312 || [istarget x86_64-*-*] } {
2313 if { [check_no_compiler_messages vect_double assembly {
2314 #ifdef __tune_atom__
2315 # error No double vectorizer support.
2316 #endif
2317 }] } {
2318 set et_vect_double_saved 1
2319 } else {
2320 set et_vect_double_saved 0
2321 }
2322 } elseif { [istarget spu-*-*] } {
2323 set et_vect_double_saved 1
2324 }
2325 }
2326
2327 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
2328 return $et_vect_double_saved
2329 }
2330
2331 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
2332 #
2333 # This won't change for different subtargets so cache the result.
2334
2335 proc check_effective_target_vect_long_long { } {
2336 global et_vect_long_long_saved
2337
2338 if [info exists et_vect_long_long_saved] {
2339 verbose "check_effective_target_vect_long_long: using cached result" 2
2340 } else {
2341 set et_vect_long_long_saved 0
2342 if { [istarget i?86-*-*]
2343 || [istarget x86_64-*-*] } {
2344 set et_vect_long_long_saved 1
2345 }
2346 }
2347
2348 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
2349 return $et_vect_long_long_saved
2350 }
2351
2352
2353 # Return 1 if the target plus current options does not support a vector
2354 # max instruction on "int", 0 otherwise.
2355 #
2356 # This won't change for different subtargets so cache the result.
2357
2358 proc check_effective_target_vect_no_int_max { } {
2359 global et_vect_no_int_max_saved
2360
2361 if [info exists et_vect_no_int_max_saved] {
2362 verbose "check_effective_target_vect_no_int_max: using cached result" 2
2363 } else {
2364 set et_vect_no_int_max_saved 0
2365 if { [istarget sparc*-*-*]
2366 || [istarget spu-*-*]
2367 || [istarget alpha*-*-*]
2368 || ([istarget mips*-*-*]
2369 && [check_effective_target_mips_loongson]) } {
2370 set et_vect_no_int_max_saved 1
2371 }
2372 }
2373 verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2
2374 return $et_vect_no_int_max_saved
2375 }
2376
2377 # Return 1 if the target plus current options does not support a vector
2378 # add instruction on "int", 0 otherwise.
2379 #
2380 # This won't change for different subtargets so cache the result.
2381
2382 proc check_effective_target_vect_no_int_add { } {
2383 global et_vect_no_int_add_saved
2384
2385 if [info exists et_vect_no_int_add_saved] {
2386 verbose "check_effective_target_vect_no_int_add: using cached result" 2
2387 } else {
2388 set et_vect_no_int_add_saved 0
2389 # Alpha only supports vector add on V8QI and V4HI.
2390 if { [istarget alpha*-*-*] } {
2391 set et_vect_no_int_add_saved 1
2392 }
2393 }
2394 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
2395 return $et_vect_no_int_add_saved
2396 }
2397
2398 # Return 1 if the target plus current options does not support vector
2399 # bitwise instructions, 0 otherwise.
2400 #
2401 # This won't change for different subtargets so cache the result.
2402
2403 proc check_effective_target_vect_no_bitwise { } {
2404 global et_vect_no_bitwise_saved
2405
2406 if [info exists et_vect_no_bitwise_saved] {
2407 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
2408 } else {
2409 set et_vect_no_bitwise_saved 0
2410 }
2411 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
2412 return $et_vect_no_bitwise_saved
2413 }
2414
2415 # Return 1 if the target plus current options supports vector permutation,
2416 # 0 otherwise.
2417 #
2418 # This won't change for different subtargets so cache the result.
2419
2420 proc check_effective_target_vect_perm { } {
2421 global et_vect_perm
2422
2423 if [info exists et_vect_perm_saved] {
2424 verbose "check_effective_target_vect_perm: using cached result" 2
2425 } else {
2426 set et_vect_perm_saved 0
2427 if { [istarget powerpc*-*-*]
2428 || [istarget spu-*-*] } {
2429 set et_vect_perm_saved 1
2430 }
2431 }
2432 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
2433 return $et_vect_perm_saved
2434 }
2435
2436 # Return 1 if the target plus current options supports a vector
2437 # widening summation of *short* args into *int* result, 0 otherwise.
2438 #
2439 # This won't change for different subtargets so cache the result.
2440
2441 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
2442 global et_vect_widen_sum_hi_to_si_pattern
2443
2444 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
2445 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
2446 } else {
2447 set et_vect_widen_sum_hi_to_si_pattern_saved 0
2448 if { [istarget powerpc*-*-*] } {
2449 set et_vect_widen_sum_hi_to_si_pattern_saved 1
2450 }
2451 }
2452 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
2453 return $et_vect_widen_sum_hi_to_si_pattern_saved
2454 }
2455
2456 # Return 1 if the target plus current options supports a vector
2457 # widening summation of *short* args into *int* result, 0 otherwise.
2458 # A target can also support this widening summation if it can support
2459 # promotion (unpacking) from shorts to ints.
2460 #
2461 # This won't change for different subtargets so cache the result.
2462
2463 proc check_effective_target_vect_widen_sum_hi_to_si { } {
2464 global et_vect_widen_sum_hi_to_si
2465
2466 if [info exists et_vect_widen_sum_hi_to_si_saved] {
2467 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
2468 } else {
2469 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
2470 if { [istarget powerpc*-*-*]
2471 || [istarget ia64-*-*] } {
2472 set et_vect_widen_sum_hi_to_si_saved 1
2473 }
2474 }
2475 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
2476 return $et_vect_widen_sum_hi_to_si_saved
2477 }
2478
2479 # Return 1 if the target plus current options supports a vector
2480 # widening summation of *char* args into *short* result, 0 otherwise.
2481 # A target can also support this widening summation if it can support
2482 # promotion (unpacking) from chars to shorts.
2483 #
2484 # This won't change for different subtargets so cache the result.
2485
2486 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
2487 global et_vect_widen_sum_qi_to_hi
2488
2489 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
2490 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
2491 } else {
2492 set et_vect_widen_sum_qi_to_hi_saved 0
2493 if { [check_effective_target_vect_unpack]
2494 || [istarget ia64-*-*] } {
2495 set et_vect_widen_sum_qi_to_hi_saved 1
2496 }
2497 }
2498 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
2499 return $et_vect_widen_sum_qi_to_hi_saved
2500 }
2501
2502 # Return 1 if the target plus current options supports a vector
2503 # widening summation of *char* args into *int* result, 0 otherwise.
2504 #
2505 # This won't change for different subtargets so cache the result.
2506
2507 proc check_effective_target_vect_widen_sum_qi_to_si { } {
2508 global et_vect_widen_sum_qi_to_si
2509
2510 if [info exists et_vect_widen_sum_qi_to_si_saved] {
2511 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
2512 } else {
2513 set et_vect_widen_sum_qi_to_si_saved 0
2514 if { [istarget powerpc*-*-*] } {
2515 set et_vect_widen_sum_qi_to_si_saved 1
2516 }
2517 }
2518 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
2519 return $et_vect_widen_sum_qi_to_si_saved
2520 }
2521
2522 # Return 1 if the target plus current options supports a vector
2523 # widening multiplication of *char* args into *short* result, 0 otherwise.
2524 # A target can also support this widening multplication if it can support
2525 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
2526 # multiplication of shorts).
2527 #
2528 # This won't change for different subtargets so cache the result.
2529
2530
2531 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
2532 global et_vect_widen_mult_qi_to_hi
2533
2534 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
2535 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
2536 } else {
2537 if { [check_effective_target_vect_unpack]
2538 && [check_effective_target_vect_short_mult] } {
2539 set et_vect_widen_mult_qi_to_hi_saved 1
2540 } else {
2541 set et_vect_widen_mult_qi_to_hi_saved 0
2542 }
2543 if { [istarget powerpc*-*-*] } {
2544 set et_vect_widen_mult_qi_to_hi_saved 1
2545 }
2546 }
2547 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
2548 return $et_vect_widen_mult_qi_to_hi_saved
2549 }
2550
2551 # Return 1 if the target plus current options supports a vector
2552 # widening multiplication of *short* args into *int* result, 0 otherwise.
2553 # A target can also support this widening multplication if it can support
2554 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
2555 # multiplication of ints).
2556 #
2557 # This won't change for different subtargets so cache the result.
2558
2559
2560 proc check_effective_target_vect_widen_mult_hi_to_si { } {
2561 global et_vect_widen_mult_hi_to_si
2562
2563 if [info exists et_vect_widen_mult_hi_to_si_saved] {
2564 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
2565 } else {
2566 if { [check_effective_target_vect_unpack]
2567 && [check_effective_target_vect_int_mult] } {
2568 set et_vect_widen_mult_hi_to_si_saved 1
2569 } else {
2570 set et_vect_widen_mult_hi_to_si_saved 0
2571 }
2572 if { [istarget powerpc*-*-*]
2573 || [istarget spu-*-*]
2574 || [istarget i?86-*-*]
2575 || [istarget x86_64-*-*] } {
2576 set et_vect_widen_mult_hi_to_si_saved 1
2577 }
2578 }
2579 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
2580 return $et_vect_widen_mult_hi_to_si_saved
2581 }
2582
2583 # Return 1 if the target plus current options supports a vector
2584 # dot-product of signed chars, 0 otherwise.
2585 #
2586 # This won't change for different subtargets so cache the result.
2587
2588 proc check_effective_target_vect_sdot_qi { } {
2589 global et_vect_sdot_qi
2590
2591 if [info exists et_vect_sdot_qi_saved] {
2592 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
2593 } else {
2594 set et_vect_sdot_qi_saved 0
2595 }
2596 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
2597 return $et_vect_sdot_qi_saved
2598 }
2599
2600 # Return 1 if the target plus current options supports a vector
2601 # dot-product of unsigned chars, 0 otherwise.
2602 #
2603 # This won't change for different subtargets so cache the result.
2604
2605 proc check_effective_target_vect_udot_qi { } {
2606 global et_vect_udot_qi
2607
2608 if [info exists et_vect_udot_qi_saved] {
2609 verbose "check_effective_target_vect_udot_qi: using cached result" 2
2610 } else {
2611 set et_vect_udot_qi_saved 0
2612 if { [istarget powerpc*-*-*] } {
2613 set et_vect_udot_qi_saved 1
2614 }
2615 }
2616 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
2617 return $et_vect_udot_qi_saved
2618 }
2619
2620 # Return 1 if the target plus current options supports a vector
2621 # dot-product of signed shorts, 0 otherwise.
2622 #
2623 # This won't change for different subtargets so cache the result.
2624
2625 proc check_effective_target_vect_sdot_hi { } {
2626 global et_vect_sdot_hi
2627
2628 if [info exists et_vect_sdot_hi_saved] {
2629 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
2630 } else {
2631 set et_vect_sdot_hi_saved 0
2632 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2633 || [istarget i?86-*-*]
2634 || [istarget x86_64-*-*] } {
2635 set et_vect_sdot_hi_saved 1
2636 }
2637 }
2638 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
2639 return $et_vect_sdot_hi_saved
2640 }
2641
2642 # Return 1 if the target plus current options supports a vector
2643 # dot-product of unsigned shorts, 0 otherwise.
2644 #
2645 # This won't change for different subtargets so cache the result.
2646
2647 proc check_effective_target_vect_udot_hi { } {
2648 global et_vect_udot_hi
2649
2650 if [info exists et_vect_udot_hi_saved] {
2651 verbose "check_effective_target_vect_udot_hi: using cached result" 2
2652 } else {
2653 set et_vect_udot_hi_saved 0
2654 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
2655 set et_vect_udot_hi_saved 1
2656 }
2657 }
2658 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
2659 return $et_vect_udot_hi_saved
2660 }
2661
2662
2663 # Return 1 if the target plus current options supports a vector
2664 # demotion (packing) of shorts (to chars) and ints (to shorts)
2665 # using modulo arithmetic, 0 otherwise.
2666 #
2667 # This won't change for different subtargets so cache the result.
2668
2669 proc check_effective_target_vect_pack_trunc { } {
2670 global et_vect_pack_trunc
2671
2672 if [info exists et_vect_pack_trunc_saved] {
2673 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
2674 } else {
2675 set et_vect_pack_trunc_saved 0
2676 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2677 || [istarget i?86-*-*]
2678 || [istarget x86_64-*-*]
2679 || [istarget spu-*-*] } {
2680 set et_vect_pack_trunc_saved 1
2681 }
2682 }
2683 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
2684 return $et_vect_pack_trunc_saved
2685 }
2686
2687 # Return 1 if the target plus current options supports a vector
2688 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
2689 #
2690 # This won't change for different subtargets so cache the result.
2691
2692 proc check_effective_target_vect_unpack { } {
2693 global et_vect_unpack
2694
2695 if [info exists et_vect_unpack_saved] {
2696 verbose "check_effective_target_vect_unpack: using cached result" 2
2697 } else {
2698 set et_vect_unpack_saved 0
2699 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
2700 || [istarget i?86-*-*]
2701 || [istarget x86_64-*-*]
2702 || [istarget spu-*-*]
2703 || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } {
2704 set et_vect_unpack_saved 1
2705 }
2706 }
2707 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
2708 return $et_vect_unpack_saved
2709 }
2710
2711 # Return 1 if the target plus current options does not guarantee
2712 # that its STACK_BOUNDARY is >= the reguired vector alignment.
2713 #
2714 # This won't change for different subtargets so cache the result.
2715
2716 proc check_effective_target_unaligned_stack { } {
2717 global et_unaligned_stack_saved
2718
2719 if [info exists et_unaligned_stack_saved] {
2720 verbose "check_effective_target_unaligned_stack: using cached result" 2
2721 } else {
2722 set et_unaligned_stack_saved 0
2723 }
2724 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
2725 return $et_unaligned_stack_saved
2726 }
2727
2728 # Return 1 if the target plus current options does not support a vector
2729 # alignment mechanism, 0 otherwise.
2730 #
2731 # This won't change for different subtargets so cache the result.
2732
2733 proc check_effective_target_vect_no_align { } {
2734 global et_vect_no_align_saved
2735
2736 if [info exists et_vect_no_align_saved] {
2737 verbose "check_effective_target_vect_no_align: using cached result" 2
2738 } else {
2739 set et_vect_no_align_saved 0
2740 if { [istarget mipsisa64*-*-*]
2741 || [istarget sparc*-*-*]
2742 || [istarget ia64-*-*]
2743 || [check_effective_target_arm32]
2744 || ([istarget mips*-*-*]
2745 && [check_effective_target_mips_loongson]) } {
2746 set et_vect_no_align_saved 1
2747 }
2748 }
2749 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
2750 return $et_vect_no_align_saved
2751 }
2752
2753 # Return 1 if the target supports a vector misalign access, 0 otherwise.
2754 #
2755 # This won't change for different subtargets so cache the result.
2756
2757 proc check_effective_target_vect_hw_misalign { } {
2758 global et_vect_hw_misalign_saved
2759
2760 if [info exists et_vect_hw_misalign_saved] {
2761 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
2762 } else {
2763 set et_vect_hw_misalign_saved 0
2764 if { ([istarget x86_64-*-*]
2765 || [istarget i?86-*-*]) } {
2766 set et_vect_hw_misalign_saved 1
2767 }
2768 }
2769 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
2770 return $et_vect_hw_misalign_saved
2771 }
2772
2773
2774 # Return 1 if arrays are aligned to the vector alignment
2775 # boundary, 0 otherwise.
2776 #
2777 # This won't change for different subtargets so cache the result.
2778
2779 proc check_effective_target_vect_aligned_arrays { } {
2780 global et_vect_aligned_arrays
2781
2782 if [info exists et_vect_aligned_arrays_saved] {
2783 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
2784 } else {
2785 set et_vect_aligned_arrays_saved 0
2786 if { (([istarget x86_64-*-*]
2787 || [istarget i?86-*-*]) && [is-effective-target lp64])
2788 || [istarget spu-*-*] } {
2789 set et_vect_aligned_arrays_saved 1
2790 }
2791 }
2792 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
2793 return $et_vect_aligned_arrays_saved
2794 }
2795
2796 # Return 1 if types of size 32 bit or less are naturally aligned
2797 # (aligned to their type-size), 0 otherwise.
2798 #
2799 # This won't change for different subtargets so cache the result.
2800
2801 proc check_effective_target_natural_alignment_32 { } {
2802 global et_natural_alignment_32
2803
2804 if [info exists et_natural_alignment_32_saved] {
2805 verbose "check_effective_target_natural_alignment_32: using cached result" 2
2806 } else {
2807 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
2808 set et_natural_alignment_32_saved 1
2809 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
2810 set et_natural_alignment_32_saved 0
2811 }
2812 }
2813 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
2814 return $et_natural_alignment_32_saved
2815 }
2816
2817 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
2818 # type-size), 0 otherwise.
2819 #
2820 # This won't change for different subtargets so cache the result.
2821
2822 proc check_effective_target_natural_alignment_64 { } {
2823 global et_natural_alignment_64
2824
2825 if [info exists et_natural_alignment_64_saved] {
2826 verbose "check_effective_target_natural_alignment_64: using cached result" 2
2827 } else {
2828 set et_natural_alignment_64_saved 0
2829 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
2830 || [istarget spu-*-*] } {
2831 set et_natural_alignment_64_saved 1
2832 }
2833 }
2834 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
2835 return $et_natural_alignment_64_saved
2836 }
2837
2838 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
2839 #
2840 # This won't change for different subtargets so cache the result.
2841
2842 proc check_effective_target_vector_alignment_reachable { } {
2843 global et_vector_alignment_reachable
2844
2845 if [info exists et_vector_alignment_reachable_saved] {
2846 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
2847 } else {
2848 if { [check_effective_target_vect_aligned_arrays]
2849 || [check_effective_target_natural_alignment_32] } {
2850 set et_vector_alignment_reachable_saved 1
2851 } else {
2852 set et_vector_alignment_reachable_saved 0
2853 }
2854 }
2855 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
2856 return $et_vector_alignment_reachable_saved
2857 }
2858
2859 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
2860 #
2861 # This won't change for different subtargets so cache the result.
2862
2863 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
2864 global et_vector_alignment_reachable_for_64bit
2865
2866 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
2867 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
2868 } else {
2869 if { [check_effective_target_vect_aligned_arrays]
2870 || [check_effective_target_natural_alignment_64] } {
2871 set et_vector_alignment_reachable_for_64bit_saved 1
2872 } else {
2873 set et_vector_alignment_reachable_for_64bit_saved 0
2874 }
2875 }
2876 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
2877 return $et_vector_alignment_reachable_for_64bit_saved
2878 }
2879
2880 # Return 1 if the target supports vector conditional operations, 0 otherwise.
2881
2882 proc check_effective_target_vect_condition { } {
2883 global et_vect_cond_saved
2884
2885 if [info exists et_vect_cond_saved] {
2886 verbose "check_effective_target_vect_cond: using cached result" 2
2887 } else {
2888 set et_vect_cond_saved 0
2889 if { [istarget powerpc*-*-*]
2890 || [istarget ia64-*-*]
2891 || [istarget i?86-*-*]
2892 || [istarget spu-*-*]
2893 || [istarget x86_64-*-*] } {
2894 set et_vect_cond_saved 1
2895 }
2896 }
2897
2898 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
2899 return $et_vect_cond_saved
2900 }
2901
2902 # Return 1 if the target supports vector char multiplication, 0 otherwise.
2903
2904 proc check_effective_target_vect_char_mult { } {
2905 global et_vect_char_mult_saved
2906
2907 if [info exists et_vect_char_mult_saved] {
2908 verbose "check_effective_target_vect_char_mult: using cached result" 2
2909 } else {
2910 set et_vect_char_mult_saved 0
2911 if { [istarget ia64-*-*]
2912 || [istarget i?86-*-*]
2913 || [istarget x86_64-*-*] } {
2914 set et_vect_char_mult_saved 1
2915 }
2916 }
2917
2918 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
2919 return $et_vect_char_mult_saved
2920 }
2921
2922 # Return 1 if the target supports vector short multiplication, 0 otherwise.
2923
2924 proc check_effective_target_vect_short_mult { } {
2925 global et_vect_short_mult_saved
2926
2927 if [info exists et_vect_short_mult_saved] {
2928 verbose "check_effective_target_vect_short_mult: using cached result" 2
2929 } else {
2930 set et_vect_short_mult_saved 0
2931 if { [istarget ia64-*-*]
2932 || [istarget spu-*-*]
2933 || [istarget i?86-*-*]
2934 || [istarget x86_64-*-*]
2935 || [istarget powerpc*-*-*]
2936 || [check_effective_target_arm32]
2937 || ([istarget mips*-*-*]
2938 && [check_effective_target_mips_loongson]) } {
2939 set et_vect_short_mult_saved 1
2940 }
2941 }
2942
2943 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
2944 return $et_vect_short_mult_saved
2945 }
2946
2947 # Return 1 if the target supports vector int multiplication, 0 otherwise.
2948
2949 proc check_effective_target_vect_int_mult { } {
2950 global et_vect_int_mult_saved
2951
2952 if [info exists et_vect_int_mult_saved] {
2953 verbose "check_effective_target_vect_int_mult: using cached result" 2
2954 } else {
2955 set et_vect_int_mult_saved 0
2956 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
2957 || [istarget spu-*-*]
2958 || [istarget i?86-*-*]
2959 || [istarget x86_64-*-*]
2960 || [check_effective_target_arm32] } {
2961 set et_vect_int_mult_saved 1
2962 }
2963 }
2964
2965 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
2966 return $et_vect_int_mult_saved
2967 }
2968
2969 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
2970
2971 proc check_effective_target_vect_extract_even_odd { } {
2972 global et_vect_extract_even_odd_saved
2973
2974 if [info exists et_vect_extract_even_odd_saved] {
2975 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
2976 } else {
2977 set et_vect_extract_even_odd_saved 0
2978 if { [istarget powerpc*-*-*]
2979 || [istarget i?86-*-*]
2980 || [istarget x86_64-*-*]
2981 || [istarget spu-*-*] } {
2982 set et_vect_extract_even_odd_saved 1
2983 }
2984 }
2985
2986 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
2987 return $et_vect_extract_even_odd_saved
2988 }
2989
2990 # Return 1 if the target supports vector even/odd elements extraction of
2991 # vectors with SImode elements or larger, 0 otherwise.
2992
2993 proc check_effective_target_vect_extract_even_odd_wide { } {
2994 global et_vect_extract_even_odd_wide_saved
2995
2996 if [info exists et_vect_extract_even_odd_wide_saved] {
2997 verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2
2998 } else {
2999 set et_vect_extract_even_odd_wide_saved 0
3000 if { [istarget powerpc*-*-*]
3001 || [istarget i?86-*-*]
3002 || [istarget x86_64-*-*]
3003 || [istarget spu-*-*] } {
3004 set et_vect_extract_even_odd_wide_saved 1
3005 }
3006 }
3007
3008 verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2
3009 return $et_vect_extract_even_odd_wide_saved
3010 }
3011
3012 # Return 1 if the target supports vector interleaving, 0 otherwise.
3013
3014 proc check_effective_target_vect_interleave { } {
3015 global et_vect_interleave_saved
3016
3017 if [info exists et_vect_interleave_saved] {
3018 verbose "check_effective_target_vect_interleave: using cached result" 2
3019 } else {
3020 set et_vect_interleave_saved 0
3021 if { [istarget powerpc*-*-*]
3022 || [istarget i?86-*-*]
3023 || [istarget x86_64-*-*]
3024 || [istarget spu-*-*] } {
3025 set et_vect_interleave_saved 1
3026 }
3027 }
3028
3029 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
3030 return $et_vect_interleave_saved
3031 }
3032
3033 # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise.
3034 proc check_effective_target_vect_strided { } {
3035 global et_vect_strided_saved
3036
3037 if [info exists et_vect_strided_saved] {
3038 verbose "check_effective_target_vect_strided: using cached result" 2
3039 } else {
3040 set et_vect_strided_saved 0
3041 if { [check_effective_target_vect_interleave]
3042 && [check_effective_target_vect_extract_even_odd] } {
3043 set et_vect_strided_saved 1
3044 }
3045 }
3046
3047 verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2
3048 return $et_vect_strided_saved
3049 }
3050
3051 # Return 1 if the target supports vector interleaving and extract even/odd
3052 # for wide element types, 0 otherwise.
3053 proc check_effective_target_vect_strided_wide { } {
3054 global et_vect_strided_wide_saved
3055
3056 if [info exists et_vect_strided_wide_saved] {
3057 verbose "check_effective_target_vect_strided_wide: using cached result" 2
3058 } else {
3059 set et_vect_strided_wide_saved 0
3060 if { [check_effective_target_vect_interleave]
3061 && [check_effective_target_vect_extract_even_odd_wide] } {
3062 set et_vect_strided_wide_saved 1
3063 }
3064 }
3065
3066 verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2
3067 return $et_vect_strided_wide_saved
3068 }
3069
3070 # Return 1 if the target supports section-anchors
3071
3072 proc check_effective_target_section_anchors { } {
3073 global et_section_anchors_saved
3074
3075 if [info exists et_section_anchors_saved] {
3076 verbose "check_effective_target_section_anchors: using cached result" 2
3077 } else {
3078 set et_section_anchors_saved 0
3079 if { [istarget powerpc*-*-*]
3080 || [istarget arm*-*-*] } {
3081 set et_section_anchors_saved 1
3082 }
3083 }
3084
3085 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
3086 return $et_section_anchors_saved
3087 }
3088
3089 # Return 1 if the target supports atomic operations on "int" and "long".
3090
3091 proc check_effective_target_sync_int_long { } {
3092 global et_sync_int_long_saved
3093
3094 if [info exists et_sync_int_long_saved] {
3095 verbose "check_effective_target_sync_int_long: using cached result" 2
3096 } else {
3097 set et_sync_int_long_saved 0
3098 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3099 # load-reserved/store-conditional instructions.
3100 if { [istarget ia64-*-*]
3101 || [istarget i?86-*-*]
3102 || [istarget x86_64-*-*]
3103 || [istarget alpha*-*-*]
3104 || [istarget arm*-*-linux-gnueabi]
3105 || [istarget bfin*-*linux*]
3106 || [istarget hppa*-*linux*]
3107 || [istarget s390*-*-*]
3108 || [istarget powerpc*-*-*]
3109 || [istarget sparc64-*-*]
3110 || [istarget sparcv9-*-*]
3111 || [istarget mips*-*-*] } {
3112 set et_sync_int_long_saved 1
3113 }
3114 }
3115
3116 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
3117 return $et_sync_int_long_saved
3118 }
3119
3120 # Return 1 if the target supports atomic operations on "char" and "short".
3121
3122 proc check_effective_target_sync_char_short { } {
3123 global et_sync_char_short_saved
3124
3125 if [info exists et_sync_char_short_saved] {
3126 verbose "check_effective_target_sync_char_short: using cached result" 2
3127 } else {
3128 set et_sync_char_short_saved 0
3129 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
3130 # load-reserved/store-conditional instructions.
3131 if { [istarget ia64-*-*]
3132 || [istarget i?86-*-*]
3133 || [istarget x86_64-*-*]
3134 || [istarget alpha*-*-*]
3135 || [istarget arm*-*-linux-gnueabi]
3136 || [istarget hppa*-*linux*]
3137 || [istarget s390*-*-*]
3138 || [istarget powerpc*-*-*]
3139 || [istarget sparc64-*-*]
3140 || [istarget sparcv9-*-*]
3141 || [istarget mips*-*-*] } {
3142 set et_sync_char_short_saved 1
3143 }
3144 }
3145
3146 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
3147 return $et_sync_char_short_saved
3148 }
3149
3150 # Return 1 if the target uses a ColdFire FPU.
3151
3152 proc check_effective_target_coldfire_fpu { } {
3153 return [check_no_compiler_messages coldfire_fpu assembly {
3154 #ifndef __mcffpu__
3155 #error FOO
3156 #endif
3157 }]
3158 }
3159
3160 # Return true if this is a uClibc target.
3161
3162 proc check_effective_target_uclibc {} {
3163 return [check_no_compiler_messages uclibc object {
3164 #include <features.h>
3165 #if !defined (__UCLIBC__)
3166 #error FOO
3167 #endif
3168 }]
3169 }
3170
3171 # Return true if this is a uclibc target and if the uclibc feature
3172 # described by __$feature__ is not present.
3173
3174 proc check_missing_uclibc_feature {feature} {
3175 return [check_no_compiler_messages $feature object "
3176 #include <features.h>
3177 #if !defined (__UCLIBC) || defined (__${feature}__)
3178 #error FOO
3179 #endif
3180 "]
3181 }
3182
3183 # Return true if this is a Newlib target.
3184
3185 proc check_effective_target_newlib {} {
3186 return [check_no_compiler_messages newlib object {
3187 #include <newlib.h>
3188 }]
3189 }
3190
3191 # Return 1 if
3192 # (a) an error of a few ULP is expected in string to floating-point
3193 # conversion functions; and
3194 # (b) overflow is not always detected correctly by those functions.
3195
3196 proc check_effective_target_lax_strtofp {} {
3197 # By default, assume that all uClibc targets suffer from this.
3198 return [check_effective_target_uclibc]
3199 }
3200
3201 # Return 1 if this is a target for which wcsftime is a dummy
3202 # function that always returns 0.
3203
3204 proc check_effective_target_dummy_wcsftime {} {
3205 # By default, assume that all uClibc targets suffer from this.
3206 return [check_effective_target_uclibc]
3207 }
3208
3209 # Return 1 if constructors with initialization priority arguments are
3210 # supposed on this target.
3211
3212 proc check_effective_target_init_priority {} {
3213 return [check_no_compiler_messages init_priority assembly "
3214 void f() __attribute__((constructor (1000)));
3215 void f() \{\}
3216 "]
3217 }
3218
3219 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
3220 # This can be used with any check_* proc that takes no argument and
3221 # returns only 1 or 0. It could be used with check_* procs that take
3222 # arguments with keywords that pass particular arguments.
3223
3224 proc is-effective-target { arg } {
3225 set selected 0
3226 if { [info procs check_effective_target_${arg}] != [list] } {
3227 set selected [check_effective_target_${arg}]
3228 } else {
3229 switch $arg {
3230 "vmx_hw" { set selected [check_vmx_hw_available] }
3231 "vsx_hw" { set selected [check_vsx_hw_available] }
3232 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
3233 "named_sections" { set selected [check_named_sections_available] }
3234 "gc_sections" { set selected [check_gc_sections_available] }
3235 "cxa_atexit" { set selected [check_cxa_atexit_available] }
3236 default { error "unknown effective target keyword `$arg'" }
3237 }
3238 }
3239 verbose "is-effective-target: $arg $selected" 2
3240 return $selected
3241 }
3242
3243 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
3244
3245 proc is-effective-target-keyword { arg } {
3246 if { [info procs check_effective_target_${arg}] != [list] } {
3247 return 1
3248 } else {
3249 # These have different names for their check_* procs.
3250 switch $arg {
3251 "vmx_hw" { return 1 }
3252 "vsx_hw" { return 1 }
3253 "ppc_recip_hw" { return 1 }
3254 "named_sections" { return 1 }
3255 "gc_sections" { return 1 }
3256 "cxa_atexit" { return 1 }
3257 default { return 0 }
3258 }
3259 }
3260 }
3261
3262 # Return 1 if target default to short enums
3263
3264 proc check_effective_target_short_enums { } {
3265 return [check_no_compiler_messages short_enums assembly {
3266 enum foo { bar };
3267 int s[sizeof (enum foo) == 1 ? 1 : -1];
3268 }]
3269 }
3270
3271 # Return 1 if target supports merging string constants at link time.
3272
3273 proc check_effective_target_string_merging { } {
3274 return [check_no_messages_and_pattern string_merging \
3275 "rodata\\.str" assembly {
3276 const char *var = "String";
3277 } {-O2}]
3278 }
3279
3280 # Return 1 if target has the basic signed and unsigned types in
3281 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
3282 # working <stdint.h> for all targets.
3283
3284 proc check_effective_target_stdint_types { } {
3285 return [check_no_compiler_messages stdint_types assembly {
3286 #include <stdint.h>
3287 int8_t a; int16_t b; int32_t c; int64_t d;
3288 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3289 }]
3290 }
3291
3292 # Return 1 if target has the basic signed and unsigned types in
3293 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
3294 # these types agree with those in the header, as some systems have
3295 # only <inttypes.h>.
3296
3297 proc check_effective_target_inttypes_types { } {
3298 return [check_no_compiler_messages inttypes_types assembly {
3299 #include <inttypes.h>
3300 int8_t a; int16_t b; int32_t c; int64_t d;
3301 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
3302 }]
3303 }
3304
3305 # Return 1 if programs are intended to be run on a simulator
3306 # (i.e. slowly) rather than hardware (i.e. fast).
3307
3308 proc check_effective_target_simulator { } {
3309
3310 # All "src/sim" simulators set this one.
3311 if [board_info target exists is_simulator] {
3312 return [board_info target is_simulator]
3313 }
3314
3315 # The "sid" simulators don't set that one, but at least they set
3316 # this one.
3317 if [board_info target exists slow_simulator] {
3318 return [board_info target slow_simulator]
3319 }
3320
3321 return 0
3322 }
3323
3324 # Return 1 if the target is a VxWorks kernel.
3325
3326 proc check_effective_target_vxworks_kernel { } {
3327 return [check_no_compiler_messages vxworks_kernel assembly {
3328 #if !defined __vxworks || defined __RTP__
3329 #error NO
3330 #endif
3331 }]
3332 }
3333
3334 # Return 1 if the target is a VxWorks RTP.
3335
3336 proc check_effective_target_vxworks_rtp { } {
3337 return [check_no_compiler_messages vxworks_rtp assembly {
3338 #if !defined __vxworks || !defined __RTP__
3339 #error NO
3340 #endif
3341 }]
3342 }
3343
3344 # Return 1 if the target is expected to provide wide character support.
3345
3346 proc check_effective_target_wchar { } {
3347 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
3348 return 0
3349 }
3350 return [check_no_compiler_messages wchar assembly {
3351 #include <wchar.h>
3352 }]
3353 }
3354
3355 # Return 1 if the target has <pthread.h>.
3356
3357 proc check_effective_target_pthread_h { } {
3358 return [check_no_compiler_messages pthread_h assembly {
3359 #include <pthread.h>
3360 }]
3361 }
3362
3363 # Return 1 if the target can truncate a file from a file-descriptor,
3364 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
3365 # chsize. We test for a trivially functional truncation; no stubs.
3366 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
3367 # different function to be used.
3368
3369 proc check_effective_target_fd_truncate { } {
3370 set prog {
3371 #define _FILE_OFFSET_BITS 64
3372 #include <unistd.h>
3373 #include <stdio.h>
3374 #include <stdlib.h>
3375 int main ()
3376 {
3377 FILE *f = fopen ("tst.tmp", "wb");
3378 int fd;
3379 const char t[] = "test writing more than ten characters";
3380 char s[11];
3381 fd = fileno (f);
3382 write (fd, t, sizeof (t) - 1);
3383 lseek (fd, 0, 0);
3384 if (ftruncate (fd, 10) != 0)
3385 exit (1);
3386 close (fd);
3387 f = fopen ("tst.tmp", "rb");
3388 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
3389 exit (1);
3390 exit (0);
3391 }
3392 }
3393
3394 if { [check_runtime ftruncate $prog] } {
3395 return 1;
3396 }
3397
3398 regsub "ftruncate" $prog "chsize" prog
3399 return [check_runtime chsize $prog]
3400 }
3401
3402 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
3403
3404 proc add_options_for_c99_runtime { flags } {
3405 if { [istarget *-*-solaris2*] } {
3406 return "$flags -std=c99"
3407 }
3408 if { [istarget powerpc-*-darwin*] } {
3409 return "$flags -mmacosx-version-min=10.3"
3410 }
3411 return $flags
3412 }
3413
3414 # Add to FLAGS all the target-specific flags needed to enable
3415 # full IEEE compliance mode.
3416
3417 proc add_options_for_ieee { flags } {
3418 if { [istarget "alpha*-*-*"]
3419 || [istarget "sh*-*-*"] } {
3420 return "$flags -mieee"
3421 }
3422 return $flags
3423 }
3424
3425 # Add to FLAGS the flags needed to enable functions to bind locally
3426 # when using pic/PIC passes in the testsuite.
3427
3428 proc add_options_for_bind_pic_locally { flags } {
3429 if {[check_no_compiler_messages using_pic2 assembly {
3430 #if __PIC__ != 2
3431 #error FOO
3432 #endif
3433 }]} {
3434 return "$flags -fPIE"
3435 }
3436 if {[check_no_compiler_messages using_pic1 assembly {
3437 #if __PIC__ != 1
3438 #error FOO
3439 #endif
3440 }]} {
3441 return "$flags -fpie"
3442 }
3443
3444 return $flags
3445 }
3446
3447 # Return 1 if the target provides a full C99 runtime.
3448
3449 proc check_effective_target_c99_runtime { } {
3450 return [check_cached_effective_target c99_runtime {
3451 global srcdir
3452
3453 set file [open "$srcdir/gcc.dg/builtins-config.h"]
3454 set contents [read $file]
3455 close $file
3456 append contents {
3457 #ifndef HAVE_C99_RUNTIME
3458 #error FOO
3459 #endif
3460 }
3461 check_no_compiler_messages_nocache c99_runtime assembly \
3462 $contents [add_options_for_c99_runtime ""]
3463 }]
3464 }
3465
3466 # Return 1 if target wchar_t is at least 4 bytes.
3467
3468 proc check_effective_target_4byte_wchar_t { } {
3469 return [check_no_compiler_messages 4byte_wchar_t object {
3470 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
3471 }]
3472 }
3473
3474 # Return 1 if the target supports automatic stack alignment.
3475
3476 proc check_effective_target_automatic_stack_alignment { } {
3477 if { [istarget i?86*-*-*]
3478 || [istarget x86_64-*-*] } then {
3479 return 1
3480 } else {
3481 return 0
3482 }
3483 }
3484
3485 # Return 1 if avx instructions can be compiled.
3486
3487 proc check_effective_target_avx { } {
3488 return [check_no_compiler_messages avx object {
3489 void _mm256_zeroall (void)
3490 {
3491 __builtin_ia32_vzeroall ();
3492 }
3493 } "-O2 -mavx" ]
3494 }
3495
3496 # Return 1 if sse instructions can be compiled.
3497 proc check_effective_target_sse { } {
3498 return [check_no_compiler_messages sse object {
3499 int main ()
3500 {
3501 __builtin_ia32_stmxcsr ();
3502 return 0;
3503 }
3504 } "-O2 -msse" ]
3505 }
3506
3507 # Return 1 if sse2 instructions can be compiled.
3508 proc check_effective_target_sse2 { } {
3509 return [check_no_compiler_messages sse2 object {
3510 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
3511
3512 __m128i _mm_srli_si128 (__m128i __A, int __N)
3513 {
3514 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
3515 }
3516 } "-O2 -msse2" ]
3517 }
3518
3519 # Return 1 if F16C instructions can be compiled.
3520
3521 proc check_effective_target_f16c { } {
3522 return [check_no_compiler_messages f16c object {
3523 #include "immintrin.h"
3524 float
3525 foo (unsigned short val)
3526 {
3527 return _cvtsh_ss (val);
3528 }
3529 } "-O2 -mf16c" ]
3530 }
3531
3532 # Return 1 if C wchar_t type is compatible with char16_t.
3533
3534 proc check_effective_target_wchar_t_char16_t_compatible { } {
3535 return [check_no_compiler_messages wchar_t_char16_t object {
3536 __WCHAR_TYPE__ wc;
3537 __CHAR16_TYPE__ *p16 = &wc;
3538 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3539 }]
3540 }
3541
3542 # Return 1 if C wchar_t type is compatible with char32_t.
3543
3544 proc check_effective_target_wchar_t_char32_t_compatible { } {
3545 return [check_no_compiler_messages wchar_t_char32_t object {
3546 __WCHAR_TYPE__ wc;
3547 __CHAR32_TYPE__ *p32 = &wc;
3548 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
3549 }]
3550 }
3551
3552 # Return 1 if pow10 function exists.
3553
3554 proc check_effective_target_pow10 { } {
3555 return [check_runtime pow10 {
3556 #include <math.h>
3557 int main () {
3558 double x;
3559 x = pow10 (1);
3560 return 0;
3561 }
3562 } "-lm" ]
3563 }
3564
3565 # Return 1 if current options generate DFP instructions, 0 otherwise.
3566
3567 proc check_effective_target_hard_dfp {} {
3568 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
3569 typedef float d64 __attribute__((mode(DD)));
3570 d64 x, y, z;
3571 void foo (void) { z = x + y; }
3572 }]
3573 }
3574
3575 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
3576 # for strchr etc. functions.
3577
3578 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
3579 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
3580 #include <string.h>
3581 #include <wchar.h>
3582 #if !defined(__cplusplus) \
3583 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
3584 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
3585 ISO C++ correct string.h and wchar.h protos not supported.
3586 #else
3587 int i;
3588 #endif
3589 }]
3590 }
3591
3592 # Return 1 if GNU as is used.
3593
3594 proc check_effective_target_gas { } {
3595 global use_gas_saved
3596 global tool
3597
3598 if {![info exists use_gas_saved]} {
3599 # Check if the as used by gcc is GNU as.
3600 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
3601 # Provide /dev/null as input, otherwise gas times out reading from
3602 # stdin.
3603 set status [remote_exec host "$gcc_as" "-v /dev/null"]
3604 set as_output [lindex $status 1]
3605 if { [ string first "GNU" $as_output ] >= 0 } {
3606 set use_gas_saved 1
3607 } else {
3608 set use_gas_saved 0
3609 }
3610 }
3611 return $use_gas_saved
3612 }
3613
3614 # Return 1 if the compiler has been configure with link-time optimization
3615 # (LTO) support.
3616
3617 proc check_effective_target_lto { } {
3618 global ENABLE_LTO
3619 return [info exists ENABLE_LTO]
3620 }
3621
3622 # Return 1 if the language for the compiler under test is C.
3623
3624 proc check_effective_target_c { } {
3625 global tool
3626 if [string match $tool "gcc"] {
3627 return 1
3628 }
3629 return 0
3630 }
3631
3632 # Return 1 if the language for the compiler under test is C++.
3633
3634 proc check_effective_target_c++ { } {
3635 global tool
3636 if [string match $tool "g++"] {
3637 return 1
3638 }
3639 return 0
3640 }
3641
3642 # Return 1 if expensive testcases should be run.
3643
3644 proc check_effective_target_run_expensive_tests { } {
3645 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
3646 return 1
3647 }
3648 return 0
3649 }