Blame SOURCES/gdb-rhbz1480497-ppc64le-shortvec-retval.patch

dc7ef9
commit a1da2672bdc5adc551ad30d73eccea902063f583
dc7ef9
Author: Ulrich Weigand <ulrich.weigand@de.ibm.com>
dc7ef9
Date:   Fri Jun 12 17:43:48 2015 +0200
dc7ef9
dc7ef9
    ppc64: Handle short vectors as function return types
dc7ef9
    
dc7ef9
    Short synthetic vector types (i.e. those defined using GCC's
dc7ef9
    attribute ((vector_size)) instead of AltiVec vector types)
dc7ef9
    are returned in r3.  Fix ppc64_sysv_abi_return_value to
dc7ef9
    correctly handle this.
dc7ef9
    
dc7ef9
    gdb/ChangeLog:
dc7ef9
    
dc7ef9
            * ppc-sysv-tdep.c (ppc64_sysv_abi_return_value_base): Handle short
dc7ef9
            synthetic (non-AltiVec) vector types.
dc7ef9
            (ppc64_sysv_abi_return_value): Likewise.
dc7ef9
dc7ef9
### a/gdb/ChangeLog
dc7ef9
### b/gdb/ChangeLog
dc7ef9
## -1,3 +1,9 @@
dc7ef9
+2015-05-12 Ulrich Weigand  <uweigand@de.ibm.com>
dc7ef9
+
dc7ef9
+	* ppc-sysv-tdep.c (ppc64_sysv_abi_return_value_base): Handle short
dc7ef9
+	synthetic (non-AltiVec) vector types.
dc7ef9
+	(ppc64_sysv_abi_return_value): Likewise.
dc7ef9
+
dc7ef9
 2015-06-12  Antoine Tremblay  <antoine.tremblay@ericsson.com>
dc7ef9
 
dc7ef9
 	PR breakpoints/16465
dc7ef9
--- a/gdb/ppc-sysv-tdep.c
dc7ef9
+++ b/gdb/ppc-sysv-tdep.c
dc7ef9
@@ -1892,7 +1892,8 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
dc7ef9
     }
dc7ef9
 
dc7ef9
   /* AltiVec vectors are returned in VRs starting at v2.  */
dc7ef9
-  if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype)
dc7ef9
+  if (TYPE_LENGTH (valtype) == 16
dc7ef9
+      && TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype)
dc7ef9
       && tdep->vector_abi == POWERPC_VEC_ALTIVEC)
dc7ef9
     {
dc7ef9
       int regnum = tdep->ppc_vr0_regnum + 2 + index;
dc7ef9
@@ -1904,6 +1905,25 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
dc7ef9
       return 1;
dc7ef9
     }
dc7ef9
 
dc7ef9
+  /* Short vectors are returned in GPRs starting at r3.  */
dc7ef9
+  if (TYPE_LENGTH (valtype) <= 8
dc7ef9
+      && TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype))
dc7ef9
+    {
dc7ef9
+      int regnum = tdep->ppc_gp0_regnum + 3 + index;
dc7ef9
+      int offset = 0;
dc7ef9
+
dc7ef9
+      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
dc7ef9
+	offset = 8 - TYPE_LENGTH (valtype);
dc7ef9
+
dc7ef9
+      if (writebuf != NULL)
dc7ef9
+	regcache_cooked_write_part (regcache, regnum,
dc7ef9
+				    offset, TYPE_LENGTH (valtype), writebuf);
dc7ef9
+      if (readbuf != NULL)
dc7ef9
+	regcache_cooked_read_part (regcache, regnum,
dc7ef9
+				   offset, TYPE_LENGTH (valtype), readbuf);
dc7ef9
+      return 1;
dc7ef9
+    }
dc7ef9
+
dc7ef9
   return 0;
dc7ef9
 }
dc7ef9
 
dc7ef9
@@ -1993,6 +2013,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
dc7ef9
 
dc7ef9
   /* Small character arrays are returned, right justified, in r3.  */
dc7ef9
   if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
dc7ef9
+      && !TYPE_VECTOR (valtype)
dc7ef9
       && TYPE_LENGTH (valtype) <= 8
dc7ef9
       && TYPE_CODE (TYPE_TARGET_TYPE (valtype)) == TYPE_CODE_INT
dc7ef9
       && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1)
dc7ef9
@@ -2012,7 +2033,13 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
dc7ef9
   /* In the ELFv2 ABI, homogeneous floating-point or vector
dc7ef9
      aggregates are returned in registers.  */
dc7ef9
   if (tdep->elf_abi == POWERPC_ELF_V2
dc7ef9
-      && ppc64_elfv2_abi_homogeneous_aggregate (valtype, &eltype, &nelt))
dc7ef9
+      && ppc64_elfv2_abi_homogeneous_aggregate (valtype, &eltype, &nelt)
dc7ef9
+      && (TYPE_CODE (eltype) == TYPE_CODE_FLT
dc7ef9
+	  || TYPE_CODE (eltype) == TYPE_CODE_DECFLOAT
dc7ef9
+	  || (TYPE_CODE (eltype) == TYPE_CODE_ARRAY
dc7ef9
+	      && TYPE_VECTOR (eltype)
dc7ef9
+	      && tdep->vector_abi == POWERPC_VEC_ALTIVEC
dc7ef9
+	      && TYPE_LENGTH (eltype) == 16)))
dc7ef9
     {
dc7ef9
       for (i = 0; i < nelt; i++)
dc7ef9
 	{