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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [lib/] [target-supports-dg.exp] - Blame information for rev 706

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 701 jeremybenn
#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2007, 2008, 2009, 2010,
2
#   2011 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
# DejaGnu's dg-test defines extra flags that are used to compile a test.
19
# Access them for directives that need to examine all options that are
20
# used for a test, including checks for non-cached effective targets.
21
# We don't know how far up the call chain it is but we know we'll hit
22
# it eventually, and that we're at least 3 calls down.
23
 
24
proc current_compiler_flags { } {
25
    set frames 2
26
    while { ![info exists flags1] } {
27
        set frames [expr $frames + 1]
28
        upvar $frames dg-extra-tool-flags flags1
29
    }
30
    upvar $frames tool_flags flags2
31
    return "$flags1 $flags2"
32
}
33
 
34
# If this target does not support weak symbols, skip this test.
35
 
36
proc dg-require-weak { args } {
37
    set weak_available [ check_weak_available ]
38
    if { $weak_available == -1 } {
39
        upvar name name
40
        unresolved "$name"
41
    }
42
    if { $weak_available != 1 } {
43
        upvar dg-do-what dg-do-what
44
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
45
    }
46
}
47
 
48
# If this target does not support overriding weak symbols, skip this
49
# test.
50
 
51
proc dg-require-weak-override { args } {
52
    set weak_override_available [ check_weak_override_available ]
53
    if { $weak_override_available == -1 } {
54
        upvar name name
55
        unresolved "$name"
56
    }
57
    if { $weak_override_available != 1 } {
58
        upvar dg-do-what dg-do-what
59
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
60
    }
61
}
62
 
63
# If this target does not support the "visibility" attribute, skip this
64
# test.
65
 
66
proc dg-require-visibility { args } {
67
    set visibility_available [ check_visibility_available [lindex $args 1 ] ]
68
    if { $visibility_available == -1 } {
69
        upvar name name
70
        unresolved "$name"
71
    }
72
    if { $visibility_available != 1 } {
73
        upvar dg-do-what dg-do-what
74
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
75
    }
76
}
77
 
78
# If this target does not support the "alias" attribute, skip this
79
# test.
80
 
81
proc dg-require-alias { args } {
82
    set alias_available [ check_alias_available ]
83
    if { $alias_available == -1 } {
84
        upvar name name
85
        unresolved "$name"
86
    }
87
    if { $alias_available < 2 } {
88
        upvar dg-do-what dg-do-what
89
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
90
    }
91
}
92
 
93
# If this target does not support the "ifunc" attribute, skip this
94
# test.
95
 
96
proc dg-require-ifunc { args } {
97
    if { ![ check_ifunc_available ] } {
98
        upvar dg-do-what dg-do-what
99
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
100
    }
101
}
102
 
103
# If this target's linker does not support the --gc-sections flag,
104
# skip this test.
105
 
106
proc dg-require-gc-sections { args } {
107
    if { ![ check_gc_sections_available ] } {
108
        upvar dg-do-what dg-do-what
109
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
110
    }
111
}
112
 
113
# If this target does not support profiling, skip this test.
114
 
115
proc dg-require-profiling { args } {
116
    if { ![ check_profiling_available [lindex $args 1] ] } {
117
        upvar dg-do-what dg-do-what
118
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
119
    }
120
}
121
 
122
# If this target does not support DLL attributes skip this test.
123
 
124
proc dg-require-dll { args } {
125
    # As a special case, the mcore-*-elf supports these attributes.
126
    # All Symbian OS targets also support these attributes.
127
    if { [istarget mcore-*-elf]
128
         || [istarget *-*-symbianelf] } {
129
        return
130
    }
131
    # PE/COFF targets support dllimport/dllexport.
132
    if { [gcc_target_object_format] == "pe" } {
133
        return
134
    }
135
 
136
    upvar dg-do-what dg-do-what
137
    set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
138
}
139
 
140
# If this host does not support an ASCII locale, skip this test.
141
 
142
proc dg-require-ascii-locale { args } {
143
    if { ![ check_ascii_locale_available] } {
144
        upvar dg-do-what dg-do-what
145
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
146
    }
147
}
148
 
149
proc dg-require-iconv { args } {
150
    if { ![ check_iconv_available ${args} ] } {
151
        upvar dg-do-what dg-do-what
152
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
153
    }
154
}
155
 
156
# If this target does not support named sections skip this test.
157
 
158
proc dg-require-named-sections { args } {
159
    if { ![ check_named_sections_available ] } {
160
        upvar dg-do-what dg-do-what
161
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
162
    }
163
}
164
 
165
# If the target does not match the required effective target, skip this test.
166
# Only apply this if the optional selector matches.
167
 
168
proc dg-require-effective-target { args } {
169
    set args [lreplace $args 0 0]
170
    # Verify the number of arguments.  The last is optional.
171
    if { [llength $args] < 1 || [llength $args] > 2 } {
172
        error "syntax error, need a single effective-target keyword with optional selector"
173
    }
174
 
175
    # Don't bother if we're already skipping the test.
176
    upvar dg-do-what dg-do-what
177
    if { [lindex ${dg-do-what} 1] == "N" } {
178
      return
179
    }
180
 
181
    # Evaluate selector if present.
182
    if { [llength $args] == 2 } {
183
        switch [dg-process-target [lindex $args 1]] {
184
            "S" { }
185
            "N" { return }
186
        }
187
    }
188
 
189
    if { ![is-effective-target [lindex $args 0]] } {
190
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
191
    }
192
}
193
 
194
# If this target does not have fork, skip this test.
195
 
196
proc dg-require-fork { args } {
197
    if { ![check_fork_available] } {
198
        upvar dg-do-what dg-do-what
199
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
200
    }
201
}
202
 
203
# If this target does not have mkfifo, skip this test.
204
 
205
proc dg-require-mkfifo { args } {
206
    if { ![check_mkfifo_available] } {
207
        upvar dg-do-what dg-do-what
208
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
209
    }
210
}
211
 
212
# If this target does not use __cxa_atexit, skip this test.
213
 
214
proc dg-require-cxa-atexit { args } {
215
    if { ![ check_cxa_atexit_available ] } {
216
        upvar dg-do-what dg-do-what
217
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
218
    }
219
}
220
 
221
# If the host is remote rather than the same as the build system, skip
222
# this test.  Some tests are incompatible with DejaGnu's handling of
223
# remote hosts, which involves copying the source file to the host and
224
# compiling it with a relative path and "-o a.out".
225
 
226
proc dg-require-host-local { args } {
227
    if [ is_remote host ] {
228
        upvar dg-do-what dg-do-what
229
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
230
    }
231
}
232
 
233
proc dg-require-linker-plugin { args } {
234
    set linker_plugin_available [ check_linker_plugin_available ]
235
    if { $linker_plugin_available == 0 } {
236
        upvar dg-do-what dg-do-what
237
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
238
    }
239
}
240
 
241
# Add any target-specific flags needed for accessing the given list
242
# of features.  This must come after all dg-options.
243
 
244
proc dg-add-options { args } {
245
    upvar dg-extra-tool-flags extra-tool-flags
246
 
247
    foreach arg [lrange $args 1 end] {
248
        if { [info procs add_options_for_$arg] != "" } {
249
            set extra-tool-flags \
250
                [eval [list add_options_for_$arg ${extra-tool-flags}]]
251
        } else {
252
            error "Unrecognized option type: $arg"
253
        }
254
    }
255
}
256
 
257
# Compare flags for a test directive against flags that will be used to
258
# compile the test: multilib flags, flags for torture options, and either
259
# the default flags for this group of tests or flags specified with a
260
# previous dg-options directive.
261
 
262
proc check-flags { args } {
263
    global compiler_flags
264
    global TOOL_OPTIONS
265
    global TEST_ALWAYS_FLAGS
266
 
267
    # The args are within another list; pull them out.
268
    set args [lindex $args 0]
269
 
270
    # Start the list with a dummy tool name so the list will match "*"
271
    # if there are no flags.
272
    set compiler_flags " toolname "
273
    append compiler_flags [current_compiler_flags]
274
    # If running a subset of the test suite, $TOOL_OPTIONS may not exist.
275
    catch {append compiler_flags " $TOOL_OPTIONS "}
276
    # If running a subset of the test suite, $TEST_ALWAYS_FLAGS may not exist.
277
    catch {append compiler_flags " $TEST_ALWAYS_FLAGS "}
278
    set dest [target_info name]
279
    if [board_info $dest exists multilib_flags] {
280
        append compiler_flags "[board_info $dest multilib_flags] "
281
    }
282
 
283
    # The next two arguments are optional.  If they were not specified,
284
    # use the defaults.
285
    if { [llength $args] == 2 } {
286
        lappend $args [list "*"]
287
    }
288
    if { [llength $args] == 3 } {
289
        lappend $args [list ""]
290
    }
291
 
292
    # If the option strings are the defaults, or the same as the
293
    # defaults, there is no need to call check_conditional_xfail to
294
    # compare them to the actual options.
295
    if { [string compare [lindex $args 2] "*"] == 0
296
         && [string compare [lindex $args 3] "" ] == 0 } {
297
        set result 1
298
    } else {
299
        # The target list might be an effective-target keyword, so replace
300
        # the original list with "*-*-*", since we already know it matches.
301
        set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
302
    }
303
 
304
    # Any value in this variable was left over from an earlier test.
305
    set compiler_flags ""
306
 
307
    return $result
308
}
309
 
310
# Skip the test (report it as UNSUPPORTED) if the target list and
311
# included flags are matched and the excluded flags are not matched.
312
#
313
# The first argument is the line number of the dg-skip-if directive
314
# within the test file.   Remaining arguments are as for xfail lists:
315
# message { targets } { include } { exclude }
316
#
317
# This tests against multilib flags plus either the default flags for this
318
# group of tests or flags specified with a previous dg-options command.
319
 
320
proc dg-skip-if { args } {
321
    # Verify the number of arguments.  The last two are optional.
322
    set args [lreplace $args 0 0]
323
    if { [llength $args] < 2 || [llength $args] > 4 } {
324
        error "dg-skip-if 2: need 2, 3, or 4 arguments"
325
    }
326
 
327
    # Don't bother if we're already skipping the test.
328
    upvar dg-do-what dg-do-what
329
    if { [lindex ${dg-do-what} 1] == "N" } {
330
      return
331
    }
332
 
333
    set selector [list target [lindex $args 1]]
334
    if { [dg-process-target $selector] == "S" } {
335
        if [check-flags $args] {
336
            upvar dg-do-what dg-do-what
337
            set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
338
        }
339
    }
340
}
341
 
342
# Like check_conditional_xfail, but callable from a dg test.
343
 
344
proc dg-xfail-if { args } {
345
    # Verify the number of arguments.  The last three are optional.
346
    set args [lreplace $args 0 0]
347
    if { [llength $args] < 2 || [llength $args] > 4 } {
348
        error "dg-xfail-if: need 2, 3, or 4 arguments"
349
    }
350
 
351
    # Don't change anything if we're already skipping the test.
352
    upvar dg-do-what dg-do-what
353
    if { [lindex ${dg-do-what} 1] == "N" } {
354
      return
355
    }
356
 
357
    set selector [list target [lindex $args 1]]
358
    if { [dg-process-target $selector] == "S" } {
359
        global compiler_conditional_xfail_data
360
 
361
        # The target list might be an effective-target keyword.  Replace
362
        # the original list with "*-*-*", since we already know it matches.
363
        set args [lreplace $args 1 1 "*-*-*"]
364
 
365
        # Supply default values for unspecified optional arguments.
366
        if { [llength $args] == 2 } {
367
            lappend $args [list "*"]
368
        }
369
        if { [llength $args] == 3 } {
370
            lappend $args [list ""]
371
        }
372
 
373
        set compiler_conditional_xfail_data $args
374
    }
375
}
376
 
377
# Like dg-xfail-if but for the execute step.
378
 
379
proc dg-xfail-run-if { args } {
380
    # Verify the number of arguments.  The last two are optional.
381
    set args [lreplace $args 0 0]
382
    if { [llength $args] < 2 || [llength $args] > 4 } {
383
        error "dg-xfail-run-if: need 2, 3, or 4 arguments"
384
    }
385
 
386
    # Don't bother if we're already skipping the test.
387
    upvar dg-do-what dg-do-what
388
    if { [lindex ${dg-do-what} 1] == "N" } {
389
      return
390
    }
391
 
392
    set selector [list target [lindex $args 1]]
393
    if { [dg-process-target $selector] == "S" } {
394
        if [check-flags $args] {
395
            upvar dg-do-what dg-do-what
396
            set dg-do-what [list [lindex ${dg-do-what} 0] "S" "F"]
397
        }
398
    }
399
}
400
 
401
# Record whether the program is expected to return a nonzero status.
402
 
403
set shouldfail 0
404
 
405
proc dg-shouldfail { args } {
406
    # Don't bother if we're already skipping the test.
407
    upvar dg-do-what dg-do-what
408
    if { [lindex ${dg-do-what} 1] == "N" } {
409
      return
410
    }
411
 
412
    global shouldfail
413
 
414
    set args [lreplace $args 0 0]
415
    if { [llength $args] > 1 } {
416
        set selector [list target [lindex $args 1]]
417
        if { [dg-process-target $selector] == "S" } {
418
            # The target matches, now check the flags.
419
            if [check-flags $args] {
420
                set shouldfail 1
421
            }
422
        }
423
    } else {
424
        set shouldfail 1
425
    }
426
}
427
 
428
# Intercept the call to the DejaGnu version of dg-process-target to
429
# support use of an effective-target keyword in place of a list of
430
# target triplets to xfail or skip a test.
431
#
432
# selector is one of:
433
#    xfail target-triplet-1 ...
434
#    xfail effective-target-keyword
435
#    xfail selector-expression
436
#    target target-triplet-1 ...
437
#    target effective-target-keyword
438
#    target selector-expression
439
#
440
# For a target list the result is "S" if the target is selected, "N" otherwise.
441
# For an xfail list the result is "F" if the target is affected, "P" otherwise.
442
#
443
# A selector expression appears within curly braces and uses a single logical
444
# operator: !, &&, or ||.  An operand is another selector expression, an
445
# effective-target keyword, or a list of target triplets within quotes or
446
# curly braces.
447
 
448
if { [info procs saved-dg-process-target] == [list] } {
449
    rename dg-process-target saved-dg-process-target
450
 
451
    # Evaluate an operand within a selector expression.
452
    proc selector_opd { op } {
453
        set selector "target"
454
        lappend selector $op
455
        set answer [ expr { [dg-process-target $selector] == "S" } ]
456
        verbose "selector_opd: `$op' $answer" 2
457
        return $answer
458
    }
459
 
460
    # Evaluate a target triplet list within a selector expression.
461
    # Unlike other operands, this needs to be expanded from a list to
462
    # the same string as "target".
463
    proc selector_list { op } {
464
        set selector "target [join $op]"
465
        set answer [ expr { [dg-process-target $selector] == "S" } ]
466
        verbose "selector_list: `$op' $answer" 2
467
        return $answer
468
    }
469
 
470
    # Evaluate a selector expression.
471
    proc selector_expression { exp } {
472
        if { [llength $exp] == 2 } {
473
            if [string match "!" [lindex $exp 0]] {
474
                set op1 [lindex $exp 1]
475
                set answer [expr { ! [selector_opd $op1] }]
476
            } else {
477
                # Assume it's a list of target triplets.
478
                set answer [selector_list $exp]
479
            }
480
        } elseif { [llength $exp] == 3 } {
481
            set op1 [lindex $exp 0]
482
            set opr [lindex $exp 1]
483
            set op2 [lindex $exp 2]
484
            if [string match "&&" $opr] {
485
                set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
486
            } elseif [string match "||" $opr] {
487
                set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
488
            } else {
489
                # Assume it's a list of target triplets.
490
                set answer [selector_list $exp]
491
            }
492
        } else {
493
            # Assume it's a list of target triplets.
494
            set answer [selector_list $exp]
495
        }
496
 
497
        verbose "selector_expression: `$exp' $answer" 2
498
        return $answer
499
    }
500
 
501
    proc dg-process-target { args } {
502
        verbose "replacement dg-process-target: `$args'" 2
503
 
504
        # Extract the 'what' keyword from the argument list.
505
        set selector [string trim [lindex $args 0]]
506
        if [regexp "^xfail " $selector] {
507
            set what "xfail"
508
        } elseif [regexp "^target " $selector] {
509
            set what "target"
510
        } else {
511
            error "syntax error in target selector \"$selector\""
512
        }
513
 
514
        # Extract the rest of the list, which might be a keyword.
515
        regsub "^${what}" $selector "" rest
516
        set rest [string trim $rest]
517
 
518
        if [is-effective-target-keyword $rest] {
519
            # The selector is an effective target keyword.
520
            if [is-effective-target $rest] {
521
                return [expr { $what == "xfail" ? "F" : "S" }]
522
            } else {
523
                return [expr { $what == "xfail" ? "P" : "N" }]
524
            }
525
        }
526
 
527
        if [string match "{*}" $rest] {
528
            if [selector_expression [lindex $rest 0]] {
529
                return [expr { $what == "xfail" ? "F" : "S" }]
530
            } else {
531
                return [expr { $what == "xfail" ? "P" : "N" }]
532
            }
533
        }
534
 
535
        # The selector is not an effective-target keyword, so process
536
        # the list of target triplets.
537
        return [saved-dg-process-target $selector]
538
    }
539
}

powered by: WebSVN 2.1.0

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