NGmemcpy.S 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. wr %g0, ASI_AIUS, %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. wr %g0, ASI_AIUS, %asi
  69. ret
  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_plus_16)
  115. add %i4, 16, %i4
  116. ba,pt %xcc, __restore_asi
  117. add %i2, %i4, %i0
  118. ENDPROC(NG_ret_i2_plus_i4_plus_16)
  119. ENTRY(NG_ret_i2_plus_i4_plus_8)
  120. add %i4, 8, %i4
  121. ba,pt %xcc, __restore_asi
  122. add %i2, %i4, %i0
  123. ENDPROC(NG_ret_i2_plus_i4_plus_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. ENTRY(NG_ret_i2_and_7_plus_i4_plus_8)
  151. and %i2, 7, %i2
  152. add %i4, 8, %i4
  153. ba,pt %xcc, __restore_asi
  154. add %i2, %i4, %i0
  155. ENDPROC(NG_ret_i2_and_7_plus_i4)
  156. #endif
  157. .align 64
  158. .globl FUNC_NAME
  159. .type FUNC_NAME,#function
  160. FUNC_NAME: /* %i0=dst, %i1=src, %i2=len */
  161. PREAMBLE
  162. save %sp, -SAVE_AMOUNT, %sp
  163. srlx %i2, 31, %g2
  164. cmp %g2, 0
  165. tne %xcc, 5
  166. mov %i0, %o0
  167. cmp %i2, 0
  168. be,pn %XCC, 85f
  169. or %o0, %i1, %i3
  170. cmp %i2, 16
  171. blu,a,pn %XCC, 80f
  172. or %i3, %i2, %i3
  173. /* 2 blocks (128 bytes) is the minimum we can do the block
  174. * copy with. We need to ensure that we'll iterate at least
  175. * once in the block copy loop. At worst we'll need to align
  176. * the destination to a 64-byte boundary which can chew up
  177. * to (64 - 1) bytes from the length before we perform the
  178. * block copy loop.
  179. */
  180. cmp %i2, (2 * 64)
  181. blu,pt %XCC, 70f
  182. andcc %i3, 0x7, %g0
  183. /* %o0: dst
  184. * %i1: src
  185. * %i2: len (known to be >= 128)
  186. *
  187. * The block copy loops will use %i4/%i5,%g2/%g3 as
  188. * temporaries while copying the data.
  189. */
  190. LOAD(prefetch, %i1, #one_read)
  191. wr %g0, STORE_ASI, %asi
  192. /* Align destination on 64-byte boundary. */
  193. andcc %o0, (64 - 1), %i4
  194. be,pt %XCC, 2f
  195. sub %i4, 64, %i4
  196. sub %g0, %i4, %i4 ! bytes to align dst
  197. sub %i2, %i4, %i2
  198. 1: subcc %i4, 1, %i4
  199. EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_i4_plus_1)
  200. EX_ST(STORE(stb, %g1, %o0), NG_ret_i2_plus_i4_plus_1)
  201. add %i1, 1, %i1
  202. bne,pt %XCC, 1b
  203. add %o0, 1, %o0
  204. /* If the source is on a 16-byte boundary we can do
  205. * the direct block copy loop. If it is 8-byte aligned
  206. * we can do the 16-byte loads offset by -8 bytes and the
  207. * init stores offset by one register.
  208. *
  209. * If the source is not even 8-byte aligned, we need to do
  210. * shifting and masking (basically integer faligndata).
  211. *
  212. * The careful bit with init stores is that if we store
  213. * to any part of the cache line we have to store the whole
  214. * cacheline else we can end up with corrupt L2 cache line
  215. * contents. Since the loop works on 64-bytes of 64-byte
  216. * aligned store data at a time, this is easy to ensure.
  217. */
  218. 2:
  219. andcc %i1, (16 - 1), %i4
  220. andn %i2, (64 - 1), %g1 ! block copy loop iterator
  221. be,pt %XCC, 50f
  222. sub %i2, %g1, %i2 ! final sub-block copy bytes
  223. cmp %i4, 8
  224. be,pt %XCC, 10f
  225. sub %i1, %i4, %i1
  226. /* Neither 8-byte nor 16-byte aligned, shift and mask. */
  227. and %i4, 0x7, GLOBAL_SPARE
  228. sll GLOBAL_SPARE, 3, GLOBAL_SPARE
  229. mov 64, %i5
  230. EX_LD(LOAD_TWIN(%i1, %g2, %g3), NG_ret_i2_plus_g1)
  231. sub %i5, GLOBAL_SPARE, %i5
  232. mov 16, %o4
  233. mov 32, %o5
  234. mov 48, %o7
  235. mov 64, %i3
  236. bg,pn %XCC, 9f
  237. nop
  238. #define MIX_THREE_WORDS(WORD1, WORD2, WORD3, PRE_SHIFT, POST_SHIFT, TMP) \
  239. sllx WORD1, POST_SHIFT, WORD1; \
  240. srlx WORD2, PRE_SHIFT, TMP; \
  241. sllx WORD2, POST_SHIFT, WORD2; \
  242. or WORD1, TMP, WORD1; \
  243. srlx WORD3, PRE_SHIFT, TMP; \
  244. or WORD2, TMP, WORD2;
  245. 8: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
  246. MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
  247. LOAD(prefetch, %i1 + %i3, #one_read)
  248. EX_ST(STORE_INIT(%g2, %o0 + 0x00), NG_ret_i2_plus_g1)
  249. EX_ST(STORE_INIT(%g3, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  250. EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
  251. MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
  252. EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  253. EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  254. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  255. MIX_THREE_WORDS(%g2, %g3, %o2, %i5, GLOBAL_SPARE, %o1)
  256. EX_ST(STORE_INIT(%g2, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  257. EX_ST(STORE_INIT(%g3, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  258. EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
  259. add %i1, 64, %i1
  260. MIX_THREE_WORDS(%o2, %o3, %g2, %i5, GLOBAL_SPARE, %o1)
  261. EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  262. EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  263. subcc %g1, 64, %g1
  264. bne,pt %XCC, 8b
  265. add %o0, 64, %o0
  266. ba,pt %XCC, 60f
  267. add %i1, %i4, %i1
  268. 9: EX_LD(LOAD_TWIN(%i1 + %o4, %o2, %o3), NG_ret_i2_plus_g1)
  269. MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
  270. LOAD(prefetch, %i1 + %i3, #one_read)
  271. EX_ST(STORE_INIT(%g3, %o0 + 0x00), NG_ret_i2_plus_g1)
  272. EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  273. EX_LD(LOAD_TWIN(%i1 + %o5, %g2, %g3), NG_ret_i2_plus_g1_minus_16)
  274. MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
  275. EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  276. EX_ST(STORE_INIT(%g2, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  277. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  278. MIX_THREE_WORDS(%g3, %o2, %o3, %i5, GLOBAL_SPARE, %o1)
  279. EX_ST(STORE_INIT(%g3, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  280. EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  281. EX_LD(LOAD_TWIN(%i1 + %i3, %g2, %g3), NG_ret_i2_plus_g1_minus_48)
  282. add %i1, 64, %i1
  283. MIX_THREE_WORDS(%o3, %g2, %g3, %i5, GLOBAL_SPARE, %o1)
  284. EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  285. EX_ST(STORE_INIT(%g2, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  286. subcc %g1, 64, %g1
  287. bne,pt %XCC, 9b
  288. add %o0, 64, %o0
  289. ba,pt %XCC, 60f
  290. add %i1, %i4, %i1
  291. 10: /* Destination is 64-byte aligned, source was only 8-byte
  292. * aligned but it has been subtracted by 8 and we perform
  293. * one twin load ahead, then add 8 back into source when
  294. * we finish the loop.
  295. */
  296. EX_LD(LOAD_TWIN(%i1, %o4, %o5), NG_ret_i2_plus_g1)
  297. mov 16, %o7
  298. mov 32, %g2
  299. mov 48, %g3
  300. mov 64, %o1
  301. 1: EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
  302. LOAD(prefetch, %i1 + %o1, #one_read)
  303. EX_ST(STORE_INIT(%o5, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
  304. EX_ST(STORE_INIT(%o2, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  305. EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
  306. EX_ST(STORE_INIT(%o3, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  307. EX_ST(STORE_INIT(%o4, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  308. EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  309. EX_ST(STORE_INIT(%o5, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  310. EX_ST(STORE_INIT(%o2, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  311. EX_LD(LOAD_TWIN(%i1 + %o1, %o4, %o5), NG_ret_i2_plus_g1_minus_48)
  312. add %i1, 64, %i1
  313. EX_ST(STORE_INIT(%o3, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  314. EX_ST(STORE_INIT(%o4, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  315. subcc %g1, 64, %g1
  316. bne,pt %XCC, 1b
  317. add %o0, 64, %o0
  318. ba,pt %XCC, 60f
  319. add %i1, 0x8, %i1
  320. 50: /* Destination is 64-byte aligned, and source is 16-byte
  321. * aligned.
  322. */
  323. mov 16, %o7
  324. mov 32, %g2
  325. mov 48, %g3
  326. mov 64, %o1
  327. 1: EX_LD(LOAD_TWIN(%i1 + %g0, %o4, %o5), NG_ret_i2_plus_g1)
  328. EX_LD(LOAD_TWIN(%i1 + %o7, %o2, %o3), NG_ret_i2_plus_g1)
  329. LOAD(prefetch, %i1 + %o1, #one_read)
  330. EX_ST(STORE_INIT(%o4, %o0 + 0x00), NG_ret_i2_plus_g1) ! initializes cache line
  331. EX_ST(STORE_INIT(%o5, %o0 + 0x08), NG_ret_i2_plus_g1_minus_8)
  332. EX_LD(LOAD_TWIN(%i1 + %g2, %o4, %o5), NG_ret_i2_plus_g1_minus_16)
  333. EX_ST(STORE_INIT(%o2, %o0 + 0x10), NG_ret_i2_plus_g1_minus_16)
  334. EX_ST(STORE_INIT(%o3, %o0 + 0x18), NG_ret_i2_plus_g1_minus_24)
  335. EX_LD(LOAD_TWIN(%i1 + %g3, %o2, %o3), NG_ret_i2_plus_g1_minus_32)
  336. add %i1, 64, %i1
  337. EX_ST(STORE_INIT(%o4, %o0 + 0x20), NG_ret_i2_plus_g1_minus_32)
  338. EX_ST(STORE_INIT(%o5, %o0 + 0x28), NG_ret_i2_plus_g1_minus_40)
  339. EX_ST(STORE_INIT(%o2, %o0 + 0x30), NG_ret_i2_plus_g1_minus_48)
  340. EX_ST(STORE_INIT(%o3, %o0 + 0x38), NG_ret_i2_plus_g1_minus_56)
  341. subcc %g1, 64, %g1
  342. bne,pt %XCC, 1b
  343. add %o0, 64, %o0
  344. /* fall through */
  345. 60:
  346. membar #Sync
  347. /* %i2 contains any final bytes still needed to be copied
  348. * over. If anything is left, we copy it one byte at a time.
  349. */
  350. RESTORE_ASI(%i3)
  351. brz,pt %i2, 85f
  352. sub %o0, %i1, %i3
  353. ba,a,pt %XCC, 90f
  354. nop
  355. .align 64
  356. 70: /* 16 < len <= 64 */
  357. bne,pn %XCC, 75f
  358. sub %o0, %i1, %i3
  359. 72:
  360. andn %i2, 0xf, %i4
  361. and %i2, 0xf, %i2
  362. 1: subcc %i4, 0x10, %i4
  363. EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_i4_plus_16)
  364. add %i1, 0x08, %i1
  365. EX_LD(LOAD(ldx, %i1, %g1), NG_ret_i2_plus_i4_plus_16)
  366. sub %i1, 0x08, %i1
  367. EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_i4_plus_16)
  368. add %i1, 0x8, %i1
  369. EX_ST(STORE(stx, %g1, %i1 + %i3), NG_ret_i2_plus_i4_plus_8)
  370. bgu,pt %XCC, 1b
  371. add %i1, 0x8, %i1
  372. 73: andcc %i2, 0x8, %g0
  373. be,pt %XCC, 1f
  374. nop
  375. sub %i2, 0x8, %i2
  376. EX_LD(LOAD(ldx, %i1, %o4), NG_ret_i2_plus_8)
  377. EX_ST(STORE(stx, %o4, %i1 + %i3), NG_ret_i2_plus_8)
  378. add %i1, 0x8, %i1
  379. 1: andcc %i2, 0x4, %g0
  380. be,pt %XCC, 1f
  381. nop
  382. sub %i2, 0x4, %i2
  383. EX_LD(LOAD(lduw, %i1, %i5), NG_ret_i2_plus_4)
  384. EX_ST(STORE(stw, %i5, %i1 + %i3), NG_ret_i2_plus_4)
  385. add %i1, 0x4, %i1
  386. 1: cmp %i2, 0
  387. be,pt %XCC, 85f
  388. nop
  389. ba,pt %xcc, 90f
  390. nop
  391. 75:
  392. andcc %o0, 0x7, %g1
  393. sub %g1, 0x8, %g1
  394. be,pn %icc, 2f
  395. sub %g0, %g1, %g1
  396. sub %i2, %g1, %i2
  397. 1: subcc %g1, 1, %g1
  398. EX_LD(LOAD(ldub, %i1, %i5), NG_ret_i2_plus_g1_plus_1)
  399. EX_ST(STORE(stb, %i5, %i1 + %i3), NG_ret_i2_plus_g1_plus_1)
  400. bgu,pt %icc, 1b
  401. add %i1, 1, %i1
  402. 2: add %i1, %i3, %o0
  403. andcc %i1, 0x7, %g1
  404. bne,pt %icc, 8f
  405. sll %g1, 3, %g1
  406. cmp %i2, 16
  407. bgeu,pt %icc, 72b
  408. nop
  409. ba,a,pt %xcc, 73b
  410. 8: mov 64, %i3
  411. andn %i1, 0x7, %i1
  412. EX_LD(LOAD(ldx, %i1, %g2), NG_ret_i2)
  413. sub %i3, %g1, %i3
  414. andn %i2, 0x7, %i4
  415. sllx %g2, %g1, %g2
  416. 1: add %i1, 0x8, %i1
  417. EX_LD(LOAD(ldx, %i1, %g3), NG_ret_i2_and_7_plus_i4)
  418. subcc %i4, 0x8, %i4
  419. srlx %g3, %i3, %i5
  420. or %i5, %g2, %i5
  421. EX_ST(STORE(stx, %i5, %o0), NG_ret_i2_and_7_plus_i4_plus_8)
  422. add %o0, 0x8, %o0
  423. bgu,pt %icc, 1b
  424. sllx %g3, %g1, %g2
  425. srl %g1, 3, %g1
  426. andcc %i2, 0x7, %i2
  427. be,pn %icc, 85f
  428. add %i1, %g1, %i1
  429. ba,pt %xcc, 90f
  430. sub %o0, %i1, %i3
  431. .align 64
  432. 80: /* 0 < len <= 16 */
  433. andcc %i3, 0x3, %g0
  434. bne,pn %XCC, 90f
  435. sub %o0, %i1, %i3
  436. 1:
  437. subcc %i2, 4, %i2
  438. EX_LD(LOAD(lduw, %i1, %g1), NG_ret_i2_plus_4)
  439. EX_ST(STORE(stw, %g1, %i1 + %i3), NG_ret_i2_plus_4)
  440. bgu,pt %XCC, 1b
  441. add %i1, 4, %i1
  442. 85: ret
  443. restore EX_RETVAL(%i0), %g0, %o0
  444. .align 32
  445. 90:
  446. subcc %i2, 1, %i2
  447. EX_LD(LOAD(ldub, %i1, %g1), NG_ret_i2_plus_1)
  448. EX_ST(STORE(stb, %g1, %i1 + %i3), NG_ret_i2_plus_1)
  449. bgu,pt %XCC, 90b
  450. add %i1, 1, %i1
  451. ret
  452. restore EX_RETVAL(%i0), %g0, %o0
  453. .size FUNC_NAME, .-FUNC_NAME