memcpy.S 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. * Copyright (C) 2007 ARC International (UK) LTD
  4. *
  5. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  6. */
  7. #include <sysdep.h>
  8. /* This memcpy implementation does not support objects of 1GB or larger -
  9. the check for alignment does not work then. */
  10. /* We assume that most sources and destinations are aligned, and
  11. that also lengths are mostly a multiple of four, although to a lesser
  12. extent. */
  13. ENTRY(memcpy)
  14. or r3,r0,r1
  15. asl_s r3,r3,30
  16. mov_s r5,r0
  17. brls.d r2,r3,.Lcopy_bytewise
  18. sub.f r3,r2,1
  19. ld_s r12,[r1,0]
  20. asr.f lp_count,r3,3
  21. bbit0.d r3,2,.Lnox4
  22. bmsk_s r2,r2,1
  23. st.ab r12,[r5,4]
  24. ld.a r12,[r1,4]
  25. .Lnox4:
  26. lppnz .Lendloop
  27. ld_s r3,[r1,4]
  28. st.ab r12,[r5,4]
  29. ld.a r12,[r1,8]
  30. st.ab r3,[r5,4]
  31. .Lendloop:
  32. breq r2,0,.Last_store
  33. ld r3,[r5,0]
  34. #ifdef __LITTLE_ENDIAN__
  35. add3 r2,-1,r2
  36. ; uses long immediate
  37. xor_s r12,r12,r3
  38. bmsk r12,r12,r2
  39. xor_s r12,r12,r3
  40. #else /* BIG ENDIAN */
  41. sub3 r2,31,r2
  42. ; uses long immediate
  43. xor_s r3,r3,r12
  44. bmsk r3,r3,r2
  45. xor_s r12,r12,r3
  46. #endif /* ENDIAN */
  47. .Last_store:
  48. j_s.d [blink]
  49. st r12,[r5,0]
  50. .balign 4
  51. .Lcopy_bytewise:
  52. jcs [blink]
  53. ldb_s r12,[r1,0]
  54. lsr.f lp_count,r3
  55. bhs_s .Lnox1
  56. stb.ab r12,[r5,1]
  57. ldb.a r12,[r1,1]
  58. .Lnox1:
  59. lppnz .Lendbloop
  60. ldb_s r3,[r1,1]
  61. stb.ab r12,[r5,1]
  62. ldb.a r12,[r1,2]
  63. stb.ab r3,[r5,1]
  64. .Lendbloop:
  65. j_s.d [blink]
  66. stb r12,[r5,0]
  67. END(memcpy)
  68. libc_hidden_def(memcpy)