NGmemcpy.S 13 KB

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