avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AW: AW: [avr-gcc-list] avr-gcc bug: global register variable is brok


From: Ned Konz
Subject: Re: AW: AW: [avr-gcc-list] avr-gcc bug: global register variable is broken
Date: Thu, 2 Dec 2004 12:52:23 -0800
User-agent: KMail/1.7.1

On Wednesday 01 December 2004 11:18 am, Klaus Rudolph wrote:

> There is a general method how gnu handle a list of registers. The
> compiler framework knows really nothing about
> the machine registers. This knowledge comes from the avr specific files
> (Traget Description macros & Functions)
> I think that global registers variables work with other platforms so it
> is no question of compiler design I hope.
> If the bug is general arround all targets, yes, then we have a bigger
> problem. But I think this is also solveable.
> In general, the compiler itself is also only a bit software which could
> be made better :-))))

I have just been playing with the ATTiny15L, which has no RAM. So I must 
declare all globals in registers.

If you look at the macros in the GCC source (in avr.h), you will see that the 
registers that are used by the compiler include:

FIXED_REGISTERS -- r0, r1
CALL_USED_REGISTERS -- r0, r1, r18-27, r30, r31
REG_ALLOC_ORDER -- 24,25, 18,19, 20,21, 22,23, 30,31, 26,27, 28,29, 17-1

And of course r26-r31 are the pointer registers, with the Yreg (28/29) being 
used as the frame pointer.

So it looks like the choices for our use include half of the register space 
(in order by safety):

r2-r15
r16,r17 (these can do operations with constants) 

and I'm not sure about:

r28-r29 (Y reg) (maybe, if you have no stack frame or auto variables, and 
don't call alloca() ?) (probably not too safe).

Also see the definitions of -ffixed-REG, -fcall-used-REG, and 
-fcall-saved-REG, which are mentioned in the header.

Also, the order1 and order2 target switches modify the register allocation 
order (from REG_ALLOC_ORDER to something slightly different).

-- 
Ned Konz
http://bike-nomad.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]