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

     1  dnl  AMD64 mpn_mul_1 optimised for Intel Atom.
     2  
     3  dnl  Copyright 2003-2005, 2007, 2008, 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	best
    34  C AMD K8,K9
    35  C AMD K10
    36  C AMD bd1
    37  C AMD bd2
    38  C AMD bobcat
    39  C AMD jaguar
    40  C Intel P4
    41  C Intel PNR
    42  C Intel NHM
    43  C Intel SBR
    44  C Intel IBR
    45  C Intel HWL
    46  C Intel BWL
    47  C Intel atom	17.3		this
    48  C VIA nano
    49  
    50  C The loop of this code is the result of running a code generation and
    51  C optimisation tool suite written by David Harvey and Torbjorn Granlund.
    52  
    53  define(`rp',      `%rdi')   C rcx
    54  define(`up',      `%rsi')   C rdx
    55  define(`n_param', `%rdx')   C r8
    56  define(`v0',      `%rcx')   C r9
    57  
    58  define(`n',       `%r11')
    59  
    60  ABI_SUPPORT(DOS64)
    61  ABI_SUPPORT(STD64)
    62  
    63  ASM_START()
    64  	TEXT
    65  	ALIGN(16)
    66  PROLOGUE(mpn_mul_1)
    67  	FUNC_ENTRY(4)
    68  	xor	%r8, %r8
    69  L(com):	mov	(up), %rax
    70  	lea	-16(up,n_param,8), up
    71  	lea	-8(rp,n_param,8), rp
    72  	test	$1, R8(n_param)
    73  	jnz	L(bx1)
    74  
    75  L(bx0):	mov	%r8, %r9
    76  	test	$2, R8(n_param)
    77  	jnz	L(b10)
    78  
    79  L(b00):	mov	$2, R32(n)
    80  	sub	n_param, n
    81  	jmp	L(lo0)
    82  
    83  L(bx1):	test	$2, R8(n_param)
    84  	jnz	L(b11)
    85  
    86  L(b01):	mov	$3, R32(n)
    87  	sub	n_param, n
    88  	mul	v0
    89  	cmp	$2, n
    90  	jnz	L(lo1)
    91  	jmp	L(cj1)
    92  
    93  L(b11):	mov	$1, R32(n)
    94  	sub	n_param, n
    95  	jmp	L(lo3)
    96  
    97  L(b10):	xor	R32(n), R32(n)
    98  	sub	n_param, n
    99  	jmp	L(lo2)
   100  
   101  L(top):	mul	v0
   102  	mov	%r9, -24(rp,n,8)
   103  L(lo1):	xor	%r9d, %r9d
   104  	add	%rax, %r8
   105  	mov	(up,n,8), %rax
   106  	adc	%rdx, %r9
   107  	mov	%r8, -16(rp,n,8)
   108  L(lo0):	xor	%r8d, %r8d
   109  	mul	v0
   110  	add	%rax, %r9
   111  	mov	8(up,n,8), %rax
   112  	adc	%rdx, %r8
   113  	mov	%r9, -8(rp,n,8)
   114  L(lo3):	xor	%r9d, %r9d
   115  	mul	v0
   116  	add	%rax, %r8
   117  	mov	16(up,n,8), %rax
   118  	adc	%rdx, %r9
   119  	mov	%r8, (rp,n,8)
   120  L(lo2):	xor	%r8d, %r8d
   121  	mul	v0
   122  	add	%rax, %r9
   123  	mov	24(up,n,8), %rax
   124  	adc	%rdx, %r8
   125  	add	$4, n
   126  	js	L(top)
   127  
   128  L(end):	mul	v0
   129  	mov	%r9, -8(rp)
   130  L(cj1):	add	%rax, %r8
   131  	mov	$0, R32(%rax)
   132  	adc	%rdx, %rax
   133  	mov	%r8, (rp)
   134  	FUNC_EXIT()
   135  	ret
   136  EPILOGUE()
   137  
   138  PROLOGUE(mpn_mul_1c)
   139  	FUNC_ENTRY(4)
   140  IFDOS(`	mov	56(%rsp), %r8	')
   141  	jmp	L(com)
   142  EPILOGUE()
   143  ASM_END()