]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/lib/target-supports.exp
2016-06-08 Alan Hayward <alan.hayward@arm.com>
[thirdparty/gcc.git] / gcc / testsuite / lib / target-supports.exp
1 # Copyright (C) 1999-2016 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # gcc-patches@gcc.gnu.org
19
20 # This file defines procs for determining features supported by the target.
21
22 # Try to compile the code given by CONTENTS into an output file of
23 # type TYPE, where TYPE is as for target_compile. Return a list
24 # whose first element contains the compiler messages and whose
25 # second element is the name of the output file.
26 #
27 # BASENAME is a prefix to use for source and output files.
28 # If ARGS is not empty, its first element is a string that
29 # should be added to the command line.
30 #
31 # Assume by default that CONTENTS is C code.
32 # Otherwise, code should contain:
33 # "// C++" for c++,
34 # "! Fortran" for Fortran code,
35 # "/* ObjC", for ObjC
36 # "// ObjC++" for ObjC++
37 # and "// Go" for Go
38 # If the tool is ObjC/ObjC++ then we overide the extension to .m/.mm to
39 # allow for ObjC/ObjC++ specific flags.
40 proc check_compile {basename type contents args} {
41 global tool
42 verbose "check_compile tool: $tool for $basename"
43
44 # Save additional_sources to avoid compiling testsuite's sources
45 # against check_compile's source.
46 global additional_sources
47 if [info exists additional_sources] {
48 set tmp_additional_sources "$additional_sources"
49 set additional_sources ""
50 }
51
52 if { [llength $args] > 0 } {
53 set options [list "additional_flags=[lindex $args 0]"]
54 } else {
55 set options ""
56 }
57 switch -glob -- $contents {
58 "*! Fortran*" { set src ${basename}[pid].f90 }
59 "*// C++*" { set src ${basename}[pid].cc }
60 "*// ObjC++*" { set src ${basename}[pid].mm }
61 "*/* ObjC*" { set src ${basename}[pid].m }
62 "*// Go*" { set src ${basename}[pid].go }
63 default {
64 switch -- $tool {
65 "objc" { set src ${basename}[pid].m }
66 "obj-c++" { set src ${basename}[pid].mm }
67 default { set src ${basename}[pid].c }
68 }
69 }
70 }
71
72 set compile_type $type
73 switch -glob $type {
74 assembly { set output ${basename}[pid].s }
75 object { set output ${basename}[pid].o }
76 executable { set output ${basename}[pid].exe }
77 "rtl-*" {
78 set output ${basename}[pid].s
79 lappend options "additional_flags=-fdump-$type"
80 set compile_type assembly
81 }
82 }
83 set f [open $src "w"]
84 puts $f $contents
85 close $f
86 set lines [${tool}_target_compile $src $output $compile_type "$options"]
87 file delete $src
88
89 set scan_output $output
90 # Don't try folding this into the switch above; calling "glob" before the
91 # file is created won't work.
92 if [regexp "rtl-(.*)" $type dummy rtl_type] {
93 set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]"
94 file delete $output
95 }
96
97 # Restore additional_sources.
98 if [info exists additional_sources] {
99 set additional_sources "$tmp_additional_sources"
100 }
101
102 return [list $lines $scan_output]
103 }
104
105 proc current_target_name { } {
106 global target_info
107 if [info exists target_info(target,name)] {
108 set answer $target_info(target,name)
109 } else {
110 set answer ""
111 }
112 return $answer
113 }
114
115 # Implement an effective-target check for property PROP by invoking
116 # the Tcl command ARGS and seeing if it returns true.
117
118 proc check_cached_effective_target { prop args } {
119 global et_cache
120 global et_prop_list
121
122 set target [current_target_name]
123 if {![info exists et_cache($prop,target)]
124 || $et_cache($prop,target) != $target} {
125 verbose "check_cached_effective_target $prop: checking $target" 2
126 set et_cache($prop,target) $target
127 set et_cache($prop,value) [uplevel eval $args]
128 if {![info exists et_prop_list]
129 || [lsearch $et_prop_list $prop] < 0} {
130 lappend et_prop_list $prop
131 }
132 verbose "check_cached_effective_target cached list is now: $et_prop_list" 2
133 }
134 set value $et_cache($prop,value)
135 verbose "check_cached_effective_target $prop: returning $value for $target" 2
136 return $value
137 }
138
139 # Clear effective-target cache. This is useful after testing
140 # effective-target features and overriding TEST_ALWAYS_FLAGS and/or
141 # ALWAYS_CXXFLAGS.
142 # If one changes ALWAYS_CXXFLAGS or TEST_ALWAYS_FLAGS then they should
143 # do a clear_effective_target_cache at the end as the target cache can
144 # make decisions based upon the flags, and those decisions need to be
145 # redone when the flags change. An example of this is the
146 # asan_init/asan_finish pair.
147
148 proc clear_effective_target_cache { } {
149 global et_cache
150 global et_prop_list
151
152 if {[info exists et_prop_list]} {
153 verbose "clear_effective_target_cache: $et_prop_list" 2
154 foreach prop $et_prop_list {
155 unset et_cache($prop,value)
156 unset et_cache($prop,target)
157 }
158 unset et_prop_list
159 }
160 }
161
162 # Like check_compile, but delete the output file and return true if the
163 # compiler printed no messages.
164 proc check_no_compiler_messages_nocache {args} {
165 set result [eval check_compile $args]
166 set lines [lindex $result 0]
167 set output [lindex $result 1]
168 remote_file build delete $output
169 return [string match "" $lines]
170 }
171
172 # Like check_no_compiler_messages_nocache, but cache the result.
173 # PROP is the property we're checking, and doubles as a prefix for
174 # temporary filenames.
175 proc check_no_compiler_messages {prop args} {
176 return [check_cached_effective_target $prop {
177 eval [list check_no_compiler_messages_nocache $prop] $args
178 }]
179 }
180
181 # Like check_compile, but return true if the compiler printed no
182 # messages and if the contents of the output file satisfy PATTERN.
183 # If PATTERN has the form "!REGEXP", the contents satisfy it if they
184 # don't match regular expression REGEXP, otherwise they satisfy it
185 # if they do match regular expression PATTERN. (PATTERN can start
186 # with something like "[!]" if the regular expression needs to match
187 # "!" as the first character.)
188 #
189 # Delete the output file before returning. The other arguments are
190 # as for check_compile.
191 proc check_no_messages_and_pattern_nocache {basename pattern args} {
192 global tool
193
194 set result [eval [list check_compile $basename] $args]
195 set lines [lindex $result 0]
196 set output [lindex $result 1]
197
198 set ok 0
199 if { [string match "" $lines] } {
200 set chan [open "$output"]
201 set invert [regexp {^!(.*)} $pattern dummy pattern]
202 set ok [expr { [regexp $pattern [read $chan]] != $invert }]
203 close $chan
204 }
205
206 remote_file build delete $output
207 return $ok
208 }
209
210 # Like check_no_messages_and_pattern_nocache, but cache the result.
211 # PROP is the property we're checking, and doubles as a prefix for
212 # temporary filenames.
213 proc check_no_messages_and_pattern {prop pattern args} {
214 return [check_cached_effective_target $prop {
215 eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args
216 }]
217 }
218
219 # Try to compile and run an executable from code CONTENTS. Return true
220 # if the compiler reports no messages and if execution "passes" in the
221 # usual DejaGNU sense. The arguments are as for check_compile, with
222 # TYPE implicitly being "executable".
223 proc check_runtime_nocache {basename contents args} {
224 global tool
225
226 set result [eval [list check_compile $basename executable $contents] $args]
227 set lines [lindex $result 0]
228 set output [lindex $result 1]
229
230 set ok 0
231 if { [string match "" $lines] } {
232 # No error messages, everything is OK.
233 set result [remote_load target "./$output" "" ""]
234 set status [lindex $result 0]
235 verbose "check_runtime_nocache $basename: status is <$status>" 2
236 if { $status == "pass" } {
237 set ok 1
238 }
239 }
240 remote_file build delete $output
241 return $ok
242 }
243
244 # Like check_runtime_nocache, but cache the result. PROP is the
245 # property we're checking, and doubles as a prefix for temporary
246 # filenames.
247 proc check_runtime {prop args} {
248 global tool
249
250 return [check_cached_effective_target $prop {
251 eval [list check_runtime_nocache $prop] $args
252 }]
253 }
254
255 ###############################
256 # proc check_weak_available { }
257 ###############################
258
259 # weak symbols are only supported in some configs/object formats
260 # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure
261
262 proc check_weak_available { } {
263 global target_cpu
264
265 # All mips targets should support it
266
267 if { [ string first "mips" $target_cpu ] >= 0 } {
268 return 1
269 }
270
271 # All AIX targets should support it
272
273 if { [istarget *-*-aix*] } {
274 return 1
275 }
276
277 # All solaris2 targets should support it
278
279 if { [istarget *-*-solaris2*] } {
280 return 1
281 }
282
283 # Windows targets Cygwin and MingW32 support it
284
285 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
286 return 1
287 }
288
289 # HP-UX 10.X doesn't support it
290
291 if { [istarget hppa*-*-hpux10*] } {
292 return 0
293 }
294
295 # nvptx (nearly) supports it
296
297 if { [istarget nvptx-*-*] } {
298 return 1
299 }
300
301 # ELF and ECOFF support it. a.out does with gas/gld but may also with
302 # other linkers, so we should try it
303
304 set objformat [gcc_target_object_format]
305
306 switch $objformat {
307 elf { return 1 }
308 ecoff { return 1 }
309 a.out { return 1 }
310 mach-o { return 1 }
311 som { return 1 }
312 unknown { return -1 }
313 default { return 0 }
314 }
315 }
316
317 ###############################
318 # proc check_weak_override_available { }
319 ###############################
320
321 # Like check_weak_available, but return 0 if weak symbol definitions
322 # cannot be overridden.
323
324 proc check_weak_override_available { } {
325 if { [istarget *-*-mingw*] } {
326 return 0
327 }
328 return [check_weak_available]
329 }
330
331 ###############################
332 # proc check_visibility_available { what_kind }
333 ###############################
334
335 # The visibility attribute is only support in some object formats
336 # This proc returns 1 if it is supported, 0 if not.
337 # The argument is the kind of visibility, default/protected/hidden/internal.
338
339 proc check_visibility_available { what_kind } {
340 if [string match "" $what_kind] { set what_kind "hidden" }
341
342 return [check_no_compiler_messages visibility_available_$what_kind object "
343 void f() __attribute__((visibility(\"$what_kind\")));
344 void f() {}
345 "]
346 }
347
348 ###############################
349 # proc check_alias_available { }
350 ###############################
351
352 # Determine if the target toolchain supports the alias attribute.
353
354 # Returns 2 if the target supports aliases. Returns 1 if the target
355 # only supports weak aliased. Returns 0 if the target does not
356 # support aliases at all. Returns -1 if support for aliases could not
357 # be determined.
358
359 proc check_alias_available { } {
360 global alias_available_saved
361 global tool
362
363 if [info exists alias_available_saved] {
364 verbose "check_alias_available returning saved $alias_available_saved" 2
365 } else {
366 set src alias[pid].c
367 set obj alias[pid].o
368 verbose "check_alias_available compiling testfile $src" 2
369 set f [open $src "w"]
370 # Compile a small test program. The definition of "g" is
371 # necessary to keep the Solaris assembler from complaining
372 # about the program.
373 puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
374 puts $f "void g() {} void f() __attribute__((alias(\"g\")));"
375 close $f
376 set lines [${tool}_target_compile $src $obj object ""]
377 file delete $src
378 remote_file build delete $obj
379
380 if [string match "" $lines] then {
381 # No error messages, everything is OK.
382 set alias_available_saved 2
383 } else {
384 if [regexp "alias definitions not supported" $lines] {
385 verbose "check_alias_available target does not support aliases" 2
386
387 set objformat [gcc_target_object_format]
388
389 if { $objformat == "elf" } {
390 verbose "check_alias_available but target uses ELF format, so it ought to" 2
391 set alias_available_saved -1
392 } else {
393 set alias_available_saved 0
394 }
395 } else {
396 if [regexp "only weak aliases are supported" $lines] {
397 verbose "check_alias_available target supports only weak aliases" 2
398 set alias_available_saved 1
399 } else {
400 set alias_available_saved -1
401 }
402 }
403 }
404
405 verbose "check_alias_available returning $alias_available_saved" 2
406 }
407
408 return $alias_available_saved
409 }
410
411 # Returns 1 if the target toolchain supports strong aliases, 0 otherwise.
412
413 proc check_effective_target_alias { } {
414 if { [check_alias_available] < 2 } {
415 return 0
416 } else {
417 return 1
418 }
419 }
420
421 # Returns 1 if the target toolchain supports ifunc, 0 otherwise.
422
423 proc check_ifunc_available { } {
424 return [check_no_compiler_messages ifunc_available object {
425 #ifdef __cplusplus
426 extern "C"
427 #endif
428 void g() {}
429 void f() __attribute__((ifunc("g")));
430 }]
431 }
432
433 # Returns true if --gc-sections is supported on the target.
434
435 proc check_gc_sections_available { } {
436 global gc_sections_available_saved
437 global tool
438
439 if {![info exists gc_sections_available_saved]} {
440 # Some targets don't support gc-sections despite whatever's
441 # advertised by ld's options.
442 if { [istarget alpha*-*-*]
443 || [istarget ia64-*-*] } {
444 set gc_sections_available_saved 0
445 return 0
446 }
447
448 # elf2flt uses -q (--emit-relocs), which is incompatible with
449 # --gc-sections.
450 if { [board_info target exists ldflags]
451 && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } {
452 set gc_sections_available_saved 0
453 return 0
454 }
455
456 # VxWorks kernel modules are relocatable objects linked with -r,
457 # while RTP executables are linked with -q (--emit-relocs).
458 # Both of these options are incompatible with --gc-sections.
459 if { [istarget *-*-vxworks*] } {
460 set gc_sections_available_saved 0
461 return 0
462 }
463
464 # Check if the ld used by gcc supports --gc-sections.
465 set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""]
466 regsub ".*\n\\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker
467 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0]
468 set ld_output [remote_exec host "$gcc_ld" "--help"]
469 if { [ string first "--gc-sections" $ld_output ] >= 0 } {
470 set gc_sections_available_saved 1
471 } else {
472 set gc_sections_available_saved 0
473 }
474 }
475 return $gc_sections_available_saved
476 }
477
478 # Return 1 if according to target_info struct and explicit target list
479 # target is supposed to support trampolines.
480
481 proc check_effective_target_trampolines { } {
482 if [target_info exists no_trampolines] {
483 return 0
484 }
485 if { [istarget avr-*-*]
486 || [istarget msp430-*-*]
487 || [istarget nvptx-*-*]
488 || [istarget hppa2.0w-hp-hpux11.23]
489 || [istarget hppa64-hp-hpux11.23] } {
490 return 0;
491 }
492 return 1
493 }
494
495 # Return 1 if according to target_info struct and explicit target list
496 # target disables -fdelete-null-pointer-checks. Targets should return 0
497 # if they simply default to -fno-delete-null-pointer-checks but obey
498 # -fdelete-null-pointer-checks when passed explicitly (and tests that
499 # depend on this option should do that).
500
501 proc check_effective_target_keeps_null_pointer_checks { } {
502 if [target_info exists keeps_null_pointer_checks] {
503 return 1
504 }
505 if { [istarget avr-*-*] } {
506 return 1;
507 }
508 return 0
509 }
510
511 # Return true if profiling is supported on the target.
512
513 proc check_profiling_available { test_what } {
514 global profiling_available_saved
515
516 verbose "Profiling argument is <$test_what>" 1
517
518 # These conditions depend on the argument so examine them before
519 # looking at the cache variable.
520
521 # Tree profiling requires TLS runtime support.
522 if { $test_what == "-fprofile-generate" } {
523 if { ![check_effective_target_tls_runtime] } {
524 return 0
525 }
526 }
527
528 # Support for -p on solaris2 relies on mcrt1.o which comes with the
529 # vendor compiler. We cannot reliably predict the directory where the
530 # vendor compiler (and thus mcrt1.o) is installed so we can't
531 # necessarily find mcrt1.o even if we have it.
532 if { [istarget *-*-solaris2*] && $test_what == "-p" } {
533 return 0
534 }
535
536 # We don't yet support profiling for MIPS16.
537 if { [istarget mips*-*-*]
538 && ![check_effective_target_nomips16]
539 && ($test_what == "-p" || $test_what == "-pg") } {
540 return 0
541 }
542
543 # MinGW does not support -p.
544 if { [istarget *-*-mingw*] && $test_what == "-p" } {
545 return 0
546 }
547
548 # cygwin does not support -p.
549 if { [istarget *-*-cygwin*] && $test_what == "-p" } {
550 return 0
551 }
552
553 # uClibc does not have gcrt1.o.
554 if { [check_effective_target_uclibc]
555 && ($test_what == "-p" || $test_what == "-pg") } {
556 return 0
557 }
558
559 # Now examine the cache variable.
560 if {![info exists profiling_available_saved]} {
561 # Some targets don't have any implementation of __bb_init_func or are
562 # missing other needed machinery.
563 if {[istarget aarch64*-*-elf]
564 || [istarget am3*-*-linux*]
565 || [istarget arm*-*-eabi*]
566 || [istarget arm*-*-elf]
567 || [istarget arm*-*-symbianelf*]
568 || [istarget avr-*-*]
569 || [istarget bfin-*-*]
570 || [istarget cris-*-*]
571 || [istarget crisv32-*-*]
572 || [istarget fido-*-elf]
573 || [istarget h8300-*-*]
574 || [istarget lm32-*-*]
575 || [istarget m32c-*-elf]
576 || [istarget m68k-*-elf]
577 || [istarget m68k-*-uclinux*]
578 || [istarget mep-*-elf]
579 || [istarget mips*-*-elf*]
580 || [istarget mmix-*-*]
581 || [istarget mn10300-*-elf*]
582 || [istarget moxie-*-elf*]
583 || [istarget msp430-*-*]
584 || [istarget nds32*-*-elf]
585 || [istarget nios2-*-elf]
586 || [istarget nvptx-*-*]
587 || [istarget powerpc-*-eabi*]
588 || [istarget powerpc-*-elf]
589 || [istarget rx-*-*]
590 || [istarget tic6x-*-elf]
591 || [istarget visium-*-*]
592 || [istarget xstormy16-*]
593 || [istarget xtensa*-*-elf]
594 || [istarget *-*-rtems*]
595 || [istarget *-*-vxworks*] } {
596 set profiling_available_saved 0
597 } else {
598 set profiling_available_saved 1
599 }
600 }
601
602 # -pg link test result can't be cached since it may change between
603 # runs.
604 set profiling_working $profiling_available_saved
605 if { $profiling_available_saved == 1
606 && ![check_no_compiler_messages_nocache profiling executable {
607 int main() { return 0; } } "-pg"] } {
608 set profiling_working 0
609 }
610
611 return $profiling_working
612 }
613
614 # Check to see if a target is "freestanding". This is as per the definition
615 # in Section 4 of C99 standard. Effectively, it is a target which supports no
616 # extra headers or libraries other than what is considered essential.
617 proc check_effective_target_freestanding { } {
618 if { [istarget nvptx-*-*] } {
619 return 1
620 }
621 return 0
622 }
623
624 # Return 1 if target has packed layout of structure members by
625 # default, 0 otherwise. Note that this is slightly different than
626 # whether the target has "natural alignment": both attributes may be
627 # false.
628
629 proc check_effective_target_default_packed { } {
630 return [check_no_compiler_messages default_packed assembly {
631 struct x { char a; long b; } c;
632 int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1];
633 }]
634 }
635
636 # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See
637 # documentation, where the test also comes from.
638
639 proc check_effective_target_pcc_bitfield_type_matters { } {
640 # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty
641 # bitfields, but let's stick to the example code from the docs.
642 return [check_no_compiler_messages pcc_bitfield_type_matters assembly {
643 struct foo1 { char x; char :0; char y; };
644 struct foo2 { char x; int :0; char y; };
645 int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1];
646 }]
647 }
648
649 # Add to FLAGS all the target-specific flags needed to use thread-local storage.
650
651 proc add_options_for_tls { flags } {
652 # On Solaris 9, __tls_get_addr/___tls_get_addr only lives in
653 # libthread, so always pass -pthread for native TLS. Same for AIX.
654 # Need to duplicate native TLS check from
655 # check_effective_target_tls_native to avoid recursion.
656 if { ([istarget powerpc-ibm-aix*]) &&
657 [check_no_messages_and_pattern tls_native "!emutls" assembly {
658 __thread int i;
659 int f (void) { return i; }
660 void g (int j) { i = j; }
661 }] } {
662 return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
663 }
664 return $flags
665 }
666
667 # Return 1 if indirect jumps are supported, 0 otherwise.
668
669 proc check_effective_target_indirect_jumps {} {
670 if { [istarget nvptx-*-*] } {
671 return 0
672 }
673 return 1
674 }
675
676 # Return 1 if nonlocal goto is supported, 0 otherwise.
677
678 proc check_effective_target_nonlocal_goto {} {
679 if { [istarget nvptx-*-*] } {
680 return 0
681 }
682 return 1
683 }
684
685 # Return 1 if global constructors are supported, 0 otherwise.
686
687 proc check_effective_target_global_constructor {} {
688 if { [istarget nvptx-*-*] } {
689 return 0
690 }
691 return 1
692 }
693
694 # Return 1 if taking label values is supported, 0 otherwise.
695
696 proc check_effective_target_label_values {} {
697 if { [istarget nvptx-*-*] } {
698 return 0
699 }
700 return [check_no_compiler_messages label_values assembly {
701 #ifdef NO_LABEL_VALUES
702 #error NO
703 #endif
704 }]
705 }
706
707 # Return 1 if builtin_return_address and builtin_frame_address are
708 # supported, 0 otherwise.
709
710 proc check_effective_target_return_address {} {
711 if { [istarget nvptx-*-*] } {
712 return 0
713 }
714 return 1
715 }
716
717 # Return 1 if the assembler does not verify function types against
718 # calls, 0 otherwise. Such verification will typically show up problems
719 # with K&R C function declarations.
720
721 proc check_effective_target_untyped_assembly {} {
722 if { [istarget nvptx-*-*] } {
723 return 0
724 }
725 return 1
726 }
727
728 # Return 1 if alloca is supported, 0 otherwise.
729
730 proc check_effective_target_alloca {} {
731 if { [istarget nvptx-*-*] } {
732 return 0
733 }
734 return 1
735 }
736
737 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
738
739 proc check_effective_target_tls {} {
740 return [check_no_compiler_messages tls assembly {
741 __thread int i;
742 int f (void) { return i; }
743 void g (int j) { i = j; }
744 }]
745 }
746
747 # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
748
749 proc check_effective_target_tls_native {} {
750 # VxWorks uses emulated TLS machinery, but with non-standard helper
751 # functions, so we fail to automatically detect it.
752 if { [istarget *-*-vxworks*] } {
753 return 0
754 }
755
756 return [check_no_messages_and_pattern tls_native "!emutls" assembly {
757 __thread int i;
758 int f (void) { return i; }
759 void g (int j) { i = j; }
760 }]
761 }
762
763 # Return 1 if *emulated* thread local storage (TLS) is supported, 0 otherwise.
764
765 proc check_effective_target_tls_emulated {} {
766 # VxWorks uses emulated TLS machinery, but with non-standard helper
767 # functions, so we fail to automatically detect it.
768 if { [istarget *-*-vxworks*] } {
769 return 1
770 }
771
772 return [check_no_messages_and_pattern tls_emulated "emutls" assembly {
773 __thread int i;
774 int f (void) { return i; }
775 void g (int j) { i = j; }
776 }]
777 }
778
779 # Return 1 if TLS executables can run correctly, 0 otherwise.
780
781 proc check_effective_target_tls_runtime {} {
782 # The runtime does not have TLS support, but just
783 # running the test below is insufficient to show this.
784 if { [istarget msp430-*-*] || [istarget visium-*-*] } {
785 return 0
786 }
787 return [check_runtime tls_runtime {
788 __thread int thr = 0;
789 int main (void) { return thr; }
790 } [add_options_for_tls ""]]
791 }
792
793 # Return 1 if atomic compare-and-swap is supported on 'int'
794
795 proc check_effective_target_cas_char {} {
796 return [check_no_compiler_messages cas_char assembly {
797 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
798 #error unsupported
799 #endif
800 } ""]
801 }
802
803 proc check_effective_target_cas_int {} {
804 return [check_no_compiler_messages cas_int assembly {
805 #if __INT_MAX__ == 0x7fff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
806 /* ok */
807 #elif __INT_MAX__ == 0x7fffffff && __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
808 /* ok */
809 #else
810 #error unsupported
811 #endif
812 } ""]
813 }
814
815 # Return 1 if -ffunction-sections is supported, 0 otherwise.
816
817 proc check_effective_target_function_sections {} {
818 # Darwin has its own scheme and silently accepts -ffunction-sections.
819 if { [istarget *-*-darwin*] } {
820 return 0
821 }
822
823 return [check_no_compiler_messages functionsections assembly {
824 void foo (void) { }
825 } "-ffunction-sections"]
826 }
827
828 # Return 1 if instruction scheduling is available, 0 otherwise.
829
830 proc check_effective_target_scheduling {} {
831 return [check_no_compiler_messages scheduling object {
832 void foo (void) { }
833 } "-fschedule-insns"]
834 }
835
836 # Return 1 if trapping arithmetic is available, 0 otherwise.
837
838 proc check_effective_target_trapping {} {
839 return [check_no_compiler_messages trapping object {
840 int add (int a, int b) { return a + b; }
841 } "-ftrapv"]
842 }
843
844 # Return 1 if compilation with -fgraphite is error-free for trivial
845 # code, 0 otherwise.
846
847 proc check_effective_target_fgraphite {} {
848 return [check_no_compiler_messages fgraphite object {
849 void foo (void) { }
850 } "-O1 -fgraphite"]
851 }
852
853 # Return 1 if compilation with -fopenacc is error-free for trivial
854 # code, 0 otherwise.
855
856 proc check_effective_target_fopenacc {} {
857 # nvptx can be built with the device-side bits of openacc, but it
858 # does not make sense to test it as an openacc host.
859 if [istarget nvptx-*-*] { return 0 }
860
861 return [check_no_compiler_messages fopenacc object {
862 void foo (void) { }
863 } "-fopenacc"]
864 }
865
866 # Return 1 if compilation with -fopenmp is error-free for trivial
867 # code, 0 otherwise.
868
869 proc check_effective_target_fopenmp {} {
870 # nvptx can be built with the device-side bits of libgomp, but it
871 # does not make sense to test it as an openmp host.
872 if [istarget nvptx-*-*] { return 0 }
873
874 return [check_no_compiler_messages fopenmp object {
875 void foo (void) { }
876 } "-fopenmp"]
877 }
878
879 # Return 1 if compilation with -fgnu-tm is error-free for trivial
880 # code, 0 otherwise.
881
882 proc check_effective_target_fgnu_tm {} {
883 return [check_no_compiler_messages fgnu_tm object {
884 void foo (void) { }
885 } "-fgnu-tm"]
886 }
887
888 # Return 1 if the target supports mmap, 0 otherwise.
889
890 proc check_effective_target_mmap {} {
891 return [check_function_available "mmap"]
892 }
893
894 # Return 1 if the target supports dlopen, 0 otherwise.
895 proc check_effective_target_dlopen {} {
896 return [check_no_compiler_messages dlopen executable {
897 #include <dlfcn.h>
898 int main(void) { dlopen ("dummy.so", RTLD_NOW); }
899 } [add_options_for_dlopen ""]]
900 }
901
902 proc add_options_for_dlopen { flags } {
903 return "$flags -ldl"
904 }
905
906 # Return 1 if the target supports clone, 0 otherwise.
907 proc check_effective_target_clone {} {
908 return [check_function_available "clone"]
909 }
910
911 # Return 1 if the target supports setrlimit, 0 otherwise.
912 proc check_effective_target_setrlimit {} {
913 # Darwin has non-posix compliant RLIMIT_AS
914 if { [istarget *-*-darwin*] } {
915 return 0
916 }
917 return [check_function_available "setrlimit"]
918 }
919
920 # Return 1 if the target supports swapcontext, 0 otherwise.
921 proc check_effective_target_swapcontext {} {
922 return [check_no_compiler_messages swapcontext executable {
923 #include <ucontext.h>
924 int main (void)
925 {
926 ucontext_t orig_context,child_context;
927 if (swapcontext(&child_context, &orig_context) < 0) { }
928 }
929 }]
930 }
931
932 # Return 1 if compilation with -pthread is error-free for trivial
933 # code, 0 otherwise.
934
935 proc check_effective_target_pthread {} {
936 return [check_no_compiler_messages pthread object {
937 void foo (void) { }
938 } "-pthread"]
939 }
940
941 # Return 1 if compilation with -gstabs is error-free for trivial
942 # code, 0 otherwise.
943
944 proc check_effective_target_stabs {} {
945 return [check_no_compiler_messages stabs object {
946 void foo (void) { }
947 } "-gstabs"]
948 }
949
950 # Return 1 if compilation with -mpe-aligned-commons is error-free
951 # for trivial code, 0 otherwise.
952
953 proc check_effective_target_pe_aligned_commons {} {
954 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
955 return [check_no_compiler_messages pe_aligned_commons object {
956 int foo;
957 } "-mpe-aligned-commons"]
958 }
959 return 0
960 }
961
962 # Return 1 if the target supports -static
963 proc check_effective_target_static {} {
964 return [check_no_compiler_messages static executable {
965 int main (void) { return 0; }
966 } "-static"]
967 }
968
969 # Return 1 if the target supports -fstack-protector
970 proc check_effective_target_fstack_protector {} {
971 return [check_runtime fstack_protector {
972 int main (void) { return 0; }
973 } "-fstack-protector"]
974 }
975
976 # Return 1 if compilation with -freorder-blocks-and-partition is error-free
977 # for trivial code, 0 otherwise.
978
979 proc check_effective_target_freorder {} {
980 return [check_no_compiler_messages freorder object {
981 void foo (void) { }
982 } "-freorder-blocks-and-partition"]
983 }
984
985 # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors
986 # emitted, 0 otherwise. Whether a shared library can actually be built is
987 # out of scope for this test.
988
989 proc check_effective_target_fpic { } {
990 # Note that M68K has a multilib that supports -fpic but not
991 # -fPIC, so we need to check both. We test with a program that
992 # requires GOT references.
993 foreach arg {fpic fPIC} {
994 if [check_no_compiler_messages $arg object {
995 extern int foo (void); extern int bar;
996 int baz (void) { return foo () + bar; }
997 } "-$arg"] {
998 return 1
999 }
1000 }
1001 return 0
1002 }
1003
1004 # On AArch64, if -fpic is not supported, then we will fall back to -fPIC
1005 # silently. So, we can't rely on above "check_effective_target_fpic" as it
1006 # assumes compiler will give warning if -fpic not supported. Here we check
1007 # whether binutils supports those new -fpic relocation modifiers, and assume
1008 # -fpic is supported if there is binutils support. GCC configuration will
1009 # enable -fpic for AArch64 in this case.
1010 #
1011 # "check_effective_target_aarch64_small_fpic" is dedicated for checking small
1012 # memory model -fpic relocation types.
1013
1014 proc check_effective_target_aarch64_small_fpic { } {
1015 if { [istarget aarch64*-*-*] } {
1016 return [check_no_compiler_messages aarch64_small_fpic object {
1017 void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
1018 }]
1019 } else {
1020 return 0
1021 }
1022 }
1023
1024 # On AArch64, instruction sequence for TLS LE under -mtls-size=32 will utilize
1025 # the relocation modifier "tprel_g0_nc" together with MOVK, it's only supported
1026 # in binutils since 2015-03-04 as PR gas/17843.
1027 #
1028 # This test directive make sure binutils support all features needed by TLS LE
1029 # under -mtls-size=32 on AArch64.
1030
1031 proc check_effective_target_aarch64_tlsle32 { } {
1032 if { [istarget aarch64*-*-*] } {
1033 return [check_no_compiler_messages aarch64_tlsle32 object {
1034 void foo (void) { asm ("movk x1,#:tprel_g0_nc:t1"); }
1035 }]
1036 } else {
1037 return 0
1038 }
1039 }
1040
1041 # Return 1 if -shared is supported, as in no warnings or errors
1042 # emitted, 0 otherwise.
1043
1044 proc check_effective_target_shared { } {
1045 # Note that M68K has a multilib that supports -fpic but not
1046 # -fPIC, so we need to check both. We test with a program that
1047 # requires GOT references.
1048 return [check_no_compiler_messages shared executable {
1049 extern int foo (void); extern int bar;
1050 int baz (void) { return foo () + bar; }
1051 } "-shared -fpic"]
1052 }
1053
1054 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
1055
1056 proc check_effective_target_pie { } {
1057 if { [istarget *-*-darwin\[912\]*]
1058 || [istarget *-*-dragonfly*]
1059 || [istarget *-*-freebsd*]
1060 || [istarget *-*-linux*]
1061 || [istarget *-*-gnu*] } {
1062 return 1;
1063 }
1064 if { [istarget *-*-solaris2.1\[1-9\]*] } {
1065 # Full PIE support was added in Solaris 11.x and Solaris 12, but gcc
1066 # errors out if missing, so check for that.
1067 return [check_no_compiler_messages pie executable {
1068 int main (void) { return 0; }
1069 } "-pie -fpie"]
1070 }
1071 return 0
1072 }
1073
1074 # Return true if the target supports -mpaired-single (as used on MIPS).
1075
1076 proc check_effective_target_mpaired_single { } {
1077 return [check_no_compiler_messages mpaired_single object {
1078 void foo (void) { }
1079 } "-mpaired-single"]
1080 }
1081
1082 # Return true if the target has access to FPU instructions.
1083
1084 proc check_effective_target_hard_float { } {
1085 if { [istarget mips*-*-*] } {
1086 return [check_no_compiler_messages hard_float assembly {
1087 #if (defined __mips_soft_float || defined __mips16)
1088 #error __mips_soft_float || __mips16
1089 #endif
1090 }]
1091 }
1092
1093 # This proc is actually checking the availabilty of FPU
1094 # support for doubles, so on the RX we must fail if the
1095 # 64-bit double multilib has been selected.
1096 if { [istarget rx-*-*] } {
1097 return 0
1098 # return [check_no_compiler_messages hard_float assembly {
1099 #if defined __RX_64_BIT_DOUBLES__
1100 #error __RX_64_BIT_DOUBLES__
1101 #endif
1102 # }]
1103 }
1104
1105 # The generic test equates hard_float with "no call for adding doubles".
1106 return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand {
1107 double a (double b, double c) { return b + c; }
1108 }]
1109 }
1110
1111 # Return true if the target is a 64-bit MIPS target.
1112
1113 proc check_effective_target_mips64 { } {
1114 return [check_no_compiler_messages mips64 assembly {
1115 #ifndef __mips64
1116 #error !__mips64
1117 #endif
1118 }]
1119 }
1120
1121 # Return true if the target is a MIPS target that does not produce
1122 # MIPS16 code.
1123
1124 proc check_effective_target_nomips16 { } {
1125 return [check_no_compiler_messages nomips16 object {
1126 #ifndef __mips
1127 #error !__mips
1128 #else
1129 /* A cheap way of testing for -mflip-mips16. */
1130 void foo (void) { asm ("addiu $20,$20,1"); }
1131 void bar (void) { asm ("addiu $20,$20,1"); }
1132 #endif
1133 }]
1134 }
1135
1136 # Add the options needed for MIPS16 function attributes. At the moment,
1137 # we don't support MIPS16 PIC.
1138
1139 proc add_options_for_mips16_attribute { flags } {
1140 return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))"
1141 }
1142
1143 # Return true if we can force a mode that allows MIPS16 code generation.
1144 # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float
1145 # for o32 and o64.
1146
1147 proc check_effective_target_mips16_attribute { } {
1148 return [check_no_compiler_messages mips16_attribute assembly {
1149 #ifdef PIC
1150 #error PIC
1151 #endif
1152 #if defined __mips_hard_float \
1153 && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
1154 && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
1155 #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
1156 #endif
1157 } [add_options_for_mips16_attribute ""]]
1158 }
1159
1160 # Return 1 if the target supports long double larger than double when
1161 # using the new ABI, 0 otherwise.
1162
1163 proc check_effective_target_mips_newabi_large_long_double { } {
1164 return [check_no_compiler_messages mips_newabi_large_long_double object {
1165 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
1166 } "-mabi=64"]
1167 }
1168
1169 # Return true if the target is a MIPS target that has access
1170 # to the LL and SC instructions.
1171
1172 proc check_effective_target_mips_llsc { } {
1173 if { ![istarget mips*-*-*] } {
1174 return 0
1175 }
1176 # Assume that these instructions are always implemented for
1177 # non-elf* targets, via emulation if necessary.
1178 if { ![istarget *-*-elf*] } {
1179 return 1
1180 }
1181 # Otherwise assume LL/SC support for everything but MIPS I.
1182 return [check_no_compiler_messages mips_llsc assembly {
1183 #if __mips == 1
1184 #error __mips == 1
1185 #endif
1186 }]
1187 }
1188
1189 # Return true if the target is a MIPS target that uses in-place relocations.
1190
1191 proc check_effective_target_mips_rel { } {
1192 if { ![istarget mips*-*-*] } {
1193 return 0
1194 }
1195 return [check_no_compiler_messages mips_rel object {
1196 #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
1197 || (defined _ABI64 && _MIPS_SIM == _ABI64)
1198 #error _ABIN32 && (_ABIN32 || _ABI64)
1199 #endif
1200 }]
1201 }
1202
1203 # Return true if the target is a MIPS target that uses the EABI.
1204
1205 proc check_effective_target_mips_eabi { } {
1206 if { ![istarget mips*-*-*] } {
1207 return 0
1208 }
1209 return [check_no_compiler_messages mips_eabi object {
1210 #ifndef __mips_eabi
1211 #error !__mips_eabi
1212 #endif
1213 }]
1214 }
1215
1216 # Return 1 if the current multilib does not generate PIC by default.
1217
1218 proc check_effective_target_nonpic { } {
1219 return [check_no_compiler_messages nonpic assembly {
1220 #if __PIC__
1221 #error __PIC__
1222 #endif
1223 }]
1224 }
1225
1226 # Return 1 if the current multilib generates PIE by default.
1227
1228 proc check_effective_target_pie_enabled { } {
1229 return [check_no_compiler_messages pie_enabled assembly {
1230 #ifndef __PIE__
1231 #error unsupported
1232 #endif
1233 }]
1234 }
1235
1236 # Return 1 if the target generates -fstack-protector by default.
1237
1238 proc check_effective_target_fstack_protector_enabled {} {
1239 return [ check_no_compiler_messages fstack_protector_enabled assembly {
1240 #if !defined(__SSP__) && !defined(__SSP_ALL__) && \
1241 !defined(__SSP_STRONG__) && !defined(__SSP_EXPICIT__)
1242 #error unsupported
1243 #endif
1244 }]
1245 }
1246
1247 # Return 1 if the target does not use a status wrapper.
1248
1249 proc check_effective_target_unwrapped { } {
1250 if { [target_info needs_status_wrapper] != "" \
1251 && [target_info needs_status_wrapper] != "0" } {
1252 return 0
1253 }
1254 return 1
1255 }
1256
1257 # Return true if iconv is supported on the target. In particular IBM1047.
1258
1259 proc check_iconv_available { test_what } {
1260 global libiconv
1261
1262 # If the tool configuration file has not set libiconv, try "-liconv"
1263 if { ![info exists libiconv] } {
1264 set libiconv "-liconv"
1265 }
1266 set test_what [lindex $test_what 1]
1267 return [check_runtime_nocache $test_what [subst {
1268 #include <iconv.h>
1269 int main (void)
1270 {
1271 iconv_t cd;
1272
1273 cd = iconv_open ("$test_what", "UTF-8");
1274 if (cd == (iconv_t) -1)
1275 return 1;
1276 return 0;
1277 }
1278 }] $libiconv]
1279 }
1280
1281 # Return true if Cilk Library is supported on the target.
1282 proc check_effective_target_cilkplus_runtime { } {
1283 return [ check_no_compiler_messages_nocache cilkplus_runtime executable {
1284 #ifdef __cplusplus
1285 extern "C"
1286 #endif
1287 int __cilkrts_set_param (const char *, const char *);
1288 int main (void) {
1289 int x = __cilkrts_set_param ("nworkers", "0");
1290 return x;
1291 }
1292 } "-fcilkplus -lcilkrts" ]
1293 }
1294
1295 # Return true if the atomic library is supported on the target.
1296 proc check_effective_target_libatomic_available { } {
1297 return [check_no_compiler_messages libatomic_available executable {
1298 int main (void) { return 0; }
1299 } "-latomic"]
1300 }
1301
1302 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
1303
1304 proc check_ascii_locale_available { } {
1305 return 1
1306 }
1307
1308 # Return true if named sections are supported on this target.
1309
1310 proc check_named_sections_available { } {
1311 return [check_no_compiler_messages named_sections assembly {
1312 int __attribute__ ((section("whatever"))) foo;
1313 }]
1314 }
1315
1316 # Return true if the "naked" function attribute is supported on this target.
1317
1318 proc check_effective_target_naked_functions { } {
1319 return [check_no_compiler_messages naked_functions assembly {
1320 void f() __attribute__((naked));
1321 }]
1322 }
1323
1324 # Return 1 if the target supports Fortran real kinds larger than real(8),
1325 # 0 otherwise.
1326 #
1327 # When the target name changes, replace the cached result.
1328
1329 proc check_effective_target_fortran_large_real { } {
1330 return [check_no_compiler_messages fortran_large_real executable {
1331 ! Fortran
1332 integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
1333 real(kind=k) :: x
1334 x = cos (x)
1335 end
1336 }]
1337 }
1338
1339 # Return 1 if the target supports Fortran real kind real(16),
1340 # 0 otherwise. Contrary to check_effective_target_fortran_large_real
1341 # this checks for Real(16) only; the other returned real(10) if
1342 # both real(10) and real(16) are available.
1343 #
1344 # When the target name changes, replace the cached result.
1345
1346 proc check_effective_target_fortran_real_16 { } {
1347 return [check_no_compiler_messages fortran_real_16 executable {
1348 ! Fortran
1349 real(kind=16) :: x
1350 x = cos (x)
1351 end
1352 }]
1353 }
1354
1355
1356 # Return 1 if the target supports Fortran's IEEE modules,
1357 # 0 otherwise.
1358 #
1359 # When the target name changes, replace the cached result.
1360
1361 proc check_effective_target_fortran_ieee { flags } {
1362 return [check_no_compiler_messages fortran_ieee executable {
1363 ! Fortran
1364 use, intrinsic :: ieee_features
1365 end
1366 } $flags ]
1367 }
1368
1369
1370 # Return 1 if the target supports SQRT for the largest floating-point
1371 # type. (Some targets lack the libm support for this FP type.)
1372 # On most targets, this check effectively checks either whether sqrtl is
1373 # available or on __float128 systems whether libquadmath is installed,
1374 # which provides sqrtq.
1375 #
1376 # When the target name changes, replace the cached result.
1377
1378 proc check_effective_target_fortran_largest_fp_has_sqrt { } {
1379 return [check_no_compiler_messages fortran_largest_fp_has_sqrt executable {
1380 ! Fortran
1381 use iso_fortran_env, only: real_kinds
1382 integer,parameter:: maxFP = real_kinds(ubound(real_kinds,dim=1))
1383 real(kind=maxFP), volatile :: x
1384 x = 2.0_maxFP
1385 x = sqrt (x)
1386 end
1387 }]
1388 }
1389
1390
1391 # Return 1 if the target supports Fortran integer kinds larger than
1392 # integer(8), 0 otherwise.
1393 #
1394 # When the target name changes, replace the cached result.
1395
1396 proc check_effective_target_fortran_large_int { } {
1397 return [check_no_compiler_messages fortran_large_int executable {
1398 ! Fortran
1399 integer,parameter :: k = selected_int_kind (range (0_8) + 1)
1400 integer(kind=k) :: i
1401 end
1402 }]
1403 }
1404
1405 # Return 1 if the target supports Fortran integer(16), 0 otherwise.
1406 #
1407 # When the target name changes, replace the cached result.
1408
1409 proc check_effective_target_fortran_integer_16 { } {
1410 return [check_no_compiler_messages fortran_integer_16 executable {
1411 ! Fortran
1412 integer(16) :: i
1413 end
1414 }]
1415 }
1416
1417 # Return 1 if we can statically link libgfortran, 0 otherwise.
1418 #
1419 # When the target name changes, replace the cached result.
1420
1421 proc check_effective_target_static_libgfortran { } {
1422 return [check_no_compiler_messages static_libgfortran executable {
1423 ! Fortran
1424 print *, 'test'
1425 end
1426 } "-static"]
1427 }
1428
1429 # Return 1 if cilk-plus is supported by the target, 0 otherwise.
1430
1431 proc check_effective_target_cilkplus { } {
1432 # Skip cilk-plus tests on int16 and size16 targets for now.
1433 # The cilk-plus tests are not generic enough to cover these
1434 # cases and would throw hundreds of FAILs.
1435 if { [check_effective_target_int16]
1436 || ![check_effective_target_size32plus] } {
1437 return 0;
1438 }
1439
1440 # Skip AVR, its RAM is too small and too many tests would fail.
1441 if { [istarget avr-*-*] } {
1442 return 0;
1443 }
1444
1445 if { ! [check_effective_target_pthread] } {
1446 return 0;
1447 }
1448
1449 return 1
1450 }
1451
1452 proc check_linker_plugin_available { } {
1453 return [check_no_compiler_messages_nocache linker_plugin executable {
1454 int main() { return 0; }
1455 } "-flto -fuse-linker-plugin"]
1456 }
1457
1458 # Return 1 if the target supports executing 750CL paired-single instructions, 0
1459 # otherwise. Cache the result.
1460
1461 proc check_750cl_hw_available { } {
1462 return [check_cached_effective_target 750cl_hw_available {
1463 # If this is not the right target then we can skip the test.
1464 if { ![istarget powerpc-*paired*] } {
1465 expr 0
1466 } else {
1467 check_runtime_nocache 750cl_hw_available {
1468 int main()
1469 {
1470 #ifdef __MACH__
1471 asm volatile ("ps_mul v0,v0,v0");
1472 #else
1473 asm volatile ("ps_mul 0,0,0");
1474 #endif
1475 return 0;
1476 }
1477 } "-mpaired"
1478 }
1479 }]
1480 }
1481
1482 # Return 1 if the target OS supports running SSE executables, 0
1483 # otherwise. Cache the result.
1484
1485 proc check_sse_os_support_available { } {
1486 return [check_cached_effective_target sse_os_support_available {
1487 # If this is not the right target then we can skip the test.
1488 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1489 expr 0
1490 } elseif { [istarget i?86-*-solaris2*] } {
1491 # The Solaris 2 kernel doesn't save and restore SSE registers
1492 # before Solaris 9 4/04. Before that, executables die with SIGILL.
1493 check_runtime_nocache sse_os_support_available {
1494 int main ()
1495 {
1496 asm volatile ("movaps %xmm0,%xmm0");
1497 return 0;
1498 }
1499 } "-msse"
1500 } else {
1501 expr 1
1502 }
1503 }]
1504 }
1505
1506 # Return 1 if the target OS supports running AVX executables, 0
1507 # otherwise. Cache the result.
1508
1509 proc check_avx_os_support_available { } {
1510 return [check_cached_effective_target avx_os_support_available {
1511 # If this is not the right target then we can skip the test.
1512 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1513 expr 0
1514 } else {
1515 # Check that OS has AVX and SSE saving enabled.
1516 check_runtime_nocache avx_os_support_available {
1517 int main ()
1518 {
1519 unsigned int eax, edx;
1520
1521 asm ("xgetbv" : "=a" (eax), "=d" (edx) : "c" (0));
1522 return (eax & 6) != 6;
1523 }
1524 } ""
1525 }
1526 }]
1527 }
1528
1529 # Return 1 if the target supports executing SSE instructions, 0
1530 # otherwise. Cache the result.
1531
1532 proc check_sse_hw_available { } {
1533 return [check_cached_effective_target sse_hw_available {
1534 # If this is not the right target then we can skip the test.
1535 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1536 expr 0
1537 } else {
1538 check_runtime_nocache sse_hw_available {
1539 #include "cpuid.h"
1540 int main ()
1541 {
1542 unsigned int eax, ebx, ecx, edx;
1543 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1544 return !(edx & bit_SSE);
1545 return 1;
1546 }
1547 } ""
1548 }
1549 }]
1550 }
1551
1552 # Return 1 if the target supports executing SSE2 instructions, 0
1553 # otherwise. Cache the result.
1554
1555 proc check_sse2_hw_available { } {
1556 return [check_cached_effective_target sse2_hw_available {
1557 # If this is not the right target then we can skip the test.
1558 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1559 expr 0
1560 } else {
1561 check_runtime_nocache sse2_hw_available {
1562 #include "cpuid.h"
1563 int main ()
1564 {
1565 unsigned int eax, ebx, ecx, edx;
1566 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1567 return !(edx & bit_SSE2);
1568 return 1;
1569 }
1570 } ""
1571 }
1572 }]
1573 }
1574
1575 # Return 1 if the target supports executing AVX instructions, 0
1576 # otherwise. Cache the result.
1577
1578 proc check_avx_hw_available { } {
1579 return [check_cached_effective_target avx_hw_available {
1580 # If this is not the right target then we can skip the test.
1581 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
1582 expr 0
1583 } else {
1584 check_runtime_nocache avx_hw_available {
1585 #include "cpuid.h"
1586 int main ()
1587 {
1588 unsigned int eax, ebx, ecx, edx;
1589 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
1590 return ((ecx & (bit_AVX | bit_OSXSAVE))
1591 != (bit_AVX | bit_OSXSAVE));
1592 return 1;
1593 }
1594 } ""
1595 }
1596 }]
1597 }
1598
1599 # Return 1 if the target supports running SSE executables, 0 otherwise.
1600
1601 proc check_effective_target_sse_runtime { } {
1602 if { [check_effective_target_sse]
1603 && [check_sse_hw_available]
1604 && [check_sse_os_support_available] } {
1605 return 1
1606 }
1607 return 0
1608 }
1609
1610 # Return 1 if the target supports running SSE2 executables, 0 otherwise.
1611
1612 proc check_effective_target_sse2_runtime { } {
1613 if { [check_effective_target_sse2]
1614 && [check_sse2_hw_available]
1615 && [check_sse_os_support_available] } {
1616 return 1
1617 }
1618 return 0
1619 }
1620
1621 # Return 1 if the target supports running AVX executables, 0 otherwise.
1622
1623 proc check_effective_target_avx_runtime { } {
1624 if { [check_effective_target_avx]
1625 && [check_avx_hw_available]
1626 && [check_avx_os_support_available] } {
1627 return 1
1628 }
1629 return 0
1630 }
1631
1632 # Return 1 if we are compiling for 64-bit PowerPC but we do not use direct
1633 # move instructions for moves from GPR to FPR.
1634
1635 proc check_effective_target_powerpc64_no_dm { } {
1636 # The "mulld" checks if we are generating PowerPC64 code. The "lfd"
1637 # checks if we do not use direct moves, but use the old-fashioned
1638 # slower move-via-the-stack.
1639 return [check_no_messages_and_pattern powerpc64_no_dm \
1640 {\mmulld\M.*\mlfd} assembly {
1641 double f(long long x) { return x*x; }
1642 } {-O2}]
1643 }
1644
1645 # Return 1 if the target supports executing power8 vector instructions, 0
1646 # otherwise. Cache the result.
1647
1648 proc check_p8vector_hw_available { } {
1649 return [check_cached_effective_target p8vector_hw_available {
1650 # Some simulators are known to not support VSX/power8 instructions.
1651 # For now, disable on Darwin
1652 if { [istarget powerpc-*-eabi]
1653 || [istarget powerpc*-*-eabispe]
1654 || [istarget *-*-darwin*]} {
1655 expr 0
1656 } else {
1657 set options "-mpower8-vector"
1658 check_runtime_nocache p8vector_hw_available {
1659 int main()
1660 {
1661 #ifdef __MACH__
1662 asm volatile ("xxlorc vs0,vs0,vs0");
1663 #else
1664 asm volatile ("xxlorc 0,0,0");
1665 #endif
1666 return 0;
1667 }
1668 } $options
1669 }
1670 }]
1671 }
1672
1673 # Return 1 if the target supports executing power9 vector instructions, 0
1674 # otherwise. Cache the result.
1675
1676 proc check_p9vector_hw_available { } {
1677 return [check_cached_effective_target p9vector_hw_available {
1678 # Some simulators are known to not support VSX/power8/power9
1679 # instructions. For now, disable on Darwin.
1680 if { [istarget powerpc-*-eabi]
1681 || [istarget powerpc*-*-eabispe]
1682 || [istarget *-*-darwin*]} {
1683 expr 0
1684 } else {
1685 set options "-mpower9-vector"
1686 check_runtime_nocache p9vector_hw_available {
1687 int main()
1688 {
1689 long e = -1;
1690 vector double v = (vector double) { 0.0, 0.0 };
1691 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
1692 return e;
1693 }
1694 } $options
1695 }
1696 }]
1697 }
1698
1699 # Return 1 if the target supports executing power9 modulo instructions, 0
1700 # otherwise. Cache the result.
1701
1702 proc check_p9modulo_hw_available { } {
1703 return [check_cached_effective_target p9modulo_hw_available {
1704 # Some simulators are known to not support VSX/power8/power9
1705 # instructions. For now, disable on Darwin.
1706 if { [istarget powerpc-*-eabi]
1707 || [istarget powerpc*-*-eabispe]
1708 || [istarget *-*-darwin*]} {
1709 expr 0
1710 } else {
1711 set options "-mmodulo"
1712 check_runtime_nocache p9modulo_hw_available {
1713 int main()
1714 {
1715 int i = 5, j = 3, r = -1;
1716 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
1717 return (r == 2);
1718 }
1719 } $options
1720 }
1721 }]
1722 }
1723
1724 # Return 1 if the target supports executing __float128 on PowerPC via software
1725 # emulation, 0 otherwise. Cache the result.
1726
1727 proc check_ppc_float128_sw_available { } {
1728 return [check_cached_effective_target ppc_float128_sw_available {
1729 # Some simulators are known to not support VSX/power8/power9
1730 # instructions. For now, disable on Darwin.
1731 if { [istarget powerpc-*-eabi]
1732 || [istarget powerpc*-*-eabispe]
1733 || [istarget *-*-darwin*]} {
1734 expr 0
1735 } else {
1736 set options "-mfloat128 -mvsx"
1737 check_runtime_nocache ppc_float128_sw_available {
1738 volatile __float128 x = 1.0q;
1739 volatile __float128 y = 2.0q;
1740 int main()
1741 {
1742 __float128 z = x + y;
1743 return (z != 3.0q);
1744 }
1745 } $options
1746 }
1747 }]
1748 }
1749
1750 # Return 1 if the target supports executing __float128 on PowerPC via power9
1751 # hardware instructions, 0 otherwise. Cache the result.
1752
1753 proc check_ppc_float128_hw_available { } {
1754 return [check_cached_effective_target ppc_float128_hw_available {
1755 # Some simulators are known to not support VSX/power8/power9
1756 # instructions. For now, disable on Darwin.
1757 if { [istarget powerpc-*-eabi]
1758 || [istarget powerpc*-*-eabispe]
1759 || [istarget *-*-darwin*]} {
1760 expr 0
1761 } else {
1762 set options "-mfloat128 -mvsx -mfloat128-hardware -mpower9-vector"
1763 check_runtime_nocache ppc_float128_hw_available {
1764 volatile __float128 x = 1.0q;
1765 volatile __float128 y = 2.0q;
1766 int main()
1767 {
1768 __float128 z = x + y;
1769 __float128 w = -1.0q;
1770
1771 __asm__ ("xsaddqp %0,%1,%2" : "+v" (w) : "v" (x), "v" (y));
1772 return ((z != 3.0q) || (z != w);
1773 }
1774 } $options
1775 }
1776 }]
1777 }
1778
1779 # Return 1 if the target supports executing VSX instructions, 0
1780 # otherwise. Cache the result.
1781
1782 proc check_vsx_hw_available { } {
1783 return [check_cached_effective_target vsx_hw_available {
1784 # Some simulators are known to not support VSX instructions.
1785 # For now, disable on Darwin
1786 if { [istarget powerpc-*-eabi]
1787 || [istarget powerpc*-*-eabispe]
1788 || [istarget *-*-darwin*]} {
1789 expr 0
1790 } else {
1791 set options "-mvsx"
1792 check_runtime_nocache vsx_hw_available {
1793 int main()
1794 {
1795 #ifdef __MACH__
1796 asm volatile ("xxlor vs0,vs0,vs0");
1797 #else
1798 asm volatile ("xxlor 0,0,0");
1799 #endif
1800 return 0;
1801 }
1802 } $options
1803 }
1804 }]
1805 }
1806
1807 # Return 1 if the target supports executing AltiVec instructions, 0
1808 # otherwise. Cache the result.
1809
1810 proc check_vmx_hw_available { } {
1811 return [check_cached_effective_target vmx_hw_available {
1812 # Some simulators are known to not support VMX instructions.
1813 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } {
1814 expr 0
1815 } else {
1816 # Most targets don't require special flags for this test case, but
1817 # Darwin does. Just to be sure, make sure VSX is not enabled for
1818 # the altivec tests.
1819 if { [istarget *-*-darwin*]
1820 || [istarget *-*-aix*] } {
1821 set options "-maltivec -mno-vsx"
1822 } else {
1823 set options "-mno-vsx"
1824 }
1825 check_runtime_nocache vmx_hw_available {
1826 int main()
1827 {
1828 #ifdef __MACH__
1829 asm volatile ("vor v0,v0,v0");
1830 #else
1831 asm volatile ("vor 0,0,0");
1832 #endif
1833 return 0;
1834 }
1835 } $options
1836 }
1837 }]
1838 }
1839
1840 proc check_ppc_recip_hw_available { } {
1841 return [check_cached_effective_target ppc_recip_hw_available {
1842 # Some simulators may not support FRE/FRES/FRSQRTE/FRSQRTES
1843 # For now, disable on Darwin
1844 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
1845 expr 0
1846 } else {
1847 set options "-mpowerpc-gfxopt -mpowerpc-gpopt -mpopcntb"
1848 check_runtime_nocache ppc_recip_hw_available {
1849 volatile double d_recip, d_rsqrt, d_four = 4.0;
1850 volatile float f_recip, f_rsqrt, f_four = 4.0f;
1851 int main()
1852 {
1853 asm volatile ("fres %0,%1" : "=f" (f_recip) : "f" (f_four));
1854 asm volatile ("fre %0,%1" : "=d" (d_recip) : "d" (d_four));
1855 asm volatile ("frsqrtes %0,%1" : "=f" (f_rsqrt) : "f" (f_four));
1856 asm volatile ("frsqrte %0,%1" : "=f" (d_rsqrt) : "d" (d_four));
1857 return 0;
1858 }
1859 } $options
1860 }
1861 }]
1862 }
1863
1864 # Return 1 if the target supports executing AltiVec and Cell PPU
1865 # instructions, 0 otherwise. Cache the result.
1866
1867 proc check_effective_target_cell_hw { } {
1868 return [check_cached_effective_target cell_hw_available {
1869 # Some simulators are known to not support VMX and PPU instructions.
1870 if { [istarget powerpc-*-eabi*] } {
1871 expr 0
1872 } else {
1873 # Most targets don't require special flags for this test
1874 # case, but Darwin and AIX do.
1875 if { [istarget *-*-darwin*]
1876 || [istarget *-*-aix*] } {
1877 set options "-maltivec -mcpu=cell"
1878 } else {
1879 set options "-mcpu=cell"
1880 }
1881 check_runtime_nocache cell_hw_available {
1882 int main()
1883 {
1884 #ifdef __MACH__
1885 asm volatile ("vor v0,v0,v0");
1886 asm volatile ("lvlx v0,r0,r0");
1887 #else
1888 asm volatile ("vor 0,0,0");
1889 asm volatile ("lvlx 0,0,0");
1890 #endif
1891 return 0;
1892 }
1893 } $options
1894 }
1895 }]
1896 }
1897
1898 # Return 1 if the target supports executing 64-bit instructions, 0
1899 # otherwise. Cache the result.
1900
1901 proc check_effective_target_powerpc64 { } {
1902 global powerpc64_available_saved
1903 global tool
1904
1905 if [info exists powerpc64_available_saved] {
1906 verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2
1907 } else {
1908 set powerpc64_available_saved 0
1909
1910 # Some simulators are known to not support powerpc64 instructions.
1911 if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } {
1912 verbose "check_effective_target_powerpc64 returning 0" 2
1913 return $powerpc64_available_saved
1914 }
1915
1916 # Set up, compile, and execute a test program containing a 64-bit
1917 # instruction. Include the current process ID in the file
1918 # names to prevent conflicts with invocations for multiple
1919 # testsuites.
1920 set src ppc[pid].c
1921 set exe ppc[pid].x
1922
1923 set f [open $src "w"]
1924 puts $f "int main() {"
1925 puts $f "#ifdef __MACH__"
1926 puts $f " asm volatile (\"extsw r0,r0\");"
1927 puts $f "#else"
1928 puts $f " asm volatile (\"extsw 0,0\");"
1929 puts $f "#endif"
1930 puts $f " return 0; }"
1931 close $f
1932
1933 set opts "additional_flags=-mcpu=G5"
1934
1935 verbose "check_effective_target_powerpc64 compiling testfile $src" 2
1936 set lines [${tool}_target_compile $src $exe executable "$opts"]
1937 file delete $src
1938
1939 if [string match "" $lines] then {
1940 # No error message, compilation succeeded.
1941 set result [${tool}_load "./$exe" "" ""]
1942 set status [lindex $result 0]
1943 remote_file build delete $exe
1944 verbose "check_effective_target_powerpc64 testfile status is <$status>" 2
1945
1946 if { $status == "pass" } then {
1947 set powerpc64_available_saved 1
1948 }
1949 } else {
1950 verbose "check_effective_target_powerpc64 testfile compilation failed" 2
1951 }
1952 }
1953
1954 return $powerpc64_available_saved
1955 }
1956
1957 # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing
1958 # complex float arguments. This affects gfortran tests that call cabsf
1959 # in libm built by an earlier compiler. Return 1 if libm uses the same
1960 # argument passing as the compiler under test, 0 otherwise.
1961 #
1962 # When the target name changes, replace the cached result.
1963
1964 proc check_effective_target_broken_cplxf_arg { } {
1965 return [check_cached_effective_target broken_cplxf_arg {
1966 # Skip the work for targets known not to be affected.
1967 if { ![istarget powerpc64-*-linux*] } {
1968 expr 0
1969 } elseif { ![is-effective-target lp64] } {
1970 expr 0
1971 } else {
1972 check_runtime_nocache broken_cplxf_arg {
1973 #include <complex.h>
1974 extern void abort (void);
1975 float fabsf (float);
1976 float cabsf (_Complex float);
1977 int main ()
1978 {
1979 _Complex float cf;
1980 float f;
1981 cf = 3 + 4.0fi;
1982 f = cabsf (cf);
1983 if (fabsf (f - 5.0) > 0.0001)
1984 abort ();
1985 return 0;
1986 }
1987 } "-lm"
1988 }
1989 }]
1990 }
1991
1992 # Return 1 is this is a TI C6X target supporting C67X instructions
1993 proc check_effective_target_ti_c67x { } {
1994 return [check_no_compiler_messages ti_c67x assembly {
1995 #if !defined(_TMS320C6700)
1996 #error !_TMS320C6700
1997 #endif
1998 }]
1999 }
2000
2001 # Return 1 is this is a TI C6X target supporting C64X+ instructions
2002 proc check_effective_target_ti_c64xp { } {
2003 return [check_no_compiler_messages ti_c64xp assembly {
2004 #if !defined(_TMS320C6400_PLUS)
2005 #error !_TMS320C6400_PLUS
2006 #endif
2007 }]
2008 }
2009
2010
2011 proc check_alpha_max_hw_available { } {
2012 return [check_runtime alpha_max_hw_available {
2013 int main() { return __builtin_alpha_amask(1<<8) != 0; }
2014 }]
2015 }
2016
2017 # Returns true iff the FUNCTION is available on the target system.
2018 # (This is essentially a Tcl implementation of Autoconf's
2019 # AC_CHECK_FUNC.)
2020
2021 proc check_function_available { function } {
2022 return [check_no_compiler_messages ${function}_available \
2023 executable [subst {
2024 #ifdef __cplusplus
2025 extern "C"
2026 #endif
2027 char $function ();
2028 int main () { $function (); }
2029 }] "-fno-builtin" ]
2030 }
2031
2032 # Returns true iff "fork" is available on the target system.
2033
2034 proc check_fork_available {} {
2035 return [check_function_available "fork"]
2036 }
2037
2038 # Returns true iff "mkfifo" is available on the target system.
2039
2040 proc check_mkfifo_available {} {
2041 if { [istarget *-*-cygwin*] } {
2042 # Cygwin has mkfifo, but support is incomplete.
2043 return 0
2044 }
2045
2046 return [check_function_available "mkfifo"]
2047 }
2048
2049 # Returns true iff "__cxa_atexit" is used on the target system.
2050
2051 proc check_cxa_atexit_available { } {
2052 return [check_cached_effective_target cxa_atexit_available {
2053 if { [istarget hppa*-*-hpux10*] } {
2054 # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes.
2055 expr 0
2056 } elseif { [istarget *-*-vxworks] } {
2057 # vxworks doesn't have __cxa_atexit but subsequent test passes.
2058 expr 0
2059 } else {
2060 check_runtime_nocache cxa_atexit_available {
2061 // C++
2062 #include <stdlib.h>
2063 static unsigned int count;
2064 struct X
2065 {
2066 X() { count = 1; }
2067 ~X()
2068 {
2069 if (count != 3)
2070 exit(1);
2071 count = 4;
2072 }
2073 };
2074 void f()
2075 {
2076 static X x;
2077 }
2078 struct Y
2079 {
2080 Y() { f(); count = 2; }
2081 ~Y()
2082 {
2083 if (count != 2)
2084 exit(1);
2085 count = 3;
2086 }
2087 };
2088 Y y;
2089 int main() { return 0; }
2090 }
2091 }
2092 }]
2093 }
2094
2095 proc check_effective_target_objc2 { } {
2096 return [check_no_compiler_messages objc2 object {
2097 #ifdef __OBJC2__
2098 int dummy[1];
2099 #else
2100 #error !__OBJC2__
2101 #endif
2102 }]
2103 }
2104
2105 proc check_effective_target_next_runtime { } {
2106 return [check_no_compiler_messages objc2 object {
2107 #ifdef __NEXT_RUNTIME__
2108 int dummy[1];
2109 #else
2110 #error !__NEXT_RUNTIME__
2111 #endif
2112 }]
2113 }
2114
2115 # Return 1 if we're generating 32-bit code using default options, 0
2116 # otherwise.
2117
2118 proc check_effective_target_ilp32 { } {
2119 return [check_no_compiler_messages ilp32 object {
2120 int dummy[sizeof (int) == 4
2121 && sizeof (void *) == 4
2122 && sizeof (long) == 4 ? 1 : -1];
2123 }]
2124 }
2125
2126 # Return 1 if we're generating ia32 code using default options, 0
2127 # otherwise.
2128
2129 proc check_effective_target_ia32 { } {
2130 return [check_no_compiler_messages ia32 object {
2131 int dummy[sizeof (int) == 4
2132 && sizeof (void *) == 4
2133 && sizeof (long) == 4 ? 1 : -1] = { __i386__ };
2134 }]
2135 }
2136
2137 # Return 1 if we're generating x32 code using default options, 0
2138 # otherwise.
2139
2140 proc check_effective_target_x32 { } {
2141 return [check_no_compiler_messages x32 object {
2142 int dummy[sizeof (int) == 4
2143 && sizeof (void *) == 4
2144 && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
2145 }]
2146 }
2147
2148 # Return 1 if we're generating 32-bit integers using default
2149 # options, 0 otherwise.
2150
2151 proc check_effective_target_int32 { } {
2152 return [check_no_compiler_messages int32 object {
2153 int dummy[sizeof (int) == 4 ? 1 : -1];
2154 }]
2155 }
2156
2157 # Return 1 if we're generating 32-bit or larger integers using default
2158 # options, 0 otherwise.
2159
2160 proc check_effective_target_int32plus { } {
2161 return [check_no_compiler_messages int32plus object {
2162 int dummy[sizeof (int) >= 4 ? 1 : -1];
2163 }]
2164 }
2165
2166 # Return 1 if we're generating 32-bit or larger pointers using default
2167 # options, 0 otherwise.
2168
2169 proc check_effective_target_ptr32plus { } {
2170 # The msp430 has 16-bit or 20-bit pointers. The 20-bit pointer is stored
2171 # in a 32-bit slot when in memory, so sizeof(void *) returns 4, but it
2172 # cannot really hold a 32-bit address, so we always return false here.
2173 if { [istarget msp430-*-*] } {
2174 return 0
2175 }
2176
2177 return [check_no_compiler_messages ptr32plus object {
2178 int dummy[sizeof (void *) >= 4 ? 1 : -1];
2179 }]
2180 }
2181
2182 # Return 1 if we support 32-bit or larger array and structure sizes
2183 # using default options, 0 otherwise. Avoid false positive on
2184 # targets with 20 or 24 bit address spaces.
2185
2186 proc check_effective_target_size32plus { } {
2187 return [check_no_compiler_messages size32plus object {
2188 char dummy[16777217L];
2189 }]
2190 }
2191
2192 # Returns 1 if we're generating 16-bit or smaller integers with the
2193 # default options, 0 otherwise.
2194
2195 proc check_effective_target_int16 { } {
2196 return [check_no_compiler_messages int16 object {
2197 int dummy[sizeof (int) < 4 ? 1 : -1];
2198 }]
2199 }
2200
2201 # Return 1 if we're generating 64-bit code using default options, 0
2202 # otherwise.
2203
2204 proc check_effective_target_lp64 { } {
2205 return [check_no_compiler_messages lp64 object {
2206 int dummy[sizeof (int) == 4
2207 && sizeof (void *) == 8
2208 && sizeof (long) == 8 ? 1 : -1];
2209 }]
2210 }
2211
2212 # Return 1 if we're generating 64-bit code using default llp64 options,
2213 # 0 otherwise.
2214
2215 proc check_effective_target_llp64 { } {
2216 return [check_no_compiler_messages llp64 object {
2217 int dummy[sizeof (int) == 4
2218 && sizeof (void *) == 8
2219 && sizeof (long long) == 8
2220 && sizeof (long) == 4 ? 1 : -1];
2221 }]
2222 }
2223
2224 # Return 1 if long and int have different sizes,
2225 # 0 otherwise.
2226
2227 proc check_effective_target_long_neq_int { } {
2228 return [check_no_compiler_messages long_ne_int object {
2229 int dummy[sizeof (int) != sizeof (long) ? 1 : -1];
2230 }]
2231 }
2232
2233 # Return 1 if the target supports long double larger than double,
2234 # 0 otherwise.
2235
2236 proc check_effective_target_large_long_double { } {
2237 return [check_no_compiler_messages large_long_double object {
2238 int dummy[sizeof(long double) > sizeof(double) ? 1 : -1];
2239 }]
2240 }
2241
2242 # Return 1 if the target supports double larger than float,
2243 # 0 otherwise.
2244
2245 proc check_effective_target_large_double { } {
2246 return [check_no_compiler_messages large_double object {
2247 int dummy[sizeof(double) > sizeof(float) ? 1 : -1];
2248 }]
2249 }
2250
2251 # Return 1 if the target supports long double of 128 bits,
2252 # 0 otherwise.
2253
2254 proc check_effective_target_longdouble128 { } {
2255 return [check_no_compiler_messages longdouble128 object {
2256 int dummy[sizeof(long double) == 16 ? 1 : -1];
2257 }]
2258 }
2259
2260 # Return 1 if the target supports double of 64 bits,
2261 # 0 otherwise.
2262
2263 proc check_effective_target_double64 { } {
2264 return [check_no_compiler_messages double64 object {
2265 int dummy[sizeof(double) == 8 ? 1 : -1];
2266 }]
2267 }
2268
2269 # Return 1 if the target supports double of at least 64 bits,
2270 # 0 otherwise.
2271
2272 proc check_effective_target_double64plus { } {
2273 return [check_no_compiler_messages double64plus object {
2274 int dummy[sizeof(double) >= 8 ? 1 : -1];
2275 }]
2276 }
2277
2278 # Return 1 if the target supports 'w' suffix on floating constant
2279 # 0 otherwise.
2280
2281 proc check_effective_target_has_w_floating_suffix { } {
2282 set opts ""
2283 if [check_effective_target_c++] {
2284 append opts "-std=gnu++03"
2285 }
2286 return [check_no_compiler_messages w_fp_suffix object {
2287 float dummy = 1.0w;
2288 } "$opts"]
2289 }
2290
2291 # Return 1 if the target supports 'q' suffix on floating constant
2292 # 0 otherwise.
2293
2294 proc check_effective_target_has_q_floating_suffix { } {
2295 set opts ""
2296 if [check_effective_target_c++] {
2297 append opts "-std=gnu++03"
2298 }
2299 return [check_no_compiler_messages q_fp_suffix object {
2300 float dummy = 1.0q;
2301 } "$opts"]
2302 }
2303 # Return 1 if the target supports compiling fixed-point,
2304 # 0 otherwise.
2305
2306 proc check_effective_target_fixed_point { } {
2307 return [check_no_compiler_messages fixed_point object {
2308 _Sat _Fract x; _Sat _Accum y;
2309 }]
2310 }
2311
2312 # Return 1 if the target supports compiling decimal floating point,
2313 # 0 otherwise.
2314
2315 proc check_effective_target_dfp_nocache { } {
2316 verbose "check_effective_target_dfp_nocache: compiling source" 2
2317 set ret [check_no_compiler_messages_nocache dfp object {
2318 float x __attribute__((mode(DD)));
2319 }]
2320 verbose "check_effective_target_dfp_nocache: returning $ret" 2
2321 return $ret
2322 }
2323
2324 proc check_effective_target_dfprt_nocache { } {
2325 return [check_runtime_nocache dfprt {
2326 typedef float d64 __attribute__((mode(DD)));
2327 d64 x = 1.2df, y = 2.3dd, z;
2328 int main () { z = x + y; return 0; }
2329 }]
2330 }
2331
2332 # Return 1 if the target supports compiling Decimal Floating Point,
2333 # 0 otherwise.
2334 #
2335 # This won't change for different subtargets so cache the result.
2336
2337 proc check_effective_target_dfp { } {
2338 return [check_cached_effective_target dfp {
2339 check_effective_target_dfp_nocache
2340 }]
2341 }
2342
2343 # Return 1 if the target supports linking and executing Decimal Floating
2344 # Point, 0 otherwise.
2345 #
2346 # This won't change for different subtargets so cache the result.
2347
2348 proc check_effective_target_dfprt { } {
2349 return [check_cached_effective_target dfprt {
2350 check_effective_target_dfprt_nocache
2351 }]
2352 }
2353
2354 # Return 1 if the target supports executing DFP hardware instructions,
2355 # 0 otherwise. Cache the result.
2356
2357 proc check_dfp_hw_available { } {
2358 return [check_cached_effective_target dfp_hw_available {
2359 # For now, disable on Darwin
2360 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
2361 expr 0
2362 } else {
2363 check_runtime_nocache dfp_hw_available {
2364 volatile _Decimal64 r;
2365 volatile _Decimal64 a = 4.0DD;
2366 volatile _Decimal64 b = 2.0DD;
2367 int main()
2368 {
2369 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2370 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2371 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2372 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
2373 return 0;
2374 }
2375 } "-mcpu=power6 -mhard-float"
2376 }
2377 }]
2378 }
2379
2380 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2381
2382 proc check_effective_target_ucn_nocache { } {
2383 # -std=c99 is only valid for C
2384 if [check_effective_target_c] {
2385 set ucnopts "-std=c99"
2386 } else {
2387 set ucnopts ""
2388 }
2389 verbose "check_effective_target_ucn_nocache: compiling source" 2
2390 set ret [check_no_compiler_messages_nocache ucn object {
2391 int \u00C0;
2392 } $ucnopts]
2393 verbose "check_effective_target_ucn_nocache: returning $ret" 2
2394 return $ret
2395 }
2396
2397 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
2398 #
2399 # This won't change for different subtargets, so cache the result.
2400
2401 proc check_effective_target_ucn { } {
2402 return [check_cached_effective_target ucn {
2403 check_effective_target_ucn_nocache
2404 }]
2405 }
2406
2407 # Return 1 if the target needs a command line argument to enable a SIMD
2408 # instruction set.
2409
2410 proc check_effective_target_vect_cmdline_needed { } {
2411 global et_vect_cmdline_needed_saved
2412 global et_vect_cmdline_needed_target_name
2413
2414 if { ![info exists et_vect_cmdline_needed_target_name] } {
2415 set et_vect_cmdline_needed_target_name ""
2416 }
2417
2418 # If the target has changed since we set the cached value, clear it.
2419 set current_target [current_target_name]
2420 if { $current_target != $et_vect_cmdline_needed_target_name } {
2421 verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2
2422 set et_vect_cmdline_needed_target_name $current_target
2423 if { [info exists et_vect_cmdline_needed_saved] } {
2424 verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2
2425 unset et_vect_cmdline_needed_saved
2426 }
2427 }
2428
2429 if [info exists et_vect_cmdline_needed_saved] {
2430 verbose "check_effective_target_vect_cmdline_needed: using cached result" 2
2431 } else {
2432 set et_vect_cmdline_needed_saved 1
2433 if { [istarget alpha*-*-*]
2434 || [istarget ia64-*-*]
2435 || (([istarget x86_64-*-*] || [istarget i?86-*-*])
2436 && ([check_effective_target_x32]
2437 || [check_effective_target_lp64]))
2438 || ([istarget powerpc*-*-*]
2439 && ([check_effective_target_powerpc_spe]
2440 || [check_effective_target_powerpc_altivec]))
2441 || ([istarget sparc*-*-*] && [check_effective_target_sparc_vis])
2442 || [istarget spu-*-*]
2443 || ([istarget arm*-*-*] && [check_effective_target_arm_neon])
2444 || [istarget aarch64*-*-*] } {
2445 set et_vect_cmdline_needed_saved 0
2446 }
2447 }
2448
2449 verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2
2450 return $et_vect_cmdline_needed_saved
2451 }
2452
2453 # Return 1 if the target supports hardware vectors of int, 0 otherwise.
2454 #
2455 # This won't change for different subtargets so cache the result.
2456
2457 proc check_effective_target_vect_int { } {
2458 global et_vect_int_saved
2459
2460 if [info exists et_vect_int_saved] {
2461 verbose "check_effective_target_vect_int: using cached result" 2
2462 } else {
2463 set et_vect_int_saved 0
2464 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2465 || ([istarget powerpc*-*-*]
2466 && ![istarget powerpc-*-linux*paired*])
2467 || [istarget spu-*-*]
2468 || [istarget sparc*-*-*]
2469 || [istarget alpha*-*-*]
2470 || [istarget ia64-*-*]
2471 || [istarget aarch64*-*-*]
2472 || [check_effective_target_arm32]
2473 || ([istarget mips*-*-*]
2474 && [check_effective_target_mips_loongson]) } {
2475 set et_vect_int_saved 1
2476 }
2477 }
2478
2479 verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2
2480 return $et_vect_int_saved
2481 }
2482
2483 # Return 1 if the target supports signed int->float conversion
2484 #
2485
2486 proc check_effective_target_vect_intfloat_cvt { } {
2487 global et_vect_intfloat_cvt_saved
2488
2489 if [info exists et_vect_intfloat_cvt_saved] {
2490 verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
2491 } else {
2492 set et_vect_intfloat_cvt_saved 0
2493 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2494 || ([istarget powerpc*-*-*]
2495 && ![istarget powerpc-*-linux*paired*])
2496 || ([istarget arm*-*-*]
2497 && [check_effective_target_arm_neon_ok])} {
2498 set et_vect_intfloat_cvt_saved 1
2499 }
2500 }
2501
2502 verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2
2503 return $et_vect_intfloat_cvt_saved
2504 }
2505
2506 #Return 1 if we're supporting __int128 for target, 0 otherwise.
2507
2508 proc check_effective_target_int128 { } {
2509 return [check_no_compiler_messages int128 object {
2510 int dummy[
2511 #ifndef __SIZEOF_INT128__
2512 -1
2513 #else
2514 1
2515 #endif
2516 ];
2517 }]
2518 }
2519
2520 # Return 1 if the target supports unsigned int->float conversion
2521 #
2522
2523 proc check_effective_target_vect_uintfloat_cvt { } {
2524 global et_vect_uintfloat_cvt_saved
2525
2526 if [info exists et_vect_uintfloat_cvt_saved] {
2527 verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
2528 } else {
2529 set et_vect_uintfloat_cvt_saved 0
2530 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2531 || ([istarget powerpc*-*-*]
2532 && ![istarget powerpc-*-linux*paired*])
2533 || [istarget aarch64*-*-*]
2534 || ([istarget arm*-*-*]
2535 && [check_effective_target_arm_neon_ok])} {
2536 set et_vect_uintfloat_cvt_saved 1
2537 }
2538 }
2539
2540 verbose "check_effective_target_vect_uintfloat_cvt: returning $et_vect_uintfloat_cvt_saved" 2
2541 return $et_vect_uintfloat_cvt_saved
2542 }
2543
2544
2545 # Return 1 if the target supports signed float->int conversion
2546 #
2547
2548 proc check_effective_target_vect_floatint_cvt { } {
2549 global et_vect_floatint_cvt_saved
2550
2551 if [info exists et_vect_floatint_cvt_saved] {
2552 verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
2553 } else {
2554 set et_vect_floatint_cvt_saved 0
2555 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
2556 || ([istarget powerpc*-*-*]
2557 && ![istarget powerpc-*-linux*paired*])
2558 || ([istarget arm*-*-*]
2559 && [check_effective_target_arm_neon_ok])} {
2560 set et_vect_floatint_cvt_saved 1
2561 }
2562 }
2563
2564 verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2
2565 return $et_vect_floatint_cvt_saved
2566 }
2567
2568 # Return 1 if the target supports unsigned float->int conversion
2569 #
2570
2571 proc check_effective_target_vect_floatuint_cvt { } {
2572 global et_vect_floatuint_cvt_saved
2573
2574 if [info exists et_vect_floatuint_cvt_saved] {
2575 verbose "check_effective_target_vect_floatuint_cvt: using cached result" 2
2576 } else {
2577 set et_vect_floatuint_cvt_saved 0
2578 if { ([istarget powerpc*-*-*]
2579 && ![istarget powerpc-*-linux*paired*])
2580 || ([istarget arm*-*-*]
2581 && [check_effective_target_arm_neon_ok])} {
2582 set et_vect_floatuint_cvt_saved 1
2583 }
2584 }
2585
2586 verbose "check_effective_target_vect_floatuint_cvt: returning $et_vect_floatuint_cvt_saved" 2
2587 return $et_vect_floatuint_cvt_saved
2588 }
2589
2590 # Return 1 if the target supports #pragma omp declare simd, 0 otherwise.
2591 #
2592 # This won't change for different subtargets so cache the result.
2593
2594 proc check_effective_target_vect_simd_clones { } {
2595 global et_vect_simd_clones_saved
2596
2597 if [info exists et_vect_simd_clones_saved] {
2598 verbose "check_effective_target_vect_simd_clones: using cached result" 2
2599 } else {
2600 set et_vect_simd_clones_saved 0
2601 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
2602 # On i?86/x86_64 #pragma omp declare simd builds a sse2, avx and
2603 # avx2 clone. Only the right clone for the specified arch will be
2604 # chosen, but still we need to at least be able to assemble
2605 # avx2.
2606 if { [check_effective_target_avx512f] } {
2607 set et_vect_simd_clones_saved 1
2608 }
2609 }
2610 }
2611
2612 verbose "check_effective_target_vect_simd_clones: returning $et_vect_simd_clones_saved" 2
2613 return $et_vect_simd_clones_saved
2614 }
2615
2616 # Return 1 if this is a AArch64 target supporting big endian
2617 proc check_effective_target_aarch64_big_endian { } {
2618 return [check_no_compiler_messages aarch64_big_endian assembly {
2619 #if !defined(__aarch64__) || !defined(__AARCH64EB__)
2620 #error !__aarch64__ || !__AARCH64EB__
2621 #endif
2622 }]
2623 }
2624
2625 # Return 1 if this is a AArch64 target supporting little endian
2626 proc check_effective_target_aarch64_little_endian { } {
2627 if { ![istarget aarch64*-*-*] } {
2628 return 0
2629 }
2630
2631 return [check_no_compiler_messages aarch64_little_endian assembly {
2632 #if !defined(__aarch64__) || defined(__AARCH64EB__)
2633 #error FOO
2634 #endif
2635 }]
2636 }
2637
2638 # Return 1 if this is a compiler supporting ARC atomic operations
2639 proc check_effective_target_arc_atomic { } {
2640 return [check_no_compiler_messages arc_atomic assembly {
2641 #if !defined(__ARC_ATOMIC__)
2642 #error FOO
2643 #endif
2644 }]
2645 }
2646
2647 # Return 1 if this is an arm target using 32-bit instructions
2648 proc check_effective_target_arm32 { } {
2649 if { ![istarget arm*-*-*] } {
2650 return 0
2651 }
2652
2653 return [check_no_compiler_messages arm32 assembly {
2654 #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
2655 #error !__arm || __thumb__ && !__thumb2__
2656 #endif
2657 }]
2658 }
2659
2660 # Return 1 if this is an arm target not using Thumb
2661 proc check_effective_target_arm_nothumb { } {
2662 if { ![istarget arm*-*-*] } {
2663 return 0
2664 }
2665
2666 return [check_no_compiler_messages arm_nothumb assembly {
2667 #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
2668 #error !__arm__ || __thumb || __thumb2__
2669 #endif
2670 }]
2671 }
2672
2673 # Return 1 if this is a little-endian ARM target
2674 proc check_effective_target_arm_little_endian { } {
2675 if { ![istarget arm*-*-*] } {
2676 return 0
2677 }
2678
2679 return [check_no_compiler_messages arm_little_endian assembly {
2680 #if !defined(__arm__) || !defined(__ARMEL__)
2681 #error !__arm__ || !__ARMEL__
2682 #endif
2683 }]
2684 }
2685
2686 # Return 1 if this is an ARM target that only supports aligned vector accesses
2687 proc check_effective_target_arm_vect_no_misalign { } {
2688 if { ![istarget arm*-*-*] } {
2689 return 0
2690 }
2691
2692 return [check_no_compiler_messages arm_vect_no_misalign assembly {
2693 #if !defined(__arm__) \
2694 || (defined(__ARM_FEATURE_UNALIGNED) \
2695 && defined(__ARMEL__))
2696 #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
2697 #endif
2698 }]
2699 }
2700
2701
2702 # Return 1 if this is an ARM target supporting -mfpu=vfp
2703 # -mfloat-abi=softfp. Some multilibs may be incompatible with these
2704 # options.
2705
2706 proc check_effective_target_arm_vfp_ok { } {
2707 if { [check_effective_target_arm32] } {
2708 return [check_no_compiler_messages arm_vfp_ok object {
2709 int dummy;
2710 } "-mfpu=vfp -mfloat-abi=softfp"]
2711 } else {
2712 return 0
2713 }
2714 }
2715
2716 # Return 1 if this is an ARM target supporting -mfpu=vfp3
2717 # -mfloat-abi=softfp.
2718
2719 proc check_effective_target_arm_vfp3_ok { } {
2720 if { [check_effective_target_arm32] } {
2721 return [check_no_compiler_messages arm_vfp3_ok object {
2722 int dummy;
2723 } "-mfpu=vfp3 -mfloat-abi=softfp"]
2724 } else {
2725 return 0
2726 }
2727 }
2728
2729 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
2730 # -mfloat-abi=softfp.
2731 proc check_effective_target_arm_v8_vfp_ok {} {
2732 if { [check_effective_target_arm32] } {
2733 return [check_no_compiler_messages arm_v8_vfp_ok object {
2734 int foo (void)
2735 {
2736 __asm__ volatile ("vrinta.f32.f32 s0, s0");
2737 return 0;
2738 }
2739 } "-mfpu=fp-armv8 -mfloat-abi=softfp"]
2740 } else {
2741 return 0
2742 }
2743 }
2744
2745 # Return 1 if this is an ARM target supporting -mfpu=vfp
2746 # -mfloat-abi=hard. Some multilibs may be incompatible with these
2747 # options.
2748
2749 proc check_effective_target_arm_hard_vfp_ok { } {
2750 if { [check_effective_target_arm32]
2751 && ! [check-flags [list "" { *-*-* } { "-mfloat-abi=*" } { "-mfloat-abi=hard" }]] } {
2752 return [check_no_compiler_messages arm_hard_vfp_ok executable {
2753 int main() { return 0;}
2754 } "-mfpu=vfp -mfloat-abi=hard"]
2755 } else {
2756 return 0
2757 }
2758 }
2759
2760 # Return 1 if this is an ARM target defining __ARM_FP. We may need
2761 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2762 # incompatible with these options. Also set et_arm_fp_flags to the
2763 # best options to add.
2764
2765 proc check_effective_target_arm_fp_ok_nocache { } {
2766 global et_arm_fp_flags
2767 set et_arm_fp_flags ""
2768 if { [check_effective_target_arm32] } {
2769 foreach flags {"" "-mfloat-abi=softfp" "-mfloat-abi=hard"} {
2770 if { [check_no_compiler_messages_nocache arm_fp_ok object {
2771 #ifndef __ARM_FP
2772 #error __ARM_FP not defined
2773 #endif
2774 } "$flags"] } {
2775 set et_arm_fp_flags $flags
2776 return 1
2777 }
2778 }
2779 }
2780
2781 return 0
2782 }
2783
2784 proc check_effective_target_arm_fp_ok { } {
2785 return [check_cached_effective_target arm_fp_ok \
2786 check_effective_target_arm_fp_ok_nocache]
2787 }
2788
2789 # Add the options needed to define __ARM_FP. We need either
2790 # -mfloat-abi=softfp or -mfloat-abi=hard, but if one is already
2791 # specified by the multilib, use it.
2792
2793 proc add_options_for_arm_fp { flags } {
2794 if { ! [check_effective_target_arm_fp_ok] } {
2795 return "$flags"
2796 }
2797 global et_arm_fp_flags
2798 return "$flags $et_arm_fp_flags"
2799 }
2800
2801 # Return 1 if this is an ARM target that supports DSP multiply with
2802 # current multilib flags.
2803
2804 proc check_effective_target_arm_dsp { } {
2805 return [check_no_compiler_messages arm_dsp assembly {
2806 #ifndef __ARM_FEATURE_DSP
2807 #error not DSP
2808 #endif
2809 int i;
2810 }]
2811 }
2812
2813 # Return 1 if this is an ARM target that supports unaligned word/halfword
2814 # load/store instructions.
2815
2816 proc check_effective_target_arm_unaligned { } {
2817 return [check_no_compiler_messages arm_unaligned assembly {
2818 #ifndef __ARM_FEATURE_UNALIGNED
2819 #error no unaligned support
2820 #endif
2821 int i;
2822 }]
2823 }
2824
2825 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2826 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2827 # incompatible with these options. Also set et_arm_crypto_flags to the
2828 # best options to add.
2829
2830 proc check_effective_target_arm_crypto_ok_nocache { } {
2831 global et_arm_crypto_flags
2832 set et_arm_crypto_flags ""
2833 if { [check_effective_target_arm_v8_neon_ok] } {
2834 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
2835 if { [check_no_compiler_messages_nocache arm_crypto_ok object {
2836 #include "arm_neon.h"
2837 uint8x16_t
2838 foo (uint8x16_t a, uint8x16_t b)
2839 {
2840 return vaeseq_u8 (a, b);
2841 }
2842 } "$flags"] } {
2843 set et_arm_crypto_flags $flags
2844 return 1
2845 }
2846 }
2847 }
2848
2849 return 0
2850 }
2851
2852 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
2853
2854 proc check_effective_target_arm_crypto_ok { } {
2855 return [check_cached_effective_target arm_crypto_ok \
2856 check_effective_target_arm_crypto_ok_nocache]
2857 }
2858
2859 # Add options for crypto extensions.
2860 proc add_options_for_arm_crypto { flags } {
2861 if { ! [check_effective_target_arm_crypto_ok] } {
2862 return "$flags"
2863 }
2864 global et_arm_crypto_flags
2865 return "$flags $et_arm_crypto_flags"
2866 }
2867
2868 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2869 # or -mfloat-abi=hard, but if one is already specified by the
2870 # multilib, use it. Similarly, if a -mfpu option already enables
2871 # NEON, do not add -mfpu=neon.
2872
2873 proc add_options_for_arm_neon { flags } {
2874 if { ! [check_effective_target_arm_neon_ok] } {
2875 return "$flags"
2876 }
2877 global et_arm_neon_flags
2878 return "$flags $et_arm_neon_flags"
2879 }
2880
2881 proc add_options_for_arm_v8_vfp { flags } {
2882 if { ! [check_effective_target_arm_v8_vfp_ok] } {
2883 return "$flags"
2884 }
2885 return "$flags -mfpu=fp-armv8 -mfloat-abi=softfp"
2886 }
2887
2888 proc add_options_for_arm_v8_neon { flags } {
2889 if { ! [check_effective_target_arm_v8_neon_ok] } {
2890 return "$flags"
2891 }
2892 global et_arm_v8_neon_flags
2893 return "$flags $et_arm_v8_neon_flags -march=armv8-a"
2894 }
2895
2896 # Add the options needed for ARMv8.1 Adv.SIMD. Also adds the ARMv8 NEON
2897 # options for AArch64 and for ARM.
2898
2899 proc add_options_for_arm_v8_1a_neon { flags } {
2900 if { ! [check_effective_target_arm_v8_1a_neon_ok] } {
2901 return "$flags"
2902 }
2903 global et_arm_v8_1a_neon_flags
2904 return "$flags $et_arm_v8_1a_neon_flags -march=armv8.1-a"
2905 }
2906
2907 proc add_options_for_arm_crc { flags } {
2908 if { ! [check_effective_target_arm_crc_ok] } {
2909 return "$flags"
2910 }
2911 global et_arm_crc_flags
2912 return "$flags $et_arm_crc_flags"
2913 }
2914
2915 # Add the options needed for NEON. We need either -mfloat-abi=softfp
2916 # or -mfloat-abi=hard, but if one is already specified by the
2917 # multilib, use it. Similarly, if a -mfpu option already enables
2918 # NEON, do not add -mfpu=neon.
2919
2920 proc add_options_for_arm_neonv2 { flags } {
2921 if { ! [check_effective_target_arm_neonv2_ok] } {
2922 return "$flags"
2923 }
2924 global et_arm_neonv2_flags
2925 return "$flags $et_arm_neonv2_flags"
2926 }
2927
2928 # Add the options needed for vfp3.
2929 proc add_options_for_arm_vfp3 { flags } {
2930 if { ! [check_effective_target_arm_vfp3_ok] } {
2931 return "$flags"
2932 }
2933 return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
2934 }
2935
2936 # Return 1 if this is an ARM target supporting -mfpu=neon
2937 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2938 # incompatible with these options. Also set et_arm_neon_flags to the
2939 # best options to add.
2940
2941 proc check_effective_target_arm_neon_ok_nocache { } {
2942 global et_arm_neon_flags
2943 set et_arm_neon_flags ""
2944 if { [check_effective_target_arm32] } {
2945 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon" "-mfpu=neon -mfloat-abi=softfp" "-mfpu=neon -mfloat-abi=softfp -march=armv7-a"} {
2946 if { [check_no_compiler_messages_nocache arm_neon_ok object {
2947 int dummy;
2948 #ifndef __ARM_NEON__
2949 #error not NEON
2950 #endif
2951 /* Avoid the case where a test adds -mfpu=neon, but the toolchain is
2952 configured for -mcpu=arm926ej-s, for example. */
2953 #if __ARM_ARCH < 7 || __ARM_ARCH_PROFILE == 'M'
2954 #error Architecture does not support NEON.
2955 #endif
2956 } "$flags"] } {
2957 set et_arm_neon_flags $flags
2958 return 1
2959 }
2960 }
2961 }
2962
2963 return 0
2964 }
2965
2966 proc check_effective_target_arm_neon_ok { } {
2967 return [check_cached_effective_target arm_neon_ok \
2968 check_effective_target_arm_neon_ok_nocache]
2969 }
2970
2971 proc check_effective_target_arm_crc_ok_nocache { } {
2972 global et_arm_crc_flags
2973 set et_arm_crc_flags "-march=armv8-a+crc"
2974 return [check_no_compiler_messages_nocache arm_crc_ok object {
2975 #if !defined (__ARM_FEATURE_CRC32)
2976 #error FOO
2977 #endif
2978 } "$et_arm_crc_flags"]
2979 }
2980
2981 proc check_effective_target_arm_crc_ok { } {
2982 return [check_cached_effective_target arm_crc_ok \
2983 check_effective_target_arm_crc_ok_nocache]
2984 }
2985
2986 # Return 1 if this is an ARM target supporting -mfpu=neon-fp16
2987 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
2988 # incompatible with these options. Also set et_arm_neon_fp16_flags to
2989 # the best options to add.
2990
2991 proc check_effective_target_arm_neon_fp16_ok_nocache { } {
2992 global et_arm_neon_fp16_flags
2993 set et_arm_neon_fp16_flags ""
2994 if { [check_effective_target_arm32] } {
2995 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp16"
2996 "-mfpu=neon-fp16 -mfloat-abi=softfp"
2997 "-mfp16-format=ieee"
2998 "-mfloat-abi=softfp -mfp16-format=ieee"
2999 "-mfpu=neon-fp16 -mfp16-format=ieee"
3000 "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
3001 if { [check_no_compiler_messages_nocache arm_neon_fp_16_ok object {
3002 #include "arm_neon.h"
3003 float16x4_t
3004 foo (float32x4_t arg)
3005 {
3006 return vcvt_f16_f32 (arg);
3007 }
3008 } "$flags"] } {
3009 set et_arm_neon_fp16_flags $flags
3010 return 1
3011 }
3012 }
3013 }
3014
3015 return 0
3016 }
3017
3018 proc check_effective_target_arm_neon_fp16_ok { } {
3019 return [check_cached_effective_target arm_neon_fp16_ok \
3020 check_effective_target_arm_neon_fp16_ok_nocache]
3021 }
3022
3023 proc check_effective_target_arm_neon_fp16_hw { } {
3024 if {! [check_effective_target_arm_neon_fp16_ok] } {
3025 return 0
3026 }
3027 global et_arm_neon_fp16_flags
3028 check_runtime_nocache arm_neon_fp16_hw {
3029 int
3030 main (int argc, char **argv)
3031 {
3032 asm ("vcvt.f32.f16 q1, d0");
3033 return 0;
3034 }
3035 } $et_arm_neon_fp16_flags
3036 }
3037
3038 proc add_options_for_arm_neon_fp16 { flags } {
3039 if { ! [check_effective_target_arm_neon_fp16_ok] } {
3040 return "$flags"
3041 }
3042 global et_arm_neon_fp16_flags
3043 return "$flags $et_arm_neon_fp16_flags"
3044 }
3045
3046 # Return 1 if this is an ARM target supporting -mfpu=neon-fp-armv8
3047 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3048 # incompatible with these options. Also set et_arm_v8_neon_flags to the
3049 # best options to add.
3050
3051 proc check_effective_target_arm_v8_neon_ok_nocache { } {
3052 global et_arm_v8_neon_flags
3053 set et_arm_v8_neon_flags ""
3054 if { [check_effective_target_arm32] } {
3055 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3056 if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
3057 #if __ARM_ARCH < 8
3058 #error not armv8 or later
3059 #endif
3060 #include "arm_neon.h"
3061 void
3062 foo ()
3063 {
3064 __asm__ volatile ("vrintn.f32 q0, q0");
3065 }
3066 } "$flags -march=armv8-a"] } {
3067 set et_arm_v8_neon_flags $flags
3068 return 1
3069 }
3070 }
3071 }
3072
3073 return 0
3074 }
3075
3076 proc check_effective_target_arm_v8_neon_ok { } {
3077 return [check_cached_effective_target arm_v8_neon_ok \
3078 check_effective_target_arm_v8_neon_ok_nocache]
3079 }
3080
3081 # Return 1 if this is an ARM target supporting -mfpu=neon-vfpv4
3082 # -mfloat-abi=softfp or equivalent options. Some multilibs may be
3083 # incompatible with these options. Also set et_arm_neonv2_flags to the
3084 # best options to add.
3085
3086 proc check_effective_target_arm_neonv2_ok_nocache { } {
3087 global et_arm_neonv2_flags
3088 set et_arm_neonv2_flags ""
3089 if { [check_effective_target_arm32] } {
3090 foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-vfpv4" "-mfpu=neon-vfpv4 -mfloat-abi=softfp"} {
3091 if { [check_no_compiler_messages_nocache arm_neonv2_ok object {
3092 #include "arm_neon.h"
3093 float32x2_t
3094 foo (float32x2_t a, float32x2_t b, float32x2_t c)
3095 {
3096 return vfma_f32 (a, b, c);
3097 }
3098 } "$flags"] } {
3099 set et_arm_neonv2_flags $flags
3100 return 1
3101 }
3102 }
3103 }
3104
3105 return 0
3106 }
3107
3108 proc check_effective_target_arm_neonv2_ok { } {
3109 return [check_cached_effective_target arm_neonv2_ok \
3110 check_effective_target_arm_neonv2_ok_nocache]
3111 }
3112
3113 # Add the options needed for NEON. We need either -mfloat-abi=softfp
3114 # or -mfloat-abi=hard, but if one is already specified by the
3115 # multilib, use it.
3116
3117 proc add_options_for_arm_fp16 { flags } {
3118 if { ! [check_effective_target_arm_fp16_ok] } {
3119 return "$flags"
3120 }
3121 global et_arm_fp16_flags
3122 return "$flags $et_arm_fp16_flags"
3123 }
3124
3125 # Return 1 if this is an ARM target that can support a VFP fp16 variant.
3126 # Skip multilibs that are incompatible with these options and set
3127 # et_arm_fp16_flags to the best options to add.
3128
3129 proc check_effective_target_arm_fp16_ok_nocache { } {
3130 global et_arm_fp16_flags
3131 set et_arm_fp16_flags ""
3132 if { ! [check_effective_target_arm32] } {
3133 return 0;
3134 }
3135 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "-mfpu=*fp16*" "-mfpu=*fpv[4-9]*" "-mfpu=*fpv[1-9][0-9]*" } ]] {
3136 # Multilib flags would override -mfpu.
3137 return 0
3138 }
3139 if [check-flags [list "" { *-*-* } { "-mfloat-abi=soft" } { "" } ]] {
3140 # Must generate floating-point instructions.
3141 return 0
3142 }
3143 if [check_effective_target_arm_hf_eabi] {
3144 # Use existing float-abi and force an fpu which supports fp16
3145 set et_arm_fp16_flags "-mfpu=vfpv4"
3146 return 1;
3147 }
3148 if [check-flags [list "" { *-*-* } { "-mfpu=*" } { "" } ]] {
3149 # The existing -mfpu value is OK; use it, but add softfp.
3150 set et_arm_fp16_flags "-mfloat-abi=softfp"
3151 return 1;
3152 }
3153 # Add -mfpu for a VFP fp16 variant since there is no preprocessor
3154 # macro to check for this support.
3155 set flags "-mfpu=vfpv4 -mfloat-abi=softfp"
3156 if { [check_no_compiler_messages_nocache arm_fp16_ok assembly {
3157 int dummy;
3158 } "$flags"] } {
3159 set et_arm_fp16_flags "$flags"
3160 return 1
3161 }
3162
3163 return 0
3164 }
3165
3166 proc check_effective_target_arm_fp16_ok { } {
3167 return [check_cached_effective_target arm_fp16_ok \
3168 check_effective_target_arm_fp16_ok_nocache]
3169 }
3170
3171 # Creates a series of routines that return 1 if the given architecture
3172 # can be selected and a routine to give the flags to select that architecture
3173 # Note: Extra flags may be added to disable options from newer compilers
3174 # (Thumb in particular - but others may be added in the future).
3175 # -march=armv7ve is special and is handled explicitly after this loop because
3176 # it needs more than one predefine check to identify.
3177 # Usage: /* { dg-require-effective-target arm_arch_v5_ok } */
3178 # /* { dg-add-options arm_arch_v5 } */
3179 # /* { dg-require-effective-target arm_arch_v5_multilib } */
3180 foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
3181 v4t "-march=armv4t" __ARM_ARCH_4T__
3182 v5 "-march=armv5 -marm" __ARM_ARCH_5__
3183 v5t "-march=armv5t" __ARM_ARCH_5T__
3184 v5te "-march=armv5te" __ARM_ARCH_5TE__
3185 v6 "-march=armv6" __ARM_ARCH_6__
3186 v6k "-march=armv6k" __ARM_ARCH_6K__
3187 v6t2 "-march=armv6t2" __ARM_ARCH_6T2__
3188 v6z "-march=armv6z" __ARM_ARCH_6Z__
3189 v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
3190 v7a "-march=armv7-a" __ARM_ARCH_7A__
3191 v7r "-march=armv7-r" __ARM_ARCH_7R__
3192 v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
3193 v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
3194 v8a "-march=armv8-a" __ARM_ARCH_8A__
3195 v8_1a "-march=armv8.1a" __ARM_ARCH_8A__ } {
3196 eval [string map [list FUNC $armfunc FLAG $armflag DEF $armdef ] {
3197 proc check_effective_target_arm_arch_FUNC_ok { } {
3198 if { [ string match "*-marm*" "FLAG" ] &&
3199 ![check_effective_target_arm_arm_ok] } {
3200 return 0
3201 }
3202 return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
3203 #if !defined (DEF)
3204 #error !DEF
3205 #endif
3206 } "FLAG" ]
3207 }
3208
3209 proc add_options_for_arm_arch_FUNC { flags } {
3210 return "$flags FLAG"
3211 }
3212
3213 proc check_effective_target_arm_arch_FUNC_multilib { } {
3214 return [check_runtime arm_arch_FUNC_multilib {
3215 int
3216 main (void)
3217 {
3218 return 0;
3219 }
3220 } [add_options_for_arm_arch_FUNC ""]]
3221 }
3222 }]
3223 }
3224
3225 # Same functions as above but for -march=armv7ve. To uniquely identify
3226 # -march=armv7ve we need to check for __ARM_ARCH_7A__ as well as
3227 # __ARM_FEATURE_IDIV otherwise it aliases with armv7-a.
3228
3229 proc check_effective_target_arm_arch_v7ve_ok { } {
3230 if { [ string match "*-marm*" "-march=armv7ve" ] &&
3231 ![check_effective_target_arm_arm_ok] } {
3232 return 0
3233 }
3234 return [check_no_compiler_messages arm_arch_v7ve_ok assembly {
3235 #if !defined (__ARM_ARCH_7A__) || !defined (__ARM_FEATURE_IDIV)
3236 #error !armv7ve
3237 #endif
3238 } "-march=armv7ve" ]
3239 }
3240
3241 proc add_options_for_arm_arch_v7ve { flags } {
3242 return "$flags -march=armv7ve"
3243 }
3244
3245 # Return 1 if this is an ARM target where -marm causes ARM to be
3246 # used (not Thumb)
3247
3248 proc check_effective_target_arm_arm_ok { } {
3249 return [check_no_compiler_messages arm_arm_ok assembly {
3250 #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
3251 #error !__arm__ || __thumb__ || __thumb2__
3252 #endif
3253 } "-marm"]
3254 }
3255
3256
3257 # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be
3258 # used.
3259
3260 proc check_effective_target_arm_thumb1_ok { } {
3261 return [check_no_compiler_messages arm_thumb1_ok assembly {
3262 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3263 #error !__arm__ || !__thumb__ || __thumb2__
3264 #endif
3265 int foo (int i) { return i; }
3266 } "-mthumb"]
3267 }
3268
3269 # Return 1 is this is an ARM target where -mthumb causes Thumb-2 to be
3270 # used.
3271
3272 proc check_effective_target_arm_thumb2_ok { } {
3273 return [check_no_compiler_messages arm_thumb2_ok assembly {
3274 #if !defined(__thumb2__)
3275 #error !__thumb2__
3276 #endif
3277 int foo (int i) { return i; }
3278 } "-mthumb"]
3279 }
3280
3281 # Return 1 if this is an ARM target where Thumb-1 is used without options
3282 # added by the test.
3283
3284 proc check_effective_target_arm_thumb1 { } {
3285 return [check_no_compiler_messages arm_thumb1 assembly {
3286 #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
3287 #error !__arm__ || !__thumb__ || __thumb2__
3288 #endif
3289 int i;
3290 } ""]
3291 }
3292
3293 # Return 1 if this is an ARM target where Thumb-2 is used without options
3294 # added by the test.
3295
3296 proc check_effective_target_arm_thumb2 { } {
3297 return [check_no_compiler_messages arm_thumb2 assembly {
3298 #if !defined(__thumb2__)
3299 #error !__thumb2__
3300 #endif
3301 int i;
3302 } ""]
3303 }
3304
3305 # Return 1 if this is an ARM target where conditional execution is available.
3306
3307 proc check_effective_target_arm_cond_exec { } {
3308 return [check_no_compiler_messages arm_cond_exec assembly {
3309 #if defined(__arm__) && defined(__thumb__) && !defined(__thumb2__)
3310 #error FOO
3311 #endif
3312 int i;
3313 } ""]
3314 }
3315
3316 # Return 1 if this is an ARM cortex-M profile cpu
3317
3318 proc check_effective_target_arm_cortex_m { } {
3319 if { ![istarget arm*-*-*] } {
3320 return 0
3321 }
3322 return [check_no_compiler_messages arm_cortex_m assembly {
3323 #if !defined(__ARM_ARCH_7M__) \
3324 && !defined (__ARM_ARCH_7EM__) \
3325 && !defined (__ARM_ARCH_6M__)
3326 #error !__ARM_ARCH_7M__ && !__ARM_ARCH_7EM__ && !__ARM_ARCH_6M__
3327 #endif
3328 int i;
3329 } "-mthumb"]
3330 }
3331
3332 # Return 1 if this compilation turns on string_ops_prefer_neon on.
3333
3334 proc check_effective_target_arm_tune_string_ops_prefer_neon { } {
3335 return [check_no_messages_and_pattern arm_tune_string_ops_prefer_neon "@string_ops_prefer_neon:\t1" assembly {
3336 int foo (void) { return 0; }
3337 } "-O2 -mprint-tune-info" ]
3338 }
3339
3340 # Return 1 if the target supports executing NEON instructions, 0
3341 # otherwise. Cache the result.
3342
3343 proc check_effective_target_arm_neon_hw { } {
3344 return [check_runtime arm_neon_hw_available {
3345 int
3346 main (void)
3347 {
3348 long long a = 0, b = 1;
3349 asm ("vorr %P0, %P1, %P2"
3350 : "=w" (a)
3351 : "0" (a), "w" (b));
3352 return (a != 1);
3353 }
3354 } [add_options_for_arm_neon ""]]
3355 }
3356
3357 proc check_effective_target_arm_neonv2_hw { } {
3358 return [check_runtime arm_neon_hwv2_available {
3359 #include "arm_neon.h"
3360 int
3361 main (void)
3362 {
3363 float32x2_t a, b, c;
3364 asm ("vfma.f32 %P0, %P1, %P2"
3365 : "=w" (a)
3366 : "w" (b), "w" (c));
3367 return 0;
3368 }
3369 } [add_options_for_arm_neonv2 ""]]
3370 }
3371
3372 # Return 1 if the target supports the ARMv8.1 Adv.SIMD extension, 0
3373 # otherwise. The test is valid for AArch64 and ARM. Record the command
3374 # line options needed.
3375
3376 proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
3377 global et_arm_v8_1a_neon_flags
3378 set et_arm_v8_1a_neon_flags ""
3379
3380 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
3381 return 0;
3382 }
3383
3384 # Iterate through sets of options to find the compiler flags that
3385 # need to be added to the -march option. Start with the empty set
3386 # since AArch64 only needs the -march setting.
3387 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
3388 "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
3389 if { [check_no_compiler_messages_nocache arm_v8_1a_neon_ok object {
3390 #if !defined (__ARM_FEATURE_QRDMX)
3391 #error "__ARM_FEATURE_QRDMX not defined"
3392 #endif
3393 } "$flags -march=armv8.1-a"] } {
3394 set et_arm_v8_1a_neon_flags "$flags -march=armv8.1-a"
3395 return 1
3396 }
3397 }
3398
3399 return 0;
3400 }
3401
3402 proc check_effective_target_arm_v8_1a_neon_ok { } {
3403 return [check_cached_effective_target arm_v8_1a_neon_ok \
3404 check_effective_target_arm_v8_1a_neon_ok_nocache]
3405 }
3406
3407 # Return 1 if the target supports executing ARMv8 NEON instructions, 0
3408 # otherwise.
3409
3410 proc check_effective_target_arm_v8_neon_hw { } {
3411 return [check_runtime arm_v8_neon_hw_available {
3412 #include "arm_neon.h"
3413 int
3414 main (void)
3415 {
3416 float32x2_t a;
3417 asm ("vrinta.f32 %P0, %P1"
3418 : "=w" (a)
3419 : "0" (a));
3420 return 0;
3421 }
3422 } [add_options_for_arm_v8_neon ""]]
3423 }
3424
3425 # Return 1 if the target supports executing the ARMv8.1 Adv.SIMD extension, 0
3426 # otherwise. The test is valid for AArch64 and ARM.
3427
3428 proc check_effective_target_arm_v8_1a_neon_hw { } {
3429 if { ![check_effective_target_arm_v8_1a_neon_ok] } {
3430 return 0;
3431 }
3432 return [check_runtime arm_v8_1a_neon_hw_available {
3433 int
3434 main (void)
3435 {
3436 #ifdef __ARM_ARCH_ISA_A64
3437 __Int32x2_t a = {0, 1};
3438 __Int32x2_t b = {0, 2};
3439 __Int32x2_t result;
3440
3441 asm ("sqrdmlah %0.2s, %1.2s, %2.2s"
3442 : "=w"(result)
3443 : "w"(a), "w"(b)
3444 : /* No clobbers. */);
3445
3446 #else
3447
3448 __simd64_int32_t a = {0, 1};
3449 __simd64_int32_t b = {0, 2};
3450 __simd64_int32_t result;
3451
3452 asm ("vqrdmlah.s32 %P0, %P1, %P2"
3453 : "=w"(result)
3454 : "w"(a), "w"(b)
3455 : /* No clobbers. */);
3456 #endif
3457
3458 return result[0];
3459 }
3460 } [add_options_for_arm_v8_1a_neon ""]]
3461 }
3462
3463 # Return 1 if this is a ARM target with NEON enabled.
3464
3465 proc check_effective_target_arm_neon { } {
3466 if { [check_effective_target_arm32] } {
3467 return [check_no_compiler_messages arm_neon object {
3468 #ifndef __ARM_NEON__
3469 #error not NEON
3470 #else
3471 int dummy;
3472 #endif
3473 }]
3474 } else {
3475 return 0
3476 }
3477 }
3478
3479 proc check_effective_target_arm_neonv2 { } {
3480 if { [check_effective_target_arm32] } {
3481 return [check_no_compiler_messages arm_neon object {
3482 #ifndef __ARM_NEON__
3483 #error not NEON
3484 #else
3485 #ifndef __ARM_FEATURE_FMA
3486 #error not NEONv2
3487 #else
3488 int dummy;
3489 #endif
3490 #endif
3491 }]
3492 } else {
3493 return 0
3494 }
3495 }
3496
3497 # Return 1 if this is an ARM target with load acquire and store release
3498 # instructions for 8-, 16- and 32-bit types.
3499
3500 proc check_effective_target_arm_acq_rel { } {
3501 return [check_no_compiler_messages arm_acq_rel object {
3502 void
3503 load_acquire_store_release (void)
3504 {
3505 asm ("lda r0, [r1]\n\t"
3506 "stl r0, [r1]\n\t"
3507 "ldah r0, [r1]\n\t"
3508 "stlh r0, [r1]\n\t"
3509 "ldab r0, [r1]\n\t"
3510 "stlb r0, [r1]"
3511 : : : "r0", "memory");
3512 }
3513 }]
3514 }
3515
3516 # Return 1 if this a Loongson-2E or -2F target using an ABI that supports
3517 # the Loongson vector modes.
3518
3519 proc check_effective_target_mips_loongson { } {
3520 return [check_no_compiler_messages loongson assembly {
3521 #if !defined(__mips_loongson_vector_rev)
3522 #error !__mips_loongson_vector_rev
3523 #endif
3524 }]
3525 }
3526
3527 # Return 1 if this is a MIPS target that supports the legacy NAN.
3528
3529 proc check_effective_target_mips_nanlegacy { } {
3530 return [check_no_compiler_messages nanlegacy assembly {
3531 #include <stdlib.h>
3532 int main () { return 0; }
3533 } "-mnan=legacy"]
3534 }
3535
3536 # Return 1 if this is an ARM target that adheres to the ABI for the ARM
3537 # Architecture.
3538
3539 proc check_effective_target_arm_eabi { } {
3540 return [check_no_compiler_messages arm_eabi object {
3541 #ifndef __ARM_EABI__
3542 #error not EABI
3543 #else
3544 int dummy;
3545 #endif
3546 }]
3547 }
3548
3549 # Return 1 if this is an ARM target that adheres to the hard-float variant of
3550 # the ABI for the ARM Architecture (e.g. -mfloat-abi=hard).
3551
3552 proc check_effective_target_arm_hf_eabi { } {
3553 return [check_no_compiler_messages arm_hf_eabi object {
3554 #if !defined(__ARM_EABI__) || !defined(__ARM_PCS_VFP)
3555 #error not hard-float EABI
3556 #else
3557 int dummy;
3558 #endif
3559 }]
3560 }
3561
3562 # Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
3563 # Some multilibs may be incompatible with this option.
3564
3565 proc check_effective_target_arm_iwmmxt_ok { } {
3566 if { [check_effective_target_arm32] } {
3567 return [check_no_compiler_messages arm_iwmmxt_ok object {
3568 int dummy;
3569 } "-mcpu=iwmmxt"]
3570 } else {
3571 return 0
3572 }
3573 }
3574
3575 # Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
3576 # for an ARM target.
3577 proc check_effective_target_arm_prefer_ldrd_strd { } {
3578 if { ![check_effective_target_arm32] } {
3579 return 0;
3580 }
3581
3582 return [check_no_messages_and_pattern arm_prefer_ldrd_strd "strd\tr" assembly {
3583 void foo (int *p) { p[0] = 1; p[1] = 0;}
3584 } "-O2 -mthumb" ]
3585 }
3586
3587 # Return 1 if this is a PowerPC target supporting -meabi.
3588
3589 proc check_effective_target_powerpc_eabi_ok { } {
3590 if { [istarget powerpc*-*-*] } {
3591 return [check_no_compiler_messages powerpc_eabi_ok object {
3592 int dummy;
3593 } "-meabi"]
3594 } else {
3595 return 0
3596 }
3597 }
3598
3599 # Return 1 if this is a PowerPC target with floating-point registers.
3600
3601 proc check_effective_target_powerpc_fprs { } {
3602 if { [istarget powerpc*-*-*]
3603 || [istarget rs6000-*-*] } {
3604 return [check_no_compiler_messages powerpc_fprs object {
3605 #ifdef __NO_FPRS__
3606 #error no FPRs
3607 #else
3608 int dummy;
3609 #endif
3610 }]
3611 } else {
3612 return 0
3613 }
3614 }
3615
3616 # Return 1 if this is a PowerPC target with hardware double-precision
3617 # floating point.
3618
3619 proc check_effective_target_powerpc_hard_double { } {
3620 if { [istarget powerpc*-*-*]
3621 || [istarget rs6000-*-*] } {
3622 return [check_no_compiler_messages powerpc_hard_double object {
3623 #ifdef _SOFT_DOUBLE
3624 #error soft double
3625 #else
3626 int dummy;
3627 #endif
3628 }]
3629 } else {
3630 return 0
3631 }
3632 }
3633
3634 # Return 1 if this is a PowerPC target supporting -maltivec.
3635
3636 proc check_effective_target_powerpc_altivec_ok { } {
3637 if { ([istarget powerpc*-*-*]
3638 && ![istarget powerpc-*-linux*paired*])
3639 || [istarget rs6000-*-*] } {
3640 # AltiVec is not supported on AIX before 5.3.
3641 if { [istarget powerpc*-*-aix4*]
3642 || [istarget powerpc*-*-aix5.1*]
3643 || [istarget powerpc*-*-aix5.2*] } {
3644 return 0
3645 }
3646 return [check_no_compiler_messages powerpc_altivec_ok object {
3647 int dummy;
3648 } "-maltivec"]
3649 } else {
3650 return 0
3651 }
3652 }
3653
3654 # Return 1 if this is a PowerPC target supporting -mpower8-vector
3655
3656 proc check_effective_target_powerpc_p8vector_ok { } {
3657 if { ([istarget powerpc*-*-*]
3658 && ![istarget powerpc-*-linux*paired*])
3659 || [istarget rs6000-*-*] } {
3660 # AltiVec is not supported on AIX before 5.3.
3661 if { [istarget powerpc*-*-aix4*]
3662 || [istarget powerpc*-*-aix5.1*]
3663 || [istarget powerpc*-*-aix5.2*] } {
3664 return 0
3665 }
3666 return [check_no_compiler_messages powerpc_p8vector_ok object {
3667 int main (void) {
3668 #ifdef __MACH__
3669 asm volatile ("xxlorc vs0,vs0,vs0");
3670 #else
3671 asm volatile ("xxlorc 0,0,0");
3672 #endif
3673 return 0;
3674 }
3675 } "-mpower8-vector"]
3676 } else {
3677 return 0
3678 }
3679 }
3680
3681 # Return 1 if this is a PowerPC target supporting -mpower9-vector
3682
3683 proc check_effective_target_powerpc_p9vector_ok { } {
3684 if { ([istarget powerpc*-*-*]
3685 && ![istarget powerpc-*-linux*paired*])
3686 || [istarget rs6000-*-*] } {
3687 # AltiVec is not supported on AIX before 5.3.
3688 if { [istarget powerpc*-*-aix4*]
3689 || [istarget powerpc*-*-aix5.1*]
3690 || [istarget powerpc*-*-aix5.2*] } {
3691 return 0
3692 }
3693 return [check_no_compiler_messages powerpc_p9vector_ok object {
3694 int main (void) {
3695 long e = -1;
3696 vector double v = (vector double) { 0.0, 0.0 };
3697 asm ("xsxexpdp %0,%1" : "+r" (e) : "wa" (v));
3698 return e;
3699 }
3700 } "-mpower9-vector"]
3701 } else {
3702 return 0
3703 }
3704 }
3705
3706 # Return 1 if this is a PowerPC target supporting -mmodulo
3707
3708 proc check_effective_target_powerpc_p9modulo_ok { } {
3709 if { ([istarget powerpc*-*-*]
3710 && ![istarget powerpc-*-linux*paired*])
3711 || [istarget rs6000-*-*] } {
3712 # AltiVec is not supported on AIX before 5.3.
3713 if { [istarget powerpc*-*-aix4*]
3714 || [istarget powerpc*-*-aix5.1*]
3715 || [istarget powerpc*-*-aix5.2*] } {
3716 return 0
3717 }
3718 return [check_no_compiler_messages powerpc_p9modulo_ok object {
3719 int main (void) {
3720 int i = 5, j = 3, r = -1;
3721 asm ("modsw %0,%1,%2" : "+r" (r) : "r" (i), "r" (j));
3722 return (r == 2);
3723 }
3724 } "-mmodulo"]
3725 } else {
3726 return 0
3727 }
3728 }
3729
3730 # Return 1 if this is a PowerPC target supporting -mfloat128 via either
3731 # software emulation on power7/power8 systems or hardware support on power9.
3732
3733 proc check_effective_target_powerpc_float128_sw_ok { } {
3734 if { ([istarget powerpc*-*-*]
3735 && ![istarget powerpc-*-linux*paired*])
3736 || [istarget rs6000-*-*] } {
3737 # AltiVec is not supported on AIX before 5.3.
3738 if { [istarget powerpc*-*-aix4*]
3739 || [istarget powerpc*-*-aix5.1*]
3740 || [istarget powerpc*-*-aix5.2*] } {
3741 return 0
3742 }
3743 return [check_no_compiler_messages powerpc_float128_sw_ok object {
3744 volatile __float128 x = 1.0q;
3745 volatile __float128 y = 2.0q;
3746 int main() {
3747 __float128 z = x + y;
3748 return (z == 3.0q);
3749 }
3750 } "-mfloat128 -mvsx"]
3751 } else {
3752 return 0
3753 }
3754 }
3755
3756 # Return 1 if this is a PowerPC target supporting -mfloat128 via hardware
3757 # support on power9.
3758
3759 proc check_effective_target_powerpc_float128_hw_ok { } {
3760 if { ([istarget powerpc*-*-*]
3761 && ![istarget powerpc-*-linux*paired*])
3762 || [istarget rs6000-*-*] } {
3763 # AltiVec is not supported on AIX before 5.3.
3764 if { [istarget powerpc*-*-aix4*]
3765 || [istarget powerpc*-*-aix5.1*]
3766 || [istarget powerpc*-*-aix5.2*] } {
3767 return 0
3768 }
3769 return [check_no_compiler_messages powerpc_float128_hw_ok object {
3770 volatile __float128 x = 1.0q;
3771 volatile __float128 y = 2.0q;
3772 int main() {
3773 __float128 z;
3774 __asm__ ("xsaddqp %0,%1,%2" : "=v" (z) : "v" (x), "v" (y));
3775 return (z == 3.0q);
3776 }
3777 } "-mfloat128-hardware"]
3778 } else {
3779 return 0
3780 }
3781 }
3782
3783 # Return 1 if this is a PowerPC target supporting -mvsx
3784
3785 proc check_effective_target_powerpc_vsx_ok { } {
3786 if { ([istarget powerpc*-*-*]
3787 && ![istarget powerpc-*-linux*paired*])
3788 || [istarget rs6000-*-*] } {
3789 # VSX is not supported on AIX before 7.1.
3790 if { [istarget powerpc*-*-aix4*]
3791 || [istarget powerpc*-*-aix5*]
3792 || [istarget powerpc*-*-aix6*] } {
3793 return 0
3794 }
3795 return [check_no_compiler_messages powerpc_vsx_ok object {
3796 int main (void) {
3797 #ifdef __MACH__
3798 asm volatile ("xxlor vs0,vs0,vs0");
3799 #else
3800 asm volatile ("xxlor 0,0,0");
3801 #endif
3802 return 0;
3803 }
3804 } "-mvsx"]
3805 } else {
3806 return 0
3807 }
3808 }
3809
3810 # Return 1 if this is a PowerPC target supporting -mhtm
3811
3812 proc check_effective_target_powerpc_htm_ok { } {
3813 if { ([istarget powerpc*-*-*]
3814 && ![istarget powerpc-*-linux*paired*])
3815 || [istarget rs6000-*-*] } {
3816 # HTM is not supported on AIX yet.
3817 if { [istarget powerpc*-*-aix*] } {
3818 return 0
3819 }
3820 return [check_no_compiler_messages powerpc_htm_ok object {
3821 int main (void) {
3822 asm volatile ("tbegin. 0");
3823 return 0;
3824 }
3825 } "-mhtm"]
3826 } else {
3827 return 0
3828 }
3829 }
3830
3831 # Return 1 if the target supports executing HTM hardware instructions,
3832 # 0 otherwise. Cache the result.
3833
3834 proc check_htm_hw_available { } {
3835 return [check_cached_effective_target htm_hw_available {
3836 # For now, disable on Darwin
3837 if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
3838 expr 0
3839 } else {
3840 check_runtime_nocache htm_hw_available {
3841 int main()
3842 {
3843 __builtin_ttest ();
3844 return 0;
3845 }
3846 } "-mhtm"
3847 }
3848 }]
3849 }
3850 # Return 1 if this is a PowerPC target supporting -mcpu=cell.
3851
3852 proc check_effective_target_powerpc_ppu_ok { } {
3853 if [check_effective_target_powerpc_altivec_ok] {
3854 return [check_no_compiler_messages cell_asm_available object {
3855 int main (void) {
3856 #ifdef __MACH__
3857 asm volatile ("lvlx v0,v0,v0");
3858 #else
3859 asm volatile ("lvlx 0,0,0");
3860 #endif
3861 return 0;
3862 }
3863 }]
3864 } else {
3865 return 0
3866 }
3867 }
3868
3869 # Return 1 if this is a PowerPC target that supports SPU.
3870
3871 proc check_effective_target_powerpc_spu { } {
3872 if { [istarget powerpc*-*-linux*] } {
3873 return [check_effective_target_powerpc_altivec_ok]
3874 } else {
3875 return 0
3876 }
3877 }
3878
3879 # Return 1 if this is a PowerPC SPE target. The check includes options
3880 # specified by dg-options for this test, so don't cache the result.
3881
3882 proc check_effective_target_powerpc_spe_nocache { } {
3883 if { [istarget powerpc*-*-*] } {
3884 return [check_no_compiler_messages_nocache powerpc_spe object {
3885 #ifndef __SPE__
3886 #error not SPE
3887 #else
3888 int dummy;
3889 #endif
3890 } [current_compiler_flags]]
3891 } else {
3892 return 0
3893 }
3894 }
3895
3896 # Return 1 if this is a PowerPC target with SPE enabled.
3897
3898 proc check_effective_target_powerpc_spe { } {
3899 if { [istarget powerpc*-*-*] } {
3900 return [check_no_compiler_messages powerpc_spe object {
3901 #ifndef __SPE__
3902 #error not SPE
3903 #else
3904 int dummy;
3905 #endif
3906 }]
3907 } else {
3908 return 0
3909 }
3910 }
3911
3912 # Return 1 if this is a PowerPC target with Altivec enabled.
3913
3914 proc check_effective_target_powerpc_altivec { } {
3915 if { [istarget powerpc*-*-*] } {
3916 return [check_no_compiler_messages powerpc_altivec object {
3917 #ifndef __ALTIVEC__
3918 #error not Altivec
3919 #else
3920 int dummy;
3921 #endif
3922 }]
3923 } else {
3924 return 0
3925 }
3926 }
3927
3928 # Return 1 if this is a PowerPC 405 target. The check includes options
3929 # specified by dg-options for this test, so don't cache the result.
3930
3931 proc check_effective_target_powerpc_405_nocache { } {
3932 if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } {
3933 return [check_no_compiler_messages_nocache powerpc_405 object {
3934 #ifdef __PPC405__
3935 int dummy;
3936 #else
3937 #error not a PPC405
3938 #endif
3939 } [current_compiler_flags]]
3940 } else {
3941 return 0
3942 }
3943 }
3944
3945 # Return 1 if this is a PowerPC target using the ELFv2 ABI.
3946
3947 proc check_effective_target_powerpc_elfv2 { } {
3948 if { [istarget powerpc*-*-*] } {
3949 return [check_no_compiler_messages powerpc_elfv2 object {
3950 #if _CALL_ELF != 2
3951 #error not ELF v2 ABI
3952 #else
3953 int dummy;
3954 #endif
3955 }]
3956 } else {
3957 return 0
3958 }
3959 }
3960
3961 # Return 1 if this is a SPU target with a toolchain that
3962 # supports automatic overlay generation.
3963
3964 proc check_effective_target_spu_auto_overlay { } {
3965 if { [istarget spu*-*-elf*] } {
3966 return [check_no_compiler_messages spu_auto_overlay executable {
3967 int main (void) { }
3968 } "-Wl,--auto-overlay" ]
3969 } else {
3970 return 0
3971 }
3972 }
3973
3974 # The VxWorks SPARC simulator accepts only EM_SPARC executables and
3975 # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the
3976 # test environment appears to run executables on such a simulator.
3977
3978 proc check_effective_target_ultrasparc_hw { } {
3979 return [check_runtime ultrasparc_hw {
3980 int main() { return 0; }
3981 } "-mcpu=ultrasparc"]
3982 }
3983
3984 # Return 1 if the test environment supports executing UltraSPARC VIS2
3985 # instructions. We check this by attempting: "bmask %g0, %g0, %g0"
3986
3987 proc check_effective_target_ultrasparc_vis2_hw { } {
3988 return [check_runtime ultrasparc_vis2_hw {
3989 int main() { __asm__(".word 0x81b00320"); return 0; }
3990 } "-mcpu=ultrasparc3"]
3991 }
3992
3993 # Return 1 if the test environment supports executing UltraSPARC VIS3
3994 # instructions. We check this by attempting: "addxc %g0, %g0, %g0"
3995
3996 proc check_effective_target_ultrasparc_vis3_hw { } {
3997 return [check_runtime ultrasparc_vis3_hw {
3998 int main() { __asm__(".word 0x81b00220"); return 0; }
3999 } "-mcpu=niagara3"]
4000 }
4001
4002 # Return 1 if this is a SPARC-V9 target.
4003
4004 proc check_effective_target_sparc_v9 { } {
4005 if { [istarget sparc*-*-*] } {
4006 return [check_no_compiler_messages sparc_v9 object {
4007 int main (void) {
4008 asm volatile ("return %i7+8");
4009 return 0;
4010 }
4011 }]
4012 } else {
4013 return 0
4014 }
4015 }
4016
4017 # Return 1 if this is a SPARC target with VIS enabled.
4018
4019 proc check_effective_target_sparc_vis { } {
4020 if { [istarget sparc*-*-*] } {
4021 return [check_no_compiler_messages sparc_vis object {
4022 #ifndef __VIS__
4023 #error not VIS
4024 #else
4025 int dummy;
4026 #endif
4027 }]
4028 } else {
4029 return 0
4030 }
4031 }
4032
4033 # Return 1 if the target supports hardware vector shift operation.
4034
4035 proc check_effective_target_vect_shift { } {
4036 global et_vect_shift_saved
4037
4038 if [info exists et_vect_shift_saved] {
4039 verbose "check_effective_target_vect_shift: using cached result" 2
4040 } else {
4041 set et_vect_shift_saved 0
4042 if { ([istarget powerpc*-*-*]
4043 && ![istarget powerpc-*-linux*paired*])
4044 || [istarget ia64-*-*]
4045 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4046 || [istarget aarch64*-*-*]
4047 || [check_effective_target_arm32]
4048 || ([istarget mips*-*-*]
4049 && [check_effective_target_mips_loongson]) } {
4050 set et_vect_shift_saved 1
4051 }
4052 }
4053
4054 verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2
4055 return $et_vect_shift_saved
4056 }
4057
4058 proc check_effective_target_whole_vector_shift { } {
4059 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4060 || [istarget ia64-*-*]
4061 || [istarget aarch64*-*-*]
4062 || [istarget powerpc64*-*-*]
4063 || ([check_effective_target_arm32]
4064 && [check_effective_target_arm_little_endian])
4065 || ([istarget mips*-*-*]
4066 && [check_effective_target_mips_loongson]) } {
4067 set answer 1
4068 } else {
4069 set answer 0
4070 }
4071
4072 verbose "check_effective_target_vect_long: returning $answer" 2
4073 return $answer
4074 }
4075
4076 # Return 1 if the target supports vector bswap operations.
4077
4078 proc check_effective_target_vect_bswap { } {
4079 global et_vect_bswap_saved
4080
4081 if [info exists et_vect_bswap_saved] {
4082 verbose "check_effective_target_vect_bswap: using cached result" 2
4083 } else {
4084 set et_vect_bswap_saved 0
4085 if { [istarget aarch64*-*-*]
4086 || ([istarget arm*-*-*]
4087 && [check_effective_target_arm_neon])
4088 } {
4089 set et_vect_bswap_saved 1
4090 }
4091 }
4092
4093 verbose "check_effective_target_vect_bswap: returning $et_vect_bswap_saved" 2
4094 return $et_vect_bswap_saved
4095 }
4096
4097 # Return 1 if the target supports hardware vector shift operation for char.
4098
4099 proc check_effective_target_vect_shift_char { } {
4100 global et_vect_shift_char_saved
4101
4102 if [info exists et_vect_shift_char_saved] {
4103 verbose "check_effective_target_vect_shift_char: using cached result" 2
4104 } else {
4105 set et_vect_shift_char_saved 0
4106 if { ([istarget powerpc*-*-*]
4107 && ![istarget powerpc-*-linux*paired*])
4108 || [check_effective_target_arm32] } {
4109 set et_vect_shift_char_saved 1
4110 }
4111 }
4112
4113 verbose "check_effective_target_vect_shift_char: returning $et_vect_shift_char_saved" 2
4114 return $et_vect_shift_char_saved
4115 }
4116
4117 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
4118 #
4119 # This can change for different subtargets so do not cache the result.
4120
4121 proc check_effective_target_vect_long { } {
4122 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4123 || (([istarget powerpc*-*-*]
4124 && ![istarget powerpc-*-linux*paired*])
4125 && [check_effective_target_ilp32])
4126 || [check_effective_target_arm32]
4127 || ([istarget sparc*-*-*] && [check_effective_target_ilp32])
4128 || [istarget aarch64*-*-*] } {
4129 set answer 1
4130 } else {
4131 set answer 0
4132 }
4133
4134 verbose "check_effective_target_vect_long: returning $answer" 2
4135 return $answer
4136 }
4137
4138 # Return 1 if the target supports hardware vectors of float, 0 otherwise.
4139 #
4140 # This won't change for different subtargets so cache the result.
4141
4142 proc check_effective_target_vect_float { } {
4143 global et_vect_float_saved
4144
4145 if [info exists et_vect_float_saved] {
4146 verbose "check_effective_target_vect_float: using cached result" 2
4147 } else {
4148 set et_vect_float_saved 0
4149 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4150 || [istarget powerpc*-*-*]
4151 || [istarget spu-*-*]
4152 || [istarget mips-sde-elf]
4153 || [istarget mipsisa64*-*-*]
4154 || [istarget ia64-*-*]
4155 || [istarget aarch64*-*-*]
4156 || [check_effective_target_arm32] } {
4157 set et_vect_float_saved 1
4158 }
4159 }
4160
4161 verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2
4162 return $et_vect_float_saved
4163 }
4164
4165 # Return 1 if the target supports hardware vectors of double, 0 otherwise.
4166 #
4167 # This won't change for different subtargets so cache the result.
4168
4169 proc check_effective_target_vect_double { } {
4170 global et_vect_double_saved
4171
4172 if [info exists et_vect_double_saved] {
4173 verbose "check_effective_target_vect_double: using cached result" 2
4174 } else {
4175 set et_vect_double_saved 0
4176 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4177 || [istarget aarch64*-*-*] } {
4178 if { [check_no_compiler_messages vect_double assembly {
4179 #ifdef __tune_atom__
4180 # error No double vectorizer support.
4181 #endif
4182 }] } {
4183 set et_vect_double_saved 1
4184 } else {
4185 set et_vect_double_saved 0
4186 }
4187 } elseif { [istarget spu-*-*] } {
4188 set et_vect_double_saved 1
4189 } elseif { [istarget powerpc*-*-*] && [check_vsx_hw_available] } {
4190 set et_vect_double_saved 1
4191 }
4192 }
4193
4194 verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2
4195 return $et_vect_double_saved
4196 }
4197
4198 # Return 1 if the target supports hardware vectors of long long, 0 otherwise.
4199 #
4200 # This won't change for different subtargets so cache the result.
4201
4202 proc check_effective_target_vect_long_long { } {
4203 global et_vect_long_long_saved
4204
4205 if [info exists et_vect_long_long_saved] {
4206 verbose "check_effective_target_vect_long_long: using cached result" 2
4207 } else {
4208 set et_vect_long_long_saved 0
4209 if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4210 set et_vect_long_long_saved 1
4211 }
4212 }
4213
4214 verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2
4215 return $et_vect_long_long_saved
4216 }
4217
4218
4219 # Return 1 if the target plus current options does not support a vector
4220 # max instruction on "int", 0 otherwise.
4221 #
4222 # This won't change for different subtargets so cache the result.
4223
4224 proc check_effective_target_vect_no_int_min_max { } {
4225 global et_vect_no_int_min_max_saved
4226
4227 if [info exists et_vect_no_int_min_max_saved] {
4228 verbose "check_effective_target_vect_no_int_min_max: using cached result" 2
4229 } else {
4230 set et_vect_no_int_min_max_saved 0
4231 if { [istarget sparc*-*-*]
4232 || [istarget spu-*-*]
4233 || [istarget alpha*-*-*]
4234 || ([istarget mips*-*-*]
4235 && [check_effective_target_mips_loongson]) } {
4236 set et_vect_no_int_min_max_saved 1
4237 }
4238 }
4239 verbose "check_effective_target_vect_no_int_min_max: returning $et_vect_no_int_min_max_saved" 2
4240 return $et_vect_no_int_min_max_saved
4241 }
4242
4243 # Return 1 if the target plus current options does not support a vector
4244 # add instruction on "int", 0 otherwise.
4245 #
4246 # This won't change for different subtargets so cache the result.
4247
4248 proc check_effective_target_vect_no_int_add { } {
4249 global et_vect_no_int_add_saved
4250
4251 if [info exists et_vect_no_int_add_saved] {
4252 verbose "check_effective_target_vect_no_int_add: using cached result" 2
4253 } else {
4254 set et_vect_no_int_add_saved 0
4255 # Alpha only supports vector add on V8QI and V4HI.
4256 if { [istarget alpha*-*-*] } {
4257 set et_vect_no_int_add_saved 1
4258 }
4259 }
4260 verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2
4261 return $et_vect_no_int_add_saved
4262 }
4263
4264 # Return 1 if the target plus current options does not support vector
4265 # bitwise instructions, 0 otherwise.
4266 #
4267 # This won't change for different subtargets so cache the result.
4268
4269 proc check_effective_target_vect_no_bitwise { } {
4270 global et_vect_no_bitwise_saved
4271
4272 if [info exists et_vect_no_bitwise_saved] {
4273 verbose "check_effective_target_vect_no_bitwise: using cached result" 2
4274 } else {
4275 set et_vect_no_bitwise_saved 0
4276 }
4277 verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2
4278 return $et_vect_no_bitwise_saved
4279 }
4280
4281 # Return 1 if the target plus current options supports vector permutation,
4282 # 0 otherwise.
4283 #
4284 # This won't change for different subtargets so cache the result.
4285
4286 proc check_effective_target_vect_perm { } {
4287 global et_vect_perm
4288
4289 if [info exists et_vect_perm_saved] {
4290 verbose "check_effective_target_vect_perm: using cached result" 2
4291 } else {
4292 set et_vect_perm_saved 0
4293 if { [is-effective-target arm_neon_ok]
4294 || [istarget aarch64*-*-*]
4295 || [istarget powerpc*-*-*]
4296 || [istarget spu-*-*]
4297 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4298 || ([istarget mips*-*-*]
4299 && [check_effective_target_mpaired_single]) } {
4300 set et_vect_perm_saved 1
4301 }
4302 }
4303 verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2
4304 return $et_vect_perm_saved
4305 }
4306
4307 # Return 1 if the target plus current options supports vector permutation
4308 # on byte-sized elements, 0 otherwise.
4309 #
4310 # This won't change for different subtargets so cache the result.
4311
4312 proc check_effective_target_vect_perm_byte { } {
4313 global et_vect_perm_byte
4314
4315 if [info exists et_vect_perm_byte_saved] {
4316 verbose "check_effective_target_vect_perm_byte: using cached result" 2
4317 } else {
4318 set et_vect_perm_byte_saved 0
4319 if { ([is-effective-target arm_neon_ok]
4320 && [is-effective-target arm_little_endian])
4321 || ([istarget aarch64*-*-*]
4322 && [is-effective-target aarch64_little_endian])
4323 || [istarget powerpc*-*-*]
4324 || [istarget spu-*-*] } {
4325 set et_vect_perm_byte_saved 1
4326 }
4327 }
4328 verbose "check_effective_target_vect_perm_byte: returning $et_vect_perm_byte_saved" 2
4329 return $et_vect_perm_byte_saved
4330 }
4331
4332 # Return 1 if the target plus current options supports vector permutation
4333 # on short-sized elements, 0 otherwise.
4334 #
4335 # This won't change for different subtargets so cache the result.
4336
4337 proc check_effective_target_vect_perm_short { } {
4338 global et_vect_perm_short
4339
4340 if [info exists et_vect_perm_short_saved] {
4341 verbose "check_effective_target_vect_perm_short: using cached result" 2
4342 } else {
4343 set et_vect_perm_short_saved 0
4344 if { ([is-effective-target arm_neon_ok]
4345 && [is-effective-target arm_little_endian])
4346 || ([istarget aarch64*-*-*]
4347 && [is-effective-target aarch64_little_endian])
4348 || [istarget powerpc*-*-*]
4349 || [istarget spu-*-*] } {
4350 set et_vect_perm_short_saved 1
4351 }
4352 }
4353 verbose "check_effective_target_vect_perm_short: returning $et_vect_perm_short_saved" 2
4354 return $et_vect_perm_short_saved
4355 }
4356
4357 # Return 1 if the target plus current options supports a vector
4358 # widening summation of *short* args into *int* result, 0 otherwise.
4359 #
4360 # This won't change for different subtargets so cache the result.
4361
4362 proc check_effective_target_vect_widen_sum_hi_to_si_pattern { } {
4363 global et_vect_widen_sum_hi_to_si_pattern
4364
4365 if [info exists et_vect_widen_sum_hi_to_si_pattern_saved] {
4366 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: using cached result" 2
4367 } else {
4368 set et_vect_widen_sum_hi_to_si_pattern_saved 0
4369 if { [istarget powerpc*-*-*]
4370 || [istarget aarch64*-*-*]
4371 || ([istarget arm*-*-*] &&
4372 [check_effective_target_arm_neon_ok])
4373 || [istarget ia64-*-*] } {
4374 set et_vect_widen_sum_hi_to_si_pattern_saved 1
4375 }
4376 }
4377 verbose "check_effective_target_vect_widen_sum_hi_to_si_pattern: returning $et_vect_widen_sum_hi_to_si_pattern_saved" 2
4378 return $et_vect_widen_sum_hi_to_si_pattern_saved
4379 }
4380
4381 # Return 1 if the target plus current options supports a vector
4382 # widening summation of *short* args into *int* result, 0 otherwise.
4383 # A target can also support this widening summation if it can support
4384 # promotion (unpacking) from shorts to ints.
4385 #
4386 # This won't change for different subtargets so cache the result.
4387
4388 proc check_effective_target_vect_widen_sum_hi_to_si { } {
4389 global et_vect_widen_sum_hi_to_si
4390
4391 if [info exists et_vect_widen_sum_hi_to_si_saved] {
4392 verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2
4393 } else {
4394 set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack]
4395 if { [istarget powerpc*-*-*]
4396 || [istarget ia64-*-*] } {
4397 set et_vect_widen_sum_hi_to_si_saved 1
4398 }
4399 }
4400 verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2
4401 return $et_vect_widen_sum_hi_to_si_saved
4402 }
4403
4404 # Return 1 if the target plus current options supports a vector
4405 # widening summation of *char* args into *short* result, 0 otherwise.
4406 # A target can also support this widening summation if it can support
4407 # promotion (unpacking) from chars to shorts.
4408 #
4409 # This won't change for different subtargets so cache the result.
4410
4411 proc check_effective_target_vect_widen_sum_qi_to_hi { } {
4412 global et_vect_widen_sum_qi_to_hi
4413
4414 if [info exists et_vect_widen_sum_qi_to_hi_saved] {
4415 verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2
4416 } else {
4417 set et_vect_widen_sum_qi_to_hi_saved 0
4418 if { [check_effective_target_vect_unpack]
4419 || [check_effective_target_arm_neon_ok]
4420 || [istarget ia64-*-*] } {
4421 set et_vect_widen_sum_qi_to_hi_saved 1
4422 }
4423 }
4424 verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2
4425 return $et_vect_widen_sum_qi_to_hi_saved
4426 }
4427
4428 # Return 1 if the target plus current options supports a vector
4429 # widening summation of *char* args into *int* result, 0 otherwise.
4430 #
4431 # This won't change for different subtargets so cache the result.
4432
4433 proc check_effective_target_vect_widen_sum_qi_to_si { } {
4434 global et_vect_widen_sum_qi_to_si
4435
4436 if [info exists et_vect_widen_sum_qi_to_si_saved] {
4437 verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2
4438 } else {
4439 set et_vect_widen_sum_qi_to_si_saved 0
4440 if { [istarget powerpc*-*-*] } {
4441 set et_vect_widen_sum_qi_to_si_saved 1
4442 }
4443 }
4444 verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2
4445 return $et_vect_widen_sum_qi_to_si_saved
4446 }
4447
4448 # Return 1 if the target plus current options supports a vector
4449 # widening multiplication of *char* args into *short* result, 0 otherwise.
4450 # A target can also support this widening multplication if it can support
4451 # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening
4452 # multiplication of shorts).
4453 #
4454 # This won't change for different subtargets so cache the result.
4455
4456
4457 proc check_effective_target_vect_widen_mult_qi_to_hi { } {
4458 global et_vect_widen_mult_qi_to_hi
4459
4460 if [info exists et_vect_widen_mult_qi_to_hi_saved] {
4461 verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2
4462 } else {
4463 if { [check_effective_target_vect_unpack]
4464 && [check_effective_target_vect_short_mult] } {
4465 set et_vect_widen_mult_qi_to_hi_saved 1
4466 } else {
4467 set et_vect_widen_mult_qi_to_hi_saved 0
4468 }
4469 if { [istarget powerpc*-*-*]
4470 || [istarget aarch64*-*-*]
4471 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4472 set et_vect_widen_mult_qi_to_hi_saved 1
4473 }
4474 }
4475 verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2
4476 return $et_vect_widen_mult_qi_to_hi_saved
4477 }
4478
4479 # Return 1 if the target plus current options supports a vector
4480 # widening multiplication of *short* args into *int* result, 0 otherwise.
4481 # A target can also support this widening multplication if it can support
4482 # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening
4483 # multiplication of ints).
4484 #
4485 # This won't change for different subtargets so cache the result.
4486
4487
4488 proc check_effective_target_vect_widen_mult_hi_to_si { } {
4489 global et_vect_widen_mult_hi_to_si
4490
4491 if [info exists et_vect_widen_mult_hi_to_si_saved] {
4492 verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2
4493 } else {
4494 if { [check_effective_target_vect_unpack]
4495 && [check_effective_target_vect_int_mult] } {
4496 set et_vect_widen_mult_hi_to_si_saved 1
4497 } else {
4498 set et_vect_widen_mult_hi_to_si_saved 0
4499 }
4500 if { [istarget powerpc*-*-*]
4501 || [istarget spu-*-*]
4502 || [istarget ia64-*-*]
4503 || [istarget aarch64*-*-*]
4504 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4505 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4506 set et_vect_widen_mult_hi_to_si_saved 1
4507 }
4508 }
4509 verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2
4510 return $et_vect_widen_mult_hi_to_si_saved
4511 }
4512
4513 # Return 1 if the target plus current options supports a vector
4514 # widening multiplication of *char* args into *short* result, 0 otherwise.
4515 #
4516 # This won't change for different subtargets so cache the result.
4517
4518 proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
4519 global et_vect_widen_mult_qi_to_hi_pattern
4520
4521 if [info exists et_vect_widen_mult_qi_to_hi_pattern_saved] {
4522 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: using cached result" 2
4523 } else {
4524 set et_vect_widen_mult_qi_to_hi_pattern_saved 0
4525 if { [istarget powerpc*-*-*]
4526 || ([istarget arm*-*-*]
4527 && [check_effective_target_arm_neon_ok]
4528 && [check_effective_target_arm_little_endian]) } {
4529 set et_vect_widen_mult_qi_to_hi_pattern_saved 1
4530 }
4531 }
4532 verbose "check_effective_target_vect_widen_mult_qi_to_hi_pattern: returning $et_vect_widen_mult_qi_to_hi_pattern_saved" 2
4533 return $et_vect_widen_mult_qi_to_hi_pattern_saved
4534 }
4535
4536 # Return 1 if the target plus current options supports a vector
4537 # widening multiplication of *short* args into *int* result, 0 otherwise.
4538 #
4539 # This won't change for different subtargets so cache the result.
4540
4541 proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
4542 global et_vect_widen_mult_hi_to_si_pattern
4543
4544 if [info exists et_vect_widen_mult_hi_to_si_pattern_saved] {
4545 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: using cached result" 2
4546 } else {
4547 set et_vect_widen_mult_hi_to_si_pattern_saved 0
4548 if { [istarget powerpc*-*-*]
4549 || [istarget spu-*-*]
4550 || [istarget ia64-*-*]
4551 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4552 || ([istarget arm*-*-*]
4553 && [check_effective_target_arm_neon_ok]
4554 && [check_effective_target_arm_little_endian]) } {
4555 set et_vect_widen_mult_hi_to_si_pattern_saved 1
4556 }
4557 }
4558 verbose "check_effective_target_vect_widen_mult_hi_to_si_pattern: returning $et_vect_widen_mult_hi_to_si_pattern_saved" 2
4559 return $et_vect_widen_mult_hi_to_si_pattern_saved
4560 }
4561
4562 # Return 1 if the target plus current options supports a vector
4563 # widening multiplication of *int* args into *long* result, 0 otherwise.
4564 #
4565 # This won't change for different subtargets so cache the result.
4566
4567 proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
4568 global et_vect_widen_mult_si_to_di_pattern
4569
4570 if [info exists et_vect_widen_mult_si_to_di_pattern_saved] {
4571 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: using cached result" 2
4572 } else {
4573 set et_vect_widen_mult_si_to_di_pattern_saved 0
4574 if {[istarget ia64-*-*]
4575 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4576 set et_vect_widen_mult_si_to_di_pattern_saved 1
4577 }
4578 }
4579 verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: returning $et_vect_widen_mult_si_to_di_pattern_saved" 2
4580 return $et_vect_widen_mult_si_to_di_pattern_saved
4581 }
4582
4583 # Return 1 if the target plus current options supports a vector
4584 # widening shift, 0 otherwise.
4585 #
4586 # This won't change for different subtargets so cache the result.
4587
4588 proc check_effective_target_vect_widen_shift { } {
4589 global et_vect_widen_shift_saved
4590
4591 if [info exists et_vect_shift_saved] {
4592 verbose "check_effective_target_vect_widen_shift: using cached result" 2
4593 } else {
4594 set et_vect_widen_shift_saved 0
4595 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
4596 set et_vect_widen_shift_saved 1
4597 }
4598 }
4599 verbose "check_effective_target_vect_widen_shift: returning $et_vect_widen_shift_saved" 2
4600 return $et_vect_widen_shift_saved
4601 }
4602
4603 # Return 1 if the target plus current options supports a vector
4604 # dot-product of signed chars, 0 otherwise.
4605 #
4606 # This won't change for different subtargets so cache the result.
4607
4608 proc check_effective_target_vect_sdot_qi { } {
4609 global et_vect_sdot_qi
4610
4611 if [info exists et_vect_sdot_qi_saved] {
4612 verbose "check_effective_target_vect_sdot_qi: using cached result" 2
4613 } else {
4614 set et_vect_sdot_qi_saved 0
4615 if { [istarget ia64-*-*] } {
4616 set et_vect_udot_qi_saved 1
4617 }
4618 }
4619 verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2
4620 return $et_vect_sdot_qi_saved
4621 }
4622
4623 # Return 1 if the target plus current options supports a vector
4624 # dot-product of unsigned chars, 0 otherwise.
4625 #
4626 # This won't change for different subtargets so cache the result.
4627
4628 proc check_effective_target_vect_udot_qi { } {
4629 global et_vect_udot_qi
4630
4631 if [info exists et_vect_udot_qi_saved] {
4632 verbose "check_effective_target_vect_udot_qi: using cached result" 2
4633 } else {
4634 set et_vect_udot_qi_saved 0
4635 if { [istarget powerpc*-*-*]
4636 || [istarget ia64-*-*] } {
4637 set et_vect_udot_qi_saved 1
4638 }
4639 }
4640 verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2
4641 return $et_vect_udot_qi_saved
4642 }
4643
4644 # Return 1 if the target plus current options supports a vector
4645 # dot-product of signed shorts, 0 otherwise.
4646 #
4647 # This won't change for different subtargets so cache the result.
4648
4649 proc check_effective_target_vect_sdot_hi { } {
4650 global et_vect_sdot_hi
4651
4652 if [info exists et_vect_sdot_hi_saved] {
4653 verbose "check_effective_target_vect_sdot_hi: using cached result" 2
4654 } else {
4655 set et_vect_sdot_hi_saved 0
4656 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4657 || [istarget ia64-*-*]
4658 || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
4659 set et_vect_sdot_hi_saved 1
4660 }
4661 }
4662 verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2
4663 return $et_vect_sdot_hi_saved
4664 }
4665
4666 # Return 1 if the target plus current options supports a vector
4667 # dot-product of unsigned shorts, 0 otherwise.
4668 #
4669 # This won't change for different subtargets so cache the result.
4670
4671 proc check_effective_target_vect_udot_hi { } {
4672 global et_vect_udot_hi
4673
4674 if [info exists et_vect_udot_hi_saved] {
4675 verbose "check_effective_target_vect_udot_hi: using cached result" 2
4676 } else {
4677 set et_vect_udot_hi_saved 0
4678 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } {
4679 set et_vect_udot_hi_saved 1
4680 }
4681 }
4682 verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2
4683 return $et_vect_udot_hi_saved
4684 }
4685
4686 # Return 1 if the target plus current options supports a vector
4687 # sad operation of unsigned chars, 0 otherwise.
4688 #
4689 # This won't change for different subtargets so cache the result.
4690
4691 proc check_effective_target_vect_usad_char { } {
4692 global et_vect_usad_char
4693
4694 if [info exists et_vect_usad_char_saved] {
4695 verbose "check_effective_target_vect_usad_char: using cached result" 2
4696 } else {
4697 set et_vect_usad_char_saved 0
4698 if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
4699 set et_vect_usad_char_saved 1
4700 }
4701 }
4702 verbose "check_effective_target_vect_usad_char: returning $et_vect_usad_char_saved" 2
4703 return $et_vect_usad_char_saved
4704 }
4705
4706 # Return 1 if the target plus current options supports a vector
4707 # demotion (packing) of shorts (to chars) and ints (to shorts)
4708 # using modulo arithmetic, 0 otherwise.
4709 #
4710 # This won't change for different subtargets so cache the result.
4711
4712 proc check_effective_target_vect_pack_trunc { } {
4713 global et_vect_pack_trunc
4714
4715 if [info exists et_vect_pack_trunc_saved] {
4716 verbose "check_effective_target_vect_pack_trunc: using cached result" 2
4717 } else {
4718 set et_vect_pack_trunc_saved 0
4719 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
4720 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4721 || [istarget aarch64*-*-*]
4722 || [istarget spu-*-*]
4723 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4724 && [check_effective_target_arm_little_endian]) } {
4725 set et_vect_pack_trunc_saved 1
4726 }
4727 }
4728 verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2
4729 return $et_vect_pack_trunc_saved
4730 }
4731
4732 # Return 1 if the target plus current options supports a vector
4733 # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise.
4734 #
4735 # This won't change for different subtargets so cache the result.
4736
4737 proc check_effective_target_vect_unpack { } {
4738 global et_vect_unpack
4739
4740 if [info exists et_vect_unpack_saved] {
4741 verbose "check_effective_target_vect_unpack: using cached result" 2
4742 } else {
4743 set et_vect_unpack_saved 0
4744 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
4745 || [istarget i?86-*-*] || [istarget x86_64-*-*]
4746 || [istarget spu-*-*]
4747 || [istarget ia64-*-*]
4748 || [istarget aarch64*-*-*]
4749 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
4750 && [check_effective_target_arm_little_endian]) } {
4751 set et_vect_unpack_saved 1
4752 }
4753 }
4754 verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2
4755 return $et_vect_unpack_saved
4756 }
4757
4758 # Return 1 if the target plus current options does not guarantee
4759 # that its STACK_BOUNDARY is >= the reguired vector alignment.
4760 #
4761 # This won't change for different subtargets so cache the result.
4762
4763 proc check_effective_target_unaligned_stack { } {
4764 global et_unaligned_stack_saved
4765
4766 if [info exists et_unaligned_stack_saved] {
4767 verbose "check_effective_target_unaligned_stack: using cached result" 2
4768 } else {
4769 set et_unaligned_stack_saved 0
4770 }
4771 verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2
4772 return $et_unaligned_stack_saved
4773 }
4774
4775 # Return 1 if the target plus current options does not support a vector
4776 # alignment mechanism, 0 otherwise.
4777 #
4778 # This won't change for different subtargets so cache the result.
4779
4780 proc check_effective_target_vect_no_align { } {
4781 global et_vect_no_align_saved
4782
4783 if [info exists et_vect_no_align_saved] {
4784 verbose "check_effective_target_vect_no_align: using cached result" 2
4785 } else {
4786 set et_vect_no_align_saved 0
4787 if { [istarget mipsisa64*-*-*]
4788 || [istarget mips-sde-elf]
4789 || [istarget sparc*-*-*]
4790 || [istarget ia64-*-*]
4791 || [check_effective_target_arm_vect_no_misalign]
4792 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4793 || ([istarget mips*-*-*]
4794 && [check_effective_target_mips_loongson]) } {
4795 set et_vect_no_align_saved 1
4796 }
4797 }
4798 verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2
4799 return $et_vect_no_align_saved
4800 }
4801
4802 # Return 1 if the target supports a vector misalign access, 0 otherwise.
4803 #
4804 # This won't change for different subtargets so cache the result.
4805
4806 proc check_effective_target_vect_hw_misalign { } {
4807 global et_vect_hw_misalign_saved
4808
4809 if [info exists et_vect_hw_misalign_saved] {
4810 verbose "check_effective_target_vect_hw_misalign: using cached result" 2
4811 } else {
4812 set et_vect_hw_misalign_saved 0
4813 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
4814 || ([istarget powerpc*-*-*] && [check_p8vector_hw_available])
4815 || [istarget aarch64*-*-*] } {
4816 set et_vect_hw_misalign_saved 1
4817 }
4818 }
4819 verbose "check_effective_target_vect_hw_misalign: returning $et_vect_hw_misalign_saved" 2
4820 return $et_vect_hw_misalign_saved
4821 }
4822
4823
4824 # Return 1 if arrays are aligned to the vector alignment
4825 # boundary, 0 otherwise.
4826 #
4827 # This won't change for different subtargets so cache the result.
4828
4829 proc check_effective_target_vect_aligned_arrays { } {
4830 global et_vect_aligned_arrays
4831
4832 if [info exists et_vect_aligned_arrays_saved] {
4833 verbose "check_effective_target_vect_aligned_arrays: using cached result" 2
4834 } else {
4835 set et_vect_aligned_arrays_saved 0
4836 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
4837 if { ([is-effective-target lp64]
4838 && ( ![check_avx_available]
4839 || [check_prefer_avx128])) } {
4840 set et_vect_aligned_arrays_saved 1
4841 }
4842 }
4843 if [istarget spu-*-*] {
4844 set et_vect_aligned_arrays_saved 1
4845 }
4846 }
4847 verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2
4848 return $et_vect_aligned_arrays_saved
4849 }
4850
4851 # Return 1 if types of size 32 bit or less are naturally aligned
4852 # (aligned to their type-size), 0 otherwise.
4853 #
4854 # This won't change for different subtargets so cache the result.
4855
4856 proc check_effective_target_natural_alignment_32 { } {
4857 global et_natural_alignment_32
4858
4859 if [info exists et_natural_alignment_32_saved] {
4860 verbose "check_effective_target_natural_alignment_32: using cached result" 2
4861 } else {
4862 # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER.
4863 set et_natural_alignment_32_saved 1
4864 if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } {
4865 set et_natural_alignment_32_saved 0
4866 }
4867 }
4868 verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2
4869 return $et_natural_alignment_32_saved
4870 }
4871
4872 # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their
4873 # type-size), 0 otherwise.
4874 #
4875 # This won't change for different subtargets so cache the result.
4876
4877 proc check_effective_target_natural_alignment_64 { } {
4878 global et_natural_alignment_64
4879
4880 if [info exists et_natural_alignment_64_saved] {
4881 verbose "check_effective_target_natural_alignment_64: using cached result" 2
4882 } else {
4883 set et_natural_alignment_64_saved 0
4884 if { ([is-effective-target lp64] && ![istarget *-*-darwin*])
4885 || [istarget spu-*-*] } {
4886 set et_natural_alignment_64_saved 1
4887 }
4888 }
4889 verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2
4890 return $et_natural_alignment_64_saved
4891 }
4892
4893 # Return 1 if all vector types are naturally aligned (aligned to their
4894 # type-size), 0 otherwise.
4895 #
4896 # This won't change for different subtargets so cache the result.
4897
4898 proc check_effective_target_vect_natural_alignment { } {
4899 global et_vect_natural_alignment
4900
4901 if [info exists et_vect_natural_alignment_saved] {
4902 verbose "check_effective_target_vect_natural_alignment: using cached result" 2
4903 } else {
4904 set et_vect_natural_alignment_saved 1
4905 if { [check_effective_target_arm_eabi]
4906 || [istarget nvptx-*-*]
4907 || [istarget s390*-*-*] } {
4908 set et_vect_natural_alignment_saved 0
4909 }
4910 }
4911 verbose "check_effective_target_vect_natural_alignment: returning $et_vect_natural_alignment_saved" 2
4912 return $et_vect_natural_alignment_saved
4913 }
4914
4915 # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise.
4916 #
4917 # This won't change for different subtargets so cache the result.
4918
4919 proc check_effective_target_vector_alignment_reachable { } {
4920 global et_vector_alignment_reachable
4921
4922 if [info exists et_vector_alignment_reachable_saved] {
4923 verbose "check_effective_target_vector_alignment_reachable: using cached result" 2
4924 } else {
4925 if { [check_effective_target_vect_aligned_arrays]
4926 || [check_effective_target_natural_alignment_32] } {
4927 set et_vector_alignment_reachable_saved 1
4928 } else {
4929 set et_vector_alignment_reachable_saved 0
4930 }
4931 }
4932 verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2
4933 return $et_vector_alignment_reachable_saved
4934 }
4935
4936 # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise.
4937 #
4938 # This won't change for different subtargets so cache the result.
4939
4940 proc check_effective_target_vector_alignment_reachable_for_64bit { } {
4941 global et_vector_alignment_reachable_for_64bit
4942
4943 if [info exists et_vector_alignment_reachable_for_64bit_saved] {
4944 verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2
4945 } else {
4946 if { [check_effective_target_vect_aligned_arrays]
4947 || [check_effective_target_natural_alignment_64] } {
4948 set et_vector_alignment_reachable_for_64bit_saved 1
4949 } else {
4950 set et_vector_alignment_reachable_for_64bit_saved 0
4951 }
4952 }
4953 verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2
4954 return $et_vector_alignment_reachable_for_64bit_saved
4955 }
4956
4957 # Return 1 if the target only requires element alignment for vector accesses
4958
4959 proc check_effective_target_vect_element_align { } {
4960 global et_vect_element_align
4961
4962 if [info exists et_vect_element_align] {
4963 verbose "check_effective_target_vect_element_align: using cached result" 2
4964 } else {
4965 set et_vect_element_align 0
4966 if { ([istarget arm*-*-*]
4967 && ![check_effective_target_arm_vect_no_misalign])
4968 || [check_effective_target_vect_hw_misalign] } {
4969 set et_vect_element_align 1
4970 }
4971 }
4972
4973 verbose "check_effective_target_vect_element_align: returning $et_vect_element_align" 2
4974 return $et_vect_element_align
4975 }
4976
4977 # Return 1 if the target supports vector LOAD_LANES operations, 0 otherwise.
4978
4979 proc check_effective_target_vect_load_lanes { } {
4980 global et_vect_load_lanes
4981
4982 if [info exists et_vect_load_lanes] {
4983 verbose "check_effective_target_vect_load_lanes: using cached result" 2
4984 } else {
4985 set et_vect_load_lanes 0
4986 if { ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])
4987 || [istarget aarch64*-*-*] } {
4988 set et_vect_load_lanes 1
4989 }
4990 }
4991
4992 verbose "check_effective_target_vect_load_lanes: returning $et_vect_load_lanes" 2
4993 return $et_vect_load_lanes
4994 }
4995
4996 # Return 1 if the target supports vector conditional operations, 0 otherwise.
4997
4998 proc check_effective_target_vect_condition { } {
4999 global et_vect_cond_saved
5000
5001 if [info exists et_vect_cond_saved] {
5002 verbose "check_effective_target_vect_cond: using cached result" 2
5003 } else {
5004 set et_vect_cond_saved 0
5005 if { [istarget aarch64*-*-*]
5006 || [istarget powerpc*-*-*]
5007 || [istarget ia64-*-*]
5008 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5009 || [istarget spu-*-*]
5010 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
5011 set et_vect_cond_saved 1
5012 }
5013 }
5014
5015 verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2
5016 return $et_vect_cond_saved
5017 }
5018
5019 # Return 1 if the target supports vector conditional operations where
5020 # the comparison has different type from the lhs, 0 otherwise.
5021
5022 proc check_effective_target_vect_cond_mixed { } {
5023 global et_vect_cond_mixed_saved
5024
5025 if [info exists et_vect_cond_mixed_saved] {
5026 verbose "check_effective_target_vect_cond_mixed: using cached result" 2
5027 } else {
5028 set et_vect_cond_mixed_saved 0
5029 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5030 || [istarget powerpc*-*-*] } {
5031 set et_vect_cond_mixed_saved 1
5032 }
5033 }
5034
5035 verbose "check_effective_target_vect_cond_mixed: returning $et_vect_cond_mixed_saved" 2
5036 return $et_vect_cond_mixed_saved
5037 }
5038
5039 # Return 1 if the target supports vector char multiplication, 0 otherwise.
5040
5041 proc check_effective_target_vect_char_mult { } {
5042 global et_vect_char_mult_saved
5043
5044 if [info exists et_vect_char_mult_saved] {
5045 verbose "check_effective_target_vect_char_mult: using cached result" 2
5046 } else {
5047 set et_vect_char_mult_saved 0
5048 if { [istarget aarch64*-*-*]
5049 || [istarget ia64-*-*]
5050 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5051 || [check_effective_target_arm32]
5052 || [check_effective_target_powerpc_altivec] } {
5053 set et_vect_char_mult_saved 1
5054 }
5055 }
5056
5057 verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2
5058 return $et_vect_char_mult_saved
5059 }
5060
5061 # Return 1 if the target supports vector short multiplication, 0 otherwise.
5062
5063 proc check_effective_target_vect_short_mult { } {
5064 global et_vect_short_mult_saved
5065
5066 if [info exists et_vect_short_mult_saved] {
5067 verbose "check_effective_target_vect_short_mult: using cached result" 2
5068 } else {
5069 set et_vect_short_mult_saved 0
5070 if { [istarget ia64-*-*]
5071 || [istarget spu-*-*]
5072 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5073 || [istarget powerpc*-*-*]
5074 || [istarget aarch64*-*-*]
5075 || [check_effective_target_arm32]
5076 || ([istarget mips*-*-*]
5077 && [check_effective_target_mips_loongson]) } {
5078 set et_vect_short_mult_saved 1
5079 }
5080 }
5081
5082 verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2
5083 return $et_vect_short_mult_saved
5084 }
5085
5086 # Return 1 if the target supports vector int multiplication, 0 otherwise.
5087
5088 proc check_effective_target_vect_int_mult { } {
5089 global et_vect_int_mult_saved
5090
5091 if [info exists et_vect_int_mult_saved] {
5092 verbose "check_effective_target_vect_int_mult: using cached result" 2
5093 } else {
5094 set et_vect_int_mult_saved 0
5095 if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
5096 || [istarget spu-*-*]
5097 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5098 || [istarget ia64-*-*]
5099 || [istarget aarch64*-*-*]
5100 || [check_effective_target_arm32] } {
5101 set et_vect_int_mult_saved 1
5102 }
5103 }
5104
5105 verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2
5106 return $et_vect_int_mult_saved
5107 }
5108
5109 # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise.
5110
5111 proc check_effective_target_vect_extract_even_odd { } {
5112 global et_vect_extract_even_odd_saved
5113
5114 if [info exists et_vect_extract_even_odd_saved] {
5115 verbose "check_effective_target_vect_extract_even_odd: using cached result" 2
5116 } else {
5117 set et_vect_extract_even_odd_saved 0
5118 if { [istarget aarch64*-*-*]
5119 || [istarget powerpc*-*-*]
5120 || [is-effective-target arm_neon_ok]
5121 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5122 || [istarget ia64-*-*]
5123 || [istarget spu-*-*]
5124 || ([istarget mips*-*-*]
5125 && [check_effective_target_mpaired_single]) } {
5126 set et_vect_extract_even_odd_saved 1
5127 }
5128 }
5129
5130 verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2
5131 return $et_vect_extract_even_odd_saved
5132 }
5133
5134 # Return 1 if the target supports vector interleaving, 0 otherwise.
5135
5136 proc check_effective_target_vect_interleave { } {
5137 global et_vect_interleave_saved
5138
5139 if [info exists et_vect_interleave_saved] {
5140 verbose "check_effective_target_vect_interleave: using cached result" 2
5141 } else {
5142 set et_vect_interleave_saved 0
5143 if { [istarget aarch64*-*-*]
5144 || [istarget powerpc*-*-*]
5145 || [is-effective-target arm_neon_ok]
5146 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5147 || [istarget ia64-*-*]
5148 || [istarget spu-*-*]
5149 || ([istarget mips*-*-*]
5150 && [check_effective_target_mpaired_single]) } {
5151 set et_vect_interleave_saved 1
5152 }
5153 }
5154
5155 verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2
5156 return $et_vect_interleave_saved
5157 }
5158
5159 foreach N {2 3 4 8} {
5160 eval [string map [list N $N] {
5161 # Return 1 if the target supports 2-vector interleaving
5162 proc check_effective_target_vect_stridedN { } {
5163 global et_vect_stridedN_saved
5164
5165 if [info exists et_vect_stridedN_saved] {
5166 verbose "check_effective_target_vect_stridedN: using cached result" 2
5167 } else {
5168 set et_vect_stridedN_saved 0
5169 if { (N & -N) == N
5170 && [check_effective_target_vect_interleave]
5171 && [check_effective_target_vect_extract_even_odd] } {
5172 set et_vect_stridedN_saved 1
5173 }
5174 if { ([istarget arm*-*-*]
5175 || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
5176 set et_vect_stridedN_saved 1
5177 }
5178 }
5179
5180 verbose "check_effective_target_vect_stridedN: returning $et_vect_stridedN_saved" 2
5181 return $et_vect_stridedN_saved
5182 }
5183 }]
5184 }
5185
5186 # Return 1 if the target supports multiple vector sizes
5187
5188 proc check_effective_target_vect_multiple_sizes { } {
5189 global et_vect_multiple_sizes_saved
5190
5191 set et_vect_multiple_sizes_saved 0
5192 if { ([istarget aarch64*-*-*]
5193 || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok])) } {
5194 set et_vect_multiple_sizes_saved 1
5195 }
5196 if { ([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
5197 if { ([check_avx_available] && ![check_prefer_avx128]) } {
5198 set et_vect_multiple_sizes_saved 1
5199 }
5200 }
5201
5202 verbose "check_effective_target_vect_multiple_sizes: returning $et_vect_multiple_sizes_saved" 2
5203 return $et_vect_multiple_sizes_saved
5204 }
5205
5206 # Return 1 if the target supports vectors of 64 bits.
5207
5208 proc check_effective_target_vect64 { } {
5209 global et_vect64_saved
5210
5211 if [info exists et_vect64_saved] {
5212 verbose "check_effective_target_vect64: using cached result" 2
5213 } else {
5214 set et_vect64_saved 0
5215 if { ([istarget arm*-*-*]
5216 && [check_effective_target_arm_neon_ok]
5217 && [check_effective_target_arm_little_endian])
5218 || [istarget aarch64*-*-*]
5219 || [istarget sparc*-*-*] } {
5220 set et_vect64_saved 1
5221 }
5222 }
5223
5224 verbose "check_effective_target_vect64: returning $et_vect64_saved" 2
5225 return $et_vect64_saved
5226 }
5227
5228 # Return 1 if the target supports vector copysignf calls.
5229
5230 proc check_effective_target_vect_call_copysignf { } {
5231 global et_vect_call_copysignf_saved
5232
5233 if [info exists et_vect_call_copysignf_saved] {
5234 verbose "check_effective_target_vect_call_copysignf: using cached result" 2
5235 } else {
5236 set et_vect_call_copysignf_saved 0
5237 if { [istarget i?86-*-*] || [istarget x86_64-*-*]
5238 || [istarget powerpc*-*-*] } {
5239 set et_vect_call_copysignf_saved 1
5240 }
5241 }
5242
5243 verbose "check_effective_target_vect_call_copysignf: returning $et_vect_call_copysignf_saved" 2
5244 return $et_vect_call_copysignf_saved
5245 }
5246
5247 # Return 1 if the target supports hardware square root instructions.
5248
5249 proc check_effective_target_sqrt_insn { } {
5250 global et_sqrt_insn_saved
5251
5252 if [info exists et_sqrt_insn_saved] {
5253 verbose "check_effective_target_hw_sqrt: using cached result" 2
5254 } else {
5255 set et_sqrt_insn_saved 0
5256 if { [istarget x86_64-*-*]
5257 || [istarget powerpc*-*-*]
5258 || [istarget aarch64*-*-*]
5259 || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok]) } {
5260 set et_sqrt_insn_saved 1
5261 }
5262 }
5263
5264 verbose "check_effective_target_hw_sqrt: returning et_sqrt_insn_saved" 2
5265 return $et_sqrt_insn_saved
5266 }
5267
5268 # Return 1 if the target supports vector sqrtf calls.
5269
5270 proc check_effective_target_vect_call_sqrtf { } {
5271 global et_vect_call_sqrtf_saved
5272
5273 if [info exists et_vect_call_sqrtf_saved] {
5274 verbose "check_effective_target_vect_call_sqrtf: using cached result" 2
5275 } else {
5276 set et_vect_call_sqrtf_saved 0
5277 if { [istarget aarch64*-*-*]
5278 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5279 || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
5280 set et_vect_call_sqrtf_saved 1
5281 }
5282 }
5283
5284 verbose "check_effective_target_vect_call_sqrtf: returning $et_vect_call_sqrtf_saved" 2
5285 return $et_vect_call_sqrtf_saved
5286 }
5287
5288 # Return 1 if the target supports vector lrint calls.
5289
5290 proc check_effective_target_vect_call_lrint { } {
5291 set et_vect_call_lrint 0
5292 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
5293 && [check_effective_target_ilp32] } {
5294 set et_vect_call_lrint 1
5295 }
5296
5297 verbose "check_effective_target_vect_call_lrint: returning $et_vect_call_lrint" 2
5298 return $et_vect_call_lrint
5299 }
5300
5301 # Return 1 if the target supports vector btrunc calls.
5302
5303 proc check_effective_target_vect_call_btrunc { } {
5304 global et_vect_call_btrunc_saved
5305
5306 if [info exists et_vect_call_btrunc_saved] {
5307 verbose "check_effective_target_vect_call_btrunc: using cached result" 2
5308 } else {
5309 set et_vect_call_btrunc_saved 0
5310 if { [istarget aarch64*-*-*] } {
5311 set et_vect_call_btrunc_saved 1
5312 }
5313 }
5314
5315 verbose "check_effective_target_vect_call_btrunc: returning $et_vect_call_btrunc_saved" 2
5316 return $et_vect_call_btrunc_saved
5317 }
5318
5319 # Return 1 if the target supports vector btruncf calls.
5320
5321 proc check_effective_target_vect_call_btruncf { } {
5322 global et_vect_call_btruncf_saved
5323
5324 if [info exists et_vect_call_btruncf_saved] {
5325 verbose "check_effective_target_vect_call_btruncf: using cached result" 2
5326 } else {
5327 set et_vect_call_btruncf_saved 0
5328 if { [istarget aarch64*-*-*] } {
5329 set et_vect_call_btruncf_saved 1
5330 }
5331 }
5332
5333 verbose "check_effective_target_vect_call_btruncf: returning $et_vect_call_btruncf_saved" 2
5334 return $et_vect_call_btruncf_saved
5335 }
5336
5337 # Return 1 if the target supports vector ceil calls.
5338
5339 proc check_effective_target_vect_call_ceil { } {
5340 global et_vect_call_ceil_saved
5341
5342 if [info exists et_vect_call_ceil_saved] {
5343 verbose "check_effective_target_vect_call_ceil: using cached result" 2
5344 } else {
5345 set et_vect_call_ceil_saved 0
5346 if { [istarget aarch64*-*-*] } {
5347 set et_vect_call_ceil_saved 1
5348 }
5349 }
5350
5351 verbose "check_effective_target_vect_call_ceil: returning $et_vect_call_ceil_saved" 2
5352 return $et_vect_call_ceil_saved
5353 }
5354
5355 # Return 1 if the target supports vector ceilf calls.
5356
5357 proc check_effective_target_vect_call_ceilf { } {
5358 global et_vect_call_ceilf_saved
5359
5360 if [info exists et_vect_call_ceilf_saved] {
5361 verbose "check_effective_target_vect_call_ceilf: using cached result" 2
5362 } else {
5363 set et_vect_call_ceilf_saved 0
5364 if { [istarget aarch64*-*-*] } {
5365 set et_vect_call_ceilf_saved 1
5366 }
5367 }
5368
5369 verbose "check_effective_target_vect_call_ceilf: returning $et_vect_call_ceilf_saved" 2
5370 return $et_vect_call_ceilf_saved
5371 }
5372
5373 # Return 1 if the target supports vector floor calls.
5374
5375 proc check_effective_target_vect_call_floor { } {
5376 global et_vect_call_floor_saved
5377
5378 if [info exists et_vect_call_floor_saved] {
5379 verbose "check_effective_target_vect_call_floor: using cached result" 2
5380 } else {
5381 set et_vect_call_floor_saved 0
5382 if { [istarget aarch64*-*-*] } {
5383 set et_vect_call_floor_saved 1
5384 }
5385 }
5386
5387 verbose "check_effective_target_vect_call_floor: returning $et_vect_call_floor_saved" 2
5388 return $et_vect_call_floor_saved
5389 }
5390
5391 # Return 1 if the target supports vector floorf calls.
5392
5393 proc check_effective_target_vect_call_floorf { } {
5394 global et_vect_call_floorf_saved
5395
5396 if [info exists et_vect_call_floorf_saved] {
5397 verbose "check_effective_target_vect_call_floorf: using cached result" 2
5398 } else {
5399 set et_vect_call_floorf_saved 0
5400 if { [istarget aarch64*-*-*] } {
5401 set et_vect_call_floorf_saved 1
5402 }
5403 }
5404
5405 verbose "check_effective_target_vect_call_floorf: returning $et_vect_call_floorf_saved" 2
5406 return $et_vect_call_floorf_saved
5407 }
5408
5409 # Return 1 if the target supports vector lceil calls.
5410
5411 proc check_effective_target_vect_call_lceil { } {
5412 global et_vect_call_lceil_saved
5413
5414 if [info exists et_vect_call_lceil_saved] {
5415 verbose "check_effective_target_vect_call_lceil: using cached result" 2
5416 } else {
5417 set et_vect_call_lceil_saved 0
5418 if { [istarget aarch64*-*-*] } {
5419 set et_vect_call_lceil_saved 1
5420 }
5421 }
5422
5423 verbose "check_effective_target_vect_call_lceil: returning $et_vect_call_lceil_saved" 2
5424 return $et_vect_call_lceil_saved
5425 }
5426
5427 # Return 1 if the target supports vector lfloor calls.
5428
5429 proc check_effective_target_vect_call_lfloor { } {
5430 global et_vect_call_lfloor_saved
5431
5432 if [info exists et_vect_call_lfloor_saved] {
5433 verbose "check_effective_target_vect_call_lfloor: using cached result" 2
5434 } else {
5435 set et_vect_call_lfloor_saved 0
5436 if { [istarget aarch64*-*-*] } {
5437 set et_vect_call_lfloor_saved 1
5438 }
5439 }
5440
5441 verbose "check_effective_target_vect_call_lfloor: returning $et_vect_call_lfloor_saved" 2
5442 return $et_vect_call_lfloor_saved
5443 }
5444
5445 # Return 1 if the target supports vector nearbyint calls.
5446
5447 proc check_effective_target_vect_call_nearbyint { } {
5448 global et_vect_call_nearbyint_saved
5449
5450 if [info exists et_vect_call_nearbyint_saved] {
5451 verbose "check_effective_target_vect_call_nearbyint: using cached result" 2
5452 } else {
5453 set et_vect_call_nearbyint_saved 0
5454 if { [istarget aarch64*-*-*] } {
5455 set et_vect_call_nearbyint_saved 1
5456 }
5457 }
5458
5459 verbose "check_effective_target_vect_call_nearbyint: returning $et_vect_call_nearbyint_saved" 2
5460 return $et_vect_call_nearbyint_saved
5461 }
5462
5463 # Return 1 if the target supports vector nearbyintf calls.
5464
5465 proc check_effective_target_vect_call_nearbyintf { } {
5466 global et_vect_call_nearbyintf_saved
5467
5468 if [info exists et_vect_call_nearbyintf_saved] {
5469 verbose "check_effective_target_vect_call_nearbyintf: using cached result" 2
5470 } else {
5471 set et_vect_call_nearbyintf_saved 0
5472 if { [istarget aarch64*-*-*] } {
5473 set et_vect_call_nearbyintf_saved 1
5474 }
5475 }
5476
5477 verbose "check_effective_target_vect_call_nearbyintf: returning $et_vect_call_nearbyintf_saved" 2
5478 return $et_vect_call_nearbyintf_saved
5479 }
5480
5481 # Return 1 if the target supports vector round calls.
5482
5483 proc check_effective_target_vect_call_round { } {
5484 global et_vect_call_round_saved
5485
5486 if [info exists et_vect_call_round_saved] {
5487 verbose "check_effective_target_vect_call_round: using cached result" 2
5488 } else {
5489 set et_vect_call_round_saved 0
5490 if { [istarget aarch64*-*-*] } {
5491 set et_vect_call_round_saved 1
5492 }
5493 }
5494
5495 verbose "check_effective_target_vect_call_round: returning $et_vect_call_round_saved" 2
5496 return $et_vect_call_round_saved
5497 }
5498
5499 # Return 1 if the target supports vector roundf calls.
5500
5501 proc check_effective_target_vect_call_roundf { } {
5502 global et_vect_call_roundf_saved
5503
5504 if [info exists et_vect_call_roundf_saved] {
5505 verbose "check_effective_target_vect_call_roundf: using cached result" 2
5506 } else {
5507 set et_vect_call_roundf_saved 0
5508 if { [istarget aarch64*-*-*] } {
5509 set et_vect_call_roundf_saved 1
5510 }
5511 }
5512
5513 verbose "check_effective_target_vect_call_roundf: returning $et_vect_call_roundf_saved" 2
5514 return $et_vect_call_roundf_saved
5515 }
5516
5517 # Return 1 if the target supports section-anchors
5518
5519 proc check_effective_target_section_anchors { } {
5520 global et_section_anchors_saved
5521
5522 if [info exists et_section_anchors_saved] {
5523 verbose "check_effective_target_section_anchors: using cached result" 2
5524 } else {
5525 set et_section_anchors_saved 0
5526 if { [istarget powerpc*-*-*]
5527 || [istarget arm*-*-*]
5528 || [istarget aarch64*-*-*] } {
5529 set et_section_anchors_saved 1
5530 }
5531 }
5532
5533 verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2
5534 return $et_section_anchors_saved
5535 }
5536
5537 # Return 1 if the target supports atomic operations on "int_128" values.
5538
5539 proc check_effective_target_sync_int_128 { } {
5540 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5541 && ![is-effective-target ia32] } {
5542 return 1
5543 } elseif { [istarget spu-*-*] } {
5544 return 1
5545 } else {
5546 return 0
5547 }
5548 }
5549
5550 # Return 1 if the target supports atomic operations on "int_128" values
5551 # and can execute them.
5552
5553 proc check_effective_target_sync_int_128_runtime { } {
5554 if { ([istarget x86_64-*-*] || [istarget i?86-*-*])
5555 && ![is-effective-target ia32] } {
5556 return [check_cached_effective_target sync_int_128_available {
5557 check_runtime_nocache sync_int_128_available {
5558 #include "cpuid.h"
5559 int main ()
5560 {
5561 unsigned int eax, ebx, ecx, edx;
5562 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5563 return !(ecx & bit_CMPXCHG16B);
5564 return 1;
5565 }
5566 } ""
5567 }]
5568 } elseif { [istarget spu-*-*] } {
5569 return 1
5570 } else {
5571 return 0
5572 }
5573 }
5574
5575 # Return 1 if the target supports atomic operations on "long long".
5576 #
5577 # Note: 32bit x86 targets require -march=pentium in dg-options.
5578 # Note: 32bit s390 targets require -mzarch in dg-options.
5579
5580 proc check_effective_target_sync_long_long { } {
5581 if { [istarget x86_64-*-*] || [istarget i?86-*-*])
5582 || [istarget aarch64*-*-*]
5583 || [istarget arm*-*-*]
5584 || [istarget alpha*-*-*]
5585 || ([istarget sparc*-*-*] && [check_effective_target_lp64])
5586 || [istarget s390*-*-*]
5587 || [istarget spu-*-*] } {
5588 return 1
5589 } else {
5590 return 0
5591 }
5592 }
5593
5594 # Return 1 if the target supports atomic operations on "long long"
5595 # and can execute them.
5596 #
5597 # Note: 32bit x86 targets require -march=pentium in dg-options.
5598
5599 proc check_effective_target_sync_long_long_runtime { } {
5600 if { [istarget x86_64-*-*] || [istarget i?86-*-*] } {
5601 return [check_cached_effective_target sync_long_long_available {
5602 check_runtime_nocache sync_long_long_available {
5603 #include "cpuid.h"
5604 int main ()
5605 {
5606 unsigned int eax, ebx, ecx, edx;
5607 if (__get_cpuid (1, &eax, &ebx, &ecx, &edx))
5608 return !(edx & bit_CMPXCHG8B);
5609 return 1;
5610 }
5611 } ""
5612 }]
5613 } elseif { [istarget aarch64*-*-*] } {
5614 return 1
5615 } elseif { [istarget arm*-*-linux-*] } {
5616 return [check_runtime sync_longlong_runtime {
5617 #include <stdlib.h>
5618 int main ()
5619 {
5620 long long l1;
5621
5622 if (sizeof (long long) != 8)
5623 exit (1);
5624
5625 /* Just check for native; checking for kernel fallback is tricky. */
5626 asm volatile ("ldrexd r0,r1, [%0]" : : "r" (&l1) : "r0", "r1");
5627
5628 exit (0);
5629 }
5630 } "" ]
5631 } elseif { [istarget alpha*-*-*] } {
5632 return 1
5633 } elseif { ([istarget sparc*-*-*]
5634 && [check_effective_target_lp64]
5635 && [check_effective_target_ultrasparc_hw]) } {
5636 return 1
5637 } elseif { [istarget spu-*-*] } {
5638 return 1
5639 } elseif { [istarget powerpc*-*-*] && [check_effective_target_lp64] } {
5640 return 1
5641 } else {
5642 return 0
5643 }
5644 }
5645
5646 # Return 1 if the target supports byte swap instructions.
5647
5648 proc check_effective_target_bswap { } {
5649 global et_bswap_saved
5650
5651 if [info exists et_bswap_saved] {
5652 verbose "check_effective_target_bswap: using cached result" 2
5653 } else {
5654 set et_bswap_saved 0
5655 if { [istarget aarch64*-*-*]
5656 || [istarget alpha*-*-*]
5657 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5658 || [istarget m68k-*-*]
5659 || [istarget powerpc*-*-*]
5660 || [istarget rs6000-*-*]
5661 || [istarget s390*-*-*] } {
5662 set et_bswap_saved 1
5663 } else {
5664 if { [istarget arm*-*-*]
5665 && [check_no_compiler_messages_nocache arm_v6_or_later object {
5666 #if __ARM_ARCH < 6
5667 #error not armv6 or later
5668 #endif
5669 int i;
5670 } ""] } {
5671 set et_bswap_saved 1
5672 }
5673 }
5674 }
5675
5676 verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
5677 return $et_bswap_saved
5678 }
5679
5680 # Return 1 if the target supports 16-bit byte swap instructions.
5681
5682 proc check_effective_target_bswap16 { } {
5683 global et_bswap16_saved
5684
5685 if [info exists et_bswap16_saved] {
5686 verbose "check_effective_target_bswap16: using cached result" 2
5687 } else {
5688 set et_bswap16_saved 0
5689 if { [is-effective-target bswap]
5690 && ![istarget alpha*-*-*]
5691 && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
5692 set et_bswap16_saved 1
5693 }
5694 }
5695
5696 verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
5697 return $et_bswap16_saved
5698 }
5699
5700 # Return 1 if the target supports 32-bit byte swap instructions.
5701
5702 proc check_effective_target_bswap32 { } {
5703 global et_bswap32_saved
5704
5705 if [info exists et_bswap32_saved] {
5706 verbose "check_effective_target_bswap32: using cached result" 2
5707 } else {
5708 set et_bswap32_saved 0
5709 if { [is-effective-target bswap] } {
5710 set et_bswap32_saved 1
5711 }
5712 }
5713
5714 verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
5715 return $et_bswap32_saved
5716 }
5717
5718 # Return 1 if the target supports 64-bit byte swap instructions.
5719 #
5720 # Note: 32bit s390 targets require -mzarch in dg-options.
5721
5722 proc check_effective_target_bswap64 { } {
5723 global et_bswap64_saved
5724
5725 # expand_unop can expand 64-bit byte swap on 32-bit targets
5726 if { [is-effective-target bswap] && [is-effective-target int32plus] } {
5727 return 1
5728 }
5729 return 0
5730 }
5731
5732 # Return 1 if the target supports atomic operations on "int" and "long".
5733
5734 proc check_effective_target_sync_int_long { } {
5735 global et_sync_int_long_saved
5736
5737 if [info exists et_sync_int_long_saved] {
5738 verbose "check_effective_target_sync_int_long: using cached result" 2
5739 } else {
5740 set et_sync_int_long_saved 0
5741 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5742 # load-reserved/store-conditional instructions.
5743 if { [istarget ia64-*-*]
5744 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5745 || [istarget aarch64*-*-*]
5746 || [istarget alpha*-*-*]
5747 || [istarget arm*-*-linux-*]
5748 || ([istarget arm*-*-*]
5749 && [check_effective_target_arm_acq_rel])
5750 || [istarget bfin*-*linux*]
5751 || [istarget hppa*-*linux*]
5752 || [istarget s390*-*-*]
5753 || [istarget powerpc*-*-*]
5754 || [istarget crisv32-*-*] || [istarget cris-*-*]
5755 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5756 || [istarget spu-*-*]
5757 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
5758 || [check_effective_target_mips_llsc] } {
5759 set et_sync_int_long_saved 1
5760 }
5761 }
5762
5763 verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2
5764 return $et_sync_int_long_saved
5765 }
5766
5767 # Return 1 if the target supports atomic operations on "char" and "short".
5768
5769 proc check_effective_target_sync_char_short { } {
5770 global et_sync_char_short_saved
5771
5772 if [info exists et_sync_char_short_saved] {
5773 verbose "check_effective_target_sync_char_short: using cached result" 2
5774 } else {
5775 set et_sync_char_short_saved 0
5776 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
5777 # load-reserved/store-conditional instructions.
5778 if { [istarget aarch64*-*-*]
5779 || [istarget ia64-*-*]
5780 || [istarget i?86-*-*] || [istarget x86_64-*-*]
5781 || [istarget alpha*-*-*]
5782 || [istarget arm*-*-linux-*]
5783 || ([istarget arm*-*-*]
5784 && [check_effective_target_arm_acq_rel])
5785 || [istarget hppa*-*linux*]
5786 || [istarget s390*-*-*]
5787 || [istarget powerpc*-*-*]
5788 || [istarget crisv32-*-*] || [istarget cris-*-*]
5789 || ([istarget sparc*-*-*] && [check_effective_target_sparc_v9])
5790 || [istarget spu-*-*]
5791 || ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
5792 || [check_effective_target_mips_llsc] } {
5793 set et_sync_char_short_saved 1
5794 }
5795 }
5796
5797 verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2
5798 return $et_sync_char_short_saved
5799 }
5800
5801 # Return 1 if the target uses a ColdFire FPU.
5802
5803 proc check_effective_target_coldfire_fpu { } {
5804 return [check_no_compiler_messages coldfire_fpu assembly {
5805 #ifndef __mcffpu__
5806 #error !__mcffpu__
5807 #endif
5808 }]
5809 }
5810
5811 # Return true if this is a uClibc target.
5812
5813 proc check_effective_target_uclibc {} {
5814 return [check_no_compiler_messages uclibc object {
5815 #include <features.h>
5816 #if !defined (__UCLIBC__)
5817 #error !__UCLIBC__
5818 #endif
5819 }]
5820 }
5821
5822 # Return true if this is a uclibc target and if the uclibc feature
5823 # described by __$feature__ is not present.
5824
5825 proc check_missing_uclibc_feature {feature} {
5826 return [check_no_compiler_messages $feature object "
5827 #include <features.h>
5828 #if !defined (__UCLIBC) || defined (__${feature}__)
5829 #error FOO
5830 #endif
5831 "]
5832 }
5833
5834 # Return true if this is a Newlib target.
5835
5836 proc check_effective_target_newlib {} {
5837 return [check_no_compiler_messages newlib object {
5838 #include <newlib.h>
5839 }]
5840 }
5841
5842 # Return true if this is NOT a Bionic target.
5843
5844 proc check_effective_target_non_bionic {} {
5845 return [check_no_compiler_messages non_bionic object {
5846 #include <ctype.h>
5847 #if defined (__BIONIC__)
5848 #error FOO
5849 #endif
5850 }]
5851 }
5852
5853 # Return true if this target has error.h header.
5854
5855 proc check_effective_target_error_h {} {
5856 return [check_no_compiler_messages error_h object {
5857 #include <error.h>
5858 }]
5859 }
5860
5861 # Return true if this target has tgmath.h header.
5862
5863 proc check_effective_target_tgmath_h {} {
5864 return [check_no_compiler_messages tgmath_h object {
5865 #include <tgmath.h>
5866 }]
5867 }
5868
5869 # Return true if target's libc supports complex functions.
5870
5871 proc check_effective_target_libc_has_complex_functions {} {
5872 return [check_no_compiler_messages libc_has_complex_functions object {
5873 #include <complex.h>
5874 }]
5875 }
5876
5877 # Return 1 if
5878 # (a) an error of a few ULP is expected in string to floating-point
5879 # conversion functions; and
5880 # (b) overflow is not always detected correctly by those functions.
5881
5882 proc check_effective_target_lax_strtofp {} {
5883 # By default, assume that all uClibc targets suffer from this.
5884 return [check_effective_target_uclibc]
5885 }
5886
5887 # Return 1 if this is a target for which wcsftime is a dummy
5888 # function that always returns 0.
5889
5890 proc check_effective_target_dummy_wcsftime {} {
5891 # By default, assume that all uClibc targets suffer from this.
5892 return [check_effective_target_uclibc]
5893 }
5894
5895 # Return 1 if constructors with initialization priority arguments are
5896 # supposed on this target.
5897
5898 proc check_effective_target_init_priority {} {
5899 return [check_no_compiler_messages init_priority assembly "
5900 void f() __attribute__((constructor (1000)));
5901 void f() \{\}
5902 "]
5903 }
5904
5905 # Return 1 if the target matches the effective target 'arg', 0 otherwise.
5906 # This can be used with any check_* proc that takes no argument and
5907 # returns only 1 or 0. It could be used with check_* procs that take
5908 # arguments with keywords that pass particular arguments.
5909
5910 proc is-effective-target { arg } {
5911 set selected 0
5912 if { [info procs check_effective_target_${arg}] != [list] } {
5913 set selected [check_effective_target_${arg}]
5914 } else {
5915 switch $arg {
5916 "vmx_hw" { set selected [check_vmx_hw_available] }
5917 "vsx_hw" { set selected [check_vsx_hw_available] }
5918 "p8vector_hw" { set selected [check_p8vector_hw_available] }
5919 "p9vector_hw" { set selected [check_p9vector_hw_available] }
5920 "p9modulo_hw" { set selected [check_p9modulo_hw_available] }
5921 "ppc_float128_sw" { set selected [check_ppc_float128_sw_available] }
5922 "ppc_float128_hw" { set selected [check_ppc_float128_hw_available] }
5923 "ppc_recip_hw" { set selected [check_ppc_recip_hw_available] }
5924 "dfp_hw" { set selected [check_dfp_hw_available] }
5925 "htm_hw" { set selected [check_htm_hw_available] }
5926 "named_sections" { set selected [check_named_sections_available] }
5927 "gc_sections" { set selected [check_gc_sections_available] }
5928 "cxa_atexit" { set selected [check_cxa_atexit_available] }
5929 default { error "unknown effective target keyword `$arg'" }
5930 }
5931 }
5932 verbose "is-effective-target: $arg $selected" 2
5933 return $selected
5934 }
5935
5936 # Return 1 if the argument is an effective-target keyword, 0 otherwise.
5937
5938 proc is-effective-target-keyword { arg } {
5939 if { [info procs check_effective_target_${arg}] != [list] } {
5940 return 1
5941 } else {
5942 # These have different names for their check_* procs.
5943 switch $arg {
5944 "vmx_hw" { return 1 }
5945 "vsx_hw" { return 1 }
5946 "p8vector_hw" { return 1 }
5947 "p9vector_hw" { return 1 }
5948 "p9modulo_hw" { return 1 }
5949 "ppc_float128_sw" { return 1 }
5950 "ppc_float128_hw" { return 1 }
5951 "ppc_recip_hw" { return 1 }
5952 "dfp_hw" { return 1 }
5953 "htm_hw" { return 1 }
5954 "named_sections" { return 1 }
5955 "gc_sections" { return 1 }
5956 "cxa_atexit" { return 1 }
5957 default { return 0 }
5958 }
5959 }
5960 }
5961
5962 # Return 1 if target default to short enums
5963
5964 proc check_effective_target_short_enums { } {
5965 return [check_no_compiler_messages short_enums assembly {
5966 enum foo { bar };
5967 int s[sizeof (enum foo) == 1 ? 1 : -1];
5968 }]
5969 }
5970
5971 # Return 1 if target supports merging string constants at link time.
5972
5973 proc check_effective_target_string_merging { } {
5974 return [check_no_messages_and_pattern string_merging \
5975 "rodata\\.str" assembly {
5976 const char *var = "String";
5977 } {-O2}]
5978 }
5979
5980 # Return 1 if target has the basic signed and unsigned types in
5981 # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a
5982 # working <stdint.h> for all targets.
5983
5984 proc check_effective_target_stdint_types { } {
5985 return [check_no_compiler_messages stdint_types assembly {
5986 #include <stdint.h>
5987 int8_t a; int16_t b; int32_t c; int64_t d;
5988 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
5989 }]
5990 }
5991
5992 # Return 1 if target has the basic signed and unsigned types in
5993 # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of
5994 # these types agree with those in the header, as some systems have
5995 # only <inttypes.h>.
5996
5997 proc check_effective_target_inttypes_types { } {
5998 return [check_no_compiler_messages inttypes_types assembly {
5999 #include <inttypes.h>
6000 int8_t a; int16_t b; int32_t c; int64_t d;
6001 uint8_t e; uint16_t f; uint32_t g; uint64_t h;
6002 }]
6003 }
6004
6005 # Return 1 if programs are intended to be run on a simulator
6006 # (i.e. slowly) rather than hardware (i.e. fast).
6007
6008 proc check_effective_target_simulator { } {
6009
6010 # All "src/sim" simulators set this one.
6011 if [board_info target exists is_simulator] {
6012 return [board_info target is_simulator]
6013 }
6014
6015 # The "sid" simulators don't set that one, but at least they set
6016 # this one.
6017 if [board_info target exists slow_simulator] {
6018 return [board_info target slow_simulator]
6019 }
6020
6021 return 0
6022 }
6023
6024 # Return 1 if programs are intended to be run on hardware rather than
6025 # on a simulator
6026
6027 proc check_effective_target_hw { } {
6028
6029 # All "src/sim" simulators set this one.
6030 if [board_info target exists is_simulator] {
6031 if [board_info target is_simulator] {
6032 return 0
6033 } else {
6034 return 1
6035 }
6036 }
6037
6038 # The "sid" simulators don't set that one, but at least they set
6039 # this one.
6040 if [board_info target exists slow_simulator] {
6041 if [board_info target slow_simulator] {
6042 return 0
6043 } else {
6044 return 1
6045 }
6046 }
6047
6048 return 1
6049 }
6050
6051 # Return 1 if the target is a VxWorks kernel.
6052
6053 proc check_effective_target_vxworks_kernel { } {
6054 return [check_no_compiler_messages vxworks_kernel assembly {
6055 #if !defined __vxworks || defined __RTP__
6056 #error NO
6057 #endif
6058 }]
6059 }
6060
6061 # Return 1 if the target is a VxWorks RTP.
6062
6063 proc check_effective_target_vxworks_rtp { } {
6064 return [check_no_compiler_messages vxworks_rtp assembly {
6065 #if !defined __vxworks || !defined __RTP__
6066 #error NO
6067 #endif
6068 }]
6069 }
6070
6071 # Return 1 if the target is expected to provide wide character support.
6072
6073 proc check_effective_target_wchar { } {
6074 if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} {
6075 return 0
6076 }
6077 return [check_no_compiler_messages wchar assembly {
6078 #include <wchar.h>
6079 }]
6080 }
6081
6082 # Return 1 if the target has <pthread.h>.
6083
6084 proc check_effective_target_pthread_h { } {
6085 return [check_no_compiler_messages pthread_h assembly {
6086 #include <pthread.h>
6087 }]
6088 }
6089
6090 # Return 1 if the target can truncate a file from a file-descriptor,
6091 # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or
6092 # chsize. We test for a trivially functional truncation; no stubs.
6093 # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a
6094 # different function to be used.
6095
6096 proc check_effective_target_fd_truncate { } {
6097 set prog {
6098 #define _FILE_OFFSET_BITS 64
6099 #include <unistd.h>
6100 #include <stdio.h>
6101 #include <stdlib.h>
6102 #include <string.h>
6103 int main ()
6104 {
6105 FILE *f = fopen ("tst.tmp", "wb");
6106 int fd;
6107 const char t[] = "test writing more than ten characters";
6108 char s[11];
6109 int status = 0;
6110 fd = fileno (f);
6111 write (fd, t, sizeof (t) - 1);
6112 lseek (fd, 0, 0);
6113 if (ftruncate (fd, 10) != 0)
6114 status = 1;
6115 close (fd);
6116 fclose (f);
6117 if (status)
6118 {
6119 unlink ("tst.tmp");
6120 exit (status);
6121 }
6122 f = fopen ("tst.tmp", "rb");
6123 if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0)
6124 status = 1;
6125 fclose (f);
6126 unlink ("tst.tmp");
6127 exit (status);
6128 }
6129 }
6130
6131 if { [check_runtime ftruncate $prog] } {
6132 return 1;
6133 }
6134
6135 regsub "ftruncate" $prog "chsize" prog
6136 return [check_runtime chsize $prog]
6137 }
6138
6139 # Add to FLAGS all the target-specific flags needed to access the c99 runtime.
6140
6141 proc add_options_for_c99_runtime { flags } {
6142 if { [istarget *-*-solaris2*] } {
6143 return "$flags -std=c99"
6144 }
6145 if { [istarget powerpc-*-darwin*] } {
6146 return "$flags -mmacosx-version-min=10.3"
6147 }
6148 return $flags
6149 }
6150
6151 # Add to FLAGS all the target-specific flags needed to enable
6152 # full IEEE compliance mode.
6153
6154 proc add_options_for_ieee { flags } {
6155 if { [istarget alpha*-*-*]
6156 || [istarget sh*-*-*] } {
6157 return "$flags -mieee"
6158 }
6159 if { [istarget rx-*-*] } {
6160 return "$flags -mnofpu"
6161 }
6162 return $flags
6163 }
6164
6165 if {![info exists flags_to_postpone]} {
6166 set flags_to_postpone ""
6167 }
6168
6169 # Add to FLAGS the flags needed to enable functions to bind locally
6170 # when using pic/PIC passes in the testsuite.
6171 proc add_options_for_bind_pic_locally { flags } {
6172 global flags_to_postpone
6173
6174 # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
6175 # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
6176 # order to make sure that the multilib_flags doesn't override this.
6177
6178 if {[check_no_compiler_messages using_pic2 assembly {
6179 #if __PIC__ != 2
6180 #error __PIC__ != 2
6181 #endif
6182 }]} {
6183 set flags_to_postpone "-fPIE"
6184 return $flags
6185 }
6186 if {[check_no_compiler_messages using_pic1 assembly {
6187 #if __PIC__ != 1
6188 #error __PIC__ != 1
6189 #endif
6190 }]} {
6191 set flags_to_postpone "-fpie"
6192 return $flags
6193 }
6194 return $flags
6195 }
6196
6197 # Add to FLAGS the flags needed to enable 64-bit vectors.
6198
6199 proc add_options_for_double_vectors { flags } {
6200 if [is-effective-target arm_neon_ok] {
6201 return "$flags -mvectorize-with-neon-double"
6202 }
6203
6204 return $flags
6205 }
6206
6207 # Return 1 if the target provides a full C99 runtime.
6208
6209 proc check_effective_target_c99_runtime { } {
6210 return [check_cached_effective_target c99_runtime {
6211 global srcdir
6212
6213 set file [open "$srcdir/gcc.dg/builtins-config.h"]
6214 set contents [read $file]
6215 close $file
6216 append contents {
6217 #ifndef HAVE_C99_RUNTIME
6218 #error !HAVE_C99_RUNTIME
6219 #endif
6220 }
6221 check_no_compiler_messages_nocache c99_runtime assembly \
6222 $contents [add_options_for_c99_runtime ""]
6223 }]
6224 }
6225
6226 # Return 1 if target wchar_t is at least 4 bytes.
6227
6228 proc check_effective_target_4byte_wchar_t { } {
6229 return [check_no_compiler_messages 4byte_wchar_t object {
6230 int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1];
6231 }]
6232 }
6233
6234 # Return 1 if the target supports automatic stack alignment.
6235
6236 proc check_effective_target_automatic_stack_alignment { } {
6237 # Ordinarily x86 supports automatic stack alignment ...
6238 if { [istarget i?86*-*-*] || [istarget x86_64-*-*] } then {
6239 if { [istarget *-*-mingw*] || [istarget *-*-cygwin*] } {
6240 # ... except Win64 SEH doesn't. Succeed for Win32 though.
6241 return [check_effective_target_ilp32];
6242 }
6243 return 1;
6244 }
6245 return 0;
6246 }
6247
6248 # Return true if we are compiling for AVX target.
6249
6250 proc check_avx_available { } {
6251 if { [check_no_compiler_messages avx_available assembly {
6252 #ifndef __AVX__
6253 #error unsupported
6254 #endif
6255 } ""] } {
6256 return 1;
6257 }
6258 return 0;
6259 }
6260
6261 # Return true if 32- and 16-bytes vectors are available.
6262
6263 proc check_effective_target_vect_sizes_32B_16B { } {
6264 if { [check_avx_available] && ![check_prefer_avx128] } {
6265 return 1;
6266 } else {
6267 return 0;
6268 }
6269 }
6270
6271 # Return true if 128-bits vectors are preferred even if 256-bits vectors
6272 # are available.
6273
6274 proc check_prefer_avx128 { } {
6275 if ![check_avx_available] {
6276 return 0;
6277 }
6278 return [check_no_messages_and_pattern avx_explicit "xmm" assembly {
6279 float a[1024],b[1024],c[1024];
6280 void foo (void) { int i; for (i = 0; i < 1024; i++) a[i]=b[i]+c[i];}
6281 } "-O2 -ftree-vectorize"]
6282 }
6283
6284
6285 # Return 1 if avx512f instructions can be compiled.
6286
6287 proc check_effective_target_avx512f { } {
6288 return [check_no_compiler_messages avx512f object {
6289 typedef double __m512d __attribute__ ((__vector_size__ (64)));
6290
6291 __m512d _mm512_add (__m512d a)
6292 {
6293 return __builtin_ia32_addpd512_mask (a, a, a, 1, 4);
6294 }
6295 } "-O2 -mavx512f" ]
6296 }
6297
6298 # Return 1 if avx instructions can be compiled.
6299
6300 proc check_effective_target_avx { } {
6301 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6302 return 0
6303 }
6304 return [check_no_compiler_messages avx object {
6305 void _mm256_zeroall (void)
6306 {
6307 __builtin_ia32_vzeroall ();
6308 }
6309 } "-O2 -mavx" ]
6310 }
6311
6312 # Return 1 if avx2 instructions can be compiled.
6313 proc check_effective_target_avx2 { } {
6314 return [check_no_compiler_messages avx2 object {
6315 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
6316 __v4di
6317 mm256_is32_andnotsi256 (__v4di __X, __v4di __Y)
6318 {
6319 return __builtin_ia32_andnotsi256 (__X, __Y);
6320 }
6321 } "-O0 -mavx2" ]
6322 }
6323
6324 # Return 1 if sse instructions can be compiled.
6325 proc check_effective_target_sse { } {
6326 return [check_no_compiler_messages sse object {
6327 int main ()
6328 {
6329 __builtin_ia32_stmxcsr ();
6330 return 0;
6331 }
6332 } "-O2 -msse" ]
6333 }
6334
6335 # Return 1 if sse2 instructions can be compiled.
6336 proc check_effective_target_sse2 { } {
6337 return [check_no_compiler_messages sse2 object {
6338 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
6339
6340 __m128i _mm_srli_si128 (__m128i __A, int __N)
6341 {
6342 return (__m128i)__builtin_ia32_psrldqi128 (__A, 8);
6343 }
6344 } "-O2 -msse2" ]
6345 }
6346
6347 # Return 1 if F16C instructions can be compiled.
6348
6349 proc check_effective_target_f16c { } {
6350 return [check_no_compiler_messages f16c object {
6351 #include "immintrin.h"
6352 float
6353 foo (unsigned short val)
6354 {
6355 return _cvtsh_ss (val);
6356 }
6357 } "-O2 -mf16c" ]
6358 }
6359
6360 # Return 1 if C wchar_t type is compatible with char16_t.
6361
6362 proc check_effective_target_wchar_t_char16_t_compatible { } {
6363 return [check_no_compiler_messages wchar_t_char16_t object {
6364 __WCHAR_TYPE__ wc;
6365 __CHAR16_TYPE__ *p16 = &wc;
6366 char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
6367 }]
6368 }
6369
6370 # Return 1 if C wchar_t type is compatible with char32_t.
6371
6372 proc check_effective_target_wchar_t_char32_t_compatible { } {
6373 return [check_no_compiler_messages wchar_t_char32_t object {
6374 __WCHAR_TYPE__ wc;
6375 __CHAR32_TYPE__ *p32 = &wc;
6376 char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1];
6377 }]
6378 }
6379
6380 # Return 1 if pow10 function exists.
6381
6382 proc check_effective_target_pow10 { } {
6383 return [check_runtime pow10 {
6384 #include <math.h>
6385 int main () {
6386 double x;
6387 x = pow10 (1);
6388 return 0;
6389 }
6390 } "-lm" ]
6391 }
6392
6393 # Return 1 if issignaling function exists.
6394 proc check_effective_target_issignaling {} {
6395 return [check_runtime issignaling {
6396 #define _GNU_SOURCE
6397 #include <math.h>
6398 int main ()
6399 {
6400 return issignaling (0.0);
6401 }
6402 } "-lm" ]
6403 }
6404
6405 # Return 1 if current options generate DFP instructions, 0 otherwise.
6406 proc check_effective_target_hard_dfp {} {
6407 return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly {
6408 typedef float d64 __attribute__((mode(DD)));
6409 d64 x, y, z;
6410 void foo (void) { z = x + y; }
6411 }]
6412 }
6413
6414 # Return 1 if string.h and wchar.h headers provide C++ requires overloads
6415 # for strchr etc. functions.
6416
6417 proc check_effective_target_correct_iso_cpp_string_wchar_protos { } {
6418 return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly {
6419 #include <string.h>
6420 #include <wchar.h>
6421 #if !defined(__cplusplus) \
6422 || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \
6423 || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO)
6424 ISO C++ correct string.h and wchar.h protos not supported.
6425 #else
6426 int i;
6427 #endif
6428 }]
6429 }
6430
6431 # Return 1 if GNU as is used.
6432
6433 proc check_effective_target_gas { } {
6434 global use_gas_saved
6435 global tool
6436
6437 if {![info exists use_gas_saved]} {
6438 # Check if the as used by gcc is GNU as.
6439 set gcc_as [lindex [${tool}_target_compile "-print-prog-name=as" "" "none" ""] 0]
6440 # Provide /dev/null as input, otherwise gas times out reading from
6441 # stdin.
6442 set status [remote_exec host "$gcc_as" "-v /dev/null"]
6443 set as_output [lindex $status 1]
6444 if { [ string first "GNU" $as_output ] >= 0 } {
6445 set use_gas_saved 1
6446 } else {
6447 set use_gas_saved 0
6448 }
6449 }
6450 return $use_gas_saved
6451 }
6452
6453 # Return 1 if GNU ld is used.
6454
6455 proc check_effective_target_gld { } {
6456 global use_gld_saved
6457 global tool
6458
6459 if {![info exists use_gld_saved]} {
6460 # Check if the ld used by gcc is GNU ld.
6461 set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=ld" "" "none" ""] 0]
6462 set status [remote_exec host "$gcc_ld" "--version"]
6463 set ld_output [lindex $status 1]
6464 if { [ string first "GNU" $ld_output ] >= 0 } {
6465 set use_gld_saved 1
6466 } else {
6467 set use_gld_saved 0
6468 }
6469 }
6470 return $use_gld_saved
6471 }
6472
6473 # Return 1 if the compiler has been configure with link-time optimization
6474 # (LTO) support.
6475
6476 proc check_effective_target_lto { } {
6477 if { [istarget nvptx-*-*] } {
6478 return 0;
6479 }
6480 return [check_no_compiler_messages lto object {
6481 void foo (void) { }
6482 } "-flto"]
6483 }
6484
6485 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
6486
6487 proc check_effective_target_maybe_x32 { } {
6488 return [check_no_compiler_messages maybe_x32 object {
6489 void foo (void) {}
6490 } "-mx32 -maddress-mode=short"]
6491 }
6492
6493 # Return 1 if this target supports the -fsplit-stack option, 0
6494 # otherwise.
6495
6496 proc check_effective_target_split_stack {} {
6497 return [check_no_compiler_messages split_stack object {
6498 void foo (void) { }
6499 } "-fsplit-stack"]
6500 }
6501
6502 # Return 1 if this target supports the -masm=intel option, 0
6503 # otherwise
6504
6505 proc check_effective_target_masm_intel {} {
6506 return [check_no_compiler_messages masm_intel object {
6507 extern void abort (void);
6508 } "-masm=intel"]
6509 }
6510
6511 # Return 1 if the language for the compiler under test is C.
6512
6513 proc check_effective_target_c { } {
6514 global tool
6515 if [string match $tool "gcc"] {
6516 return 1
6517 }
6518 return 0
6519 }
6520
6521 # Return 1 if the language for the compiler under test is C++.
6522
6523 proc check_effective_target_c++ { } {
6524 global tool
6525 if [string match $tool "g++"] {
6526 return 1
6527 }
6528 return 0
6529 }
6530
6531 set cxx_default "c++14"
6532 # Check whether the current active language standard supports the features
6533 # of C++11/C++14 by checking for the presence of one of the -std flags.
6534 # This assumes that the default for the compiler is $cxx_default, and that
6535 # there will never be multiple -std= arguments on the command line.
6536 proc check_effective_target_c++11_only { } {
6537 global cxx_default
6538 if ![check_effective_target_c++] {
6539 return 0
6540 }
6541 if [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }] {
6542 return 1
6543 }
6544 if { $cxx_default == "c++11" && [check-flags { { } { } { } { -std=* } }] } {
6545 return 1
6546 }
6547 return 0
6548 }
6549 proc check_effective_target_c++11 { } {
6550 if [check_effective_target_c++11_only] {
6551 return 1
6552 }
6553 return [check_effective_target_c++14]
6554 }
6555 proc check_effective_target_c++11_down { } {
6556 if ![check_effective_target_c++] {
6557 return 0
6558 }
6559 return [expr ![check_effective_target_c++14] ]
6560 }
6561
6562 proc check_effective_target_c++14_only { } {
6563 global cxx_default
6564 if ![check_effective_target_c++] {
6565 return 0
6566 }
6567 if [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }] {
6568 return 1
6569 }
6570 if { $cxx_default == "c++14" && [check-flags { { } { } { } { -std=* } }] } {
6571 return 1
6572 }
6573 return 0
6574 }
6575
6576 proc check_effective_target_c++14 { } {
6577 if [check_effective_target_c++14_only] {
6578 return 1
6579 }
6580 return [check_effective_target_c++1z]
6581 }
6582 proc check_effective_target_c++14_down { } {
6583 if ![check_effective_target_c++] {
6584 return 0
6585 }
6586 return [expr ![check_effective_target_c++1z] ]
6587 }
6588
6589 proc check_effective_target_c++98_only { } {
6590 global cxx_default
6591 if ![check_effective_target_c++] {
6592 return 0
6593 }
6594 if [check-flags { { } { } { -std=c++98 -std=gnu++98 -std=c++03 -std=gnu++03 } }] {
6595 return 1
6596 }
6597 if { $cxx_default == "c++98" && [check-flags { { } { } { } { -std=* } }] } {
6598 return 1
6599 }
6600 return 0
6601 }
6602
6603 proc check_effective_target_c++1z_only { } {
6604 global cxx_default
6605 if ![check_effective_target_c++] {
6606 return 0
6607 }
6608 if [check-flags { { } { } { -std=c++17 -std=gnu++17 -std=c++1z -std=gnu++1z } }] {
6609 return 1
6610 }
6611 if { $cxx_default == "c++17" && [check-flags { { } { } { } { -std=* } }] } {
6612 return 1
6613 }
6614 return 0
6615 }
6616 proc check_effective_target_c++1z { } {
6617 return [check_effective_target_c++1z_only]
6618 }
6619
6620 # Check for C++ Concepts TS support, i.e. -fconcepts flag.
6621 proc check_effective_target_concepts { } {
6622 return [check-flags { "" { } { -fconcepts } }]
6623 }
6624
6625 # Return 1 if expensive testcases should be run.
6626
6627 proc check_effective_target_run_expensive_tests { } {
6628 if { [getenv GCC_TEST_RUN_EXPENSIVE] != "" } {
6629 return 1
6630 }
6631 return 0
6632 }
6633
6634 # Returns 1 if "mempcpy" is available on the target system.
6635
6636 proc check_effective_target_mempcpy {} {
6637 return [check_function_available "mempcpy"]
6638 }
6639
6640 # Returns 1 if "stpcpy" is available on the target system.
6641
6642 proc check_effective_target_stpcpy {} {
6643 return [check_function_available "stpcpy"]
6644 }
6645
6646 # Check whether the vectorizer tests are supported by the target and
6647 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
6648 # Set dg-do-what-default to either compile or run, depending on target
6649 # capabilities. Return 1 if vectorizer tests are supported by
6650 # target, 0 otherwise.
6651
6652 proc check_vect_support_and_set_flags { } {
6653 global DEFAULT_VECTCFLAGS
6654 global dg-do-what-default
6655
6656 if [istarget powerpc-*paired*] {
6657 lappend DEFAULT_VECTCFLAGS "-mpaired"
6658 if [check_750cl_hw_available] {
6659 set dg-do-what-default run
6660 } else {
6661 set dg-do-what-default compile
6662 }
6663 } elseif [istarget powerpc*-*-*] {
6664 # Skip targets not supporting -maltivec.
6665 if ![is-effective-target powerpc_altivec_ok] {
6666 return 0
6667 }
6668
6669 lappend DEFAULT_VECTCFLAGS "-maltivec"
6670 if [check_p9vector_hw_available] {
6671 lappend DEFAULT_VECTCFLAGS "-mpower9-vector"
6672 } elseif [check_p8vector_hw_available] {
6673 lappend DEFAULT_VECTCFLAGS "-mpower8-vector"
6674 } elseif [check_vsx_hw_available] {
6675 lappend DEFAULT_VECTCFLAGS "-mvsx" "-mno-allow-movmisalign"
6676 }
6677
6678 if [check_vmx_hw_available] {
6679 set dg-do-what-default run
6680 } else {
6681 if [is-effective-target ilp32] {
6682 # Specify a cpu that supports VMX for compile-only tests.
6683 lappend DEFAULT_VECTCFLAGS "-mcpu=970"
6684 }
6685 set dg-do-what-default compile
6686 }
6687 } elseif { [istarget spu-*-*] } {
6688 set dg-do-what-default run
6689 } elseif { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
6690 lappend DEFAULT_VECTCFLAGS "-msse2"
6691 if { [check_effective_target_sse2_runtime] } {
6692 set dg-do-what-default run
6693 } else {
6694 set dg-do-what-default compile
6695 }
6696 } elseif { [istarget mips*-*-*]
6697 && ([check_effective_target_mpaired_single]
6698 || [check_effective_target_mips_loongson])
6699 && [check_effective_target_nomips16] } {
6700 if { [check_effective_target_mpaired_single] } {
6701 lappend DEFAULT_VECTCFLAGS "-mpaired-single"
6702 }
6703 set dg-do-what-default run
6704 } elseif [istarget sparc*-*-*] {
6705 lappend DEFAULT_VECTCFLAGS "-mcpu=ultrasparc" "-mvis"
6706 if [check_effective_target_ultrasparc_hw] {
6707 set dg-do-what-default run
6708 } else {
6709 set dg-do-what-default compile
6710 }
6711 } elseif [istarget alpha*-*-*] {
6712 # Alpha's vectorization capabilities are extremely limited.
6713 # It's more effort than its worth disabling all of the tests
6714 # that it cannot pass. But if you actually want to see what
6715 # does work, command out the return.
6716 return 0
6717
6718 lappend DEFAULT_VECTCFLAGS "-mmax"
6719 if [check_alpha_max_hw_available] {
6720 set dg-do-what-default run
6721 } else {
6722 set dg-do-what-default compile
6723 }
6724 } elseif [istarget ia64-*-*] {
6725 set dg-do-what-default run
6726 } elseif [is-effective-target arm_neon_ok] {
6727 eval lappend DEFAULT_VECTCFLAGS [add_options_for_arm_neon ""]
6728 # NEON does not support denormals, so is not used for vectorization by
6729 # default to avoid loss of precision. We must pass -ffast-math to test
6730 # vectorization of float operations.
6731 lappend DEFAULT_VECTCFLAGS "-ffast-math"
6732 if [is-effective-target arm_neon_hw] {
6733 set dg-do-what-default run
6734 } else {
6735 set dg-do-what-default compile
6736 }
6737 } elseif [istarget "aarch64*-*-*"] {
6738 set dg-do-what-default run
6739 } else {
6740 return 0
6741 }
6742
6743 return 1
6744 }
6745
6746 # Return 1 if the target does *not* require strict alignment.
6747
6748 proc check_effective_target_non_strict_align {} {
6749
6750 # On ARM, the default is to use STRICT_ALIGNMENT, but there
6751 # are interfaces defined for misaligned access and thus
6752 # depending on the architecture levels unaligned access is
6753 # available.
6754 if [istarget "arm*-*-*"] {
6755 return [check_effective_target_arm_unaligned]
6756 }
6757
6758 return [check_no_compiler_messages non_strict_align assembly {
6759 char *y;
6760 typedef char __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__))) c;
6761 c *z;
6762 void foo(void) { z = (c *) y; }
6763 } "-Wcast-align"]
6764 }
6765
6766 # Return 1 if the target has <ucontext.h>.
6767
6768 proc check_effective_target_ucontext_h { } {
6769 return [check_no_compiler_messages ucontext_h assembly {
6770 #include <ucontext.h>
6771 }]
6772 }
6773
6774 proc check_effective_target_aarch64_tiny { } {
6775 if { [istarget aarch64*-*-*] } {
6776 return [check_no_compiler_messages aarch64_tiny object {
6777 #ifdef __AARCH64_CMODEL_TINY__
6778 int dummy;
6779 #else
6780 #error target not AArch64 tiny code model
6781 #endif
6782 }]
6783 } else {
6784 return 0
6785 }
6786 }
6787
6788 # Create functions to check that the AArch64 assembler supports the
6789 # various architecture extensions via the .arch_extension pseudo-op.
6790
6791 foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse"} {
6792 eval [string map [list FUNC $aarch64_ext] {
6793 proc check_effective_target_aarch64_asm_FUNC_ok { } {
6794 if { [istarget aarch64*-*-*] } {
6795 return [check_no_compiler_messages aarch64_FUNC_assembler object {
6796 __asm__ (".arch_extension FUNC");
6797 } "-march=armv8-a+FUNC"]
6798 } else {
6799 return 0
6800 }
6801 }
6802 }]
6803 }
6804
6805 proc check_effective_target_aarch64_small { } {
6806 if { [istarget aarch64*-*-*] } {
6807 return [check_no_compiler_messages aarch64_small object {
6808 #ifdef __AARCH64_CMODEL_SMALL__
6809 int dummy;
6810 #else
6811 #error target not AArch64 small code model
6812 #endif
6813 }]
6814 } else {
6815 return 0
6816 }
6817 }
6818
6819 proc check_effective_target_aarch64_large { } {
6820 if { [istarget aarch64*-*-*] } {
6821 return [check_no_compiler_messages aarch64_large object {
6822 #ifdef __AARCH64_CMODEL_LARGE__
6823 int dummy;
6824 #else
6825 #error target not AArch64 large code model
6826 #endif
6827 }]
6828 } else {
6829 return 0
6830 }
6831 }
6832
6833 # Return 1 if <fenv.h> is available with all the standard IEEE
6834 # exceptions and floating-point exceptions are raised by arithmetic
6835 # operations. (If the target requires special options for "inexact"
6836 # exceptions, those need to be specified in the testcases.)
6837
6838 proc check_effective_target_fenv_exceptions {} {
6839 return [check_runtime fenv_exceptions {
6840 #include <fenv.h>
6841 #include <stdlib.h>
6842 #ifndef FE_DIVBYZERO
6843 # error Missing FE_DIVBYZERO
6844 #endif
6845 #ifndef FE_INEXACT
6846 # error Missing FE_INEXACT
6847 #endif
6848 #ifndef FE_INVALID
6849 # error Missing FE_INVALID
6850 #endif
6851 #ifndef FE_OVERFLOW
6852 # error Missing FE_OVERFLOW
6853 #endif
6854 #ifndef FE_UNDERFLOW
6855 # error Missing FE_UNDERFLOW
6856 #endif
6857 volatile float a = 0.0f, r;
6858 int
6859 main (void)
6860 {
6861 r = a / a;
6862 if (fetestexcept (FE_INVALID))
6863 exit (0);
6864 else
6865 abort ();
6866 }
6867 } [add_options_for_ieee "-std=gnu99"]]
6868 }
6869
6870 proc check_effective_target_tiny {} {
6871 global et_target_tiny_saved
6872
6873 if [info exists et_target_tine_saved] {
6874 verbose "check_effective_target_tiny: using cached result" 2
6875 } else {
6876 set et_target_tiny_saved 0
6877 if { [istarget aarch64*-*-*]
6878 && [check_effective_target_aarch64_tiny] } {
6879 set et_target_tiny_saved 1
6880 }
6881 }
6882
6883 return $et_target_tiny_saved
6884 }
6885
6886 # Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
6887
6888 proc check_effective_target_logical_op_short_circuit {} {
6889 if { [istarget mips*-*-*]
6890 || [istarget arc*-*-*]
6891 || [istarget avr*-*-*]
6892 || [istarget crisv32-*-*] || [istarget cris-*-*]
6893 || [istarget mmix-*-*]
6894 || [istarget s390*-*-*]
6895 || [istarget powerpc*-*-*]
6896 || [istarget nios2*-*-*]
6897 || [istarget visium-*-*]
6898 || [check_effective_target_arm_cortex_m] } {
6899 return 1
6900 }
6901 return 0
6902 }
6903
6904 # Record that dg-final test TEST requires convential compilation.
6905
6906 proc force_conventional_output_for { test } {
6907 if { [info proc $test] == "" } {
6908 perror "$test does not exist"
6909 exit 1
6910 }
6911 proc ${test}_required_options {} {
6912 global gcc_force_conventional_output
6913 return $gcc_force_conventional_output
6914 }
6915 }
6916
6917 # Return 1 if the x86-64 target supports PIE with copy reloc, 0
6918 # otherwise. Cache the result.
6919
6920 proc check_effective_target_pie_copyreloc { } {
6921 global pie_copyreloc_available_saved
6922 global tool
6923 global GCC_UNDER_TEST
6924
6925 if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
6926 return 0
6927 }
6928
6929 # Need auto-host.h to check linker support.
6930 if { ![file exists ../../auto-host.h ] } {
6931 return 0
6932 }
6933
6934 if [info exists pie_copyreloc_available_saved] {
6935 verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
6936 } else {
6937 # Set up and compile to see if linker supports PIE with copy
6938 # reloc. Include the current process ID in the file names to
6939 # prevent conflicts with invocations for multiple testsuites.
6940
6941 set src pie[pid].c
6942 set obj pie[pid].o
6943
6944 set f [open $src "w"]
6945 puts $f "#include \"../../auto-host.h\""
6946 puts $f "#if HAVE_LD_PIE_COPYRELOC == 0"
6947 puts $f "# error Linker does not support PIE with copy reloc."
6948 puts $f "#endif"
6949 close $f
6950
6951 verbose "check_effective_target_pie_copyreloc compiling testfile $src" 2
6952 set lines [${tool}_target_compile $src $obj object ""]
6953
6954 file delete $src
6955 file delete $obj
6956
6957 if [string match "" $lines] then {
6958 verbose "check_effective_target_pie_copyreloc testfile compilation passed" 2
6959 set pie_copyreloc_available_saved 1
6960 } else {
6961 verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
6962 set pie_copyreloc_available_saved 0
6963 }
6964 }
6965
6966 return $pie_copyreloc_available_saved
6967 }
6968
6969 # Return 1 if the target uses comdat groups.
6970
6971 proc check_effective_target_comdat_group {} {
6972 return [check_no_messages_and_pattern comdat_group "\.section\[^\n\r]*,comdat" assembly {
6973 // C++
6974 inline int foo () { return 1; }
6975 int (*fn) () = foo;
6976 }]
6977 }
6978
6979 # Return 1 if target supports __builtin_eh_return
6980 proc check_effective_target_builtin_eh_return { } {
6981 return [check_no_compiler_messages builtin_eh_return object {
6982 void test (long l, void *p)
6983 {
6984 __builtin_eh_return (l, p);
6985 }
6986 } "" ]
6987 }
6988
6989 # Return 1 if the target supports max reduction for vectors.
6990
6991 proc check_effective_target_vect_max_reduc { } {
6992 if { [istarget aarch64*-*-*] || [istarget arm*-*-*] } {
6993 return 1
6994 }
6995 return 0
6996 }
6997
6998 # Return 1 if there is an nvptx offload compiler.
6999
7000 proc check_effective_target_offload_nvptx { } {
7001 return [check_no_compiler_messages offload_nvptx object {
7002 int main () {return 0;}
7003 } "-foffload=nvptx-none" ]
7004 }
7005
7006 # Return 1 if the compiler has been configured with hsa offloading.
7007
7008 proc check_effective_target_offload_hsa { } {
7009 return [check_no_compiler_messages offload_hsa assembly {
7010 int main () {return 0;}
7011 } "-foffload=hsa" ]
7012 }