| 1 |
dnl SPARC v9 mpn_popcount for T3/T4. |
| 2 |
|
| 3 |
dnl Contributed to the GNU project by David Miller. |
| 4 |
|
| 5 |
dnl Copyright 2013 Free Software Foundation, Inc. |
| 6 |
|
| 7 |
dnl This file is part of the GNU MP Library. |
| 8 |
dnl |
| 9 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify |
| 10 |
dnl it under the terms of either: |
| 11 |
dnl |
| 12 |
dnl * the GNU Lesser General Public License as published by the Free |
| 13 |
dnl Software Foundation; either version 3 of the License, or (at your |
| 14 |
dnl option) any later version. |
| 15 |
dnl |
| 16 |
dnl or |
| 17 |
dnl |
| 18 |
dnl * the GNU General Public License as published by the Free Software |
| 19 |
dnl Foundation; either version 2 of the License, or (at your option) any |
| 20 |
dnl later version. |
| 21 |
dnl |
| 22 |
dnl or both in parallel, as here. |
| 23 |
dnl |
| 24 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but |
| 25 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 26 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 27 |
dnl for more details. |
| 28 |
dnl |
| 29 |
dnl You should have received copies of the GNU General Public License and the |
| 30 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not, |
| 31 |
dnl see https://www.gnu.org/licenses/. |
| 32 |
|
| 33 |
include(`../config.m4') |
| 34 |
|
| 35 |
C cycles/limb |
| 36 |
C UltraSPARC T3: 15 |
| 37 |
C UltraSPARC T4: 2.5 |
| 38 |
|
| 39 |
C INPUT PARAMETERS |
| 40 |
define(`up', `%o0') |
| 41 |
define(`n', `%o1') |
| 42 |
define(`pcnt', `%o5') |
| 43 |
|
| 44 |
ASM_START() |
| 45 |
REGISTER(%g2,#scratch) |
| 46 |
REGISTER(%g3,#scratch) |
| 47 |
PROLOGUE(mpn_popcount) |
| 48 |
subcc n, 1, n |
| 49 |
be L(final_one) |
| 50 |
clr pcnt |
| 51 |
L(top): |
| 52 |
ldx [up + 0], %g1 |
| 53 |
sub n, 2, n |
| 54 |
ldx [up + 8], %o4 |
| 55 |
add up, 16, up |
| 56 |
popc %g1, %g2 |
| 57 |
popc %o4, %g3 |
| 58 |
add pcnt, %g2, pcnt |
| 59 |
brgz n, L(top) |
| 60 |
add pcnt, %g3, pcnt |
| 61 |
brlz,pt n, L(done) |
| 62 |
nop |
| 63 |
L(final_one): |
| 64 |
ldx [up + 0], %g1 |
| 65 |
popc %g1, %g2 |
| 66 |
add pcnt, %g2, pcnt |
| 67 |
L(done): |
| 68 |
retl |
| 69 |
mov pcnt, %o0 |
| 70 |
EPILOGUE() |