1 # This testcase is part of GDB, the GNU debugger.
3 # Copyright 1996, 1997, 1999, 2003, 2004, 2007, 2008
4 # Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
26 # Some targets can't call functions, so don't even bother with this
29 if [target_info exists gdb,cannot_call_functions] {
31 fail "This target can not call functions"
35 set testfile "structs"
36 set srcfile ${testfile}.c
37 set binfile ${objdir}/${subdir}/${testfile}
39 # Create and source the file that provides information about the
40 # compiler used to compile the test case.
42 if [get_compiler_info ${binfile}] {
46 # Compile a variant of structs.c using TYPES to specify the type of
47 # the first N struct elements (the remaining elements take the type of
48 # the last TYPES field). Run the compmiled program up to "main".
49 # Also updates the global "testfile" to reflect the most recent build.
51 proc start_structs_test { types } {
60 # Create the additional flags
62 set testfile "structs"
64 for {set n 0} {$n<[llength ${types}]} {incr n} {
66 set t [lindex ${types} $n]
67 lappend flags "additional_flags=-Dt${m}=${t}"
68 append testfile "-" "$t"
71 set binfile ${objdir}/${subdir}/${testfile}
72 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags}"] != "" } {
73 # built the second test case since we can't use prototypes
74 warning "Prototypes not supported, rebuilding with -DNO_PROTOTYPES"
75 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "${flags} additional_flags=-DNO_PROTOTYPES"] != "" } {
81 # Start with a fresh gdb.
84 gdb_reinitialize_dir $srcdir/$subdir
87 # Make certain that the output is consistent
88 gdb_test "set print sevenbit-strings" "" \
89 "set print sevenbit-strings; ${testfile}"
90 gdb_test "set print address off" "" \
91 "set print address off; ${testfile}"
92 gdb_test "set width 0" "" \
93 "set width 0; ${testfile}"
96 if { ![runto_main] } then {
100 # Get the debug format
103 # check that at the struct containing all the relevant types is correct
104 set foo_t "type = struct struct[llength ${types}] \{"
105 for {set n 0} {$n<[llength ${types}]} {incr n} {
106 append foo_t "\[\r\n \]+[lindex ${types} $n] [i2a $n];"
108 append foo_t "\[\r\n \]+\}"
109 gdb_test "ptype foo[llength ${types}]" "${foo_t}" \
110 "ptype foo[llength ${types}]; ${testfile}"
113 # The expected value for fun${n}, L${n} and foo${n}. First element is
114 # empty to make indexing easier. "foo" returns the modified value,
115 # "zed" returns the invalid value.
121 "{a = 97 'a', b = 50 '2'}"
122 "{a = 49 '1', b = 98 'b', c = 51 '3'}"
123 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4'}"
124 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5'}"
125 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6'}"
126 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7'}"
127 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8'}"
128 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9'}"
129 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A'}"
130 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B'}"
131 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C'}"
132 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D'}"
133 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E'}"
134 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F'}"
135 "{a = 97 'a', b = 50 '2', c = 99 'c', d = 52 '4', e = 101 'e', f = 54 '6', g = 103 'g', h = 56 '8', i = 105 'i', j = 65 'A', k = 107 'k', l = 67 'C', m = 109 'm', n = 69 'E', o = 111 'o', p = 71 'G'}"
136 "{a = 49 '1', b = 98 'b', c = 51 '3', d = 100 'd', e = 53 '5', f = 102 'f', g = 55 '7', h = 104 'h', i = 57 '9', j = 106 'j', k = 66 'B', l = 108 'l', m = 68 'D', n = 110 'n', o = 70 'F', p = 112 'p', q = 72 'H'}"
144 "{a = 90 'Z', b = 90 'Z'}"
145 "{a = 90 'Z', b = 90 'Z', c = 90 'Z'}"
146 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z'}"
147 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z'}"
148 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z'}"
149 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z'}"
150 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z'}"
151 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z'}"
152 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z'}"
153 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z'}"
154 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z'}"
155 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z'}"
156 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z'}"
157 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z'}"
158 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z'}"
159 "{a = 90 'Z', b = 90 'Z', c = 90 'Z', d = 90 'Z', e = 90 'Z', f = 90 'Z', g = 90 'Z', h = 90 'Z', i = 90 'Z', j = 90 'Z', k = 90 'Z', l = 90 'Z', m = 90 'Z', n = 90 'Z', o = 90 'Z', p = 90 'Z', q = 90 'Z'}"
167 "{a = \[^,\}\]*, b = \[^,\}\]*}"
168 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*}"
169 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*}"
170 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*}"
171 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*}"
172 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*}"
173 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*}"
174 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*}"
175 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*}"
176 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*}"
177 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*}"
178 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*}"
179 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*}"
180 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*}"
181 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*}"
182 "{a = \[^,\}\]*, b = \[^,\}\]*, c = \[^,\}\]*, d = \[^,\}\]*, e = \[^,\}\]*, f = \[^,\}\]*, g = \[^,\}\]*, h = \[^,\}\]*, i = \[^,\}\]*, j = \[^,\}\]*, k = \[^,\}\]*, l = \[^,\}\]*, m = \[^,\}\]*, n = \[^,\}\]*, o = \[^,\}\]*, p = \[^,\}\]*, q = \[^,\}\]*}"
186 # Given N (0..25), return the corresponding alphabetic letter in lower
187 # or upper case. This is ment to be i18n proof.
190 return [string range "abcdefghijklmnopqrstuvwxyz" $n $n]
194 return [string toupper [i2a $n]]
198 # Use the file name, compiler and tuples to set up any needed KFAILs.
200 proc setup_kfails { file tuples bug } {
202 if [string match $file $testfile] {
203 foreach f $tuples { setup_kfail $f $bug }
207 proc setup_compiler_kfails { file compiler format tuples bug } {
209 if {[string match $file $testfile] && [test_compiler_info $compiler] && [test_debug_format $format]} {
210 foreach f $tuples { setup_kfail $f $bug }
214 # Test GDB's ability to make inferior function calls to functions
215 # returning (or passing in a single structs.
217 # N identifies the number of elements in the struct that will be used
218 # for the test case. FAILS is a list of target tuples that will fail
221 # start_structs_test() will have previously built a program with a
222 # specified combination of types for those elements. To ensure
223 # robustness of the output, "p/c" is used.
225 # This tests the code paths "which return-value convention?" and
226 # "extract return-value from registers" called by "infcall.c".
228 proc test_struct_calls { n } {
232 # Check that GDB can always extract a struct-return value from an
233 # inferior function call. Since GDB always knows the location of an
234 # inferior function call's return value these should never fail
236 # Implemented by calling the parameterless function "fun$N" and then
237 # examining the return value printed by GDB.
239 set tests "call $n ${testfile}"
241 # Call fun${n}, checking the printed return-value.
242 setup_compiler_kfails structs-tc-tll gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
243 setup_compiler_kfails structs-tc-td gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
244 gdb_test "p/c fun${n}()" "[foo ${n}]" "p/c fun<n>(); ${tests}"
246 # Check that GDB can always pass a structure to an inferior function.
247 # This test can never fail.
249 # Implemented by calling the one parameter function "Fun$N" which
250 # stores its parameter in the global variable "L$N". GDB then
251 # examining that global to confirm that the value is as expected.
253 gdb_test "call Fun${n}(foo${n})" "" "call Fun<n>(foo<n>); ${tests}"
254 setup_compiler_kfails structs-tc-tll gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
255 setup_compiler_kfails structs-tc-td gcc-3-3-* "DWARF 2" i*86-*-* gdb/1455
256 gdb_test "p/c L${n}" [foo ${n}] "p/c L<n>; ${tests}"
259 # Test GDB's ability to both return a function (with "return" or
260 # "finish") and correctly extract/store any corresponding
263 # Check that GDB can consistently extract/store structure return
264 # values. There are two cases - returned in registers and returned in
265 # memory. For the latter case, the return value can't be found and a
266 # failure is "expected". However GDB must still both return the
267 # function and display the final source and line information.
269 # N identifies the number of elements in the struct that will be used
270 # for the test case. FAILS is a list of target tuples that will fail
273 # This tests the code paths "which return-value convention?", "extract
274 # return-value from registers", and "store return-value in registers".
275 # Unlike "test struct calls", this test is expected to "fail" when the
276 # return-value is in memory (GDB can't find the location). The test
277 # is in three parts: test "return"; test "finish"; check that the two
278 # are consistent. GDB can sometimes work for one command and not the
281 proc test_struct_returns { n } {
285 set tests "return $n ${testfile}"
288 # Check that "return" works.
290 # GDB must always force the return of a function that has
291 # a struct result. Dependant on the ABI, it may, or may not be
292 # possible to store the return value in a register.
294 # The relevant code looks like "L{n} = fun{n}()". The test forces
295 # "fun{n}" to "return" with an explicit value. Since that code
296 # snippet will store the the returned value in "L{n}" the return
297 # is tested by examining "L{n}". This assumes that the
298 # compiler implemented this as fun{n}(&L{n}) and hence that when
299 # the value isn't stored "L{n}" remains unchanged. Also check for
300 # consistency between this and the "finish" case.
302 # Get into a call of fun${n}
303 gdb_test "advance fun${n}" \
304 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
305 "advance to fun<n> for return; ${tests}"
307 # Check that the program invalidated the relevant global.
308 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for return; ${tests}"
310 # Force the "return". This checks that the return is always
311 # performed, and that GDB correctly reported this to the user.
312 # GDB 6.0 and earlier, when the return-value's location wasn't
313 # known, both failed to print a final "source and line" and misplaced
314 # the frame ("No frame").
316 # The test is writen so that it only reports one FAIL/PASS for the
317 # entire operation. The value returned is checked further down.
318 # "return_value_known", if non-zero, indicates that GDB knew where
319 # the return value was located.
321 set test "return foo<n>; ${tests}"
322 set return_value_known 1
323 set return_value_unimplemented 0
324 gdb_test_multiple "return foo${n}" "${test}" {
326 # Ulgh, a struct return, remember this (still need prompt).
327 set return_value_known 0
330 -re "A structure or union" {
331 # Ulgh, a struct return, remember this (still need prompt).
332 set return_value_known 0
333 # Double ulgh. Architecture doesn't use return_value and
334 # hence hasn't implemented small structure return.
335 set return_value_unimplemented 1
338 -re "Make fun${n} return now.*y or n. $" {
339 gdb_test_multiple "y" "${test}" {
340 -re "L${n} *= fun${n}.*${gdb_prompt} $" {
341 # Need to step off the function call
342 gdb_test "next" "L.* *= fun.*" "${test}"
344 -re "L[expr ${n} + 1] *= fun[expr ${n} + 1].*${gdb_prompt} $" {
351 # Check that the return-value is as expected. At this stage we're
352 # just checking that GDB has returned a value consistent with
353 # "return_value_known" set above.
355 # Note that, when return_value_known is false, we can't make any
356 # assumptions at all about the value L<n>:
358 # - If the caller passed the address of L<n> directly as fun<n>'s
359 # return value buffer, then L<n> will be unchanged, because we
360 # forced fun<n> to return before it could store anything in it.
362 # - If the caller passed the address of some temporary buffer to
363 # fun<n>, and then copied the buffer into L<n>, then L<n> will
364 # have been overwritten with whatever garbage was in the
365 # uninitialized buffer.
367 # - However, if the temporary buffer just happened to have the
368 # "right" value of foo<n> in it, then L<n> will, in fact, have
369 # the value you'd expect to see if the 'return' had worked!
370 # This has actually been observed to happen on the Renesas M32C.
372 # So, really, anything is acceptable unless return_value_known is
375 set test "value foo<n> returned; ${tests}"
376 gdb_test_multiple "p/c L${n}" "${test}" {
377 -re " = [foo ${n}].*${gdb_prompt} $" {
378 # This answer is okay regardless of whether GDB claims to
379 # have set the return value: if it did, then this is what
380 # we expected; and if it didn't, then any answer is okay.
383 -re " = [any $n].*${gdb_prompt} $" {
384 if $return_value_known {
385 # This contradicts the above claim that GDB knew
386 # the location of the return value.
389 # We expected L${n} to be set to garbage, so any
390 # answer is acceptable.
394 -re ".*${gdb_prompt} $" {
395 if $return_value_unimplemented {
396 # What a suprize. The architecture hasn't implemented
397 # return_value, and hence has to fail.
398 kfail "$test" gdb/1444
405 # Check that a "finish" works.
407 # This is almost but not quite the same as "call struct funcs".
408 # Architectures can have subtle differences in the two code paths.
410 # The relevant code snippet is "L{n} = fun{n}()". The program is
411 # advanced into a call to "fun{n}" and then that function is
412 # finished. The returned value that GDB prints, reformatted using
415 # Get into "fun${n}()".
416 gdb_test "advance fun${n}" \
417 "fun${n} .*\[\r\n\]+\[0-9\].*return foo${n}.*" \
418 "advance to fun<n> for finish; ${tests}"
420 # Check that the program invalidated the relevant global.
421 gdb_test "p/c L${n}" " = [zed $n]" "zed L<n> for finish; ${tests}"
423 # Finish the function, set 'finish_value_known" to non-empty if
424 # the return-value was found.
426 set test "finish foo<n>; ${tests}"
427 set finish_value_known 1
428 gdb_test_multiple "finish" "${test}" {
429 -re "Value returned is .*${gdb_prompt} $" {
432 -re "Cannot determine contents.*${gdb_prompt} $" {
433 # Expected bad value. For the moment this is ok.
434 set finish_value_known 0
439 # Re-print the last (return-value) using the more robust
440 # "p/c". If no return value was found, the 'Z' from the previous
441 # check that the variable was cleared, is printed.
442 set test "value foo<n> finished; ${tests}"
443 gdb_test_multiple "p/c" "${test}" {
444 -re "[foo ${n}]\[\r\n\]+${gdb_prompt} $" {
445 if $finish_value_known {
448 # This contradicts the above claim that GDB didn't
449 # know the location of the return-value.
453 -re "[zed ${n}]\[\r\n\]+${gdb_prompt} $" {
454 # The value didn't get found. This is "expected".
455 if $finish_value_known {
456 # This contradicts the above claim that GDB did
457 # know the location of the return-value.
465 # Finally, check that "return" and finish" have consistent
468 # Since "finish" works in more cases than "return" (see
469 # RETURN_VALUE_ABI_RETURNS_ADDRESS and
470 # RETURN_VALUE_ABI_PRESERVES_ADDRESS), the "return" value being
471 # known implies that the "finish" value is known (but not the
474 set test "return value known implies finish value known; ${tests}"
475 if {$return_value_known && ! $finish_value_known} {
476 kfail gdb/1444 "${test}"
482 # ABIs pass anything >8 or >16 bytes in memory but below that things
483 # randomly use register and/and structure conventions. Check all
484 # possible sized char structs in that range. But only a restricted
485 # range of the other types.
487 # NetBSD/PPC returns "unnatural" (3, 5, 6, 7) sized structs in memory.
489 # d10v is weird. 5/6 byte structs go in memory. 2 or more char
490 # structs go in memory. Everything else is in a register!
492 # Test every single char struct from 1..17 in size. This is what the
493 # original "structs" test was doing.
495 start_structs_test { tc }
513 test_struct_returns 1
514 test_struct_returns 2
515 test_struct_returns 3
516 test_struct_returns 4
517 test_struct_returns 5
518 test_struct_returns 6
519 test_struct_returns 7
520 test_struct_returns 8
525 # Assuming that any integer struct larger than 8 bytes goes in memory,
526 # come up with many and varied combinations of a return struct. For
527 # "struct calls" test just beyond that 8 byte boundary, for "struct
528 # returns" test up to that boundary.
530 # For floats, assumed that up to two struct elements can be stored in
531 # floating point registers, regardless of their size.
533 # The approx size of each structure it is computed assumed that tc=1,
534 # ts=2, ti=4, tl=4, tll=8, tf=4, td=8, tld=16, and that all fields are
535 # naturally aligned. Padding being added where needed. Note that
536 # these numbers are just approx, the d10v has ti=2, a 64-bit has has
539 # Approx size: 2, 4, ...
540 start_structs_test { ts }
546 test_struct_returns 1
547 test_struct_returns 2
548 test_struct_returns 3
549 test_struct_returns 4
551 # Approx size: 4, 8, ...
552 start_structs_test { ti }
556 test_struct_returns 1
557 test_struct_returns 2
559 # Approx size: 4, 8, ...
560 start_structs_test { tl }
564 test_struct_returns 1
565 test_struct_returns 2
567 # Approx size: 8, 16, ...
568 start_structs_test { tll }
571 test_struct_returns 1
573 # Approx size: 4, 8, ...
574 start_structs_test { tf }
578 test_struct_returns 1
579 test_struct_returns 2
581 # Approx size: 8, 16, ...
582 start_structs_test { td }
585 test_struct_returns 1
587 # Approx size: 16, 32, ...
588 start_structs_test { tld }
591 test_struct_returns 1
593 # Approx size: 2+1=3, 4, ...
594 start_structs_test { ts tc }
602 test_struct_returns 2
604 # Approx size: 4+1=5, 6, ...
605 start_structs_test { ti tc }
611 test_struct_returns 2
613 # Approx size: 4+1=5, 6, ...
614 start_structs_test { tl tc }
620 test_struct_returns 2
622 # Approx size: 8+1=9, 10, ...
623 start_structs_test { tll tc }
626 # Approx size: 4+1=5, 6, ...
627 start_structs_test { tf tc }
633 test_struct_returns 2
635 # Approx size: 8+1=9, 10, ...
636 start_structs_test { td tc }
639 # Approx size: 16+1=17, 18, ...
640 start_structs_test { tld tc }
643 # Approx size: (1+1)+2=4, 6, ...
644 start_structs_test { tc ts }
650 test_struct_returns 2
652 # Approx size: (1+3)+4=8, 12, ...
653 start_structs_test { tc ti }
657 test_struct_returns 2
659 # Approx size: (1+3)+4=8, 12, ...
660 start_structs_test { tc tl }
664 test_struct_returns 2
666 # Approx size: (1+7)+8=16, 24, ...
667 start_structs_test { tc tll }
670 # Approx size: (1+3)+4=8, 12, ...
671 start_structs_test { tc tf }
676 # Approx size: (1+7)+8=16, 24, ...
677 start_structs_test { tc td }
680 # Approx size: (1+15)+16=32, 48, ...
681 start_structs_test { tc tld }
684 # Some float combinations
686 # Approx size: 8+4=12, 16, ...
687 # d10v: 4+4=8, 12, ...
688 start_structs_test { td tf }
690 test_struct_returns 2
692 # Approx size: (4+4)+8=16, 32, ...
693 # d10v: 4+4=8, 12, ...
694 start_structs_test { tf td }
696 test_struct_returns 2