From patchwork Fri Jul 23 13:59:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 59794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id DF9E81007D1 for ; Fri, 23 Jul 2010 23:59:57 +1000 (EST) Received: (qmail 28479 invoked by alias); 23 Jul 2010 13:59:53 -0000 Received: (qmail 28469 invoked by uid 22791); 23 Jul 2010 13:59:52 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 23 Jul 2010 13:59:45 +0000 Received: (qmail 5438 invoked from network); 23 Jul 2010 13:59:43 -0000 Received: from unknown (HELO localhost) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 23 Jul 2010 13:59:43 -0000 Date: Fri, 23 Jul 2010 06:59:42 -0700 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] remove __builtin_args_info Message-ID: <20100723135942.GE9110@codesourcery.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch removes __builtin_args_info. If I understand correctly, __builtin_args_info was part of an old way to implement varargs. We have much nicer, modern interfaces for that now, so __builtin_args_info can go. __builtin_saveregs looks like it can also be eliminated. I'll do that as a followup (non-obvious) patch if this patch is approved. __builtin_next_arg needs to stay, as its guts are still used for the modern varargs implementation. Tested on x86_64-unknown-linux-gnu. OK to commit? * builtins.def (BUILT_IN_ARGS_INFO): Remove. * ipa-pure-const.c (special_builtlin_state): Remove BUILT_IN_ARGS_INFO case. * tree-stdarg.c (execute_optimize_stdarg): Likewise. * builtins.c (expand_builtin): Likewise. (expand_builtin_args_info): Remove. * doc/tm.texi (__builtin_args_info): Remove. (__builtin_next_arg): Adjust to not refer to __builtin_args_info. * doc/tm.text.in: Likewise. diff --git a/gcc/builtins.c b/gcc/builtins.c index 40327e0..9b6fb10 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -111,7 +111,6 @@ static rtx expand_builtin_sincos (tree); static rtx expand_builtin_cexpi (tree, rtx, rtx); static rtx expand_builtin_int_roundingfn (tree, rtx); static rtx expand_builtin_int_roundingfn_2 (tree, rtx); -static rtx expand_builtin_args_info (tree); static rtx expand_builtin_next_arg (void); static rtx expand_builtin_va_start (tree); static rtx expand_builtin_va_end (tree); @@ -4398,38 +4397,6 @@ expand_builtin_saveregs (void) return val; } -/* __builtin_args_info (N) returns word N of the arg space info - for the current function. The number and meanings of words - is controlled by the definition of CUMULATIVE_ARGS. */ - -static rtx -expand_builtin_args_info (tree exp) -{ - int nwords = sizeof (CUMULATIVE_ARGS) / sizeof (int); - int *word_ptr = (int *) &crtl->args.info; - - gcc_assert (sizeof (CUMULATIVE_ARGS) % sizeof (int) == 0); - - if (call_expr_nargs (exp) != 0) - { - if (!host_integerp (CALL_EXPR_ARG (exp, 0), 0)) - error ("argument of %<__builtin_args_info%> must be constant"); - else - { - HOST_WIDE_INT wordnum = tree_low_cst (CALL_EXPR_ARG (exp, 0), 0); - - if (wordnum < 0 || wordnum >= nwords) - error ("argument of %<__builtin_args_info%> out of range"); - else - return GEN_INT (word_ptr[wordnum]); - } - } - else - error ("missing argument in %<__builtin_args_info%>"); - - return const0_rtx; -} - /* Expand a call to __builtin_next_arg. */ static rtx @@ -5925,9 +5892,6 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, case BUILT_IN_SAVEREGS: return expand_builtin_saveregs (); - case BUILT_IN_ARGS_INFO: - return expand_builtin_args_info (exp); - case BUILT_IN_VA_ARG_PACK: /* All valid uses of __builtin_va_arg_pack () are removed during inlining. */ diff --git a/gcc/builtins.def b/gcc/builtins.def index 4e4eb3e..ab0d018 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -606,7 +606,6 @@ DEF_GCC_BUILTIN (BUILT_IN_AGGREGATE_INCOMING_ADDRESS, "aggregate_incoming DEF_EXT_LIB_BUILTIN (BUILT_IN_ALLOCA, "alloca", BT_FN_PTR_SIZE, ATTR_MALLOC_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_APPLY, "apply", BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_APPLY_ARGS, "apply_args", BT_FN_PTR_VAR, ATTR_NULL) -DEF_GCC_BUILTIN (BUILT_IN_ARGS_INFO, "args_info", BT_FN_INT_INT, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, ATTR_CONST_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, ATTR_CONST_NOTHROW_LIST) DEF_EXT_LIB_BUILTIN (BUILT_IN_CLEAR_CACHE, "__clear_cache", BT_FN_VOID_PTR_PTR, ATTR_NOTHROW_LIST) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 78f2f2f..30210ec 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -5007,33 +5007,8 @@ to use them for its own purposes. @c 10feb93 @end defmac -@defmac __builtin_args_info (@var{category}) -Use this built-in function to find the first anonymous arguments in -registers. - -In general, a machine may have several categories of registers used for -arguments, each for a particular category of data types. (For example, -on some machines, floating-point registers are used for floating-point -arguments while other arguments are passed in the general registers.) -To make non-varargs functions use the proper calling convention, you -have defined the @code{CUMULATIVE_ARGS} data type to record how many -registers in each category have been used so far - -@code{__builtin_args_info} accesses the same data structure of type -@code{CUMULATIVE_ARGS} after the ordinary argument layout is finished -with it, with @var{category} specifying which word to access. Thus, the -value indicates the first unused register in a given category. - -Normally, you would use @code{__builtin_args_info} in the implementation -of @code{va_start}, accessing each category just once and storing the -value in the @code{va_list} object. This is because @code{va_list} will -have to update the values, and there is no way to alter the -values accessed by @code{__builtin_args_info}. -@end defmac - @defmac __builtin_next_arg (@var{lastarg}) -This is the equivalent of @code{__builtin_args_info}, for stack -arguments. It returns the address of the first anonymous stack +This builtin returns the address of the first anonymous stack argument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it returns the address of the location above the first anonymous stack argument. Use it in @code{va_start} to initialize the pointer for diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 2f35a42..b5c75d3 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -5007,33 +5007,8 @@ to use them for its own purposes. @c 10feb93 @end defmac -@defmac __builtin_args_info (@var{category}) -Use this built-in function to find the first anonymous arguments in -registers. - -In general, a machine may have several categories of registers used for -arguments, each for a particular category of data types. (For example, -on some machines, floating-point registers are used for floating-point -arguments while other arguments are passed in the general registers.) -To make non-varargs functions use the proper calling convention, you -have defined the @code{CUMULATIVE_ARGS} data type to record how many -registers in each category have been used so far - -@code{__builtin_args_info} accesses the same data structure of type -@code{CUMULATIVE_ARGS} after the ordinary argument layout is finished -with it, with @var{category} specifying which word to access. Thus, the -value indicates the first unused register in a given category. - -Normally, you would use @code{__builtin_args_info} in the implementation -of @code{va_start}, accessing each category just once and storing the -value in the @code{va_list} object. This is because @code{va_list} will -have to update the values, and there is no way to alter the -values accessed by @code{__builtin_args_info}. -@end defmac - @defmac __builtin_next_arg (@var{lastarg}) -This is the equivalent of @code{__builtin_args_info}, for stack -arguments. It returns the address of the first anonymous stack +This builtin returns the address of the first anonymous stack argument, as type @code{void *}. If @code{ARGS_GROW_DOWNWARD}, it returns the address of the location above the first anonymous stack argument. Use it in @code{va_start} to initialize the pointer for diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c index 4a29e10..1ff15bf 100644 --- a/gcc/ipa-pure-const.c +++ b/gcc/ipa-pure-const.c @@ -446,7 +446,6 @@ special_builtlin_state (enum pure_const_state_e *state, bool *looping, case BUILT_IN_FRAME_ADDRESS: case BUILT_IN_APPLY: case BUILT_IN_APPLY_ARGS: - case BUILT_IN_ARGS_INFO: *looping = false; *state = IPA_CONST; return true; diff --git a/gcc/tree-stdarg.c b/gcc/tree-stdarg.c index dae14f5..5c9b35c 100644 --- a/gcc/tree-stdarg.c +++ b/gcc/tree-stdarg.c @@ -636,7 +636,6 @@ execute_optimize_stdarg (void) break; /* If old style builtins are used, don't optimize anything. */ case BUILT_IN_SAVEREGS: - case BUILT_IN_ARGS_INFO: case BUILT_IN_NEXT_ARG: va_list_escapes = true; continue;