This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PRE_DEC, POST_INC
Thank you.
> I am assuming you already have basic generation of auto-incs and you
> have your definitions for legitimate{legitimize}_address all set up
> correctly.
Well, I think they are. But the problem could be this. Here are cuts
from the machine description dealing with auto-inc-dec:
#define HAVE_PRE_INCREMENT 0
#define HAVE_PRE_DECREMENT 1
#define HAVE_POST_INCREMENT 1
#define HAVE_POST_DECREMENT 0
int
tam16_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
rtx x, int strict)
{
rtx op1,op2;
/* Post-inc and pre-dec addressing modes allowed. */
if ((GET_CODE (x) == POST_INC || GET_CODE (x) == PRE_DEC)
&& REG_P (XEXP (x, 0))
&& (strict ? REG_OK_FOR_BASE_STRICT_P (XEXP (x, 0))
: REG_OK_FOR_BASE_NOSTRICT_P (XEXP (x, 0)))
/*&& reload_completed*/)
{
return 1;
}
...
The legitimize address function is defined as the legitimate address
function. I took inspiration from msp430's md.
#define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) \
GO_IF_LEGITIMATE_ADDRESS (MODE, X, WIN)
> In this case you could start by tweaking your address costs macros.
I did. Here again I could be wrong in the implementation:
int
tam16_address_costs (rtx x)
{
switch (GET_CODE (x))
{
case REG:
/* (rn) */
return COSTS_N_INSNS (2);
break;
case PLUS:
/* X(rn) */
return COSTS_N_INSNS (4);
break;
case POST_INC:
case PRE_DEC:
/* -(rn) , (rn)+ */
return COSTS_N_INSNS (2);
break;
default:
break;
}
if (CONSTANT_ADDRESS_P (x))
{
return COSTS_N_INSNS (4);
}
/* Unknown addressing mode. */
debug_rtx (x);
return COSTS_N_INSNS (50);
}
According to you, is this enough to enable basic auto-inc-dec in GCC ?
I tried to compile some test-cases I found in emails about the
subject. The result is there is no pre-dec or post-inc generated at
all.
Regards.
Florent