From patchwork Mon Jun 14 15:33:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 55555 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 CCC10B7D48 for ; Tue, 15 Jun 2010 01:33:11 +1000 (EST) Received: (qmail 17945 invoked by alias); 14 Jun 2010 15:33:09 -0000 Received: (qmail 17923 invoked by uid 22791); 14 Jun 2010 15:33:06 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SARE_SUB_GETRID, SPF_HELO_PASS, TW_FN, TW_HF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 15:32:57 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5EFWtrw010762 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Jun 2010 11:32:55 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5EFWsXZ017852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Jun 2010 11:32:55 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5EFX1fv017416; Mon, 14 Jun 2010 17:33:01 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5EFX1bJ017414; Mon, 14 Jun 2010 17:33:01 +0200 Date: Mon, 14 Jun 2010 17:33:01 +0200 From: Jakub Jelinek To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Get rid of some further varargs macros (PR bootstrap/44426) Message-ID: <20100614153301.GL7811@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) 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 Hi! This patch gets rid of the remaining #define xxx(...) macros (after the sel_print* patch). build_call_nofold has been used just 11 times, all in builtins.c and generally it was easy to find out the right locus to use. build_call_expr is used more than 3 times that often, so the patch just duplicates the short function. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2010-06-14 Jakub Jelinek PR bootstrap/44426 * tree.h (build_call_expr): Don't define as vararg macro, instead add a prototype. * builtins.c (build_call_nofold): Remove. (expand_builtin_int_roundingfn, expand_builtin_pow, expand_builtin_mempcpy_args, expand_builtin_stpcpy, expand_builtin_memset_args, expand_builtin_strcmp, expand_builtin_strncmp, expand_builtin_memory_chk): Use build_call_nofold_loc instead of build_call_nofold. (build_call_expr): New function. Jakub --- gcc/tree.h.jj 2010-06-14 07:44:24.000000000 +0200 +++ gcc/tree.h 2010-06-14 13:32:36.000000000 +0200 @@ -5017,9 +5017,8 @@ extern bool fold_builtin_next_arg (tree, extern enum built_in_function builtin_mathfn_code (const_tree); extern tree build_function_call_expr (location_t, tree, tree); extern tree fold_builtin_call_array (location_t, tree, tree, int, tree *); -#define build_call_expr(...)\ - build_call_expr_loc (UNKNOWN_LOCATION, __VA_ARGS__) extern tree build_call_expr_loc (location_t, tree, int, ...); +extern tree build_call_expr (tree, int, ...); extern tree mathfn_built_in (tree, enum built_in_function fn); extern tree c_strlen (tree, int); extern tree std_gimplify_va_arg_expr (tree, tree, gimple_seq *, gimple_seq *); --- gcc/builtins.c.jj 2010-06-01 12:27:48.000000000 +0200 +++ gcc/builtins.c 2010-06-14 14:01:08.000000000 +0200 @@ -2521,8 +2521,6 @@ build_call_nofold_loc (location_t loc, t SET_EXPR_LOCATION (fn, loc); return fn; } -#define build_call_nofold(...) \ - build_call_nofold_loc (UNKNOWN_LOCATION, __VA_ARGS__) /* Expand a call to one of the builtin rounding functions gcc defines as an extension (lfloor and lceil). As these are gcc extensions we @@ -2640,7 +2638,7 @@ expand_builtin_int_roundingfn (tree exp, fallback_fndecl = build_fn_decl (name, fntype); } - exp = build_call_nofold (fallback_fndecl, 1, arg); + exp = build_call_nofold_loc (EXPR_LOCATION (exp), fallback_fndecl, 1, arg); tmp = expand_normal (exp); @@ -3085,7 +3083,8 @@ expand_builtin_pow (tree exp, rtx target && (optab_handler (sqrt_optab, mode)->insn_code != CODE_FOR_nothing)))) { - tree call_expr = build_call_nofold (fn, 1, narg0); + tree call_expr = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 1, + narg0); /* Use expand_expr in case the newly built call expression was folded to a non-call. */ op = expand_expr (call_expr, subtarget, mode, EXPAND_NORMAL); @@ -3137,7 +3136,8 @@ expand_builtin_pow (tree exp, rtx target && powi_cost (n/3) <= POWI_MAX_MULTS) || n == 1)) { - tree call_expr = build_call_nofold (fn, 1,narg0); + tree call_expr = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 1, + narg0); op = expand_builtin (call_expr, NULL_RTX, subtarget, mode, 0); if (abs (n) % 3 == 2) op = expand_simple_binop (mode, MULT, op, op, op, @@ -3471,7 +3471,8 @@ expand_builtin_mempcpy_args (tree dest, if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_MEMCPY]) { tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY]; - tree result = build_call_nofold (fn, 3, dest, src, len); + tree result = build_call_nofold_loc (UNKNOWN_LOCATION, fn, 3, + dest, src, len); return expand_expr (result, target, mode, EXPAND_NORMAL); } else @@ -3652,7 +3653,7 @@ expand_builtin_stpcpy (tree exp, rtx tar if (target == const0_rtx && implicit_built_in_decls[BUILT_IN_STRCPY]) { tree fn = implicit_built_in_decls[BUILT_IN_STRCPY]; - tree result = build_call_nofold (fn, 2, dst, src); + tree result = build_call_nofold_loc (loc, fn, 2, dst, src); return expand_expr (result, target, mode, EXPAND_NORMAL); } else @@ -3955,9 +3956,11 @@ expand_builtin_memset_args (tree dest, t fndecl = get_callee_fndecl (orig_exp); fcode = DECL_FUNCTION_CODE (fndecl); if (fcode == BUILT_IN_MEMSET) - fn = build_call_nofold (fndecl, 3, dest, val, len); + fn = build_call_nofold_loc (EXPR_LOCATION (orig_exp), fndecl, 3, + dest, val, len); else if (fcode == BUILT_IN_BZERO) - fn = build_call_nofold (fndecl, 2, dest, len); + fn = build_call_nofold_loc (EXPR_LOCATION (orig_exp), fndecl, 2, + dest, len); else gcc_unreachable (); gcc_assert (TREE_CODE (fn) == CALL_EXPR); @@ -4230,7 +4233,7 @@ expand_builtin_strcmp (tree exp, ATTRIBU do_libcall: #endif fndecl = get_callee_fndecl (exp); - fn = build_call_nofold (fndecl, 2, arg1, arg2); + fn = build_call_nofold_loc (EXPR_LOCATION (exp), fndecl, 2, arg1, arg2); gcc_assert (TREE_CODE (fn) == CALL_EXPR); CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp); return expand_call (fn, target, target == const0_rtx); @@ -4352,7 +4355,8 @@ expand_builtin_strncmp (tree exp, ATTRIB /* Expand the library call ourselves using a stabilized argument list to avoid re-evaluating the function's arguments twice. */ fndecl = get_callee_fndecl (exp); - fn = build_call_nofold (fndecl, 3, arg1, arg2, len); + fn = build_call_nofold_loc (EXPR_LOCATION (exp), fndecl, 3, + arg1, arg2, len); gcc_assert (TREE_CODE (fn) == CALL_EXPR); CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp); return expand_call (fn, target, target == const0_rtx); @@ -10758,6 +10762,26 @@ build_call_expr_loc (location_t loc, tre return fold_builtin_call_array (loc, TREE_TYPE (fntype), fn, n, argarray); } +/* Like build_call_expr_loc (UNKNOWN_LOCATION, ...). Duplicated because + varargs macros aren't supported by all bootstrap compilers. */ + +tree +build_call_expr (tree fndecl, int n, ...) +{ + va_list ap; + tree fntype = TREE_TYPE (fndecl); + tree fn = build1 (ADDR_EXPR, build_pointer_type (fntype), fndecl); + tree *argarray = (tree *) alloca (n * sizeof (tree)); + int i; + + va_start (ap, n); + for (i = 0; i < n; i++) + argarray[i] = va_arg (ap, tree); + va_end (ap); + return fold_builtin_call_array (UNKNOWN_LOCATION, TREE_TYPE (fntype), + fn, n, argarray); +} + /* Construct a CALL_EXPR with type TYPE with FN as the function expression. N arguments are passed in the array ARGARRAY. */ @@ -11848,7 +11872,7 @@ expand_builtin_memory_chk (tree exp, rtx if (! fn) return NULL_RTX; - fn = build_call_nofold (fn, 3, dest, src, len); + fn = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 3, dest, src, len); gcc_assert (TREE_CODE (fn) == CALL_EXPR); CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp); return expand_expr (fn, target, mode, EXPAND_NORMAL); @@ -11896,7 +11920,8 @@ expand_builtin_memory_chk (tree exp, rtx tree fn = built_in_decls[BUILT_IN_MEMCPY_CHK]; if (!fn) return NULL_RTX; - fn = build_call_nofold (fn, 4, dest, src, len, size); + fn = build_call_nofold_loc (EXPR_LOCATION (exp), fn, 4, + dest, src, len, size); gcc_assert (TREE_CODE (fn) == CALL_EXPR); CALL_EXPR_TAILCALL (fn) = CALL_EXPR_TAILCALL (exp); return expand_expr (fn, target, mode, EXPAND_NORMAL);