This is an archive of the discontinued LLVM Phabricator instance.

Add {read,write}{16,32,64}{le,be} functions
Needs RevisionPublic

Authored by ruiu on Feb 26 2015, 6:18 PM.

Details

Summary

Nothing wrong with reinterpret_cast<llvm::support::ulittle32_t *>(loc),
but that's redundant and not great from readability point of view.
The new functions are wrappers for that kind of reinterpet_casts.

Surprisingly or unsurprisingly, there was no use of big endian read
and write. {read,write}{16,32,64}be has no user. But I think they still
worth to be there in the header for completeness.

Diff Detail

Event Timeline

ruiu updated this revision to Diff 20813.Feb 26 2015, 6:18 PM
ruiu retitled this revision from to Add {read,write}{16,32,64}{le,be} functions.
ruiu updated this object.
ruiu edited the test plan for this revision. (Show Details)
ruiu added a project: lld.
ruiu added a subscriber: Unknown Object (MLST).
This revision is now accepted and ready to land.Feb 26 2015, 7:09 PM
davide added a subscriber: davide.Feb 26 2015, 7:13 PM

Seems fine, nice cleanup.

Bigcheese requested changes to this revision.Feb 27 2015, 1:25 PM
Bigcheese added a reviewer: Bigcheese.
Bigcheese added a subscriber: Bigcheese.

These functions already exist llvm/Support/Endian.h as llvm::endian::{read,write}<{u,}int{8,16,32,64}_t, endianness, alignment>. If you would like the short names, typedef these.

This revision now requires changes to proceed.Feb 27 2015, 1:25 PM
ruiu added a comment.Feb 27 2015, 1:33 PM

Can I add the typedefs to llvm/Support/Endian.h? Is that too much?