github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/mpn/powerpc64/mode64/p7/aorsorrlshC_n.asm (about)

     1  dnl  PowerPC-64 mpn_addlshC_n, mpn_sublshC_n, mpn_rsblshC_n.
     2  
     3  dnl  Copyright 2003, 2005, 2009, 2010, 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  C                  cycles/limb
    32  C POWER3/PPC630          ?
    33  C POWER4/PPC970          ?
    34  C POWER5                 ?
    35  C POWER6                 ?
    36  C POWER7                 2.5
    37  
    38  C INPUT PARAMETERS
    39  define(`rp', `r3')
    40  define(`up', `r4')
    41  define(`vp', `r5')
    42  define(`n',  `r6')
    43  
    44  ifdef(`DO_add', `
    45    define(`ADDSUBC',	`addc	$1, $2, $3')
    46    define(`ADDSUBE',	`adde	$1, $2, $3')
    47    define(INITCY,	`addic	$1, r1, 0')
    48    define(RETVAL,	`addze	r3, $1')
    49    define(`func',	mpn_addlsh`'LSH`'_n)')
    50  ifdef(`DO_sub', `
    51    define(`ADDSUBC',	`subfc	$1, $2, $3')
    52    define(`ADDSUBE',	`subfe	$1, $2, $3')
    53    define(INITCY,	`addic	$1, r1, -1')
    54    define(RETVAL,	`subfze	r3, $1
    55  			neg	r3, r3')
    56    define(`func',	mpn_sublsh`'LSH`'_n)')
    57  ifdef(`DO_rsb', `
    58    define(`ADDSUBC',	`subfc	$1, $3, $2')
    59    define(`ADDSUBE',	`subfe	$1, $3, $2')
    60    define(INITCY,	`addic	$1, r1, -1')
    61    define(RETVAL,	`addme	r3, $1')
    62    define(`func',	mpn_rsblsh`'LSH`'_n)')
    63  
    64  define(`s0', `r0')  define(`s1', `r9')
    65  define(`u0', `r6')  define(`u1', `r7')
    66  define(`v0', `r10') define(`v1', `r11')
    67  
    68  
    69  ASM_START()
    70  PROLOGUE(func)
    71  	rldic	r7, n, 3, 59
    72  	add	up, up, r7
    73  	add	vp, vp, r7
    74  	add	rp, rp, r7
    75  
    76  ifdef(`DO_add', `
    77  	addic	r0, n, 3	C set cy flag as side effect
    78  ',`
    79  	subfc	r0, r0, r0	C set cy flag
    80  	addi	r0, n, 3
    81  ')
    82  	srdi	r0, r0, 2
    83  	mtctr	r0
    84  
    85  	andi.	r0, n, 1
    86  	beq	L(bx0)
    87  
    88  L(bx1):	andi.	r0, n, 2
    89  	li	s0, 0
    90  	bne	L(lo3)
    91  	b	L(lo1)
    92  
    93  L(bx0):	andi.	r0, n, 2
    94  	li	s1, 0
    95  	bne	L(lo2)
    96  
    97  	ALIGN(32)
    98  L(top):	addi	rp, rp, 32
    99  	ld	v0, 0(vp)
   100  	addi	vp, vp, 32
   101  	rldimi	s1, v0, LSH, 0
   102  	ld	u0, 0(up)
   103  	addi	up, up, 32
   104  	srdi	s0, v0, RSH
   105  	ADDSUBE(s1, s1, u0)
   106  	std	s1, -32(rp)
   107  L(lo3):	ld	v1, -24(vp)
   108  	rldimi	s0, v1, LSH, 0
   109  	ld	u1, -24(up)
   110  	srdi	s1, v1, RSH
   111  	ADDSUBE(s0, s0, u1)
   112  	std	s0, -24(rp)
   113  L(lo2):	ld	v0, -16(vp)
   114  	rldimi	s1, v0, LSH, 0
   115  	ld	u0, -16(up)
   116  	srdi	s0, v0, RSH
   117  	ADDSUBE(s1, s1, u0)
   118  	std	s1, -16(rp)
   119  L(lo1):	ld	v1, -8(vp)
   120  	rldimi	s0, v1, LSH, 0
   121  	ld	u1, -8(up)
   122  	srdi	s1, v1, RSH
   123  	ADDSUBE(s0, s0, u1)
   124  	std	s0, -8(rp)
   125  	bdnz	L(top)		C decrement CTR and loop back
   126  
   127  	RETVAL(	s1)
   128  	blr
   129  EPILOGUE()