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