From: Richard Sandiford Date: Sun, 18 Nov 2012 17:32:29 +0000 (+0000) Subject: expr.h (adjust_address_1): Add a size parameter. X-Git-Tag: releases/gcc-4.8.0~1938 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f2cbd0debd8670fdf8689891ea0d2e711a2fecd;p=thirdparty%2Fgcc.git expr.h (adjust_address_1): Add a size parameter. 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. From-SVN: r193601 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a64c25f8cbb7..8c7a6a1d6fbb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2012-11-18 Richard Sandiford + + * 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. + 2012-11-18 Richard Sandiford * combine.c (make_extraction): Handle TRUNCATEd INNERs. diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e16215d548e6..27464dab09e0 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -2052,11 +2052,14 @@ change_address (rtx memref, enum machine_mode mode, rtx addr) 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; @@ -2069,8 +2072,14 @@ adjust_address_1 (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset, = targetm.addr_space.pointer_mode (attrs.addrspace); #endif + /* 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; @@ -2155,24 +2164,23 @@ adjust_address_1 (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset, 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); @@ -2190,7 +2198,7 @@ adjust_automodify_address_1 (rtx memref, enum machine_mode mode, rtx addr, 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 @@ -2272,7 +2280,7 @@ replace_equiv_address_nv (rtx memref, rtx addr) 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); diff --git a/gcc/expr.h b/gcc/expr.h index 7ad5f8192e4a..f94f1db2224f 100644 --- a/gcc/expr.h +++ b/gcc/expr.h @@ -557,22 +557,27 @@ extern rtx change_address (rtx, enum machine_mode, rtx); /* 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 @@ extern rtx change_address (rtx, enum machine_mode, rtx); 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);