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

     1  dnl  ARM mpn_and_n, mpn_andn_n. mpn_nand_n, etc.
     2  
     3  dnl  Contributed to the GNU project by Torbjörn Granlund.
     4  
     5  dnl  Copyright 1997, 2000, 2001, 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             cycles/limb
    36  C          and andn ior xor         nand iorn nior xnor
    37  C StrongARM	 ?			 ?
    38  C XScale	 ?			 ?
    39  C Cortex-A7	 ?			 ?
    40  C Cortex-A8	 ?			 ?
    41  C Cortex-A9	2.5-2.72		2.75-3
    42  C Cortex-A15	2.25			2.75
    43  
    44  C TODO
    45  C  * It seems that 2.25 c/l and 2.75 c/l is possible for A9.
    46  C  * Debug popping issue, see comment below.
    47  
    48  define(`rp', `r0')
    49  define(`up', `r1')
    50  define(`vp', `r2')
    51  define(`n',  `r3')
    52  
    53  define(`POSTOP')
    54  
    55  ifdef(`OPERATION_and_n',`
    56    define(`func',    `mpn_and_n')
    57    define(`LOGOP',   `and	$1, $2, $3')')
    58  ifdef(`OPERATION_andn_n',`
    59    define(`func',    `mpn_andn_n')
    60    define(`LOGOP',   `bic	$1, $2, $3')')
    61  ifdef(`OPERATION_nand_n',`
    62    define(`func',    `mpn_nand_n')
    63    define(`POSTOP',  `mvn	$1, $1')
    64    define(`LOGOP',   `and	$1, $2, $3')')
    65  ifdef(`OPERATION_ior_n',`
    66    define(`func',    `mpn_ior_n')
    67    define(`LOGOP',   `orr	$1, $2, $3')')
    68  ifdef(`OPERATION_iorn_n',`
    69    define(`func',    `mpn_iorn_n')
    70    define(`POSTOP',  `mvn	$1, $1')
    71    define(`LOGOP',   `bic	$1, $3, $2')')
    72  ifdef(`OPERATION_nior_n',`
    73    define(`func',    `mpn_nior_n')
    74    define(`POSTOP',  `mvn	$1, $1')
    75    define(`LOGOP',   `orr	$1, $2, $3')')
    76  ifdef(`OPERATION_xor_n',`
    77    define(`func',    `mpn_xor_n')
    78    define(`LOGOP',   `eor	$1, $2, $3')')
    79  ifdef(`OPERATION_xnor_n',`
    80    define(`func',    `mpn_xnor_n')
    81    define(`POSTOP',  `mvn	$1, $1')
    82    define(`LOGOP',   `eor	$1, $2, $3')')
    83  
    84  MULFUNC_PROLOGUE(mpn_and_n mpn_andn_n mpn_nand_n mpn_ior_n mpn_iorn_n mpn_nior_n mpn_xor_n mpn_xnor_n)
    85  
    86  ASM_START()
    87  PROLOGUE(func)
    88  	push	{ r8, r9, r10 }
    89  	tst	n, #1
    90  	beq	L(skip1)
    91  	ldr	r10, [vp], #4
    92  	ldr	r12, [up], #4
    93  	LOGOP(	r12, r12, r10)
    94  	POSTOP(	r12)
    95  	str	r12, [rp], #4
    96  L(skip1):
    97  	tst	n, #2
    98  	beq	L(skip2)
    99  	ldmia	vp!, { r10, r12 }
   100  	ldmia	up!, { r8, r9 }
   101  	LOGOP(	r8, r8, r10)
   102  	LOGOP(	r9, r9, r12)
   103  	POSTOP(	r8)
   104  	POSTOP(	r9)
   105  	stmia	rp!, { r8, r9 }
   106  L(skip2):
   107  	bics	n, n, #3
   108  	beq	L(rtn)
   109  	push	{ r4, r5, r6, r7 }
   110  
   111  	ldmia	vp!, { r8, r9, r10, r12 }
   112  	b	L(mid)
   113  
   114  L(top):	ldmia	vp!, { r8, r9, r10, r12 }
   115  	POSTOP(	r4)
   116  	POSTOP(	r5)
   117  	POSTOP(	r6)
   118  	POSTOP(	r7)
   119  	stmia	rp!, { r4, r5, r6, r7 }
   120  L(mid):	sub	n, n, #4
   121  	ldmia	up!, { r4, r5, r6, r7 }
   122  	teq	n, #0
   123  	LOGOP(	r4, r4, r8)
   124  	LOGOP(	r5, r5, r9)
   125  	LOGOP(	r6, r6, r10)
   126  	LOGOP(	r7, r7, r12)
   127  	bne	L(top)
   128  
   129  	POSTOP(	r4)
   130  	POSTOP(	r5)
   131  	POSTOP(	r6)
   132  	POSTOP(	r7)
   133  	stmia	rp!, { r4, r5, r6, r7 }
   134  
   135  	pop	{ r4, r5, r6, r7 }	C popping r8-r10 here strangely fails
   136  
   137  L(rtn):	pop	{ r8, r9, r10 }
   138  	ret	r14
   139  EPILOGUE()