public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix passing double float complex arguments in sparc64
@ 2013-10-15 15:55 Jose E. Marchesi
  2013-10-23 19:58 ` Mark Kettenis
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2013-10-15 15:55 UTC (permalink / raw)
  To: gdb-patches


Hi.

Double float complex objects are not 16-byte aligned in either gcc or
solaris studio.  This patch makes gdb to not align double float complex
arguments in the dummy frame when calling a function.

This makes all the tests in gdb.base/varargs.exp to pass in
sparc64-*-linux-gnu.

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.

Index: sparc64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v
retrieving revision 1.62
diff -u -r1.62 sparc64-tdep.c
--- sparc64-tdep.c	1 Jan 2013 06:32:51 -0000	1.62
+++ sparc64-tdep.c	15 Oct 2013 15:46:25 -0000
@@ -831,7 +831,7 @@
                  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
@@ -913,7 +913,7 @@
 	  /* Floating arguments.  */
 	  if (len == 16)
 	    {
-	      if (element % 2)
+	      if ((element % 2) && sparc64_16_byte_align_p (type))
 		element++;
 	      if (element < 16)
 		regnum = SPARC64_Q0_REGNUM + element / 2;
@@ -961,7 +961,7 @@
 	    }
 	  else if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q8_REGNUM)
 	    {
-	      gdb_assert (element < 5);
+	      gdb_assert (element < 6);
 	      regnum = SPARC_O0_REGNUM + element;
 	      regcache_cooked_write (regcache, regnum, valbuf);
 	      regcache_cooked_write (regcache, regnum + 1, valbuf + 8);

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2013-10-15 15:55 [PATCH] Fix passing double float complex arguments in sparc64 Jose E. Marchesi
@ 2013-10-23 19:58 ` Mark Kettenis
  2013-12-10 18:46   ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Mark Kettenis @ 2013-10-23 19:58 UTC (permalink / raw)
  To: jose.marchesi; +Cc: gdb-patches

> From: jose.marchesi@oracle.com (Jose E. Marchesi)
> Date: Tue, 15 Oct 2013 17:57:27 +0200
> 
> Hi.
> 
> Double float complex objects are not 16-byte aligned in either gcc or
> solaris studio.  This patch makes gdb to not align double float complex
> arguments in the dummy frame when calling a function.
> 
> This makes all the tests in gdb.base/varargs.exp to pass in
> sparc64-*-linux-gnu.
> 
> 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.

Mark

> Index: sparc64-tdep.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/sparc64-tdep.c,v
> retrieving revision 1.62
> diff -u -r1.62 sparc64-tdep.c
> --- sparc64-tdep.c	1 Jan 2013 06:32:51 -0000	1.62
> +++ sparc64-tdep.c	15 Oct 2013 15:46:25 -0000
> @@ -831,7 +831,7 @@
>                   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
> @@ -913,7 +913,7 @@
>  	  /* Floating arguments.  */
>  	  if (len == 16)
>  	    {
> -	      if (element % 2)
> +	      if ((element % 2) && sparc64_16_byte_align_p (type))
>  		element++;
>  	      if (element < 16)
>  		regnum = SPARC64_Q0_REGNUM + element / 2;
> @@ -961,7 +961,7 @@
>  	    }
>  	  else if (regnum >= SPARC64_Q0_REGNUM && regnum <= SPARC64_Q8_REGNUM)
>  	    {
> -	      gdb_assert (element < 5);
> +	      gdb_assert (element < 6);
>  	      regnum = SPARC_O0_REGNUM + element;
>  	      regcache_cooked_write (regcache, regnum, valbuf);
>  	      regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2013-10-23 19:58 ` Mark Kettenis
@ 2013-12-10 18:46   ` Jose E. Marchesi
  2013-12-11 12:29     ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2013-12-10 18:46 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches


    > 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.

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..9767bbe 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,6 +956,10 @@ 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_D10_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).  */

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2013-12-10 18:46   ` Jose E. Marchesi
@ 2013-12-11 12:29     ` Jose E. Marchesi
  2013-12-11 14:09       ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2013-12-11 12:29 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches


        > 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).

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_D10_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)
 	    {

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2013-12-11 12:29     ` Jose E. Marchesi
@ 2013-12-11 14:09       ` Jose E. Marchesi
  0 siblings, 0 replies; 11+ messages in thread
From: Jose E. Marchesi @ 2013-12-11 14:09 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches


            > 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)
 	    {

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2014-02-11  4:45       ` Joel Brobecker
@ 2014-02-11 12:39         ` Jose E. Marchesi
  0 siblings, 0 replies; 11+ messages in thread
From: Jose E. Marchesi @ 2014-02-11 12:39 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches


    > n2013-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.
    
    The patch is OK. Watch out for the 'n' at the start of the date in
    this ChangeLog entry.

Committed.  Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2014-02-10 13:22     ` Jose E. Marchesi
@ 2014-02-11  4:45       ` Joel Brobecker
  2014-02-11 12:39         ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2014-02-11  4:45 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gdb-patches

> Somehow I missed the fact that for big structs and unions the writing of
> the "additional" register is performed immediately after setting regnum.
> A bit confusing, but that avoids repeated logic in the `if (regnum !=
> 1)' block, so I agree it is a better solution.

Thank you. I don't think one way is all that better than the other
(I actually find this way a little confusing at first), but I prefer
that everything remains consistent...

> n2013-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.

The patch is OK. Watch out for the 'n' at the start of the date in
this ChangeLog entry.

Just one tiny formatting request before committing:

> +	  /* Float Complex or double Complex arguments.  */
> +	  if (element < 16)
> +	    {
> +	      regnum = SPARC64_D0_REGNUM + element;
> +	      
> +	      if (len == 16)

Can you remove the tabs/spaces in the empty line before the "if"?

Thank you,
-- 
Joel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2014-02-08  2:47   ` Joel Brobecker
@ 2014-02-10 13:22     ` Jose E. Marchesi
  2014-02-11  4:45       ` Joel Brobecker
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2014-02-10 13:22 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

    
    > 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.
    
    One remark and a question...
    
    >        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);
    
    I think this part should be moved next to where complex_floating_point
    types are handled in terms of setting regnum. It seems to be the way
    things are done for other situations like this.

Somehow I missed the fact that for big structs and unions the writing of
the "additional" register is performed immediately after setting regnum.
A bit confusing, but that avoids repeated logic in the `if (regnum !=
1)' block, so I agree it is a better solution.

Please find below the amended patch.

n2013-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 52958df..9ccee42 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,25 @@ 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;
+	      
+	      if (len == 16)
+		{
+		  if (regnum < SPARC64_D30_REGNUM)
+		    regcache_cooked_write (regcache, regnum + 1, valbuf + 8);
+		  if (regnum < SPARC64_D10_REGNUM)
+		    regcache_cooked_write (regcache,
+					   SPARC_O0_REGNUM + element + 1,
+					   valbuf + 8);
+		}
+	    }
+	}
+      else if (sparc64_floating_p (type))
 	{
 	  /* Floating arguments.  */
 	  if (len == 16)

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2014-02-05 19:02 ` Jose E. Marchesi
@ 2014-02-08  2:47   ` Joel Brobecker
  2014-02-10 13:22     ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Joel Brobecker @ 2014-02-08  2:47 UTC (permalink / raw)
  To: Jose E. Marchesi; +Cc: gdb-patches

Hi Jose,

Sorry about the delay....

> 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.

One remark and a question...

>        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);

I think this part should be moved next to where complex_floating_point
types are handled in terms of setting regnum. It seems to be the way
things are done for other situations like this.

>           /* 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);

I think the same is true of this hunk, no? Also, I don't see the reason
why you're defining a new variable dregnum which is just a copy of
regnum.

-- 
Joel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
  2014-01-23 15:01 Jose E. Marchesi
@ 2014-02-05 19:02 ` Jose E. Marchesi
  2014-02-08  2:47   ` Joel Brobecker
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2014-02-05 19:02 UTC (permalink / raw)
  To: gdb-patches


ping

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)
            {



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] Fix passing double float complex arguments in sparc64
@ 2014-01-23 15:01 Jose E. Marchesi
  2014-02-05 19:02 ` Jose E. Marchesi
  0 siblings, 1 reply; 11+ messages in thread
From: Jose E. Marchesi @ 2014-01-23 15:01 UTC (permalink / raw)
  To: gdb-patches


ping

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)
            {

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-02-11 12:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-15 15:55 [PATCH] Fix passing double float complex arguments in sparc64 Jose E. Marchesi
2013-10-23 19:58 ` Mark Kettenis
2013-12-10 18:46   ` Jose E. Marchesi
2013-12-11 12:29     ` Jose E. Marchesi
2013-12-11 14:09       ` Jose E. Marchesi
2014-01-23 15:01 Jose E. Marchesi
2014-02-05 19:02 ` Jose E. Marchesi
2014-02-08  2:47   ` Joel Brobecker
2014-02-10 13:22     ` Jose E. Marchesi
2014-02-11  4:45       ` Joel Brobecker
2014-02-11 12:39         ` Jose E. Marchesi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).