1
dnl Intel Pentium mpn_and_n,...,mpn_xnor_n -- bitwise logical operations.
3
dnl P5: 3.0 c/l and, ior, xor
4
dnl 3.5 c/l andn, iorn, nand, nior, xnor
6
dnl Copyright 2001 Free Software Foundation, Inc.
8
dnl This file is part of the GNU MP Library.
10
dnl The GNU MP Library is free software; you can redistribute it and/or
11
dnl modify it under the terms of the GNU Lesser General Public License as
12
dnl published by the Free Software Foundation; either version 2.1 of the
13
dnl License, or (at your option) any later version.
15
dnl The GNU MP Library is distributed in the hope that it will be useful,
16
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
17
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
dnl Lesser General Public License for more details.
20
dnl You should have received a copy of the GNU Lesser General Public
21
dnl License along with the GNU MP Library; see the file COPYING.LIB. If
22
dnl not, write to the Free Software Foundation, Inc., 59 Temple Place -
23
dnl Suite 330, Boston, MA 02111-1307, USA.
25
include(`../config.m4')
29
`ifdef(`OPERATION_$1',`
30
define(`M4_function', `mpn_$1')
31
define(`M4_want_pre', `$4')
33
define(`M4_want_post',`$2')
35
define(M4pre, `ifelse(M4_want_pre, yes,`$1')')
36
define(M4post,`ifelse(M4_want_post,yes,`$1')')
38
M4_choose_op( and_n, , andl, )
39
M4_choose_op( andn_n, , andl, yes)
40
M4_choose_op( nand_n, yes, andl, )
41
M4_choose_op( ior_n, , orl, )
42
M4_choose_op( iorn_n, , orl, yes)
43
M4_choose_op( nior_n, yes, orl, )
44
M4_choose_op( xor_n, , xorl, )
45
M4_choose_op( xnor_n, yes, xorl, )
48
`m4_error(`Unrecognised or undefined OPERATION symbol
51
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)
54
C void M4_function (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size);
56
C Nothing complicated here, just some care to avoid data cache bank clashes
59
C We're one register short of being able to do a simple 4 loads, 2 ops, 2
60
C stores. Instead %ebp is juggled a bit and nops are introduced to keep the
61
C pairings as intended. An in-place operation would free up a register, for
62
C an 0.5 c/l speedup, if that's worth bothering with.
64
C This code seems best for P55 too. Data alignment is a big problem for MMX
65
C and the pairing restrictions on movq and integer instructions make life
68
defframe(PARAM_SIZE,16)
69
defframe(PARAM_YP, 12)
79
pushl %ebx FRAME_pushl()
80
pushl %esi FRAME_pushl()
82
pushl %edi FRAME_pushl()
83
pushl %ebp FRAME_pushl()
94
movl (%ebx,%ecx,8), %eax C risk of data cache bank clash here
95
movl (%esi,%ecx,8), %edx
101
M4post(`xorl $-1, %eax')
104
movl %eax, (%edi,%ecx,8)
113
C ecx counter, limb pairs, decrementing
122
M4post(`xorl $-1, %eax')
123
M4post(`xorl $-1, %edx')
125
movl %eax, 4(%edi,%ecx,8)
126
movl %edx, (%edi,%ecx,8)
129
movl -4(%ebx,%ecx,8), %ebp
132
movl -4(%esi,%ecx,8), %eax
133
movl -8(%esi,%ecx,8), %edx
135
M4pre(` xorl $-1, %eax')
136
M4pre(` xorl $-1, %edx')
139
movl -8(%ebx,%ecx,8), %ebp
148
M4post(`xorl $-1, %eax')
149
M4post(`xorl $-1, %edx')
151
movl %eax, 4(%edi,%ecx,8)
152
movl %edx, (%edi,%ecx,8)