1 dnl SPARC T3/T4/T5 mpn_bdiv_q_1. 2 3 dnl Contributed to the GNU project by Torbjrn Granlund. 4 5 dnl Copyright 2013, 2017 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: 31 37 C UltraSPARC T4/T5: 20-26 hits 20 early, then sharply drops 38 39 C INPUT PARAMETERS 40 define(`qp', `%i0') 41 define(`ap', `%i1') 42 define(`n', `%i2') 43 define(`d', `%i3') 44 define(`dinv',`%i4') 45 define(`cnt', `%i5') 46 47 define(`tnc', `%o2') 48 49 ASM_START() 50 REGISTER(%g2,#scratch) 51 REGISTER(%g3,#scratch) 52 PROLOGUE(mpn_bdiv_q_1) 53 save %sp, -176, %sp 54 ldx [ap], %o5 55 add d, -1, %g1 56 andn %g1, d, %g1 57 popc %g1, cnt 58 59 srlx d, cnt, d 60 srlx d, 1, %g1 61 and %g1, 127, %g1 62 LEA64(binvert_limb_table, g2, g4) 63 ldub [%g2+%g1], %g1 64 add %g1, %g1, %g2 65 mulx %g1, %g1, %g1 66 mulx %g1, d, %g1 67 sub %g2, %g1, %g2 68 add %g2, %g2, %g1 69 mulx %g2, %g2, %g2 70 mulx %g2, d, %g2 71 sub %g1, %g2, %g1 72 add %g1, %g1, %o7 73 mulx %g1, %g1, %g1 74 mulx %g1, d, %g1 75 add n, -2, n 76 brz,pt cnt, L(norm) 77 sub %o7, %g1, dinv 78 79 brlz,pt n, L(edu) 80 srlx %o5, cnt, %o5 81 b L(eee) 82 mov 0, %g4 83 EPILOGUE() 84 85 PROLOGUE(mpn_pi1_bdiv_q_1) 86 save %sp, -176, %sp 87 ldx [ap], %o5 88 89 brz,pt cnt, L(norm) 90 add n, -2, n 91 92 L(unorm): 93 brlz,pt n, L(edu) 94 srlx %o5, cnt, %o5 95 mov 0, %g4 96 L(eee): sub %g0, cnt, tnc 97 98 L(tpu): ldx [ap+8], %g3 99 add ap, 8, ap 100 sllx %g3, tnc, %g5 101 or %g5, %o5, %g5 102 srlx %g3, cnt, %o5 103 subcc %g5, %g4, %g4 104 mulx %g4, dinv, %g1 105 stx %g1, [qp] 106 add qp, 8, qp 107 umulxhi(d, %g1, %g1) 108 addxc( %g1, %g0, %g4) 109 brgz,pt n, L(tpu) 110 add n, -1, n 111 112 sub %o5, %g4, %o5 113 L(edu): mulx %o5, dinv, %g1 114 return %i7+8 115 stx %g1, [%o0] 116 117 L(norm): 118 mulx dinv, %o5, %g1 119 brlz,pt n, L(edn) 120 stx %g1, [qp] 121 add qp, 8, qp 122 addcc %g0, 0, %g4 123 124 L(tpn): umulxhi(d, %g1, %g1) 125 ldx [ap+8], %g5 126 add ap, 8, ap 127 addxc( %g1, %g0, %g1) 128 subcc %g5, %g1, %g1 129 mulx %g1, dinv, %g1 130 stx %g1, [qp] 131 add qp, 8, qp 132 brgz,pt n, L(tpn) 133 add n, -1, n 134 135 L(edn): return %i7+8 136 nop 137 EPILOGUE() 138