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

     1  dnl  ARM mpn_rsh1add_n and mpn_rsh1sub_n.
     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	3.64-3.7
    41  C Cortex-A15	 2.5
    42  
    43  C TODO
    44  C  * Not optimised.
    45  
    46  define(`rp', `r0')
    47  define(`up', `r1')
    48  define(`vp', `r2')
    49  define(`n',  `r3')
    50  
    51  ifdef(`OPERATION_rsh1add_n', `
    52    define(`ADDSUB',	adds)
    53    define(`ADDSUBC',	adcs)
    54    define(`RSTCY',	`cmn	$1, $1')
    55    define(`func',	mpn_rsh1add_n)
    56    define(`func_nc',	mpn_rsh1add_nc)')
    57  ifdef(`OPERATION_rsh1sub_n', `
    58    define(`ADDSUB',	subs)
    59    define(`ADDSUBC',	sbcs)
    60    define(`RSTCY',
    61  	`mvn	$2, #0x80000000
    62  	cmp	$2, $1')
    63    define(`func',	mpn_rsh1sub_n)
    64    define(`func_nc',	mpn_rsh1sub_nc)')
    65  
    66  MULFUNC_PROLOGUE(mpn_rsh1add_n mpn_rsh1sub_n)
    67  
    68  ASM_START()
    69  PROLOGUE(func)
    70  	push	{r4-r11}
    71  	ldr	r4, [up], #4
    72  	ldr	r8, [vp], #4
    73  	ADDSUB	r4, r4, r8
    74  	movs	r12, r7, rrx
    75  	and	r11, r4, #1	C return value
    76  	subs	n, n, #4
    77  	blo	L(end)
    78  
    79  L(top):	ldmia	up!, {r5,r6,r7}
    80  	ldmia	vp!, {r8,r9,r10}
    81  	cmn	r12, r12
    82  	ADDSUBC	r5, r5, r8
    83  	ADDSUBC	r6, r6, r9
    84  	ADDSUBC	r7, r7, r10
    85  	movs	r12, r7, rrx
    86  	movs	r6, r6, rrx
    87  	movs	r5, r5, rrx
    88  	movs	r4, r4, rrx
    89  	subs	n, n, #3
    90  	stmia	rp!, {r4,r5,r6}
    91  	mov	r4, r7
    92  	bhs	L(top)
    93  
    94  L(end):	cmn	n, #2
    95  	bls	L(e2)
    96  	ldm	up, {r5,r6}
    97  	ldm	vp, {r8,r9}
    98  	cmn	r12, r12
    99  	ADDSUBC	r5, r5, r8
   100  	ADDSUBC	r6, r6, r9
   101  	movs	r12, r6, rrx
   102  	movs	r5, r5, rrx
   103  	movs	r4, r4, rrx
   104  	stmia	rp!, {r4,r5}
   105  	mov	r4, r6
   106  	b	L(e1)
   107  
   108  L(e2):	bne	L(e1)
   109  	ldr	r5, [up, #0]
   110  	ldr	r8, [vp, #0]
   111  	cmn	r12, r12
   112  	ADDSUBC	r5, r5, r8
   113  	movs	r12, r5, rrx
   114  	movs	r4, r4, rrx
   115  	str	r4, [rp], #4
   116  	mov	r4, r5
   117  
   118  L(e1):	RSTCY(	r12, r1)
   119  	mov	r4, r4, rrx
   120  	str	r4, [rp, #0]
   121  	mov	r0, r11
   122  	pop	{r4-r11}
   123  	ret	r14
   124  EPILOGUE()