This is an archive of the discontinued LLVM Phabricator instance.

[builtins] Implement __aeabi_uread4/8 and __aeabi_uwrite4/8.
AcceptedPublic

Authored by efriedma on Oct 11 2018, 3:31 PM.

Details

Summary

These functions are part of the ARM RTABI (http://infocenter.arm.com/help/topic/com.arm.doc.ihi0043d/IHI0043D_rtabi.pdf).

Currently LLVM doesn't generate calls to them, but they could be useful for optimizing for size.

Diff Detail

Event Timeline

efriedma created this revision.Oct 11 2018, 3:31 PM
Herald added subscribers: Restricted Project, kristof.beyls, mgorny. · View Herald Transcript

Nice idea. The rtabi seems to says:

Write functions return the value written, read functions the value read.

With signitures:

int __aeabi_uread4(void *address);
int __aeabi_uwrite4(int value, void *address);
long long __aeabi_uread8(void *address);
long long __aeabi_uwrite8(long long value, void *address);

So writes also return values.

Also, and I kind of trust you know what you are talking about here, but is this using a struct like this always valid? Does packed always means alignment of 1? And is the mayalias needed if the thing we are aliasing with is a char*? (It does make the intent clearer, and the IR looks OK to me.)

The packed/may_alias struct pattern is the same pattern we use in the x86 immintrin.h for unaligned loads; should do the right thing in general.

Does packed always means alignment of 1?

Yes.

And is the mayalias needed if the thing we are aliasing with is a char*?

Well, if we're not doing LTO with compiler-rt (which isn't really something we support anyway), the may_alias does nothing because there aren't any other memory accesses. The type of the pointer isn't really relevant.


Write functions return the value written

Oh, oops, will fix.

efriedma updated this revision to Diff 169472.Oct 12 2018, 12:17 PM

Fixed signature of __aeabi_uwrite4/8.

dmgreen accepted this revision.Oct 12 2018, 1:29 PM

Yeah, I agree. LGTM.

This revision is now accepted and ready to land.Oct 12 2018, 1:29 PM