memcpy.S 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. /* Copy SIZE bytes from SRC to DEST.
  2. For SPARC v7.
  3. Copyright (C) 1996, 1999, 2003 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. Contributed by David S. Miller <davem@caip.rutgers.edu>,
  6. Eddie C. Dost <ecd@skynet.be> and
  7. Jakub Jelinek <jj@ultra.linux.cz>.
  8. The GNU C Library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Lesser General Public
  10. License as published by the Free Software Foundation; either
  11. version 2.1 of the License, or (at your option) any later version.
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. Lesser General Public License for more details.
  16. You should have received a copy of the GNU Lesser General Public
  17. License along with the GNU C Library; if not, write to the Free
  18. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19. 02111-1307 USA. */
  20. /* Both these macros have to start with exactly the same insn */
  21. #define MOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  22. ldd [%src + offset + 0x00], %t0; \
  23. ldd [%src + offset + 0x08], %t2; \
  24. ldd [%src + offset + 0x10], %t4; \
  25. ldd [%src + offset + 0x18], %t6; \
  26. st %t0, [%dst + offset + 0x00]; \
  27. st %t1, [%dst + offset + 0x04]; \
  28. st %t2, [%dst + offset + 0x08]; \
  29. st %t3, [%dst + offset + 0x0c]; \
  30. st %t4, [%dst + offset + 0x10]; \
  31. st %t5, [%dst + offset + 0x14]; \
  32. st %t6, [%dst + offset + 0x18]; \
  33. st %t7, [%dst + offset + 0x1c];
  34. #define MOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  35. ldd [%src + offset + 0x00], %t0; \
  36. ldd [%src + offset + 0x08], %t2; \
  37. ldd [%src + offset + 0x10], %t4; \
  38. ldd [%src + offset + 0x18], %t6; \
  39. std %t0, [%dst + offset + 0x00]; \
  40. std %t2, [%dst + offset + 0x08]; \
  41. std %t4, [%dst + offset + 0x10]; \
  42. std %t6, [%dst + offset + 0x18];
  43. #define MOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
  44. ldd [%src - offset - 0x10], %t0; \
  45. ldd [%src - offset - 0x08], %t2; \
  46. st %t0, [%dst - offset - 0x10]; \
  47. st %t1, [%dst - offset - 0x0c]; \
  48. st %t2, [%dst - offset - 0x08]; \
  49. st %t3, [%dst - offset - 0x04];
  50. #define MOVE_LASTALIGNCHUNK(src, dst, offset, t0, t1, t2, t3) \
  51. ldd [%src - offset - 0x10], %t0; \
  52. ldd [%src - offset - 0x08], %t2; \
  53. std %t0, [%dst - offset - 0x10]; \
  54. std %t2, [%dst - offset - 0x08];
  55. #define MOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
  56. ldub [%src - offset - 0x02], %t0; \
  57. ldub [%src - offset - 0x01], %t1; \
  58. stb %t0, [%dst - offset - 0x02]; \
  59. stb %t1, [%dst - offset - 0x01];
  60. /* Both these macros have to start with exactly the same insn */
  61. #define RMOVE_BIGCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  62. ldd [%src - offset - 0x20], %t0; \
  63. ldd [%src - offset - 0x18], %t2; \
  64. ldd [%src - offset - 0x10], %t4; \
  65. ldd [%src - offset - 0x08], %t6; \
  66. st %t0, [%dst - offset - 0x20]; \
  67. st %t1, [%dst - offset - 0x1c]; \
  68. st %t2, [%dst - offset - 0x18]; \
  69. st %t3, [%dst - offset - 0x14]; \
  70. st %t4, [%dst - offset - 0x10]; \
  71. st %t5, [%dst - offset - 0x0c]; \
  72. st %t6, [%dst - offset - 0x08]; \
  73. st %t7, [%dst - offset - 0x04];
  74. #define RMOVE_BIGALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  75. ldd [%src - offset - 0x20], %t0; \
  76. ldd [%src - offset - 0x18], %t2; \
  77. ldd [%src - offset - 0x10], %t4; \
  78. ldd [%src - offset - 0x08], %t6; \
  79. std %t0, [%dst - offset - 0x20]; \
  80. std %t2, [%dst - offset - 0x18]; \
  81. std %t4, [%dst - offset - 0x10]; \
  82. std %t6, [%dst - offset - 0x08];
  83. #define RMOVE_LASTCHUNK(src, dst, offset, t0, t1, t2, t3) \
  84. ldd [%src + offset + 0x00], %t0; \
  85. ldd [%src + offset + 0x08], %t2; \
  86. st %t0, [%dst + offset + 0x00]; \
  87. st %t1, [%dst + offset + 0x04]; \
  88. st %t2, [%dst + offset + 0x08]; \
  89. st %t3, [%dst + offset + 0x0c];
  90. #define RMOVE_SHORTCHUNK(src, dst, offset, t0, t1) \
  91. ldub [%src + offset + 0x00], %t0; \
  92. ldub [%src + offset + 0x01], %t1; \
  93. stb %t0, [%dst + offset + 0x00]; \
  94. stb %t1, [%dst + offset + 0x01];
  95. #define SMOVE_CHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
  96. ldd [%src + offset + 0x00], %t0; \
  97. ldd [%src + offset + 0x08], %t2; \
  98. srl %t0, shir, %t5; \
  99. srl %t1, shir, %t6; \
  100. sll %t0, shil, %t0; \
  101. or %t5, %prev, %t5; \
  102. sll %t1, shil, %prev; \
  103. or %t6, %t0, %t0; \
  104. srl %t2, shir, %t1; \
  105. srl %t3, shir, %t6; \
  106. sll %t2, shil, %t2; \
  107. or %t1, %prev, %t1; \
  108. std %t4, [%dst + offset + offset2 - 0x04]; \
  109. std %t0, [%dst + offset + offset2 + 0x04]; \
  110. sll %t3, shil, %prev; \
  111. or %t6, %t2, %t4;
  112. #define SMOVE_ALIGNCHUNK(src, dst, offset, t0, t1, t2, t3, t4, t5, t6, prev, shil, shir, offset2) \
  113. ldd [%src + offset + 0x00], %t0; \
  114. ldd [%src + offset + 0x08], %t2; \
  115. srl %t0, shir, %t4; \
  116. srl %t1, shir, %t5; \
  117. sll %t0, shil, %t6; \
  118. or %t4, %prev, %t0; \
  119. sll %t1, shil, %prev; \
  120. or %t5, %t6, %t1; \
  121. srl %t2, shir, %t4; \
  122. srl %t3, shir, %t5; \
  123. sll %t2, shil, %t6; \
  124. or %t4, %prev, %t2; \
  125. sll %t3, shil, %prev; \
  126. or %t5, %t6, %t3; \
  127. std %t0, [%dst + offset + offset2 + 0x00]; \
  128. std %t2, [%dst + offset + offset2 + 0x08];
  129. .text
  130. .align 4
  131. 70: andcc %o1, 1, %g0
  132. be 4f
  133. andcc %o1, 2, %g0
  134. ldub [%o1 - 1], %g2
  135. sub %o1, 1, %o1
  136. stb %g2, [%o0 - 1]
  137. sub %o2, 1, %o2
  138. be 3f
  139. sub %o0, 1, %o0
  140. 4: lduh [%o1 - 2], %g2
  141. sub %o1, 2, %o1
  142. sth %g2, [%o0 - 2]
  143. sub %o2, 2, %o2
  144. b 3f
  145. sub %o0, 2, %o0
  146. ENTRY(bcopy)
  147. mov %o0, %o3
  148. mov %o1, %o0
  149. mov %o3, %o1
  150. END(bcopy)
  151. ENTRY(memmove)
  152. cmp %o0, %o1
  153. st %o0, [%sp + 64]
  154. bleu 9f
  155. sub %o0, %o1, %o4
  156. add %o1, %o2, %o3
  157. cmp %o3, %o0
  158. bleu 0f
  159. andcc %o4, 3, %o5
  160. add %o1, %o2, %o1
  161. add %o0, %o2, %o0
  162. bne 77f
  163. cmp %o2, 15
  164. bleu 91f
  165. andcc %o1, 3, %g0
  166. bne 70b
  167. 3: andcc %o1, 4, %g0
  168. be 2f
  169. mov %o2, %g1
  170. ld [%o1 - 4], %o4
  171. sub %g1, 4, %g1
  172. st %o4, [%o0 - 4]
  173. sub %o1, 4, %o1
  174. sub %o0, 4, %o0
  175. 2: andcc %g1, 0xffffff80, %g6
  176. be 3f
  177. andcc %o0, 4, %g0
  178. be 74f + 4
  179. 5: RMOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  180. RMOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  181. RMOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  182. RMOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  183. subcc %g6, 128, %g6
  184. sub %o1, 128, %o1
  185. bne 5b
  186. sub %o0, 128, %o0
  187. 3: andcc %g1, 0x70, %g6
  188. be 72f
  189. andcc %g1, 8, %g0
  190. srl %g6, 1, %o4
  191. mov %o7, %g2
  192. add %g6, %o4, %o4
  193. 101: call 100f
  194. sub %o1, %g6, %o1
  195. mov %g2, %o7
  196. jmpl %o5 + (72f - 101b), %g0
  197. sub %o0, %g6, %o0
  198. 71: RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  199. RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  200. RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  201. RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  202. RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  203. RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  204. RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  205. 72: be 73f
  206. andcc %g1, 4, %g0
  207. ldd [%o1 - 0x08], %g2
  208. sub %o0, 8, %o0
  209. sub %o1, 8, %o1
  210. st %g2, [%o0]
  211. st %g3, [%o0 + 0x04]
  212. 73: be 1f
  213. andcc %g1, 2, %g0
  214. ld [%o1 - 4], %g2
  215. sub %o1, 4, %o1
  216. st %g2, [%o0 - 4]
  217. sub %o0, 4, %o0
  218. 1: be 1f
  219. andcc %g1, 1, %g0
  220. lduh [%o1 - 2], %g2
  221. sub %o1, 2, %o1
  222. sth %g2, [%o0 - 2]
  223. sub %o0, 2, %o0
  224. 1: be 1f
  225. nop
  226. ldub [%o1 - 1], %g2
  227. stb %g2, [%o0 - 1]
  228. 1: retl
  229. ld [%sp + 64], %o0
  230. 74: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  231. RMOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  232. RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  233. RMOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  234. subcc %g6, 128, %g6
  235. sub %o1, 128, %o1
  236. bne 74b
  237. sub %o0, 128, %o0
  238. andcc %g1, 0x70, %g6
  239. be 72b
  240. andcc %g1, 8, %g0
  241. srl %g6, 1, %o4
  242. mov %o7, %g2
  243. add %g6, %o4, %o4
  244. 102: call 100f
  245. sub %o1, %g6, %o1
  246. mov %g2, %o7
  247. jmpl %o5 + (72b - 102b), %g0
  248. sub %o0, %g6, %o0
  249. 75: and %o2, 0xe, %o3
  250. mov %o7, %g2
  251. sll %o3, 3, %o4
  252. sub %o0, %o3, %o0
  253. 103: call 100f
  254. sub %o1, %o3, %o1
  255. mov %g2, %o7
  256. jmpl %o5 + (76f - 103b), %g0
  257. andcc %o2, 1, %g0
  258. RMOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
  259. RMOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
  260. RMOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
  261. RMOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
  262. RMOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
  263. RMOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
  264. RMOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
  265. 76: be 1f
  266. nop
  267. ldub [%o1 - 1], %g2
  268. stb %g2, [%o0 - 1]
  269. 1: retl
  270. ld [%sp + 64], %o0
  271. 91: bne 75b
  272. andcc %o2, 8, %g0
  273. be 1f
  274. andcc %o2, 4, %g0
  275. ld [%o1 - 0x08], %g2
  276. ld [%o1 - 0x04], %g3
  277. sub %o1, 8, %o1
  278. st %g2, [%o0 - 0x08]
  279. st %g3, [%o0 - 0x04]
  280. sub %o0, 8, %o0
  281. 1: b 73b
  282. mov %o2, %g1
  283. 77: cmp %o2, 15
  284. bleu 75b
  285. andcc %o0, 3, %g0
  286. be 64f
  287. andcc %o0, 1, %g0
  288. be 63f
  289. andcc %o0, 2, %g0
  290. ldub [%o1 - 1], %g5
  291. sub %o1, 1, %o1
  292. stb %g5, [%o0 - 1]
  293. sub %o0, 1, %o0
  294. be 64f
  295. sub %o2, 1, %o2
  296. 63: ldub [%o1 - 1], %g5
  297. sub %o1, 2, %o1
  298. stb %g5, [%o0 - 1]
  299. sub %o0, 2, %o0
  300. ldub [%o1], %g5
  301. sub %o2, 2, %o2
  302. stb %g5, [%o0]
  303. 64: and %o1, 3, %g2
  304. and %o1, -4, %o1
  305. and %o2, 0xc, %g3
  306. add %o1, 4, %o1
  307. cmp %g3, 4
  308. sll %g2, 3, %g4
  309. mov 32, %g2
  310. be 4f
  311. sub %g2, %g4, %g6
  312. blu 3f
  313. cmp %g3, 8
  314. be 2f
  315. srl %o2, 2, %g3
  316. ld [%o1 - 4], %o3
  317. add %o0, -8, %o0
  318. ld [%o1 - 8], %o4
  319. add %o1, -16, %o1
  320. b 7f
  321. add %g3, 1, %g3
  322. 2: ld [%o1 - 4], %o4
  323. add %o0, -4, %o0
  324. ld [%o1 - 8], %g1
  325. add %o1, -12, %o1
  326. b 8f
  327. add %g3, 2, %g3
  328. 3: ld [%o1 - 4], %o5
  329. add %o0, -12, %o0
  330. ld [%o1 - 8], %o3
  331. add %o1, -20, %o1
  332. b 6f
  333. srl %o2, 2, %g3
  334. 4: ld [%o1 - 4], %g1
  335. srl %o2, 2, %g3
  336. ld [%o1 - 8], %o5
  337. add %o1, -24, %o1
  338. add %o0, -16, %o0
  339. add %g3, -1, %g3
  340. ld [%o1 + 12], %o3
  341. 5: sll %o5, %g4, %g2
  342. srl %g1, %g6, %g5
  343. or %g2, %g5, %g2
  344. st %g2, [%o0 + 12]
  345. 6: ld [%o1 + 8], %o4
  346. sll %o3, %g4, %g2
  347. srl %o5, %g6, %g5
  348. or %g2, %g5, %g2
  349. st %g2, [%o0 + 8]
  350. 7: ld [%o1 + 4], %g1
  351. sll %o4, %g4, %g2
  352. srl %o3, %g6, %g5
  353. or %g2, %g5, %g2
  354. st %g2, [%o0 + 4]
  355. 8: ld [%o1], %o5
  356. sll %g1, %g4, %g2
  357. srl %o4, %g6, %g5
  358. addcc %g3, -4, %g3
  359. or %g2, %g5, %g2
  360. add %o1, -16, %o1
  361. st %g2, [%o0]
  362. add %o0, -16, %o0
  363. bne,a 5b
  364. ld [%o1 + 12], %o3
  365. sll %o5, %g4, %g2
  366. srl %g1, %g6, %g5
  367. srl %g4, 3, %g3
  368. or %g2, %g5, %g2
  369. add %o1, %g3, %o1
  370. andcc %o2, 2, %g0
  371. st %g2, [%o0 + 12]
  372. be 1f
  373. andcc %o2, 1, %g0
  374. ldub [%o1 + 15], %g5
  375. add %o1, -2, %o1
  376. stb %g5, [%o0 + 11]
  377. add %o0, -2, %o0
  378. ldub [%o1 + 16], %g5
  379. stb %g5, [%o0 + 12]
  380. 1: be 1f
  381. nop
  382. ldub [%o1 + 15], %g5
  383. stb %g5, [%o0 + 11]
  384. 1: retl
  385. ld [%sp + 64], %o0
  386. 78: andcc %o1, 1, %g0
  387. be 4f
  388. andcc %o1, 2, %g0
  389. ldub [%o1], %g2
  390. add %o1, 1, %o1
  391. stb %g2, [%o0]
  392. sub %o2, 1, %o2
  393. bne 3f
  394. add %o0, 1, %o0
  395. 4: lduh [%o1], %g2
  396. add %o1, 2, %o1
  397. sth %g2, [%o0]
  398. sub %o2, 2, %o2
  399. b 3f
  400. add %o0, 2, %o0
  401. END(memmove)
  402. libc_hidden_def(memmove)
  403. ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
  404. sub %o0, %o1, %o4
  405. st %o0, [%sp + 64]
  406. 9: andcc %o4, 3, %o5
  407. 0: bne 86f
  408. cmp %o2, 15
  409. bleu 90f
  410. andcc %o1, 3, %g0
  411. bne 78b
  412. 3: andcc %o1, 4, %g0
  413. be 2f
  414. mov %o2, %g1
  415. ld [%o1], %o4
  416. sub %g1, 4, %g1
  417. st %o4, [%o0]
  418. add %o1, 4, %o1
  419. add %o0, 4, %o0
  420. 2: andcc %g1, 0xffffff80, %g6
  421. be 3f
  422. andcc %o0, 4, %g0
  423. be 82f + 4
  424. 5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  425. MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  426. MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  427. MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  428. subcc %g6, 128, %g6
  429. add %o1, 128, %o1
  430. bne 5b
  431. add %o0, 128, %o0
  432. 3: andcc %g1, 0x70, %g6
  433. be 80f
  434. andcc %g1, 8, %g0
  435. srl %g6, 1, %o4
  436. mov %o7, %g2
  437. add %g6, %o4, %o4
  438. add %o1, %g6, %o1
  439. 104: call 100f
  440. add %o0, %g6, %o0
  441. jmpl %o5 + (80f - 104b), %g0
  442. mov %g2, %o7
  443. 79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  444. MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  445. MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  446. MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  447. MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  448. MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  449. MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  450. 80: be 81f
  451. andcc %g1, 4, %g0
  452. ldd [%o1], %g2
  453. add %o0, 8, %o0
  454. st %g2, [%o0 - 0x08]
  455. add %o1, 8, %o1
  456. st %g3, [%o0 - 0x04]
  457. 81: be 1f
  458. andcc %g1, 2, %g0
  459. ld [%o1], %g2
  460. add %o1, 4, %o1
  461. st %g2, [%o0]
  462. add %o0, 4, %o0
  463. 1: be 1f
  464. andcc %g1, 1, %g0
  465. lduh [%o1], %g2
  466. add %o1, 2, %o1
  467. sth %g2, [%o0]
  468. add %o0, 2, %o0
  469. 1: be 1f
  470. nop
  471. ldub [%o1], %g2
  472. stb %g2, [%o0]
  473. 1: retl
  474. ld [%sp + 64], %o0
  475. 82: /* ldd_std */
  476. MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  477. MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  478. MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  479. MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  480. subcc %g6, 128, %g6
  481. add %o1, 128, %o1
  482. bne 82b
  483. add %o0, 128, %o0
  484. andcc %g1, 0x70, %g6
  485. be 84f
  486. andcc %g1, 8, %g0
  487. mov %o7, %g2
  488. 111: call 110f
  489. add %o1, %g6, %o1
  490. mov %g2, %o7
  491. jmpl %o5 + (84f - 111b), %g0
  492. add %o0, %g6, %o0
  493. 83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  494. MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  495. MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  496. MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  497. MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  498. MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  499. MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  500. 84: be 85f
  501. andcc %g1, 4, %g0
  502. ldd [%o1], %g2
  503. add %o0, 8, %o0
  504. std %g2, [%o0 - 0x08]
  505. add %o1, 8, %o1
  506. 85: be 1f
  507. andcc %g1, 2, %g0
  508. ld [%o1], %g2
  509. add %o1, 4, %o1
  510. st %g2, [%o0]
  511. add %o0, 4, %o0
  512. 1: be 1f
  513. andcc %g1, 1, %g0
  514. lduh [%o1], %g2
  515. add %o1, 2, %o1
  516. sth %g2, [%o0]
  517. add %o0, 2, %o0
  518. 1: be 1f
  519. nop
  520. ldub [%o1], %g2
  521. stb %g2, [%o0]
  522. 1: retl
  523. ld [%sp + 64], %o0
  524. 86: cmp %o2, 6
  525. bleu 88f
  526. cmp %o2, 256
  527. bcc 87f
  528. andcc %o0, 3, %g0
  529. be 61f
  530. andcc %o0, 1, %g0
  531. be 60f
  532. andcc %o0, 2, %g0
  533. ldub [%o1], %g5
  534. add %o1, 1, %o1
  535. stb %g5, [%o0]
  536. sub %o2, 1, %o2
  537. bne 61f
  538. add %o0, 1, %o0
  539. 60: ldub [%o1], %g3
  540. add %o1, 2, %o1
  541. stb %g3, [%o0]
  542. sub %o2, 2, %o2
  543. ldub [%o1 - 1], %g3
  544. add %o0, 2, %o0
  545. stb %g3, [%o0 - 1]
  546. 61: and %o1, 3, %g2
  547. and %o2, 0xc, %g3
  548. and %o1, -4, %o1
  549. cmp %g3, 4
  550. sll %g2, 3, %g4
  551. mov 32, %g2
  552. be 4f
  553. sub %g2, %g4, %g6
  554. blu 3f
  555. cmp %g3, 0x8
  556. be 2f
  557. srl %o2, 2, %g3
  558. ld [%o1], %o3
  559. add %o0, -8, %o0
  560. ld [%o1 + 4], %o4
  561. b 8f
  562. add %g3, 1, %g3
  563. 2: ld [%o1], %o4
  564. add %o0, -12, %o0
  565. ld [%o1 + 4], %o5
  566. add %g3, 2, %g3
  567. b 9f
  568. add %o1, -4, %o1
  569. 3: ld [%o1], %g1
  570. add %o0, -4, %o0
  571. ld [%o1 + 4], %o3
  572. srl %o2, 2, %g3
  573. b 7f
  574. add %o1, 4, %o1
  575. 4: ld [%o1], %o5
  576. cmp %o2, 7
  577. ld [%o1 + 4], %g1
  578. srl %o2, 2, %g3
  579. bleu 10f
  580. add %o1, 8, %o1
  581. ld [%o1], %o3
  582. add %g3, -1, %g3
  583. 5: sll %o5, %g4, %g2
  584. srl %g1, %g6, %g5
  585. or %g2, %g5, %g2
  586. st %g2, [%o0]
  587. 7: ld [%o1 + 4], %o4
  588. sll %g1, %g4, %g2
  589. srl %o3, %g6, %g5
  590. or %g2, %g5, %g2
  591. st %g2, [%o0 + 4]
  592. 8: ld [%o1 + 8], %o5
  593. sll %o3, %g4, %g2
  594. srl %o4, %g6, %g5
  595. or %g2, %g5, %g2
  596. st %g2, [%o0 + 8]
  597. 9: ld [%o1 + 12], %g1
  598. sll %o4, %g4, %g2
  599. srl %o5, %g6, %g5
  600. addcc %g3, -4, %g3
  601. or %g2, %g5, %g2
  602. add %o1, 16, %o1
  603. st %g2, [%o0 + 12]
  604. add %o0, 16, %o0
  605. bne,a 5b
  606. ld [%o1], %o3
  607. 10: sll %o5, %g4, %g2
  608. srl %g1, %g6, %g5
  609. srl %g6, 3, %g3
  610. or %g2, %g5, %g2
  611. sub %o1, %g3, %o1
  612. andcc %o2, 2, %g0
  613. st %g2, [%o0]
  614. be 1f
  615. andcc %o2, 1, %g0
  616. ldub [%o1], %g2
  617. add %o1, 2, %o1
  618. stb %g2, [%o0 + 4]
  619. add %o0, 2, %o0
  620. ldub [%o1 - 1], %g2
  621. stb %g2, [%o0 + 3]
  622. 1: be 1f
  623. nop
  624. ldub [%o1], %g2
  625. stb %g2, [%o0 + 4]
  626. 1: retl
  627. ld [%sp + 64], %o0
  628. 87: andcc %o1, 3, %g0
  629. be 3f
  630. andcc %o1, 1, %g0
  631. be 4f
  632. andcc %o1, 2, %g0
  633. ldub [%o1], %g2
  634. add %o1, 1, %o1
  635. stb %g2, [%o0]
  636. sub %o2, 1, %o2
  637. bne 3f
  638. add %o0, 1, %o0
  639. 4: lduh [%o1], %g2
  640. add %o1, 2, %o1
  641. srl %g2, 8, %g3
  642. sub %o2, 2, %o2
  643. stb %g3, [%o0]
  644. add %o0, 2, %o0
  645. stb %g2, [%o0 - 1]
  646. 3: andcc %o1, 4, %g0
  647. bne 2f
  648. cmp %o5, 1
  649. ld [%o1], %o4
  650. srl %o4, 24, %g2
  651. stb %g2, [%o0]
  652. srl %o4, 16, %g3
  653. stb %g3, [%o0 + 1]
  654. srl %o4, 8, %g2
  655. stb %g2, [%o0 + 2]
  656. sub %o2, 4, %o2
  657. stb %o4, [%o0 + 3]
  658. add %o1, 4, %o1
  659. add %o0, 4, %o0
  660. 2: be 33f
  661. cmp %o5, 2
  662. be 32f
  663. sub %o2, 4, %o2
  664. 31: ld [%o1], %g2
  665. add %o1, 4, %o1
  666. srl %g2, 24, %g3
  667. and %o0, 7, %g5
  668. stb %g3, [%o0]
  669. cmp %g5, 7
  670. sll %g2, 8, %g1
  671. add %o0, 4, %o0
  672. be 41f
  673. and %o2, 0xffffffc0, %o3
  674. ld [%o0 - 7], %o4
  675. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  676. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  677. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  678. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  679. subcc %o3, 64, %o3
  680. add %o1, 64, %o1
  681. bne 4b
  682. add %o0, 64, %o0
  683. andcc %o2, 0x30, %o3
  684. be,a 1f
  685. srl %g1, 16, %g2
  686. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  687. subcc %o3, 16, %o3
  688. add %o1, 16, %o1
  689. bne 4b
  690. add %o0, 16, %o0
  691. srl %g1, 16, %g2
  692. 1: st %o4, [%o0 - 7]
  693. sth %g2, [%o0 - 3]
  694. srl %g1, 8, %g4
  695. b 88f
  696. stb %g4, [%o0 - 1]
  697. 32: ld [%o1], %g2
  698. add %o1, 4, %o1
  699. srl %g2, 16, %g3
  700. and %o0, 7, %g5
  701. sth %g3, [%o0]
  702. cmp %g5, 6
  703. sll %g2, 16, %g1
  704. add %o0, 4, %o0
  705. be 42f
  706. and %o2, 0xffffffc0, %o3
  707. ld [%o0 - 6], %o4
  708. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  709. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  710. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  711. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  712. subcc %o3, 64, %o3
  713. add %o1, 64, %o1
  714. bne 4b
  715. add %o0, 64, %o0
  716. andcc %o2, 0x30, %o3
  717. be,a 1f
  718. srl %g1, 16, %g2
  719. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  720. subcc %o3, 16, %o3
  721. add %o1, 16, %o1
  722. bne 4b
  723. add %o0, 16, %o0
  724. srl %g1, 16, %g2
  725. 1: st %o4, [%o0 - 6]
  726. b 88f
  727. sth %g2, [%o0 - 2]
  728. 33: ld [%o1], %g2
  729. sub %o2, 4, %o2
  730. srl %g2, 24, %g3
  731. and %o0, 7, %g5
  732. stb %g3, [%o0]
  733. cmp %g5, 5
  734. srl %g2, 8, %g4
  735. sll %g2, 24, %g1
  736. sth %g4, [%o0 + 1]
  737. add %o1, 4, %o1
  738. be 43f
  739. and %o2, 0xffffffc0, %o3
  740. ld [%o0 - 1], %o4
  741. add %o0, 4, %o0
  742. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  743. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  744. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  745. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  746. subcc %o3, 64, %o3
  747. add %o1, 64, %o1
  748. bne 4b
  749. add %o0, 64, %o0
  750. andcc %o2, 0x30, %o3
  751. be,a 1f
  752. srl %g1, 24, %g2
  753. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  754. subcc %o3, 16, %o3
  755. add %o1, 16, %o1
  756. bne 4b
  757. add %o0, 16, %o0
  758. srl %g1, 24, %g2
  759. 1: st %o4, [%o0 - 5]
  760. b 88f
  761. stb %g2, [%o0 - 1]
  762. 41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  763. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  764. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  765. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  766. subcc %o3, 64, %o3
  767. add %o1, 64, %o1
  768. bne 41b
  769. add %o0, 64, %o0
  770. andcc %o2, 0x30, %o3
  771. be,a 1f
  772. srl %g1, 16, %g2
  773. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  774. subcc %o3, 16, %o3
  775. add %o1, 16, %o1
  776. bne 4b
  777. add %o0, 16, %o0
  778. srl %g1, 16, %g2
  779. 1: sth %g2, [%o0 - 3]
  780. srl %g1, 8, %g4
  781. b 88f
  782. stb %g4, [%o0 - 1]
  783. 43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  784. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  785. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  786. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  787. subcc %o3, 64, %o3
  788. add %o1, 64, %o1
  789. bne 43b
  790. add %o0, 64, %o0
  791. andcc %o2, 0x30, %o3
  792. be,a 1f
  793. srl %g1, 24, %g2
  794. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  795. subcc %o3, 16, %o3
  796. add %o1, 16, %o1
  797. bne 4b
  798. add %o0, 16, %o0
  799. srl %g1, 24, %g2
  800. 1: stb %g2, [%o0 + 3]
  801. b 88f
  802. add %o0, 4, %o0
  803. 42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  804. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  805. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  806. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  807. subcc %o3, 64, %o3
  808. add %o1, 64, %o1
  809. bne 42b
  810. add %o0, 64, %o0
  811. andcc %o2, 0x30, %o3
  812. be,a 1f
  813. srl %g1, 16, %g2
  814. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  815. subcc %o3, 16, %o3
  816. add %o1, 16, %o1
  817. bne 4b
  818. add %o0, 16, %o0
  819. srl %g1, 16, %g2
  820. 1: sth %g2, [%o0 - 2]
  821. /* Fall through */
  822. 88: and %o2, 0xe, %o3
  823. mov %o7, %g2
  824. sll %o3, 3, %o4
  825. add %o0, %o3, %o0
  826. 106: call 100f
  827. add %o1, %o3, %o1
  828. mov %g2, %o7
  829. jmpl %o5 + (89f - 106b), %g0
  830. andcc %o2, 1, %g0
  831. MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
  832. MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
  833. MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
  834. MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
  835. MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
  836. MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
  837. MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
  838. 89: be 1f
  839. nop
  840. ldub [%o1], %g2
  841. stb %g2, [%o0]
  842. 1: retl
  843. ld [%sp + 64], %o0
  844. 90: bne 88b
  845. andcc %o2, 8, %g0
  846. be 1f
  847. andcc %o2, 4, %g0
  848. ld [%o1 + 0x00], %g2
  849. ld [%o1 + 0x04], %g3
  850. add %o1, 8, %o1
  851. st %g2, [%o0 + 0x00]
  852. st %g3, [%o0 + 0x04]
  853. add %o0, 8, %o0
  854. 1: b 81b
  855. mov %o2, %g1
  856. 100: retl
  857. sub %o7, %o4, %o5
  858. 110: retl
  859. sub %o7, %g6, %o5
  860. END(memcpy)
  861. libc_hidden_def(memcpy)