summaryrefslogtreecommitdiff
path: root/gcc/builtins.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-16 23:25:51 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-16 23:25:51 +0000
commit2799a2b76e6fad98489f9d05477ad8d65a5839f9 (patch)
tree736540023a0461568858dfe8fec7b2c58a7dd59d /gcc/builtins.c
parentbdebf8b35081fd5408bea5c50cf864f61861d184 (diff)
downloadgcc-2799a2b76e6fad98489f9d05477ad8d65a5839f9.tar.gz
* builtins.c (std_expand_builtin_va_arg): Remove.
(expand_builtin_va_arg): Remove. * expr.h: Don't declare them. * gimplify.c (mark_decls_volatile_r): Remove. (copy_if_shared_r): Don't call it. * target-def.h: Don't test EXPAND_BUILTIN_VA_ARG. * expr.c (expand_expr_real_1): Don't handle VA_ARG_EXPR. * gimple-low.c (lower_stmt): Likewise. * tree-cfg.c (cfg_remove_useless_stmts_bb): Likewise. * tree-gimple.c (is_gimple_tmp_rhs, is_gimple_stmt): Likewise. * tree-ssa-operands.c (get_expr_operands): Likewise. * doc/tm.texi (TARGET_GIMPLIFY_VA_ARG_EXPR): Don't mention EXPAND_BUILTIN_VA_ARG. * system.h (EXPAND_BUILTIN_VA_ARG): Poison. * config/alpha/alpha.h, config/alpha/unicosmk.h, config/i386/i386.h, config/ia64/ia64.h, config/rs6000/rs6000.h, config/s390/s390.h, config/sparc/sparc.h (EXPAND_BUILTIN_VA_ARG): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84842 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r--gcc/builtins.c183
1 files changed, 2 insertions, 181 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index d83b0de27de..de2cca6de17 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -4288,186 +4288,6 @@ expand_builtin_va_start (tree arglist)
/* The "standard" implementation of va_arg: read the value from the
current (padded) address and increment by the (padded) size. */
-rtx
-std_expand_builtin_va_arg (tree valist, tree type)
-{
- tree addr_tree, t, type_size = NULL;
- tree align, alignm1;
- tree rounded_size;
- rtx addr;
- HOST_WIDE_INT boundary;
-
- /* Compute the rounded size of the type. */
- align = size_int (PARM_BOUNDARY / BITS_PER_UNIT);
- alignm1 = size_int (PARM_BOUNDARY / BITS_PER_UNIT - 1);
- boundary = FUNCTION_ARG_BOUNDARY (TYPE_MODE (type), type);
-
- /* va_list pointer is aligned to PARM_BOUNDARY. If argument actually
- requires greater alignment, we must perform dynamic alignment. */
-
- if (boundary > PARM_BOUNDARY)
- {
- if (!PAD_VARARGS_DOWN)
- {
- t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist,
- build2 (PLUS_EXPR, TREE_TYPE (valist), valist,
- build_int_2 (boundary / BITS_PER_UNIT - 1, 0)));
- TREE_SIDE_EFFECTS (t) = 1;
- expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
- }
- t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist,
- build2 (BIT_AND_EXPR, TREE_TYPE (valist), valist,
- build_int_2 (~(boundary / BITS_PER_UNIT - 1), -1)));
- TREE_SIDE_EFFECTS (t) = 1;
- expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
- }
- if (type == error_mark_node
- || (type_size = TYPE_SIZE_UNIT (TYPE_MAIN_VARIANT (type))) == NULL
- || TREE_OVERFLOW (type_size))
- rounded_size = size_zero_node;
- else
- {
- rounded_size = fold (build2 (PLUS_EXPR, sizetype, type_size, alignm1));
- rounded_size = fold (build2 (TRUNC_DIV_EXPR, sizetype,
- rounded_size, align));
- rounded_size = fold (build2 (MULT_EXPR, sizetype,
- rounded_size, align));
- }
-
- /* Get AP. */
- addr_tree = valist;
- if (PAD_VARARGS_DOWN && ! integer_zerop (rounded_size))
- {
- /* Small args are padded downward. */
- addr_tree = fold (build2 (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree,
- fold (build3 (COND_EXPR, sizetype,
- fold (build2 (GT_EXPR, sizetype,
- rounded_size,
- align)),
- size_zero_node,
- fold (build2 (MINUS_EXPR,
- sizetype,
- rounded_size,
- type_size))))));
- }
-
- addr = expand_expr (addr_tree, NULL_RTX, Pmode, EXPAND_NORMAL);
- addr = copy_to_reg (addr);
-
- /* Compute new value for AP. */
- if (! integer_zerop (rounded_size))
- {
- t = build2 (MODIFY_EXPR, TREE_TYPE (valist), valist,
- build2 (PLUS_EXPR, TREE_TYPE (valist), valist,
- rounded_size));
- TREE_SIDE_EFFECTS (t) = 1;
- expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
- }
-
- return addr;
-}
-
-/* Expand __builtin_va_arg, which is not really a builtin function, but
- a very special sort of operator. */
-
-rtx
-expand_builtin_va_arg (tree valist, tree type)
-{
- rtx addr, result;
- tree promoted_type, want_va_type, have_va_type;
-
- /* Verify that valist is of the proper type. */
-
- want_va_type = va_list_type_node;
- have_va_type = TREE_TYPE (valist);
- if (TREE_CODE (want_va_type) == ARRAY_TYPE)
- {
- /* If va_list is an array type, the argument may have decayed
- to a pointer type, e.g. by being passed to another function.
- In that case, unwrap both types so that we can compare the
- underlying records. */
- if (TREE_CODE (have_va_type) == ARRAY_TYPE
- || TREE_CODE (have_va_type) == POINTER_TYPE)
- {
- want_va_type = TREE_TYPE (want_va_type);
- have_va_type = TREE_TYPE (have_va_type);
- }
- }
- if (TYPE_MAIN_VARIANT (want_va_type) != TYPE_MAIN_VARIANT (have_va_type))
- {
- error ("first argument to `va_arg' not of type `va_list'");
- addr = const0_rtx;
- }
-
- /* Generate a diagnostic for requesting data of a type that cannot
- be passed through `...' due to type promotion at the call site. */
- else if ((promoted_type = lang_hooks.types.type_promotes_to (type))
- != type)
- {
- const char *name = "<anonymous type>", *pname = 0;
- static bool gave_help;
-
- if (TYPE_NAME (type))
- {
- if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
- name = IDENTIFIER_POINTER (TYPE_NAME (type));
- else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
- && DECL_NAME (TYPE_NAME (type)))
- name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
- }
- if (TYPE_NAME (promoted_type))
- {
- if (TREE_CODE (TYPE_NAME (promoted_type)) == IDENTIFIER_NODE)
- pname = IDENTIFIER_POINTER (TYPE_NAME (promoted_type));
- else if (TREE_CODE (TYPE_NAME (promoted_type)) == TYPE_DECL
- && DECL_NAME (TYPE_NAME (promoted_type)))
- pname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (promoted_type)));
- }
-
- /* Unfortunately, this is merely undefined, rather than a constraint
- violation, so we cannot make this an error. If this call is never
- executed, the program is still strictly conforming. */
- warning ("`%s' is promoted to `%s' when passed through `...'",
- name, pname);
- if (! gave_help)
- {
- gave_help = true;
- warning ("(so you should pass `%s' not `%s' to `va_arg')",
- pname, name);
- }
-
- /* We can, however, treat "undefined" any way we please.
- Call abort to encourage the user to fix the program. */
- inform ("if this code is reached, the program will abort");
- expand_builtin_trap ();
-
- /* This is dead code, but go ahead and finish so that the
- mode of the result comes out right. */
- addr = const0_rtx;
- }
- else
- {
- /* Make it easier for the backends by protecting the valist argument
- from multiple evaluations. */
- valist = stabilize_va_list (valist, 0);
-
-#ifdef EXPAND_BUILTIN_VA_ARG
- addr = EXPAND_BUILTIN_VA_ARG (valist, type);
-#else
- addr = std_expand_builtin_va_arg (valist, type);
-#endif
- }
-
- addr = convert_memory_address (Pmode, addr);
-
- result = gen_rtx_MEM (TYPE_MODE (type), addr);
- set_mem_alias_set (result, get_varargs_alias_set ());
-
- return result;
-}
-
-/* Like std_expand_builtin_va_arg, but gimplify instead of expanding. */
-
tree
std_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p)
{
@@ -4550,7 +4370,8 @@ dummy_object (tree type)
return build1 (INDIRECT_REF, type, t);
}
-/* Like expand_builtin_va_arg, but gimplify instead of expanding. */
+/* Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a
+ builtin function, but a very special sort of operator. */
enum gimplify_status
gimplify_va_arg_expr (tree *expr_p, tree *pre_p, tree *post_p)