~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/mpn/x86/pentium/logops_n.asm

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl  Intel Pentium mpn_and_n,...,mpn_xnor_n -- bitwise logical operations.
 
2
dnl
 
3
dnl  P5: 3.0 c/l  and, ior, xor
 
4
dnl      3.5 c/l  andn, iorn, nand, nior, xnor
 
5
 
 
6
dnl  Copyright 2001 Free Software Foundation, Inc.
 
7
dnl 
 
8
dnl  This file is part of the GNU MP Library.
 
9
dnl 
 
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.
 
14
dnl 
 
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.
 
19
dnl 
 
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.
 
24
 
 
25
include(`../config.m4')
 
26
 
 
27
 
 
28
define(M4_choose_op,
 
29
`ifdef(`OPERATION_$1',`
 
30
define(`M4_function', `mpn_$1')
 
31
define(`M4_want_pre', `$4')
 
32
define(`M4op',        `$3')
 
33
define(`M4_want_post',`$2')
 
34
')')
 
35
define(M4pre, `ifelse(M4_want_pre, yes,`$1')')
 
36
define(M4post,`ifelse(M4_want_post,yes,`$1')')
 
37
 
 
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,    )
 
46
 
 
47
ifdef(`M4_function',,
 
48
`m4_error(`Unrecognised or undefined OPERATION symbol
 
49
')')
 
50
 
 
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)
 
52
 
 
53
 
 
54
C void M4_function (mp_ptr wp, mp_srcptr xp, mp_srcptr yp, mp_size_t size);
 
55
C
 
56
C Nothing complicated here, just some care to avoid data cache bank clashes
 
57
C and AGIs.
 
58
C
 
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.
 
63
C
 
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
 
66
C difficult.
 
67
 
 
68
defframe(PARAM_SIZE,16)
 
69
defframe(PARAM_YP,  12)
 
70
defframe(PARAM_XP,   8)
 
71
defframe(PARAM_WP,   4)
 
72
 
 
73
        TEXT
 
74
        ALIGN(8)
 
75
 
 
76
PROLOGUE(M4_function)
 
77
deflit(`FRAME',0)
 
78
 
 
79
        pushl   %ebx    FRAME_pushl()
 
80
        pushl   %esi    FRAME_pushl()
 
81
 
 
82
        pushl   %edi    FRAME_pushl()
 
83
        pushl   %ebp    FRAME_pushl()
 
84
 
 
85
        movl    PARAM_SIZE, %ecx
 
86
        movl    PARAM_XP, %ebx
 
87
 
 
88
        movl    PARAM_YP, %esi
 
89
        movl    PARAM_WP, %edi
 
90
 
 
91
        shrl    %ecx
 
92
        jnc     L(entry)
 
93
 
 
94
        movl    (%ebx,%ecx,8), %eax     C risk of data cache bank clash here
 
95
        movl    (%esi,%ecx,8), %edx
 
96
 
 
97
M4pre(` notl    %edx')
 
98
 
 
99
        M4op    %edx, %eax
 
100
 
 
101
M4post(`xorl    $-1, %eax')
 
102
        orl     %ecx, %ecx
 
103
 
 
104
        movl    %eax, (%edi,%ecx,8)
 
105
        jz      L(done)
 
106
 
 
107
        jmp     L(entry)
 
108
 
 
109
 
 
110
L(top):
 
111
        C eax
 
112
        C ebx   xp
 
113
        C ecx   counter, limb pairs, decrementing
 
114
        C edx
 
115
        C esi   yp
 
116
        C edi   wp
 
117
        C ebp
 
118
 
 
119
        M4op    %ebp, %edx
 
120
        nop
 
121
 
 
122
M4post(`xorl    $-1, %eax')
 
123
M4post(`xorl    $-1, %edx')
 
124
 
 
125
        movl    %eax, 4(%edi,%ecx,8)
 
126
        movl    %edx, (%edi,%ecx,8)
 
127
 
 
128
L(entry):
 
129
        movl    -4(%ebx,%ecx,8), %ebp
 
130
        nop
 
131
 
 
132
        movl    -4(%esi,%ecx,8), %eax
 
133
        movl    -8(%esi,%ecx,8), %edx
 
134
 
 
135
M4pre(` xorl    $-1, %eax')
 
136
M4pre(` xorl    $-1, %edx')
 
137
 
 
138
        M4op    %ebp, %eax
 
139
        movl    -8(%ebx,%ecx,8), %ebp
 
140
 
 
141
        decl    %ecx
 
142
        jnz     L(top)
 
143
 
 
144
 
 
145
        M4op    %ebp, %edx
 
146
        nop
 
147
 
 
148
M4post(`xorl    $-1, %eax')
 
149
M4post(`xorl    $-1, %edx')
 
150
 
 
151
        movl    %eax, 4(%edi,%ecx,8)
 
152
        movl    %edx, (%edi,%ecx,8)
 
153
 
 
154
 
 
155
L(done):
 
156
        popl    %ebp
 
157
        popl    %edi
 
158
 
 
159
        popl    %esi
 
160
        popl    %ebx
 
161
 
 
162
        ret
 
163
 
 
164
EPILOGUE()