This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [middle-end] Add machine_mode to address_cost target hook


Oleg Endo <oleg.endo@t-online.de> writes:
> While experimenting a little bit with an idea for an address mode
> selection RTL pass for SH, I realized that SH's sh_address_cost function
> is quite broken.  When trying to fix it, I ran against a wall, since the
> mode of the MEM is not passed to the target hook function, as it is e.g.
> in legitimate_address.  This circumstance makes it a bit difficult to
> return useful answers in the address_cost hook.  Like on SH,
> displacement address modes for anything < SImode are considered slightly
> more expensive due to increased pressure on R0.
>
> Since everything in the middle-end already seems to pass the mode to the
> 'address_cost' function in rtlanal.c, I'd like to propose to forward the
> mode arg to the target hook.  The change is quite obvious, as it only
> adds one new (mostly) unused argument to the various address_cost
> functions in the targets.

Thanks for doing this.  We should perhaps add the address space too,
but if you don't feel like redoing the whole patch, that can wait until
someone wants it.

>  /* If the target doesn't override, compute the cost as with arithmetic.  */
>  
>  int
> -default_address_cost (rtx x, bool speed)
> +default_address_cost (rtx x, enum machine_mode mode, bool speed)
>  {
>    return rtx_cost (x, MEM, 0, speed);
>  }

Remove the "mode" parameter name because it's unused.  I think this
would trigger a warning otherwise.

OK for the target-independent bits otherwise.  For MIPS:

> Index: gcc/config/mips/mips.c
> ===================================================================
> --- gcc/config/mips/mips.c	(revision 190780)
> +++ gcc/config/mips/mips.c	(working copy)
> @@ -3943,7 +3943,8 @@
>  /* Implement TARGET_ADDRESS_COST.  */
>  
>  static int
> -mips_address_cost (rtx addr, bool speed ATTRIBUTE_UNUSED)
> +mips_address_cost (rtx addr, enum machine_mode mode ATTRIBUTE_UNUSED,
> +		   bool speed ATTRIBUTE_UNUSED)
>  {
>    return mips_address_insns (addr, SImode, false);

Please change this to:

static int
mips_address_cost (rtx addr, enum machine_mode mode,
		   bool speed ATTRIBUTE_UNUSED)
{
  return mips_address_insns (addr, mode, false);
}

MIPS is one of those targets that wanted to know the mode all along.

Richard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]