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