On Sun, May 6, 2012 at 11:41 AM, Richard Sandiford
<rdsandif...@googlemail.com> wrote:
> x32 uses a mixture of MEM address modes for the same address space.
> Some MEMs have SImode addresses, some have DImode.  This means that
> the currently common idiom:
>
>    targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem))
>
> isn't trustworthy.  We have to use the mode of the address if it has one,
> and only fall back on the above for VOIDmode (CONST_INT) addresses.
>
> We actually already have two (identical) functions to calculate
> such a mode.  The patch below puts the function in a more general place
> and uses it instead of the above for rtl-level stuff.
>
> I'm not sure whether what x32 is doing is a good thing, but I like the
> patch anyway because (a) it removes a duplicated function and (b) it at
> least abstracts the concept away.
>
> Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested to
> make sure that there were no differences for cc1 .ii files for MIPS
> n32, o32 and n64.  (I used MIPS to get LO_SUM coverage.)  OK to install?
>
> Richard
>
>
> gcc/
>        PR middle-end/53249
>        * dwarf2out.h (get_address_mode): Move declaration to...
>        * rtl.h: ...here.
>        * dwarf2out.c (get_address_mode): Move definition to...
>        * rtlanal.c: ...here.
>        * var-tracking.c (get_address_mode): Delete.
>        * combine.c (find_split_point): Use get_address_mode instead of
>        targetm.addr_space.address_mode.
>        * cselib.c (cselib_record_sets): Likewise.
>        * dse.c (canon_address, record_store): Likewise.
>        * emit-rtl.c (adjust_address_1, offset_address): Likewise.
>        * expr.c (move_by_pieces, emit_block_move_via_loop, store_by_pieces)
>        (store_by_pieces_1, expand_assignment, store_expr, store_constructor)
>        (expand_expr_real_1): Likewise.
>        * ifcvt.c (noce_try_cmove_arith): Likewise.
>        * optabs.c (maybe_legitimize_operand_same_code): Likewise.
>        * reload.c (find_reloads): Likewise.
>        * sched-deps.c (sched_analyze_1, sched_analyze_2): Likewise.
>        * sel-sched-dump.c (debug_mem_addr_value): Likewise.
>

> Index: gcc/rtlanal.c
> ===================================================================
> --- gcc/rtlanal.c       2012-05-06 16:17:20.000000000 +0100
> +++ gcc/rtlanal.c       2012-05-06 16:17:20.298206160 +0100
> @@ -5279,3 +5279,17 @@ low_bitmask_len (enum machine_mode mode,
>
>   return exact_log2 (m + 1);
>  }
> +
> +/* Return the mode of MEM's address.  */
> +
> +enum machine_mode
> +get_address_mode (rtx mem)
> +{
> +  enum machine_mode mode;
> +
> +  gcc_assert (MEM_P (mem));
> +  mode = GET_MODE (XEXP (mem, 0));
> +  if (mode != VOIDmode)
> +    return mode;
> +  return targetm.addr_space.address_mode (MEM_ADDR_SPACE (mem));
> +}

> Index: gcc/sel-sched-dump.c
> ===================================================================
> --- gcc/sel-sched-dump.c        2012-05-06 16:17:20.000000000 +0100
> +++ gcc/sel-sched-dump.c        2012-05-06 16:17:20.316206160 +0100
> @@ -957,7 +957,7 @@ debug_mem_addr_value (rtx x)
>   enum machine_mode address_mode;
>
>   gcc_assert (MEM_P (x));

You should remove this assert since  get_address_mode does it.

> -  address_mode = targetm.addr_space.address_mode (MEM_ADDR_SPACE (x));
> +  address_mode = get_address_mode (x);
>
>   t = shallow_copy_rtx (x);
>   if (cselib_lookup (XEXP (t, 0), address_mode, 0, GET_MODE (t)))



-- 
H.J.

Reply via email to