summaryrefslogtreecommitdiffstats
path: root/lib/arm_support/support-arm.S
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arm_support/support-arm.S')
-rw-r--r--lib/arm_support/support-arm.S53
1 files changed, 29 insertions, 24 deletions
diff --git a/lib/arm_support/support-arm.S b/lib/arm_support/support-arm.S
index df49dc49e8..3af0c70975 100644
--- a/lib/arm_support/support-arm.S
+++ b/lib/arm_support/support-arm.S
@@ -227,7 +227,7 @@
/* Test whether divisor is 2^N */
cmp \inv, #1<<31
/* Load approximate reciprocal */
- ldrhib \inv, [\neg, #.L_udiv_est_table-.-64]
+ ldrbhi \inv, [\neg, #.L_udiv_est_table-.-64]
bls 20f
subs \bits, \bits, #7
rsb \neg, \divisor, #0
@@ -676,8 +676,8 @@ __udivsi3:
.size __udivsi3, . - __udivsi3
__divsi3:
- str lr, [sp, #-4]
- ARMV5_SDIV32_BODY r0, r1, r0, "", r2, lr, ip, r3, __div0_wrap_s, "ldr pc, [sp, #-4]"
+ push {lr}
+ ARMV5_SDIV32_BODY r0, r1, r0, "", r2, lr, ip, r3, __div0_wrap_s, "pop {pc}"
.size __divsi3, . - __divsi3
#else
@@ -686,8 +686,8 @@ __aeabi_uidivmod:
.size __aeabi_uidivmod, . - __aeabi_uidivmod
__aeabi_idivmod:
- str lr, [sp, #-4]
- ARMV5_SDIV32_BODY r0, r1, r0, r1, r2, lr, ip, r3, __div0_wrap_s, "ldr pc, [sp, #-4]"
+ push {lr}
+ ARMV5_SDIV32_BODY r0, r1, r0, r1, r2, lr, ip, r3, __div0_wrap_s, "pop {pc}"
.size __aeabi_idivmod, . - __aeabi_idivmod
#endif
@@ -705,6 +705,9 @@ __aeabi_idivmod:
/*
* int __popcountsi2(unsigned int x)
* int __popcountdi2(unsigned long x)
+ * x = x - ((x >> 1) & 0x55555555);
+ * x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+ * c = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
*/
.section .text.__popcountsi2, "ax", %progbits
.global __popcountsi2
@@ -712,23 +715,25 @@ __aeabi_idivmod:
.global __popcountdi2
.type __popcountdi2, %function
.set __popcountdi2, __popcountsi2
+
__popcountsi2:
- mov r1, #0x33 @ r1 = 0x33333333
- orr r1, r1, r1, lsl #8 @ ...
- orr r1, r1, r1, lsl #16 @ ...
- eor r2, r1, r1, lsl #1 @ r2 = 0x55555555
- and r2, r2, r0, lsr #1 @ r2 = (x >> 1) & 0x55555555
- sub r0, r0, r2 @ x = x - ((x >> 1) & 0x55555555)
- and r2, r1, r0 @ r2 = x & 0x33333333
- and r1, r1, r0, lsr #2 @ r1 = (x >> 2) & 0x33333333
- add r0, r2, r1 @ x = (x & 0x33333333) + ((x >> 2) & 0x33333333)
- mov r1, #0x0f @ r1 = 0x0f0f0f0f
- orr r1, r1, r1, lsl #8 @ ...
- orr r1, r1, r1, lsl #16 @ ...
- add r0, r0, lsr #4 @ x = x + (x >> 4)
- and r0, r0, r1 @ x = (x + (x >> 4)) & 0x0f0f0f0f
- add r0, r0, lsr #16 @ x = x + (x >> 16)
- add r0, r0, lsr #8 @ x = x + (x >> 8)
- and r0, r0, #0x3f @ x &= 0x3f
- bx lr @ return x
- .size __popcountsi2, .-__popcountsi2
+ ldr r2, .L2 @ r2 = 0x55555555
+ ldr r3, .L2+4 @ r3 = 0x33333333
+ and r2, r2, r0, lsr #1 @ r2 = (x >> 1)
+ rsb r2, r2, r0 @ x = x - ((x >> 1) & 0x55555555)
+ and r0, r2, r3
+ and r3, r3, r2, lsr #2 @ r3 = (x >> 2)
+ add r0, r0, r3
+ ldr r3, .L2+8 @ r3 = 0xF0F0F0F
+ add r0, r0, r0, lsr #4 @ x = x + (x >> 4)
+ and r3, r0, r3
+ add r3, r3, r3, asl #8
+ add r3, r3, r3, asl #16
+ mov r0, r3, lsr #24 @ (r3 >> 24)
+ bx lr
+.L2:
+ .word 0x55555555
+ .word 0x33333333
+ .word 0xF0F0F0F
+ .size __popcountsi2, .-__popcountsi2
+