From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13656 invoked by alias); 9 Jul 2004 09:26:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 13641 invoked from network); 9 Jul 2004 09:26:07 -0000 Received: from unknown (HELO mail.polimi.it) (131.175.12.67) by sourceware.org with SMTP; 9 Jul 2004 09:26:07 -0000 Received: from polimi.it (paride.rett.polimi.it [131.175.65.135]) (authenticated bits=0) by mail.polimi.it (Switch-3.0.5/Switch-3.0.0) with ESMTP id i699PwpT026689; Fri, 9 Jul 2004 11:25:59 +0200 (MEST) Message-ID: <40EE6589.8000506@polimi.it> Date: Fri, 09 Jul 2004 09:44:00 -0000 From: Paolo Bonzini User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) MIME-Version: 1.0 To: Paolo Bonzini CC: Richard Henderson , Paolo Bonzini , gcc-patches@gcc.gnu.org Subject: Re: [RFT/RFA] gimplify pa va_arg References: <20040708195110.GC20150@redhat.com> <40EE4596.1090008@polimi.it> <40EE6551.6090603@polimi.it> In-Reply-To: <40EE6551.6090603@polimi.it> Content-Type: multipart/mixed; boundary="------------010703030607010508060007" X-PMX-Version: 4.6.0.99824, Antispam-Core: 4.6.1.104326, Antispam-Data: 2004.7.8.106480 X-PerlMx-Spam: Gauge=%%XPROB%%IIIIIIIII, Probability=9%, Report='UPPERCASE_25_50 0.450, __HAS_MSGID 0, __SANE_MSGID 0, __USER_AGENT 0, X_ACCEPT_LANG 0, __MIME_VERSION 0, __TO_MALFORMED_2 0, __REFERENCES 0, __IN_REP_TO 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __BAT_BOUNDARY 0, __UNUSABLE_MSGID 0, __UPPERCASE_25_50 0, EMAIL_ATTRIBUTION 0, QUOTED_EMAIL_TEXT 0, __MIME_TEXT_ONLY 0, __MOZILLA_MSGID 0, REFERENCES 0.000, IN_REP_TO 0, USER_AGENT 0.000' X-SW-Source: 2004-07/txt/msg00912.txt.bz2 This is a multi-part message in MIME format. --------------010703030607010508060007 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 731 Paolo Bonzini wrote: > And here is the second. This gives several differences for both PA and > PA64 in the struct case. For PA64, it looks like awful optimization on > part of the current mainline GCC (but HPPA assembly is not my forte). > For PA, the only important change is that the frame grows from 64 to 128 > bytes, but again I cannot figure it out. > > I attach two sdiffs to help review. > > Ok for mainline? > > Paolo > > 2004-07-09 Paolo Bonzini > > * config/pa/pa.h (EXPAND_BUILTIN_VA_ARG): Do not define. > * config/pa/pa.c (hppa_gimplify_va_arg_expr): New, based on > hppa_va_arg. Produce GIMPLE in the pre-queue instead of > expanding trees to RTL. ENOPATCH Paolo --------------010703030607010508060007 Content-Type: text/plain; name="gimplify-va-arg-pa.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="gimplify-va-arg-pa.patch" Content-length: 4263 Index: pa.h =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.h,v retrieving revision 1.221 diff -u -r1.221 pa.h --- pa.h 5 Jul 2004 19:49:16 -0000 1.221 +++ pa.h 9 Jul 2004 09:22:56 -0000 @@ -1141,10 +1141,6 @@ #define EXPAND_BUILTIN_VA_START(valist, nextarg) \ hppa_va_start (valist, nextarg) -/* Implement `va_arg'. */ - -#define EXPAND_BUILTIN_VA_ARG(valist, type) \ - hppa_va_arg (valist, type) /* Addressing modes, and classification of registers for them. Index: pa.c =================================================================== RCS file: /cvs/gcc/gcc/gcc/config/pa/pa.c,v retrieving revision 1.255 diff -u -r1.255 pa.c --- pa.c 7 Jul 2004 19:24:34 -0000 1.255 +++ pa.c 9 Jul 2004 09:22:57 -0000 @@ -47,6 +47,7 @@ #include "tm_p.h" #include "target.h" #include "target-def.h" +#include "tree-gimple.h" #undef TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE hook_int_void_1 @@ -142,6 +143,7 @@ static void pa_hpux_init_libfuncs (void); #endif static rtx pa_struct_value_rtx (tree, int); +static tree hppa_gimplify_va_arg_expr (tree, tree, tree *, tree *); /* Save the operands last given to a compare for use when we generate a scc or bcc insn. */ @@ -268,6 +270,9 @@ #undef TARGET_EXPAND_BUILTIN_SAVEREGS #define TARGET_EXPAND_BUILTIN_SAVEREGS hppa_builtin_saveregs +#undef TARGET_GIMPLIFY_VA_ARG_EXPR +#define TARGET_GIMPLIFY_VA_ARG_EXPR hppa_gimplify_va_arg_expr + struct gcc_target targetm = TARGET_INITIALIZER; void @@ -5948,8 +5953,8 @@ std_expand_builtin_va_start (valist, nextarg); } -rtx -hppa_va_arg (tree valist, tree type) +static tree +hppa_gimplify_va_arg_expr (tree valist, tree type, tree *pre_p, tree *post_p) { HOST_WIDE_INT size = int_size_in_bytes (type); HOST_WIDE_INT ofs; @@ -5975,27 +5980,21 @@ t = build (BIT_AND_EXPR, TREE_TYPE (t), t, build_int_2 (-2 * UNITS_PER_WORD, -1)); t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, t); - TREE_SIDE_EFFECTS (t) = 1; - expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL); + gimplify_and_add (t, pre_p); } if (size > 0) - return std_expand_builtin_va_arg (valist, type); + return std_gimplify_va_arg_expr (valist, type, pre_p, post_p); else { ptr = build_pointer_type (type); + pptr = build_pointer_type (ptr); /* Args grow upward. */ t = build (POSTINCREMENT_EXPR, TREE_TYPE (valist), valist, build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0)); - TREE_SIDE_EFFECTS (t) = 1; - - pptr = build_pointer_type (ptr); - t = build1 (NOP_EXPR, pptr, t); - TREE_SIDE_EFFECTS (t) = 1; - - t = build1 (INDIRECT_REF, ptr, t); - TREE_SIDE_EFFECTS (t) = 1; + t = fold_convert (pptr, t); + t = build_fold_indirect_ref (t); } } else /* !TARGET_64BIT */ @@ -6006,16 +6005,12 @@ if (size > 8 || size <= 0) { /* Args grow downward. */ - t = build (PREDECREMENT_EXPR, TREE_TYPE (valist), valist, - build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0)); - TREE_SIDE_EFFECTS (t) = 1; - pptr = build_pointer_type (ptr); - t = build1 (NOP_EXPR, pptr, t); - TREE_SIDE_EFFECTS (t) = 1; - t = build1 (INDIRECT_REF, ptr, t); - TREE_SIDE_EFFECTS (t) = 1; + t = build2 (PREDECREMENT_EXPR, TREE_TYPE (valist), valist, + build_int_2 (POINTER_SIZE / BITS_PER_UNIT, 0)); + t = fold_convert (pptr, t); + t = build_fold_indirect_ref (t); } else { @@ -6028,23 +6023,21 @@ build_int_2 ((size > 4 ? -8 : -4), -1)); t = build (MODIFY_EXPR, TREE_TYPE (valist), valist, t); - TREE_SIDE_EFFECTS (t) = 1; + gimplify_and_add (t, pre_p); ofs = (8 - size) % 4; if (ofs) - { - t = build (PLUS_EXPR, TREE_TYPE (valist), t, - build_int_2 (ofs, 0)); - TREE_SIDE_EFFECTS (t) = 1; - } + t = build (PLUS_EXPR, TREE_TYPE (valist), valist, + build_int_2 (ofs, 0)); + else + t = valist; - t = build1 (NOP_EXPR, ptr, t); - TREE_SIDE_EFFECTS (t) = 1; + t = fold_convert (ptr, t); } } /* Calculate! */ - return expand_expr (t, NULL_RTX, VOIDmode, EXPAND_NORMAL); + return build_fold_indirect_ref (t); } --------------010703030607010508060007--