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]

Re: GBR on Hitachi SH


> Hi,
> 
> 	I am writing a small, multitasking operating system for the Hitachi SH1
> processor.  I would like to use the GBR (Global Base Register) as a pointer to
> my current task struct in the kernel but I need to make sure that egcs never
> uses that register normally.  Also, if egcs does not normally use that
> register, is there an asm() directive I can use to make accesses to the current
> task struct efficient?  There are a couple of addressing modes using the GBR
> that would be nice if egcs used.
> 
> For example, if I declare my current pointer as:
> struct task {
> 	struct regset *regs;
> 	int state;
> 	/* ... */
> };
> 
> register struct task *current asm ("gbr");
> 
> and I do:
> current->state = 10;
> 
> Will the compiler be smart enough to generate:
> mov     #10, r0
> mov.l   r0, @(1, GBR)

No.  It doesn't know about gbr-relative adddressing modes.
And even if you teach it about them, you will find that things
that need r0 are tricky, since r0 is also the return register for
integer values, and reload is not particularily good at handling
registers that might be used for returning values.


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