0001
0002
0003
0004
0005
0006 #include <linux/linkage.h>
0007
0008 ENTRY_CFI(strcmp)
0009 or r2, r0, r1
0010 bmsk_s r2, r2, 1
0011 brne r2, 0, @.Lcharloop
0012
0013 ;;; s1 and s2 are word aligned
0014 ld.ab r2, [r0, 4]
0015
0016 mov_s r12, 0x01010101
0017 ror r11, r12
0018 .align 4
0019 .LwordLoop:
0020 ld.ab r3, [r1, 4]
0021 ;; Detect NULL char in str1
0022 sub r4, r2, r12
0023 ld.ab r5, [r0, 4]
0024 bic r4, r4, r2
0025 and r4, r4, r11
0026 brne.d.nt r4, 0, .LfoundNULL
0027 ;; Check if the read locations are the same
0028 cmp r2, r3
0029 beq.d .LwordLoop
0030 mov.eq r2, r5
0031
0032 ;; A match is found, spot it out
0033 #ifdef __LITTLE_ENDIAN__
0034 swape r3, r3
0035 mov_s r0, 1
0036 swape r2, r2
0037 #else
0038 mov_s r0, 1
0039 #endif
0040 cmp_s r2, r3
0041 j_s.d [blink]
0042 bset.lo r0, r0, 31
0043
0044 .align 4
0045 .LfoundNULL:
0046 #ifdef __BIG_ENDIAN__
0047 swape r4, r4
0048 swape r2, r2
0049 swape r3, r3
0050 #endif
0051 ;; Find null byte
0052 ffs r0, r4
0053 bmsk r2, r2, r0
0054 bmsk r3, r3, r0
0055 swape r2, r2
0056 swape r3, r3
0057 ;; make the return value
0058 sub.f r0, r2, r3
0059 mov.hi r0, 1
0060 j_s.d [blink]
0061 bset.lo r0, r0, 31
0062
0063 .align 4
0064 .Lcharloop:
0065 ldb.ab r2, [r0, 1]
0066 ldb.ab r3, [r1, 1]
0067 nop
0068 breq r2, 0, .Lcmpend
0069 breq r2, r3, .Lcharloop
0070
0071 .align 4
0072 .Lcmpend:
0073 j_s.d [blink]
0074 sub r0, r2, r3
0075 END_CFI(strcmp)