[coldfire-gnu-discuss] Small data sections

David Brown david at westcontrol.com
Tue Jun 26 14:00:01 UTC 2007


Nathan Sidwell wrote:
> David Brown wrote:
>> Just a passing thought...
>>
>> Some gcc targets support the concept of "small data section".  This is 
>> particularly important for 32-bit RISC cpus (like the PPC), were an 
>> addressing mode of the form "Rx + 16bit" can fit in one instruction, 
>> while an absolute 32-bit address takes a lot of messing around to get 
>> the address into a register and then doing the real load or store.  On 
>> a ColdFire, which has absolute long addressing modes, it is not nearly 
>> as important.
> 
> thanks for your suggestion.
> 
> As you probably realize, small data sections are a psABI design 
> feature.  We would be stepping outside of the m68k ABI by adding that to 
> ColdFire.  ABIs that have small data sections generally have a lot of 
> registers -- mips and ppc have 32 integer registers, for instance.  m68k 
> has 8 address registers (arm has 16 registers, and I don't think the ARM 
> EABI has small data references).
> 

Yes, I understand it is outside the ABI.  Clearly, you don't want to 
mess with this sort of thing when working with other software (such as 
ucLinux) - it's mainly for standalone embedded systems with dedicated 
software.

While we are on the subject of ABI, another option that would be at 
least as useful would be parameter passing via registers rather than the 
stack.  This would have a very large impact on the function call 
overhead and be especially for small functions (common in C++ 
programming).  When you have a stack in sdram, the performance cost in 
pushing parameters onto the stack, only to load them again immediately 
afterwards, is very high.  Again, I realise this leads to all sorts of 
complications involving libraries, command-line options, function 
attributes (so that you can mix and match if needed - like "fastcall" 
for the i386 target), etc.

> Whether small data is a win on ColdFire is probably 
> application-specific.  We may get better mileage by teaching the 
> compiler more about instruction costs and using section anchors.  (The 
> m68k port is one of the oldest gcc ports, and its age shows in certain 
> places.)
> 

Section anchors will allow (Ax + 16-bit offset) addressing for blocks of 
data, and is undoubtedly something that will help many types of code on 
many targets, not just the ColdFire.  I gather there is also work going 
on regarding the re-ordering of data in the data sections (or even with 
structs) to take better advantage of cache lines.  But the key point 
about having a small data section is the placement in fast memory, 
rather than the way it is accessed - if section anchors are soon 
realised, then there is probably nothing to be gained by addressing the 
small data in a specific manner.  And yes, the benefits are 
application-specific - again, it is for dedicated embedded software 
running either without an OS, or with a fairly minimal one, since you 
have to be able to specifically place the small data section in internal 
memory to take advantage of it.

mvh.,

David


> nathan




More information about the coldfire-gnu-discuss mailing list