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

     1  dnl  ARM mpn_mod_34lsub1 -- remainder modulo 2^24-1.
     2  
     3  dnl  Copyright 2012, 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 StrongARM	 ?
    35  C XScale	 ?
    36  C Cortex-A7	 ?
    37  C Cortex-A8	 ?
    38  C Cortex-A9	 1.33
    39  C Cortex-A15	 1.33
    40  
    41  define(`ap',	r0)
    42  define(`n',	r1)
    43  
    44  C mp_limb_t mpn_mod_34lsub1 (mp_srcptr up, mp_size_t n)
    45  
    46  C TODO
    47  C  * Write cleverer summation code.
    48  C  * Consider loading 6 64-bit aligned registers at a time, to approach 1 c/l.
    49  
    50  ASM_START()
    51  	TEXT
    52  	ALIGN(32)
    53  PROLOGUE(mpn_mod_34lsub1)
    54  	push	{ r4, r5, r6, r7 }
    55  
    56  	subs	n, n, #3
    57  	mov	r7, #0
    58  	blt	L(le2)			C n <= 2
    59  
    60  	ldmia	ap!, { r2, r3, r12 }
    61  	subs	n, n, #3
    62  	blt	L(sum)			C n <= 5
    63  	cmn	r0, #0			C clear carry
    64  	sub	n, n, #3
    65  	b	L(mid)
    66  
    67  L(top):	adcs	r2, r2, r4
    68  	adcs	r3, r3, r5
    69  	adcs	r12, r12, r6
    70  L(mid):	ldmia	ap!, { r4, r5, r6 }
    71  	tst	n, n
    72  	sub	n, n, #3
    73  	bpl	L(top)
    74  
    75  	add	n, n, #3
    76  
    77  	adcs	r2, r2, r4
    78  	adcs	r3, r3, r5
    79  	adcs	r12, r12, r6
    80  	movcs	r7, #1			C r7 <= 1
    81  
    82  L(sum):	cmn	n, #2
    83  	movlo	r4, #0
    84  	ldrhs	r4, [ap], #4
    85  	movls	r5, #0
    86  	ldrhi	r5, [ap], #4
    87  
    88  	adds	r2, r2, r4
    89  	adcs	r3, r3, r5
    90  	adcs	r12, r12, #0
    91  	adc	r7, r7, #0		C r7 <= 2
    92  
    93  L(sum2):
    94  	bic	r0, r2, #0xff000000
    95  	add	r0, r0, r2, lsr #24
    96  	add	r0, r0, r7
    97  
    98  	mov	r7, r3, lsl #8
    99  	bic	r1, r7, #0xff000000
   100  	add	r0, r0, r1
   101  	add	r0, r0, r3, lsr #16
   102  
   103  	mov	r7, r12, lsl #16
   104  	bic	r1, r7, #0xff000000
   105  	add	r0, r0, r1
   106  	add	r0, r0, r12, lsr #8
   107  
   108  	pop	{ r4, r5, r6, r7 }
   109  	ret	lr
   110  
   111  L(le2):	cmn	n, #1
   112  	bne	L(1)
   113  	ldmia	ap!, { r2, r3 }
   114  	mov	r12, #0
   115  	b	L(sum2)
   116  L(1):	ldr	r2, [ap]
   117  	bic	r0, r2, #0xff000000
   118  	add	r0, r0, r2, lsr #24
   119  	pop	{ r4, r5, r6, r7 }
   120  	ret	lr
   121  EPILOGUE()