3 * Imagination Technologies Limited.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY IMAGINATION TECHNOLOGIES LIMITED ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL IMAGINATION TECHNOLOGIES LIMITED BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #ifdef ANDROID_CHANGES
31 # include "machine/asm.h"
32 # include "machine/regdef.h"
34 # include "machine/asm.h"
35 # include "machine/regdef.h"
41 /* Technically strcmp should not read past the end of the strings being
42 compared. We will read a full word that may contain excess bits beyond
43 the NULL string terminator but unless ENABLE_READAHEAD is set, we will not
44 read the next word after the end of string. Setting ENABLE_READAHEAD will
45 improve performance but is technically illegal based on the definition of
47 #ifdef ENABLE_READAHEAD
50 # define DELAY_READ nop
53 /* Testing on a little endian machine showed using CLZ was a
54 performance loss, so we are not turning it on by default. */
55 #if defined(ENABLE_CLZ) && (__mips_isa_rev > 1)
59 /* Some asm.h files do not have the L macro definition. */
61 # if _MIPS_SIM == _ABIO32
62 # define L(label) $L ## label
64 # define L(label) .L ## label
68 /* Some asm.h files do not have the PTR_ADDIU macro definition. */
71 # define PTR_ADDIU daddiu
73 # define PTR_ADDIU addiu
77 /* Allow the routine to be named something else if desired. */
79 # define STRCMP_NAME strcmp
82 #ifdef ANDROID_CHANGES
92 bne t0, zero, L(byteloop)
94 /* Both strings are 4 byte aligned at this point. */
101 #define STRCMP32(OFFSET) \
105 bne v0, v1, L(worddiff); \
108 bne t0, zero, L(returnzero)
141 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
147 # if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
158 # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
160 beq t0, zero, L(wexit01)
162 bne t0, t1, L(wexit01)
167 beq t8, zero, L(wexit89)
169 bne t8, t9, L(wexit89)
174 beq t0, zero, L(wexit01)
176 bne t0, t1, L(wexit01)
180 # else /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */
182 beq t0, zero, L(wexit01)
184 bne t0, t1, L(wexit01)
189 beq t8, zero, L(wexit89)
191 bne t8, t9, L(wexit89)
196 beq t0, zero, L(wexit01)
198 bne t0, t1, L(wexit01)
202 # endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */
212 /* It might seem better to do the 'beq' instruction between the two 'lbu'
213 instructions so that the nop is not needed but testing showed that this
214 code is actually faster (based on glibc strcmp test). */
215 #define BYTECMP01(OFFSET) \
216 lbu v0, OFFSET(a0); \
217 lbu v1, OFFSET(a1); \
218 beq v0, zero, L(bexit01); \
220 bne v0, v1, L(bexit01)
222 #define BYTECMP89(OFFSET) \
223 lbu t8, OFFSET(a0); \
224 lbu t9, OFFSET(a1); \
225 beq t8, zero, L(bexit89); \
227 bne t8, t9, L(bexit89)