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: Klaus Rudolph
Subject: Re: AW: AW: [avr-gcc-list] avr-gcc bug: global register variable is broken
Date: Wed, 01 Dec 2004 20:18:51 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.6) Gecko/20040114

Haase Bjoern (PT-BEU/MKP5) * schrieb:

Hi Klaus,

With register r10 for example the compile is totally corrupt. The register r10 is used in a function but not filled in by the caller! This seems to be also a bug. And if lower registers work, why isn´t there any error message or warning?

Because the praised individuals that have spend time on writing the free 
compiler
port probably didn't care about this point.

Sorry, it is my bad english. I don´t want to say that there are bad programmers. I want to say that
we have a problem. It is not a question of fault anyway.

Because of undefined behaviour we must fix this bug. Also the libc doc says nothing against the use of global register vars.

Yes, It is certainly a good idea to add some remarks to the documentation.

I like more to fix the problem :-)

And in addition: I need more then one register above r16 if possible:-)
I have no idea how the internal machine description works, but I think there is something wrong in avr specific implementation.

I will have a look at the code and tell you if I find out something on the constraints. Meanwhile my guess is that the X-Register might work. BTW, in my opinion there is not something
like "wrong" or "right". The compiler simply has been designed for most compact
and efficient C-code. It has not been designed as a solution for your 
non-standard problem. :-(.

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 currently digging into the GCC Internals manual and yes, there is a lot of text :-))

We will see who find the first solution.

Thanks for your ideas

   bye

       Klaus


Yours,

Björn


Haase Bjoern (PT-BEU/MKP5) * schrieb:

Hi,

I have never tried it, but as much as I know, it should be possible to declare one of the lower 
registers for "fixed" purposes. I recommend you to try r2 and/or r3. The compiler will 
certainly not be able to work properly if you declare one of the registers usually being used for 
passing parameters to functions or one of the pointer registers to be "fixed". E.g. the Y 
register is required for the frame pointer.

Yours,

Björn Haase

-----Ursprüngliche Nachricht-----
Von: address@hidden
[mailto:address@hidden Auftrag von Klaus Rudolph
Gesendet: Mittwoch, 1. Dezember 2004 15:49
An: address@hidden
Betreff: [avr-gcc-list] avr-gcc bug: global register variable is broken


Hi all,

it is impossible to define a global register variable in avr-gcc.
The register is used by the compiler on some places and it is really not
preserved.


The actual gnu documentation says:
"Defining a global register variable in a certain register reserves that
register entirely for this use, at least within the current compilation. The
register will not be allocated for any other purpose in the functions in the
current compilation. The register will not be saved and restored by these
functions. Stores into this register are never deleted even if they would
appear to be dead, but references may be deleted or moved or simplified."

I know that it is not ok to call to LIBRARY functions, but it is allowed to
use
all functions which are compiled with the knowledge of the reserved
register.
As a hint the documentation says that it is allowed to recompile all used
library functions with -ffixed-reg option to preserve the register for
use.
The bug is:
It is not possible to define a global register variable because it is used
from
ompiler.
It is impossible to preserve the register with -ffixed-reg option.

Any idea for a workaround? I need some register vars for interrupt handler
:-(

Is there allready a patch available or is this maybe fixed in current CVS
head of release 4.0 in gcc sources?

Thanks
  Klaus














reply via email to

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