NG2memcpy.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /* NG2memcpy.S: Niagara-2 optimized memcpy.
  2. *
  3. * Copyright (C) 2007 David S. Miller (davem@davemloft.net)
  4. */
  5. #ifdef __KERNEL__
  6. #include <linux/linkage.h>
  7. #include <asm/visasm.h>
  8. #include <asm/asi.h>
  9. #define GLOBAL_SPARE %g7
  10. #else
  11. #define ASI_PNF 0x82
  12. #define ASI_BLK_P 0xf0
  13. #define ASI_BLK_INIT_QUAD_LDD_P 0xe2
  14. #define FPRS_FEF 0x04
  15. #ifdef MEMCPY_DEBUG
  16. #define VISEntryHalf rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs; \
  17. clr %g1; clr %g2; clr %g3; clr %g5; subcc %g0, %g0, %g0;
  18. #define VISExitHalf and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
  19. #else
  20. #define VISEntryHalf rd %fprs, %o5; wr %g0, FPRS_FEF, %fprs
  21. #define VISExitHalf and %o5, FPRS_FEF, %o5; wr %o5, 0x0, %fprs
  22. #endif
  23. #define GLOBAL_SPARE %g5
  24. #endif
  25. #ifndef STORE_ASI
  26. #ifndef SIMULATE_NIAGARA_ON_NON_NIAGARA
  27. #define STORE_ASI ASI_BLK_INIT_QUAD_LDD_P
  28. #else
  29. #define STORE_ASI 0x80 /* ASI_P */
  30. #endif
  31. #endif
  32. #ifndef EX_LD
  33. #define EX_LD(x,y) x
  34. #endif
  35. #ifndef EX_LD_FP
  36. #define EX_LD_FP(x,y) x
  37. #endif
  38. #ifndef EX_ST
  39. #define EX_ST(x,y) x
  40. #endif
  41. #ifndef EX_ST_FP
  42. #define EX_ST_FP(x,y) x
  43. #endif
  44. #ifndef LOAD
  45. #define LOAD(type,addr,dest) type [addr], dest
  46. #endif
  47. #ifndef LOAD_BLK
  48. #define LOAD_BLK(addr,dest) ldda [addr] ASI_BLK_P, dest
  49. #endif
  50. #ifndef STORE
  51. #ifndef MEMCPY_DEBUG
  52. #define STORE(type,src,addr) type src, [addr]
  53. #else
  54. #define STORE(type,src,addr) type##a src, [addr] 0x80
  55. #endif
  56. #endif
  57. #ifndef STORE_BLK
  58. #define STORE_BLK(src,addr) stda src, [addr] ASI_BLK_P
  59. #endif
  60. #ifndef STORE_INIT
  61. #define STORE_INIT(src,addr) stxa src, [addr] STORE_ASI
  62. #endif
  63. #ifndef FUNC_NAME
  64. #define FUNC_NAME NG2memcpy
  65. #endif
  66. #ifndef PREAMBLE
  67. #define PREAMBLE
  68. #endif
  69. #ifndef XCC
  70. #define XCC xcc
  71. #endif
  72. #define FREG_FROB(x0, x1, x2, x3, x4, x5, x6, x7, x8) \
  73. faligndata %x0, %x1, %f0; \
  74. faligndata %x1, %x2, %f2; \
  75. faligndata %x2, %x3, %f4; \
  76. faligndata %x3, %x4, %f6; \
  77. faligndata %x4, %x5, %f8; \
  78. faligndata %x5, %x6, %f10; \
  79. faligndata %x6, %x7, %f12; \
  80. faligndata %x7, %x8, %f14;
  81. #define FREG_MOVE_1(x0) \
  82. fsrc2 %x0, %f0;
  83. #define FREG_MOVE_2(x0, x1) \
  84. fsrc2 %x0, %f0; \
  85. fsrc2 %x1, %f2;
  86. #define FREG_MOVE_3(x0, x1, x2) \
  87. fsrc2 %x0, %f0; \
  88. fsrc2 %x1, %f2; \
  89. fsrc2 %x2, %f4;
  90. #define FREG_MOVE_4(x0, x1, x2, x3) \
  91. fsrc2 %x0, %f0; \
  92. fsrc2 %x1, %f2; \
  93. fsrc2 %x2, %f4; \
  94. fsrc2 %x3, %f6;
  95. #define FREG_MOVE_5(x0, x1, x2, x3, x4) \
  96. fsrc2 %x0, %f0; \
  97. fsrc2 %x1, %f2; \
  98. fsrc2 %x2, %f4; \
  99. fsrc2 %x3, %f6; \
  100. fsrc2 %x4, %f8;
  101. #define FREG_MOVE_6(x0, x1, x2, x3, x4, x5) \
  102. fsrc2 %x0, %f0; \
  103. fsrc2 %x1, %f2; \
  104. fsrc2 %x2, %f4; \
  105. fsrc2 %x3, %f6; \
  106. fsrc2 %x4, %f8; \
  107. fsrc2 %x5, %f10;
  108. #define FREG_MOVE_7(x0, x1, x2, x3, x4, x5, x6) \
  109. fsrc2 %x0, %f0; \
  110. fsrc2 %x1, %f2; \
  111. fsrc2 %x2, %f4; \
  112. fsrc2 %x3, %f6; \
  113. fsrc2 %x4, %f8; \
  114. fsrc2 %x5, %f10; \
  115. fsrc2 %x6, %f12;
  116. #define FREG_MOVE_8(x0, x1, x2, x3, x4, x5, x6, x7) \
  117. fsrc2 %x0, %f0; \
  118. fsrc2 %x1, %f2; \
  119. fsrc2 %x2, %f4; \
  120. fsrc2 %x3, %f6; \
  121. fsrc2 %x4, %f8; \
  122. fsrc2 %x5, %f10; \
  123. fsrc2 %x6, %f12; \
  124. fsrc2 %x7, %f14;
  125. #define FREG_LOAD_1(base, x0) \
  126. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1)
  127. #define FREG_LOAD_2(base, x0, x1) \
  128. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  129. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1);
  130. #define FREG_LOAD_3(base, x0, x1, x2) \
  131. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  132. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
  133. EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1);
  134. #define FREG_LOAD_4(base, x0, x1, x2, x3) \
  135. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  136. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
  137. EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
  138. EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1);
  139. #define FREG_LOAD_5(base, x0, x1, x2, x3, x4) \
  140. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  141. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
  142. EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
  143. EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
  144. EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1);
  145. #define FREG_LOAD_6(base, x0, x1, x2, x3, x4, x5) \
  146. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  147. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
  148. EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
  149. EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
  150. EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
  151. EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1);
  152. #define FREG_LOAD_7(base, x0, x1, x2, x3, x4, x5, x6) \
  153. EX_LD_FP(LOAD(ldd, base + 0x00, %x0), NG2_retl_o2_plus_g1); \
  154. EX_LD_FP(LOAD(ldd, base + 0x08, %x1), NG2_retl_o2_plus_g1); \
  155. EX_LD_FP(LOAD(ldd, base + 0x10, %x2), NG2_retl_o2_plus_g1); \
  156. EX_LD_FP(LOAD(ldd, base + 0x18, %x3), NG2_retl_o2_plus_g1); \
  157. EX_LD_FP(LOAD(ldd, base + 0x20, %x4), NG2_retl_o2_plus_g1); \
  158. EX_LD_FP(LOAD(ldd, base + 0x28, %x5), NG2_retl_o2_plus_g1); \
  159. EX_LD_FP(LOAD(ldd, base + 0x30, %x6), NG2_retl_o2_plus_g1);
  160. .register %g2,#scratch
  161. .register %g3,#scratch
  162. .text
  163. #ifndef EX_RETVAL
  164. #define EX_RETVAL(x) x
  165. __restore_fp:
  166. VISExitHalf
  167. __restore_asi:
  168. retl
  169. wr %g0, ASI_AIUS, %asi
  170. ENTRY(NG2_retl_o2)
  171. ba,pt %xcc, __restore_asi
  172. mov %o2, %o0
  173. ENDPROC(NG2_retl_o2)
  174. ENTRY(NG2_retl_o2_plus_1)
  175. ba,pt %xcc, __restore_asi
  176. add %o2, 1, %o0
  177. ENDPROC(NG2_retl_o2_plus_1)
  178. ENTRY(NG2_retl_o2_plus_4)
  179. ba,pt %xcc, __restore_asi
  180. add %o2, 4, %o0
  181. ENDPROC(NG2_retl_o2_plus_4)
  182. ENTRY(NG2_retl_o2_plus_8)
  183. ba,pt %xcc, __restore_asi
  184. add %o2, 8, %o0
  185. ENDPROC(NG2_retl_o2_plus_8)
  186. ENTRY(NG2_retl_o2_plus_o4_plus_1)
  187. add %o4, 1, %o4
  188. ba,pt %xcc, __restore_asi
  189. add %o2, %o4, %o0
  190. ENDPROC(NG2_retl_o2_plus_o4_plus_1)
  191. ENTRY(NG2_retl_o2_plus_o4_plus_8)
  192. add %o4, 8, %o4
  193. ba,pt %xcc, __restore_asi
  194. add %o2, %o4, %o0
  195. ENDPROC(NG2_retl_o2_plus_o4_plus_8)
  196. ENTRY(NG2_retl_o2_plus_o4_plus_16)
  197. add %o4, 16, %o4
  198. ba,pt %xcc, __restore_asi
  199. add %o2, %o4, %o0
  200. ENDPROC(NG2_retl_o2_plus_o4_plus_16)
  201. ENTRY(NG2_retl_o2_plus_g1_fp)
  202. ba,pt %xcc, __restore_fp
  203. add %o2, %g1, %o0
  204. ENDPROC(NG2_retl_o2_plus_g1_fp)
  205. ENTRY(NG2_retl_o2_plus_g1_plus_64_fp)
  206. add %g1, 64, %g1
  207. ba,pt %xcc, __restore_fp
  208. add %o2, %g1, %o0
  209. ENDPROC(NG2_retl_o2_plus_g1_plus_64_fp)
  210. ENTRY(NG2_retl_o2_plus_g1_plus_1)
  211. add %g1, 1, %g1
  212. ba,pt %xcc, __restore_asi
  213. add %o2, %g1, %o0
  214. ENDPROC(NG2_retl_o2_plus_g1_plus_1)
  215. ENTRY(NG2_retl_o2_and_7_plus_o4)
  216. and %o2, 7, %o2
  217. ba,pt %xcc, __restore_asi
  218. add %o2, %o4, %o0
  219. ENDPROC(NG2_retl_o2_and_7_plus_o4)
  220. ENTRY(NG2_retl_o2_and_7_plus_o4_plus_8)
  221. and %o2, 7, %o2
  222. add %o4, 8, %o4
  223. ba,pt %xcc, __restore_asi
  224. add %o2, %o4, %o0
  225. ENDPROC(NG2_retl_o2_and_7_plus_o4_plus_8)
  226. #endif
  227. .align 64
  228. .globl FUNC_NAME
  229. .type FUNC_NAME,#function
  230. FUNC_NAME: /* %o0=dst, %o1=src, %o2=len */
  231. srlx %o2, 31, %g2
  232. cmp %g2, 0
  233. tne %xcc, 5
  234. PREAMBLE
  235. mov %o0, %o3
  236. cmp %o2, 0
  237. be,pn %XCC, 85f
  238. or %o0, %o1, GLOBAL_SPARE
  239. cmp %o2, 16
  240. blu,a,pn %XCC, 80f
  241. or GLOBAL_SPARE, %o2, GLOBAL_SPARE
  242. /* 2 blocks (128 bytes) is the minimum we can do the block
  243. * copy with. We need to ensure that we'll iterate at least
  244. * once in the block copy loop. At worst we'll need to align
  245. * the destination to a 64-byte boundary which can chew up
  246. * to (64 - 1) bytes from the length before we perform the
  247. * block copy loop.
  248. *
  249. * However, the cut-off point, performance wise, is around
  250. * 4 64-byte blocks.
  251. */
  252. cmp %o2, (4 * 64)
  253. blu,pt %XCC, 75f
  254. andcc GLOBAL_SPARE, 0x7, %g0
  255. /* %o0: dst
  256. * %o1: src
  257. * %o2: len (known to be >= 128)
  258. *
  259. * The block copy loops can use %o4, %g2, %g3 as
  260. * temporaries while copying the data. %o5 must
  261. * be preserved between VISEntryHalf and VISExitHalf
  262. */
  263. LOAD(prefetch, %o1 + 0x000, #one_read)
  264. LOAD(prefetch, %o1 + 0x040, #one_read)
  265. LOAD(prefetch, %o1 + 0x080, #one_read)
  266. /* Align destination on 64-byte boundary. */
  267. andcc %o0, (64 - 1), %o4
  268. be,pt %XCC, 2f
  269. sub %o4, 64, %o4
  270. sub %g0, %o4, %o4 ! bytes to align dst
  271. sub %o2, %o4, %o2
  272. 1: subcc %o4, 1, %o4
  273. EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_o4_plus_1)
  274. EX_ST(STORE(stb, %g1, %o0), NG2_retl_o2_plus_o4_plus_1)
  275. add %o1, 1, %o1
  276. bne,pt %XCC, 1b
  277. add %o0, 1, %o0
  278. 2:
  279. /* Clobbers o5/g1/g2/g3/g7/icc/xcc. We must preserve
  280. * o5 from here until we hit VISExitHalf.
  281. */
  282. VISEntryHalf
  283. membar #Sync
  284. alignaddr %o1, %g0, %g0
  285. add %o1, (64 - 1), %o4
  286. andn %o4, (64 - 1), %o4
  287. andn %o2, (64 - 1), %g1
  288. sub %o2, %g1, %o2
  289. and %o1, (64 - 1), %g2
  290. add %o1, %g1, %o1
  291. sub %o0, %o4, %g3
  292. brz,pt %g2, 190f
  293. cmp %g2, 32
  294. blu,a 5f
  295. cmp %g2, 16
  296. cmp %g2, 48
  297. blu,a 4f
  298. cmp %g2, 40
  299. cmp %g2, 56
  300. blu 170f
  301. nop
  302. ba,a,pt %xcc, 180f
  303. 4: /* 32 <= low bits < 48 */
  304. blu 150f
  305. nop
  306. ba,a,pt %xcc, 160f
  307. 5: /* 0 < low bits < 32 */
  308. blu,a 6f
  309. cmp %g2, 8
  310. cmp %g2, 24
  311. blu 130f
  312. nop
  313. ba,a,pt %xcc, 140f
  314. 6: /* 0 < low bits < 16 */
  315. bgeu 120f
  316. nop
  317. /* fall through for 0 < low bits < 8 */
  318. 110: sub %o4, 64, %g2
  319. EX_LD_FP(LOAD_BLK(%g2, %f0), NG2_retl_o2_plus_g1)
  320. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  321. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  322. FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f14, f16)
  323. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  324. FREG_MOVE_8(f16, f18, f20, f22, f24, f26, f28, f30)
  325. subcc %g1, 64, %g1
  326. add %o4, 64, %o4
  327. bne,pt %xcc, 1b
  328. LOAD(prefetch, %o4 + 64, #one_read)
  329. ba,pt %xcc, 195f
  330. nop
  331. 120: sub %o4, 56, %g2
  332. FREG_LOAD_7(%g2, f0, f2, f4, f6, f8, f10, f12)
  333. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  334. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  335. FREG_FROB(f0, f2, f4, f6, f8, f10, f12, f16, f18)
  336. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  337. FREG_MOVE_7(f18, f20, f22, f24, f26, f28, f30)
  338. subcc %g1, 64, %g1
  339. add %o4, 64, %o4
  340. bne,pt %xcc, 1b
  341. LOAD(prefetch, %o4 + 64, #one_read)
  342. ba,pt %xcc, 195f
  343. nop
  344. 130: sub %o4, 48, %g2
  345. FREG_LOAD_6(%g2, f0, f2, f4, f6, f8, f10)
  346. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  347. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  348. FREG_FROB(f0, f2, f4, f6, f8, f10, f16, f18, f20)
  349. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  350. FREG_MOVE_6(f20, f22, f24, f26, f28, f30)
  351. subcc %g1, 64, %g1
  352. add %o4, 64, %o4
  353. bne,pt %xcc, 1b
  354. LOAD(prefetch, %o4 + 64, #one_read)
  355. ba,pt %xcc, 195f
  356. nop
  357. 140: sub %o4, 40, %g2
  358. FREG_LOAD_5(%g2, f0, f2, f4, f6, f8)
  359. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  360. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  361. FREG_FROB(f0, f2, f4, f6, f8, f16, f18, f20, f22)
  362. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  363. FREG_MOVE_5(f22, f24, f26, f28, f30)
  364. subcc %g1, 64, %g1
  365. add %o4, 64, %o4
  366. bne,pt %xcc, 1b
  367. LOAD(prefetch, %o4 + 64, #one_read)
  368. ba,pt %xcc, 195f
  369. nop
  370. 150: sub %o4, 32, %g2
  371. FREG_LOAD_4(%g2, f0, f2, f4, f6)
  372. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  373. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  374. FREG_FROB(f0, f2, f4, f6, f16, f18, f20, f22, f24)
  375. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  376. FREG_MOVE_4(f24, f26, f28, f30)
  377. subcc %g1, 64, %g1
  378. add %o4, 64, %o4
  379. bne,pt %xcc, 1b
  380. LOAD(prefetch, %o4 + 64, #one_read)
  381. ba,pt %xcc, 195f
  382. nop
  383. 160: sub %o4, 24, %g2
  384. FREG_LOAD_3(%g2, f0, f2, f4)
  385. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  386. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  387. FREG_FROB(f0, f2, f4, f16, f18, f20, f22, f24, f26)
  388. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  389. FREG_MOVE_3(f26, f28, f30)
  390. subcc %g1, 64, %g1
  391. add %o4, 64, %o4
  392. bne,pt %xcc, 1b
  393. LOAD(prefetch, %o4 + 64, #one_read)
  394. ba,pt %xcc, 195f
  395. nop
  396. 170: sub %o4, 16, %g2
  397. FREG_LOAD_2(%g2, f0, f2)
  398. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  399. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  400. FREG_FROB(f0, f2, f16, f18, f20, f22, f24, f26, f28)
  401. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  402. FREG_MOVE_2(f28, f30)
  403. subcc %g1, 64, %g1
  404. add %o4, 64, %o4
  405. bne,pt %xcc, 1b
  406. LOAD(prefetch, %o4 + 64, #one_read)
  407. ba,pt %xcc, 195f
  408. nop
  409. 180: sub %o4, 8, %g2
  410. FREG_LOAD_1(%g2, f0)
  411. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  412. EX_LD_FP(LOAD_BLK(%o4, %f16), NG2_retl_o2_plus_g1)
  413. FREG_FROB(f0, f16, f18, f20, f22, f24, f26, f28, f30)
  414. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1)
  415. FREG_MOVE_1(f30)
  416. subcc %g1, 64, %g1
  417. add %o4, 64, %o4
  418. bne,pt %xcc, 1b
  419. LOAD(prefetch, %o4 + 64, #one_read)
  420. ba,pt %xcc, 195f
  421. nop
  422. 190:
  423. 1: EX_ST_FP(STORE_INIT(%g0, %o4 + %g3), NG2_retl_o2_plus_g1)
  424. subcc %g1, 64, %g1
  425. EX_LD_FP(LOAD_BLK(%o4, %f0), NG2_retl_o2_plus_g1_plus_64)
  426. EX_ST_FP(STORE_BLK(%f0, %o4 + %g3), NG2_retl_o2_plus_g1_plus_64)
  427. add %o4, 64, %o4
  428. bne,pt %xcc, 1b
  429. LOAD(prefetch, %o4 + 64, #one_read)
  430. 195:
  431. add %o4, %g3, %o0
  432. membar #Sync
  433. VISExitHalf
  434. /* %o2 contains any final bytes still needed to be copied
  435. * over. If anything is left, we copy it one byte at a time.
  436. */
  437. brz,pt %o2, 85f
  438. sub %o0, %o1, GLOBAL_SPARE
  439. ba,a,pt %XCC, 90f
  440. .align 64
  441. 75: /* 16 < len <= 64 */
  442. bne,pn %XCC, 75f
  443. sub %o0, %o1, GLOBAL_SPARE
  444. 72:
  445. andn %o2, 0xf, %o4
  446. and %o2, 0xf, %o2
  447. 1: subcc %o4, 0x10, %o4
  448. EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_o4_plus_16)
  449. add %o1, 0x08, %o1
  450. EX_LD(LOAD(ldx, %o1, %g1), NG2_retl_o2_plus_o4_plus_16)
  451. sub %o1, 0x08, %o1
  452. EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_16)
  453. add %o1, 0x8, %o1
  454. EX_ST(STORE(stx, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_o4_plus_8)
  455. bgu,pt %XCC, 1b
  456. add %o1, 0x8, %o1
  457. 73: andcc %o2, 0x8, %g0
  458. be,pt %XCC, 1f
  459. nop
  460. sub %o2, 0x8, %o2
  461. EX_LD(LOAD(ldx, %o1, %o5), NG2_retl_o2_plus_8)
  462. EX_ST(STORE(stx, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_8)
  463. add %o1, 0x8, %o1
  464. 1: andcc %o2, 0x4, %g0
  465. be,pt %XCC, 1f
  466. nop
  467. sub %o2, 0x4, %o2
  468. EX_LD(LOAD(lduw, %o1, %o5), NG2_retl_o2_plus_4)
  469. EX_ST(STORE(stw, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
  470. add %o1, 0x4, %o1
  471. 1: cmp %o2, 0
  472. be,pt %XCC, 85f
  473. nop
  474. ba,pt %xcc, 90f
  475. nop
  476. 75:
  477. andcc %o0, 0x7, %g1
  478. sub %g1, 0x8, %g1
  479. be,pn %icc, 2f
  480. sub %g0, %g1, %g1
  481. sub %o2, %g1, %o2
  482. 1: subcc %g1, 1, %g1
  483. EX_LD(LOAD(ldub, %o1, %o5), NG2_retl_o2_plus_g1_plus_1)
  484. EX_ST(STORE(stb, %o5, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_g1_plus_1)
  485. bgu,pt %icc, 1b
  486. add %o1, 1, %o1
  487. 2: add %o1, GLOBAL_SPARE, %o0
  488. andcc %o1, 0x7, %g1
  489. bne,pt %icc, 8f
  490. sll %g1, 3, %g1
  491. cmp %o2, 16
  492. bgeu,pt %icc, 72b
  493. nop
  494. ba,a,pt %xcc, 73b
  495. 8: mov 64, GLOBAL_SPARE
  496. andn %o1, 0x7, %o1
  497. EX_LD(LOAD(ldx, %o1, %g2), NG2_retl_o2)
  498. sub GLOBAL_SPARE, %g1, GLOBAL_SPARE
  499. andn %o2, 0x7, %o4
  500. sllx %g2, %g1, %g2
  501. 1: add %o1, 0x8, %o1
  502. EX_LD(LOAD(ldx, %o1, %g3), NG2_retl_o2_and_7_plus_o4)
  503. subcc %o4, 0x8, %o4
  504. srlx %g3, GLOBAL_SPARE, %o5
  505. or %o5, %g2, %o5
  506. EX_ST(STORE(stx, %o5, %o0), NG2_retl_o2_and_7_plus_o4_plus_8)
  507. add %o0, 0x8, %o0
  508. bgu,pt %icc, 1b
  509. sllx %g3, %g1, %g2
  510. srl %g1, 3, %g1
  511. andcc %o2, 0x7, %o2
  512. be,pn %icc, 85f
  513. add %o1, %g1, %o1
  514. ba,pt %xcc, 90f
  515. sub %o0, %o1, GLOBAL_SPARE
  516. .align 64
  517. 80: /* 0 < len <= 16 */
  518. andcc GLOBAL_SPARE, 0x3, %g0
  519. bne,pn %XCC, 90f
  520. sub %o0, %o1, GLOBAL_SPARE
  521. 1:
  522. subcc %o2, 4, %o2
  523. EX_LD(LOAD(lduw, %o1, %g1), NG2_retl_o2_plus_4)
  524. EX_ST(STORE(stw, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_4)
  525. bgu,pt %XCC, 1b
  526. add %o1, 4, %o1
  527. 85: retl
  528. mov EX_RETVAL(%o3), %o0
  529. .align 32
  530. 90:
  531. subcc %o2, 1, %o2
  532. EX_LD(LOAD(ldub, %o1, %g1), NG2_retl_o2_plus_1)
  533. EX_ST(STORE(stb, %g1, %o1 + GLOBAL_SPARE), NG2_retl_o2_plus_1)
  534. bgu,pt %XCC, 90b
  535. add %o1, 1, %o1
  536. retl
  537. mov EX_RETVAL(%o3), %o0
  538. .size FUNC_NAME, .-FUNC_NAME