This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [rx] Add builtin-decl support
- From: Richard Guenther <richard dot guenther at gmail dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 29 Oct 2010 15:24:55 +0200
- Subject: Re: [rx] Add builtin-decl support
- References: <201010290601.o9T61T7u028311@greed.delorie.com>
On Fri, Oct 29, 2010 at 8:01 AM, DJ Delorie <dj@redhat.com> wrote:
>
> I've had this in my tree for a while, it's for LTO. ?Ok?
>
> ? ? ? ?* config/rx/rx.c (rx_init_builtins): Save all decls.
> ? ? ? ?(rx_builtin_decl): New, return them as requested.
>
> Index: rx.c
> ===================================================================
> --- rx.c ? ? ? ?(revision 166029)
> +++ rx.c ? ? ? ?(working copy)
> @@ -1820,34 +1820,39 @@ enum rx_builtin
> ? RX_BUILTIN_SAT,
> ? RX_BUILTIN_SETPSW,
> ? RX_BUILTIN_WAIT,
> ? RX_BUILTIN_max
> ?};
>
> +static tree rx_builtins[RX_BUILTIN_max];
> +
Needs GTY markers, otherwise it'll crash when in lto1.
Richard.
> ?static void
> ?rx_init_builtins (void)
> ?{
> ?#define ADD_RX_BUILTIN1(UC_NAME, LC_NAME, RET_TYPE, ARG_TYPE) ? ? ? ? ?\
> - ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? ? \
> + ?rx_builtins[RX_BUILTIN_##UC_NAME] = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?build_function_type_list (RET_TYPE##_type_node, \
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE##_type_node, \
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NULL_TREE), ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?RX_BUILTIN_##UC_NAME, ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?BUILT_IN_MD, NULL, NULL_TREE)
>
> ?#define ADD_RX_BUILTIN2(UC_NAME, LC_NAME, RET_TYPE, ARG_TYPE1, ARG_TYPE2) \
> - ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? ? \
> + ?rx_builtins[RX_BUILTIN_##UC_NAME] = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?build_function_type_list (RET_TYPE##_type_node, \
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE1##_type_node,\
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE2##_type_node,\
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NULL_TREE), ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?RX_BUILTIN_##UC_NAME, ? ? ? ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?BUILT_IN_MD, NULL, NULL_TREE)
>
> ?#define ADD_RX_BUILTIN3(UC_NAME,LC_NAME,RET_TYPE,ARG_TYPE1,ARG_TYPE2,ARG_TYPE3) \
> - ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? ? \
> + ?rx_builtins[RX_BUILTIN_##UC_NAME] = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?\
> + ? ?add_builtin_function ("__builtin_rx_" LC_NAME, ? ? ? ? ? ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?build_function_type_list (RET_TYPE##_type_node, \
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE1##_type_node,\
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE2##_type_node,\
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ARG_TYPE3##_type_node,\
> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NULL_TREE), ? ? ? ? ? \
> ? ? ? ? ? ? ? ? ? ? ? ?RX_BUILTIN_##UC_NAME, ? ? ? ? ? ? ? ? ? ? ? ? ? \
> @@ -1873,12 +1878,23 @@ rx_init_builtins (void)
> ? ADD_RX_BUILTIN1 (ROUND, ? "round", ? intSI, float);
> ? ADD_RX_BUILTIN1 (REVW, ? ?"revw", ? ?intSI, intSI);
> ? ADD_RX_BUILTIN1 (SAT, ? ? "sat", ? ? intSI, intSI);
> ? ADD_RX_BUILTIN1 (WAIT, ? ?"wait", ? ?void, ?void);
> ?}
>
> +/* Return the RX builtin for CODE. ?*/
> +
> +static tree
> +rx_builtin_decl (unsigned code, bool initialize_p ATTRIBUTE_UNUSED)
> +{
> + ?if (code >= RX_BUILTIN_max)
> + ? ?return error_mark_node;
> +
> + ?return rx_builtins[code];
> +}
> +
> ?static rtx
> ?rx_expand_void_builtin_1_arg (rtx arg, rtx (* gen_func)(rtx), bool reg)
> ?{
> ? if (reg && ! REG_P (arg))
> ? ? arg = force_reg (SImode, arg);
>
> @@ -2770,12 +2786,15 @@ rx_memory_move_cost (enum machine_mode m
> ?#undef TARGET_ASM_SELECT_SECTION
> ?#define ? ? ? ?TARGET_ASM_SELECT_SECTION ? ? ? rx_select_section
>
> ?#undef ?TARGET_INIT_BUILTINS
> ?#define TARGET_INIT_BUILTINS ? ? ? ? ? rx_init_builtins
>
> +#undef ?TARGET_BUILTIN_DECL
> +#define TARGET_BUILTIN_DECL ? ? ? ? ? ?rx_builtin_decl
> +
> ?#undef ?TARGET_EXPAND_BUILTIN
> ?#define TARGET_EXPAND_BUILTIN ? ? ? ? ?rx_expand_builtin
>
> ?#undef ?TARGET_ASM_CONSTRUCTOR
> ?#define TARGET_ASM_CONSTRUCTOR ? ? ? ? rx_elf_asm_constructor
>
>