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

     1  dnl  S/390-64 mpn_mul_basecase.
     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		 ?
    35  C z990		23
    36  C z9		 ?
    37  C z10		28
    38  C z196		 ?
    39  
    40  C TODO
    41  C  * Perhaps add special case for un <= 2.
    42  C  * Replace loops by faster code.  The mul_1 and addmul_1 loops could be sped
    43  C    up by about 10%.
    44  
    45  C INPUT PARAMETERS
    46  define(`rp',	`%r2')
    47  define(`up',	`%r3')
    48  define(`un',	`%r4')
    49  define(`vp',	`%r5')
    50  define(`vn',	`%r6')
    51  
    52  define(`zero',	`%r8')
    53  
    54  ASM_START()
    55  PROLOGUE(mpn_mul_basecase)
    56  	cghi	un, 2
    57  	jhe	L(ge2)
    58  
    59  C un = vn = 1
    60  	lg	%r1, 0(vp)
    61  	mlg	%r0, 0(up)
    62  	stg	%r1, 0(rp)
    63  	stg	%r0, 8(rp)
    64  	br	%r14
    65  
    66  L(ge2):	C jne	L(gen)
    67  
    68  
    69  L(gen):
    70  C mul_1 =======================================================================
    71  
    72  	stmg	%r6, %r12, 48(%r15)
    73  	lghi	zero, 0
    74  	aghi	un, -1
    75  
    76  	lg	%r7, 0(vp)
    77  	lg	%r11, 0(up)
    78  	lghi	%r12, 8			C init index register
    79  	mlgr	%r10, %r7
    80  	lgr	%r9, un
    81  	stg	%r11, 0(rp)
    82  	cr	%r15, %r15		C clear carry flag
    83  
    84  L(tm):	lg	%r1, 0(%r12,up)
    85  	mlgr	%r0, %r7
    86  	alcgr	%r1, %r10
    87  	lgr	%r10, %r0		C copy high part to carry limb
    88  	stg	%r1, 0(%r12,rp)
    89  	la	%r12, 8(%r12)
    90  	brctg	%r9, L(tm)
    91  
    92  	alcgr	%r0, zero
    93  	stg	%r0, 0(%r12,rp)
    94  
    95  C addmul_1 loop ===============================================================
    96  
    97  	aghi	vn, -1
    98  	je	L(outer_end)
    99  L(outer_loop):
   100  
   101  	la	rp, 8(rp)		C rp += 1
   102  	la	vp, 8(vp)		C up += 1
   103  	lg	%r7, 0(vp)
   104  	lg	%r11, 0(up)
   105  	lghi	%r12, 8			C init index register
   106  	mlgr	%r10, %r7
   107  	lgr	%r9, un
   108  	alg	%r11, 0(rp)
   109  	stg	%r11, 0(rp)
   110  
   111  L(tam):	lg	%r1, 0(%r12,up)
   112  	lg	%r11, 0(%r12,rp)
   113  	mlgr	%r0, %r7
   114  	alcgr	%r1, %r11
   115  	alcgr	%r0, zero
   116  	algr	%r1, %r10
   117  	lgr	%r10, %r0
   118  	stg	%r1, 0(%r12,rp)
   119  	la	%r12, 8(%r12)
   120  	brctg	%r9, L(tam)
   121  
   122  	alcgr	%r0, zero
   123  	stg	%r0, 0(%r12,rp)
   124  
   125  	brctg	vn, L(outer_loop)
   126  L(outer_end):
   127  
   128  	lmg	%r6, %r12, 48(%r15)
   129  	br	%r14
   130  EPILOGUE()