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

     1  dnl  ARM mpn_cnd_add_n, mpn_cnd_sub_n
     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	 3
    39  C Cortex-A15	 2.5
    40  
    41  define(`cnd',	`r0')
    42  define(`rp',	`r1')
    43  define(`up',	`r2')
    44  define(`vp',	`r3')
    45  
    46  define(`n',	`r12')
    47  
    48  
    49  ifdef(`OPERATION_cnd_add_n', `
    50  	define(`ADDSUB',      adds)
    51  	define(`ADDSUBC',      adcs)
    52  	define(`INITCY',      `cmn	r0, #0')
    53  	define(`RETVAL',      `adc	r0, n, #0')
    54  	define(func,	      mpn_cnd_add_n)')
    55  ifdef(`OPERATION_cnd_sub_n', `
    56  	define(`ADDSUB',      subs)
    57  	define(`ADDSUBC',      sbcs)
    58  	define(`INITCY',      `cmp	r0, #0')
    59  	define(`RETVAL',      `adc	r0, n, #0
    60  			      rsb	r0, r0, #1')
    61  	define(func,	      mpn_cnd_sub_n)')
    62  
    63  MULFUNC_PROLOGUE(mpn_cnd_add_n mpn_cnd_sub_n)
    64  
    65  ASM_START()
    66  PROLOGUE(func)
    67  	push	{r4-r11}
    68  	ldr	n, [sp, #32]
    69  
    70  	cmp	cnd, #1
    71  	sbc	cnd, cnd, cnd		C conditionally set to 0xffffffff
    72  
    73  	INITCY				C really only needed for n = 0 (mod 4)
    74  
    75  	ands	r4, n, #3
    76  	beq	L(top)
    77  	cmp	r4, #2
    78  	bcc	L(b1)
    79  	beq	L(b2)
    80  
    81  L(b3):	ldm	vp!, {r4,r5,r6}
    82  	ldm	up!, {r8,r9,r10}
    83  	bic	r4, r4, cnd
    84  	bic	r5, r5, cnd
    85  	bic	r6, r6, cnd
    86  	ADDSUB	r8, r8, r4
    87  	ADDSUBC	r9, r9, r5
    88  	ADDSUBC	r10, r10, r6
    89  	stm	rp!, {r8,r9,r10}
    90  	sub	n, n, #3
    91  	teq	n, #0
    92  	bne	L(top)
    93  	b	L(end)
    94  
    95  L(b2):	ldm	vp!, {r4,r5}
    96  	ldm	up!, {r8,r9}
    97  	bic	r4, r4, cnd
    98  	bic	r5, r5, cnd
    99  	ADDSUB	r8, r8, r4
   100  	ADDSUBC	r9, r9, r5
   101  	stm	rp!, {r8,r9}
   102  	sub	n, n, #2
   103  	teq	n, #0
   104  	bne	L(top)
   105  	b	L(end)
   106  
   107  L(b1):	ldr	r4, [vp], #4
   108  	ldr	r8, [up], #4
   109  	bic	r4, r4, cnd
   110  	ADDSUB	r8, r8, r4
   111  	str	r8, [rp], #4
   112  	sub	n, n, #1
   113  	teq	n, #0
   114  	beq	L(end)
   115  
   116  L(top):	ldm	vp!, {r4,r5,r6,r7}
   117  	ldm	up!, {r8,r9,r10,r11}
   118  	bic	r4, r4, cnd
   119  	bic	r5, r5, cnd
   120  	bic	r6, r6, cnd
   121  	bic	r7, r7, cnd
   122  	ADDSUBC	r8, r8, r4
   123  	ADDSUBC	r9, r9, r5
   124  	ADDSUBC	r10, r10, r6
   125  	ADDSUBC	r11, r11, r7
   126  	sub	n, n, #4
   127  	stm	rp!, {r8,r9,r10,r11}
   128  	teq	n, #0
   129  	bne	L(top)
   130  
   131  L(end):	RETVAL
   132  	pop	{r4-r11}
   133  	ret	r14
   134  EPILOGUE()