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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [lib/] [target-supports-dg.exp] - Blame information for rev 149

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

Line No. Rev Author Line
1 149 jeremybenn
#   Copyright (C) 1997, 1999, 2000, 2003, 2004, 2005, 2007
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
# If this target does not support weak symbols, skip this test.
19
 
20
proc dg-require-weak { args } {
21
    set weak_available [ check_weak_available ]
22
    if { $weak_available == -1 } {
23
        upvar name name
24
        unresolved "$name"
25
    }
26
    if { $weak_available != 1 } {
27
        upvar dg-do-what dg-do-what
28
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
29
    }
30
}
31
 
32
# If this target does not support the "visibility" attribute, skip this
33
# test.
34
 
35
proc dg-require-visibility { args } {
36
    set visibility_available [ check_visibility_available [lindex $args 1 ] ]
37
    if { $visibility_available == -1 } {
38
        upvar name name
39
        unresolved "$name"
40
    }
41
    if { $visibility_available != 1 } {
42
        upvar dg-do-what dg-do-what
43
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
44
    }
45
}
46
 
47
# If this target does not support the "alias" attribute, skip this
48
# test.
49
 
50
proc dg-require-alias { args } {
51
    set alias_available [ check_alias_available ]
52
    if { $alias_available == -1 } {
53
        upvar name name
54
        unresolved "$name"
55
    }
56
    if { $alias_available < 2 } {
57
        upvar dg-do-what dg-do-what
58
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
59
    }
60
}
61
 
62
# If this target's linker does not support the --gc-sections flag,
63
# skip this test.
64
 
65
proc dg-require-gc-sections { args } {
66
    if { ![ check_gc_sections_available ] } {
67
        upvar dg-do-what dg-do-what
68
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
69
    }
70
}
71
 
72
# If this target does not support profiling, skip this test.
73
 
74
proc dg-require-profiling { args } {
75
    if { ![ check_profiling_available ${args} ] } {
76
        upvar dg-do-what dg-do-what
77
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
78
    }
79
}
80
 
81
# If this target does not support DLL attributes skip this test.
82
 
83
proc dg-require-dll { args } {
84
    global target_triplet
85
    # As a special case, the mcore-*-elf supports these attributes.
86
    # All Symbian OS targets also support these attributes.
87
    if { [string match "mcore-*-elf" $target_triplet]
88
         || [string match "*-*-symbianelf" $target_triplet]} {
89
        return
90
    }
91
    # PE/COFF targets support dllimport/dllexport.
92
    if { [gcc_target_object_format] == "pe" } {
93
        return
94
    }
95
 
96
    upvar dg-do-what dg-do-what
97
    set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
98
}
99
 
100
proc dg-require-iconv { args } {
101
    if { ![ check_iconv_available ${args} ] } {
102
        upvar dg-do-what dg-do-what
103
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
104
    }
105
}
106
 
107
# If this target does not support named sections skip this test.
108
 
109
proc dg-require-named-sections { args } {
110
    if { ![ check_named_sections_available ] } {
111
        upvar dg-do-what dg-do-what
112
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
113
    }
114
}
115
 
116
# If the target does not match the required effective target, skip this test.
117
 
118
proc dg-require-effective-target { args } {
119
    set args [lreplace $args 0 0]
120
    if { ![is-effective-target [lindex $args 0]] } {
121
        upvar dg-do-what dg-do-what
122
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
123
    }
124
}
125
 
126
# If this target does not have fork, skip this test.
127
 
128
proc dg-require-fork { args } {
129
    if { ![check_fork_available] } {
130
        upvar dg-do-what dg-do-what
131
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
132
    }
133
}
134
 
135
# If this target does not have mkfifo, skip this test.
136
 
137
proc dg-require-mkfifo { args } {
138
    if { ![check_mkfifo_available] } {
139
        upvar dg-do-what dg-do-what
140
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
141
    }
142
}
143
 
144
# If this target does not use __cxa_atexit, skip this test.
145
 
146
proc dg-require-cxa-atexit { args } {
147
    if { ![ check_cxa_atexit_available ] } {
148
        upvar dg-do-what dg-do-what
149
        set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
150
    }
151
}
152
 
153
# Check the flags with which the test will be run against options in
154
# a test directive that will skip or xfail that test.  The DejaGnu proc
155
# check_conditional_xfail will look at the options in compiler_flags, so
156
# set that up for this test based on flags we know about.
157
 
158
proc check_test_flags { args } {
159
    global compiler_flags
160
    upvar 2 dg-extra-tool-flags extra_tool_flags
161
 
162
    # Pull the args out of the enclosing list.
163
    set args [lindex $args 0]
164
 
165
    # Start the list with a dummy tool name so the list will match "*"
166
    # if there are no flags.
167
    set compiler_flags " toolname "
168
    append compiler_flags $extra_tool_flags
169
    set dest [target_info name]
170
    if [board_info $dest exists multilib_flags] {
171
        append compiler_flags "[board_info $dest multilib_flags] "
172
    }
173
 
174
    set answer [check_conditional_xfail $args]
175
 
176
    # Any value in this variable originally was left over from an earlier test.
177
    set compiler_flags ""
178
 
179
    verbose "check_test_flags: $args $answer" 2
180
    return $answer
181
}
182
 
183
# Compare flags for a test directive against flags that will be used to
184
# compile the test: multilib flags, flags for torture options, and either
185
# the default flags for this group of tests or flags specified with a
186
# previous dg-options directive.
187
 
188
proc check-flags { args } {
189
    global compiler_flags
190
    global TOOL_OPTIONS
191
    # These variables are from DejaGnu's dg-test.
192
    upvar dg-extra-tool-flags extra_tool_flags
193
    upvar tool_flags tool_flags
194
 
195
    # The args are within another list; pull them out.
196
    set args [lindex $args 0]
197
 
198
    # Start the list with a dummy tool name so the list will match "*"
199
    # if there are no flags.
200
    set compiler_flags " toolname "
201
    append compiler_flags $extra_tool_flags
202
    append compiler_flags $tool_flags
203
    # If running a subset of the test suite, $TOOL_OPTIONS may not exist.
204
    catch {append compiler_flags " $TOOL_OPTIONS "}
205
    set dest [target_info name]
206
    if [board_info $dest exists multilib_flags] {
207
        append compiler_flags "[board_info $dest multilib_flags] "
208
    }
209
 
210
    # The target list might be an effective-target keyword, so replace
211
    # the original list with "*-*-*", since we already know it matches.
212
    set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
213
 
214
    # Any value in this variable was left over from an earlier test.
215
    set compiler_flags ""
216
 
217
    return $result
218
}
219
 
220
# Skip the test (report it as UNSUPPORTED) if the target list and
221
# included flags are matched and the excluded flags are not matched.
222
#
223
# The first argument is the line number of the dg-skip-if directive
224
# within the test file.   Remaining arguments are as for xfail lists:
225
# message { targets } { include } { exclude }
226
#
227
# This tests against multilib flags plus either the default flags for this
228
# group of tests or flags specified with a previous dg-options command.
229
 
230
proc dg-skip-if { args } {
231
    # Don't bother if we're already skipping the test.
232
    upvar dg-do-what dg-do-what
233
    if { [lindex ${dg-do-what} 1] == "N" } {
234
      return
235
    }
236
 
237
    set args [lreplace $args 0 0]
238
 
239
    set selector [list target [lindex $args 1]]
240
    if { [dg-process-target $selector] == "S" } {
241
        # These are defined in DejaGnu's dg-test, needed by check-flags.
242
        upvar dg-extra-tool-flags dg-extra-tool-flags
243
        upvar tool_flags tool_flags
244
 
245
        if [check-flags $args] {
246
            upvar dg-do-what dg-do-what
247
            set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
248
        }
249
    }
250
}
251
 
252
# Like check_conditional_xfail, but callable from a dg test.
253
 
254
proc dg-xfail-if { args } {
255
    # Don't change anything if we're already skipping the test.
256
    upvar dg-do-what dg-do-what
257
    if { [lindex ${dg-do-what} 1] == "N" } {
258
      return
259
    }
260
 
261
    set args [lreplace $args 0 0]
262
    set selector [list target [lindex $args 1]]
263
    if { [dg-process-target $selector] == "S" } {
264
        global compiler_conditional_xfail_data
265
        set compiler_conditional_xfail_data [lreplace $args 1 1 "*-*-*"]
266
    }
267
}
268
 
269
# Record whether the program is expected to return a nonzero status.
270
 
271
set shouldfail 0
272
 
273
proc dg-shouldfail { args } {
274
    # Don't bother if we're already skipping the test.
275
    upvar dg-do-what dg-do-what
276
    if { [lindex ${dg-do-what} 1] == "N" } {
277
      return
278
    }
279
 
280
    global shouldfail
281
 
282
    set args [lreplace $args 0 0]
283
    if { [llength $args] > 1 } {
284
        set selector [list target [lindex $args 1]]
285
        if { [dg-process-target $selector] == "S" } {
286
            # The target matches, now check the flags.  These variables
287
            # are defined in DejaGnu's dg-test, needed by check-flags.
288
            upvar dg-extra-tool-flags dg-extra-tool-flags
289
            upvar tool_flags tool_flags
290
 
291
            if [check-flags $args] {
292
                set shouldfail 1
293
            }
294
        }
295
    } else {
296
        set shouldfail 1
297
    }
298
}
299
 
300
# Intercept the call to the DejaGnu version of dg-process-target to
301
# support use of an effective-target keyword in place of a list of
302
# target triplets to xfail or skip a test.
303
#
304
# selector is one of:
305
#    xfail target-triplet-1 ...
306
#    xfail effective-target-keyword
307
#    xfail selector-expression
308
#    target target-triplet-1 ...
309
#    target effective-target-keyword
310
#    target selector-expression
311
#
312
# For a target list the result is "S" if the target is selected, "N" otherwise.
313
# For an xfail list the result is "F" if the target is affected, "P" otherwise.
314
#
315
# A selector expression appears within curly braces and uses a single logical
316
# operator: !, &&, or ||.  An operand is another selector expression, an
317
# effective-target keyword, or a list of target triplets within quotes or
318
# curly braces.
319
 
320
if { [info procs saved-dg-process-target] == [list] } {
321
    rename dg-process-target saved-dg-process-target
322
 
323
    # Evaluate an operand within a selector expression.
324
    proc selector_opd { op } {
325
        set selector "target"
326
        lappend selector $op
327
        set answer [ expr { [dg-process-target $selector] == "S" } ]
328
        verbose "selector_opd: `$op' $answer" 2
329
        return $answer
330
    }
331
 
332
    # Evaluate a target triplet list within a selector expression.
333
    # Unlike other operands, this needs to be expanded from a list to
334
    # the same string as "target".
335
    proc selector_list { op } {
336
        set selector "target [join $op]"
337
        set answer [ expr { [dg-process-target $selector] == "S" } ]
338
        verbose "selector_list: `$op' $answer" 2
339
        return $answer
340
    }
341
 
342
    # Evaluate a selector expression.
343
    proc selector_expression { exp } {
344
        if { [llength $exp] == 2 } {
345
            if [string match "!" [lindex $exp 0]] {
346
                set op1 [lindex $exp 1]
347
                set answer [expr { ! [selector_opd $op1] }]
348
            } else {
349
                # Assume it's a list of target triplets.
350
                set answer [selector_list $exp]
351
            }
352
        } elseif { [llength $exp] == 3 } {
353
            set op1 [lindex $exp 0]
354
            set opr [lindex $exp 1]
355
            set op2 [lindex $exp 2]
356
            if [string match "&&" $opr] {
357
                set answer [expr { [selector_opd $op1] && [selector_opd $op2] }]
358
            } elseif [string match "||" $opr] {
359
                set answer [expr { [selector_opd $op1] || [selector_opd $op2] }]
360
            } else {
361
                # Assume it's a list of target triplets.
362
                set answer [selector_list $exp]
363
            }
364
        } else {
365
            # Assume it's a list of target triplets.
366
            set answer [selector_list $exp]
367
        }
368
 
369
        verbose "selector_expression: `$exp' $answer" 2
370
        return $answer
371
    }
372
 
373
    proc dg-process-target { args } {
374
        verbose "replacement dg-process-target: `$args'" 2
375
 
376
        # Extract the 'what' keyword from the argument list.
377
        set selector [string trim [lindex $args 0]]
378
        if [regexp "^xfail " $selector] {
379
            set what "xfail"
380
        } elseif [regexp "^target " $selector] {
381
            set what "target"
382
        } else {
383
            error "syntax error in target selector \"$selector\""
384
        }
385
 
386
        # Extract the rest of the list, which might be a keyword.
387
        regsub "^${what}" $selector "" rest
388
        set rest [string trim $rest]
389
 
390
        if [is-effective-target-keyword $rest] {
391
            # The selector is an effective target keyword.
392
            if [is-effective-target $rest] {
393
                return [expr { $what == "xfail" ? "F" : "S" }]
394
            } else {
395
                return [expr { $what == "xfail" ? "P" : "N" }]
396
            }
397
        }
398
 
399
        if [string match "{*}" $rest] {
400
            if [selector_expression [lindex $rest 0]] {
401
                return [expr { $what == "xfail" ? "F" : "S" }]
402
            } else {
403
                return [expr { $what == "xfail" ? "P" : "N" }]
404
            }
405
        }
406
 
407
        # The selector is not an effective-target keyword, so process
408
        # the list of target triplets.
409
        return [saved-dg-process-target $selector]
410
    }
411
}

powered by: WebSVN 2.1.0

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