Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Adrian Bunk | 88278ca | 2008-05-19 16:53:02 -0700 | [diff] [blame] | 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * strncmp.S: Hand optimized Sparc assembly of GCC output from GNU libc |
| 4 | * generic strncmp routine. |
| 5 | */ |
| 6 | |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 7 | #include <linux/linkage.h> |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 8 | #include <asm/export.h> |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | .text |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 11 | ENTRY(strncmp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | mov %o0, %g3 |
| 13 | mov 0, %o3 |
| 14 | |
| 15 | cmp %o2, 3 |
| 16 | ble 7f |
| 17 | mov 0, %g2 |
| 18 | |
| 19 | sra %o2, 2, %o4 |
| 20 | ldub [%g3], %o3 |
| 21 | |
| 22 | 0: |
| 23 | ldub [%o1], %g2 |
| 24 | add %g3, 1, %g3 |
| 25 | and %o3, 0xff, %o0 |
| 26 | |
| 27 | cmp %o0, 0 |
| 28 | be 8f |
| 29 | add %o1, 1, %o1 |
| 30 | |
| 31 | cmp %o0, %g2 |
| 32 | be,a 1f |
| 33 | ldub [%g3], %o3 |
| 34 | |
| 35 | retl |
| 36 | sub %o0, %g2, %o0 |
| 37 | |
| 38 | 1: |
| 39 | ldub [%o1], %g2 |
| 40 | add %g3,1, %g3 |
| 41 | and %o3, 0xff, %o0 |
| 42 | |
| 43 | cmp %o0, 0 |
| 44 | be 8f |
| 45 | add %o1, 1, %o1 |
| 46 | |
| 47 | cmp %o0, %g2 |
| 48 | be,a 1f |
| 49 | ldub [%g3], %o3 |
| 50 | |
| 51 | retl |
| 52 | sub %o0, %g2, %o0 |
| 53 | |
| 54 | 1: |
| 55 | ldub [%o1], %g2 |
| 56 | add %g3, 1, %g3 |
| 57 | and %o3, 0xff, %o0 |
| 58 | |
| 59 | cmp %o0, 0 |
| 60 | be 8f |
| 61 | add %o1, 1, %o1 |
| 62 | |
| 63 | cmp %o0, %g2 |
| 64 | be,a 1f |
| 65 | ldub [%g3], %o3 |
| 66 | |
| 67 | retl |
| 68 | sub %o0, %g2, %o0 |
| 69 | |
| 70 | 1: |
| 71 | ldub [%o1], %g2 |
| 72 | add %g3, 1, %g3 |
| 73 | and %o3, 0xff, %o0 |
| 74 | |
| 75 | cmp %o0, 0 |
| 76 | be 8f |
| 77 | add %o1, 1, %o1 |
| 78 | |
| 79 | cmp %o0, %g2 |
| 80 | be 1f |
| 81 | add %o4, -1, %o4 |
| 82 | |
| 83 | retl |
| 84 | sub %o0, %g2, %o0 |
| 85 | |
| 86 | 1: |
| 87 | |
| 88 | cmp %o4, 0 |
| 89 | bg,a 0b |
| 90 | ldub [%g3], %o3 |
| 91 | |
| 92 | b 7f |
| 93 | and %o2, 3, %o2 |
| 94 | |
| 95 | 9: |
| 96 | ldub [%o1], %g2 |
| 97 | add %g3, 1, %g3 |
| 98 | and %o3, 0xff, %o0 |
| 99 | |
| 100 | cmp %o0, 0 |
| 101 | be 8f |
| 102 | add %o1, 1, %o1 |
| 103 | |
| 104 | cmp %o0, %g2 |
| 105 | be 7f |
| 106 | add %o2, -1, %o2 |
| 107 | |
| 108 | 8: |
| 109 | retl |
| 110 | sub %o0, %g2, %o0 |
| 111 | |
| 112 | 7: |
| 113 | cmp %o2, 0 |
| 114 | bg,a 9b |
| 115 | ldub [%g3], %o3 |
| 116 | |
| 117 | and %g2, 0xff, %o0 |
| 118 | retl |
| 119 | sub %o3, %o0, %o0 |
David S. Miller | 8695c37 | 2012-05-11 20:33:22 -0700 | [diff] [blame] | 120 | ENDPROC(strncmp) |
Al Viro | d3867f04 | 2016-01-16 21:39:30 -0500 | [diff] [blame] | 121 | EXPORT_SYMBOL(strncmp) |