~vorlon/ubuntu/natty/eglibc/multiarch

« back to all changes in this revision

Viewing changes to ports/sysdeps/powerpc/powerpc32/405/strcmp.S

  • Committer: Steve Langasek
  • Date: 2011-02-18 21:18:44 UTC
  • mfrom: (103.1.7 eglibc)
  • Revision ID: steve.langasek@linaro.org-20110218211844-lodmi8b1qhyq3f3x
Tags: 2.13~pre1-0ubuntu1+multiarch.1
merge from natty

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Optimized strcmp implementation for PowerPC476.
 
2
   Copyright (C) 2010 Free Software Foundation, Inc.
 
3
   This file is part of the GNU C Library.
 
4
 
 
5
   The GNU C Library is free software; you can redistribute it and/or
 
6
   modify it under the terms of the GNU Lesser General Public
 
7
   License as published by the Free Software Foundation; either
 
8
   version 2.1 of the License, or (at your option) any later version.
 
9
 
 
10
   The GNU C Library is distributed in the hope that it will be useful,
 
11
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
   Lesser General Public License for more details.
 
14
 
 
15
   You should have received a copy of the GNU Lesser General Public
 
16
   License along with the GNU C Library; if not, write to the Free
 
17
   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA
 
18
   02110-1301 USA.  */
 
19
 
 
20
#include <sysdep.h>
 
21
#include <bp-sym.h>
 
22
#include <bp-asm.h>
 
23
 
 
24
/* strcmp
 
25
 
 
26
       Register Use
 
27
       r0:temp return equality
 
28
       r3:source1 address, return equality
 
29
       r4:source2 address
 
30
 
 
31
       Implementation description
 
32
       Check 2 words from src1 and src2. If unequal jump to end and
 
33
       return src1 > src2 or src1 < src2.
 
34
       If null check bytes before null and then jump to end and
 
35
       return src1 > src2, src1 < src2 or src1 = src2.
 
36
       If src1 = src2 and no null, repeat. */
 
37
 
 
38
EALIGN (BP_SYM(strcmp),5,0)
 
39
       neg     r7,r3
 
40
       clrlwi  r7,r7,20
 
41
       neg     r8,r4
 
42
       clrlwi  r8,r8,20
 
43
       srwi.   r7,r7,5
 
44
       beq     L(byte_loop)
 
45
       srwi.   r8,r8,5
 
46
       beq     L(byte_loop)
 
47
       cmplw   r7,r8
 
48
       mtctr   r7
 
49
       ble     L(big_loop)
 
50
       mtctr   r8
 
51
 
 
52
L(big_loop):
 
53
       lwz     r5,0(r3)
 
54
       lwz     r6,4(r3)
 
55
       lwz     r8,0(r4)
 
56
       lwz     r9,4(r4)
 
57
       dlmzb.  r12,r5,r6
 
58
       bne     L(end_check)
 
59
       cmplw   r5,r8
 
60
       bne     L(st1)
 
61
       cmplw   r6,r9
 
62
       bne     L(st1)
 
63
       lwz     r5,8(r3)
 
64
       lwz     r6,12(r3)
 
65
       lwz     r8,8(r4)
 
66
       lwz     r9,12(r4)
 
67
       dlmzb.  r12,r5,r6
 
68
       bne     L(end_check)
 
69
       cmplw   r5,r8
 
70
       bne     L(st1)
 
71
       cmplw   r6,r9
 
72
       bne     L(st1)
 
73
       lwz     r5,16(r3)
 
74
       lwz     r6,20(r3)
 
75
       lwz     r8,16(r4)
 
76
       lwz     r9,20(r4)
 
77
       dlmzb.  r12,r5,r6
 
78
       bne     L(end_check)
 
79
       cmplw   r5,r8
 
80
       bne     L(st1)
 
81
       cmplw   r6,r9
 
82
       bne     L(st1)
 
83
       lwz     r5,24(r3)
 
84
       lwz     r6,28(r3)
 
85
       addi    r3,r3,0x20
 
86
       lwz     r8,24(r4)
 
87
       lwz     r9,28(r4)
 
88
       addi    r4,r4,0x20
 
89
       dlmzb.  r12,r5,r6
 
90
       bne     L(end_check)
 
91
       cmplw   r5,r8
 
92
       bne     L(st1)
 
93
       cmplw   r6,r9
 
94
       bne     L(st1)
 
95
       bdnz    L(big_loop)
 
96
       b       L(byte_loop)
 
97
 
 
98
L(end_check):
 
99
       subfic  r12,r12,4
 
100
       blt     L(end_check2)
 
101
       rlwinm  r12,r12,3,0,31
 
102
       srw     r5,r5,r12
 
103
       srw     r8,r8,r12
 
104
       cmplw   r5,r8
 
105
       bne     L(st1)
 
106
       b       L(end_strcmp)
 
107
 
 
108
L(end_check2):
 
109
       addi    r12,r12,4
 
110
       cmplw   r5,r8
 
111
       rlwinm  r12,r12,3,0,31
 
112
       bne     L(st1)
 
113
       srw     r6,r6,r12
 
114
       srw     r9,r9,r12
 
115
       cmplw   r6,r9
 
116
       bne     L(st1)
 
117
 
 
118
L(end_strcmp):
 
119
       addi    r3,r0,0
 
120
       blr
 
121
 
 
122
L(st1):
 
123
       mfcr    r3
 
124
       blr
 
125
 
 
126
L(byte_loop):
 
127
       lbz     r5,0(r3)
 
128
       addi    r3,r3,1
 
129
       lbz     r6,0(r4)
 
130
       addi    r4,r4,1
 
131
       cmplw   r5,r6
 
132
       bne     L(st1)
 
133
       cmpwi   r5,0
 
134
       beq     L(end_strcmp)
 
135
       b       L(byte_loop)
 
136
END (BP_SYM (strcmp))
 
137
libc_hidden_builtin_def (strcmp)