From c8f5fc7032940ad6633f932ac40cade82ec4d0cc Mon Sep 17 00:00:00 2001 From: obrien Date: Thu, 9 May 2002 20:02:13 +0000 Subject: Gcc 3.1.0 pre-release from the FSF anoncvs repo on 9-May-2002 15:57:15 EDT. --- contrib/gcc/builtins.c | 90 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 62 insertions(+), 28 deletions(-) (limited to 'contrib/gcc/builtins.c') diff --git a/contrib/gcc/builtins.c b/contrib/gcc/builtins.c index e3adb05..7eb878f7 100644 --- a/contrib/gcc/builtins.c +++ b/contrib/gcc/builtins.c @@ -2991,37 +2991,54 @@ rtx std_expand_builtin_va_arg (valist, type) tree valist, type; { - tree addr_tree, t; - HOST_WIDE_INT align; - HOST_WIDE_INT rounded_size; + tree addr_tree, t, type_size = NULL; + tree align, alignm1; + tree rounded_size; rtx addr; /* Compute the rounded size of the type. */ - align = PARM_BOUNDARY / BITS_PER_UNIT; - rounded_size = (((int_size_in_bytes (type) + align - 1) / align) * align); + align = size_int (PARM_BOUNDARY / BITS_PER_UNIT); + alignm1 = size_int (PARM_BOUNDARY / BITS_PER_UNIT - 1); + 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 (build (MULT_EXPR, sizetype, + fold (build (TRUNC_DIV_EXPR, sizetype, + fold (build (PLUS_EXPR, sizetype, + type_size, alignm1)), + align)), + align)); /* Get AP. */ addr_tree = valist; - if (PAD_VARARGS_DOWN) + if (PAD_VARARGS_DOWN && ! integer_zerop (rounded_size)) { /* Small args are padded downward. */ - - HOST_WIDE_INT adj - = rounded_size > align ? rounded_size : int_size_in_bytes (type); - - addr_tree = build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree, - build_int_2 (rounded_size - adj, 0)); + addr_tree = fold (build (PLUS_EXPR, TREE_TYPE (addr_tree), addr_tree, + fold (build (COND_EXPR, sizetype, + fold (build (GT_EXPR, sizetype, + rounded_size, + align)), + size_zero_node, + fold (build (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. */ - t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, - build (PLUS_EXPR, TREE_TYPE (valist), valist, - build_int_2 (rounded_size, 0))); - TREE_SIDE_EFFECTS (t) = 1; - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); + if (! integer_zerop (rounded_size)) + { + t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, + build (PLUS_EXPR, TREE_TYPE (valist), valist, + rounded_size)); + TREE_SIDE_EFFECTS (t) = 1; + expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); + } return addr; } @@ -3064,7 +3081,7 @@ expand_builtin_va_arg (valist, type) else if ((promoted_type = (*lang_type_promotes_to) (type)) != NULL_TREE) { const char *name = "", *pname = 0; - static int gave_help; + static bool gave_help; if (TYPE_NAME (type)) { @@ -3083,13 +3100,24 @@ expand_builtin_va_arg (valist, type) pname = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (promoted_type))); } - error ("`%s' is promoted to `%s' when passed through `...'", name, pname); + /* 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 = 1; - error ("(so you should pass `%s' not `%s' to `va_arg')", pname, name); + 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. */ + 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 @@ -3541,6 +3569,18 @@ expand_builtin_expect_jump (exp, if_false_label, if_true_label) return ret; } + +void +expand_builtin_trap () +{ +#ifdef HAVE_trap + if (HAVE_trap) + emit_insn (gen_trap ()); + else +#endif + emit_library_call (abort_libfunc, LCT_NORETURN, VOIDmode, 0); + emit_barrier (); +} /* Expand an expression EXP that calls a built-in function, with result going to TARGET if that's convenient @@ -3875,13 +3915,7 @@ expand_builtin (exp, target, subtarget, mode, ignore) } case BUILT_IN_TRAP: -#ifdef HAVE_trap - if (HAVE_trap) - emit_insn (gen_trap ()); - else -#endif - error ("__builtin_trap not supported by this target"); - emit_barrier (); + expand_builtin_trap (); return const0_rtx; case BUILT_IN_PUTCHAR: -- cgit v1.1