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

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