This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: unexpected RTL
Follows up at the end
>> I am working on a new port for a 16bits target, 8 registers.
>>
>> When compiling libgcc2.c I get this error:
>>
>> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c: In function ‘__mulsi3’:
>> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c:566: error: insn does not
>> satisfy its constraints:
>> (insn 122 171 102 ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c:565 (set
>> (mem/c/i:HI (plus:HI (mem/f/c/i:HI (plus:HI (reg/f:HI 5 r5)
>> ? ? ? ? ? ? ? ? ? ? ? ?(const_int 2 [0x2])) [0 D.2445+0 S2 A16])
>> ? ? ? ? ? ? ? ?(const_int 2 [0x2])) [0 <result>+2 S2 A16])
>> ? ? ? ?(reg:HI 0 r0)) 5 {movhi} (nil))
>> ../../../gcc-4.3.3/libgcc/../gcc/libgcc2.c:566: internal compiler
>> error: in final_scan_insn, at final.c:2548
>>
>>
>> According to my GO_IF_LEGITIMATE_ADDRESS, this RTL should not exist.
>> Is it possible that there are not enough registers in the machine ?
>
> This macro and some others like REGNO_OK_FOR_BASE_P have two flavours:
> strict (for strict RTL) and non-strict (for non-strict RTL).
> Strict versions must disallow pseudos that have no hard regs assigned.
These macros are implemented this way:
_____________________________________target.c____________________________________
int
tam16_regno_ok_for_base_p (int r)
{
if (r < FIRST_PSEUDO_REGISTER && r > 0)
return 1;
if (reg_renumber
&& reg_renumber[r] < FIRST_PSEUDO_REGISTER
&& reg_renumber[r] > 0)
return 1;
return 0;
}
int
tam16_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
rtx x, int strict)
{
rtx op1,op2;
if (CONSTANT_ADDRESS_P (x))
return 1;
if (GET_CODE(x) == REG
&& REG_OK_FOR_BASE_P (x))
return 1;
if (GET_CODE(x) == PLUS)
{
op1 = XEXP (x,0);
op2 = XEXP (x,1);
if (GET_CODE (op1) == REG
&& REG_OK_FOR_BASE_P (op1)
&& CONSTANT_ADDRESS_P (op2))
return 1;
if (GET_CODE (op2) == REG
&& REG_OK_FOR_BASE_P (op2)
&& CONSTANT_ADDRESS_P (op1))
return 1;
}
return 0;
}
___________________________________________end_target.c_________________________
_________________________________________target.h_______________________________
#define REGNO_OK_FOR_BASE_P(R) tam16_regno_ok_for_base_p(R)
#ifdef REG_OK_STRICT
# define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \
{ \
if (tam16_legitimate_address_p (mode, operand, 1)) \
goto ADDR; \
}
# else
# define GO_IF_LEGITIMATE_ADDRESS(mode, operand, ADDR) \
{ \
if (tam16_legitimate_address_p (mode, operand, 0)) \
goto ADDR; \
}
#endif
#define REG_OK_FOR_BASE_STRICT_P(X) REGNO_OK_FOR_BASE_P (REGNO (X))
#define REG_OK_FOR_BASE_NOSTRICT_P(X) \
(REGNO (X) >= FIRST_PSEUDO_REGISTER || REG_OK_FOR_BASE_STRICT_P(X))
#ifdef REG_OK_STRICT
# define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_STRICT_P (X)
#else
# define REG_OK_FOR_BASE_P(X) REG_OK_FOR_BASE_NOSTRICT_P (X)
#endif
___________________________________________end_target.h__________________________________
> When gcc runs out of regs it puts values in stack slots: the reg is replaced
> with a mem in reload pass.
According to the error message, the RTL contains memory addressed by
memory. It is not possible according to my
GO_IF_LEGITIMATE_ADDRESS, whatever the mode strict or not.
Do you see something wrong in my implementation?
Is this error due to something else?
Thank you.
Regards.
Florent