From patchwork Fri Apr 8 07:36:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carrot Wei X-Patchwork-Id: 90275 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 9B797B6F8D for ; Fri, 8 Apr 2011 17:36:52 +1000 (EST) Received: (qmail 26566 invoked by alias); 8 Apr 2011 07:36:49 -0000 Received: (qmail 26383 invoked by uid 22791); 8 Apr 2011 07:36:48 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_QE, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 08 Apr 2011 07:36:43 +0000 Received: from hpaq12.eem.corp.google.com (hpaq12.eem.corp.google.com [172.25.149.12]) by smtp-out.google.com with ESMTP id p387ageo011192 for ; Fri, 8 Apr 2011 00:36:42 -0700 Received: from yic15 (yic15.prod.google.com [10.243.65.143]) by hpaq12.eem.corp.google.com with ESMTP id p387adhW019372 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 8 Apr 2011 00:36:40 -0700 Received: by yic15 with SMTP id 15so1443647yic.36 for ; Fri, 08 Apr 2011 00:36:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.69.9 with SMTP id r9mr1551621yba.427.1302248199374; Fri, 08 Apr 2011 00:36:39 -0700 (PDT) Received: by 10.150.189.20 with HTTP; Fri, 8 Apr 2011 00:36:39 -0700 (PDT) In-Reply-To: <4D9DA06D.2050106@linaro.org> References: <4D925EA7.2080102@linaro.org> <4D94A47C.5070305@linaro.org> <4D9DA06D.2050106@linaro.org> Date: Fri, 8 Apr 2011 15:36:39 +0800 Message-ID: Subject: Re: [PATCH, ARM] PR47855 Compute attr "length" for some thumb2 insns From: Carrot Wei To: Ramana Radhakrishnan Cc: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org X-System-Of-Record: true 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 moves the length computation of push_multi into a C function to avoid the usage of GNU extension. Tested on qemu without regression. OK to install? thanks Carrot ChangeLog: 2011-04-08 Wei Guozhi PR target/47855 * config/arm/arm-protos.h (arm_attr_length_push_multi): New prototype. * config/arm/arm.c (arm_attr_length_push_multi): New function. * config/arm/arm.md (*push_multi): Change the length computation to call a C function. On Thu, Apr 7, 2011 at 7:30 PM, Ramana Radhakrishnan wrote: > On 07/04/11 12:08, Carrot Wei wrote: >> >> On Thu, Apr 7, 2011 at 5:31 PM, Richard Sandiford >>  wrote: >>> >>> Hi Carrot, >>> >>> Sorry if this has already been reported, but the patch breaks bootstrap >>> of arm-linux-gnueabi (or cross builds with --enable-werror).  The problem >>> is that this... >>> >>> uses a statement expression -- i.e. ({ code; result; }) -- which is >>> a GNU extension. >>> >>> I suppose a simple fix would be to put the code into an arm.c function. >>> >> >> Thank you for the report, I will add this fix to the second part of the >> patch. > > It would be worth unbreaking bootstrap as a separate patch and not > conflating it with a different set of improvements. > > Ramana > >> >> Carrot > > Index: arm.c =================================================================== --- arm.c (revision 172158) +++ arm.c (working copy) @@ -23696,4 +23696,30 @@ arm_preferred_rename_class (reg_class_t return NO_REGS; } +/* Compute the atrribute "length" of insn "*push_multi". + So this function MUST be kept in sync with that insn pattern. */ +int +arm_attr_length_push_multi(rtx parallel_op, rtx first_op) +{ + int i, regno, hi_reg; + int num_saves = XVECLEN (parallel_op, 0); + + /* ARM mode. */ + if (TARGET_ARM) + return 4; + + /* Thumb2 mode. */ + regno = REGNO (first_op); + hi_reg = (REGNO_REG_CLASS (regno) == HI_REGS) && (regno != LR_REGNUM); + for (i = 1; i < num_saves && !hi_reg; i++) + { + regno = REGNO (XEXP (XVECEXP (parallel_op, 0, i), 0)); + hi_reg |= (REGNO_REG_CLASS (regno) == HI_REGS) && (regno != LR_REGNUM); + } + + if (!hi_reg) + return 2; + return 4; +} + #include "gt-arm.h" Index: arm-protos.h =================================================================== --- arm-protos.h (revision 172158) +++ arm-protos.h (working copy) @@ -152,6 +152,7 @@ extern void arm_expand_sync (enum machin extern const char *arm_output_memory_barrier (rtx *); extern const char *arm_output_sync_insn (rtx, rtx *); extern unsigned int arm_sync_loop_insns (rtx , rtx *); +extern int arm_attr_length_push_multi(rtx, rtx); #if defined TREE_CODE extern void arm_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree); Index: arm.md =================================================================== --- arm.md (revision 172158) +++ arm.md (working copy) @@ -10290,27 +10290,7 @@ }" [(set_attr "type" "store4") (set (attr "length") - (if_then_else - (and (ne (symbol_ref "TARGET_THUMB2") (const_int 0)) - (ne (symbol_ref "{ - /* Check if there are any high register (except lr) - references in the list. KEEP the following iteration - in sync with the template above. */ - int i, regno, hi_reg; - int num_saves = XVECLEN (operands[2], 0); - regno = REGNO (operands[1]); - hi_reg = (REGNO_REG_CLASS (regno) == HI_REGS) - && (regno != LR_REGNUM); - for (i = 1; i < num_saves && !hi_reg; i++) - { - regno = REGNO (XEXP (XVECEXP (operands[2], 0, i), 0)); - hi_reg |= (REGNO_REG_CLASS (regno) == HI_REGS) - && (regno != LR_REGNUM); - } - !hi_reg; }") - (const_int 0))) - (const_int 2) - (const_int 4)))] + (symbol_ref "arm_attr_length_push_multi (operands[2], operands[1])"))] ) (define_insn "stack_tie"