-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Compiler-rt] Implement AEABI Unaligned Read/Write Helpers in compiler-rt #167913
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…r-rt This patch adds implementations for the __aeabi_uread and __aeabi_uwrite helper functions to compiler-rt..
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===-----------------------------------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a good idea to link to the document defining these functions.
https://github.com/ARM-software/abi-aa/blob/main/rtabi32/rtabi32.rst#unaligned-memory-access
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| char v[4]; | ||
| } v4; | ||
|
|
||
| int __aeabi_uread4(void *p) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say that surely the read functions should take a const void *, but in RTABI, they don't! I suppose because nobody ever calls these functions from C, so the C prototype isn't really important, only the machine-level PCS that it translates into.
| extern long long __aeabi_uread8(void *); | ||
| extern long long __aeabi_uwrite8(long long, void *); | ||
|
|
||
| #define lenof(x) (sizeof((x)) / sizeof(*(x))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's 2025, so we can use _Countof for this! \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| long long target8; | ||
| int target4; | ||
| const char source[] = "abcdefghijklmno"; | ||
| static char dest1[lenof(source)], dest2[lenof(source)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why static?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using static is optional. It’s used here mainly to improve reproducibility — since it provides a stable address from which we can repeatably test unaligned writes.
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
🐧 Linux x64 Test Results
|
…compiler-rt Apply clang-format to address style issues in the previous patch.
This patch adds implementations for the __aeabi_uread and __aeabi_uwrite helper functions to compiler-rt..