Refactor ppc64 function call and return value handling
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 4 Feb 2014 17:24:42 +0000 (18:24 +0100)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Tue, 4 Feb 2014 17:24:42 +0000 (18:24 +0100)
commite765b44c3853ed228506fc22c276becd63198238
treea9337653355c191123bda1f93b5f7caa7d961f27
parent36c24d95382572e9cf4095712a8613664d7165cc
Refactor ppc64 function call and return value handling

This patch refactors the ppc64 function call and return value handling code
in ppc-sysv-tdep.c.  The main problem to be addressed by this refactoring
is the code duplication caused by certain aggregate types:

According to the ABI, some types are to be decomposed into component types
for parameter and return value handling.  For example, complex types are
to be passed as if the real and imaginary component were separate arguments.
Similarly, certain OpenCL vector types are passed as if they were multiple
separate arguments of the vector element type.  With the new ELFv2 ABI,
there is another case: "homogeneous aggregates" (e.g. a struct containing
4 floats) are passed in multiple floating point registers as well.

Unfortunately, the current code is not structured to easily model these
ABI properties.  For example, code to pass complex values re-implements
code to pass the underlying (floating-point) type.  This has already
led to some unfortunate code duplication, and with the addition of
ELFv2 ABI support, I would have had to add yet more such duplication.

To avoid that, I've decided to refactor the code in order to re-use
subroutines that handle the "base" types when handling those aggregate
types.  This was not intended to cause any difference on current
(ELFv1) ABI code, but in fact it fixes a bug:

FAIL: gdb.base/varargs.exp: print find_max_float_real(4, fc1, fc2, fc3, fc4)

This was caused by the old code in ppc64_sysv_abi_push_float incorrectly
handling floating-point arguments to vararg routines, which just happens
to work out correctly automatically in the refactored code ...

gdb/ChangeLog:

* ppc-sysv-tdep.c (get_decimal_float_return_value): Update comment.
(struct ppc64_sysv_argpos): New data structure.
(ppc64_sysv_abi_push_float): Remove.
(ppc64_sysv_abi_push_val): New function.
(ppc64_sysv_abi_push_integer): Likewise.
(ppc64_sysv_abi_push_freg): Likewise.
(ppc64_sysv_abi_push_vreg): Likewise.
(ppc64_sysv_abi_push_param): Likewise.
(ppc64_sysv_abi_push_dummy_call): Refactor to use those new routines.
(ppc64_sysv_abi_return_value_base): New function.
(ppc64_sysv_abi_return_value): Refactor to use it.
gdb/ChangeLog
gdb/ppc-sysv-tdep.c
This page took 0.025695 seconds and 4 git commands to generate.