Patchwork remove __builtin_args_info

login
register
mail settings
Submitter Nathan Froyd
Date July 23, 2010, 1:59 p.m.
Message ID <20100723135942.GE9110@codesourcery.com>
Download mbox | patch
Permalink /patch/59794/
State New
Headers show

Comments

Nathan Froyd - July 23, 2010, 1:59 p.m.
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.
Diego Novillo - July 23, 2010, 2:08 p.m.
On 10-07-23 09:59 , Nathan Froyd wrote:

> 	* 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.

OK.


Diego.

Patch

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;