avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [RFC] Patch adding support for atmega2560-2561


From: Björn Haase
Subject: [avr-libc-dev] [RFC] Patch adding support for atmega2560-2561
Date: Sun, 18 Sep 2005 17:32:59 +0200
User-agent: KMail/1.7.1

Hi,

since there has been quite some discussion about the new large devices. The 
attached patch is a summary of my present working directory for the AVR port.
Yet it does not have reached production quality, but it might help as a base 
of discussion. It includes a number of changes:

1.) Prologue and epilogue now are generated as rtl instead of text. The old 
epilogue code is still there for comparison purpose but it is commented out 
in the assembly output. This part is not sufficiently checked at the moment! 
One will have to have a look at all of these various combinations of compile 
switches (like small stack, nointerrupt, main function, intterupt function, 
signal function, enhanced/not enhanced, etc.). Also it makes use of static 
storage for per-function data (epilogue RTL) and that will be a problem as 
soon as we are supporting nested functions. It also implements a couple of 
ideas suggested by Andy Hutchinson to reduce the prologue size and tries to 
get away with less unspecs than his older patch did.
2.) The SREG is given an own hard register number in order to prepare the 
future cc0-> CCmode transition.
3.) A new family avr6 is introduced for the >128k devices and the required 
changes for adding the atmega2560 and the atmega2561 have been added.
4.) A new variable avr_pc_size is introduced in order to make the 
prologue/epilogue sequence and the offset between the stack pointer and the 
arg pointer depend on the size of the program counter.

5.) A small change in the divmod4 expanders is present that could help to 
avoid two divmod4 calls in case that both division and modulo result are 
used. This however will require an early CSE pass that is currently not 
present (one would need a change in passes.c).
6.) A small code segment has been introduced in order to prepare to use the 
scheduler for reducing register pressure. This part is presently commented 
out (last lines in the machine description file).

7.) Many other minor changes have been introduced, e.g. using define_constant  
for the unspec numbers of the machine description in replacement of the old 
magic numbers.

The method for adding support for the larger devices is the following. The 
function's code is now splitted into two parts for the avr6 devices. A small 
part consisting of one single jump stub per function is placed in the section 
".text 1". The rest of the function resides in the section ".text 2".  For 
these devices ".text 0" is meant to be used for initialized program memory 
data that should end up in the lower 64k. The linker will start with placeing 
the objects of ".text 0", then take the ".text 1" and then the ".text 2" 
data. Drawback of this method is that a jump stub is always generated. Even 
if the function resides in the lower 128k and even if one never takes the 
address of this function. The pattern for the call instructions is changed 
such, that for avr6 it generally jumps directly to the ".text 2" labels in 
order to avoid unnecessary jumping. All indirect calls will make use of the 
address of the jump stub. So each indirect call will result in a sequence of 
two calls.

Yours,

Bjoern 

Attachment: atmega2560.patch
Description: Text Data


reply via email to

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