diff options
-rw-r--r-- | lib/arm_support/support-arm.S | 43 |
1 files changed, 24 insertions, 19 deletions
diff --git a/lib/arm_support/support-arm.S b/lib/arm_support/support-arm.S index 442a629fca..f99d086b0b 100644 --- a/lib/arm_support/support-arm.S +++ b/lib/arm_support/support-arm.S | |||
@@ -705,6 +705,9 @@ __aeabi_idivmod: | |||
705 | /* | 705 | /* |
706 | * int __popcountsi2(unsigned int x) | 706 | * int __popcountsi2(unsigned int x) |
707 | * int __popcountdi2(unsigned long x) | 707 | * int __popcountdi2(unsigned long x) |
708 | * x = x - ((x >> 1) & 0x55555555); | ||
709 | * x = (x & 0x33333333) + ((x >> 2) & 0x33333333); | ||
710 | * c = ((x + (x >> 4) & 0xF0F0F0F) * 0x1010101) >> 24; | ||
708 | */ | 711 | */ |
709 | .section .text.__popcountsi2, "ax", %progbits | 712 | .section .text.__popcountsi2, "ax", %progbits |
710 | .global __popcountsi2 | 713 | .global __popcountsi2 |
@@ -712,23 +715,25 @@ __aeabi_idivmod: | |||
712 | .global __popcountdi2 | 715 | .global __popcountdi2 |
713 | .type __popcountdi2, %function | 716 | .type __popcountdi2, %function |
714 | .set __popcountdi2, __popcountsi2 | 717 | .set __popcountdi2, __popcountsi2 |
718 | |||
715 | __popcountsi2: | 719 | __popcountsi2: |
716 | mov r1, #0x33 @ r1 = 0x33333333 | 720 | ldr r2, .L2 @ r2 = 0x55555555 |
717 | orr r1, r1, r1, lsl #8 @ ... | 721 | ldr r3, .L2+4 @ r3 = 0x33333333 |
718 | orr r1, r1, r1, lsl #16 @ ... | 722 | and r2, r2, r0, lsr #1 @ r2 = (x >> 1) |
719 | eor r2, r1, r1, lsl #1 @ r2 = 0x55555555 | 723 | rsb r2, r2, r0 @ x = x - ((x >> 1) & 0x55555555) |
720 | and r2, r2, r0, lsr #1 @ r2 = (x >> 1) & 0x55555555 | 724 | and r0, r2, r3 |
721 | sub r0, r0, r2 @ x = x - ((x >> 1) & 0x55555555) | 725 | and r3, r3, r2, lsr #2 @ r3 = (x >> 2) |
722 | and r2, r1, r0 @ r2 = x & 0x33333333 | 726 | add r0, r0, r3 |
723 | and r1, r1, r0, lsr #2 @ r1 = (x >> 2) & 0x33333333 | 727 | ldr r3, .L2+8 @ r3 = 0xF0F0F0F |
724 | add r0, r2, r1 @ x = (x & 0x33333333) + ((x >> 2) & 0x33333333) | 728 | add r0, r0, r0, lsr #4 @ x = x + (x >> 4) |
725 | mov r1, #0x0f @ r1 = 0x0f0f0f0f | 729 | and r3, r0, r3 |
726 | orr r1, r1, r1, lsl #8 @ ... | 730 | add r3, r3, r3, asl #8 |
727 | orr r1, r1, r1, lsl #16 @ ... | 731 | add r3, r3, r3, asl #16 |
728 | add r0, r0, lsr #4 @ x = x + (x >> 4) | 732 | mov r0, r3, lsr #24 @ (r3 >> 24) |
729 | and r0, r0, r1 @ x = (x + (x >> 4)) & 0x0f0f0f0f | 733 | bx lr |
730 | add r0, r0, lsr #16 @ x = x + (x >> 16) | 734 | .L2: |
731 | add r0, r0, lsr #8 @ x = x + (x >> 8) | 735 | .word 0x55555555 |
732 | and r0, r0, #0x3f @ x &= 0x3f | 736 | .word 0x33333333 |
733 | bx lr @ return x | 737 | .word 0xF0F0F0F |
734 | .size __popcountsi2, .-__popcountsi2 | 738 | .size __popcountsi2, .-__popcountsi2 |
739 | |||