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

     1  dnl  ARM mpn_mod_1_1p
     2  
     3  dnl  Contributed to the GNU project by Torbjörn Granlund.
     4  
     5  dnl  Copyright 2012 Free Software Foundation, Inc.
     6  
     7  dnl  This file is part of the GNU MP Library.
     8  dnl
     9  dnl  The GNU MP Library is free software; you can redistribute it and/or modify
    10  dnl  it under the terms of either:
    11  dnl
    12  dnl    * the GNU Lesser General Public License as published by the Free
    13  dnl      Software Foundation; either version 3 of the License, or (at your
    14  dnl      option) any later version.
    15  dnl
    16  dnl  or
    17  dnl
    18  dnl    * the GNU General Public License as published by the Free Software
    19  dnl      Foundation; either version 2 of the License, or (at your option) any
    20  dnl      later version.
    21  dnl
    22  dnl  or both in parallel, as here.
    23  dnl
    24  dnl  The GNU MP Library is distributed in the hope that it will be useful, but
    25  dnl  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    26  dnl  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    27  dnl  for more details.
    28  dnl
    29  dnl  You should have received copies of the GNU General Public License and the
    30  dnl  GNU Lesser General Public License along with the GNU MP Library.  If not,
    31  dnl  see https://www.gnu.org/licenses/.
    32  
    33  include(`../config.m4')
    34  
    35  C	     cycles/limb
    36  C StrongARM	 -
    37  C XScale	 ?
    38  C Cortex-A7	 ?
    39  C Cortex-A8	 ?
    40  C Cortex-A9	 7
    41  C Cortex-A15	 6
    42  
    43  define(`ap', `r0')
    44  define(`n',  `r1')
    45  define(`d',  `r2')
    46  define(`cps',`r3')
    47  
    48  ASM_START()
    49  PROLOGUE(mpn_mod_1_1p)
    50  	push	{r4-r10}
    51  	add	r0, r0, r1, asl #2
    52  	ldr	r5, [r0, #-4]!
    53  	ldr	r12, [r0, #-4]!
    54  	subs	r1, r1, #2
    55  	ble	L(4)
    56  	ldr	r8, [r3, #12]
    57  	mov	r4, r12
    58  	mov	r10, r5
    59  	umull	r7, r5, r10, r8
    60  	sub	r1, r1, #1
    61  	b	L(mid)
    62  
    63  L(top):	adds	r12, r6, r7
    64  	adcs	r10, r4, r5
    65  	sub	r1, r1, #1
    66  	mov	r6, #0
    67  	movcs	r6, r8
    68  	umull	r7, r5, r10, r8
    69  	adds	r4, r12, r6
    70  	subcs	r4, r4, r2
    71  L(mid):	ldr	r6, [r0, #-4]!
    72  	teq	r1, #0
    73  	bne	L(top)
    74  
    75  	adds	r12, r6, r7
    76  	adcs	r5, r4, r5
    77  	subcs	r5, r5, r2
    78  L(4):	ldr	r1, [r3, #4]
    79  	cmp	r1, #0
    80  	beq	L(7)
    81  	ldr	r4, [r3, #8]
    82  	umull	r0, r6, r5, r4
    83  	adds	r12, r0, r12
    84  	addcs	r6, r6, #1
    85  	rsb	r0, r1, #32
    86  	mov	r0, r12, lsr r0
    87  	orr	r5, r0, r6, asl r1
    88  	mov	r12, r12, asl r1
    89  	b	L(8)
    90  L(7):	cmp	r5, r2
    91  	subcs	r5, r5, r2
    92  L(8):	ldr	r0, [r3, #0]
    93  	umull	r4, r3, r5, r0
    94  	add	r5, r5, #1
    95  	adds	r0, r4, r12
    96  	adc	r5, r3, r5
    97  	mul	r5, r2, r5
    98  	sub	r12, r12, r5
    99  	cmp	r12, r0
   100  	addhi	r12, r12, r2
   101  	cmp	r2, r12
   102  	subls	r12, r12, r2
   103  	mov	r0, r12, lsr r1
   104  	pop	{r4-r10}
   105  	bx	r14
   106  EPILOGUE()
   107  
   108  PROLOGUE(mpn_mod_1_1p_cps)
   109  	stmfd	sp!, {r4, r5, r6, r14}
   110  	mov	r5, r0
   111  	clz	r4, r1
   112  	mov	r0, r1, asl r4
   113  	rsb	r6, r0, #0
   114  	bl	mpn_invert_limb
   115  	str	r0, [r5, #0]
   116  	str	r4, [r5, #4]
   117  	cmp	r4, #0
   118  	beq	L(2)
   119  	rsb	r1, r4, #32
   120  	mov	r3, #1
   121  	mov	r3, r3, asl r4
   122  	orr	r3, r3, r0, lsr r1
   123  	mul	r3, r6, r3
   124  	mov	r4, r3, lsr r4
   125  	str	r4, [r5, #8]
   126  L(2):	mul	r0, r6, r0
   127  	str	r0, [r5, #12]
   128  	ldmfd	sp!, {r4, r5, r6, pc}
   129  EPILOGUE()