This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH [3/n] X32: Promote pointers to Pmode
- From: Uros Bizjak <ubizjak at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 10 Jul 2011 16:32:53 +0200
- Subject: Re: PATCH [3/n] X32: Promote pointers to Pmode
- References: <20110709212846.GA3563@intel.com>
On Sat, Jul 9, 2011 at 11:28 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> X32 psABI requires promoting pointers to Pmode when passing/returning
> in registers. ?OK for trunk?
>
> Thanks.
>
> H.J.
> --
> 2011-07-09 ?H.J. Lu ?<hongjiu.lu@intel.com>
>
> ? ? ? ?* config/i386/i386.c (ix86_promote_function_mode): New.
> ? ? ? ?(TARGET_PROMOTE_FUNCTION_MODE): Likewise.
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 04cb07d..c852719 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -7052,6 +7061,23 @@ ix86_function_value (const_tree valtype, const_tree fntype_or_decl,
> ? return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode);
> ?}
>
> +/* Pointer function arguments and return values are promoted to
> + ? Pmode. ?*/
> +
> +static enum machine_mode
> +ix86_promote_function_mode (const_tree type, enum machine_mode mode,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? int *punsignedp, const_tree fntype,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? int for_return)
> +{
> + ?if (for_return != 1 && type != NULL_TREE && POINTER_TYPE_P (type))
> + ? ?{
> + ? ? ?*punsignedp = POINTERS_EXTEND_UNSIGNED;
> + ? ? ?return Pmode;
> + ? ?}
> + ?return default_promote_function_mode (type, mode, punsignedp, fntype,
> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? for_return);
> +}
Please rewrite the condition to:
if (for_return == 1)
/* Do not promote function return values. */
;
else if (type != NULL_TREE && ...)
Also, please add some comments.
Your comment also says that pointer return arguments are promoted to
Pmode. The documentation says that:
FOR_RETURN allows to distinguish the promotion of arguments and
return values. If it is `1', a return value is being promoted and
`TARGET_FUNCTION_VALUE' must perform the same promotions done here.
If it is `2', the returned mode should be that of the register in
which an incoming parameter is copied, or the outgoing result is
computed; then the hook should return the same mode as
`promote_mode', though the signedness may be different.
You bypass promotions when FOR_RETURN is 1.
Uros.