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 310

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

powered by: WebSVN 2.1.0

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