/* 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-2017 Free Software Foundation, Inc.
This file is part of GDB.
#include "objfiles.h"
#include "infcall.h"
#include "dwarf2.h"
+#include <algorithm>
/* Check whether FTPYE is a (pointer to) function type that should use
{
/* Always store the floating point value using
the register's floating-point format. */
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
struct type *regtype
= register_type (gdbarch, tdep->ppc_fp0_regnum + freg);
convert_typed_floating (val, type, regval, regtype);
{
if (write_pass)
{
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
const gdb_byte *p;
/* 32-bit decimal floats are right aligned in the
if (write_pass)
{
int regnum = tdep->ppc_fp0_regnum + freg;
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
struct type *regtype
= register_type (gdbarch, regnum);
convert_typed_floating (elval, eltype,
}
else
{
- gdb_byte word[MAX_REGISTER_SIZE];
+ gdb_byte word[PPC_MAX_REGISTER_SIZE];
store_unsigned_integer (word, tdep->wordsize, byte_order,
unpack_long (eltype, elval));
{
/* Reduce the parameter down to something that fits in a
"word". */
- gdb_byte word[MAX_REGISTER_SIZE];
- memset (word, 0, MAX_REGISTER_SIZE);
+ gdb_byte word[PPC_MAX_REGISTER_SIZE];
+ memset (word, 0, PPC_MAX_REGISTER_SIZE);
if (len > tdep->wordsize
|| TYPE_CODE (type) == TYPE_CODE_STRUCT
|| TYPE_CODE (type) == TYPE_CODE_UNION)
}
/* 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)
{
if (writebuf != NULL)
{
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
const gdb_byte *p;
/* 32-bit decimal float is right aligned in the doubleword. */
{
/* Floats and doubles stored in "f1". Convert the value to
the required type. */
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
struct type *regtype = register_type (gdbarch,
tdep->ppc_fp0_regnum + 1);
regcache_cooked_read (regcache, tdep->ppc_fp0_regnum + 1, regval);
{
/* Floats and doubles stored in "f1". Convert the value to
the register's "double" type. */
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
struct type *regtype = register_type (gdbarch, tdep->ppc_fp0_regnum);
convert_typed_floating (writebuf, type, regval, regtype);
regcache_cooked_write (regcache, tdep->ppc_fp0_regnum + 1, regval);
|| TYPE_CODE (type) == TYPE_CODE_CHAR
|| TYPE_CODE (type) == TYPE_CODE_BOOL
|| TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF
+ || TYPE_IS_REFERENCE (type)
|| TYPE_CODE (type) == TYPE_CODE_ENUM)
&& TYPE_LENGTH (type) <= tdep->wordsize)
{
if (TYPE_CODE (eltype) == TYPE_CODE_FLT)
{
int regnum = tdep->ppc_fp0_regnum + 1 + i;
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
struct type *regtype = register_type (gdbarch, regnum);
if (writebuf != NULL)
/* GCC screwed up for structures or unions whose size is less
than or equal to 8 bytes.. Instead of left-aligning, it
right-aligns the data into the buffer formed by r3, r4. */
- gdb_byte regvals[MAX_REGISTER_SIZE * 2];
+ gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2];
int len = TYPE_LENGTH (type);
int offset = (2 * tdep->wordsize - len) % tdep->wordsize;
/* This matches SVr4 PPC, it does not match GCC. */
/* The value is right-padded to 8 bytes and then loaded, as
two "words", into r3/r4. */
- gdb_byte regvals[MAX_REGISTER_SIZE * 2];
+ gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2];
regcache_cooked_read (regcache, tdep->ppc_gp0_regnum + 3,
regvals + 0 * tdep->wordsize);
if (TYPE_LENGTH (type) > tdep->wordsize)
/* This matches SVr4 PPC, it does not match GCC. */
/* The value is padded out to 8 bytes and then loaded, as
two "words" into r3/r4. */
- gdb_byte regvals[MAX_REGISTER_SIZE * 2];
+ gdb_byte regvals[PPC_MAX_REGISTER_SIZE * 2];
memset (regvals, 0, sizeof regvals);
memcpy (regvals, writebuf, TYPE_LENGTH (type));
regcache_cooked_write (regcache, tdep->ppc_gp0_regnum + 3,
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. */
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- gdb_byte buf[MAX_REGISTER_SIZE];
+ gdb_byte buf[PPC_MAX_REGISTER_SIZE];
if (argpos->regcache)
store_unsigned_integer (buf, tdep->wordsize, byte_order, val);
{
int regnum = tdep->ppc_fp0_regnum + argpos->freg;
struct type *regtype = register_type (gdbarch, regnum);
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
convert_typed_floating (val, type, regval, regtype);
regcache_cooked_write (argpos->regcache, regnum, regval);
|| TYPE_CODE (type) == TYPE_CODE_BOOL
|| TYPE_CODE (type) == TYPE_CODE_CHAR
|| TYPE_CODE (type) == TYPE_CODE_PTR
- || TYPE_CODE (type) == TYPE_CODE_REF)
+ || TYPE_IS_REFERENCE (type))
&& TYPE_LENGTH (type) <= tdep->wordsize)
{
ULONGEST word = 0;
{
int regnum = tdep->ppc_fp0_regnum + 1 + index;
struct type *regtype = register_type (gdbarch, regnum);
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
if (writebuf != NULL)
{
}
/* 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;
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;
}
}
/* All pointers live in r3. */
- if (TYPE_CODE (valtype) == TYPE_CODE_PTR
- || TYPE_CODE (valtype) == TYPE_CODE_REF)
+ if (TYPE_CODE (valtype) == TYPE_CODE_PTR || TYPE_IS_REFERENCE (valtype))
{
int regnum = tdep->ppc_gp0_regnum + 3;
/* 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)
/* 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++)
{
for (i = 0; i < n_regs; i++)
{
- gdb_byte regval[MAX_REGISTER_SIZE];
+ gdb_byte regval[PPC_MAX_REGISTER_SIZE];
int regnum = tdep->ppc_gp0_regnum + 3 + i;
int offset = i * tdep->wordsize;
int len = TYPE_LENGTH (valtype) - offset;