1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
#include <features.h>
#include <endian.h>
#ifdef WANT_WIDE
# define Wstrcmp wcscmp
# define Wstrcoll wcscoll
#else
# define Wstrcmp strcmp
# define Wstrcoll strcoll
#endif
/* FIXME attention!!! it may be a bug when WANT_WIDE define */
/*libc_hidden_proto(Wstrcmp)*/
.align 2
.global Wstrcmp
.type Wstrcmp, @function
Wstrcmp:
mov r6, r2
or r2, r3
andi r2, 0x3
cmpnei r2, 0x0 /* d or s is aligned ?*/
bt 4f /* if not aligned, goto 4f*/
1: /* if aligned, load word each time.*/
ldw r2, (r6, 0)
ldw r7, (r3, 0)
cmpne r2, r7
bt 1f /* if d[i] != s[i], goto 1f */
tstnbz r2 /* if d[i] == s[i], check if d or s is at the end. */
bf 3f /* if at the end, goto 3f (finish comparing) */
ldw r2, (r6, 4)
ldw r7, (r3, 4)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 8)
ldw r7, (r3, 8)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 12)
ldw r7, (r3, 12)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 16)
ldw r7, (r3, 16)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 20)
ldw r7, (r3, 20)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 24)
ldw r7, (r3, 24)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
ldw r2, (r6, 28)
ldw r7, (r3, 28)
cmpne r2, r7
bt 1f
tstnbz r2
bf 3f
addi r6, 32
addi r3, 32
br 1b
#ifdef __CSKYBE__
/* d[i] != s[i] in word, so we check byte 0 ? */
1:
xtrb0 r1, r2
mov r4, r1
xtrb0 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb1 r1, r2
mov r4, r1
xtrb1 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb2 r1, r2
mov r4, r1
xtrb2 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb3 r1, r2
mov r4, r1
xtrb3 r1, r7
#else /* little endian */
/* d[i] != s[i] in word, so we check byte 0 ? */
1:
xtrb3 r1, r2
mov r4, r1
xtrb3 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb2 r1, r2
mov r4, r1
xtrb2 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb1 r1, r2
mov r4, r1
xtrb1 r1, r7
cmpne r4, r1
bt 2f
cmpnei r4, 0
bf 2f
/* d[i] != s[i] in word, so we check byte 1 ? */
xtrb0 r1, r2
mov r4, r1
xtrb0 r1, r7
#endif
/* get the result when d[i] != s[i] */
2:
subu r4, r1
mov r2, r4
jmp r15
/* return when d[i] == s[i] */
3:
subu r2, r7
jmp r15
/* cmp when d or s is not aligned */
4:
ldb r2, (r6,0)
ldb r7, (r3, 0)
cmpne r2, r7
bt 3b
addi r3, 1
addi r6, 1
cmpnei r2, 0
bt 4b
jmp r15
.size Wstrcmp, .-Wstrcmp
libc_hidden_def(Wstrcmp)
.weak Wstrcmp
#ifndef __UCLIBC_HAS_LOCALE__
/* libc_hidden_proto(Wstrcoll) */
strong_alias(Wstrcmp,Wstrcoll)
libc_hidden_def(Wstrcoll)
#endif
|