NGmemcpy.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509
  1. /* NGmemcpy.S: Niagara optimized memcpy.
  2. *
  3. * Copyright (C) 2006, 2007 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifdef __KERNEL__
  6. #include <linux/linkage.h>
  7. #include <asm/asi.h>
  8. #include <asm/thread_info.h>
  9. #define GLOBAL_SPARE %g7
  10. #define RESTORE_ASI(TMP) \
  11. ldub [%g6 + TI_CURRENT_DS], TMP; \
  12. wr TMP, 0x0, %asi;
  13. #else
  14. #define GLOBAL_SPARE %g5
  15. #define RESTORE_ASI(TMP) \
  16. wr %g0, ASI_PNF, %asi
  17. #endif
  18. #ifdef __sparc_v9__
  19. #define SAVE_AMOUNT 128
  20. #else
  21. #define SAVE_AMOUNT 64
  22. #endif
  23. #ifndef STORE_ASI
  24. #define STORE_ASI ASI_BLK_INIT_QUAD_LDD_P
  25. #endif
  26. #ifndef EX_LD
  27. #define EX_LD(x,y) x
  28. #endif
  29. #ifndef EX_ST
  30. #define EX_ST(x,y) x
  31. #endif
  32. #ifndef LOAD
  33. #ifndef MEMCPY_DEBUG
  34. #define LOAD(type,addr,dest) type [addr], dest
  35. #else
  36. #define LOAD(type,addr,dest) type##a [addr] 0x80, dest
  37. #endif
  38. #endif
  39. #ifndef LOAD_TWIN
  40. #define LOAD_TWIN(addr_reg,dest0,dest1) \
  41. ldda [addr_reg] ASI_BLK_INIT_QUAD_LDD_P, dest0
  42. #endif
  43. #ifndef STORE
  44. #define STORE(type,src,addr) type src, [addr]
  45. #endif
  46. #ifndef STORE_INIT
  47. #ifndef SIMULATE_NIAGARA_ON_NON_NIAGARA
  48. #define STORE_INIT(src,addr) stxa src, [addr] %asi
  49. #else
  50. #define STORE_INIT(src,addr) stx src, [addr + 0x00]
  51. #endif
  52. #endif
  53. #ifndef FUNC_NAME
  54. #define FUNC_NAME NGmemcpy
  55. #endif
  56. #ifndef PREAMBLE
  57. #define PREAMBLE
  58. #endif
  59. #ifndef XCC
  60. #define XCC xcc
  61. #endif
  62. .register %g2,#scratch
  63. .register %g3,#scratch
  64. .text
  65. #ifndef EX_RETVAL
  66. #define EX_RETVAL(x) x
  67. __restore_asi:
  68. ret
  69. wr %g0, ASI_AIUS, %asi
  70. restore
  71. ENTRY(NG_ret_i2_plus_i4_plus_1)
  72. ba,pt %xcc, __restore_asi
  73. add %i2, %i5, %i0
  74. ENDPROC(NG_ret_i2_plus_i4_plus_1)
  75. ENTRY(NG_ret_i2_plus_g1)
  76. ba,pt %xcc, __restore_asi
  77. add %i2, %g1, %i0
  78. ENDPROC(NG_ret_i2_plus_g1)
  79. ENTRY(NG_ret_i2_plus_g1_minus_8)
  80. sub %g1, 8, %g1
  81. ba,pt %xcc, __restore_asi
  82. add %i2, %g1, %i0
  83. ENDPROC(NG_ret_i2_plus_g1_minus_8)
  84. ENTRY(NG_ret_i2_plus_g1_minus_16)
  85. sub %g1, 16, %g1
  86. ba,pt %xcc, __restore_asi
  87. add %i2, %g1, %i0
  88. ENDPROC(NG_ret_i2_plus_g1_minus_16)
  89. ENTRY(NG_ret_i2_plus_g1_minus_24)
  90. sub %g1, 24, %g1
  91. ba,pt %xcc, __restore_asi
  92. add %i2, %g1, %i0
  93. ENDPROC(NG_ret_i2_plus_g1_minus_24)
  94. ENTRY(NG_ret_i2_plus_g1_minus_32)
  95. sub %g1, 32, %g1
  96. ba,pt %xcc, __restore_asi
  97. add %i2, %g1, %i0
  98. ENDPROC(NG_ret_i2_plus_g1_minus_32)
  99. ENTRY(NG_ret_i2_plus_g1_minus_40)
  100. sub %g1, 40, %g1
  101. ba,pt %xcc, __restore_asi
  102. add %i2, %g1, %i0
  103. ENDPROC(NG_ret_i2_plus_g1_minus_40)
  104. ENTRY(NG_ret_i2_plus_g1_minus_48)
  105. sub %g1, 48, %g1
  106. ba,pt %xcc, __restore_asi
  107. add %i2, %g1, %i0
  108. ENDPROC(NG_ret_i2_plus_g1_minus_48)
  109. ENTRY(NG_ret_i2_plus_g1_minus_56)
  110. sub %g1, 56, %g1
  111. ba,pt %xcc, __restore_asi
  112. add %i2, %g1, %i0
  113. ENDPROC(NG_ret_i2_plus_g1_minus_56)
  114. ENTRY(NG_ret_i2_plus_i4)
  115. ba,pt %xcc, __restore_asi
  116. add %i2, %i4, %i0
  117. ENDPROC(NG_ret_i2_plus_i4)
  118. ENTRY(NG_ret_i2_plus_i4_minus_8)
  119. sub %i4, 8, %i4
  120. ba,pt %xcc, __restore_asi
  121. add %i2, %i4, %i0
  122. ENDPROC(NG_ret_i2_plus_i4_minus_8)
  123. ENTRY(NG_ret_i2_plus_8)
  124. ba,pt %xcc, __restore_asi
  125. add %i2, 8, %i0
  126. ENDPROC(NG_ret_i2_plus_8)
  127. ENTRY(NG_ret_i2_plus_4)
  128. ba,pt %xcc, __restore_asi
  129. add %i2, 4, %i0
  130. ENDPROC(NG_ret_i2_plus_4)
  131. ENTRY(NG_ret_i2_plus_1)
  132. ba,pt %xcc, __restore_asi
  133. add %i2, 1, %i0
  134. ENDPROC(NG_ret_i2_plus_1)
  135. ENTRY(NG_ret_i2_plus_g1_plus_1)
  136. add %g1, 1, %g1
  137. ba,pt %xcc, __restore_asi
  138. add %i2, %g1, %i0
  139. ENDPROC(NG_ret_i2_plus_g1_plus_1)
  140. ENTRY(NG_ret_i2)
  141. ba,pt %xcc, __restore_asi
  142. mov %i2, %i0
  143. ENDPROC(NG_ret_i2)
  144. ENTRY(NG_ret_i2_and_7_plus_i4)
  145. and %i2, 7, %i2
  146. ba,pt %xcc, __restore_asi
  147. add %i2, %i4, %i0
  148. ENDPROC(NG_ret_i2_and_7_plus_i4)
  149. #endif
  150. .align 64
  151. .globl FUNC_NAME
  152. .type FUNC_NAME,#function
  153. FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
  154. PREAMBLE
  155. save %sp, -SAVE_AMOUNT, %sp
  156. srlx %i2, 31, %g2
  157. cmp %g2, 0
  158. tne %xcc, 5
  159. mov %i0, %o0
  160. cmp %i2, 0
  161. be,pn %XCC, 85f
  162. or %o0, %i1, %i3
  163. cmp %i2, 16
  164. blu,a,pn %XCC, 80f
  165. or %i3, %i2, %i3
  166. /* 2 blocks (128 bytes) is the minimum we can do the block
  167. * copy with. We need to ensure that we'll iterate at least
  168. * once in the block copy loop. At worst we'll need to align
  169. * the destination to a 64-byte boundary which can chew up
  170. * to (64 - 1) bytes from the length before we perform the
  171. * block copy loop.
  172. */
  173. cmp %i2, (2 * 64)
  174. blu,pt %XCC, 70f
  175. andcc %i3, 0x7, %g0
  176. /* %o0: dst
  177. * %i1: src
  178. * %i2: len (known to be >= 128)
  179. *
  180. * The block copy loops will use %i4/%i5,%g2/%g3 as
  181. * temporaries while copying the data.
  182. */
  183. LOAD(prefetch, %i1, #one_read)
  184. wr %g0, STORE_ASI, %asi
  185. /* Align destination on 64-byte boundary. */
  186. andcc %o0, (64 - 1), %i4
  187. be,pt %XCC, 2f
  188. sub %i4, 64, %i4
  189. sub %g0, %i4, %i4 ! bytes to align dst
  190. sub %i2, %i4, %i2
  191. 1: subcc %i4, 1, %i4
  192. EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_i4_plus_1)
  193. EX_ST(STORE(stb, %g1, %o0), NG_ret_i2_plus_i4_plus_1)
  194. add %i1, 1, %i1
  195. bne,pt %XCC, 1b
  196. add %o0, 1, %o0
  197. /* If the source is on a 16-byte boundary we can do
  198. * the direct block copy loop. If it is 8-byte aligned
  199. * we can do the 16-byte loads offset by -8 bytes and the
  200. * init stores offset by one register.
  201. *
  202. * If the source is not even 8-byte aligned, we need to do
  203. * shifting and masking (basically integer faligndata).
  204. *
  205. * The careful bit with init stores is that if we store
  206. * to any part of the cache line we have to store the whole
  207. * cacheline else we can end up with corrupt L2 cache line
  208. * contents. Since the loop works on 64-bytes of 64-byte
  209. * aligned store data at a time, this is easy to ensure.
  210. */
  211. 2:
  212. andcc %i1, (16 - 1), %i4
  213. andn %i2, (64 - 1), %g1 ! block copy loop iterator
  214. be,pt %XCC, 50f
  215. sub %i2, %g1, %i2 ! final sub-block copy bytes
  216. cmp %i4, 8
  217. be,pt %XCC, 10f
  218. sub %i1, %i4, %i1
  219. /* Neither 8-byte nor 16-byte aligned, shift and mask. */
  220. and %i4, 0x7, GLOBAL_SPARE
  221. sll GLOBAL_SPARE, 3, GLOBAL_SPARE
  222. mov 64, %i5
  223. EX_LD(LOAD_TWIN(%i1, %g2, %g3), NG_ret_i2_plus_g1)
  224. sub %i5, GLOBAL_SPARE, %i5
  225. mov 16, %o4
  226. mov 32, %o5
  227. mov 48, %o7
  228. mov 64, %i3
  229. bg,pn %XCC, 9f
  230. nop
  231. #define MIX_THREE_WORDS(WORD1, WORD2, WORD3, PRE_SHIFT, POST_SHIFT, TMP) \
  232. sllx WORD1, POST_SHIFT, WORD1; \
  233. srlx WORD2, PRE_SHIFT, TMP; \
  234. sllx WORD2, POST_SHIFT, WORD2; \
  235. or WORD1, TMP, WORD1; \
  236. srlx WORD3, PRE_SHIFT, TMP; \
  237. or WORD2, TMP, WORD2;
  238. 8: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
  239. MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
  240. LOAD(prefetch, %i1 + %i3, #one_read)
  241. EX_ST(STORE_INIT(%g2, %o0 + 0x00), NG_ret_i2_plus_g1)
  242. EX_ST(STORE_INIT(%g3, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  243. EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
  244. MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
  245. EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  246. EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  247. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  248. MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
  249. EX_ST(STORE_INIT(%g2, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  250. EX_ST(STORE_INIT(%g3, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  251. EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
  252. add %i1, 64, %i1
  253. MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
  254. EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  255. EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  256. subcc %g1, 64, %g1
  257. bne,pt %XCC, 8b
  258. add %o0, 64, %o0
  259. ba,pt %XCC, 60f
  260. add %i1, %i4, %i1
  261. 9: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
  262. MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
  263. LOAD(prefetch, %i1 + %i3, #one_read)
  264. EX_ST(STORE_INIT(%g3, %o0 + 0x00), NG_ret_i2_plus_g1)
  265. EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  266. EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
  267. MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
  268. EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  269. EX_ST(STORE_INIT(%g2, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  270. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  271. MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
  272. EX_ST(STORE_INIT(%g3, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  273. EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  274. EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
  275. add %i1, 64, %i1
  276. MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
  277. EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  278. EX_ST(STORE_INIT(%g2, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  279. subcc %g1, 64, %g1
  280. bne,pt %XCC, 9b
  281. add %o0, 64, %o0
  282. ba,pt %XCC, 60f
  283. add %i1, %i4, %i1
  284. 10: /* Destination is 64-byte aligned, source was only 8-byte
  285. * aligned but it has been subtracted by 8 and we perform
  286. * one twin load ahead, then add 8 back into source when
  287. * we finish the loop.
  288. */
  289. EX_LD(LOAD_TWIN(%i1, %o4, %o5), NG_ret_i2_plus_g1)
  290. mov 16, %o7
  291. mov 32, %g2
  292. mov 48, %g3
  293. mov 64, %o1
  294. 1: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
  295. LOAD(prefetch, %i1 + %o1, #one_read)
  296. EX_ST(STORE_INIT(%o5, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
  297. EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  298. EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
  299. EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  300. EX_ST(STORE_INIT(%o4, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  301. EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  302. EX_ST(STORE_INIT(%o5, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  303. EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  304. EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5), NG_ret_i2_plus_g1_minus_48)
  305. add %i1, 64, %i1
  306. EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  307. EX_ST(STORE_INIT(%o4, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  308. subcc %g1, 64, %g1
  309. bne,pt %XCC, 1b
  310. add %o0, 64, %o0
  311. ba,pt %XCC, 60f
  312. add %i1, 0x8, %i1
  313. 50: /* Destination is 64-byte aligned, and source is 16-byte
  314. * aligned.
  315. */
  316. mov 16, %o7
  317. mov 32, %g2
  318. mov 48, %g3
  319. mov 64, %o1
  320. 1: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5), NG_ret_i2_plus_g1)
  321. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
  322. LOAD(prefetch, %i1 + %o1, #one_read)
  323. EX_ST(STORE_INIT(%o4, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
  324. EX_ST(STORE_INIT(%o5, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  325. EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
  326. EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  327. EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  328. EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  329. add %i1, 64, %i1
  330. EX_ST(STORE_INIT(%o4, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  331. EX_ST(STORE_INIT(%o5, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  332. EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  333. EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  334. subcc %g1, 64, %g1
  335. bne,pt %XCC, 1b
  336. add %o0, 64, %o0
  337. /* fall through */
  338. 60:
  339. membar #Sync
  340. /* %i2 contains any final bytes still needed to be copied
  341. * over. If anything is left, we copy it one byte at a time.
  342. */
  343. RESTORE_ASI(%i3)
  344. brz,pt %i2, 85f
  345. sub %o0, %i1, %i3
  346. ba,a,pt %XCC, 90f
  347. .align 64
  348. 70: /* 16 < len <= 64 */
  349. bne,pn %XCC, 75f
  350. sub %o0, %i1, %i3
  351. 72:
  352. andn %i2, 0xf, %i4
  353. and %i2, 0xf, %i2
  354. 1: subcc %i4, 0x10, %i4
  355. EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4)
  356. add %i1, 0x08, %i1
  357. EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4)
  358. sub %i1, 0x08, %i1
  359. EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4)
  360. add %i1, 0x8, %i1
  361. EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_minus_8)
  362. bgu,pt %XCC, 1b
  363. add %i1, 0x8, %i1
  364. 73: andcc %i2, 0x8, %g0
  365. be,pt %XCC, 1f
  366. nop
  367. sub %i2, 0x8, %i2
  368. EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_8)
  369. EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_8)
  370. add %i1, 0x8, %i1
  371. 1: andcc %i2, 0x4, %g0
  372. be,pt %XCC, 1f
  373. nop
  374. sub %i2, 0x4, %i2
  375. EX_LD(LOAD(lduw, %i1, %i5), NG_ret_i2_plus_4)
  376. EX_ST(STORE(stw, %i5, %i1 + %i3), NG_ret_i2_plus_4)
  377. add %i1, 0x4, %i1
  378. 1: cmp %i2, 0
  379. be,pt %XCC, 85f
  380. nop
  381. ba,pt %xcc, 90f
  382. nop
  383. 75:
  384. andcc %o0, 0x7, %g1
  385. sub %g1, 0x8, %g1
  386. be,pn %icc, 2f
  387. sub %g0, %g1, %g1
  388. sub %i2, %g1, %i2
  389. 1: subcc %g1, 1, %g1
  390. EX_LD(LOAD(ldub, %i1, %i5), NG_ret_i2_plus_g1_plus_1)
  391. EX_ST(STORE(stb, %i5, %i1 + %i3), NG_ret_i2_plus_g1_plus_1)
  392. bgu,pt %icc, 1b
  393. add %i1, 1, %i1
  394. 2: add %i1, %i3, %o0
  395. andcc %i1, 0x7, %g1
  396. bne,pt %icc, 8f
  397. sll %g1, 3, %g1
  398. cmp %i2, 16
  399. bgeu,pt %icc, 72b
  400. nop
  401. ba,a,pt %xcc, 73b
  402. 8: mov 64, %i3
  403. andn %i1, 0x7, %i1
  404. EX_LD(LOAD(ldx, %i1, %g2), NG_ret_i2)
  405. sub %i3, %g1, %i3
  406. andn %i2, 0x7, %i4
  407. sllx %g2, %g1, %g2
  408. 1: add %i1, 0x8, %i1
  409. EX_LD(LOAD(ldx, %i1, %g3), NG_ret_i2_and_7_plus_i4)
  410. subcc %i4, 0x8, %i4
  411. srlx %g3, %i3, %i5
  412. or %i5, %g2, %i5
  413. EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4)
  414. add %o0, 0x8, %o0
  415. bgu,pt %icc, 1b
  416. sllx %g3, %g1, %g2
  417. srl %g1, 3, %g1
  418. andcc %i2, 0x7, %i2
  419. be,pn %icc, 85f
  420. add %i1, %g1, %i1
  421. ba,pt %xcc, 90f
  422. sub %o0, %i1, %i3
  423. .align 64
  424. 80: /* 0 < len <= 16 */
  425. andcc %i3, 0x3, %g0
  426. bne,pn %XCC, 90f
  427. sub %o0, %i1, %i3
  428. 1:
  429. subcc %i2, 4, %i2
  430. EX_LD(LOAD(lduw, %i1, %g1), NG_ret_i2_plus_4)
  431. EX_ST(STORE(stw, %g1, %i1 + %i3), NG_ret_i2_plus_4)
  432. bgu,pt %XCC, 1b
  433. add %i1, 4, %i1
  434. 85: ret
  435. restore EX_RETVAL(%i0), %g0, %o0
  436. .align 32
  437. 90:
  438. subcc %i2, 1, %i2
  439. EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_1)
  440. EX_ST(STORE(stb, %g1, %i1 + %i3), NG_ret_i2_plus_1)
  441. bgu,pt %XCC, 90b
  442. add %i1, 1, %i1
  443. ret
  444. restore EX_RETVAL(%i0), %g0, %o0
  445. .size FUNC_NAME, .-FUNC_NAME