memset-archs.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (C) 2014-15 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. #undef PREALLOC_NOT_AVAIL
  10. ENTRY_CFI(memset)
  11. prefetchw [r0] ; Prefetch the write location
  12. mov.f 0, r2
  13. ;;; if size is zero
  14. jz.d [blink]
  15. mov r3, r0 ; don't clobber ret val
  16. ;;; if length < 8
  17. brls.d.nt r2, 8, .Lsmallchunk
  18. mov.f lp_count,r2
  19. and.f r4, r0, 0x03
  20. rsub lp_count, r4, 4
  21. lpnz @.Laligndestination
  22. ;; LOOP BEGIN
  23. stb.ab r1, [r3,1]
  24. sub r2, r2, 1
  25. .Laligndestination:
  26. ;;; Destination is aligned
  27. and r1, r1, 0xFF
  28. asl r4, r1, 8
  29. or r4, r4, r1
  30. asl r5, r4, 16
  31. or r5, r5, r4
  32. mov r4, r5
  33. sub3 lp_count, r2, 8
  34. cmp r2, 64
  35. bmsk.hi r2, r2, 5
  36. mov.ls lp_count, 0
  37. add3.hi r2, r2, 8
  38. ;;; Convert len to Dwords, unfold x8
  39. lsr.f lp_count, lp_count, 6
  40. lpnz @.Lset64bytes
  41. ;; LOOP START
  42. #ifdef PREALLOC_NOT_AVAIL
  43. prefetchw [r3, 64] ;Prefetch the next write location
  44. #else
  45. prealloc [r3, 64]
  46. #endif
  47. #ifdef CONFIG_ARC_HAS_LL64
  48. std.ab r4, [r3, 8]
  49. std.ab r4, [r3, 8]
  50. std.ab r4, [r3, 8]
  51. std.ab r4, [r3, 8]
  52. std.ab r4, [r3, 8]
  53. std.ab r4, [r3, 8]
  54. std.ab r4, [r3, 8]
  55. std.ab r4, [r3, 8]
  56. #else
  57. st.ab r4, [r3, 4]
  58. st.ab r4, [r3, 4]
  59. st.ab r4, [r3, 4]
  60. st.ab r4, [r3, 4]
  61. st.ab r4, [r3, 4]
  62. st.ab r4, [r3, 4]
  63. st.ab r4, [r3, 4]
  64. st.ab r4, [r3, 4]
  65. st.ab r4, [r3, 4]
  66. st.ab r4, [r3, 4]
  67. st.ab r4, [r3, 4]
  68. st.ab r4, [r3, 4]
  69. st.ab r4, [r3, 4]
  70. st.ab r4, [r3, 4]
  71. st.ab r4, [r3, 4]
  72. st.ab r4, [r3, 4]
  73. #endif
  74. .Lset64bytes:
  75. lsr.f lp_count, r2, 5 ;Last remaining max 124 bytes
  76. lpnz .Lset32bytes
  77. ;; LOOP START
  78. prefetchw [r3, 32] ;Prefetch the next write location
  79. #ifdef CONFIG_ARC_HAS_LL64
  80. std.ab r4, [r3, 8]
  81. std.ab r4, [r3, 8]
  82. std.ab r4, [r3, 8]
  83. std.ab r4, [r3, 8]
  84. #else
  85. st.ab r4, [r3, 4]
  86. st.ab r4, [r3, 4]
  87. st.ab r4, [r3, 4]
  88. st.ab r4, [r3, 4]
  89. st.ab r4, [r3, 4]
  90. st.ab r4, [r3, 4]
  91. st.ab r4, [r3, 4]
  92. st.ab r4, [r3, 4]
  93. #endif
  94. .Lset32bytes:
  95. and.f lp_count, r2, 0x1F ;Last remaining 31 bytes
  96. .Lsmallchunk:
  97. lpnz .Lcopy3bytes
  98. ;; LOOP START
  99. stb.ab r1, [r3, 1]
  100. .Lcopy3bytes:
  101. j [blink]
  102. END_CFI(memset)
  103. ENTRY_CFI(memzero)
  104. ; adjust bzero args to memset args
  105. mov r2, r1
  106. b.d memset ;tail call so need to tinker with blink
  107. mov r1, 0
  108. END_CFI(memzero)