Annotation of OpenXM_contrib/gmp/mpn/x86/k7/mmx/copyd.asm, Revision 1.1.1.2
1.1 maekawa 1: dnl AMD K7 mpn_copyd -- copy limb vector, decrementing.
2:
1.1.1.2 ! ohara 3: dnl Copyright 1999, 2000, 2002 Free Software Foundation, Inc.
1.1 maekawa 4: dnl
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
8: dnl modify it under the terms of the GNU Lesser General Public License as
9: dnl published by the Free Software Foundation; either version 2.1 of the
10: dnl License, or (at your option) any later version.
11: dnl
12: dnl The GNU MP Library is distributed in the hope that it will be useful,
13: dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14: dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: dnl Lesser General Public License for more details.
16: dnl
17: dnl You should have received a copy of the GNU Lesser General Public
18: dnl License along with the GNU MP Library; see the file COPYING.LIB. If
19: dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
20: dnl Suite 330, Boston, MA 02111-1307, USA.
21:
22: include(`../config.m4')
23:
24:
1.1.1.2 ! ohara 25: C alignment dst/src, A=0mod8 N=4mod8
! 26: C A/A A/N N/A N/N
! 27: C K7 0.75 1.0 1.0 0.75
! 28:
! 29:
1.1 maekawa 30: C void mpn_copyd (mp_ptr dst, mp_srcptr src, mp_size_t size);
31: C
32: C The various comments in mpn/x86/k7/copyi.asm apply here too.
33:
34: defframe(PARAM_SIZE,12)
35: defframe(PARAM_SRC, 8)
36: defframe(PARAM_DST, 4)
37: deflit(`FRAME',0)
38:
39: dnl parameter space reused
40: define(SAVE_EBX,`PARAM_SIZE')
41: define(SAVE_ESI,`PARAM_SRC')
42:
43: dnl minimum 5 since the unrolled code can't handle less than 5
44: deflit(UNROLL_THRESHOLD, 5)
45:
1.1.1.2 ! ohara 46: TEXT
1.1 maekawa 47: ALIGN(32)
48: PROLOGUE(mpn_copyd)
49:
50: movl PARAM_SIZE, %ecx
51: movl %ebx, SAVE_EBX
52:
53: movl PARAM_SRC, %eax
54: movl PARAM_DST, %edx
55:
56: cmpl $UNROLL_THRESHOLD, %ecx
57: jae L(unroll)
58:
59: orl %ecx, %ecx
60: jz L(simple_done)
61:
62: L(simple):
63: C eax src
64: C ebx scratch
65: C ecx counter
66: C edx dst
67: C
68: C this loop is 2 cycles/limb
69:
70: movl -4(%eax,%ecx,4), %ebx
71: movl %ebx, -4(%edx,%ecx,4)
72: decl %ecx
73: jnz L(simple)
74:
75: L(simple_done):
76: movl SAVE_EBX, %ebx
77: ret
78:
79:
80: L(unroll):
81: movl %esi, SAVE_ESI
82: leal (%eax,%ecx,4), %ebx
83: leal (%edx,%ecx,4), %esi
84:
85: andl %esi, %ebx
86: movl SAVE_ESI, %esi
87: subl $4, %ecx C size-4
88:
89: testl $4, %ebx C testl to pad code closer to 16 bytes for L(top)
90: jz L(aligned)
91:
92: C both src and dst unaligned, process one limb to align them
93: movl 12(%eax,%ecx,4), %ebx
94: movl %ebx, 12(%edx,%ecx,4)
95: decl %ecx
96: L(aligned):
97:
98:
99: ALIGN(16)
100: L(top):
101: C eax src
102: C ebx
103: C ecx counter, limbs
104: C edx dst
105:
106: movq 8(%eax,%ecx,4), %mm0
107: movq (%eax,%ecx,4), %mm1
108: subl $4, %ecx
109: movq %mm0, 16+8(%edx,%ecx,4)
110: movq %mm1, 16(%edx,%ecx,4)
111: jns L(top)
112:
113:
114: C now %ecx is -4 to -1 representing respectively 0 to 3 limbs remaining
115:
116: testb $2, %cl
117: jz L(finish_not_two)
118:
119: movq 8(%eax,%ecx,4), %mm0
120: movq %mm0, 8(%edx,%ecx,4)
121: L(finish_not_two):
122:
123: testb $1, %cl
124: jz L(done)
125:
126: movl (%eax), %ebx
127: movl %ebx, (%edx)
128:
129: L(done):
130: movl SAVE_EBX, %ebx
131: emms
132: ret
133:
134:
135: EPILOGUE()
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>