[XTENSA] Hookize LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P

Sterling Augustine sterling@tensilica.com
Thu Jan 13 17:55:00 GMT 2011


Approved. Please apply. Thanks!

Sterling

On 01/12/2011 10:13 AM, Anatoly Sokolov wrote:
> Hello.
>
>    This patch removes obsolete LIBCALL_VALUE and FUNCTION_VALUE_REGNO_P macros
> from XTENSA back end in the GCC and introduces equivalent
> TARGET_LIBCALL_VALUE and TARGET_FUNCTION_VALUE_REGNO_P target hooks.
>
>    Not tested.
>
>    OK to install?
>
>          * config/xtensa/xtensa.h (XTENSA_LIBCALL_VALUE, LIBCALL_VALUE,
>          LIBCALL_OUTGOING_VALUE, FUNCTION_VALUE_REGNO_P): Remove macros.
>          * config/xtensa/xtensa.c (xtensa_libcall_value,
>          xtensa_function_value_regno_p): New functions.
>          (TARGET_LIBCALL_VALUE, TARGET_FUNCTION_VALUE_REGNO_P): Define.
>
>
> Index: gcc/config/xtensa/xtensa.c
> ===================================================================
> --- gcc/config/xtensa/xtensa.c  (revision 168721)
> +++ gcc/config/xtensa/xtensa.c  (working copy)
> @@ -147,6 +147,8 @@
>   static rtx xtensa_function_incoming_arg (CUMULATIVE_ARGS *,
>                                           enum machine_mode, const_tree, bool);
>   static rtx xtensa_function_value (const_tree, const_tree, bool);
> +static rtx xtensa_libcall_value (enum machine_mode, const_rtx);
> +static bool xtensa_function_value_regno_p (const unsigned int);
>   static unsigned int xtensa_function_arg_boundary (enum machine_mode,
>                                                    const_tree);
>   static void xtensa_init_builtins (void);
> @@ -220,6 +222,11 @@
>   #define TARGET_RETURN_IN_MEMORY xtensa_return_in_memory
>   #undef TARGET_FUNCTION_VALUE
>   #define TARGET_FUNCTION_VALUE xtensa_function_value
> +#undef TARGET_LIBCALL_VALUE
> +#define TARGET_LIBCALL_VALUE xtensa_libcall_value
> +#undef TARGET_FUNCTION_VALUE_REGNO_P
> +#define TARGET_FUNCTION_VALUE_REGNO_P xtensa_function_value_regno_p
> +
>   #undef TARGET_SPLIT_COMPLEX_ARG
>   #define TARGET_SPLIT_COMPLEX_ARG hook_bool_const_tree_true
>   #undef TARGET_MUST_PASS_IN_STACK
> @@ -3496,6 +3503,24 @@
>                        outgoing ? GP_OUTGOING_RETURN : GP_RETURN);
>   }
>
> +/* Worker function for TARGET_LIBCALL_VALUE.  */
> +
> +static rtx
> +xtensa_libcall_value (enum machine_mode mode, const_rtx fun ATTRIBUTE_UNUSED)
> +{
> +  return gen_rtx_REG ((GET_MODE_CLASS (mode) == MODE_INT
> +&&  GET_MODE_SIZE (mode)<  UNITS_PER_WORD)
> +                     ? SImode : mode, GP_RETURN);
> +}
> +
> +/* Worker function TARGET_FUNCTION_VALUE_REGNO_P.  */
> +
> +static bool
> +xtensa_function_value_regno_p (const unsigned int regno)
> +{
> +  return (regno == GP_RETURN);
> +}
> +
>   /* The static chain is passed in memory.  Provide rtx giving 'mem'
>      expressions that denote where they are stored.  */
>
> Index: gcc/config/xtensa/xtensa.h
> ===================================================================
> --- gcc/config/xtensa/xtensa.h  (revision 168721)
> +++ gcc/config/xtensa/xtensa.h  (working copy)
> @@ -539,34 +539,7 @@
>   /* Don't worry about compatibility with PCC.  */
>   #define DEFAULT_PCC_STRUCT_RETURN 0
>
> -/* Define how to find the value returned by a library function
> -   assuming the value has mode MODE.  Because we have defined
> -   TARGET_PROMOTE_FUNCTION_MODE to promote everything, we have to
> -   perform the same promotions as PROMOTE_MODE.  */
> -#define XTENSA_LIBCALL_VALUE(MODE, OUTGOINGP)                          \
> -  gen_rtx_REG ((GET_MODE_CLASS (MODE) == MODE_INT                      \
> -&&  GET_MODE_SIZE (MODE)<  UNITS_PER_WORD)               \
> -              ? SImode : (MODE),                                       \
> -              OUTGOINGP ? GP_OUTGOING_RETURN : GP_RETURN)
> -
> -#define LIBCALL_VALUE(MODE)                                            \
> -  XTENSA_LIBCALL_VALUE ((MODE), 0)
> -
> -#define LIBCALL_OUTGOING_VALUE(MODE)                                   \
> -  XTENSA_LIBCALL_VALUE ((MODE), 1)
> -
>   /* A C expression that is nonzero if REGNO is the number of a hard
> -   register in which the values of called function may come back.  A
> -   register whose use for returning values is limited to serving as
> -   the second of a pair (for a value of type 'double', say) need not
> -   be recognized by this macro.  If the machine has register windows,
> -   so that the caller and the called function use different registers
> -   for the return value, this macro should recognize only the caller's
> -   register numbers.  */
> -#define FUNCTION_VALUE_REGNO_P(N)                                      \
> -  ((N) == GP_RETURN)
> -
> -/* A C expression that is nonzero if REGNO is the number of a hard
>      register in which function arguments are sometimes passed.  This
>      does *not* include implicit arguments such as the static chain and
>      the structure-value address.  On many machines, no registers can be
>
>
> Anatoly.
>



More information about the Gcc-patches mailing list