Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@ericsson.com>
To: Ulrich Weigand <uweigand@de.ibm.com>, <gdb-patches@sourceware.org>
Subject: Re: [committed] ppc64: Handle short vectors as function return types
Date: Fri, 12 Jun 2015 17:10:00 -0000	[thread overview]
Message-ID: <557B1293.8040108@ericsson.com> (raw)
In-Reply-To: <20150612154605.24CAB12CF@oc7340732750.ibm.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


  reply	other threads:[~2015-06-12 17:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 15:46 Ulrich Weigand
2015-06-12 17:10 ` Simon Marchi [this message]
2015-06-15 11:51   ` Ulrich Weigand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=557B1293.8040108@ericsson.com \
    --to=simon.marchi@ericsson.com \
    --cc=gdb-patches@sourceware.org \
    --cc=uweigand@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox