This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [committed] ppc64: Handle short vectors as function return types
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Ulrich Weigand <uweigand at de dot ibm dot com>, <gdb-patches at sourceware dot org>
- Date: Fri, 12 Jun 2015 13:10:43 -0400
- Subject: Re: [committed] ppc64: Handle short vectors as function return types
- Authentication-results: sourceware.org; auth=none
- References: <20150612154605 dot 24CAB12CF at oc7340732750 dot ibm dot com>
On 15-06-12 11:46 AM, Ulrich Weigand wrote:
> Hello,
>
> Short synthetic vector types (i.e. those defined using GCC's
> attribute ((vector_size)) instead of AltiVec vector types)
> are returned in r3. Fix ppc64_sysv_abi_return_value to
> correctly handle this.
>
> Tested on powerpc64-linux and powerpc64le-linux.
> Pushed to mainline.
>
> Bye,
> Ulrich
>
> gdb/ChangeLog:
>
> * ppc-sysv-tdep.c (ppc64_sysv_abi_return_value_base): Handle short
> synthetic (non-AltiVec) vector types.
> (ppc64_sysv_abi_return_value): Likewise.
>
> diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
> index 6487bec..ea98c6e 100644
> --- a/gdb/ppc-sysv-tdep.c
> +++ b/gdb/ppc-sysv-tdep.c
> @@ -1892,7 +1892,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 +1905,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 +2013,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 +2033,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++)
> {
>
Hi Ulrich,
I think you made a typo in the date in the ChangeLog (05 instead of 06). While
we are at it, there is a missing space before your name. Do I let you change it
or do I do it myself?
Thanks,
Simon