[OpenBIOS] [PATCH] ppc: Increase #address-cells for ppc64

Andreas Färber andreas.faerber at web.de
Sun Nov 28 00:36:32 CET 2010

Am 28.11.2010 um 00:19 schrieb Tarl Neustaedter:

> On 2010-11-27 6:01 PM, Andreas Färber wrote:
>> [...]
>> I applied a reworked version in r975, with the PUSH() logic in an  
>> inline function.
>> As mentioned in the commit message, what I failed with was a loop  
>> along the lines of:
>> while (remaining > 0) {
>> PUSH(value);
>> remaining -= sizeof(ucell);
>> value >>= (sizeof(ucell) * 8);
>> }
>> That shift compiles only if sizeof(phys_addr_t) > sizeof(ucell),  
>> i.e. on ppc64.
> That loop seems somewhat overkill, given that sizeof() phys_addr_t  
> and ucell are going to be either 4 or 8. I'd think it would be  
> easier to check for equality to do a single PUSH, otherwise check to  
> make sure two PUSHes will work.

In theory, my-#acells claims to support a maximum of 4 cells. We don't  
use it though, and 128 bits would need special #ifdef handling for  
systems that don't have a native int128_t.

> (We don't support 16-bit ucells any more, do we?)

Not to my knowledge, no.

> Something like:
> if (sizeof(ucell) >= sizeof(phys_addr_t))
>    PUSH(value);
> else {
>    PUSH(value);
>    PUSH(value >> (sizeof(ucell) * 8));
> }

Same problem with the shift here. We don't need a compiler statement  
to optimize this out but a preprocessor statement to not compile it in.

On second thoughts, replacing one shift by two half shifts might trick  
the compiler, but that's even more overkill given that no other  
architecture uses this function yet. Haven't checked whether sparc32  
might benefit.


More information about the OpenBIOS mailing list