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

     1  dnl  S/390-64 mpn_addlsh1_n and mpn_rsblsh1_n.
     2  
     3  dnl  Copyright 2011 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 z900		 9
    35  C z990		 4.75
    36  C z9		 ?
    37  C z10		11
    38  C z196		 ?
    39  
    40  C TODO
    41  C  * Optimise for small n, avoid 'la' like in aors_n.asm.
    42  C  * Tune to reach 3.5 c/l.  For addlsh1, we could let the main alcgr propagate
    43  C    carry to the lsh1 alcgr.
    44  C  * Compute RETVAL for sublsh1_n less stupidly.
    45  
    46  C INPUT PARAMETERS
    47  define(`rp',	`%r2')
    48  define(`up',	`%r3')
    49  define(`vp',	`%r4')
    50  define(`n',	`%r5')
    51  
    52  ifdef(`OPERATION_addlsh1_n',`
    53    define(ADSB,		alg)
    54    define(ADSBC,		alcg)
    55    define(INITCY,	`lghi	%r9, -1')
    56    define(RETVAL,	`la	%r2, 2(%r1,%r9)')
    57    define(func, mpn_addlsh1_n)
    58  ')
    59  ifdef(`OPERATION_rsblsh1_n',`
    60    define(ADSB,		slg)
    61    define(ADSBC,		slbg)
    62    define(INITCY,	`lghi	%r9, 0')
    63    define(RETVAL,`dnl
    64  	algr	%r1, %r9
    65  	lghi	%r2, 1
    66  	algr	%r2, %r1')
    67    define(func, mpn_rsblsh1_n)
    68  ')
    69  
    70  MULFUNC_PROLOGUE(mpn_addlsh1_n mpn_rsblsh1_n)
    71  
    72  ASM_START()
    73  PROLOGUE(func)
    74  	stmg	%r6, %r9, 48(%r15)
    75  
    76  	aghi	n, 3
    77  	lghi	%r7, 3
    78  	srlg	%r0, n, 2
    79  	ngr	%r7, n			C n mod 4
    80  	je	L(b1)
    81  	cghi	%r7, 2
    82  	jl	L(b2)
    83  	jne	L(b0)
    84  
    85  L(b3):	lmg	%r5, %r7, 0(vp)
    86  	la	vp, 24(vp)
    87  
    88  	algr	%r5, %r5
    89  	alcgr	%r6, %r6
    90  	alcgr	%r7, %r7
    91  	slbgr	%r1, %r1
    92  
    93  	ADSB	%r5, 0(up)
    94  	ADSBC	%r6, 8(up)
    95  	ADSBC	%r7, 16(up)
    96  	la	up, 24(up)
    97  	slbgr	%r9, %r9
    98  
    99  	stmg	%r5, %r7, 0(rp)
   100  	la	rp, 24(rp)
   101  	brctg	%r0, L(top)
   102  	j	L(end)
   103  
   104  L(b0):	lghi	%r1, -1
   105  	INITCY
   106  	j	L(top)
   107  
   108  L(b1):	lg	%r5, 0(vp)
   109  	la	vp, 8(vp)
   110  
   111  	algr	%r5, %r5
   112  	slbgr	%r1, %r1
   113  	ADSB	%r5, 0(up)
   114  	la	up, 8(up)
   115  	slbgr	%r9, %r9
   116  
   117  	stg	%r5, 0(rp)
   118  	la	rp, 8(rp)
   119  	brctg	%r0, L(top)
   120  	j	L(end)
   121  
   122  L(b2):	lmg	%r5, %r6, 0(vp)
   123  	la	vp, 16(vp)
   124  
   125  	algr	%r5, %r5
   126  	alcgr	%r6, %r6
   127  	slbgr	%r1, %r1
   128  
   129  	ADSB	%r5, 0(up)
   130  	ADSBC	%r6, 8(up)
   131  	la	up, 16(up)
   132  	slbgr	%r9, %r9
   133  
   134  	stmg	%r5, %r6, 0(rp)
   135  	la	rp, 16(rp)
   136  	brctg	%r0, L(top)
   137  	j	L(end)
   138  
   139  L(top):	lmg	%r5, %r8, 0(vp)
   140  	la	vp, 32(vp)
   141  
   142  	aghi	%r1, 1			C restore carry
   143  
   144  	alcgr	%r5, %r5
   145  	alcgr	%r6, %r6
   146  	alcgr	%r7, %r7
   147  	alcgr	%r8, %r8
   148  
   149  	slbgr	%r1, %r1		C save carry
   150  
   151  	aghi	%r9, 1			C restore carry
   152  
   153  	ADSBC	%r5, 0(up)
   154  	ADSBC	%r6, 8(up)
   155  	ADSBC	%r7, 16(up)
   156  	ADSBC	%r8, 24(up)
   157  	la	up, 32(up)
   158  
   159  	slbgr	%r9, %r9		C save carry
   160  
   161  	stmg	%r5, %r8, 0(rp)
   162  	la	rp, 32(rp)
   163  	brctg	%r0, L(top)
   164  
   165  L(end):	RETVAL
   166  	lmg	%r6, %r9, 48(%r15)
   167  	br	%r14
   168  EPILOGUE()