Home | History | Annotate | Line # | Download | only in arm64
      1 dnl  ARM64 mpn_addlshC_n, mpn_sublshC_n, mpn_rsblshC_n.
      2 
      3 dnl  Contributed to the GNU project by Torbjrn Granlund.
      4 
      5 dnl  Copyright 2017 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 Cortex-A53	3.25-3.75
     37 C Cortex-A57	 2.18
     38 C X-Gene	 2.5
     39 
     40 changecom(blah)
     41 
     42 define(`rp', `x0')
     43 define(`up', `x1')
     44 define(`vp', `x2')
     45 define(`n',  `x3')
     46 
     47 ifdef(`DO_add', `
     48   define(`ADDSUB',	`adds	$1, $2, $3')
     49   define(`ADDSUBC',	`adcs	$1, $2, $3')
     50   define(`CLRRCY',	`adds	$1, xzr, xzr')
     51   define(`RETVAL',	`adc	x0, $1, xzr')
     52   define(`func_n',	mpn_addlsh`'LSH`'_n)')
     53 ifdef(`DO_sub', `
     54   define(`ADDSUB',	`subs	$1, $3, $2')
     55   define(`ADDSUBC',	`sbcs	$1, $3, $2')
     56   define(`CLRRCY',	`subs	$1, xzr, xzr')
     57   define(`RETVAL',	`cinc	x0, $1, cc')
     58   define(`func_n',	mpn_sublsh`'LSH`'_n)')
     59 ifdef(`DO_rsb', `
     60   define(`ADDSUB',	`subs	$1, $2, $3')
     61   define(`ADDSUBC',	`sbcs	$1, $2, $3')
     62   define(`CLRRCY',	`subs	$1, xzr, xzr')
     63   define(`RETVAL',	`sbc	x0, $1, xzr')
     64   define(`func_n',	mpn_rsblsh`'LSH`'_n)')
     65 
     66 ASM_START()
     67 PROLOGUE(func_n)
     68 	lsr	x18, n, #2
     69 	tbz	n, #0, L(bx0)
     70 
     71 L(bx1):	ldr	x5, [up]
     72 	tbnz	n, #1, L(b11)
     73 
     74 L(b01):	ldr	x11, [vp]
     75 	cbz	x18, L(1)
     76 	ldp	x8, x9, [vp,#8]
     77 	lsl	x13, x11, #LSH
     78 	ADDSUB(	x15, x13, x5)
     79 	str	x15, [rp],#8
     80 	sub	up, up, #24
     81 	sub	vp, vp, #8
     82 	b	L(mid)
     83 
     84 L(1):	lsl	x13, x11, #LSH
     85 	ADDSUB(	x15, x13, x5)
     86 	str	x15, [rp]
     87 	lsr	x0, x11, RSH
     88 	RETVAL(	 x0, x1)
     89 	ret
     90 
     91 L(b11):	ldr	x9, [vp]
     92 	ldp	x10, x11, [vp,#8]!
     93 	lsl	x13, x9, #LSH
     94 	ADDSUB(	x17, x13, x5)
     95 	str	x17, [rp],#8
     96 	sub	up, up, #8
     97 	cbz	x18, L(end)
     98 	b	L(top)
     99 
    100 L(bx0):	tbnz	n, #1, L(b10)
    101 
    102 L(b00):	CLRRCY(	x11)
    103 	ldp	x8, x9, [vp],#-16
    104 	sub	up, up, #32
    105 	b	L(mid)
    106 
    107 L(b10):	CLRRCY(	x9)
    108 	ldp	x10, x11, [vp]
    109 	sub	up, up, #16
    110 	cbz	x18, L(end)
    111 
    112 	ALIGN(16)
    113 L(top):	ldp	x4, x5, [up,#16]
    114 	extr	x12, x10, x9, #RSH
    115 	ldp	x8, x9, [vp,#16]
    116 	extr	x13, x11, x10, #RSH
    117 	ADDSUBC(x14, x12, x4)
    118 	ADDSUBC(x15, x13, x5)
    119 	stp	x14, x15, [rp],#16
    120 L(mid):	ldp	x4, x5, [up,#32]!
    121 	extr	x12, x8, x11, #RSH
    122 	ldp	x10, x11, [vp,#32]!
    123 	extr	x13, x9, x8, #RSH
    124 	ADDSUBC(x16, x12, x4)
    125 	ADDSUBC(x17, x13, x5)
    126 	stp	x16, x17, [rp],#16
    127 	sub	x18, x18, #1
    128 	cbnz	x18, L(top)
    129 
    130 L(end):	ldp	x4, x5, [up,#16]
    131 	extr	x12, x10, x9, #RSH
    132 	extr	x13, x11, x10, #RSH
    133 	ADDSUBC(x14, x12, x4)
    134 	ADDSUBC(x15, x13, x5)
    135 	stp	x14, x15, [rp]
    136 	lsr	x0, x11, RSH
    137 	RETVAL(	 x0, x1)
    138 	ret
    139 EPILOGUE()
    140