memcpy.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. .section ".text.hot.memcpy","ax"
  2. .balign 4
  3. .globl mempcpy
  4. mempcpy:
  5. mv a3, a0
  6. add a0, a0, a2
  7. j __memxcpy
  8. .type mempcpy, @function
  9. .size mempcpy, . - mempcpy
  10. .balign 4
  11. .globl memcpy
  12. memcpy:
  13. mv a3, a0
  14. .type memcpy, @function
  15. .size memcpy, . - memcpy
  16. .globl __memxcpy
  17. __memxcpy:
  18. or a5, a3, a1
  19. or a5, a5, a2
  20. andi a5, a5, 3
  21. bnez a5, __memxcpy_bytewise
  22. .type __memxcpy, @function
  23. .size __memxcpy, . - __memxcpy
  24. .globl __memxcpy_aligned
  25. __memxcpy_aligned:
  26. add a4, a3, a2
  27. andi a2, a2, 7*4
  28. .option norelax
  29. sub a5, zero, a2
  30. jr a5, %lo(.L_case0)
  31. .option relax
  32. .balign 4
  33. .L_aligned_loop:
  34. .option norvc
  35. li a2, 32
  36. .option rvc
  37. c.lw a5, 28(a1)
  38. c.sw a5, 28(a3)
  39. .L_case7:
  40. c.lw a5, 24(a1)
  41. c.sw a5, 24(a3)
  42. .L_case6:
  43. c.lw a5, 20(a1)
  44. c.sw a5, 20(a3)
  45. .L_case5:
  46. c.lw a5, 16(a1)
  47. c.sw a5, 16(a3)
  48. .L_case4:
  49. c.lw a5, 12(a1)
  50. c.sw a5, 12(a3)
  51. .L_case3:
  52. c.lw a5, 8(a1)
  53. c.sw a5, 8(a3)
  54. .L_case2:
  55. c.lw a5, 4(a1)
  56. c.sw a5, 4(a3)
  57. .L_case1:
  58. c.lw a5, 0(a1)
  59. c.sw a5, 0(a3)
  60. .L_case0:
  61. add a1, a1, a2
  62. add a3, a3, a2
  63. bltu a3, a4, .L_aligned_loop
  64. .L_empty:
  65. ret
  66. .type __memxcpy_aligned, @function
  67. .size __memxcpy_aligned, . - __memxcpy_aligned
  68. //
  69. // These can be used by I/O devices that need bytewise access
  70. //
  71. .balign 4
  72. memcpy_bytewise:
  73. .option norvc
  74. mv a0, a3
  75. .option rvc
  76. .type memcpy_bytewise, @function
  77. .size memcpy_bytewise, . - memcpy_bytewise
  78. .balign 4
  79. __memxcpy_bytewise:
  80. .option norvc
  81. add a4, a3, a2
  82. .option rvc
  83. .balign 4
  84. .L_bytewise_loop:
  85. lbu a5, 0(a1)
  86. sb a5, 0(a3)
  87. addi a1, a1, 1
  88. addi a3, a3, 1
  89. bltu a3, a4, .L_bytewise_loop
  90. ret
  91. .type __memxcpy_bytewise, @function
  92. .size __memxcpy_bytewise, . - __memxcpy_bytewise