This is the mail archive of the gcc@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: question on 16 bit registers with 32 bit pointers


On Fri, Apr 10, 2009 at 06:29:06PM +0100, Dave Korn wrote:

> Stelian Pop wrote:
> > Hi,
> > 
> > I'm (still) porting GCC to a 16 bit microcontroller, and I'm having a few
> > issues with the way it handles memory accesses: this microcontroller can
> > function in two modes: in one of them the pointers are on 16 bit (a full
> > register), in the second one the pointers are on 32 bit and are stored in
> > two following registers (N and N+1).
> > 
> > I did implement a GCC option to select between the two modes, and I'm using
> > this option to select the size of the pointers and Pmode:
> > 
> > #define Pmode		((TARGET_16) ? HImode : SImode) #define POINTER_SIZE
> > ((TARGET_16) ? 16 : 32)
> > 
> > Do I need to define movsi3(), addsi3() etc. patterns manually or should GCC
> > figure those by itself ?
> 
>   Not sure I understand you.  You always need to define movMM3 etc.  GCC will
> correctly select between movhi3 and movsi3 based on your Pmode macro when
> handling pointers, but you still need to write the patterns.

The thing is that this CPU does not have any real 32 bit registers, or
instructions to do assignments/additions/etc to 32 bit registers. So the 32 bit
operations (on pointers) need to be emulated using the 16 bit components, and I
thought that GCC can do this automatically for me ...

> > Is there something special I need to do to express the relationship between
> > the two registers N and N+1 composing a pointer, or does GCC automatically
> > allocate two subsequent HI registers when it needs a SI one ?
> 
>   GCC always uses consecutive hard regs when doing multi-reg data sizes.  See
> HARD_REGNO_MODE_OK in the internals docs.

Great, thanks !

Stelian.
-- 
Stelian Pop <stelian@popies.net>


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