libffi: Simplify PowerPC assembly and avoid CPU-specific string instructions

Anthony Green green@moxielogic.com
Sat Nov 12 20:56:00 GMT 2011


On 11/1/2011 4:55 PM, Moffett, Kyle D wrote:
> On Nov 01, 2011, at 11:53, Kyle Moffett wrote:
>> After upgrading to a new version of GNU ld for PowerPC e500, I started
>> seeing build errors on e500 systems again.  It turns out that the
>> PowerPC "string instructions" are unimplemented on PPC440 and most other
>> embedded cores, and also cause unexpectedly high instruction latencies
>> and pipeline stalls even on POWER processors.
>>
>> This historically worked in the past because the unknown string opcodes
>> are trapped on PPC440 and similar systems and emulated in the kernel,
>> though that is obviously very inefficient and undesirable.
>>
>> Since the struct-copy code doesn't really need to be implemented in
>> assembly, this patch ensures that there is always enough space to store
>> both r3 and r4 and then uses C to extract the 1-8 byte "small struct"
>> into the user-provided memory.
>>
>> Even with all the big new comments, it's still removes 11 lines of code,
>> and the ASM is much simpler and easier to understand now.
>>
>> Please consider applying.
>


I like this patch, and have applied it after a minor tweak (cache 
cif->rtype->size in a local var to avoid multiple accesses).

Thanks!

AG



More information about the Libffi-discuss mailing list