1dnl S/390-64 mpn_addlsh1_n and mpn_rsblsh1_n. 2 3dnl Copyright 2011 Free Software Foundation, Inc. 4 5dnl This file is part of the GNU MP Library. 6 7dnl The GNU MP Library is free software; you can redistribute it and/or modify 8dnl it under the terms of the GNU Lesser General Public License as published 9dnl by the Free Software Foundation; either version 3 of the License, or (at 10dnl your option) any later version. 11 12dnl The GNU MP Library is distributed in the hope that it will be useful, but 13dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15dnl License for more details. 16 17dnl You should have received a copy of the GNU Lesser General Public License 18dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 20include(`../config.m4') 21 22C cycles/limb 23C z900 9 24C z990 4.75 25C z9 ? 26C z10 ? 27C z196 ? 28 29C TODO 30C * Optimise for small n, avoid 'la' like in aors_n.asm. 31C * Tune to reach 3.5 c/l. For addlsh1, we could let the main alcgr propagate 32C carry to the lsh1 alcgr. 33C * Compute RETVAL for sublsh1_n less stupidly. 34 35C INPUT PARAMETERS 36define(`rp', `%r2') 37define(`up', `%r3') 38define(`vp', `%r4') 39define(`n', `%r5') 40 41ifdef(`OPERATION_addlsh1_n',` 42 define(ADSB, alg) 43 define(ADSBC, alcg) 44 define(INITCY, `lghi %r9, -1') 45 define(RETVAL, `la %r2, 2(%r1,%r9)') 46 define(func, mpn_addlsh1_n) 47') 48ifdef(`OPERATION_rsblsh1_n',` 49 define(ADSB, slg) 50 define(ADSBC, slbg) 51 define(INITCY, `lghi %r9, 0') 52 define(RETVAL,`dnl 53 algr %r1, %r9 54 lghi %r2, 1 55 algr %r2, %r1') 56 define(func, mpn_rsblsh1_n) 57') 58 59MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_rsblsh1_n) 60 61ASM_START() 62PROLOGUE(func) 63 stmg %r6, %r9, 48(%r15) 64 65 aghi n, 3 66 lghi %r7, 3 67 srlg %r0, n, 2 68 ngr %r7, n C n mod 4 69 je L(b1) 70 cghi %r7, 2 71 jl L(b2) 72 jne L(b0) 73 74L(b3): lmg %r5, %r7, 0(vp) 75 la vp, 24(vp) 76 77 algr %r5, %r5 78 alcgr %r6, %r6 79 alcgr %r7, %r7 80 slbgr %r1, %r1 81 82 ADSB %r5, 0(up) 83 ADSBC %r6, 8(up) 84 ADSBC %r7, 16(up) 85 la up, 24(up) 86 slbgr %r9, %r9 87 88 stmg %r5, %r7, 0(rp) 89 la rp, 24(rp) 90 brctg %r0, L(top) 91 j L(end) 92 93L(b0): lghi %r1, -1 94 INITCY 95 j L(top) 96 97L(b1): lg %r5, 0(vp) 98 la vp, 8(vp) 99 100 algr %r5, %r5 101 slbgr %r1, %r1 102 ADSB %r5, 0(up) 103 la up, 8(up) 104 slbgr %r9, %r9 105 106 stg %r5, 0(rp) 107 la rp, 8(rp) 108 brctg %r0, L(top) 109 j L(end) 110 111L(b2): lmg %r5, %r6, 0(vp) 112 la vp, 16(vp) 113 114 algr %r5, %r5 115 alcgr %r6, %r6 116 slbgr %r1, %r1 117 118 ADSB %r5, 0(up) 119 ADSBC %r6, 8(up) 120 la up, 16(up) 121 slbgr %r9, %r9 122 123 stmg %r5, %r6, 0(rp) 124 la rp, 16(rp) 125 brctg %r0, L(top) 126 j L(end) 127 128L(top): lmg %r5, %r8, 0(vp) 129 la vp, 32(vp) 130 131 aghi %r1, 1 C restore carry 132 133 alcgr %r5, %r5 134 alcgr %r6, %r6 135 alcgr %r7, %r7 136 alcgr %r8, %r8 137 138 slbgr %r1, %r1 C save carry 139 140 aghi %r9, 1 C restore carry 141 142 ADSBC %r5, 0(up) 143 ADSBC %r6, 8(up) 144 ADSBC %r7, 16(up) 145 ADSBC %r8, 24(up) 146 la up, 32(up) 147 148 slbgr %r9, %r9 C save carry 149 150 stmg %r5, %r8, 0(rp) 151 la rp, 32(rp) 152 brctg %r0, L(top) 153 154L(end): RETVAL 155 lmg %r6, %r9, 48(%r15) 156 br %r14 157EPILOGUE() 158