]> git.ipfire.org Git - thirdparty/elfutils.git/commit
riscv: Partial implementation of flatten_aggregate
authorMark Wielaard <mark@klomp.org>
Tue, 19 Mar 2024 22:43:10 +0000 (22:43 +0000)
committerMark Wielaard <mark@klomp.org>
Wed, 20 Mar 2024 19:36:51 +0000 (20:36 +0100)
commit669b648111d3bc27cd4756879f5fe5a18515de77
tree14ae8f7d6e5546f525cb224c258d265af53a1011
parentef8a4b841aaf26326b8961a651dbe915d54d23e7
riscv: Partial implementation of flatten_aggregate

dwfl_module_return_value_location would fail on riscv for functions
which return a (small) struct. This patch implements the simplest
cases of flatten_aggregate in backends/riscv_retval.c. It just handles
structs containing one or two members of the same base type which fit
completely or in pieces in one or two general or floating point
registers.

It also adds a specific test case run-funcretval-struct.sh containing
small structs of ints, longs, floats and doubles. All these testscases
now work for riscv. There is already a slightly more extensive
testcase for this in tests/run-funcretval.sh but that only has a
testcase for aarch64.

 * backends/riscv_retval.c (flatten_aggregate_arg): Implement
         for the simple cases where we have a struct with one or two
         members of the same base type.
 (pass_by_flattened_arg): Likewise. Call either
 pass_in_gpr_lp64 or pass_in_fpr_lp64d.
 (riscv_return_value_location_lp64ifd): Call
 flatten_aggregate_arg including size.
 * tests/Makefile.am (TESTS): Add run-funcretval-struct.sh
 and run-funcretval-struct-native.sh.
 (check_PROGRAMS): Add funcretval_test_struct.
 (funcretval_test_struct_SOURCES): New.
 (EXTRA_DIST): Add run-funcretval-struct.sh,
 funcretval_test_struct_riscv.bz2 and
 run-funcretval-struct-native.sh.
 * tests/funcretval_test_struct_riscv.bz2: New test binary.
 * tests/run-funcretval-struct-native.sh: New test.
 * tests/run-funcretval-struct.sh: Likewise.

https://sourceware.org/bugzilla/show_bug.cgi?id=31142

Signed-off-by: Mark Wielaard <mark@klomp.org>
backends/riscv_retval.c
tests/Makefile.am
tests/funcretval_test_struct.c [new file with mode: 0644]
tests/funcretval_test_struct_riscv.bz2 [new file with mode: 0755]
tests/run-funcretval-struct-native.sh [new file with mode: 0755]
tests/run-funcretval-struct.sh [new file with mode: 0755]