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