strcpy-700.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  4. */
  5. /* If dst and src are 4 byte aligned, copy 8 bytes at a time.
  6. If the src is 4, but not 8 byte aligned, we first read 4 bytes to get
  7. it 8 byte aligned. Thus, we can do a little read-ahead, without
  8. dereferencing a cache line that we should not touch.
  9. Note that short and long instructions have been scheduled to avoid
  10. branch stalls.
  11. The beq_s to r3z could be made unaligned & long to avoid a stall
  12. there, but the it is not likely to be taken often, and it
  13. would also be likey to cost an unaligned mispredict at the next call. */
  14. #include <linux/linkage.h>
  15. ENTRY_CFI(strcpy)
  16. or r2,r0,r1
  17. bmsk_s r2,r2,1
  18. brne.d r2,0,charloop
  19. mov_s r10,r0
  20. ld_s r3,[r1,0]
  21. mov r8,0x01010101
  22. bbit0.d r1,2,loop_start
  23. ror r12,r8
  24. sub r2,r3,r8
  25. bic_s r2,r2,r3
  26. tst_s r2,r12
  27. bne r3z
  28. mov_s r4,r3
  29. .balign 4
  30. loop:
  31. ld.a r3,[r1,4]
  32. st.ab r4,[r10,4]
  33. loop_start:
  34. ld.a r4,[r1,4]
  35. sub r2,r3,r8
  36. bic_s r2,r2,r3
  37. tst_s r2,r12
  38. bne_s r3z
  39. st.ab r3,[r10,4]
  40. sub r2,r4,r8
  41. bic r2,r2,r4
  42. tst r2,r12
  43. beq loop
  44. mov_s r3,r4
  45. #ifdef __LITTLE_ENDIAN__
  46. r3z: bmsk.f r1,r3,7
  47. lsr_s r3,r3,8
  48. #else
  49. r3z: lsr.f r1,r3,24
  50. asl_s r3,r3,8
  51. #endif
  52. bne.d r3z
  53. stb.ab r1,[r10,1]
  54. j_s [blink]
  55. .balign 4
  56. charloop:
  57. ldb.ab r3,[r1,1]
  58. brne.d r3,0,charloop
  59. stb.ab r3,[r10,1]
  60. j [blink]
  61. END_CFI(strcpy)