strlen.S 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. */
  8. #include <linux/linkage.h>
  9. ENTRY_CFI(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. .Loop:
  44. ld_s r2,[r3,4]
  45. ld.a r6,[r3,8]
  46. ; stall for load result
  47. sub r1,r2,r4
  48. bic_s r1,r1,r2
  49. sub r12,r6,r4
  50. bic r12,r12,r6
  51. or r12,r12,r1
  52. and r12,r12,r5
  53. breq r12,0,.Loop
  54. .Lend:
  55. and.f r1,r1,r5
  56. sub.ne r3,r3,4
  57. mov.eq r1,r12
  58. #ifdef __LITTLE_ENDIAN__
  59. sub_s r2,r1,1
  60. bic_s r2,r2,r1
  61. norm r1,r2
  62. sub_s r0,r0,3
  63. lsr_s r1,r1,3
  64. sub r0,r3,r0
  65. j_s.d [blink]
  66. sub r0,r0,r1
  67. #else /* BIG ENDIAN */
  68. lsr_s r1,r1,7
  69. mov.eq r2,r6
  70. bic_s r1,r1,r2
  71. norm r1,r1
  72. sub r0,r3,r0
  73. lsr_s r1,r1,3
  74. j_s.d [blink]
  75. add r0,r0,r1
  76. #endif /* ENDIAN */
  77. .Learly_end:
  78. b.d .Lend
  79. sub_s.ne r1,r1,r1
  80. END_CFI(strlen)