From patchwork Sat Nov 3 11:14:28 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 196820 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 69FFB2C00DE for ; Sat, 3 Nov 2012 22:14:33 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1352546073; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:To:Mail-Followup-To:Subject:References:Date: In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=pZXGnu0dC1ZSkGC2FDyy gdJBG8I=; b=QrjndWXGDXBu+tv3Zbo1AVu5dEJmVkA3y/gLw7LSejRjQs5SrPSQ Fmckw5spvAomstbjXQm3+yeOJBll4jK/MnyYfPeEhvgdt/+obhMsQqD70D/z2xSy mwxfMBtqDezssmqTJGfr5J/dCWL7JbCKBhtdeZkaGuoZSXXISauOTSY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:To:Mail-Followup-To:Subject:References:Date:In-Reply-To:Message-ID:User-Agent:MIME-Version:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=fUewMLjDJ46qRX9087Td2Dk8tqQYC44juc6Ql5dIrgB2w5qneQJesQaEhuaKAZ dytyvuebDZjJGUsRbiO1TaSKL3UsfDBJf16ZETNoN/jyJu91/gtP9mtiUhx4w9Dv EpYRXUvqOLxxZyDEKMOfSNwxIXZHpwEYdGnlNyBP9s0cg=; Received: (qmail 1004 invoked by alias); 3 Nov 2012 11:14:30 -0000 Received: (qmail 996 invoked by uid 22791); 3 Nov 2012 11:14:29 -0000 X-SWARE-Spam-Status: No, hits=-3.6 required=5.0 tests=AWL, BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_SPAMHAUS_DROP, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-we0-f175.google.com (HELO mail-we0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 03 Nov 2012 11:14:25 +0000 Received: by mail-we0-f175.google.com with SMTP id t44so2046573wey.20 for ; Sat, 03 Nov 2012 04:14:24 -0700 (PDT) Received: by 10.216.200.198 with SMTP id z48mr1503356wen.7.1351941264033; Sat, 03 Nov 2012 04:14:24 -0700 (PDT) Received: from localhost ([2.26.192.222]) by mx.google.com with ESMTPS id hb6sm1936040wib.7.2012.11.03.04.14.22 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Nov 2012 04:14:23 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [2/8] Add adjust_bitfield_address_size References: <87k3u3eybu.fsf@talisman.home> Date: Sat, 03 Nov 2012 11:14:28 +0000 In-Reply-To: <87k3u3eybu.fsf@talisman.home> (Richard Sandiford's message of "Sat, 03 Nov 2012 11:10:45 +0000") Message-ID: <87boffey5n.fsf@talisman.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 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 As mentioned in the covering note, the new memory optabs take a BLKmode reference to the bitfield. That requires a new adjust_bitfield_address interface that takes the size of the reference as a parameter. Tested as described in the covering note. OK to install? Richard gcc/ * expr.h (adjust_address_1): Add a size parameter. (adjust_address, adjust_address_nv, adjust_bitfield_address) (adjust_bitfield_address_nv): Adjust accordingly. (adjust_bitfield_address_size): Define. * emit-rtl.c (adjust_address_1): Add a size parameter. Use it to set the size if MODE has no size. Check whether the size matches before returning the original memref. Require the size to be known for adjust_object. (adjust_automodify_address_1, widen_memory_access): Update calls to adjust_address_1. Index: gcc/expr.h =================================================================== --- gcc/expr.h 2012-11-01 23:06:58.000000000 +0000 +++ gcc/expr.h 2012-11-01 23:12:39.719369067 +0000 @@ -557,22 +557,27 @@ extern rtx change_address (rtx, enum mac /* Return a memory reference like MEMREF, but with its mode changed to MODE and its address offset by OFFSET bytes. */ #define adjust_address(MEMREF, MODE, OFFSET) \ - adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 0) + adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 0, 0) /* Likewise, but the reference is not required to be valid. */ #define adjust_address_nv(MEMREF, MODE, OFFSET) \ - adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 0) + adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 0, 0) /* Return a memory reference like MEMREF, but with its mode changed to MODE and its address offset by OFFSET bytes. Assume that it's for a bitfield and conservatively drop the underlying object if we cannot be sure to stay within its bounds. */ #define adjust_bitfield_address(MEMREF, MODE, OFFSET) \ - adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1) + adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, 0) + +/* As for adjust_bitfield_address, but specify that the width of + BLKmode accesses is SIZE bytes. */ +#define adjust_bitfield_address_size(MEMREF, MODE, OFFSET, SIZE) \ + adjust_address_1 (MEMREF, MODE, OFFSET, 1, 1, 1, SIZE) /* Likewise, but the reference is not required to be valid. */ #define adjust_bitfield_address_nv(MEMREF, MODE, OFFSET) \ - adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 1) + adjust_address_1 (MEMREF, MODE, OFFSET, 0, 1, 1, 0) /* Return a memory reference like MEMREF, but with its mode changed to MODE and its address changed to ADDR, which is assumed to be @@ -585,7 +590,7 @@ #define adjust_automodify_address_nv(MEM adjust_automodify_address_1 (MEMREF, MODE, ADDR, OFFSET, 0) extern rtx adjust_address_1 (rtx, enum machine_mode, HOST_WIDE_INT, int, int, - int); + int, HOST_WIDE_INT); extern rtx adjust_automodify_address_1 (rtx, enum machine_mode, rtx, HOST_WIDE_INT, int); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2012-11-01 23:06:58.000000000 +0000 +++ gcc/emit-rtl.c 2012-11-01 23:15:35.968368637 +0000 @@ -2061,11 +2061,14 @@ change_address (rtx memref, enum machine If ADJUST_OBJECT is zero, the underlying object associated with the memory reference is left unchanged and the caller is responsible for dealing with it. Otherwise, if the new memory reference is outside - the underlying object, even partially, then the object is dropped. */ + the underlying object, even partially, then the object is dropped. + SIZE, if nonzero, is the size of an access in cases where MODE + has no inherent size. */ rtx adjust_address_1 (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset, - int validate, int adjust_address, int adjust_object) + int validate, int adjust_address, int adjust_object, + HOST_WIDE_INT size) { rtx addr = XEXP (memref, 0); rtx new_rtx; @@ -2076,8 +2079,14 @@ adjust_address_1 (rtx memref, enum machi attrs = *get_mem_attrs (memref); + /* Take the size of non-BLKmode accesses from the mode. */ + defattrs = mode_mem_attrs[(int) mode]; + if (defattrs->size_known_p) + size = defattrs->size; + /* If there are no changes, just return the original memory reference. */ if (mode == GET_MODE (memref) && !offset + && (size == 0 || (attrs.size_known_p && attrs.size == size)) && (!validate || memory_address_addr_space_p (mode, addr, attrs.addrspace))) return memref; @@ -2150,24 +2159,23 @@ adjust_address_1 (rtx memref, enum machi attrs.align = MIN (attrs.align, max_align); } - /* We can compute the size in a number of ways. */ - defattrs = mode_mem_attrs[(int) GET_MODE (new_rtx)]; - if (defattrs->size_known_p) + if (size) { /* Drop the object if the new right end is not within its bounds. */ - if (adjust_object && (offset + defattrs->size) > attrs.size) + if (adjust_object && (offset + size) > attrs.size) { attrs.expr = NULL_TREE; attrs.alias = 0; } attrs.size_known_p = true; - attrs.size = defattrs->size; + attrs.size = size; } else if (attrs.size_known_p) { + gcc_assert (!adjust_object); attrs.size -= offset; - /* ??? The store_by_pieces machinery generates negative sizes. */ - gcc_assert (!(adjust_object && attrs.size < 0)); + /* ??? The store_by_pieces machinery generates negative sizes, + so don't assert for that here. */ } set_mem_attrs (new_rtx, &attrs); @@ -2185,7 +2193,7 @@ adjust_automodify_address_1 (rtx memref, HOST_WIDE_INT offset, int validate) { memref = change_address_1 (memref, VOIDmode, addr, validate); - return adjust_address_1 (memref, mode, offset, validate, 0, 0); + return adjust_address_1 (memref, mode, offset, validate, 0, 0, 0); } /* Return a memory reference like MEMREF, but whose address is changed by @@ -2267,7 +2275,7 @@ replace_equiv_address_nv (rtx memref, rt rtx widen_memory_access (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset) { - rtx new_rtx = adjust_address_1 (memref, mode, offset, 1, 1, 0); + rtx new_rtx = adjust_address_1 (memref, mode, offset, 1, 1, 0, 0); struct mem_attrs attrs; unsigned int size = GET_MODE_SIZE (mode);