Skip to content

[compiler-rt] Fix tests of __aeabi_(idivmod|uidivmod|uldivmod) to support big endian #126277

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

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions compiler-rt/lib/builtins/arm/aeabi_idivmod.S
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ DEFINE_COMPILERRT_FUNCTION(__aeabi_idivmod)
mov r1, r3
#endif
bl SYMBOL_NAME(__divmodsi4)
#if _YUGA_BIG_ENDIAN
mov r1, r0
ldr r0, [sp]
#else
ldr r1, [sp]
#endif
add sp, sp, #4
pop { pc }
#endif // defined(USE_THUMB_1)
Expand Down
5 changes: 5 additions & 0 deletions compiler-rt/lib/builtins/arm/aeabi_uidivmod.S
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,12 @@ LOCAL_LABEL(case_denom_larger):
mov r1, r3
#endif
bl SYMBOL_NAME(__udivmodsi4)
#if _YUGA_BIG_ENDIAN
mov r1, r0
ldr r0, [sp]
#else
ldr r1, [sp]
#endif
add sp, sp, #4
pop { pc }
#endif
Expand Down
19 changes: 16 additions & 3 deletions compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,32 @@ int test_aeabi_uldivmod(du_int a, du_int b, du_int expected_q, du_int expected_r
{
du_int q, r;
__asm__(
# if _YUGA_BIG_ENDIAN
"movs r1, %Q[a] \n"
"movs r0, %R[a] \n"
"movs r3, %Q[b] \n"
"movs r2, %R[b] \n"
# else
"movs r0, %Q[a] \n"
"movs r1, %R[a] \n"
"movs r2, %Q[b] \n"
"movs r3, %R[b] \n"
# endif
"bl __aeabi_uldivmod \n"
# if _YUGA_BIG_ENDIAN
"movs %Q[q], r1\n"
"movs %R[q], r0\n"
"movs %Q[r], r3\n"
"movs %R[r], r2\n"
# else
"movs %Q[q], r0\n"
"movs %R[q], r1\n"
"movs %Q[r], r2\n"
"movs %R[r], r3\n"
: [q] "=r" (q), [r] "=r"(r)
# endif
: [q] "=r"(q), [r] "=r"(r)
: [a] "r"(a), [b] "r"(b)
: "lr", "r0", "r1", "r2", "r3"
);
: "lr", "r0", "r1", "r2", "r3");
if (q != expected_q || r != expected_r)
printf("error in aeabi_uldivmod: %llX / %llX = %llX, R = %llX, expected %llX, %llX\n",
a, b, q, r, expected_q, expected_r);
Expand Down