memset.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Cloned and hacked for uClibc by Paul Mundt, December 2003 */
  2. /* Modified by SuperH, Inc. September 2003 */
  3. !
  4. ! Fast SH memset
  5. !
  6. ! by Toshiyasu Morita (tm@netcom.com)
  7. !
  8. ! SH5 code by J"orn Rennecke (joern.rennecke@superh.com)
  9. ! Copyright 2002 SuperH Ltd.
  10. !
  11. #ifdef __LITTLE_ENDIAN__
  12. #define SHHI shlld
  13. #define SHLO shlrd
  14. #else
  15. #define SHHI shlrd
  16. #define SHLO shlld
  17. #endif
  18. .section .text..SHmedia32,"ax"
  19. .globl memset
  20. .type memset, @function
  21. .align 5
  22. memset:
  23. pta/l multiquad, tr0
  24. andi r2, 7, r22
  25. ptabs r18, tr2
  26. mshflo.b r3,r3,r3
  27. add r4, r22, r23
  28. mperm.w r3, r63, r3 // Fill pattern now in every byte of r3
  29. movi 8, r9
  30. bgtu/u r23, r9, tr0 // multiquad
  31. beqi/u r4, 0, tr2 // Return with size 0 - ensures no mem accesses
  32. ldlo.q r2, 0, r7
  33. shlli r4, 2, r4
  34. movi -1, r8
  35. SHHI r8, r4, r8
  36. SHHI r8, r4, r8
  37. mcmv r7, r8, r3
  38. stlo.q r2, 0, r3
  39. blink tr2, r63
  40. multiquad:
  41. pta/l lastquad, tr0
  42. stlo.q r2, 0, r3
  43. shlri r23, 3, r24
  44. add r2, r4, r5
  45. beqi/u r24, 1, tr0 // lastquad
  46. pta/l loop, tr1
  47. sub r2, r22, r25
  48. andi r5, -8, r20 // calculate end address and
  49. addi r20, -7*8, r8 // loop end address; This might overflow, so we need
  50. // to use a different test before we start the loop
  51. bge/u r24, r9, tr1 // loop
  52. st.q r25, 8, r3
  53. st.q r20, -8, r3
  54. shlri r24, 1, r24
  55. beqi/u r24, 1, tr0 // lastquad
  56. st.q r25, 16, r3
  57. st.q r20, -16, r3
  58. beqi/u r24, 2, tr0 // lastquad
  59. st.q r25, 24, r3
  60. st.q r20, -24, r3
  61. lastquad:
  62. sthi.q r5, -1, r3
  63. blink tr2,r63
  64. loop:
  65. !!! alloco r25, 32 // QQQ comment out for short-term fix to SHUK #3895.
  66. // QQQ commenting out is locically correct, but sub-optimal
  67. // QQQ Sean McGoogan - 4th April 2003.
  68. st.q r25, 8, r3
  69. st.q r25, 16, r3
  70. st.q r25, 24, r3
  71. st.q r25, 32, r3
  72. addi r25, 32, r25
  73. bgeu/l r8, r25, tr1 // loop
  74. st.q r20, -40, r3
  75. st.q r20, -32, r3
  76. st.q r20, -24, r3
  77. st.q r20, -16, r3
  78. st.q r20, -8, r3
  79. sthi.q r5, -1, r3
  80. blink tr2,r63
  81. .size memset, . - memset