This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix passing double float complex arguments in sparc64
- From: jose dot marchesi at oracle dot com (Jose E. Marchesi)
- To: Mark Kettenis <mark dot kettenis at xs4all dot nl>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 11 Dec 2013 15:11:43 +0100
- Subject: Re: [PATCH] Fix passing double float complex arguments in sparc64
- Authentication-results: sourceware.org; auth=none
- References: <87ob6qo7bs dot fsf at oracle dot com> <201310231958 dot r9NJwEje005359 at glazunov dot sibelius dot xs4all dot nl> <878uvsv8xl dot fsf at oracle dot com> <87haaffu2j dot fsf at oracle dot com>
> 2013-10-15 Jose E. Marchesi <jose.marchesi@oracle.com>
>
> * sparc64-tdep.c (sparc64_store_arguments): Do not align complex
> double float arguments to 16-byte.
Hi Jose,
A bit of digging around seems to confirm that we shouldn't align
double complex variables. However, I think that with your diff we're
still not storing things in the right registers.
Aye. Fixed in the amended patch below.
Argh, I forgot to fix the case where the argument is promoted to a %o
register. Fixed below. Now it works in all cases: normal function with
prototype available (args in %f registers), normal function with
prototype not available (args in both %f and %o registers) and vararg
function (args in %o registers).
Today I found a typo in the patch that made gdb.base/funcargs.exp to
fail. Fixed below (checking for regnum < SPARC64_D30_REGNUM).
2013-10-15 Jose E. Marchesi <jose.marchesi@oracle.com>
* sparc64-tdep.c (sparc64_store_arguments): Do not align complex
double float arguments to 16-byte in the argument slots.
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 8bcf418..246b7d1 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -831,7 +831,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
quad-aligned, and thus a hole might be introduced
into the parameter array to force alignment." Skip
an element if necessary. */
- if (num_elements % 2)
+ if ((num_elements % 2) && sparc64_16_byte_align_p (type))
num_elements++;
}
else
@@ -890,7 +890,7 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
if (sparc64_structure_or_union_p (type)
|| (sparc64_complex_floating_p (type) && len == 32))
{
- /* Structure or Union arguments. */
+ /* Structure, Union or long double Complex arguments. */
gdb_assert (len <= 16);
memset (buf, 0, sizeof (buf));
valbuf = memcpy (buf, valbuf, len);
@@ -908,7 +908,13 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
if (element < 16)
sparc64_store_floating_fields (regcache, type, valbuf, element, 0);
}
- else if (sparc64_floating_p (type) || sparc64_complex_floating_p (type))
+ else if (sparc64_complex_floating_p (type))
+ {
+ /* Float Complex or double Complex arguments. */
+ if (element < 16)
+ regnum = SPARC64_D0_REGNUM + element;
+ }
+ else if (sparc64_floating_p (type))
{
/* Floating arguments. */
if (len == 16)
@@ -950,14 +956,23 @@ sparc64_store_arguments (struct regcache *regcache, int nargs,
if (regnum != -1)
{
regcache_cooked_write (regcache, regnum, valbuf);
+ if (sparc64_complex_floating_p (type)
+ && (len == 16)
+ && (regnum < SPARC64_D30_REGNUM))
+ regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
/* If we're storing the value in a floating-point register,
also store it in the corresponding %0 register(s). */
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D10_REGNUM)
{
+ int dregnum = regnum;
gdb_assert (element < 6);
regnum = SPARC_O0_REGNUM + element;
regcache_cooked_write (regcache, regnum, valbuf);
+ if (sparc64_complex_floating_p (type)
+ && (len == 16)
+ && (dregnum < SPARC64_D10_REGNUM))
+ regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
}
else if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q8_REGNUM)
{