Fix whitespace issue.
[glibc.git] / sysdeps / x86_64 / addmul_1.S
blobe99789670376cb9c046a99b8679cd810a02110fb
1 /* x86-64 __mpn_addmul_1 -- Multiply a limb vector with a limb and add
2    the result to a second limb vector.
3    Copyright (C) 2003,2004,2005,2007,2008,2009 Free Software Foundation, Inc.
4    This file is part of the GNU MP Library.
6    The GNU MP Library is free software; you can redistribute it and/or modify
7    it under the terms of the GNU Lesser General Public License as published by
8    the Free Software Foundation; either version 2.1 of the License, or (at your
9    option) any later version.
11    The GNU MP Library is distributed in the hope that it will be useful, but
12    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13    or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14    License for more details.
16    You should have received a copy of the GNU Lesser General Public License
17    along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
18    the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
19    MA 02111-1307, USA. */
21 #include "sysdep.h"
22 #include "asm-syntax.h"
24 #define rp      %rdi
25 #define up      %rsi
26 #define n       %rdx
27 #define v0      %rcx
29 #ifndef func
30 # define func __mpn_addmul_1
31 # define ADDSUB add
32 #endif
34         .text
35 ENTRY (func)
36         push    %rbx
37         push    %rbp
38         lea     (%rdx), %rbx
39         neg     %rbx
41         mov     (up), %rax
42         mov     (rp), %r10
44         lea     -16(rp,%rdx,8), rp
45         lea     (up,%rdx,8), up
46         mul     %rcx
48         bt      $0, %ebx
49         jc      L(odd)
51         lea     (%rax), %r11
52         mov     8(up,%rbx,8), %rax
53         lea     (%rdx), %rbp
54         mul     %rcx
55         add     $2, %rbx
56         jns     L(n2)
58         lea     (%rax), %r8
59         mov     (up,%rbx,8), %rax
60         lea     (%rdx), %r9
61         jmp     L(mid)
63 L(odd): add     $1, %rbx
64         jns     L(n1)
66         lea     (%rax), %r8
67         mov     (up,%rbx,8), %rax
68         lea     (%rdx), %r9
69         mul     %rcx
70         lea     (%rax), %r11
71         mov     8(up,%rbx,8), %rax
72         lea     (%rdx), %rbp
73         jmp     L(e)
75         .p2align 4
76 L(top): mul     %rcx
77         ADDSUB  %r8, %r10
78         lea     (%rax), %r8
79         mov     (up,%rbx,8), %rax
80         adc     %r9, %r11
81         mov     %r10, -8(rp,%rbx,8)
82         mov     (rp,%rbx,8), %r10
83         lea     (%rdx), %r9
84         adc     $0, %rbp
85 L(mid): mul     %rcx
86         ADDSUB  %r11, %r10
87         lea     (%rax), %r11
88         mov     8(up,%rbx,8), %rax
89         adc     %rbp, %r8
90         mov     %r10, (rp,%rbx,8)
91         mov     8(rp,%rbx,8), %r10
92         lea     (%rdx), %rbp
93         adc     $0, %r9
94 L(e):   add     $2, %rbx
95         js      L(top)
97         mul     %rcx
98         ADDSUB  %r8, %r10
99         adc     %r9, %r11
100         mov     %r10, -8(rp)
101         adc     $0, %rbp
102 L(n2):  mov     (rp), %r10
103         ADDSUB  %r11, %r10
104         adc     %rbp, %rax
105         mov     %r10, (rp)
106         adc     $0, %rdx
107 L(n1):  mov     8(rp), %r10
108         ADDSUB  %rax, %r10
109         mov     %r10, 8(rp)
110         mov     %ebx, %eax      /* zero rax */
111         adc     %rdx, %rax
112         pop     %rbp
113         pop     %rbx
114         ret
115 END (func)