Skip to content

Commit 66d28e3

Browse files
committed
Added code comments for clarification
1 parent 16d863d commit 66d28e3

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

compiler-rt/test/builtins/Unit/arm/aeabi_idivmod_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ int test__aeabi_idivmod(si_int a, si_int b,
1414
{
1515
si_int rem;
1616
du_int ret = __aeabi_idivmod(a, b);
17+
// __aeabi_idivmod actually returns a struct { quotient; remainder; } using
18+
// value_in_regs calling convention. Due to the ABI rules, struct fields
19+
// come in the same order regardless of endianness. However since the
20+
// result is received here as a 64-bit integer, in which endianness does
21+
// matter, the position of each component (quotient and remainder) varies
22+
// depending on endianness.
1723
# if _YUGA_BIG_ENDIAN
1824
rem = ret & 0xFFFFFFFF;
1925
si_int result = ret >> 32;

compiler-rt/test/builtins/Unit/arm/aeabi_uidivmod_test.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ int test__aeabi_uidivmod(su_int a, su_int b,
1313
su_int expected_result, su_int expected_rem)
1414
{
1515
du_int ret = __aeabi_uidivmod(a, b);
16+
// __aeabi_uidivmod actually returns a struct { quotient; remainder; }
17+
// using value_in_regs calling convention. Due to the ABI rules, struct
18+
// fields come in the same order regardless of endianness. However since
19+
// the result is received here as a 64-bit integer, in which endianness
20+
// does matter, the position of each component (quotient and remainder)
21+
// varies depending on endianness.
1622
# if _YUGA_BIG_ENDIAN
1723
su_int rem = ret & 0xFFFFFFFF;
1824
si_int result = ret >> 32;

compiler-rt/test/builtins/Unit/arm/aeabi_uldivmod_test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ COMPILER_RT_ABI void /* __value_in_regs */ __aeabi_uldivmod(du_int a, du_int b);
1212
int test_aeabi_uldivmod(du_int a, du_int b, du_int expected_q, du_int expected_r)
1313
{
1414
du_int q, r;
15+
// __aeabi_uldivmod returns a struct { quotient; remainder; } using
16+
// value_in_regs calling convention. Each field is a 64-bit integer, so the
17+
// quotient resides in r0 and r1, while the remainder in r2 and r3. The
18+
// byte order however depends on the endianness.
1519
__asm__(
1620
# if _YUGA_BIG_ENDIAN
1721
"movs r1, %Q[a] \n"

0 commit comments

Comments
 (0)