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

« back to all changes in this revision

Viewing changes to gmp3/mpn/x86/pentium/hamdist.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 P5 mpn_hamdist -- mpn hamming distance.
 
2
dnl
 
3
dnl  P5: 14.0 cycles/limb
 
4
 
 
5
dnl  Copyright 2001 Free Software Foundation, Inc.
 
6
dnl 
 
7
dnl  This file is part of the GNU MP Library.
 
8
dnl 
 
9
dnl  The GNU MP Library is free software; you can redistribute it and/or
 
10
dnl  modify it under the terms of the GNU Lesser General Public License as
 
11
dnl  published by the Free Software Foundation; either version 2.1 of the
 
12
dnl  License, or (at your option) any later version.
 
13
dnl 
 
14
dnl  The GNU MP Library is distributed in the hope that it will be useful,
 
15
dnl  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
17
dnl  Lesser General Public License for more details.
 
18
dnl 
 
19
dnl  You should have received a copy of the GNU Lesser General Public
 
20
dnl  License along with the GNU MP Library; see the file COPYING.LIB.  If
 
21
dnl  not, write to the Free Software Foundation, Inc., 59 Temple Place -
 
22
dnl  Suite 330, Boston, MA 02111-1307, USA.
 
23
 
 
24
include(`../config.m4')
 
25
 
 
26
 
 
27
C unsigned long mpn_hamdist (mp_srcptr src1, mp_srcptr src2, mp_size_t size);
 
28
C
 
29
C It might be possible to shave 1 cycle from the loop, and hence 2
 
30
C cycles/limb.  The xorb is taking 2 cycles, but a separate load and xor
 
31
C would be 1, if the right schedule could be found (not found so far).
 
32
C Wanting to avoid potential cache bank clashes makes it tricky.
 
33
 
 
34
C The slightly strange quoting here helps the renaming done by tune/many.pl.
 
35
deflit(TABLE_NAME,
 
36
m4_assert_defined(`GSYM_PREFIX')
 
37
GSYM_PREFIX`'mpn_popcount``'_table')
 
38
 
 
39
defframe(PARAM_SIZE,12)
 
40
defframe(PARAM_SRC2, 8)
 
41
defframe(PARAM_SRC1, 4)
 
42
 
 
43
        TEXT
 
44
        ALIGN(8)
 
45
 
 
46
PROLOGUE(mpn_hamdist)
 
47
deflit(`FRAME',0)
 
48
 
 
49
        movl    PARAM_SIZE, %ecx
 
50
        pushl   %esi    FRAME_pushl()
 
51
 
 
52
        shll    %ecx            C size in byte pairs
 
53
        pushl   %edi    FRAME_pushl()
 
54
 
 
55
ifdef(`PIC',`
 
56
        pushl   %ebx    FRAME_pushl()
 
57
        pushl   %ebp    FRAME_pushl()
 
58
 
 
59
        call    L(here) FRAME_pushl()
 
60
L(here):
 
61
        movl    PARAM_SRC1, %esi
 
62
        popl    %ebp    FRAME_popl()
 
63
 
 
64
        movl    PARAM_SRC2, %edi
 
65
        addl    $_GLOBAL_OFFSET_TABLE_+[.-L(here)], %ebp
 
66
 
 
67
        xorl    %ebx, %ebx      C byte
 
68
        xorl    %edx, %edx      C byte
 
69
 
 
70
        movl    TABLE_NAME@GOT(%ebp), %ebp
 
71
        xorl    %eax, %eax      C total
 
72
define(TABLE,`(%ebp,$1)')
 
73
 
 
74
',`
 
75
dnl non-PIC
 
76
        movl    PARAM_SRC1, %esi
 
77
        movl    PARAM_SRC2, %edi
 
78
 
 
79
        xorl    %eax, %eax      C total
 
80
        pushl   %ebx    FRAME_pushl()
 
81
 
 
82
        xorl    %edx, %edx      C byte
 
83
        xorl    %ebx, %ebx      C byte
 
84
 
 
85
define(TABLE,`TABLE_NAME($1)')
 
86
')
 
87
 
 
88
 
 
89
        C The nop after the xorb seems necessary.  Although a movb might be
 
90
        C expected to go down the V pipe in the second cycle of the xorb, it
 
91
        C doesn't and costs an extra 2 cycles.
 
92
L(top):
 
93
        C eax   total
 
94
        C ebx   byte
 
95
        C ecx   counter, 2*size to 2
 
96
        C edx   byte
 
97
        C esi   src1
 
98
        C edi   src2
 
99
        C ebp   [PIC] table
 
100
 
 
101
        addl    %ebx, %eax
 
102
        movb    -1(%esi,%ecx,2), %bl
 
103
 
 
104
        addl    %edx, %eax
 
105
        movb    -1(%edi,%ecx,2), %dl
 
106
 
 
107
        xorb    %dl, %bl
 
108
        movb    -2(%esi,%ecx,2), %dl
 
109
 
 
110
        xorb    -2(%edi,%ecx,2), %dl
 
111
        nop
 
112
 
 
113
        movb    TABLE(%ebx), %bl
 
114
        decl    %ecx
 
115
 
 
116
        movb    TABLE(%edx), %dl
 
117
        jnz     L(top)
 
118
 
 
119
 
 
120
ifdef(`PIC',`
 
121
        popl    %ebp
 
122
')
 
123
        addl    %ebx, %eax
 
124
        popl    %ebx
 
125
 
 
126
        addl    %edx, %eax
 
127
        popl    %edi
 
128
 
 
129
        popl    %esi
 
130
 
 
131
        ret
 
132
 
 
133
EPILOGUE()