Can be gcc portable to architecture without indexed addressing mode?

Tim Rye timjrye@gmail.com
Wed Aug 1 11:57:00 GMT 2012


Hello,

This question is a followup to a previous question asked in March
2010. I am in a similar situation. The original question was:

> Hello.
>
> I have to start to make some c compiler for my own cpu. This cpu has
> very simple core and has many limitations.
>
> I think that many of those limitations are evitable in source coding.
> But I cannot convince a few of them.
>
> Instructions of this cpu core have no indexed addressing mode like
> 'base' + 'offset'.
>
> This cpu can address memories only according to followings.
>
>   immediate addressing
>   indirect addressing with general registers
>
> I really want to know that gcc is portable on this core in spite of
> the limitation.

I too am porting GCC (working on 4.7.1) to a new architecture which
has no indexed addressing mode. I cannot seem to stop GCC from
generating RTL such as (mem:XX (plus:XX (reg:XX ...) (const_int XX))).
This is clearly invalid for a machine with no indexed addressing mode.

I have tried defining the following macros as I think they need to be
defined, but it doesn't seem to work:

#define BASE_REG_CLASS WRITEABLE_REGS
#define MODE_BASE_REG_REG_CLASS(MODE) NO_REGS
#define INDEX_REG_CLASS NO_REGS
#ifdef REG_OK_STRICT
#define REGNO_OK_FOR_BASE_P(NUM) mytarget_regno_ok_for_base_p(NUM,1)
#else
#define REGNO_OK_FOR_BASE_P(NUM) mytarget_regno_ok_for_base_p(NUM,0)
#endif
#define REGNO_MODE_OK_FOR_REG_BASE_P(NUM, MODE) 0
#define REGNO_OK_FOR_INDEX_P(NUM) 0

Are these definitions correct for the situation I describe? And if so,
what else would I need to define to stop GCC using indexed addressing?
Or, if they are not correct, could you describe what I need to do
instead?

My TARGET_LEGITIMATE_ADDRESS_P hook returns false when the code of the
operand is PLUS.

(On 17th March 2010, Andrew Haley answered the above question, saying
that it was possible to port GCC for such a machine, but gave no
indication as to how).

Thanks in advance for your help.



More information about the Gcc-help mailing list