1 /* Copyright (c) 2017 SiFive Inc. All rights reserved.
3 This copyrighted material is made available to anyone wishing to use,
4 modify, copy, or redistribute it subject to the terms and conditions
5 of the FreeBSD License. This program is distributed in the hope that
6 it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
7 including the implied warranties of MERCHANTABILITY or FITNESS FOR
8 A PARTICULAR PURPOSE. A copy of this license is available at
9 http://www.opensource.org/licenses.
16 .type strcmp, @function
18 #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
31 .size strcmp, .-strcmp
44 .macro check_one_word i n
45 REG_L a2, \i*SZREG(a0)
46 REG_L a3, \i*SZREG(a1)
55 bne a2, a3, .Lmismatch
60 # fall through to .Lmismatch
72 bne a2, a3, .Lmisaligned
79 # examine full words at a time, favoring strings of a couple dozen chars
80 #if __riscv_xlen == 32
91 # backwards branch to .Lloop contained above
94 # words don't match, but a2 has no null byte.
96 #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
98 #if __riscv_xlen == 64
101 bne a4, a5, .Lmismatch_upper
104 bne a4, a5, .Lmismatch_upper
108 bne a4, a5, .Lmismatch_upper
110 srl a4, a2, 8*SZREG-16
111 srl a5, a3, 8*SZREG-16
118 srl a4, a4, 8*SZREG-16
119 srl a5, a5, 8*SZREG-16
132 #if __riscv_xlen == 64
135 bne a4, a5, .Lmismatch_lower
138 bne a4, a5, .Lmismatch_lower
142 bne a4, a5, .Lmismatch_lower
170 bnez a2, .Lmisaligned
176 # cases in which a null byte was detected
177 #if __riscv_xlen == 32
188 .size strcmp, .-strcmp
191 .section .srodata.cst8,"aM",@progbits,8
194 .dword 0x7f7f7f7f7f7f7f7f