Alexey Brodkin | 2272382 | 2014-02-04 12:56:15 +0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004, 2007-2010, 2011-2014 Synopsys, Inc. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | .global strlen |
| 8 | .align 4 |
| 9 | strlen: |
| 10 | or %r3, %r0, 7 |
| 11 | ld %r2, [%r3, -7] |
| 12 | ld.a %r6, [%r3, -3] |
| 13 | mov %r4, 0x01010101 |
| 14 | /* uses long immediate */ |
| 15 | #ifdef __LITTLE_ENDIAN__ |
| 16 | asl_s %r1, %r0, 3 |
| 17 | btst_s %r0, 2 |
| 18 | asl %r7, %r4, %r1 |
| 19 | ror %r5, %r4 |
| 20 | sub %r1, %r2, %r7 |
| 21 | bic_s %r1, %r1, %r2 |
| 22 | mov.eq %r7, %r4 |
| 23 | sub %r12, %r6, %r7 |
| 24 | bic %r12, %r12, %r6 |
| 25 | or.eq %r12, %r12, %r1 |
| 26 | and %r12, %r12, %r5 |
| 27 | brne %r12, 0, .Learly_end |
| 28 | #else /* __BIG_ENDIAN__ */ |
| 29 | ror %r5, %r4 |
| 30 | btst_s %r0, 2 |
| 31 | mov_s %r1, 31 |
| 32 | sub3 %r7, %r1, %r0 |
| 33 | sub %r1, %r2, %r4 |
| 34 | bic_s %r1, %r1, %r2 |
| 35 | bmsk %r1, %r1, %r7 |
| 36 | sub %r12, %r6, %r4 |
| 37 | bic %r12, %r12, %r6 |
| 38 | bmsk.ne %r12, %r12, %r7 |
| 39 | or.eq %r12, %r12, %r1 |
| 40 | and %r12, %r12, %r5 |
| 41 | brne %r12, 0, .Learly_end |
| 42 | #endif /* _ENDIAN__ */ |
| 43 | |
| 44 | .Loop: |
| 45 | ld_s %r2, [%r3, 4] |
| 46 | ld.a %r6, [%r3, 8] |
| 47 | /* stall for load result */ |
| 48 | sub %r1, %r2, %r4 |
| 49 | bic_s %r1, %r1, %r2 |
| 50 | sub %r12, %r6, %r4 |
| 51 | bic %r12, %r12, %r6 |
| 52 | or %r12, %r12, %r1 |
| 53 | and %r12, %r12, %r5 |
| 54 | breq %r12, 0, .Loop |
| 55 | .Lend: |
| 56 | and.f %r1, %r1, %r5 |
| 57 | sub.ne %r3, %r3, 4 |
| 58 | mov.eq %r1, %r12 |
| 59 | #ifdef __LITTLE_ENDIAN__ |
| 60 | sub_s %r2, %r1, 1 |
| 61 | bic_s %r2, %r2, %r1 |
| 62 | norm %r1, %r2 |
| 63 | sub_s %r0, %r0, 3 |
| 64 | lsr_s %r1, %r1, 3 |
| 65 | sub %r0, %r3, %r0 |
| 66 | j_s.d [%blink] |
| 67 | sub %r0, %r0, %r1 |
| 68 | #else /* __BIG_ENDIAN__ */ |
| 69 | lsr_s %r1, %r1, 7 |
| 70 | mov.eq %r2, %r6 |
| 71 | bic_s %r1, %r1, %r2 |
| 72 | norm %r1, %r1 |
| 73 | sub %r0, %r3, %r0 |
| 74 | lsr_s %r1, %r1, 3 |
| 75 | j_s.d [%blink] |
| 76 | add %r0, %r0, %r1 |
| 77 | #endif /* _ENDIAN */ |
| 78 | .Learly_end: |
| 79 | b.d .Lend |
| 80 | sub_s.ne %r1, %r1, %r1 |