]>
Commit | Line | Data |
---|---|---|
b6c6057e | 1 | # Copyright (C) 1999, 2001, 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
f63ff66b | 2 | # Free Software Foundation, Inc. |
fe804fc2 | 3 | |
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
f63ff66b | 6 | # the Free Software Foundation; either version 3 of the License, or |
fe804fc2 | 7 | # (at your option) any later version. |
ccb84981 | 8 | # |
fe804fc2 | 9 | # This program is distributed in the hope that it will be useful, |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
ccb84981 | 13 | # |
fe804fc2 | 14 | # You should have received a copy of the GNU General Public License |
f63ff66b | 15 | # along with GCC; see the file COPYING3. If not see |
16 | # <http://www.gnu.org/licenses/>. | |
fe804fc2 | 17 | |
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # gcc-patches@gcc.gnu.org | |
20 | ||
21 | # This file defines procs for determining features supported by the target. | |
22 | ||
383ec9c4 | 23 | # Try to compile the code given by CONTENTS into an output file of |
24 | # type TYPE, where TYPE is as for target_compile. Return a list | |
25 | # whose first element contains the compiler messages and whose | |
26 | # second element is the name of the output file. | |
34d688ab | 27 | # |
383ec9c4 | 28 | # BASENAME is a prefix to use for source and output files. |
29 | # If ARGS is not empty, its first element is a string that | |
30 | # should be added to the command line. | |
31 | # | |
32 | # Assume by default that CONTENTS is C code. C++ code should contain | |
33 | # "// C++" and Fortran code should contain "! Fortran". | |
34 | proc check_compile {basename type contents args} { | |
34d688ab | 35 | global tool |
36 | ||
60786eff | 37 | if { [llength $args] > 0 } { |
57e21dbf | 38 | set options [list "additional_flags=[lindex $args 0]"] |
60786eff | 39 | } else { |
40 | set options "" | |
41 | } | |
383ec9c4 | 42 | switch -glob -- $contents { |
43 | "*! Fortran*" { set src ${basename}[pid].f90 } | |
44 | "*// C++*" { set src ${basename}[pid].cc } | |
45 | default { set src ${basename}[pid].c } | |
46 | } | |
8d22f418 | 47 | set compile_type $type |
48 | switch -glob $type { | |
34d688ab | 49 | assembly { set output ${basename}[pid].s } |
50 | object { set output ${basename}[pid].o } | |
383ec9c4 | 51 | executable { set output ${basename}[pid].exe } |
8d22f418 | 52 | "rtl-*" { |
53 | set output ${basename}[pid].s | |
54 | lappend options "additional_flags=-fdump-$type" | |
55 | set compile_type assembly | |
56 | } | |
34d688ab | 57 | } |
58 | set f [open $src "w"] | |
59 | puts $f $contents | |
60 | close $f | |
8d22f418 | 61 | set lines [${tool}_target_compile $src $output $compile_type "$options"] |
34d688ab | 62 | file delete $src |
34d688ab | 63 | |
8d22f418 | 64 | set scan_output $output |
65 | # Don't try folding this into the switch above; calling "glob" before the | |
66 | # file is created won't work. | |
67 | if [regexp "rtl-(.*)" $type dummy rtl_type] { | |
68 | set scan_output "[glob $src.\[0-9\]\[0-9\]\[0-9\]r.$rtl_type]" | |
69 | file delete $output | |
70 | } | |
71 | ||
72 | return [list $lines $scan_output] | |
34d688ab | 73 | } |
74 | ||
d24b67c0 | 75 | proc current_target_name { } { |
76 | global target_info | |
77 | if [info exists target_info(target,name)] { | |
78 | set answer $target_info(target,name) | |
79 | } else { | |
80 | set answer "" | |
81 | } | |
82 | return $answer | |
83 | } | |
84 | ||
b7714d40 | 85 | # Implement an effective-target check for property PROP by invoking |
720f6ebb | 86 | # the Tcl command ARGS and seeing if it returns true. |
87 | ||
88 | proc check_cached_effective_target { prop args } { | |
b7714d40 | 89 | global et_cache |
90 | ||
91 | set target [current_target_name] | |
92 | if {![info exists et_cache($prop,target)] | |
93 | || $et_cache($prop,target) != $target} { | |
720f6ebb | 94 | verbose "check_cached_effective_target $prop: checking $target" 2 |
4533b23c | 95 | set et_cache($prop,target) $target |
720f6ebb | 96 | set et_cache($prop,value) [uplevel eval $args] |
4533b23c | 97 | } |
98 | set value $et_cache($prop,value) | |
720f6ebb | 99 | verbose "check_cached_effective_target $prop: returning $value for $target" 2 |
4533b23c | 100 | return $value |
101 | } | |
102 | ||
383ec9c4 | 103 | # Like check_compile, but delete the output file and return true if the |
104 | # compiler printed no messages. | |
105 | proc check_no_compiler_messages_nocache {args} { | |
106 | set result [eval check_compile $args] | |
107 | set lines [lindex $result 0] | |
108 | set output [lindex $result 1] | |
109 | remote_file build delete $output | |
110 | return [string match "" $lines] | |
111 | } | |
112 | ||
113 | # Like check_no_compiler_messages_nocache, but cache the result. | |
114 | # PROP is the property we're checking, and doubles as a prefix for | |
115 | # temporary filenames. | |
720f6ebb | 116 | proc check_no_compiler_messages {prop args} { |
117 | return [check_cached_effective_target $prop { | |
383ec9c4 | 118 | eval [list check_no_compiler_messages_nocache $prop] $args |
720f6ebb | 119 | }] |
120 | } | |
121 | ||
383ec9c4 | 122 | # Like check_compile, but return true if the compiler printed no |
123 | # messages and if the contents of the output file satisfy PATTERN. | |
124 | # If PATTERN has the form "!REGEXP", the contents satisfy it if they | |
125 | # don't match regular expression REGEXP, otherwise they satisfy it | |
126 | # if they do match regular expression PATTERN. (PATTERN can start | |
127 | # with something like "[!]" if the regular expression needs to match | |
128 | # "!" as the first character.) | |
129 | # | |
130 | # Delete the output file before returning. The other arguments are | |
131 | # as for check_compile. | |
132 | proc check_no_messages_and_pattern_nocache {basename pattern args} { | |
133 | global tool | |
134 | ||
135 | set result [eval [list check_compile $basename] $args] | |
136 | set lines [lindex $result 0] | |
137 | set output [lindex $result 1] | |
138 | ||
139 | set ok 0 | |
140 | if { [string match "" $lines] } { | |
141 | set chan [open "$output"] | |
142 | set invert [regexp {^!(.*)} $pattern dummy pattern] | |
143 | set ok [expr { [regexp $pattern [read $chan]] != $invert }] | |
144 | close $chan | |
145 | } | |
146 | ||
147 | remote_file build delete $output | |
148 | return $ok | |
149 | } | |
150 | ||
151 | # Like check_no_messages_and_pattern_nocache, but cache the result. | |
152 | # PROP is the property we're checking, and doubles as a prefix for | |
153 | # temporary filenames. | |
4533b23c | 154 | proc check_no_messages_and_pattern {prop pattern args} { |
720f6ebb | 155 | return [check_cached_effective_target $prop { |
383ec9c4 | 156 | eval [list check_no_messages_and_pattern_nocache $prop $pattern] $args |
157 | }] | |
158 | } | |
159 | ||
160 | # Try to compile and run an executable from code CONTENTS. Return true | |
161 | # if the compiler reports no messages and if execution "passes" in the | |
162 | # usual DejaGNU sense. The arguments are as for check_compile, with | |
163 | # TYPE implicitly being "executable". | |
164 | proc check_runtime_nocache {basename contents args} { | |
165 | global tool | |
166 | ||
167 | set result [eval [list check_compile $basename executable $contents] $args] | |
168 | set lines [lindex $result 0] | |
169 | set output [lindex $result 1] | |
170 | ||
171 | set ok 0 | |
172 | if { [string match "" $lines] } { | |
173 | # No error messages, everything is OK. | |
174 | set result [remote_load target "./$output" "" ""] | |
175 | set status [lindex $result 0] | |
176 | verbose "check_runtime_nocache $basename: status is <$status>" 2 | |
177 | if { $status == "pass" } { | |
178 | set ok 1 | |
179 | } | |
180 | } | |
181 | remote_file build delete $output | |
182 | return $ok | |
183 | } | |
184 | ||
185 | # Like check_runtime_nocache, but cache the result. PROP is the | |
186 | # property we're checking, and doubles as a prefix for temporary | |
187 | # filenames. | |
188 | proc check_runtime {prop args} { | |
189 | global tool | |
190 | ||
191 | return [check_cached_effective_target $prop { | |
192 | eval [list check_runtime_nocache $prop] $args | |
720f6ebb | 193 | }] |
b7714d40 | 194 | } |
195 | ||
fe804fc2 | 196 | ############################### |
197 | # proc check_weak_available { } | |
198 | ############################### | |
199 | ||
200 | # weak symbols are only supported in some configs/object formats | |
201 | # this proc returns 1 if they're supported, 0 if they're not, or -1 if unsure | |
202 | ||
203 | proc check_weak_available { } { | |
00320b83 | 204 | global target_triplet |
fe804fc2 | 205 | global target_cpu |
206 | ||
207 | # All mips targets should support it | |
ccb84981 | 208 | |
fe804fc2 | 209 | if { [ string first "mips" $target_cpu ] >= 0 } { |
210 | return 1 | |
211 | } | |
212 | ||
ebee689c | 213 | # All solaris2 targets should support it |
ccb84981 | 214 | |
ebee689c | 215 | if { [regexp ".*-solaris2.*" $target_triplet] } { |
216 | return 1 | |
217 | } | |
218 | ||
00320b83 | 219 | # DEC OSF/1/Digital UNIX/Tru64 UNIX supports it |
220 | ||
221 | if { [regexp "alpha.*osf.*" $target_triplet] } { | |
222 | return 1 | |
223 | } | |
224 | ||
570d41f9 | 225 | # Windows targets Cygwin and MingW32 support it |
226 | ||
227 | if { [regexp ".*mingw32|.*cygwin" $target_triplet] } { | |
228 | return 1 | |
229 | } | |
230 | ||
1a6c50b8 | 231 | # HP-UX 10.X doesn't support it |
232 | ||
5a1cd9d8 | 233 | if { [istarget "hppa*-*-hpux10*"] } { |
1a6c50b8 | 234 | return 0 |
235 | } | |
236 | ||
fe804fc2 | 237 | # ELF and ECOFF support it. a.out does with gas/gld but may also with |
238 | # other linkers, so we should try it | |
239 | ||
240 | set objformat [gcc_target_object_format] | |
241 | ||
242 | switch $objformat { | |
243 | elf { return 1 } | |
244 | ecoff { return 1 } | |
245 | a.out { return 1 } | |
e561fc1c | 246 | mach-o { return 1 } |
1a6c50b8 | 247 | som { return 1 } |
fe804fc2 | 248 | unknown { return -1 } |
249 | default { return 0 } | |
250 | } | |
251 | } | |
252 | ||
cabf5d2b | 253 | ############################### |
254 | # proc check_weak_override_available { } | |
255 | ############################### | |
256 | ||
257 | # Like check_weak_available, but return 0 if weak symbol definitions | |
258 | # cannot be overridden. | |
259 | ||
260 | proc check_weak_override_available { } { | |
261 | if { [istarget "*-*-mingw*"] } { | |
262 | return 0 | |
263 | } | |
264 | return [check_weak_available] | |
265 | } | |
266 | ||
50333348 | 267 | ############################### |
683c8e7c | 268 | # proc check_visibility_available { what_kind } |
50333348 | 269 | ############################### |
270 | ||
271 | # The visibility attribute is only support in some object formats | |
1dcec918 | 272 | # This proc returns 1 if it is supported, 0 if not. |
683c8e7c | 273 | # The argument is the kind of visibility, default/protected/hidden/internal. |
50333348 | 274 | |
683c8e7c | 275 | proc check_visibility_available { what_kind } { |
1dcec918 | 276 | global tool |
50333348 | 277 | global target_triplet |
50333348 | 278 | |
634f7a13 | 279 | # On NetWare, support makes no sense. |
c79d5a34 | 280 | if { [istarget *-*-netware*] } { |
634f7a13 | 281 | return 0 |
282 | } | |
283 | ||
683c8e7c | 284 | if [string match "" $what_kind] { set what_kind "hidden" } |
285 | ||
b7714d40 | 286 | return [check_no_compiler_messages visibility_available_$what_kind object " |
683c8e7c | 287 | void f() __attribute__((visibility(\"$what_kind\"))); |
288 | void f() {} | |
289 | "] | |
50333348 | 290 | } |
291 | ||
fe804fc2 | 292 | ############################### |
293 | # proc check_alias_available { } | |
294 | ############################### | |
295 | ||
296 | # Determine if the target toolchain supports the alias attribute. | |
fe804fc2 | 297 | |
176dca07 | 298 | # Returns 2 if the target supports aliases. Returns 1 if the target |
299 | # only supports weak aliased. Returns 0 if the target does not | |
300 | # support aliases at all. Returns -1 if support for aliases could not | |
301 | # be determined. | |
302 | ||
303 | proc check_alias_available { } { | |
fe804fc2 | 304 | global alias_available_saved |
007f9998 | 305 | global tool |
306 | ||
fe804fc2 | 307 | if [info exists alias_available_saved] { |
308 | verbose "check_alias_available returning saved $alias_available_saved" 2 | |
309 | } else { | |
85be136d | 310 | set src alias[pid].c |
311 | set obj alias[pid].o | |
312 | verbose "check_alias_available compiling testfile $src" 2 | |
313 | set f [open $src "w"] | |
9f7e3a88 | 314 | # Compile a small test program. The definition of "g" is |
315 | # necessary to keep the Solaris assembler from complaining | |
316 | # about the program. | |
751b045e | 317 | puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n" |
9f7e3a88 | 318 | puts $f "void g() {} void f() __attribute__((alias(\"g\")));" |
176dca07 | 319 | close $f |
85be136d | 320 | set lines [${tool}_target_compile $src $obj object ""] |
321 | file delete $src | |
322 | remote_file build delete $obj | |
176dca07 | 323 | |
fe804fc2 | 324 | if [string match "" $lines] then { |
325 | # No error messages, everything is OK. | |
176dca07 | 326 | set alias_available_saved 2 |
fe804fc2 | 327 | } else { |
328 | if [regexp "alias definitions not supported" $lines] { | |
329 | verbose "check_alias_available target does not support aliases" 2 | |
330 | ||
331 | set objformat [gcc_target_object_format] | |
332 | ||
333 | if { $objformat == "elf" } { | |
334 | verbose "check_alias_available but target uses ELF format, so it ought to" 2 | |
176dca07 | 335 | set alias_available_saved -1 |
fe804fc2 | 336 | } else { |
176dca07 | 337 | set alias_available_saved 0 |
fe804fc2 | 338 | } |
339 | } else { | |
65a5d44b | 340 | if [regexp "only weak aliases are supported" $lines] { |
341 | verbose "check_alias_available target supports only weak aliases" 2 | |
176dca07 | 342 | set alias_available_saved 1 |
65a5d44b | 343 | } else { |
176dca07 | 344 | set alias_available_saved -1 |
65a5d44b | 345 | } |
fe804fc2 | 346 | } |
347 | } | |
ccb84981 | 348 | |
fe804fc2 | 349 | verbose "check_alias_available returning $alias_available_saved" 2 |
350 | } | |
351 | ||
352 | return $alias_available_saved | |
353 | } | |
176dca07 | 354 | |
355 | # Returns true if --gc-sections is supported on the target. | |
356 | ||
357 | proc check_gc_sections_available { } { | |
358 | global gc_sections_available_saved | |
007f9998 | 359 | global tool |
176dca07 | 360 | |
53600772 | 361 | if {![info exists gc_sections_available_saved]} { |
e67e521b | 362 | # Some targets don't support gc-sections despite whatever's |
363 | # advertised by ld's options. | |
364 | if { [istarget alpha*-*-*] | |
365 | || [istarget ia64-*-*] } { | |
366 | set gc_sections_available_saved 0 | |
367 | return 0 | |
368 | } | |
369 | ||
1a802179 | 370 | # elf2flt uses -q (--emit-relocs), which is incompatible with |
371 | # --gc-sections. | |
372 | if { [board_info target exists ldflags] | |
373 | && [regexp " -elf2flt\[ =\]" " [board_info target ldflags] "] } { | |
374 | set gc_sections_available_saved 0 | |
375 | return 0 | |
376 | } | |
377 | ||
f32bff02 | 378 | # VxWorks kernel modules are relocatable objects linked with -r, |
379 | # while RTP executables are linked with -q (--emit-relocs). | |
380 | # Both of these options are incompatible with --gc-sections. | |
381 | if { [istarget *-*-vxworks*] } { | |
382 | set gc_sections_available_saved 0 | |
383 | return 0 | |
384 | } | |
385 | ||
176dca07 | 386 | # Check if the ld used by gcc supports --gc-sections. |
634f7a13 | 387 | set gcc_spec [${tool}_target_compile "-dumpspecs" "" "none" ""] |
388 | regsub ".*\n\*linker:\[ \t\]*\n(\[^ \t\n\]*).*" "$gcc_spec" {\1} linker | |
389 | set gcc_ld [lindex [${tool}_target_compile "-print-prog-name=$linker" "" "none" ""] 0] | |
176dca07 | 390 | set ld_output [remote_exec host "$gcc_ld" "--help"] |
391 | if { [ string first "--gc-sections" $ld_output ] >= 0 } { | |
392 | set gc_sections_available_saved 1 | |
393 | } else { | |
394 | set gc_sections_available_saved 0 | |
395 | } | |
396 | } | |
397 | return $gc_sections_available_saved | |
398 | } | |
152b4f70 | 399 | |
4f336ecc | 400 | # Return 1 if according to target_info struct and explicit target list |
401 | # target is supposed to support trampolines. | |
402 | ||
403 | proc check_effective_target_trampolines { } { | |
404 | if [target_info exists no_trampolines] { | |
405 | return 0 | |
406 | } | |
407 | if { [istarget avr-*-*] | |
408 | || [istarget hppa2.0w-hp-hpux11.23] | |
409 | || [istarget hppa64-hp-hpux11.23] } { | |
410 | return 0; | |
411 | } | |
412 | return 1 | |
413 | } | |
414 | ||
762bb557 | 415 | # Return 1 if according to target_info struct and explicit target list |
416 | # target is supposed to keep null pointer checks. This could be due to | |
417 | # use of option fno-delete-null-pointer-checks or hardwired in target. | |
418 | ||
419 | proc check_effective_target_keeps_null_pointer_checks { } { | |
420 | if [target_info exists keeps_null_pointer_checks] { | |
421 | return 1 | |
422 | } | |
423 | if { [istarget avr-*-*] } { | |
424 | return 1; | |
425 | } | |
426 | return 0 | |
427 | } | |
428 | ||
152b4f70 | 429 | # Return true if profiling is supported on the target. |
430 | ||
9bd65cc1 | 431 | proc check_profiling_available { test_what } { |
152b4f70 | 432 | global profiling_available_saved |
433 | ||
9bd65cc1 | 434 | verbose "Profiling argument is <$test_what>" 1 |
435 | ||
436 | # These conditions depend on the argument so examine them before | |
437 | # looking at the cache variable. | |
438 | ||
439 | # Support for -p on solaris2 relies on mcrt1.o which comes with the | |
440 | # vendor compiler. We cannot reliably predict the directory where the | |
441 | # vendor compiler (and thus mcrt1.o) is installed so we can't | |
442 | # necessarily find mcrt1.o even if we have it. | |
443 | if { [istarget *-*-solaris2*] && [lindex $test_what 1] == "-p" } { | |
444 | return 0 | |
445 | } | |
446 | ||
447 | # Support for -p on irix relies on libprof1.a which doesn't appear to | |
448 | # exist on any irix6 system currently posting testsuite results. | |
449 | # Support for -pg on irix relies on gcrt1.o which doesn't exist yet. | |
450 | # See: http://gcc.gnu.org/ml/gcc/2002-10/msg00169.html | |
ccb84981 | 451 | if { [istarget mips*-*-irix*] |
9bd65cc1 | 452 | && ([lindex $test_what 1] == "-p" || [lindex $test_what 1] == "-pg") } { |
453 | return 0 | |
559b0712 | 454 | } |
455 | ||
456 | # We don't yet support profiling for MIPS16. | |
457 | if { [istarget mips*-*-*] | |
458 | && ![check_effective_target_nomips16] | |
459 | && ([lindex $test_what 1] == "-p" | |
460 | || [lindex $test_what 1] == "-pg") } { | |
461 | return 0 | |
9bd65cc1 | 462 | } |
463 | ||
e8a35d85 | 464 | # MinGW does not support -p. |
465 | if { [istarget *-*-mingw*] && [lindex $test_what 1] == "-p" } { | |
466 | return 0 | |
467 | } | |
468 | ||
d8e3d959 | 469 | # uClibc does not have gcrt1.o. |
470 | if { [check_effective_target_uclibc] | |
471 | && ([lindex $test_what 1] == "-p" | |
472 | || [lindex $test_what 1] == "-pg") } { | |
473 | return 0 | |
c79d5a34 | 474 | } |
475 | ||
9bd65cc1 | 476 | # Now examine the cache variable. |
152b4f70 | 477 | if {![info exists profiling_available_saved]} { |
478 | # Some targets don't have any implementation of __bb_init_func or are | |
479 | # missing other needed machinery. | |
480 | if { [istarget mmix-*-*] | |
984fb08c | 481 | || [istarget arm*-*-eabi*] |
0c20e33d | 482 | || [istarget picochip-*-*] |
483 | || [istarget *-*-netware*] | |
152b4f70 | 484 | || [istarget arm*-*-elf] |
984fb08c | 485 | || [istarget arm*-*-symbianelf*] |
4f336ecc | 486 | || [istarget avr-*-*] |
86c993ef | 487 | || [istarget bfin-*-*] |
e46fa561 | 488 | || [istarget powerpc-*-eabi*] |
152b4f70 | 489 | || [istarget cris-*-*] |
70665388 | 490 | || [istarget crisv32-*-*] |
e5b64d7b | 491 | || [istarget fido-*-elf] |
ccb84981 | 492 | || [istarget h8300-*-*] |
b3c3dab2 | 493 | || [istarget m32c-*-elf] |
deb8c70b | 494 | || [istarget m68k-*-elf] |
0160306e | 495 | || [istarget m68k-*-uclinux*] |
c24e4d86 | 496 | || [istarget mips*-*-elf*] |
42dd0565 | 497 | || [istarget xstormy16-*] |
a76109da | 498 | || [istarget xtensa*-*-elf] |
7cd90267 | 499 | || [istarget *-*-rtems*] |
6af9f7ea | 500 | || [istarget *-*-vxworks*] } { |
152b4f70 | 501 | set profiling_available_saved 0 |
502 | } else { | |
503 | set profiling_available_saved 1 | |
504 | } | |
505 | } | |
ccb84981 | 506 | |
152b4f70 | 507 | return $profiling_available_saved |
508 | } | |
ccb84981 | 509 | |
0c20e33d | 510 | # Check to see if a target is "freestanding". This is as per the definition |
511 | # in Section 4 of C99 standard. Effectively, it is a target which supports no | |
512 | # extra headers or libraries other than what is considered essential. | |
513 | proc check_effective_target_freestanding { } { | |
514 | if { [istarget picochip-*-*] } then { | |
515 | return 1 | |
516 | } else { | |
517 | return 0 | |
518 | } | |
519 | } | |
520 | ||
782f645b | 521 | # Return 1 if target has packed layout of structure members by |
522 | # default, 0 otherwise. Note that this is slightly different than | |
523 | # whether the target has "natural alignment": both attributes may be | |
524 | # false. | |
525 | ||
526 | proc check_effective_target_default_packed { } { | |
b7714d40 | 527 | return [check_no_compiler_messages default_packed assembly { |
528 | struct x { char a; long b; } c; | |
529 | int s[sizeof (c) == sizeof (char) + sizeof (long) ? 1 : -1]; | |
530 | }] | |
782f645b | 531 | } |
532 | ||
93cec6a9 | 533 | # Return 1 if target has PCC_BITFIELD_TYPE_MATTERS defined. See |
534 | # documentation, where the test also comes from. | |
535 | ||
536 | proc check_effective_target_pcc_bitfield_type_matters { } { | |
b7714d40 | 537 | # PCC_BITFIELD_TYPE_MATTERS isn't just about unnamed or empty |
538 | # bitfields, but let's stick to the example code from the docs. | |
539 | return [check_no_compiler_messages pcc_bitfield_type_matters assembly { | |
540 | struct foo1 { char x; char :0; char y; }; | |
541 | struct foo2 { char x; int :0; char y; }; | |
542 | int s[sizeof (struct foo1) != sizeof (struct foo2) ? 1 : -1]; | |
543 | }] | |
93cec6a9 | 544 | } |
545 | ||
7ca4b2b8 | 546 | # Return 1 if thread local storage (TLS) is supported, 0 otherwise. |
1defd4fb | 547 | # |
548 | # This won't change for different subtargets so cache the result. | |
549 | ||
550 | proc check_effective_target_tls {} { | |
383ec9c4 | 551 | return [check_no_compiler_messages tls assembly { |
552 | __thread int i; | |
553 | int f (void) { return i; } | |
554 | void g (int j) { i = j; } | |
555 | }] | |
7ca4b2b8 | 556 | } |
557 | ||
558 | # Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise. | |
559 | # | |
560 | # This won't change for different subtargets so cache the result. | |
561 | ||
562 | proc check_effective_target_tls_native {} { | |
38475469 | 563 | # VxWorks uses emulated TLS machinery, but with non-standard helper |
564 | # functions, so we fail to automatically detect it. | |
565 | global target_triplet | |
566 | if { [regexp ".*-.*-vxworks.*" $target_triplet] } { | |
567 | return 0 | |
568 | } | |
569 | ||
7b42244d | 570 | return [check_no_messages_and_pattern tls_native "!emutls" assembly { |
383ec9c4 | 571 | __thread int i; |
572 | int f (void) { return i; } | |
573 | void g (int j) { i = j; } | |
574 | }] | |
1defd4fb | 575 | } |
576 | ||
577 | # Return 1 if TLS executables can run correctly, 0 otherwise. | |
578 | # | |
579 | # This won't change for different subtargets so cache the result. | |
580 | ||
581 | proc check_effective_target_tls_runtime {} { | |
383ec9c4 | 582 | return [check_runtime tls_runtime { |
583 | __thread int thr = 0; | |
584 | int main (void) { return thr; } | |
585 | }] | |
1defd4fb | 586 | } |
587 | ||
255b6be7 | 588 | # Return 1 if compilation with -fgraphite is error-free for trivial |
589 | # code, 0 otherwise. | |
590 | ||
591 | proc check_effective_target_fgraphite {} { | |
592 | return [check_no_compiler_messages fgraphite object { | |
593 | void foo (void) { } | |
95033205 | 594 | } "-O1 -fgraphite"] |
255b6be7 | 595 | } |
596 | ||
7e11c1cb | 597 | # Return 1 if compilation with -fopenmp is error-free for trivial |
598 | # code, 0 otherwise. | |
599 | ||
600 | proc check_effective_target_fopenmp {} { | |
b7714d40 | 601 | return [check_no_compiler_messages fopenmp object { |
602 | void foo (void) { } | |
603 | } "-fopenmp"] | |
7e11c1cb | 604 | } |
605 | ||
9a4ca5e9 | 606 | # Return 1 if compilation with -pthread is error-free for trivial |
607 | # code, 0 otherwise. | |
608 | ||
609 | proc check_effective_target_pthread {} { | |
610 | return [check_no_compiler_messages pthread object { | |
611 | void foo (void) { } | |
612 | } "-pthread"] | |
613 | } | |
614 | ||
0ce01723 | 615 | # Return 1 if the target supports -fstack-protector |
0ce01723 | 616 | proc check_effective_target_fstack_protector {} { |
383ec9c4 | 617 | return [check_runtime fstack_protector { |
618 | int main (void) { return 0; } | |
619 | } "-fstack-protector"] | |
0ce01723 | 620 | } |
621 | ||
c045fcc0 | 622 | # Return 1 if compilation with -freorder-blocks-and-partition is error-free |
623 | # for trivial code, 0 otherwise. | |
624 | ||
625 | proc check_effective_target_freorder {} { | |
b7714d40 | 626 | return [check_no_compiler_messages freorder object { |
627 | void foo (void) { } | |
628 | } "-freorder-blocks-and-partition"] | |
c045fcc0 | 629 | } |
630 | ||
60786eff | 631 | # Return 1 if -fpic and -fPIC are supported, as in no warnings or errors |
632 | # emitted, 0 otherwise. Whether a shared library can actually be built is | |
633 | # out of scope for this test. | |
60786eff | 634 | |
635 | proc check_effective_target_fpic { } { | |
b7714d40 | 636 | # Note that M68K has a multilib that supports -fpic but not |
637 | # -fPIC, so we need to check both. We test with a program that | |
638 | # requires GOT references. | |
639 | foreach arg {fpic fPIC} { | |
640 | if [check_no_compiler_messages $arg object { | |
60786eff | 641 | extern int foo (void); extern int bar; |
642 | int baz (void) { return foo () + bar; } | |
b7714d40 | 643 | } "-$arg"] { |
644 | return 1 | |
60786eff | 645 | } |
646 | } | |
b7714d40 | 647 | return 0 |
60786eff | 648 | } |
649 | ||
b52ed5f3 | 650 | # Return true if the target supports -mpaired-single (as used on MIPS). |
651 | ||
652 | proc check_effective_target_mpaired_single { } { | |
747c7125 | 653 | return [check_no_compiler_messages mpaired_single object { |
b52ed5f3 | 654 | void foo (void) { } |
655 | } "-mpaired-single"] | |
656 | } | |
657 | ||
c492c383 | 658 | # Return true if the target has access to FPU instructions. |
f69adbab | 659 | |
c492c383 | 660 | proc check_effective_target_hard_float { } { |
c55056bc | 661 | if { [istarget mips*-*-*] } { |
8d22f418 | 662 | return [check_no_compiler_messages hard_float assembly { |
c55056bc | 663 | #if (defined __mips_soft_float || defined __mips16) |
8d22f418 | 664 | #error FOO |
665 | #endif | |
666 | }] | |
667 | } | |
668 | ||
669 | # The generic test equates hard_float with "no call for adding doubles". | |
670 | return [check_no_messages_and_pattern hard_float "!\\(call" rtl-expand { | |
671 | double a (double b, double c) { return b + c; } | |
f69adbab | 672 | }] |
673 | } | |
674 | ||
612cf2b5 | 675 | # Return true if the target is a 64-bit MIPS target. |
676 | ||
677 | proc check_effective_target_mips64 { } { | |
678 | return [check_no_compiler_messages mips64 assembly { | |
679 | #ifndef __mips64 | |
680 | #error FOO | |
681 | #endif | |
682 | }] | |
683 | } | |
684 | ||
c19eff17 | 685 | # Return true if the target is a MIPS target that does not produce |
686 | # MIPS16 code. | |
687 | ||
688 | proc check_effective_target_nomips16 { } { | |
689 | return [check_no_compiler_messages nomips16 object { | |
690 | #ifndef __mips | |
691 | #error FOO | |
692 | #else | |
693 | /* A cheap way of testing for -mflip-mips16. */ | |
694 | void foo (void) { asm ("addiu $20,$20,1"); } | |
695 | void bar (void) { asm ("addiu $20,$20,1"); } | |
696 | #endif | |
697 | }] | |
698 | } | |
699 | ||
c9342b72 | 700 | # Add the options needed for MIPS16 function attributes. At the moment, |
701 | # we don't support MIPS16 PIC. | |
702 | ||
703 | proc add_options_for_mips16_attribute { flags } { | |
71fd5515 | 704 | return "$flags -mno-abicalls -fno-pic -DMIPS16=__attribute__((mips16))" |
c9342b72 | 705 | } |
706 | ||
707 | # Return true if we can force a mode that allows MIPS16 code generation. | |
215a5674 | 708 | # We don't support MIPS16 PIC, and only support MIPS16 -mhard-float |
709 | # for o32 and o64. | |
c9342b72 | 710 | |
711 | proc check_effective_target_mips16_attribute { } { | |
712 | return [check_no_compiler_messages mips16_attribute assembly { | |
215a5674 | 713 | #ifdef PIC |
714 | #error FOO | |
715 | #endif | |
716 | #if defined __mips_hard_float \ | |
717 | && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \ | |
718 | && (!defined _ABIO64 || _MIPS_SIM != _ABIO64) | |
c9342b72 | 719 | #error FOO |
720 | #endif | |
721 | } [add_options_for_mips16_attribute ""]] | |
722 | } | |
723 | ||
e1701a71 | 724 | # Return 1 if the current multilib does not generate PIC by default. |
725 | ||
726 | proc check_effective_target_nonpic { } { | |
727 | return [check_no_compiler_messages nonpic assembly { | |
728 | #if __PIC__ | |
729 | #error FOO | |
730 | #endif | |
731 | }] | |
732 | } | |
733 | ||
ec32d774 | 734 | # Return 1 if the target does not use a status wrapper. |
735 | ||
736 | proc check_effective_target_unwrapped { } { | |
737 | if { [target_info needs_status_wrapper] != "" \ | |
738 | && [target_info needs_status_wrapper] != "0" } { | |
739 | return 0 | |
740 | } | |
741 | return 1 | |
742 | } | |
743 | ||
1c128d26 | 744 | # Return true if iconv is supported on the target. In particular IBM1047. |
ccb84981 | 745 | |
746 | proc check_iconv_available { test_what } { | |
d3c27322 | 747 | global libiconv |
ccb84981 | 748 | |
175d5683 | 749 | # If the tool configuration file has not set libiconv, try "-liconv" |
750 | if { ![info exists libiconv] } { | |
751 | set libiconv "-liconv" | |
752 | } | |
383ec9c4 | 753 | set test_what [lindex $test_what 1] |
754 | return [check_runtime_nocache $test_what [subst { | |
755 | #include <iconv.h> | |
756 | int main (void) | |
757 | { | |
758 | iconv_t cd; | |
759 | ||
760 | cd = iconv_open ("$test_what", "UTF-8"); | |
761 | if (cd == (iconv_t) -1) | |
762 | return 1; | |
763 | return 0; | |
d3c27322 | 764 | } |
383ec9c4 | 765 | }] $libiconv] |
ccb84981 | 766 | } |
a278084f | 767 | |
768 | # Return true if named sections are supported on this target. | |
b7714d40 | 769 | |
a278084f | 770 | proc check_named_sections_available { } { |
b7714d40 | 771 | return [check_no_compiler_messages named_sections assembly { |
34d688ab | 772 | int __attribute__ ((section("whatever"))) foo; |
b7714d40 | 773 | }] |
a278084f | 774 | } |
52401a44 | 775 | |
14c3c235 | 776 | # Return 1 if the target supports Fortran real kinds larger than real(8), |
a840dd14 | 777 | # 0 otherwise. |
778 | # | |
779 | # When the target name changes, replace the cached result. | |
14c3c235 | 780 | |
781 | proc check_effective_target_fortran_large_real { } { | |
383ec9c4 | 782 | return [check_no_compiler_messages fortran_large_real executable { |
783 | ! Fortran | |
784 | integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1) | |
785 | real(kind=k) :: x | |
786 | x = cos (x) | |
787 | end | |
788 | }] | |
14c3c235 | 789 | } |
790 | ||
791 | # Return 1 if the target supports Fortran integer kinds larger than | |
a840dd14 | 792 | # integer(8), 0 otherwise. |
793 | # | |
794 | # When the target name changes, replace the cached result. | |
14c3c235 | 795 | |
796 | proc check_effective_target_fortran_large_int { } { | |
383ec9c4 | 797 | return [check_no_compiler_messages fortran_large_int executable { |
798 | ! Fortran | |
799 | integer,parameter :: k = selected_int_kind (range (0_8) + 1) | |
800 | integer(kind=k) :: i | |
801 | end | |
802 | }] | |
14c3c235 | 803 | } |
804 | ||
8b1a1e8b | 805 | # Return 1 if the target supports Fortran integer(16), 0 otherwise. |
806 | # | |
807 | # When the target name changes, replace the cached result. | |
808 | ||
809 | proc check_effective_target_fortran_integer_16 { } { | |
810 | return [check_no_compiler_messages fortran_integer_16 executable { | |
811 | ! Fortran | |
812 | integer(16) :: i | |
813 | end | |
814 | }] | |
815 | } | |
816 | ||
76875ccb | 817 | # Return 1 if we can statically link libgfortran, 0 otherwise. |
818 | # | |
819 | # When the target name changes, replace the cached result. | |
820 | ||
821 | proc check_effective_target_static_libgfortran { } { | |
383ec9c4 | 822 | return [check_no_compiler_messages static_libgfortran executable { |
823 | ! Fortran | |
824 | print *, 'test' | |
825 | end | |
826 | } "-static"] | |
76875ccb | 827 | } |
828 | ||
a39ea4df | 829 | # Return 1 if the target supports executing 750CL paired-single instructions, 0 |
830 | # otherwise. Cache the result. | |
831 | ||
832 | proc check_750cl_hw_available { } { | |
383ec9c4 | 833 | return [check_cached_effective_target 750cl_hw_available { |
834 | # If this is not the right target then we can skip the test. | |
835 | if { ![istarget powerpc-*paired*] } { | |
836 | expr 0 | |
837 | } else { | |
838 | check_runtime_nocache 750cl_hw_available { | |
839 | int main() | |
840 | { | |
841 | #ifdef __MACH__ | |
842 | asm volatile ("ps_mul v0,v0,v0"); | |
843 | #else | |
844 | asm volatile ("ps_mul 0,0,0"); | |
845 | #endif | |
846 | return 0; | |
847 | } | |
848 | } "-mpaired" | |
849 | } | |
850 | }] | |
a39ea4df | 851 | } |
852 | ||
e101b9bf | 853 | # Return 1 if the target supports executing SSE2 instructions, 0 |
854 | # otherwise. Cache the result. | |
855 | ||
856 | proc check_sse2_hw_available { } { | |
857 | return [check_cached_effective_target sse2_hw_available { | |
858 | # If this is not the right target then we can skip the test. | |
859 | if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } { | |
860 | expr 0 | |
861 | } else { | |
862 | check_runtime_nocache sse2_hw_available { | |
863 | #include "cpuid.h" | |
864 | int main () | |
865 | { | |
866 | unsigned int eax, ebx, ecx, edx = 0; | |
867 | if (__get_cpuid (1, &eax, &ebx, &ecx, &edx)) | |
868 | return !(edx & bit_SSE2); | |
869 | return 1; | |
870 | } | |
871 | } "" | |
872 | } | |
873 | }] | |
874 | } | |
875 | ||
52401a44 | 876 | # Return 1 if the target supports executing AltiVec instructions, 0 |
877 | # otherwise. Cache the result. | |
878 | ||
879 | proc check_vmx_hw_available { } { | |
383ec9c4 | 880 | return [check_cached_effective_target vmx_hw_available { |
52401a44 | 881 | # Some simulators are known to not support VMX instructions. |
882 | if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] } { | |
383ec9c4 | 883 | expr 0 |
ed5c6f54 | 884 | } else { |
383ec9c4 | 885 | # Most targets don't require special flags for this test case, but |
886 | # Darwin does. | |
887 | if { [istarget *-*-darwin*] | |
888 | || [istarget *-*-aix*] } { | |
889 | set options "-maltivec" | |
890 | } else { | |
891 | set options "" | |
52401a44 | 892 | } |
383ec9c4 | 893 | check_runtime_nocache vmx_hw_available { |
894 | int main() | |
895 | { | |
896 | #ifdef __MACH__ | |
897 | asm volatile ("vor v0,v0,v0"); | |
898 | #else | |
899 | asm volatile ("vor 0,0,0"); | |
900 | #endif | |
901 | return 0; | |
902 | } | |
903 | } $options | |
52401a44 | 904 | } |
383ec9c4 | 905 | }] |
52401a44 | 906 | } |
34d688ab | 907 | |
3a555774 | 908 | # Return 1 if the target supports executing AltiVec and Cell PPU |
909 | # instructions, 0 otherwise. Cache the result. | |
910 | ||
911 | proc check_effective_target_cell_hw { } { | |
912 | return [check_cached_effective_target cell_hw_available { | |
913 | # Some simulators are known to not support VMX and PPU instructions. | |
914 | if { [istarget powerpc-*-eabi*] } { | |
915 | expr 0 | |
916 | } else { | |
917 | # Most targets don't require special flags for this test | |
918 | # case, but Darwin and AIX do. | |
919 | if { [istarget *-*-darwin*] | |
920 | || [istarget *-*-aix*] } { | |
921 | set options "-maltivec -mcpu=cell" | |
922 | } else { | |
923 | set options "-mcpu=cell" | |
924 | } | |
925 | check_runtime_nocache cell_hw_available { | |
926 | int main() | |
927 | { | |
928 | #ifdef __MACH__ | |
929 | asm volatile ("vor v0,v0,v0"); | |
930 | asm volatile ("lvlx v0,r0,r0"); | |
931 | #else | |
932 | asm volatile ("vor 0,0,0"); | |
933 | asm volatile ("lvlx 0,0,0"); | |
934 | #endif | |
935 | return 0; | |
936 | } | |
937 | } $options | |
938 | } | |
939 | }] | |
940 | } | |
941 | ||
4a3240e2 | 942 | # Return 1 if the target supports executing 64-bit instructions, 0 |
943 | # otherwise. Cache the result. | |
944 | ||
945 | proc check_effective_target_powerpc64 { } { | |
946 | global powerpc64_available_saved | |
947 | global tool | |
948 | ||
949 | if [info exists powerpc64_available_saved] { | |
950 | verbose "check_effective_target_powerpc64 returning saved $powerpc64_available_saved" 2 | |
951 | } else { | |
952 | set powerpc64_available_saved 0 | |
953 | ||
954 | # Some simulators are known to not support powerpc64 instructions. | |
955 | if { [istarget powerpc-*-eabi*] || [istarget powerpc-ibm-aix*] } { | |
956 | verbose "check_effective_target_powerpc64 returning 0" 2 | |
957 | return $powerpc64_available_saved | |
958 | } | |
959 | ||
960 | # Set up, compile, and execute a test program containing a 64-bit | |
961 | # instruction. Include the current process ID in the file | |
962 | # names to prevent conflicts with invocations for multiple | |
963 | # testsuites. | |
964 | set src ppc[pid].c | |
965 | set exe ppc[pid].x | |
966 | ||
967 | set f [open $src "w"] | |
968 | puts $f "int main() {" | |
969 | puts $f "#ifdef __MACH__" | |
970 | puts $f " asm volatile (\"extsw r0,r0\");" | |
971 | puts $f "#else" | |
972 | puts $f " asm volatile (\"extsw 0,0\");" | |
973 | puts $f "#endif" | |
974 | puts $f " return 0; }" | |
975 | close $f | |
976 | ||
977 | set opts "additional_flags=-mcpu=G5" | |
978 | ||
979 | verbose "check_effective_target_powerpc64 compiling testfile $src" 2 | |
980 | set lines [${tool}_target_compile $src $exe executable "$opts"] | |
981 | file delete $src | |
982 | ||
983 | if [string match "" $lines] then { | |
984 | # No error message, compilation succeeded. | |
985 | set result [${tool}_load "./$exe" "" ""] | |
986 | set status [lindex $result 0] | |
987 | remote_file build delete $exe | |
988 | verbose "check_effective_target_powerpc64 testfile status is <$status>" 2 | |
989 | ||
990 | if { $status == "pass" } then { | |
991 | set powerpc64_available_saved 1 | |
992 | } | |
993 | } else { | |
994 | verbose "check_effective_target_powerpc64 testfile compilation failed" 2 | |
995 | } | |
996 | } | |
997 | ||
998 | return $powerpc64_available_saved | |
999 | } | |
1000 | ||
751f3290 | 1001 | # GCC 3.4.0 for powerpc64-*-linux* included an ABI fix for passing |
1002 | # complex float arguments. This affects gfortran tests that call cabsf | |
1003 | # in libm built by an earlier compiler. Return 1 if libm uses the same | |
1004 | # argument passing as the compiler under test, 0 otherwise. | |
1005 | # | |
1006 | # When the target name changes, replace the cached result. | |
1007 | ||
1008 | proc check_effective_target_broken_cplxf_arg { } { | |
383ec9c4 | 1009 | return [check_cached_effective_target broken_cplxf_arg { |
1010 | # Skip the work for targets known not to be affected. | |
1011 | if { ![istarget powerpc64-*-linux*] } { | |
1012 | expr 0 | |
1013 | } elseif { ![is-effective-target lp64] } { | |
1014 | expr 0 | |
751f3290 | 1015 | } else { |
383ec9c4 | 1016 | check_runtime_nocache broken_cplxf_arg { |
1017 | #include <complex.h> | |
1018 | extern void abort (void); | |
1019 | float fabsf (float); | |
1020 | float cabsf (_Complex float); | |
1021 | int main () | |
1022 | { | |
1023 | _Complex float cf; | |
1024 | float f; | |
1025 | cf = 3 + 4.0fi; | |
1026 | f = cabsf (cf); | |
1027 | if (fabsf (f - 5.0) > 0.0001) | |
1028 | abort (); | |
1029 | return 0; | |
1030 | } | |
1031 | } "-lm" | |
751f3290 | 1032 | } |
383ec9c4 | 1033 | }] |
751f3290 | 1034 | } |
1035 | ||
3ec9142f | 1036 | proc check_alpha_max_hw_available { } { |
383ec9c4 | 1037 | return [check_runtime alpha_max_hw_available { |
1038 | int main() { return __builtin_alpha_amask(1<<8) != 0; } | |
1039 | }] | |
3ec9142f | 1040 | } |
1041 | ||
16cb9d1f | 1042 | # Returns true iff the FUNCTION is available on the target system. |
1043 | # (This is essentially a Tcl implementation of Autoconf's | |
1044 | # AC_CHECK_FUNC.) | |
1045 | ||
1046 | proc check_function_available { function } { | |
383ec9c4 | 1047 | return [check_no_compiler_messages ${function}_available \ |
1048 | executable [subst { | |
1049 | #ifdef __cplusplus | |
1050 | extern "C" | |
1051 | #endif | |
1052 | char $function (); | |
1053 | int main () { $function (); } | |
1054 | }]] | |
16cb9d1f | 1055 | } |
1056 | ||
e3feb2af | 1057 | # Returns true iff "fork" is available on the target system. |
16cb9d1f | 1058 | |
1059 | proc check_fork_available {} { | |
1060 | return [check_function_available "fork"] | |
1061 | } | |
1062 | ||
e3feb2af | 1063 | # Returns true iff "mkfifo" is available on the target system. |
16cb9d1f | 1064 | |
1065 | proc check_mkfifo_available {} { | |
e3feb2af | 1066 | if {[istarget *-*-cygwin*]} { |
1067 | # Cygwin has mkfifo, but support is incomplete. | |
1068 | return 0 | |
1069 | } | |
1070 | ||
16cb9d1f | 1071 | return [check_function_available "mkfifo"] |
1072 | } | |
1073 | ||
04fdd837 | 1074 | # Returns true iff "__cxa_atexit" is used on the target system. |
1075 | ||
1076 | proc check_cxa_atexit_available { } { | |
383ec9c4 | 1077 | return [check_cached_effective_target cxa_atexit_available { |
1078 | if { [istarget "hppa*-*-hpux10*"] } { | |
1079 | # HP-UX 10 doesn't have __cxa_atexit but subsequent test passes. | |
1080 | expr 0 | |
04fdd837 | 1081 | } else { |
383ec9c4 | 1082 | check_runtime_nocache cxa_atexit_available { |
1083 | // C++ | |
1084 | #include <stdlib.h> | |
1085 | static unsigned int count; | |
1086 | struct X | |
1087 | { | |
1088 | X() { count = 1; } | |
1089 | ~X() | |
1090 | { | |
1091 | if (count != 3) | |
1092 | exit(1); | |
1093 | count = 4; | |
1094 | } | |
1095 | }; | |
1096 | void f() | |
1097 | { | |
1098 | static X x; | |
1099 | } | |
1100 | struct Y | |
1101 | { | |
1102 | Y() { f(); count = 2; } | |
1103 | ~Y() | |
1104 | { | |
1105 | if (count != 2) | |
1106 | exit(1); | |
1107 | count = 3; | |
1108 | } | |
1109 | }; | |
1110 | Y y; | |
1111 | int main() { return 0; } | |
1112 | } | |
04fdd837 | 1113 | } |
383ec9c4 | 1114 | }] |
04fdd837 | 1115 | } |
1116 | ||
1117 | ||
34d688ab | 1118 | # Return 1 if we're generating 32-bit code using default options, 0 |
1119 | # otherwise. | |
1120 | ||
1121 | proc check_effective_target_ilp32 { } { | |
b7714d40 | 1122 | return [check_no_compiler_messages ilp32 object { |
1123 | int dummy[sizeof (int) == 4 | |
1124 | && sizeof (void *) == 4 | |
1125 | && sizeof (long) == 4 ? 1 : -1]; | |
1126 | }] | |
34d688ab | 1127 | } |
1128 | ||
b3c3dab2 | 1129 | # Return 1 if we're generating 32-bit or larger integers using default |
1130 | # options, 0 otherwise. | |
1131 | ||
1132 | proc check_effective_target_int32plus { } { | |
1133 | return [check_no_compiler_messages int32plus object { | |
1134 | int dummy[sizeof (int) >= 4 ? 1 : -1]; | |
1135 | }] | |
1136 | } | |
1137 | ||
1138 | # Return 1 if we're generating 32-bit or larger pointers using default | |
1139 | # options, 0 otherwise. | |
1140 | ||
1141 | proc check_effective_target_ptr32plus { } { | |
1142 | return [check_no_compiler_messages ptr32plus object { | |
1143 | int dummy[sizeof (void *) >= 4 ? 1 : -1]; | |
1144 | }] | |
1145 | } | |
1146 | ||
1147 | # Return 1 if we support 32-bit or larger array and structure sizes | |
1148 | # using default options, 0 otherwise. | |
1149 | ||
1150 | proc check_effective_target_size32plus { } { | |
1151 | return [check_no_compiler_messages size32plus object { | |
1152 | char dummy[65537]; | |
1153 | }] | |
1154 | } | |
1155 | ||
1156 | # Returns 1 if we're generating 16-bit or smaller integers with the | |
1157 | # default options, 0 otherwise. | |
1158 | ||
1159 | proc check_effective_target_int16 { } { | |
1160 | return [check_no_compiler_messages int16 object { | |
1161 | int dummy[sizeof (int) < 4 ? 1 : -1]; | |
1162 | }] | |
1163 | } | |
1164 | ||
34d688ab | 1165 | # Return 1 if we're generating 64-bit code using default options, 0 |
1166 | # otherwise. | |
1167 | ||
1168 | proc check_effective_target_lp64 { } { | |
b7714d40 | 1169 | return [check_no_compiler_messages lp64 object { |
1170 | int dummy[sizeof (int) == 4 | |
1171 | && sizeof (void *) == 8 | |
1172 | && sizeof (long) == 8 ? 1 : -1]; | |
1173 | }] | |
34d688ab | 1174 | } |
1175 | ||
9ad60bf7 | 1176 | # Return 1 if we're generating 64-bit code using default llp64 options, |
1177 | # 0 otherwise. | |
1178 | ||
1179 | proc check_effective_target_llp64 { } { | |
1180 | return [check_no_compiler_messages llp64 object { | |
1181 | int dummy[sizeof (int) == 4 | |
1182 | && sizeof (void *) == 8 | |
1183 | && sizeof (long long) == 8 | |
1184 | && sizeof (long) == 4 ? 1 : -1]; | |
1185 | }] | |
1186 | } | |
1187 | ||
b8c926ff | 1188 | # Return 1 if the target supports long double larger than double, |
1189 | # 0 otherwise. | |
1190 | ||
1191 | proc check_effective_target_large_long_double { } { | |
1192 | return [check_no_compiler_messages large_long_double object { | |
1193 | int dummy[sizeof(long double) > sizeof(double) ? 1 : -1]; | |
1194 | }] | |
1195 | } | |
1196 | ||
a6f0abb1 | 1197 | # Return 1 if the target supports compiling fixed-point, |
1198 | # 0 otherwise. | |
1199 | ||
1200 | proc check_effective_target_fixed_point { } { | |
1201 | return [check_no_compiler_messages fixed_point object { | |
1202 | _Sat _Fract x; _Sat _Accum y; | |
1203 | }] | |
1204 | } | |
b8c926ff | 1205 | |
73492ab6 | 1206 | # Return 1 if the target supports compiling decimal floating point, |
1207 | # 0 otherwise. | |
1208 | ||
1209 | proc check_effective_target_dfp_nocache { } { | |
1210 | verbose "check_effective_target_dfp_nocache: compiling source" 2 | |
383ec9c4 | 1211 | set ret [check_no_compiler_messages_nocache dfp object { |
73492ab6 | 1212 | _Decimal32 x; _Decimal64 y; _Decimal128 z; |
383ec9c4 | 1213 | }] |
73492ab6 | 1214 | verbose "check_effective_target_dfp_nocache: returning $ret" 2 |
1215 | return $ret | |
1216 | } | |
1217 | ||
1218 | proc check_effective_target_dfprt_nocache { } { | |
383ec9c4 | 1219 | return [check_runtime_nocache dfprt { |
1220 | _Decimal32 x = 1.2df; _Decimal64 y = 2.3dd; _Decimal128 z; | |
1221 | int main () { z = x + y; return 0; } | |
1222 | }] | |
73492ab6 | 1223 | } |
1224 | ||
1225 | # Return 1 if the target supports compiling Decimal Floating Point, | |
1226 | # 0 otherwise. | |
41a20961 | 1227 | # |
1228 | # This won't change for different subtargets so cache the result. | |
1229 | ||
1230 | proc check_effective_target_dfp { } { | |
383ec9c4 | 1231 | return [check_cached_effective_target dfp { |
1232 | check_effective_target_dfp_nocache | |
1233 | }] | |
41a20961 | 1234 | } |
1235 | ||
73492ab6 | 1236 | # Return 1 if the target supports linking and executing Decimal Floating |
1237 | # Point, # 0 otherwise. | |
1238 | # | |
1239 | # This won't change for different subtargets so cache the result. | |
1240 | ||
1241 | proc check_effective_target_dfprt { } { | |
383ec9c4 | 1242 | return [check_cached_effective_target dfprt { |
1243 | check_effective_target_dfprt_nocache | |
1244 | }] | |
73492ab6 | 1245 | } |
1246 | ||
951981be | 1247 | # Return 1 if the target needs a command line argument to enable a SIMD |
1248 | # instruction set. | |
951981be | 1249 | |
1250 | proc check_effective_target_vect_cmdline_needed { } { | |
1251 | global et_vect_cmdline_needed_saved | |
13a86eaf | 1252 | global et_vect_cmdline_needed_target_name |
1253 | ||
1254 | if { ![info exists et_vect_cmdline_needed_target_name] } { | |
1255 | set et_vect_cmdline_needed_target_name "" | |
1256 | } | |
1257 | ||
1258 | # If the target has changed since we set the cached value, clear it. | |
1259 | set current_target [current_target_name] | |
1260 | if { $current_target != $et_vect_cmdline_needed_target_name } { | |
1261 | verbose "check_effective_target_vect_cmdline_needed: `$et_vect_cmdline_needed_target_name' `$current_target'" 2 | |
1262 | set et_vect_cmdline_needed_target_name $current_target | |
1263 | if { [info exists et_vect_cmdline_needed_saved] } { | |
1264 | verbose "check_effective_target_vect_cmdline_needed: removing cached result" 2 | |
1265 | unset et_vect_cmdline_needed_saved | |
1266 | } | |
1267 | } | |
951981be | 1268 | |
1269 | if [info exists et_vect_cmdline_needed_saved] { | |
1270 | verbose "check_effective_target_vect_cmdline_needed: using cached result" 2 | |
1271 | } else { | |
1272 | set et_vect_cmdline_needed_saved 1 | |
1273 | if { [istarget ia64-*-*] | |
13a86eaf | 1274 | || (([istarget x86_64-*-*] || [istarget i?86-*-*]) |
8663c890 | 1275 | && [check_effective_target_lp64]) |
1276 | || ([istarget powerpc*-*-*] | |
efc2322a | 1277 | && ([check_effective_target_powerpc_spe] |
644b0594 | 1278 | || [check_effective_target_powerpc_altivec])) |
f9f75854 | 1279 | || [istarget spu-*-*] |
1280 | || ([istarget arm*-*-*] && [check_effective_target_arm_neon]) } { | |
951981be | 1281 | set et_vect_cmdline_needed_saved 0 |
1282 | } | |
1283 | } | |
1284 | ||
1285 | verbose "check_effective_target_vect_cmdline_needed: returning $et_vect_cmdline_needed_saved" 2 | |
1286 | return $et_vect_cmdline_needed_saved | |
1287 | } | |
1288 | ||
0e0971c0 | 1289 | # Return 1 if the target supports hardware vectors of int, 0 otherwise. |
1290 | # | |
1291 | # This won't change for different subtargets so cache the result. | |
1292 | ||
1293 | proc check_effective_target_vect_int { } { | |
1294 | global et_vect_int_saved | |
1295 | ||
1296 | if [info exists et_vect_int_saved] { | |
1297 | verbose "check_effective_target_vect_int: using cached result" 2 | |
1298 | } else { | |
1299 | set et_vect_int_saved 0 | |
1300 | if { [istarget i?86-*-*] | |
a39ea4df | 1301 | || ([istarget powerpc*-*-*] |
1302 | && ![istarget powerpc-*-linux*paired*]) | |
4fe49efc | 1303 | || [istarget spu-*-*] |
0e0971c0 | 1304 | || [istarget x86_64-*-*] |
3ec9142f | 1305 | || [istarget sparc*-*-*] |
a5c5f9d3 | 1306 | || [istarget alpha*-*-*] |
f9f75854 | 1307 | || [istarget ia64-*-*] |
1308 | || [check_effective_target_arm32] } { | |
0e0971c0 | 1309 | set et_vect_int_saved 1 |
1310 | } | |
1311 | } | |
1312 | ||
1313 | verbose "check_effective_target_vect_int: returning $et_vect_int_saved" 2 | |
1314 | return $et_vect_int_saved | |
1315 | } | |
1316 | ||
30f263a4 | 1317 | # Return 1 if the target supports int->float conversion |
1318 | # | |
1319 | ||
1320 | proc check_effective_target_vect_intfloat_cvt { } { | |
1321 | global et_vect_intfloat_cvt_saved | |
1322 | ||
1323 | if [info exists et_vect_intfloat_cvt_saved] { | |
1324 | verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2 | |
1325 | } else { | |
1326 | set et_vect_intfloat_cvt_saved 0 | |
1327 | if { [istarget i?86-*-*] | |
a39ea4df | 1328 | || ([istarget powerpc*-*-*] |
1329 | && ![istarget powerpc-*-linux*paired*]) | |
30f263a4 | 1330 | || [istarget x86_64-*-*] } { |
1331 | set et_vect_intfloat_cvt_saved 1 | |
1332 | } | |
1333 | } | |
1334 | ||
1335 | verbose "check_effective_target_vect_intfloat_cvt: returning $et_vect_intfloat_cvt_saved" 2 | |
1336 | return $et_vect_intfloat_cvt_saved | |
1337 | } | |
1338 | ||
1339 | ||
1340 | # Return 1 if the target supports float->int conversion | |
1341 | # | |
1342 | ||
1343 | proc check_effective_target_vect_floatint_cvt { } { | |
1344 | global et_vect_floatint_cvt_saved | |
1345 | ||
1346 | if [info exists et_vect_floatint_cvt_saved] { | |
1347 | verbose "check_effective_target_vect_floatint_cvt: using cached result" 2 | |
1348 | } else { | |
1349 | set et_vect_floatint_cvt_saved 0 | |
1350 | if { [istarget i?86-*-*] | |
8e0587db | 1351 | || ([istarget powerpc*-*-*] |
1352 | && ![istarget powerpc-*-linux*paired*]) | |
30f263a4 | 1353 | || [istarget x86_64-*-*] } { |
1354 | set et_vect_floatint_cvt_saved 1 | |
1355 | } | |
1356 | } | |
1357 | ||
1358 | verbose "check_effective_target_vect_floatint_cvt: returning $et_vect_floatint_cvt_saved" 2 | |
1359 | return $et_vect_floatint_cvt_saved | |
1360 | } | |
1361 | ||
5a204d73 | 1362 | # Return 1 is this is an arm target using 32-bit instructions |
1363 | proc check_effective_target_arm32 { } { | |
35f198f2 | 1364 | return [check_no_compiler_messages arm32 assembly { |
1365 | #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__)) | |
1366 | #error FOO | |
1367 | #endif | |
1368 | }] | |
5a204d73 | 1369 | } |
1370 | ||
57e21dbf | 1371 | # Return 1 if this is an ARM target supporting -mfpu=vfp |
1372 | # -mfloat-abi=softfp. Some multilibs may be incompatible with these | |
1373 | # options. | |
1374 | ||
1375 | proc check_effective_target_arm_vfp_ok { } { | |
1376 | if { [check_effective_target_arm32] } { | |
1377 | return [check_no_compiler_messages arm_vfp_ok object { | |
1378 | int dummy; | |
1379 | } "-mfpu=vfp -mfloat-abi=softfp"] | |
1380 | } else { | |
1381 | return 0 | |
1382 | } | |
1383 | } | |
1384 | ||
d98a3884 | 1385 | # Return 1 if this is an ARM target supporting -mfpu=neon |
1386 | # -mfloat-abi=softfp. Some multilibs may be incompatible with these | |
1387 | # options. | |
1388 | ||
1389 | proc check_effective_target_arm_neon_ok { } { | |
1390 | if { [check_effective_target_arm32] } { | |
1391 | return [check_no_compiler_messages arm_neon_ok object { | |
1392 | int dummy; | |
1393 | } "-mfpu=neon -mfloat-abi=softfp"] | |
1394 | } else { | |
1395 | return 0 | |
1396 | } | |
1397 | } | |
1398 | ||
6a9d972b | 1399 | # Return 1 is this is an ARM target where -mthumb causes Thumb-1 to be |
1400 | # used. | |
1401 | ||
1402 | proc check_effective_target_arm_thumb1_ok { } { | |
1403 | return [check_no_compiler_messages arm_thumb1_ok assembly { | |
1404 | #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__) | |
1405 | #error FOO | |
1406 | #endif | |
1407 | } "-mthumb"] | |
1408 | } | |
1409 | ||
d98a3884 | 1410 | # Return 1 if the target supports executing NEON instructions, 0 |
1411 | # otherwise. Cache the result. | |
1412 | ||
1413 | proc check_effective_target_arm_neon_hw { } { | |
383ec9c4 | 1414 | return [check_runtime arm_neon_hw_available { |
1415 | int | |
1416 | main (void) | |
1417 | { | |
1418 | long long a = 0, b = 1; | |
1419 | asm ("vorr %P0, %P1, %P2" | |
1420 | : "=w" (a) | |
1421 | : "0" (a), "w" (b)); | |
1422 | return (a != 1); | |
1423 | } | |
1424 | } "-mfpu=neon -mfloat-abi=softfp"] | |
d98a3884 | 1425 | } |
1426 | ||
f9f75854 | 1427 | # Return 1 if this is a ARM target with NEON enabled. |
1428 | ||
1429 | proc check_effective_target_arm_neon { } { | |
1430 | if { [check_effective_target_arm32] } { | |
1431 | return [check_no_compiler_messages arm_neon object { | |
1432 | #ifndef __ARM_NEON__ | |
1433 | #error not NEON | |
1434 | #else | |
1435 | int dummy; | |
1436 | #endif | |
1437 | }] | |
1438 | } else { | |
1439 | return 0 | |
1440 | } | |
1441 | } | |
1442 | ||
9636921b | 1443 | # Return 1 if this a Loongson-2E or -2F target using an ABI that supports |
1444 | # the Loongson vector modes. | |
1445 | ||
1446 | proc check_effective_target_mips_loongson { } { | |
1447 | return [check_no_compiler_messages loongson assembly { | |
1448 | #if !defined(__mips_loongson_vector_rev) | |
1449 | #error FOO | |
1450 | #endif | |
1451 | }] | |
1452 | } | |
1453 | ||
fb20d2ee | 1454 | # Return 1 if this is an ARM target that adheres to the ABI for the ARM |
1455 | # Architecture. | |
1456 | ||
1457 | proc check_effective_target_arm_eabi { } { | |
1458 | return [check_no_compiler_messages arm_eabi object { | |
1459 | #ifndef __ARM_EABI__ | |
1460 | #error not EABI | |
1461 | #else | |
1462 | int dummy; | |
1463 | #endif | |
1464 | }] | |
1465 | } | |
1466 | ||
92fcf68f | 1467 | # Return 1 if this is a PowerPC target with floating-point registers. |
1468 | ||
1469 | proc check_effective_target_powerpc_fprs { } { | |
1470 | if { [istarget powerpc*-*-*] | |
1471 | || [istarget rs6000-*-*] } { | |
1472 | return [check_no_compiler_messages powerpc_fprs object { | |
1473 | #ifdef __NO_FPRS__ | |
1474 | #error no FPRs | |
1475 | #else | |
1476 | int dummy; | |
1477 | #endif | |
1478 | }] | |
1479 | } else { | |
1480 | return 0 | |
1481 | } | |
1482 | } | |
1483 | ||
2e585924 | 1484 | # Return 1 if this is a PowerPC target with hardware double-precision |
1485 | # floating point. | |
1486 | ||
1487 | proc check_effective_target_powerpc_hard_double { } { | |
1488 | if { [istarget powerpc*-*-*] | |
1489 | || [istarget rs6000-*-*] } { | |
1490 | return [check_no_compiler_messages powerpc_hard_double object { | |
1491 | #ifdef _SOFT_DOUBLE | |
1492 | #error soft double | |
1493 | #else | |
1494 | int dummy; | |
1495 | #endif | |
1496 | }] | |
1497 | } else { | |
1498 | return 0 | |
1499 | } | |
1500 | } | |
1501 | ||
92fcf68f | 1502 | # Return 1 if this is a PowerPC target supporting -maltivec. |
1503 | ||
1504 | proc check_effective_target_powerpc_altivec_ok { } { | |
a39ea4df | 1505 | if { ([istarget powerpc*-*-*] |
1506 | && ![istarget powerpc-*-linux*paired*]) | |
92fcf68f | 1507 | || [istarget rs6000-*-*] } { |
9400d827 | 1508 | # AltiVec is not supported on AIX before 5.3. |
1509 | if { [istarget powerpc*-*-aix4*] | |
1510 | || [istarget powerpc*-*-aix5.1*] | |
1511 | || [istarget powerpc*-*-aix5.2*] } { | |
92fcf68f | 1512 | return 0 |
1513 | } | |
1514 | return [check_no_compiler_messages powerpc_altivec_ok object { | |
1515 | int dummy; | |
1516 | } "-maltivec"] | |
1517 | } else { | |
1518 | return 0 | |
1519 | } | |
1520 | } | |
1521 | ||
700a7ea3 | 1522 | # Return 1 if this is a PowerPC target supporting -mcpu=cell. |
1523 | ||
1524 | proc check_effective_target_powerpc_ppu_ok { } { | |
1525 | if [check_effective_target_powerpc_altivec_ok] { | |
1526 | return [check_no_compiler_messages cell_asm_available object { | |
1527 | int main (void) { | |
1528 | #ifdef __MACH__ | |
1529 | asm volatile ("lvlx v0,v0,v0"); | |
1530 | #else | |
1531 | asm volatile ("lvlx 0,0,0"); | |
1532 | #endif | |
1533 | return 0; | |
1534 | } | |
1535 | }] | |
1536 | } else { | |
1537 | return 0 | |
1538 | } | |
1539 | } | |
1540 | ||
16b3b93f | 1541 | # Return 1 if this is a PowerPC target that supports SPU. |
1542 | ||
1543 | proc check_effective_target_powerpc_spu { } { | |
8ecacf14 | 1544 | if [istarget powerpc*-*-linux*] { |
1545 | return [check_effective_target_powerpc_altivec_ok] | |
1546 | } else { | |
1547 | return 0 | |
1548 | } | |
16b3b93f | 1549 | } |
1550 | ||
76c7f98f | 1551 | # Return 1 if this is a PowerPC SPE target. The check includes options |
1552 | # specified by dg-options for this test, so don't cache the result. | |
1553 | ||
1554 | proc check_effective_target_powerpc_spe_nocache { } { | |
1555 | if { [istarget powerpc*-*-*] } { | |
1556 | return [check_no_compiler_messages_nocache powerpc_spe object { | |
1557 | #ifndef __SPE__ | |
1558 | #error not SPE | |
1559 | #else | |
1560 | int dummy; | |
1561 | #endif | |
1562 | } [current_compiler_flags]] | |
1563 | } else { | |
1564 | return 0 | |
1565 | } | |
1566 | } | |
1567 | ||
8663c890 | 1568 | # Return 1 if this is a PowerPC target with SPE enabled. |
1569 | ||
1570 | proc check_effective_target_powerpc_spe { } { | |
1571 | if { [istarget powerpc*-*-*] } { | |
1572 | return [check_no_compiler_messages powerpc_spe object { | |
1573 | #ifndef __SPE__ | |
1574 | #error not SPE | |
1575 | #else | |
1576 | int dummy; | |
1577 | #endif | |
1578 | }] | |
1579 | } else { | |
1580 | return 0 | |
1581 | } | |
1582 | } | |
1583 | ||
efc2322a | 1584 | # Return 1 if this is a PowerPC target with Altivec enabled. |
1585 | ||
1586 | proc check_effective_target_powerpc_altivec { } { | |
1587 | if { [istarget powerpc*-*-*] } { | |
1588 | return [check_no_compiler_messages powerpc_altivec object { | |
1589 | #ifndef __ALTIVEC__ | |
1590 | #error not Altivec | |
1591 | #else | |
1592 | int dummy; | |
1593 | #endif | |
1594 | }] | |
1595 | } else { | |
1596 | return 0 | |
1597 | } | |
1598 | } | |
1599 | ||
6159737c | 1600 | # Return 1 if this is a PowerPC 405 target. The check includes options |
1601 | # specified by dg-options for this test, so don't cache the result. | |
1602 | ||
1603 | proc check_effective_target_powerpc_405_nocache { } { | |
1604 | if { [istarget powerpc*-*-*] || [istarget rs6000-*-*] } { | |
1605 | return [check_no_compiler_messages_nocache powerpc_405 object { | |
1606 | #ifdef __PPC405__ | |
1607 | int dummy; | |
1608 | #else | |
1609 | #error not a PPC405 | |
1610 | #endif | |
1611 | } [current_compiler_flags]] | |
1612 | } else { | |
1613 | return 0 | |
1614 | } | |
1615 | } | |
1616 | ||
3dd2807f | 1617 | # Return 1 if this is a SPU target with a toolchain that |
1618 | # supports automatic overlay generation. | |
1619 | ||
1620 | proc check_effective_target_spu_auto_overlay { } { | |
1621 | if { [istarget spu*-*-elf*] } { | |
1622 | return [check_no_compiler_messages spu_auto_overlay executable { | |
1623 | int main (void) { } | |
1624 | } "-Wl,--auto-overlay" ] | |
1625 | } else { | |
1626 | return 0 | |
1627 | } | |
1628 | } | |
1629 | ||
5f2db322 | 1630 | # The VxWorks SPARC simulator accepts only EM_SPARC executables and |
1631 | # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the | |
1632 | # test environment appears to run executables on such a simulator. | |
1633 | ||
1634 | proc check_effective_target_ultrasparc_hw { } { | |
383ec9c4 | 1635 | return [check_runtime ultrasparc_hw { |
1636 | int main() { return 0; } | |
1637 | } "-mcpu=ultrasparc"] | |
5f2db322 | 1638 | } |
1639 | ||
2202f408 | 1640 | # Return 1 if the target supports hardware vector shift operation. |
1641 | ||
1642 | proc check_effective_target_vect_shift { } { | |
e1e39447 | 1643 | global et_vect_shift_saved |
1644 | ||
1645 | if [info exists et_vect_shift_saved] { | |
1646 | verbose "check_effective_target_vect_shift: using cached result" 2 | |
2202f408 | 1647 | } else { |
e1e39447 | 1648 | set et_vect_shift_saved 0 |
a39ea4df | 1649 | if { ([istarget powerpc*-*-*] |
1650 | && ![istarget powerpc-*-linux*paired*]) | |
e1e39447 | 1651 | || [istarget ia64-*-*] |
1652 | || [istarget i?86-*-*] | |
f9f75854 | 1653 | || [istarget x86_64-*-*] |
1654 | || [check_effective_target_arm32] } { | |
e1e39447 | 1655 | set et_vect_shift_saved 1 |
1656 | } | |
2202f408 | 1657 | } |
1658 | ||
e1e39447 | 1659 | verbose "check_effective_target_vect_shift: returning $et_vect_shift_saved" 2 |
1660 | return $et_vect_shift_saved | |
2202f408 | 1661 | } |
1662 | ||
3ec9142f | 1663 | # Return 1 if the target supports hardware vectors of long, 0 otherwise. |
1664 | # | |
bef2e2fb | 1665 | # This can change for different subtargets so do not cache the result. |
3ec9142f | 1666 | |
1667 | proc check_effective_target_vect_long { } { | |
bef2e2fb | 1668 | if { [istarget i?86-*-*] |
a39ea4df | 1669 | || (([istarget powerpc*-*-*] |
1670 | && ![istarget powerpc-*-linux*paired*]) | |
1671 | && [check_effective_target_ilp32]) | |
bef2e2fb | 1672 | || [istarget x86_64-*-*] |
f9f75854 | 1673 | || [check_effective_target_arm32] |
bef2e2fb | 1674 | || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } { |
1675 | set answer 1 | |
3ec9142f | 1676 | } else { |
bef2e2fb | 1677 | set answer 0 |
3ec9142f | 1678 | } |
1679 | ||
bef2e2fb | 1680 | verbose "check_effective_target_vect_long: returning $answer" 2 |
1681 | return $answer | |
3ec9142f | 1682 | } |
1683 | ||
0e0971c0 | 1684 | # Return 1 if the target supports hardware vectors of float, 0 otherwise. |
1685 | # | |
1686 | # This won't change for different subtargets so cache the result. | |
1687 | ||
1688 | proc check_effective_target_vect_float { } { | |
1689 | global et_vect_float_saved | |
1690 | ||
1691 | if [info exists et_vect_float_saved] { | |
1692 | verbose "check_effective_target_vect_float: using cached result" 2 | |
1693 | } else { | |
1694 | set et_vect_float_saved 0 | |
1695 | if { [istarget i?86-*-*] | |
1696 | || [istarget powerpc*-*-*] | |
4fe49efc | 1697 | || [istarget spu-*-*] |
0e0971c0 | 1698 | || [istarget mipsisa64*-*-*] |
a5c5f9d3 | 1699 | || [istarget x86_64-*-*] |
f9f75854 | 1700 | || [istarget ia64-*-*] |
1701 | || [check_effective_target_arm32] } { | |
0e0971c0 | 1702 | set et_vect_float_saved 1 |
1703 | } | |
1704 | } | |
1705 | ||
1706 | verbose "check_effective_target_vect_float: returning $et_vect_float_saved" 2 | |
1707 | return $et_vect_float_saved | |
1708 | } | |
1709 | ||
1710 | # Return 1 if the target supports hardware vectors of double, 0 otherwise. | |
1711 | # | |
1712 | # This won't change for different subtargets so cache the result. | |
1713 | ||
1714 | proc check_effective_target_vect_double { } { | |
1715 | global et_vect_double_saved | |
1716 | ||
1717 | if [info exists et_vect_double_saved] { | |
1718 | verbose "check_effective_target_vect_double: using cached result" 2 | |
1719 | } else { | |
1720 | set et_vect_double_saved 0 | |
1721 | if { [istarget i?86-*-*] | |
4fe49efc | 1722 | || [istarget x86_64-*-*] |
1723 | || [istarget spu-*-*] } { | |
0e0971c0 | 1724 | set et_vect_double_saved 1 |
1725 | } | |
1726 | } | |
1727 | ||
1728 | verbose "check_effective_target_vect_double: returning $et_vect_double_saved" 2 | |
1729 | return $et_vect_double_saved | |
1730 | } | |
1731 | ||
862bb3cd | 1732 | # Return 1 if the target supports hardware vectors of long long, 0 otherwise. |
1733 | # | |
1734 | # This won't change for different subtargets so cache the result. | |
1735 | ||
1736 | proc check_effective_target_vect_long_long { } { | |
1737 | global et_vect_long_long_saved | |
1738 | ||
1739 | if [info exists et_vect_long_long_saved] { | |
1740 | verbose "check_effective_target_vect_long_long: using cached result" 2 | |
1741 | } else { | |
1742 | set et_vect_long_long_saved 0 | |
1743 | if { [istarget i?86-*-*] | |
81fb48bc | 1744 | || [istarget x86_64-*-*] } { |
862bb3cd | 1745 | set et_vect_long_long_saved 1 |
1746 | } | |
1747 | } | |
1748 | ||
1749 | verbose "check_effective_target_vect_long_long: returning $et_vect_long_long_saved" 2 | |
1750 | return $et_vect_long_long_saved | |
1751 | } | |
1752 | ||
1753 | ||
5028d56d | 1754 | # Return 1 if the target plus current options does not support a vector |
20e8f94a | 1755 | # max instruction on "int", 0 otherwise. |
5028d56d | 1756 | # |
1757 | # This won't change for different subtargets so cache the result. | |
1758 | ||
20e8f94a | 1759 | proc check_effective_target_vect_no_int_max { } { |
1760 | global et_vect_no_int_max_saved | |
5028d56d | 1761 | |
20e8f94a | 1762 | if [info exists et_vect_no_int_max_saved] { |
1763 | verbose "check_effective_target_vect_no_int_max: using cached result" 2 | |
5028d56d | 1764 | } else { |
20e8f94a | 1765 | set et_vect_no_int_max_saved 0 |
e313c83f | 1766 | if { [istarget sparc*-*-*] |
4fe49efc | 1767 | || [istarget spu-*-*] |
5028d56d | 1768 | || [istarget alpha*-*-*] } { |
20e8f94a | 1769 | set et_vect_no_int_max_saved 1 |
5028d56d | 1770 | } |
1771 | } | |
20e8f94a | 1772 | verbose "check_effective_target_vect_no_int_max: returning $et_vect_no_int_max_saved" 2 |
1773 | return $et_vect_no_int_max_saved | |
1774 | } | |
1775 | ||
1776 | # Return 1 if the target plus current options does not support a vector | |
1777 | # add instruction on "int", 0 otherwise. | |
1778 | # | |
1779 | # This won't change for different subtargets so cache the result. | |
1780 | ||
1781 | proc check_effective_target_vect_no_int_add { } { | |
1782 | global et_vect_no_int_add_saved | |
1783 | ||
1784 | if [info exists et_vect_no_int_add_saved] { | |
1785 | verbose "check_effective_target_vect_no_int_add: using cached result" 2 | |
1786 | } else { | |
1787 | set et_vect_no_int_add_saved 0 | |
1788 | # Alpha only supports vector add on V8QI and V4HI. | |
1789 | if { [istarget alpha*-*-*] } { | |
1790 | set et_vect_no_int_add_saved 1 | |
1791 | } | |
1792 | } | |
1793 | verbose "check_effective_target_vect_no_int_add: returning $et_vect_no_int_add_saved" 2 | |
1794 | return $et_vect_no_int_add_saved | |
5028d56d | 1795 | } |
1796 | ||
1797 | # Return 1 if the target plus current options does not support vector | |
1798 | # bitwise instructions, 0 otherwise. | |
1799 | # | |
1800 | # This won't change for different subtargets so cache the result. | |
1801 | ||
1802 | proc check_effective_target_vect_no_bitwise { } { | |
1803 | global et_vect_no_bitwise_saved | |
1804 | ||
1805 | if [info exists et_vect_no_bitwise_saved] { | |
1806 | verbose "check_effective_target_vect_no_bitwise: using cached result" 2 | |
1807 | } else { | |
1808 | set et_vect_no_bitwise_saved 0 | |
5028d56d | 1809 | } |
1810 | verbose "check_effective_target_vect_no_bitwise: returning $et_vect_no_bitwise_saved" 2 | |
1811 | return $et_vect_no_bitwise_saved | |
1812 | } | |
1813 | ||
a0515226 | 1814 | # Return 1 if the target plus current options supports vector permutation, |
1815 | # 0 otherwise. | |
1816 | # | |
1817 | # This won't change for different subtargets so cache the result. | |
1818 | ||
1819 | proc check_effective_target_vect_perm { } { | |
1820 | global et_vect_perm | |
1821 | ||
1822 | if [info exists et_vect_perm_saved] { | |
1823 | verbose "check_effective_target_vect_perm: using cached result" 2 | |
1824 | } else { | |
1825 | set et_vect_perm_saved 0 | |
1826 | if { [istarget powerpc*-*-*] | |
1827 | || [istarget spu-*-*] } { | |
1828 | set et_vect_perm_saved 1 | |
1829 | } | |
1830 | } | |
1831 | verbose "check_effective_target_vect_perm: returning $et_vect_perm_saved" 2 | |
1832 | return $et_vect_perm_saved | |
1833 | } | |
1834 | ||
1835 | ||
3000c6f3 | 1836 | # Return 1 if the target plus current options supports a vector |
1837 | # widening summation of *short* args into *int* result, 0 otherwise. | |
c6c91d61 | 1838 | # A target can also support this widening summation if it can support |
1839 | # promotion (unpacking) from shorts to ints. | |
3000c6f3 | 1840 | # |
1841 | # This won't change for different subtargets so cache the result. | |
1842 | ||
1843 | proc check_effective_target_vect_widen_sum_hi_to_si { } { | |
1844 | global et_vect_widen_sum_hi_to_si | |
c6c91d61 | 1845 | |
3000c6f3 | 1846 | if [info exists et_vect_widen_sum_hi_to_si_saved] { |
1847 | verbose "check_effective_target_vect_widen_sum_hi_to_si: using cached result" 2 | |
1848 | } else { | |
c6c91d61 | 1849 | set et_vect_widen_sum_hi_to_si_saved [check_effective_target_vect_unpack] |
c2c53ff9 | 1850 | if { [istarget powerpc*-*-*] |
1851 | || [istarget ia64-*-*] } { | |
3000c6f3 | 1852 | set et_vect_widen_sum_hi_to_si_saved 1 |
1853 | } | |
1854 | } | |
1855 | verbose "check_effective_target_vect_widen_sum_hi_to_si: returning $et_vect_widen_sum_hi_to_si_saved" 2 | |
1856 | return $et_vect_widen_sum_hi_to_si_saved | |
1857 | } | |
1858 | ||
1859 | # Return 1 if the target plus current options supports a vector | |
1860 | # widening summation of *char* args into *short* result, 0 otherwise. | |
c6c91d61 | 1861 | # A target can also support this widening summation if it can support |
1862 | # promotion (unpacking) from chars to shorts. | |
3000c6f3 | 1863 | # |
1864 | # This won't change for different subtargets so cache the result. | |
1865 | ||
1866 | proc check_effective_target_vect_widen_sum_qi_to_hi { } { | |
1867 | global et_vect_widen_sum_qi_to_hi | |
c6c91d61 | 1868 | |
3000c6f3 | 1869 | if [info exists et_vect_widen_sum_qi_to_hi_saved] { |
1870 | verbose "check_effective_target_vect_widen_sum_qi_to_hi: using cached result" 2 | |
1871 | } else { | |
1872 | set et_vect_widen_sum_qi_to_hi_saved 0 | |
c2c53ff9 | 1873 | if { [check_effective_target_vect_unpack] |
1874 | || [istarget ia64-*-*] } { | |
3000c6f3 | 1875 | set et_vect_widen_sum_qi_to_hi_saved 1 |
c6c91d61 | 1876 | } |
3000c6f3 | 1877 | } |
1878 | verbose "check_effective_target_vect_widen_sum_qi_to_hi: returning $et_vect_widen_sum_qi_to_hi_saved" 2 | |
1879 | return $et_vect_widen_sum_qi_to_hi_saved | |
1880 | } | |
1881 | ||
1882 | # Return 1 if the target plus current options supports a vector | |
1883 | # widening summation of *char* args into *int* result, 0 otherwise. | |
1884 | # | |
1885 | # This won't change for different subtargets so cache the result. | |
1886 | ||
1887 | proc check_effective_target_vect_widen_sum_qi_to_si { } { | |
1888 | global et_vect_widen_sum_qi_to_si | |
c6c91d61 | 1889 | |
3000c6f3 | 1890 | if [info exists et_vect_widen_sum_qi_to_si_saved] { |
1891 | verbose "check_effective_target_vect_widen_sum_qi_to_si: using cached result" 2 | |
1892 | } else { | |
1893 | set et_vect_widen_sum_qi_to_si_saved 0 | |
1894 | if { [istarget powerpc*-*-*] } { | |
1895 | set et_vect_widen_sum_qi_to_si_saved 1 | |
1896 | } | |
1897 | } | |
1898 | verbose "check_effective_target_vect_widen_sum_qi_to_si: returning $et_vect_widen_sum_qi_to_si_saved" 2 | |
1899 | return $et_vect_widen_sum_qi_to_si_saved | |
1900 | } | |
1901 | ||
4a61a337 | 1902 | # Return 1 if the target plus current options supports a vector |
c6c91d61 | 1903 | # widening multiplication of *char* args into *short* result, 0 otherwise. |
1904 | # A target can also support this widening multplication if it can support | |
1905 | # promotion (unpacking) from chars to shorts, and vect_short_mult (non-widening | |
1906 | # multiplication of shorts). | |
4a61a337 | 1907 | # |
1908 | # This won't change for different subtargets so cache the result. | |
c6c91d61 | 1909 | |
1910 | ||
1911 | proc check_effective_target_vect_widen_mult_qi_to_hi { } { | |
1912 | global et_vect_widen_mult_qi_to_hi | |
1913 | ||
1914 | if [info exists et_vect_widen_mult_qi_to_hi_saved] { | |
1915 | verbose "check_effective_target_vect_widen_mult_qi_to_hi: using cached result" 2 | |
4a61a337 | 1916 | } else { |
c6c91d61 | 1917 | if { [check_effective_target_vect_unpack] |
1918 | && [check_effective_target_vect_short_mult] } { | |
1919 | set et_vect_widen_mult_qi_to_hi_saved 1 | |
1920 | } else { | |
1921 | set et_vect_widen_mult_qi_to_hi_saved 0 | |
1922 | } | |
1923 | if { [istarget powerpc*-*-*] } { | |
1924 | set et_vect_widen_mult_qi_to_hi_saved 1 | |
4a61a337 | 1925 | } |
1926 | } | |
c6c91d61 | 1927 | verbose "check_effective_target_vect_widen_mult_qi_to_hi: returning $et_vect_widen_mult_qi_to_hi_saved" 2 |
1928 | return $et_vect_widen_mult_qi_to_hi_saved | |
1929 | } | |
1930 | ||
1931 | # Return 1 if the target plus current options supports a vector | |
1932 | # widening multiplication of *short* args into *int* result, 0 otherwise. | |
1933 | # A target can also support this widening multplication if it can support | |
1934 | # promotion (unpacking) from shorts to ints, and vect_int_mult (non-widening | |
1935 | # multiplication of ints). | |
1936 | # | |
1937 | # This won't change for different subtargets so cache the result. | |
1938 | ||
1939 | ||
1940 | proc check_effective_target_vect_widen_mult_hi_to_si { } { | |
1941 | global et_vect_widen_mult_hi_to_si | |
1942 | ||
1943 | if [info exists et_vect_widen_mult_hi_to_si_saved] { | |
1944 | verbose "check_effective_target_vect_widen_mult_hi_to_si: using cached result" 2 | |
1945 | } else { | |
1946 | if { [check_effective_target_vect_unpack] | |
1947 | && [check_effective_target_vect_int_mult] } { | |
1948 | set et_vect_widen_mult_hi_to_si_saved 1 | |
1949 | } else { | |
1950 | set et_vect_widen_mult_hi_to_si_saved 0 | |
1951 | } | |
1f428eb0 | 1952 | if { [istarget powerpc*-*-*] |
e99f512d | 1953 | || [istarget spu-*-*] |
1f428eb0 | 1954 | || [istarget i?86-*-*] |
1955 | || [istarget x86_64-*-*] } { | |
c6c91d61 | 1956 | set et_vect_widen_mult_hi_to_si_saved 1 |
1957 | } | |
1958 | } | |
1959 | verbose "check_effective_target_vect_widen_mult_hi_to_si: returning $et_vect_widen_mult_hi_to_si_saved" 2 | |
1960 | return $et_vect_widen_mult_hi_to_si_saved | |
4a61a337 | 1961 | } |
1962 | ||
1963 | # Return 1 if the target plus current options supports a vector | |
1964 | # dot-product of signed chars, 0 otherwise. | |
1965 | # | |
1966 | # This won't change for different subtargets so cache the result. | |
1967 | ||
1968 | proc check_effective_target_vect_sdot_qi { } { | |
1969 | global et_vect_sdot_qi | |
1970 | ||
1971 | if [info exists et_vect_sdot_qi_saved] { | |
1972 | verbose "check_effective_target_vect_sdot_qi: using cached result" 2 | |
1973 | } else { | |
1974 | set et_vect_sdot_qi_saved 0 | |
4a61a337 | 1975 | } |
1976 | verbose "check_effective_target_vect_sdot_qi: returning $et_vect_sdot_qi_saved" 2 | |
1977 | return $et_vect_sdot_qi_saved | |
1978 | } | |
1979 | ||
1980 | # Return 1 if the target plus current options supports a vector | |
1981 | # dot-product of unsigned chars, 0 otherwise. | |
1982 | # | |
1983 | # This won't change for different subtargets so cache the result. | |
1984 | ||
1985 | proc check_effective_target_vect_udot_qi { } { | |
1986 | global et_vect_udot_qi | |
1987 | ||
1988 | if [info exists et_vect_udot_qi_saved] { | |
1989 | verbose "check_effective_target_vect_udot_qi: using cached result" 2 | |
1990 | } else { | |
1991 | set et_vect_udot_qi_saved 0 | |
c6c91d61 | 1992 | if { [istarget powerpc*-*-*] } { |
4a61a337 | 1993 | set et_vect_udot_qi_saved 1 |
1994 | } | |
1995 | } | |
1996 | verbose "check_effective_target_vect_udot_qi: returning $et_vect_udot_qi_saved" 2 | |
1997 | return $et_vect_udot_qi_saved | |
1998 | } | |
1999 | ||
2000 | # Return 1 if the target plus current options supports a vector | |
2001 | # dot-product of signed shorts, 0 otherwise. | |
2002 | # | |
2003 | # This won't change for different subtargets so cache the result. | |
2004 | ||
2005 | proc check_effective_target_vect_sdot_hi { } { | |
2006 | global et_vect_sdot_hi | |
2007 | ||
2008 | if [info exists et_vect_sdot_hi_saved] { | |
2009 | verbose "check_effective_target_vect_sdot_hi: using cached result" 2 | |
2010 | } else { | |
2011 | set et_vect_sdot_hi_saved 0 | |
a39ea4df | 2012 | if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) |
4a61a337 | 2013 | || [istarget i?86-*-*] |
c6c91d61 | 2014 | || [istarget x86_64-*-*] } { |
4a61a337 | 2015 | set et_vect_sdot_hi_saved 1 |
2016 | } | |
2017 | } | |
2018 | verbose "check_effective_target_vect_sdot_hi: returning $et_vect_sdot_hi_saved" 2 | |
2019 | return $et_vect_sdot_hi_saved | |
2020 | } | |
2021 | ||
2022 | # Return 1 if the target plus current options supports a vector | |
2023 | # dot-product of unsigned shorts, 0 otherwise. | |
2024 | # | |
2025 | # This won't change for different subtargets so cache the result. | |
2026 | ||
2027 | proc check_effective_target_vect_udot_hi { } { | |
2028 | global et_vect_udot_hi | |
2029 | ||
2030 | if [info exists et_vect_udot_hi_saved] { | |
2031 | verbose "check_effective_target_vect_udot_hi: using cached result" 2 | |
2032 | } else { | |
2033 | set et_vect_udot_hi_saved 0 | |
a39ea4df | 2034 | if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) } { |
4a61a337 | 2035 | set et_vect_udot_hi_saved 1 |
2036 | } | |
2037 | } | |
2038 | verbose "check_effective_target_vect_udot_hi: returning $et_vect_udot_hi_saved" 2 | |
2039 | return $et_vect_udot_hi_saved | |
2040 | } | |
2041 | ||
2042 | ||
c6c91d61 | 2043 | # Return 1 if the target plus current options supports a vector |
2044 | # demotion (packing) of shorts (to chars) and ints (to shorts) | |
2045 | # using modulo arithmetic, 0 otherwise. | |
2046 | # | |
2047 | # This won't change for different subtargets so cache the result. | |
2048 | ||
39387fec | 2049 | proc check_effective_target_vect_pack_trunc { } { |
2050 | global et_vect_pack_trunc | |
c6c91d61 | 2051 | |
39387fec | 2052 | if [info exists et_vect_pack_trunc_saved] { |
2053 | verbose "check_effective_target_vect_pack_trunc: using cached result" 2 | |
c6c91d61 | 2054 | } else { |
39387fec | 2055 | set et_vect_pack_trunc_saved 0 |
a39ea4df | 2056 | if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) |
c6c91d61 | 2057 | || [istarget i?86-*-*] |
d46f3cd0 | 2058 | || [istarget x86_64-*-*] |
2059 | || [istarget spu-*-*] } { | |
39387fec | 2060 | set et_vect_pack_trunc_saved 1 |
c6c91d61 | 2061 | } |
2062 | } | |
39387fec | 2063 | verbose "check_effective_target_vect_pack_trunc: returning $et_vect_pack_trunc_saved" 2 |
2064 | return $et_vect_pack_trunc_saved | |
c6c91d61 | 2065 | } |
2066 | ||
2067 | # Return 1 if the target plus current options supports a vector | |
2068 | # promotion (unpacking) of chars (to shorts) and shorts (to ints), 0 otherwise. | |
2069 | # | |
2070 | # This won't change for different subtargets so cache the result. | |
2071 | ||
2072 | proc check_effective_target_vect_unpack { } { | |
2073 | global et_vect_unpack | |
2074 | ||
2075 | if [info exists et_vect_unpack_saved] { | |
2076 | verbose "check_effective_target_vect_unpack: using cached result" 2 | |
2077 | } else { | |
2078 | set et_vect_unpack_saved 0 | |
a39ea4df | 2079 | if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*]) |
c6c91d61 | 2080 | || [istarget i?86-*-*] |
8c85798c | 2081 | || [istarget x86_64-*-*] |
2082 | || [istarget spu-*-*] } { | |
c6c91d61 | 2083 | set et_vect_unpack_saved 1 |
2084 | } | |
2085 | } | |
2086 | verbose "check_effective_target_vect_unpack: returning $et_vect_unpack_saved" 2 | |
2087 | return $et_vect_unpack_saved | |
2088 | } | |
2089 | ||
2483fa68 | 2090 | # Return 1 if the target plus current options does not guarantee |
2091 | # that its STACK_BOUNDARY is >= the reguired vector alignment. | |
2092 | # | |
2093 | # This won't change for different subtargets so cache the result. | |
2094 | ||
2095 | proc check_effective_target_unaligned_stack { } { | |
2096 | global et_unaligned_stack_saved | |
2097 | ||
2098 | if [info exists et_unaligned_stack_saved] { | |
2099 | verbose "check_effective_target_unaligned_stack: using cached result" 2 | |
2100 | } else { | |
2101 | set et_unaligned_stack_saved 0 | |
2483fa68 | 2102 | } |
2103 | verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2 | |
2104 | return $et_unaligned_stack_saved | |
2105 | } | |
2106 | ||
5028d56d | 2107 | # Return 1 if the target plus current options does not support a vector |
2108 | # alignment mechanism, 0 otherwise. | |
2109 | # | |
2110 | # This won't change for different subtargets so cache the result. | |
2111 | ||
2112 | proc check_effective_target_vect_no_align { } { | |
2113 | global et_vect_no_align_saved | |
2114 | ||
2115 | if [info exists et_vect_no_align_saved] { | |
2116 | verbose "check_effective_target_vect_no_align: using cached result" 2 | |
2117 | } else { | |
2118 | set et_vect_no_align_saved 0 | |
8b804257 | 2119 | if { [istarget mipsisa64*-*-*] |
a5c5f9d3 | 2120 | || [istarget sparc*-*-*] |
f9f75854 | 2121 | || [istarget ia64-*-*] |
2122 | || [check_effective_target_arm32] } { | |
5028d56d | 2123 | set et_vect_no_align_saved 1 |
2124 | } | |
2125 | } | |
2126 | verbose "check_effective_target_vect_no_align: returning $et_vect_no_align_saved" 2 | |
2127 | return $et_vect_no_align_saved | |
2128 | } | |
2129 | ||
fba6e19a | 2130 | # Return 1 if arrays are aligned to the vector alignment |
2131 | # boundary, 0 otherwise. | |
5090788d | 2132 | # |
2133 | # This won't change for different subtargets so cache the result. | |
2134 | ||
2135 | proc check_effective_target_vect_aligned_arrays { } { | |
2136 | global et_vect_aligned_arrays | |
2137 | ||
2138 | if [info exists et_vect_aligned_arrays_saved] { | |
2139 | verbose "check_effective_target_vect_aligned_arrays: using cached result" 2 | |
2140 | } else { | |
2141 | set et_vect_aligned_arrays_saved 0 | |
ff7e0027 | 2142 | if { (([istarget x86_64-*-*] |
2143 | || [istarget i?86-*-*]) && [is-effective-target lp64]) | |
2144 | || [istarget spu-*-*] } { | |
5090788d | 2145 | set et_vect_aligned_arrays_saved 1 |
2146 | } | |
2147 | } | |
2148 | verbose "check_effective_target_vect_aligned_arrays: returning $et_vect_aligned_arrays_saved" 2 | |
2149 | return $et_vect_aligned_arrays_saved | |
2150 | } | |
2151 | ||
ff7e0027 | 2152 | # Return 1 if types of size 32 bit or less are naturally aligned |
2153 | # (aligned to their type-size), 0 otherwise. | |
2154 | # | |
2155 | # This won't change for different subtargets so cache the result. | |
2156 | ||
2157 | proc check_effective_target_natural_alignment_32 { } { | |
2158 | global et_natural_alignment_32 | |
2159 | ||
2160 | if [info exists et_natural_alignment_32_saved] { | |
2161 | verbose "check_effective_target_natural_alignment_32: using cached result" 2 | |
2162 | } else { | |
2163 | # FIXME: 32bit powerpc: guaranteed only if MASK_ALIGN_NATURAL/POWER. | |
2164 | set et_natural_alignment_32_saved 1 | |
2165 | if { ([istarget *-*-darwin*] && [is-effective-target lp64]) } { | |
2166 | set et_natural_alignment_32_saved 0 | |
2167 | } | |
2168 | } | |
2169 | verbose "check_effective_target_natural_alignment_32: returning $et_natural_alignment_32_saved" 2 | |
2170 | return $et_natural_alignment_32_saved | |
2171 | } | |
2172 | ||
2173 | # Return 1 if types of size 64 bit or less are naturally aligned (aligned to their | |
2174 | # type-size), 0 otherwise. | |
0e87db76 | 2175 | # |
2176 | # This won't change for different subtargets so cache the result. | |
2177 | ||
ff7e0027 | 2178 | proc check_effective_target_natural_alignment_64 { } { |
2179 | global et_natural_alignment_64 | |
0e87db76 | 2180 | |
ff7e0027 | 2181 | if [info exists et_natural_alignment_64_saved] { |
2182 | verbose "check_effective_target_natural_alignment_64: using cached result" 2 | |
0e87db76 | 2183 | } else { |
ff7e0027 | 2184 | set et_natural_alignment_64_saved 0 |
2185 | if { ([is-effective-target lp64] && ![istarget *-*-darwin*]) | |
2186 | || [istarget spu-*-*] } { | |
2187 | set et_natural_alignment_64_saved 1 | |
0e87db76 | 2188 | } |
2189 | } | |
ff7e0027 | 2190 | verbose "check_effective_target_natural_alignment_64: returning $et_natural_alignment_64_saved" 2 |
2191 | return $et_natural_alignment_64_saved | |
0e87db76 | 2192 | } |
2193 | ||
ff7e0027 | 2194 | # Return 1 if vector alignment (for types of size 32 bit or less) is reachable, 0 otherwise. |
0e87db76 | 2195 | # |
2196 | # This won't change for different subtargets so cache the result. | |
2197 | ||
2198 | proc check_effective_target_vector_alignment_reachable { } { | |
2199 | global et_vector_alignment_reachable | |
2200 | ||
2201 | if [info exists et_vector_alignment_reachable_saved] { | |
2202 | verbose "check_effective_target_vector_alignment_reachable: using cached result" 2 | |
2203 | } else { | |
2204 | if { [check_effective_target_vect_aligned_arrays] | |
ff7e0027 | 2205 | || [check_effective_target_natural_alignment_32] } { |
0e87db76 | 2206 | set et_vector_alignment_reachable_saved 1 |
2207 | } else { | |
2208 | set et_vector_alignment_reachable_saved 0 | |
2209 | } | |
2210 | } | |
2211 | verbose "check_effective_target_vector_alignment_reachable: returning $et_vector_alignment_reachable_saved" 2 | |
2212 | return $et_vector_alignment_reachable_saved | |
2213 | } | |
2214 | ||
ff7e0027 | 2215 | # Return 1 if vector alignment for 64 bit is reachable, 0 otherwise. |
3744f5f8 | 2216 | # |
2217 | # This won't change for different subtargets so cache the result. | |
2218 | ||
ff7e0027 | 2219 | proc check_effective_target_vector_alignment_reachable_for_64bit { } { |
2220 | global et_vector_alignment_reachable_for_64bit | |
3744f5f8 | 2221 | |
ff7e0027 | 2222 | if [info exists et_vector_alignment_reachable_for_64bit_saved] { |
2223 | verbose "check_effective_target_vector_alignment_reachable_for_64bit: using cached result" 2 | |
3744f5f8 | 2224 | } else { |
ff7e0027 | 2225 | if { [check_effective_target_vect_aligned_arrays] |
2226 | || [check_effective_target_natural_alignment_64] } { | |
2227 | set et_vector_alignment_reachable_for_64bit_saved 1 | |
3744f5f8 | 2228 | } else { |
ff7e0027 | 2229 | set et_vector_alignment_reachable_for_64bit_saved 0 |
3744f5f8 | 2230 | } |
2231 | } | |
ff7e0027 | 2232 | verbose "check_effective_target_vector_alignment_reachable_for_64bit: returning $et_vector_alignment_reachable_for_64bit_saved" 2 |
2233 | return $et_vector_alignment_reachable_for_64bit_saved | |
3744f5f8 | 2234 | } |
2235 | ||
e9705e7f | 2236 | # Return 1 if the target supports vector conditional operations, 0 otherwise. |
2237 | ||
2238 | proc check_effective_target_vect_condition { } { | |
2239 | global et_vect_cond_saved | |
2240 | ||
e1e39447 | 2241 | if [info exists et_vect_cond_saved] { |
e9705e7f | 2242 | verbose "check_effective_target_vect_cond: using cached result" 2 |
2243 | } else { | |
2244 | set et_vect_cond_saved 0 | |
76405cce | 2245 | if { [istarget powerpc*-*-*] |
2246 | || [istarget ia64-*-*] | |
2247 | || [istarget i?86-*-*] | |
5474166e | 2248 | || [istarget spu-*-*] |
76405cce | 2249 | || [istarget x86_64-*-*] } { |
e9705e7f | 2250 | set et_vect_cond_saved 1 |
2251 | } | |
2252 | } | |
2253 | ||
2254 | verbose "check_effective_target_vect_cond: returning $et_vect_cond_saved" 2 | |
2255 | return $et_vect_cond_saved | |
2256 | } | |
2257 | ||
3000c6f3 | 2258 | # Return 1 if the target supports vector char multiplication, 0 otherwise. |
2259 | ||
2260 | proc check_effective_target_vect_char_mult { } { | |
2261 | global et_vect_char_mult_saved | |
2262 | ||
2263 | if [info exists et_vect_char_mult_saved] { | |
2264 | verbose "check_effective_target_vect_char_mult: using cached result" 2 | |
2265 | } else { | |
2266 | set et_vect_char_mult_saved 0 | |
2267 | if { [istarget ia64-*-*] | |
2268 | || [istarget i?86-*-*] | |
2269 | || [istarget x86_64-*-*] } { | |
2270 | set et_vect_char_mult_saved 1 | |
2271 | } | |
2272 | } | |
2273 | ||
2274 | verbose "check_effective_target_vect_char_mult: returning $et_vect_char_mult_saved" 2 | |
2275 | return $et_vect_char_mult_saved | |
2276 | } | |
2277 | ||
2278 | # Return 1 if the target supports vector short multiplication, 0 otherwise. | |
2279 | ||
2280 | proc check_effective_target_vect_short_mult { } { | |
2281 | global et_vect_short_mult_saved | |
2282 | ||
2283 | if [info exists et_vect_short_mult_saved] { | |
2284 | verbose "check_effective_target_vect_short_mult: using cached result" 2 | |
2285 | } else { | |
2286 | set et_vect_short_mult_saved 0 | |
2287 | if { [istarget ia64-*-*] | |
8c85798c | 2288 | || [istarget spu-*-*] |
3000c6f3 | 2289 | || [istarget i?86-*-*] |
0da87323 | 2290 | || [istarget x86_64-*-*] |
a184d254 | 2291 | || [istarget powerpc*-*-*] |
2292 | || [check_effective_target_arm32] } { | |
3000c6f3 | 2293 | set et_vect_short_mult_saved 1 |
2294 | } | |
2295 | } | |
2296 | ||
2297 | verbose "check_effective_target_vect_short_mult: returning $et_vect_short_mult_saved" 2 | |
2298 | return $et_vect_short_mult_saved | |
2299 | } | |
2300 | ||
5210db79 | 2301 | # Return 1 if the target supports vector int multiplication, 0 otherwise. |
2302 | ||
2303 | proc check_effective_target_vect_int_mult { } { | |
2304 | global et_vect_int_mult_saved | |
2305 | ||
87121034 | 2306 | if [info exists et_vect_int_mult_saved] { |
5210db79 | 2307 | verbose "check_effective_target_vect_int_mult: using cached result" 2 |
2308 | } else { | |
2309 | set et_vect_int_mult_saved 0 | |
a39ea4df | 2310 | if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*]) |
a28df51d | 2311 | || [istarget spu-*-*] |
c195473e | 2312 | || [istarget i?86-*-*] |
f9f75854 | 2313 | || [istarget x86_64-*-*] |
2314 | || [check_effective_target_arm32] } { | |
5210db79 | 2315 | set et_vect_int_mult_saved 1 |
2316 | } | |
2317 | } | |
2318 | ||
2319 | verbose "check_effective_target_vect_int_mult: returning $et_vect_int_mult_saved" 2 | |
2320 | return $et_vect_int_mult_saved | |
2321 | } | |
e9705e7f | 2322 | |
6b8dbb53 | 2323 | # Return 1 if the target supports vector even/odd elements extraction, 0 otherwise. |
2324 | ||
2325 | proc check_effective_target_vect_extract_even_odd { } { | |
2326 | global et_vect_extract_even_odd_saved | |
2327 | ||
2328 | if [info exists et_vect_extract_even_odd_saved] { | |
2329 | verbose "check_effective_target_vect_extract_even_odd: using cached result" 2 | |
2330 | } else { | |
2331 | set et_vect_extract_even_odd_saved 0 | |
d46f3cd0 | 2332 | if { [istarget powerpc*-*-*] |
2333 | || [istarget spu-*-*] } { | |
6b8dbb53 | 2334 | set et_vect_extract_even_odd_saved 1 |
2335 | } | |
2336 | } | |
2337 | ||
2338 | verbose "check_effective_target_vect_extract_even_odd: returning $et_vect_extract_even_odd_saved" 2 | |
2339 | return $et_vect_extract_even_odd_saved | |
2340 | } | |
2341 | ||
56c7c824 | 2342 | # Return 1 if the target supports vector even/odd elements extraction of |
2343 | # vectors with SImode elements or larger, 0 otherwise. | |
2344 | ||
2345 | proc check_effective_target_vect_extract_even_odd_wide { } { | |
2346 | global et_vect_extract_even_odd_wide_saved | |
2347 | ||
2348 | if [info exists et_vect_extract_even_odd_wide_saved] { | |
2349 | verbose "check_effective_target_vect_extract_even_odd_wide: using cached result" 2 | |
2350 | } else { | |
2351 | set et_vect_extract_even_odd_wide_saved 0 | |
2352 | if { [istarget powerpc*-*-*] | |
2353 | || [istarget i?86-*-*] | |
d46f3cd0 | 2354 | || [istarget x86_64-*-*] |
2355 | || [istarget spu-*-*] } { | |
56c7c824 | 2356 | set et_vect_extract_even_odd_wide_saved 1 |
2357 | } | |
2358 | } | |
2359 | ||
2360 | verbose "check_effective_target_vect_extract_even_wide_odd: returning $et_vect_extract_even_odd_wide_saved" 2 | |
2361 | return $et_vect_extract_even_odd_wide_saved | |
2362 | } | |
2363 | ||
6b8dbb53 | 2364 | # Return 1 if the target supports vector interleaving, 0 otherwise. |
2365 | ||
2366 | proc check_effective_target_vect_interleave { } { | |
2367 | global et_vect_interleave_saved | |
2368 | ||
2369 | if [info exists et_vect_interleave_saved] { | |
2370 | verbose "check_effective_target_vect_interleave: using cached result" 2 | |
2371 | } else { | |
2372 | set et_vect_interleave_saved 0 | |
2373 | if { [istarget powerpc*-*-*] | |
2374 | || [istarget i?86-*-*] | |
d46f3cd0 | 2375 | || [istarget x86_64-*-*] |
2376 | || [istarget spu-*-*] } { | |
6b8dbb53 | 2377 | set et_vect_interleave_saved 1 |
2378 | } | |
2379 | } | |
2380 | ||
2381 | verbose "check_effective_target_vect_interleave: returning $et_vect_interleave_saved" 2 | |
2382 | return $et_vect_interleave_saved | |
2383 | } | |
2384 | ||
c6895939 | 2385 | # Return 1 if the target supports vector interleaving and extract even/odd, 0 otherwise. |
2386 | proc check_effective_target_vect_strided { } { | |
2387 | global et_vect_strided_saved | |
2388 | ||
2389 | if [info exists et_vect_strided_saved] { | |
2390 | verbose "check_effective_target_vect_strided: using cached result" 2 | |
2391 | } else { | |
2392 | set et_vect_strided_saved 0 | |
2393 | if { [check_effective_target_vect_interleave] | |
2394 | && [check_effective_target_vect_extract_even_odd] } { | |
2395 | set et_vect_strided_saved 1 | |
2396 | } | |
2397 | } | |
2398 | ||
2399 | verbose "check_effective_target_vect_strided: returning $et_vect_strided_saved" 2 | |
2400 | return $et_vect_strided_saved | |
2401 | } | |
2402 | ||
56c7c824 | 2403 | # Return 1 if the target supports vector interleaving and extract even/odd |
2404 | # for wide element types, 0 otherwise. | |
2405 | proc check_effective_target_vect_strided_wide { } { | |
2406 | global et_vect_strided_wide_saved | |
2407 | ||
2408 | if [info exists et_vect_strided_wide_saved] { | |
2409 | verbose "check_effective_target_vect_strided_wide: using cached result" 2 | |
2410 | } else { | |
2411 | set et_vect_strided_wide_saved 0 | |
2412 | if { [check_effective_target_vect_interleave] | |
2413 | && [check_effective_target_vect_extract_even_odd_wide] } { | |
2414 | set et_vect_strided_wide_saved 1 | |
2415 | } | |
2416 | } | |
2417 | ||
2418 | verbose "check_effective_target_vect_strided_wide: returning $et_vect_strided_wide_saved" 2 | |
2419 | return $et_vect_strided_wide_saved | |
2420 | } | |
2421 | ||
9896f25b | 2422 | # Return 1 if the target supports section-anchors |
2423 | ||
2424 | proc check_effective_target_section_anchors { } { | |
2425 | global et_section_anchors_saved | |
2426 | ||
2427 | if [info exists et_section_anchors_saved] { | |
2428 | verbose "check_effective_target_section_anchors: using cached result" 2 | |
2429 | } else { | |
2430 | set et_section_anchors_saved 0 | |
2431 | if { [istarget powerpc*-*-*] } { | |
2432 | set et_section_anchors_saved 1 | |
2433 | } | |
2434 | } | |
2435 | ||
2436 | verbose "check_effective_target_section_anchors: returning $et_section_anchors_saved" 2 | |
2437 | return $et_section_anchors_saved | |
2438 | } | |
2439 | ||
87121034 | 2440 | # Return 1 if the target supports atomic operations on "int" and "long". |
2441 | ||
2442 | proc check_effective_target_sync_int_long { } { | |
2443 | global et_sync_int_long_saved | |
2444 | ||
2445 | if [info exists et_sync_int_long_saved] { | |
2446 | verbose "check_effective_target_sync_int_long: using cached result" 2 | |
2447 | } else { | |
2448 | set et_sync_int_long_saved 0 | |
970ae149 | 2449 | # This is intentionally powerpc but not rs6000, rs6000 doesn't have the |
2450 | # load-reserved/store-conditional instructions. | |
87121034 | 2451 | if { [istarget ia64-*-*] |
2452 | || [istarget i?86-*-*] | |
2453 | || [istarget x86_64-*-*] | |
970ae149 | 2454 | || [istarget alpha*-*-*] |
e8473153 | 2455 | || [istarget s390*-*-*] |
6c6e47a5 | 2456 | || [istarget powerpc*-*-*] |
2457 | || [istarget sparc64-*-*] | |
40efb338 | 2458 | || [istarget sparcv9-*-*] |
2459 | || [istarget mips*-*-*] } { | |
87121034 | 2460 | set et_sync_int_long_saved 1 |
2461 | } | |
2462 | } | |
2463 | ||
2464 | verbose "check_effective_target_sync_int_long: returning $et_sync_int_long_saved" 2 | |
2465 | return $et_sync_int_long_saved | |
2466 | } | |
2467 | ||
2246af0a | 2468 | # Return 1 if the target supports atomic operations on "char" and "short". |
2469 | ||
2470 | proc check_effective_target_sync_char_short { } { | |
2471 | global et_sync_char_short_saved | |
2472 | ||
2473 | if [info exists et_sync_char_short_saved] { | |
2474 | verbose "check_effective_target_sync_char_short: using cached result" 2 | |
2475 | } else { | |
2476 | set et_sync_char_short_saved 0 | |
2477 | # This is intentionally powerpc but not rs6000, rs6000 doesn't have the | |
2478 | # load-reserved/store-conditional instructions. | |
2479 | if { [istarget ia64-*-*] | |
2480 | || [istarget i?86-*-*] | |
2481 | || [istarget x86_64-*-*] | |
596d3184 | 2482 | || [istarget alpha*-*-*] |
182f815e | 2483 | || [istarget s390*-*-*] |
6c6e47a5 | 2484 | || [istarget powerpc*-*-*] |
2485 | || [istarget sparc64-*-*] | |
40efb338 | 2486 | || [istarget sparcv9-*-*] |
2487 | || [istarget mips*-*-*] } { | |
2246af0a | 2488 | set et_sync_char_short_saved 1 |
2489 | } | |
2490 | } | |
2491 | ||
2492 | verbose "check_effective_target_sync_char_short: returning $et_sync_char_short_saved" 2 | |
2493 | return $et_sync_char_short_saved | |
2494 | } | |
2495 | ||
7c4ef0f0 | 2496 | # Return 1 if the target uses a ColdFire FPU. |
2497 | ||
2498 | proc check_effective_target_coldfire_fpu { } { | |
2499 | return [check_no_compiler_messages coldfire_fpu assembly { | |
2500 | #ifndef __mcffpu__ | |
2501 | #error FOO | |
2502 | #endif | |
2503 | }] | |
2504 | } | |
2505 | ||
f248f4ef | 2506 | # Return true if this is a uClibc target. |
2507 | ||
2508 | proc check_effective_target_uclibc {} { | |
2509 | return [check_no_compiler_messages uclibc object { | |
2510 | #include <features.h> | |
2511 | #if !defined (__UCLIBC__) | |
2512 | #error FOO | |
2513 | #endif | |
2514 | }] | |
2515 | } | |
2516 | ||
616560f2 | 2517 | # Return true if this is a uclibc target and if the uclibc feature |
2518 | # described by __$feature__ is not present. | |
2519 | ||
2520 | proc check_missing_uclibc_feature {feature} { | |
3a0c1df2 | 2521 | return [check_no_compiler_messages $feature object " |
2522 | #include <features.h> | |
32220f06 | 2523 | #if !defined (__UCLIBC) || defined (__${feature}__) |
3a0c1df2 | 2524 | #error FOO |
2525 | #endif | |
2526 | "] | |
616560f2 | 2527 | } |
2528 | ||
55616ae2 | 2529 | # Return true if this is a Newlib target. |
2530 | ||
2531 | proc check_effective_target_newlib {} { | |
2532 | return [check_no_compiler_messages newlib object { | |
2533 | #include <newlib.h> | |
2534 | }] | |
2535 | } | |
2536 | ||
e29698fd | 2537 | # Return 1 if |
2538 | # (a) an error of a few ULP is expected in string to floating-point | |
2539 | # conversion functions; and | |
2540 | # (b) overflow is not always detected correctly by those functions. | |
2541 | ||
2542 | proc check_effective_target_lax_strtofp {} { | |
2543 | # By default, assume that all uClibc targets suffer from this. | |
2544 | return [check_effective_target_uclibc] | |
2545 | } | |
2546 | ||
2547 | # Return 1 if this is a target for which wcsftime is a dummy | |
2548 | # function that always returns 0. | |
2549 | ||
2550 | proc check_effective_target_dummy_wcsftime {} { | |
2551 | # By default, assume that all uClibc targets suffer from this. | |
2552 | return [check_effective_target_uclibc] | |
2553 | } | |
2554 | ||
9af7fd5b | 2555 | # Return 1 if constructors with initialization priority arguments are |
2556 | # supposed on this target. | |
2557 | ||
2558 | proc check_effective_target_init_priority {} { | |
9af7fd5b | 2559 | return [check_no_compiler_messages init_priority assembly " |
2560 | void f() __attribute__((constructor (1000))); | |
2561 | void f() \{\} | |
2562 | "] | |
2563 | } | |
2564 | ||
34d688ab | 2565 | # Return 1 if the target matches the effective target 'arg', 0 otherwise. |
2566 | # This can be used with any check_* proc that takes no argument and | |
2567 | # returns only 1 or 0. It could be used with check_* procs that take | |
2568 | # arguments with keywords that pass particular arguments. | |
2569 | ||
2570 | proc is-effective-target { arg } { | |
2571 | set selected 0 | |
766cf2ea | 2572 | if { [info procs check_effective_target_${arg}] != [list] } { |
2573 | set selected [check_effective_target_${arg}] | |
2574 | } else { | |
2575 | switch $arg { | |
2576 | "vmx_hw" { set selected [check_vmx_hw_available] } | |
2577 | "named_sections" { set selected [check_named_sections_available] } | |
2578 | "gc_sections" { set selected [check_gc_sections_available] } | |
1b4091a0 | 2579 | "cxa_atexit" { set selected [check_cxa_atexit_available] } |
766cf2ea | 2580 | default { error "unknown effective target keyword `$arg'" } |
2581 | } | |
34d688ab | 2582 | } |
2583 | verbose "is-effective-target: $arg $selected" 2 | |
2584 | return $selected | |
2585 | } | |
f347a455 | 2586 | |
2587 | # Return 1 if the argument is an effective-target keyword, 0 otherwise. | |
2588 | ||
2589 | proc is-effective-target-keyword { arg } { | |
2590 | if { [info procs check_effective_target_${arg}] != [list] } { | |
2591 | return 1 | |
2592 | } else { | |
2593 | # These have different names for their check_* procs. | |
2594 | switch $arg { | |
2595 | "vmx_hw" { return 1 } | |
2596 | "named_sections" { return 1 } | |
2597 | "gc_sections" { return 1 } | |
1b4091a0 | 2598 | "cxa_atexit" { return 1 } |
f347a455 | 2599 | default { return 0 } |
2600 | } | |
2601 | } | |
2602 | } | |
d82fdc24 | 2603 | |
2604 | # Return 1 if target default to short enums | |
2605 | ||
2606 | proc check_effective_target_short_enums { } { | |
b7714d40 | 2607 | return [check_no_compiler_messages short_enums assembly { |
2608 | enum foo { bar }; | |
2609 | int s[sizeof (enum foo) == 1 ? 1 : -1]; | |
2610 | }] | |
d82fdc24 | 2611 | } |
2612 | ||
4533b23c | 2613 | # Return 1 if target supports merging string constants at link time. |
2614 | ||
2615 | proc check_effective_target_string_merging { } { | |
2616 | return [check_no_messages_and_pattern string_merging \ | |
2617 | "rodata\\.str" assembly { | |
2618 | const char *var = "String"; | |
2619 | } {-O2}] | |
2620 | } | |
37334623 | 2621 | |
2622 | # Return 1 if target has the basic signed and unsigned types in | |
f3449a3c | 2623 | # <stdint.h>, 0 otherwise. This will be obsolete when GCC ensures a |
2624 | # working <stdint.h> for all targets. | |
37334623 | 2625 | |
2626 | proc check_effective_target_stdint_types { } { | |
2627 | return [check_no_compiler_messages stdint_types assembly { | |
2628 | #include <stdint.h> | |
2629 | int8_t a; int16_t b; int32_t c; int64_t d; | |
2630 | uint8_t e; uint16_t f; uint32_t g; uint64_t h; | |
2631 | }] | |
2632 | } | |
6123c183 | 2633 | |
f3449a3c | 2634 | # Return 1 if target has the basic signed and unsigned types in |
2635 | # <inttypes.h>, 0 otherwise. This is for tests that GCC's notions of | |
2636 | # these types agree with those in the header, as some systems have | |
2637 | # only <inttypes.h>. | |
2638 | ||
2639 | proc check_effective_target_inttypes_types { } { | |
2640 | return [check_no_compiler_messages inttypes_types assembly { | |
2641 | #include <inttypes.h> | |
2642 | int8_t a; int16_t b; int32_t c; int64_t d; | |
2643 | uint8_t e; uint16_t f; uint32_t g; uint64_t h; | |
2644 | }] | |
2645 | } | |
2646 | ||
6123c183 | 2647 | # Return 1 if programs are intended to be run on a simulator |
2648 | # (i.e. slowly) rather than hardware (i.e. fast). | |
2649 | ||
2650 | proc check_effective_target_simulator { } { | |
2651 | ||
2652 | # All "src/sim" simulators set this one. | |
2653 | if [board_info target exists is_simulator] { | |
2654 | return [board_info target is_simulator] | |
2655 | } | |
2656 | ||
2657 | # The "sid" simulators don't set that one, but at least they set | |
2658 | # this one. | |
2659 | if [board_info target exists slow_simulator] { | |
2660 | return [board_info target slow_simulator] | |
2661 | } | |
2662 | ||
2663 | return 0 | |
2664 | } | |
eeca68b7 | 2665 | |
a20c72eb | 2666 | # Return 1 if the target is a VxWorks kernel. |
eeca68b7 | 2667 | |
2668 | proc check_effective_target_vxworks_kernel { } { | |
2669 | return [check_no_compiler_messages vxworks_kernel assembly { | |
2670 | #if !defined __vxworks || defined __RTP__ | |
2671 | #error NO | |
2672 | #endif | |
2673 | }] | |
2674 | } | |
616560f2 | 2675 | |
a20c72eb | 2676 | # Return 1 if the target is a VxWorks RTP. |
2677 | ||
2678 | proc check_effective_target_vxworks_rtp { } { | |
2679 | return [check_no_compiler_messages vxworks_rtp assembly { | |
2680 | #if !defined __vxworks || !defined __RTP__ | |
2681 | #error NO | |
2682 | #endif | |
2683 | }] | |
2684 | } | |
2685 | ||
616560f2 | 2686 | # Return 1 if the target is expected to provide wide character support. |
2687 | ||
2688 | proc check_effective_target_wchar { } { | |
2689 | if {[check_missing_uclibc_feature UCLIBC_HAS_WCHAR]} { | |
2690 | return 0 | |
2691 | } | |
2692 | return [check_no_compiler_messages wchar assembly { | |
2693 | #include <wchar.h> | |
2694 | }] | |
2695 | } | |
9c7f6198 | 2696 | |
218fb16a | 2697 | # Return 1 if the target has <pthread.h>. |
2698 | ||
2699 | proc check_effective_target_pthread_h { } { | |
2700 | return [check_no_compiler_messages pthread_h assembly { | |
2701 | #include <pthread.h> | |
2702 | }] | |
2703 | } | |
2704 | ||
b5857ece | 2705 | # Return 1 if the target can truncate a file from a file-descriptor, |
2706 | # as used by libgfortran/io/unix.c:fd_truncate; i.e. ftruncate or | |
2707 | # chsize. We test for a trivially functional truncation; no stubs. | |
2708 | # As libgfortran uses _FILE_OFFSET_BITS 64, we do too; it'll cause a | |
2709 | # different function to be used. | |
2710 | ||
2711 | proc check_effective_target_fd_truncate { } { | |
2712 | set prog { | |
2713 | #define _FILE_OFFSET_BITS 64 | |
2714 | #include <unistd.h> | |
2715 | #include <stdio.h> | |
2716 | #include <stdlib.h> | |
2717 | int main () | |
2718 | { | |
2719 | FILE *f = fopen ("tst.tmp", "wb"); | |
2720 | int fd; | |
2721 | const char t[] = "test writing more than ten characters"; | |
2722 | char s[11]; | |
2723 | fd = fileno (f); | |
2724 | write (fd, t, sizeof (t) - 1); | |
2725 | lseek (fd, 0, 0); | |
2726 | if (ftruncate (fd, 10) != 0) | |
2727 | exit (1); | |
2728 | close (fd); | |
2729 | f = fopen ("tst.tmp", "rb"); | |
2730 | if (fread (s, 1, sizeof (s), f) != 10 || strncmp (s, t, 10) != 0) | |
2731 | exit (1); | |
2732 | exit (0); | |
2733 | } | |
2734 | } | |
2735 | ||
2736 | if { [check_runtime ftruncate $prog] } { | |
2737 | return 1; | |
2738 | } | |
2739 | ||
2740 | regsub "ftruncate" $prog "chsize" prog | |
2741 | return [check_runtime chsize $prog] | |
2742 | } | |
2743 | ||
9c7f6198 | 2744 | # Add to FLAGS all the target-specific flags needed to access the c99 runtime. |
2745 | ||
2746 | proc add_options_for_c99_runtime { flags } { | |
2747 | if { [istarget *-*-solaris2*] } { | |
2748 | return "$flags -std=c99" | |
2749 | } | |
2750 | if { [istarget powerpc-*-darwin*] } { | |
2751 | return "$flags -mmacosx-version-min=10.3" | |
2752 | } | |
2753 | return $flags | |
2754 | } | |
720f6ebb | 2755 | |
2756 | # Return 1 if the target provides a full C99 runtime. | |
2757 | ||
2758 | proc check_effective_target_c99_runtime { } { | |
2759 | return [check_cached_effective_target c99_runtime { | |
2760 | global srcdir | |
2761 | ||
2762 | set file [open "$srcdir/gcc.dg/builtins-config.h"] | |
2763 | set contents [read $file] | |
2764 | close $file | |
2765 | append contents { | |
2766 | #ifndef HAVE_C99_RUNTIME | |
2767 | #error FOO | |
2768 | #endif | |
2769 | } | |
383ec9c4 | 2770 | check_no_compiler_messages_nocache c99_runtime assembly \ |
2771 | $contents [add_options_for_c99_runtime ""] | |
720f6ebb | 2772 | }] |
2773 | } | |
0c42ee5b | 2774 | |
2775 | # Return 1 if target wchar_t is at least 4 bytes. | |
2776 | ||
2777 | proc check_effective_target_4byte_wchar_t { } { | |
2778 | return [check_no_compiler_messages 4byte_wchar_t object { | |
b9940fd2 | 2779 | int dummy[sizeof (__WCHAR_TYPE__) >= 4 ? 1 : -1]; |
0c42ee5b | 2780 | }] |
2781 | } | |
cc31dd2a | 2782 | |
2783 | # Return 1 if the target supports automatic stack alignment. | |
2784 | ||
2785 | proc check_effective_target_automatic_stack_alignment { } { | |
2786 | if { [istarget i?86*-*-*] | |
2787 | || [istarget x86_64-*-*] } then { | |
2788 | return 1 | |
2789 | } else { | |
2790 | return 0 | |
2791 | } | |
2792 | } | |
e60895e5 | 2793 | |
2794 | # Return 1 if avx instructions can be compiled. | |
2795 | ||
2796 | proc check_effective_target_avx { } { | |
2797 | return [check_no_compiler_messages avx object { | |
2798 | void _mm256_zeroall (void) | |
2799 | { | |
2800 | __builtin_ia32_vzeroall (); | |
2801 | } | |
2802 | } "-O2 -mavx" ] | |
2803 | } | |
c79da9aa | 2804 | |
2805 | # Return 1 if C wchar_t type is compatible with char16_t. | |
2806 | ||
2807 | proc check_effective_target_wchar_t_char16_t_compatible { } { | |
2808 | return [check_no_compiler_messages wchar_t_char16_t object { | |
2809 | __WCHAR_TYPE__ wc; | |
2810 | __CHAR16_TYPE__ *p16 = &wc; | |
2811 | char t[(((__CHAR16_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; | |
2812 | }] | |
2813 | } | |
2814 | ||
2815 | # Return 1 if C wchar_t type is compatible with char32_t. | |
2816 | ||
2817 | proc check_effective_target_wchar_t_char32_t_compatible { } { | |
2818 | return [check_no_compiler_messages wchar_t_char32_t object { | |
2819 | __WCHAR_TYPE__ wc; | |
2820 | __CHAR32_TYPE__ *p32 = &wc; | |
2821 | char t[(((__CHAR32_TYPE__) -1) < 0 == ((__WCHAR_TYPE__) -1) < 0) ? 1 : -1]; | |
2822 | }] | |
2823 | } | |
46ca4aa9 | 2824 | |
2825 | # Return 1 if pow10 function exists. | |
2826 | ||
2827 | proc check_effective_target_pow10 { } { | |
2828 | return [check_runtime pow10 { | |
2829 | #include <math.h> | |
2830 | int main () { | |
2831 | double x; | |
2832 | x = pow10 (1); | |
2833 | return 0; | |
2834 | } | |
2835 | } "-lm" ] | |
2836 | } | |
c938d9eb | 2837 | |
2838 | # Return 1 if current options generate DFP instructions, 0 otherwise. | |
2839 | ||
2840 | proc check_effective_target_hard_dfp {} { | |
2841 | return [check_no_messages_and_pattern hard_dfp "!adddd3" assembly { | |
2842 | _Decimal64 x, y, z; | |
2843 | void foo (void) { z = x + y; } | |
2844 | }] | |
2845 | } | |
b6c6057e | 2846 | |
2847 | # Return 1 if string.h and wchar.h headers provide C++ requires overloads | |
2848 | # for strchr etc. functions. | |
2849 | ||
2850 | proc check_effective_target_correct_iso_cpp_string_wchar_protos { } { | |
2851 | return [check_no_compiler_messages correct_iso_cpp_string_wchar_protos assembly { | |
2852 | #include <string.h> | |
2853 | #include <wchar.h> | |
2854 | #if !defined(__cplusplus) \ | |
2855 | || !defined(__CORRECT_ISO_CPP_STRING_H_PROTO) \ | |
2856 | || !defined(__CORRECT_ISO_CPP_WCHAR_H_PROTO) | |
2857 | ISO C++ correct string.h and wchar.h protos not supported. | |
2858 | #else | |
2859 | int i; | |
2860 | #endif | |
2861 | }] | |
2862 | } |