testsuite: Fix recent GCC FAIL: gdb.arch/i386-signal.exp
[deliverable/binutils-gdb.git] / gdb / ppc-sysv-tdep.c
index bf2bcc51b14b3e539c8fba70849c756773fd5c25..4083cc81fc9e3f2402ef4d79432941cf0cc56440 100644 (file)
@@ -1,7 +1,7 @@
 /* Target-dependent code for PowerPC systems using the SVR4 ABI
    for GDB, the GNU debugger.
 
-   Copyright (C) 2000-2014 Free Software Foundation, Inc.
+   Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -28,6 +28,7 @@
 #include "objfiles.h"
 #include "infcall.h"
 #include "dwarf2.h"
+#include <algorithm>
 
 
 /* Check whether FTPYE is a (pointer to) function type that should use
@@ -608,7 +609,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 }
 
 /* Handle the return-value conventions for Decimal Floating Point values.  */
-static int
+static enum return_value_convention
 get_decimal_float_return_value (struct gdbarch *gdbarch, struct type *valtype,
                                struct regcache *regcache, gdb_byte *readbuf,
                                const gdb_byte *writebuf)
@@ -1189,7 +1190,7 @@ ppc64_aggregate_candidate (struct type *type,
              if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
                count += sub_count;
              else
-               count = max (count, sub_count);
+               count = std::max (count, sub_count);
            }
 
          /* There must be no padding.  */
@@ -1892,7 +1893,8 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
     }
 
   /* AltiVec vectors are returned in VRs starting at v2.  */
-  if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype)
+  if (TYPE_LENGTH (valtype) == 16
+      && TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype)
       && tdep->vector_abi == POWERPC_VEC_ALTIVEC)
     {
       int regnum = tdep->ppc_vr0_regnum + 2 + index;
@@ -1904,6 +1906,25 @@ ppc64_sysv_abi_return_value_base (struct gdbarch *gdbarch, struct type *valtype,
       return 1;
     }
 
+  /* Short vectors are returned in GPRs starting at r3.  */
+  if (TYPE_LENGTH (valtype) <= 8
+      && TYPE_CODE (valtype) == TYPE_CODE_ARRAY && TYPE_VECTOR (valtype))
+    {
+      int regnum = tdep->ppc_gp0_regnum + 3 + index;
+      int offset = 0;
+
+      if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+       offset = 8 - TYPE_LENGTH (valtype);
+
+      if (writebuf != NULL)
+       regcache_cooked_write_part (regcache, regnum,
+                                   offset, TYPE_LENGTH (valtype), writebuf);
+      if (readbuf != NULL)
+       regcache_cooked_read_part (regcache, regnum,
+                                  offset, TYPE_LENGTH (valtype), readbuf);
+      return 1;
+    }
+
   return 0;
 }
 
@@ -1993,6 +2014,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
 
   /* Small character arrays are returned, right justified, in r3.  */
   if (TYPE_CODE (valtype) == TYPE_CODE_ARRAY
+      && !TYPE_VECTOR (valtype)
       && TYPE_LENGTH (valtype) <= 8
       && TYPE_CODE (TYPE_TARGET_TYPE (valtype)) == TYPE_CODE_INT
       && TYPE_LENGTH (TYPE_TARGET_TYPE (valtype)) == 1)
@@ -2012,7 +2034,13 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct value *function,
   /* In the ELFv2 ABI, homogeneous floating-point or vector
      aggregates are returned in registers.  */
   if (tdep->elf_abi == POWERPC_ELF_V2
-      && ppc64_elfv2_abi_homogeneous_aggregate (valtype, &eltype, &nelt))
+      && ppc64_elfv2_abi_homogeneous_aggregate (valtype, &eltype, &nelt)
+      && (TYPE_CODE (eltype) == TYPE_CODE_FLT
+         || TYPE_CODE (eltype) == TYPE_CODE_DECFLOAT
+         || (TYPE_CODE (eltype) == TYPE_CODE_ARRAY
+             && TYPE_VECTOR (eltype)
+             && tdep->vector_abi == POWERPC_VEC_ALTIVEC
+             && TYPE_LENGTH (eltype) == 16)))
     {
       for (i = 0; i < nelt; i++)
        {
This page took 0.025496 seconds and 4 git commands to generate.