[PATCH] Fix passing double float complex arguments in sparc64

Jose E. Marchesi jose.marchesi@oracle.com
Mon Feb 10 13:22:00 GMT 2014


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



More information about the Gdb-patches mailing list