github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/x86/atom/logops_n.asm (about)

     1  dnl  Intel Atom mpn_and_n,...,mpn_xnor_n -- bitwise logical operations.
     2  
     3  dnl  Copyright 2011 Free Software Foundation, Inc.
     4  
     5  dnl  Contributed to the GNU project by Marco Bodrato.
     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				op	nop	opn
    37  C P5
    38  C P6 model 0-8,10-12
    39  C P6 model 9  (Banias)
    40  C P6 model 13 (Dothan)
    41  C P4 model 0  (Willamette)
    42  C P4 model 1  (?)
    43  C P4 model 2  (Northwood)
    44  C P4 model 3  (Prescott)
    45  C P4 model 4  (Nocona)
    46  C Intel Atom			 3	 3.5	 3.5
    47  C AMD K6
    48  C AMD K7
    49  C AMD K8
    50  C AMD K10
    51  
    52  define(M4_choose_op,
    53  `ifdef(`OPERATION_$1',`
    54  define(`M4_function', `mpn_$1')
    55  define(`M4_want_pre', `$4')
    56  define(`M4_inst',     `$3')
    57  define(`M4_want_post',`$2')
    58  ')')
    59  define(M4pre, `ifelse(M4_want_pre, yes,`$1')')
    60  define(M4post,`ifelse(M4_want_post,yes,`$1')')
    61  
    62  M4_choose_op( and_n,     , andl,    )
    63  M4_choose_op( andn_n,    , andl, yes)
    64  M4_choose_op( nand_n, yes, andl,    )
    65  M4_choose_op( ior_n,     ,  orl,    )
    66  M4_choose_op( iorn_n,    ,  orl, yes)
    67  M4_choose_op( nior_n, yes,  orl,    )
    68  M4_choose_op( xor_n,     , xorl,    )
    69  M4_choose_op( xnor_n, yes, xorl,    )
    70  
    71  ifdef(`M4_function',,
    72  `m4_error(`Unrecognised or undefined OPERATION symbol
    73  ')')
    74  
    75  MULFUNC_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  
    77  C void M4_function (mp_ptr dst, mp_srcptr src2, mp_srcptr src1, mp_size_t size);
    78  C
    79  
    80  defframe(PARAM_SIZE, 16)
    81  defframe(PARAM_SRC1, 12)
    82  defframe(PARAM_SRC2, 8)
    83  defframe(PARAM_DST,  4)
    84  
    85  dnl  re-use parameter space
    86  define(SAVE_RP,`PARAM_SIZE')
    87  define(SAVE_VP,`PARAM_SRC1')
    88  define(SAVE_UP,`PARAM_DST')
    89  
    90  define(`rp',  `%edi')
    91  define(`up',  `%esi')
    92  define(`vp',  `%ebx')
    93  define(`cnt', `%eax')
    94  define(`r1',  `%ecx')
    95  define(`r2',  `%edx')
    96  
    97  ASM_START()
    98  	TEXT
    99  	ALIGN(16)
   100  deflit(`FRAME',0)
   101  
   102  PROLOGUE(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)
   116  L(oop):
   117  M4pre(`	notl_or_xorl_GMP_NUMB_MASK(r1)')
   118  	M4_inst	(vp), r1
   119  	lea	8(up), up
   120  	mov	-4(up), r2
   121  M4post(`	notl_or_xorl_GMP_NUMB_MASK(r1)')
   122  	lea	8(vp), vp
   123  	mov	r1, (rp)
   124  L(entry):
   125  M4pre(`	notl_or_xorl_GMP_NUMB_MASK(r2)')
   126  	M4_inst	-4(vp), r2
   127  	lea	8(rp), rp
   128  M4post(`	notl_or_xorl_GMP_NUMB_MASK(r2)')
   129  	dec	cnt
   130  	mov	(up), r1
   131  	mov	r2, -4(rp)
   132  	jnz	L(oop)
   133  
   134  L(end):
   135  M4pre(`	notl_or_xorl_GMP_NUMB_MASK(r1)')
   136  	mov	SAVE_UP, up
   137  	M4_inst	(vp), r1
   138  M4post(`notl_or_xorl_GMP_NUMB_MASK(r1)')
   139  	mov	SAVE_VP, vp
   140  	mov	r1, (rp)
   141  	mov	SAVE_RP, rp
   142  	ret
   143  
   144  L(even):
   145  	mov	r1, r2
   146  	lea	4(up), up
   147  	lea	4(vp), vp
   148  	lea	-4(rp), rp
   149  	jmp	L(entry)
   150  EPILOGUE()
   151  ASM_END()