OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [lib/] [target-supports.exp] - Blame information for rev 399

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.