1dnl Intel Atom mpn_and_n,...,mpn_xnor_n -- bitwise logical operations. 2 3dnl Copyright 2011 Free Software Foundation, Inc. 4 5dnl Contributed to the GNU project by Marco Bodrato. 6 7dnl This file is part of the GNU MP Library. 8dnl 9dnl The GNU MP Library is free software; you can redistribute it and/or modify 10dnl it under the terms of either: 11dnl 12dnl * the GNU Lesser General Public License as published by the Free 13dnl Software Foundation; either version 3 of the License, or (at your 14dnl option) any later version. 15dnl 16dnl or 17dnl 18dnl * the GNU General Public License as published by the Free Software 19dnl Foundation; either version 2 of the License, or (at your option) any 20dnl later version. 21dnl 22dnl or both in parallel, as here. 23dnl 24dnl The GNU MP Library is distributed in the hope that it will be useful, but 25dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 26dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 27dnl for more details. 28dnl 29dnl You should have received copies of the GNU General Public License and the 30dnl GNU Lesser General Public License along with the GNU MP Library. If not, 31dnl see https://www.gnu.org/licenses/. 32 33include(`../config.m4') 34 35C cycles/limb 36C op nop opn 37C P5 38C P6 model 0-8,10-12 39C P6 model 9 (Banias) 40C P6 model 13 (Dothan) 41C P4 model 0 (Willamette) 42C P4 model 1 (?) 43C P4 model 2 (Northwood) 44C P4 model 3 (Prescott) 45C P4 model 4 (Nocona) 46C Intel Atom 3 3.5 3.5 47C AMD K6 48C AMD K7 49C AMD K8 50C AMD K10 51 52define(M4_choose_op, 53`ifdef(`OPERATION_$1',` 54define(`M4_function', `mpn_$1') 55define(`M4_want_pre', `$4') 56define(`M4_inst', `$3') 57define(`M4_want_post',`$2') 58')') 59define(M4pre, `ifelse(M4_want_pre, yes,`$1')') 60define(M4post,`ifelse(M4_want_post,yes,`$1')') 61 62M4_choose_op( and_n, , andl, ) 63M4_choose_op( andn_n, , andl, yes) 64M4_choose_op( nand_n, yes, andl, ) 65M4_choose_op( ior_n, , orl, ) 66M4_choose_op( iorn_n, , orl, yes) 67M4_choose_op( nior_n, yes, orl, ) 68M4_choose_op( xor_n, , xorl, ) 69M4_choose_op( xnor_n, yes, xorl, ) 70 71ifdef(`M4_function',, 72`m4_error(`Unrecognised or undefined OPERATION symbol 73')') 74 75MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n) 76 77C void M4_function (mp_ptr dst, mp_srcptr src2, mp_srcptr src1, mp_size_t size); 78C 79 80defframe(PARAM_SIZE, 16) 81defframe(PARAM_SRC1, 12) 82defframe(PARAM_SRC2, 8) 83defframe(PARAM_DST, 4) 84 85dnl re-use parameter space 86define(SAVE_RP,`PARAM_SIZE') 87define(SAVE_VP,`PARAM_SRC1') 88define(SAVE_UP,`PARAM_DST') 89 90define(`rp', `%edi') 91define(`up', `%esi') 92define(`vp', `%ebx') 93define(`cnt', `%eax') 94define(`r1', `%ecx') 95define(`r2', `%edx') 96 97ASM_START() 98 TEXT 99 ALIGN(16) 100deflit(`FRAME',0) 101 102PROLOGUE(M4_function) 103 mov PARAM_SIZE, cnt C size 104 mov rp, SAVE_RP 105 mov PARAM_DST, rp 106 mov up, SAVE_UP 107 mov PARAM_SRC1, up 108 shr cnt C size >> 1 109 mov vp, SAVE_VP 110 mov PARAM_SRC2, vp 111 mov (up), r1 112 jz L(end) C size == 1 113 jnc L(even) C size % 2 == 0 114 115 ALIGN(16) 116L(oop): 117M4pre(` notl_or_xorl_GMP_NUMB_MASK(r1)') 118 M4_inst (vp), r1 119 lea 8(up), up 120 mov -4(up), r2 121M4post(` notl_or_xorl_GMP_NUMB_MASK(r1)') 122 lea 8(vp), vp 123 mov r1, (rp) 124L(entry): 125M4pre(` notl_or_xorl_GMP_NUMB_MASK(r2)') 126 M4_inst -4(vp), r2 127 lea 8(rp), rp 128M4post(` notl_or_xorl_GMP_NUMB_MASK(r2)') 129 dec cnt 130 mov (up), r1 131 mov r2, -4(rp) 132 jnz L(oop) 133 134L(end): 135M4pre(` notl_or_xorl_GMP_NUMB_MASK(r1)') 136 mov SAVE_UP, up 137 M4_inst (vp), r1 138M4post(`notl_or_xorl_GMP_NUMB_MASK(r1)') 139 mov SAVE_VP, vp 140 mov r1, (rp) 141 mov SAVE_RP, rp 142 ret 143 144L(even): 145 mov r1, r2 146 lea 4(up), up 147 lea 4(vp), vp 148 lea -4(rp), rp 149 jmp L(entry) 150EPILOGUE() 151ASM_END() 152