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

     1  dnl  ARM mpn_mul_1.
     2  
     3  dnl  Copyright 2012 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 ARM11		 6.4
    37  C Cortex-A7	 5.25
    38  C Cortex-A8	 7
    39  C Cortex-A9	 3.25
    40  C Cortex-A15	 4
    41  
    42  C TODO
    43  C  * Micro-optimise feed-in code.
    44  C  * Optimise for n=1,2 by delaying register saving.
    45  C  * Try using ldm/stm.
    46  
    47  define(`rp',`r0')
    48  define(`up',`r1')
    49  define(`n', `r2')
    50  define(`v0',`r3')
    51  
    52  ASM_START()
    53  PROLOGUE(mpn_mul_1)
    54  	stmfd	sp!, { r4, r5, r6, r7 }
    55  
    56  	ands	r6, n, #3
    57  	mov	r12, #0
    58  	beq	L(fi0)
    59  	cmp	r6, #2
    60  	bcc	L(fi1)
    61  	beq	L(fi2)
    62  
    63  L(fi3):	ldr	r4, [up], #4
    64  	mov	r6, #0
    65  	ldr	r5, [up], #4
    66  	b	L(lo3)
    67  
    68  L(fi0):	ldr	r5, [up], #4
    69  	add	rp, rp, #4
    70  	mov	r7, #0
    71  	ldr	r4, [up], #4
    72  	b	L(lo0)
    73  
    74  L(fi1):	ldr	r4, [up], #4
    75  	mov	r6, #0
    76  	add	rp, rp, #8
    77  	subs	n, n, #1
    78  	beq	L(1)
    79  	ldr	r5, [up], #4
    80  	b	L(lo1)
    81  
    82  L(fi2):	ldr	r5, [up], #4
    83  	add	rp, rp, #12
    84  	mov	r7, #0
    85  	ldr	r4, [up], #4
    86  	b	L(lo2)
    87  
    88  	ALIGN(16)
    89  L(top):	mov	r6, #0
    90  	ldr	r5, [up], #4
    91  	str	r7, [rp, #-12]
    92  L(lo1):	umaal	r6, r12, r4, v0
    93  	mov	r7, #0
    94  	ldr	r4, [up], #4
    95  	str	r6, [rp, #-8]
    96  L(lo0):	umaal	r7, r12, r5, v0
    97  	mov	r6, #0
    98  	ldr	r5, [up], #4
    99  	str	r7, [rp, #-4]
   100  L(lo3):	umaal	r6, r12, r4, v0
   101  	mov	r7, #0
   102  	ldr	r4, [up], #4
   103  	str	r6, [rp], #16
   104  L(lo2):	umaal	r7, r12, r5, v0
   105  	subs	n, n, #4
   106  	bhi	L(top)
   107  
   108  	mov	r6, #0
   109  	str	r7, [rp, #-12]
   110  L(1):	umaal	r6, r12, r4, v0
   111  	str	r6, [rp, #-8]
   112  	mov	r0, r12
   113  	ldmfd	sp!, { r4, r5, r6, r7 }
   114  	bx	lr
   115  EPILOGUE()