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 | #ifdef __LITTLE_ENDIAN__ |
| 8 | #define WORD2 r2 |
| 9 | #define SHIFT r3 |
| 10 | #else /* __BIG_ENDIAN__ */ |
| 11 | #define WORD2 r3 |
| 12 | #define SHIFT r2 |
| 13 | #endif /* _ENDIAN__ */ |
| 14 | |
| 15 | .global memcmp |
| 16 | .align 4 |
| 17 | memcmp: |
| 18 | or %r12, %r0, %r1 |
| 19 | asl_s %r12, %r12, 30 |
| 20 | sub %r3, %r2, 1 |
| 21 | brls %r2, %r12, .Lbytewise |
| 22 | ld %r4, [%r0, 0] |
| 23 | ld %r5, [%r1, 0] |
| 24 | lsr.f %lp_count, %r3, 3 |
| 25 | lpne .Loop_end |
| 26 | ld_s WORD2, [%r0, 4] |
| 27 | ld_s %r12, [%r1, 4] |
| 28 | brne %r4, %r5, .Leven |
| 29 | ld.a %r4, [%r0, 8] |
| 30 | ld.a %r5, [%r1, 8] |
| 31 | brne WORD2, %r12, .Lodd |
| 32 | .Loop_end: |
| 33 | asl_s SHIFT, SHIFT, 3 |
| 34 | bhs_s .Last_cmp |
| 35 | brne %r4, %r5, .Leven |
| 36 | ld %r4, [%r0, 4] |
| 37 | ld %r5, [%r1, 4] |
| 38 | #ifdef __LITTLE_ENDIAN__ |
| 39 | nop_s |
| 40 | /* one more load latency cycle */ |
| 41 | .Last_cmp: |
| 42 | xor %r0, %r4, %r5 |
| 43 | bset %r0, %r0, SHIFT |
| 44 | sub_s %r1, %r0, 1 |
| 45 | bic_s %r1, %r1, %r0 |
| 46 | norm %r1, %r1 |
| 47 | b.d .Leven_cmp |
| 48 | and %r1, %r1, 24 |
| 49 | .Leven: |
| 50 | xor %r0, %r4, %r5 |
| 51 | sub_s %r1, %r0, 1 |
| 52 | bic_s %r1, %r1, %r0 |
| 53 | norm %r1, %r1 |
| 54 | /* slow track insn */ |
| 55 | and %r1, %r1, 24 |
| 56 | .Leven_cmp: |
| 57 | asl %r2, %r4, %r1 |
| 58 | asl %r12, %r5, %r1 |
| 59 | lsr_s %r2, %r2, 1 |
| 60 | lsr_s %r12, %r12, 1 |
| 61 | j_s.d [%blink] |
| 62 | sub %r0, %r2, %r12 |
| 63 | .balign 4 |
| 64 | .Lodd: |
| 65 | xor %r0, WORD2, %r12 |
| 66 | sub_s %r1, %r0, 1 |
| 67 | bic_s %r1, %r1, %r0 |
| 68 | norm %r1, %r1 |
| 69 | /* slow track insn */ |
| 70 | and %r1, %r1, 24 |
| 71 | asl_s %r2, %r2, %r1 |
| 72 | asl_s %r12, %r12, %r1 |
| 73 | lsr_s %r2, %r2, 1 |
| 74 | lsr_s %r12, %r12, 1 |
| 75 | j_s.d [%blink] |
| 76 | sub %r0, %r2, %r12 |
| 77 | #else /* __BIG_ENDIAN__ */ |
| 78 | .Last_cmp: |
| 79 | neg_s SHIFT, SHIFT |
| 80 | lsr %r4, %r4, SHIFT |
| 81 | lsr %r5, %r5, SHIFT |
| 82 | /* slow track insn */ |
| 83 | .Leven: |
| 84 | sub.f %r0, %r4, %r5 |
| 85 | mov.ne %r0, 1 |
| 86 | j_s.d [%blink] |
| 87 | bset.cs %r0, %r0, 31 |
| 88 | .Lodd: |
| 89 | cmp_s WORD2, %r12 |
| 90 | |
| 91 | mov_s %r0, 1 |
| 92 | j_s.d [%blink] |
| 93 | bset.cs %r0, %r0, 31 |
| 94 | #endif /* _ENDIAN__ */ |
| 95 | .balign 4 |
| 96 | .Lbytewise: |
| 97 | breq %r2, 0, .Lnil |
| 98 | ldb %r4, [%r0, 0] |
| 99 | ldb %r5, [%r1, 0] |
| 100 | lsr.f %lp_count, %r3 |
| 101 | lpne .Lbyte_end |
| 102 | ldb_s %r3, [%r0, 1] |
| 103 | ldb %r12, [%r1, 1] |
| 104 | brne %r4, %r5, .Lbyte_even |
| 105 | ldb.a %r4, [%r0, 2] |
| 106 | ldb.a %r5, [%r1, 2] |
| 107 | brne %r3, %r12, .Lbyte_odd |
| 108 | .Lbyte_end: |
| 109 | bcc .Lbyte_even |
| 110 | brne %r4, %r5, .Lbyte_even |
| 111 | ldb_s %r3, [%r0, 1] |
| 112 | ldb_s %r12, [%r1, 1] |
| 113 | .Lbyte_odd: |
| 114 | j_s.d [%blink] |
| 115 | sub %r0, %r3, %r12 |
| 116 | .Lbyte_even: |
| 117 | j_s.d [%blink] |
| 118 | sub %r0, %r4, %r5 |
| 119 | .Lnil: |
| 120 | j_s.d [%blink] |
| 121 | mov %r0, 0 |