github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/alpha/aorslsh1_n.asm (about)

     1  dnl  Alpha mpn_addlsh1_n/mpn_sublsh1_n -- rp[] = up[] +- (vp[] << 1).
     2  
     3  dnl  Copyright 2003, 2013 Free Software Foundation, Inc.
     4  
     5  dnl  This file is part of the GNU MP Library.
     6  dnl
     7  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
     8  dnl  it under the terms of either:
     9  dnl
    10  dnl    * the GNU Lesser General Public License as published by the Free
    11  dnl      Software Foundation; either version 3 of the License, or (at your
    12  dnl      option) any later version.
    13  dnl
    14  dnl  or
    15  dnl
    16  dnl    * the GNU General Public License as published by the Free Software
    17  dnl      Foundation; either version 2 of the License, or (at your option) any
    18  dnl      later version.
    19  dnl
    20  dnl  or both in parallel, as here.
    21  dnl
    22  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    23  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    24  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    25  dnl  for more details.
    26  dnl
    27  dnl  You should have received copies of the GNU General Public License and the
    28  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    29  dnl  see https://www.gnu.org/licenses/.
    30  
    31  include(`../config.m4')
    32  
    33  C      cycles/limb
    34  C EV4:     ?
    35  C EV5:     6.25
    36  C EV6:     4.5
    37  
    38  define(`rp',`r16')
    39  define(`up',`r17')
    40  define(`vp',`r18')
    41  define(`n', `r19')
    42  
    43  define(`u0', `r8')
    44  define(`u1', `r1')
    45  define(`v0', `r4')
    46  define(`v1', `r5')
    47  
    48  define(`cy0', `r0')
    49  define(`cy1', `r20')
    50  define(`cy', `r22')
    51  define(`rr', `r24')
    52  define(`ps', `r25')
    53  define(`sl', `r28')
    54  
    55  ifdef(`OPERATION_addlsh1_n',`
    56    define(ADDSUB,       addq)
    57    define(CARRY,       `cmpult $1,$2,$3')
    58    define(func, mpn_addlsh1_n)
    59  ')
    60  ifdef(`OPERATION_sublsh1_n',`
    61    define(ADDSUB,       subq)
    62    define(CARRY,       `cmpult $2,$1,$3')
    63    define(func, mpn_sublsh1_n)
    64  ')
    65  
    66  MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_sublsh1_n)
    67  
    68  ASM_START()
    69  PROLOGUE(func)
    70  	and	n, 2, cy0
    71  	blbs	n, L(bx1)
    72  L(bx0):	ldq	v1, 0(vp)
    73  	ldq	u1, 0(up)
    74  	nop
    75  	bne	cy0, L(b10)
    76  
    77  L(b00):	lda	vp, 48(vp)
    78  	lda	up, -16(up)
    79  	lda	rp, -8(rp)
    80  	br	r31, L(lo0)
    81  
    82  L(b10):	lda	vp, 32(vp)
    83  	lda	rp, 8(rp)
    84  	lda	cy0, 0(r31)
    85  	br	r31, L(lo2)
    86  
    87  L(bx1):	ldq	v0, 0(vp)
    88  	ldq	u0, 0(up)
    89  	lda	cy1, 0(r31)
    90  	beq	cy0, L(b01)
    91  
    92  L(b11):	lda	vp, 40(vp)
    93  	lda	up, -24(up)
    94  	lda	rp, 16(rp)
    95  	br	r31, L(lo3)
    96  
    97  L(b01):	lda	n, -4(n)
    98  	ble	n, L(end)
    99  	lda	vp, 24(vp)
   100  	lda	up, -8(up)
   101  
   102  	ALIGN(16)
   103  L(top):	addq	v0, v0, sl	C left shift vlimb
   104  	ldq	v1, -16(vp)
   105  	ADDSUB	u0, sl, ps	C ulimb + (vlimb << 1)
   106  	cmplt	v0, r31, cy0	C carry out #1
   107  	ldq	u1, 16(up)
   108  	ADDSUB	ps, cy1, rr	C consume carry from previous operation
   109  	CARRY(	ps, u0, cy)	C carry out #2
   110  	stq	rr, 0(rp)
   111  	addq	cy, cy0, cy0	C combine carry out #1 and #2
   112  	CARRY(	rr, ps, cy)	C carry out #3
   113  	addq	cy, cy0, cy0	C final carry out
   114  	lda	vp, 32(vp)	C bookkeeping
   115  L(lo0):	addq	v1, v1, sl
   116  	ldq	v0, -40(vp)
   117  	ADDSUB	u1, sl, ps
   118  	cmplt	v1, r31, cy1
   119  	ldq	u0, 24(up)
   120  	ADDSUB	ps, cy0, rr
   121  	CARRY(	ps, u1, cy)
   122  	stq	rr, 8(rp)
   123  	addq	cy, cy1, cy1
   124  	CARRY(	rr, ps, cy)
   125  	addq	cy, cy1, cy1
   126  	lda	rp, 32(rp)	C bookkeeping
   127  L(lo3):	addq	v0, v0, sl
   128  	ldq	v1, -32(vp)
   129  	ADDSUB	u0, sl, ps
   130  	cmplt	v0, r31, cy0
   131  	ldq	u1, 32(up)
   132  	ADDSUB	ps, cy1, rr
   133  	CARRY(	ps, u0, cy)
   134  	stq	rr, -16(rp)
   135  	addq	cy, cy0, cy0
   136  	CARRY(	rr, ps, cy)
   137  	addq	cy, cy0, cy0
   138  	lda	up, 32(up)	C bookkeeping
   139  L(lo2):	addq	v1, v1, sl
   140  	ldq	v0, -24(vp)
   141  	ADDSUB	u1, sl, ps
   142  	cmplt	v1, r31, cy1
   143  	ldq	u0, 8(up)
   144  	ADDSUB	ps, cy0, rr
   145  	CARRY(	ps, u1, cy)
   146  	stq	rr, -8(rp)
   147  	addq	cy, cy1, cy1
   148  	CARRY(	rr, ps, cy)
   149  	addq	cy, cy1, cy1
   150  	lda	n, -4(n)	C bookkeeping
   151  	bgt	n, L(top)
   152  
   153  L(end):	addq	v0, v0, sl
   154  	ADDSUB	u0, sl, ps
   155  	ADDSUB	ps, cy1, rr
   156  	cmplt	v0, r31, cy0
   157  	CARRY(	ps, u0, cy)
   158  	stq	rr, 0(rp)
   159  	addq	cy, cy0, cy0
   160  	CARRY(	rr, ps, cy)
   161  	addq	cy, cy0, r0
   162  	ret	r31,(r26),1
   163  EPILOGUE()
   164  ASM_END()