memcpy.S 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972
  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, see
  18. <http://www.gnu.org/licenses/>. */
  19. #include <features.h>
  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. #ifdef __UCLIBC_SUSV3_LEGACY__
  147. ENTRY(bcopy)
  148. mov %o0, %o3
  149. mov %o1, %o0
  150. mov %o3, %o1
  151. END(bcopy)
  152. #endif
  153. ENTRY(memmove)
  154. cmp %o0, %o1
  155. st %o0, [%sp + 64]
  156. bleu 9f
  157. sub %o0, %o1, %o4
  158. add %o1, %o2, %o3
  159. cmp %o3, %o0
  160. bleu 0f
  161. andcc %o4, 3, %o5
  162. add %o1, %o2, %o1
  163. add %o0, %o2, %o0
  164. bne 77f
  165. cmp %o2, 15
  166. bleu 91f
  167. andcc %o1, 3, %g0
  168. bne 70b
  169. 3: andcc %o1, 4, %g0
  170. be 2f
  171. mov %o2, %g1
  172. ld [%o1 - 4], %o4
  173. sub %g1, 4, %g1
  174. st %o4, [%o0 - 4]
  175. sub %o1, 4, %o1
  176. sub %o0, 4, %o0
  177. 2: andcc %g1, 0xffffff80, %g6
  178. be 3f
  179. andcc %o0, 4, %g0
  180. be 74f + 4
  181. 5: RMOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  182. RMOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  183. RMOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  184. RMOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  185. subcc %g6, 128, %g6
  186. sub %o1, 128, %o1
  187. bne 5b
  188. sub %o0, 128, %o0
  189. 3: andcc %g1, 0x70, %g6
  190. be 72f
  191. andcc %g1, 8, %g0
  192. srl %g6, 1, %o4
  193. mov %o7, %g2
  194. add %g6, %o4, %o4
  195. 101: call 100f
  196. sub %o1, %g6, %o1
  197. mov %g2, %o7
  198. jmpl %o5 + (72f - 101b), %g0
  199. sub %o0, %g6, %o0
  200. 71: RMOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  201. RMOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  202. RMOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  203. RMOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  204. RMOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  205. RMOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  206. RMOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  207. 72: be 73f
  208. andcc %g1, 4, %g0
  209. ldd [%o1 - 0x08], %g2
  210. sub %o0, 8, %o0
  211. sub %o1, 8, %o1
  212. st %g2, [%o0]
  213. st %g3, [%o0 + 0x04]
  214. 73: be 1f
  215. andcc %g1, 2, %g0
  216. ld [%o1 - 4], %g2
  217. sub %o1, 4, %o1
  218. st %g2, [%o0 - 4]
  219. sub %o0, 4, %o0
  220. 1: be 1f
  221. andcc %g1, 1, %g0
  222. lduh [%o1 - 2], %g2
  223. sub %o1, 2, %o1
  224. sth %g2, [%o0 - 2]
  225. sub %o0, 2, %o0
  226. 1: be 1f
  227. nop
  228. ldub [%o1 - 1], %g2
  229. stb %g2, [%o0 - 1]
  230. 1: retl
  231. ld [%sp + 64], %o0
  232. 74: RMOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  233. RMOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  234. RMOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  235. RMOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  236. subcc %g6, 128, %g6
  237. sub %o1, 128, %o1
  238. bne 74b
  239. sub %o0, 128, %o0
  240. andcc %g1, 0x70, %g6
  241. be 72b
  242. andcc %g1, 8, %g0
  243. srl %g6, 1, %o4
  244. mov %o7, %g2
  245. add %g6, %o4, %o4
  246. 102: call 100f
  247. sub %o1, %g6, %o1
  248. mov %g2, %o7
  249. jmpl %o5 + (72b - 102b), %g0
  250. sub %o0, %g6, %o0
  251. 75: and %o2, 0xe, %o3
  252. mov %o7, %g2
  253. sll %o3, 3, %o4
  254. sub %o0, %o3, %o0
  255. 103: call 100f
  256. sub %o1, %o3, %o1
  257. mov %g2, %o7
  258. jmpl %o5 + (76f - 103b), %g0
  259. andcc %o2, 1, %g0
  260. RMOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
  261. RMOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
  262. RMOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
  263. RMOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
  264. RMOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
  265. RMOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
  266. RMOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
  267. 76: be 1f
  268. nop
  269. ldub [%o1 - 1], %g2
  270. stb %g2, [%o0 - 1]
  271. 1: retl
  272. ld [%sp + 64], %o0
  273. 91: bne 75b
  274. andcc %o2, 8, %g0
  275. be 1f
  276. andcc %o2, 4, %g0
  277. ld [%o1 - 0x08], %g2
  278. ld [%o1 - 0x04], %g3
  279. sub %o1, 8, %o1
  280. st %g2, [%o0 - 0x08]
  281. st %g3, [%o0 - 0x04]
  282. sub %o0, 8, %o0
  283. 1: b 73b
  284. mov %o2, %g1
  285. 77: cmp %o2, 15
  286. bleu 75b
  287. andcc %o0, 3, %g0
  288. be 64f
  289. andcc %o0, 1, %g0
  290. be 63f
  291. andcc %o0, 2, %g0
  292. ldub [%o1 - 1], %g5
  293. sub %o1, 1, %o1
  294. stb %g5, [%o0 - 1]
  295. sub %o0, 1, %o0
  296. be 64f
  297. sub %o2, 1, %o2
  298. 63: ldub [%o1 - 1], %g5
  299. sub %o1, 2, %o1
  300. stb %g5, [%o0 - 1]
  301. sub %o0, 2, %o0
  302. ldub [%o1], %g5
  303. sub %o2, 2, %o2
  304. stb %g5, [%o0]
  305. 64: and %o1, 3, %g2
  306. and %o1, -4, %o1
  307. and %o2, 0xc, %g3
  308. add %o1, 4, %o1
  309. cmp %g3, 4
  310. sll %g2, 3, %g4
  311. mov 32, %g2
  312. be 4f
  313. sub %g2, %g4, %g6
  314. blu 3f
  315. cmp %g3, 8
  316. be 2f
  317. srl %o2, 2, %g3
  318. ld [%o1 - 4], %o3
  319. add %o0, -8, %o0
  320. ld [%o1 - 8], %o4
  321. add %o1, -16, %o1
  322. b 7f
  323. add %g3, 1, %g3
  324. 2: ld [%o1 - 4], %o4
  325. add %o0, -4, %o0
  326. ld [%o1 - 8], %g1
  327. add %o1, -12, %o1
  328. b 8f
  329. add %g3, 2, %g3
  330. 3: ld [%o1 - 4], %o5
  331. add %o0, -12, %o0
  332. ld [%o1 - 8], %o3
  333. add %o1, -20, %o1
  334. b 6f
  335. srl %o2, 2, %g3
  336. 4: ld [%o1 - 4], %g1
  337. srl %o2, 2, %g3
  338. ld [%o1 - 8], %o5
  339. add %o1, -24, %o1
  340. add %o0, -16, %o0
  341. add %g3, -1, %g3
  342. ld [%o1 + 12], %o3
  343. 5: sll %o5, %g4, %g2
  344. srl %g1, %g6, %g5
  345. or %g2, %g5, %g2
  346. st %g2, [%o0 + 12]
  347. 6: ld [%o1 + 8], %o4
  348. sll %o3, %g4, %g2
  349. srl %o5, %g6, %g5
  350. or %g2, %g5, %g2
  351. st %g2, [%o0 + 8]
  352. 7: ld [%o1 + 4], %g1
  353. sll %o4, %g4, %g2
  354. srl %o3, %g6, %g5
  355. or %g2, %g5, %g2
  356. st %g2, [%o0 + 4]
  357. 8: ld [%o1], %o5
  358. sll %g1, %g4, %g2
  359. srl %o4, %g6, %g5
  360. addcc %g3, -4, %g3
  361. or %g2, %g5, %g2
  362. add %o1, -16, %o1
  363. st %g2, [%o0]
  364. add %o0, -16, %o0
  365. bne,a 5b
  366. ld [%o1 + 12], %o3
  367. sll %o5, %g4, %g2
  368. srl %g1, %g6, %g5
  369. srl %g4, 3, %g3
  370. or %g2, %g5, %g2
  371. add %o1, %g3, %o1
  372. andcc %o2, 2, %g0
  373. st %g2, [%o0 + 12]
  374. be 1f
  375. andcc %o2, 1, %g0
  376. ldub [%o1 + 15], %g5
  377. add %o1, -2, %o1
  378. stb %g5, [%o0 + 11]
  379. add %o0, -2, %o0
  380. ldub [%o1 + 16], %g5
  381. stb %g5, [%o0 + 12]
  382. 1: be 1f
  383. nop
  384. ldub [%o1 + 15], %g5
  385. stb %g5, [%o0 + 11]
  386. 1: retl
  387. ld [%sp + 64], %o0
  388. 78: andcc %o1, 1, %g0
  389. be 4f
  390. andcc %o1, 2, %g0
  391. ldub [%o1], %g2
  392. add %o1, 1, %o1
  393. stb %g2, [%o0]
  394. sub %o2, 1, %o2
  395. bne 3f
  396. add %o0, 1, %o0
  397. 4: lduh [%o1], %g2
  398. add %o1, 2, %o1
  399. sth %g2, [%o0]
  400. sub %o2, 2, %o2
  401. b 3f
  402. add %o0, 2, %o0
  403. END(memmove)
  404. libc_hidden_def(memmove)
  405. ENTRY(memcpy) /* %o0=dst %o1=src %o2=len */
  406. sub %o0, %o1, %o4
  407. st %o0, [%sp + 64]
  408. 9: andcc %o4, 3, %o5
  409. 0: bne 86f
  410. cmp %o2, 15
  411. bleu 90f
  412. andcc %o1, 3, %g0
  413. bne 78b
  414. 3: andcc %o1, 4, %g0
  415. be 2f
  416. mov %o2, %g1
  417. ld [%o1], %o4
  418. sub %g1, 4, %g1
  419. st %o4, [%o0]
  420. add %o1, 4, %o1
  421. add %o0, 4, %o0
  422. 2: andcc %g1, 0xffffff80, %g6
  423. be 3f
  424. andcc %o0, 4, %g0
  425. be 82f + 4
  426. 5: MOVE_BIGCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  427. MOVE_BIGCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  428. MOVE_BIGCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  429. MOVE_BIGCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  430. subcc %g6, 128, %g6
  431. add %o1, 128, %o1
  432. bne 5b
  433. add %o0, 128, %o0
  434. 3: andcc %g1, 0x70, %g6
  435. be 80f
  436. andcc %g1, 8, %g0
  437. srl %g6, 1, %o4
  438. mov %o7, %g2
  439. add %g6, %o4, %o4
  440. add %o1, %g6, %o1
  441. 104: call 100f
  442. add %o0, %g6, %o0
  443. jmpl %o5 + (80f - 104b), %g0
  444. mov %g2, %o7
  445. 79: MOVE_LASTCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  446. MOVE_LASTCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  447. MOVE_LASTCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  448. MOVE_LASTCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  449. MOVE_LASTCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  450. MOVE_LASTCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  451. MOVE_LASTCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  452. 80: be 81f
  453. andcc %g1, 4, %g0
  454. ldd [%o1], %g2
  455. add %o0, 8, %o0
  456. st %g2, [%o0 - 0x08]
  457. add %o1, 8, %o1
  458. st %g3, [%o0 - 0x04]
  459. 81: be 1f
  460. andcc %g1, 2, %g0
  461. ld [%o1], %g2
  462. add %o1, 4, %o1
  463. st %g2, [%o0]
  464. add %o0, 4, %o0
  465. 1: be 1f
  466. andcc %g1, 1, %g0
  467. lduh [%o1], %g2
  468. add %o1, 2, %o1
  469. sth %g2, [%o0]
  470. add %o0, 2, %o0
  471. 1: be 1f
  472. nop
  473. ldub [%o1], %g2
  474. stb %g2, [%o0]
  475. 1: retl
  476. ld [%sp + 64], %o0
  477. 82: /* ldd_std */
  478. MOVE_BIGALIGNCHUNK(o1, o0, 0x00, o2, o3, o4, o5, g2, g3, g4, g5)
  479. MOVE_BIGALIGNCHUNK(o1, o0, 0x20, o2, o3, o4, o5, g2, g3, g4, g5)
  480. MOVE_BIGALIGNCHUNK(o1, o0, 0x40, o2, o3, o4, o5, g2, g3, g4, g5)
  481. MOVE_BIGALIGNCHUNK(o1, o0, 0x60, o2, o3, o4, o5, g2, g3, g4, g5)
  482. subcc %g6, 128, %g6
  483. add %o1, 128, %o1
  484. bne 82b
  485. add %o0, 128, %o0
  486. andcc %g1, 0x70, %g6
  487. be 84f
  488. andcc %g1, 8, %g0
  489. mov %o7, %g2
  490. 111: call 110f
  491. add %o1, %g6, %o1
  492. mov %g2, %o7
  493. jmpl %o5 + (84f - 111b), %g0
  494. add %o0, %g6, %o0
  495. 83: MOVE_LASTALIGNCHUNK(o1, o0, 0x60, g2, g3, g4, g5)
  496. MOVE_LASTALIGNCHUNK(o1, o0, 0x50, g2, g3, g4, g5)
  497. MOVE_LASTALIGNCHUNK(o1, o0, 0x40, g2, g3, g4, g5)
  498. MOVE_LASTALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5)
  499. MOVE_LASTALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5)
  500. MOVE_LASTALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5)
  501. MOVE_LASTALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5)
  502. 84: be 85f
  503. andcc %g1, 4, %g0
  504. ldd [%o1], %g2
  505. add %o0, 8, %o0
  506. std %g2, [%o0 - 0x08]
  507. add %o1, 8, %o1
  508. 85: be 1f
  509. andcc %g1, 2, %g0
  510. ld [%o1], %g2
  511. add %o1, 4, %o1
  512. st %g2, [%o0]
  513. add %o0, 4, %o0
  514. 1: be 1f
  515. andcc %g1, 1, %g0
  516. lduh [%o1], %g2
  517. add %o1, 2, %o1
  518. sth %g2, [%o0]
  519. add %o0, 2, %o0
  520. 1: be 1f
  521. nop
  522. ldub [%o1], %g2
  523. stb %g2, [%o0]
  524. 1: retl
  525. ld [%sp + 64], %o0
  526. 86: cmp %o2, 6
  527. bleu 88f
  528. cmp %o2, 256
  529. bcc 87f
  530. andcc %o0, 3, %g0
  531. be 61f
  532. andcc %o0, 1, %g0
  533. be 60f
  534. andcc %o0, 2, %g0
  535. ldub [%o1], %g5
  536. add %o1, 1, %o1
  537. stb %g5, [%o0]
  538. sub %o2, 1, %o2
  539. bne 61f
  540. add %o0, 1, %o0
  541. 60: ldub [%o1], %g3
  542. add %o1, 2, %o1
  543. stb %g3, [%o0]
  544. sub %o2, 2, %o2
  545. ldub [%o1 - 1], %g3
  546. add %o0, 2, %o0
  547. stb %g3, [%o0 - 1]
  548. 61: and %o1, 3, %g2
  549. and %o2, 0xc, %g3
  550. and %o1, -4, %o1
  551. cmp %g3, 4
  552. sll %g2, 3, %g4
  553. mov 32, %g2
  554. be 4f
  555. sub %g2, %g4, %g6
  556. blu 3f
  557. cmp %g3, 0x8
  558. be 2f
  559. srl %o2, 2, %g3
  560. ld [%o1], %o3
  561. add %o0, -8, %o0
  562. ld [%o1 + 4], %o4
  563. b 8f
  564. add %g3, 1, %g3
  565. 2: ld [%o1], %o4
  566. add %o0, -12, %o0
  567. ld [%o1 + 4], %o5
  568. add %g3, 2, %g3
  569. b 9f
  570. add %o1, -4, %o1
  571. 3: ld [%o1], %g1
  572. add %o0, -4, %o0
  573. ld [%o1 + 4], %o3
  574. srl %o2, 2, %g3
  575. b 7f
  576. add %o1, 4, %o1
  577. 4: ld [%o1], %o5
  578. cmp %o2, 7
  579. ld [%o1 + 4], %g1
  580. srl %o2, 2, %g3
  581. bleu 10f
  582. add %o1, 8, %o1
  583. ld [%o1], %o3
  584. add %g3, -1, %g3
  585. 5: sll %o5, %g4, %g2
  586. srl %g1, %g6, %g5
  587. or %g2, %g5, %g2
  588. st %g2, [%o0]
  589. 7: ld [%o1 + 4], %o4
  590. sll %g1, %g4, %g2
  591. srl %o3, %g6, %g5
  592. or %g2, %g5, %g2
  593. st %g2, [%o0 + 4]
  594. 8: ld [%o1 + 8], %o5
  595. sll %o3, %g4, %g2
  596. srl %o4, %g6, %g5
  597. or %g2, %g5, %g2
  598. st %g2, [%o0 + 8]
  599. 9: ld [%o1 + 12], %g1
  600. sll %o4, %g4, %g2
  601. srl %o5, %g6, %g5
  602. addcc %g3, -4, %g3
  603. or %g2, %g5, %g2
  604. add %o1, 16, %o1
  605. st %g2, [%o0 + 12]
  606. add %o0, 16, %o0
  607. bne,a 5b
  608. ld [%o1], %o3
  609. 10: sll %o5, %g4, %g2
  610. srl %g1, %g6, %g5
  611. srl %g6, 3, %g3
  612. or %g2, %g5, %g2
  613. sub %o1, %g3, %o1
  614. andcc %o2, 2, %g0
  615. st %g2, [%o0]
  616. be 1f
  617. andcc %o2, 1, %g0
  618. ldub [%o1], %g2
  619. add %o1, 2, %o1
  620. stb %g2, [%o0 + 4]
  621. add %o0, 2, %o0
  622. ldub [%o1 - 1], %g2
  623. stb %g2, [%o0 + 3]
  624. 1: be 1f
  625. nop
  626. ldub [%o1], %g2
  627. stb %g2, [%o0 + 4]
  628. 1: retl
  629. ld [%sp + 64], %o0
  630. 87: andcc %o1, 3, %g0
  631. be 3f
  632. andcc %o1, 1, %g0
  633. be 4f
  634. andcc %o1, 2, %g0
  635. ldub [%o1], %g2
  636. add %o1, 1, %o1
  637. stb %g2, [%o0]
  638. sub %o2, 1, %o2
  639. bne 3f
  640. add %o0, 1, %o0
  641. 4: lduh [%o1], %g2
  642. add %o1, 2, %o1
  643. srl %g2, 8, %g3
  644. sub %o2, 2, %o2
  645. stb %g3, [%o0]
  646. add %o0, 2, %o0
  647. stb %g2, [%o0 - 1]
  648. 3: andcc %o1, 4, %g0
  649. bne 2f
  650. cmp %o5, 1
  651. ld [%o1], %o4
  652. srl %o4, 24, %g2
  653. stb %g2, [%o0]
  654. srl %o4, 16, %g3
  655. stb %g3, [%o0 + 1]
  656. srl %o4, 8, %g2
  657. stb %g2, [%o0 + 2]
  658. sub %o2, 4, %o2
  659. stb %o4, [%o0 + 3]
  660. add %o1, 4, %o1
  661. add %o0, 4, %o0
  662. 2: be 33f
  663. cmp %o5, 2
  664. be 32f
  665. sub %o2, 4, %o2
  666. 31: ld [%o1], %g2
  667. add %o1, 4, %o1
  668. srl %g2, 24, %g3
  669. and %o0, 7, %g5
  670. stb %g3, [%o0]
  671. cmp %g5, 7
  672. sll %g2, 8, %g1
  673. add %o0, 4, %o0
  674. be 41f
  675. and %o2, 0xffffffc0, %o3
  676. ld [%o0 - 7], %o4
  677. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  678. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  679. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  680. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  681. subcc %o3, 64, %o3
  682. add %o1, 64, %o1
  683. bne 4b
  684. add %o0, 64, %o0
  685. andcc %o2, 0x30, %o3
  686. be,a 1f
  687. srl %g1, 16, %g2
  688. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  689. subcc %o3, 16, %o3
  690. add %o1, 16, %o1
  691. bne 4b
  692. add %o0, 16, %o0
  693. srl %g1, 16, %g2
  694. 1: st %o4, [%o0 - 7]
  695. sth %g2, [%o0 - 3]
  696. srl %g1, 8, %g4
  697. b 88f
  698. stb %g4, [%o0 - 1]
  699. 32: ld [%o1], %g2
  700. add %o1, 4, %o1
  701. srl %g2, 16, %g3
  702. and %o0, 7, %g5
  703. sth %g3, [%o0]
  704. cmp %g5, 6
  705. sll %g2, 16, %g1
  706. add %o0, 4, %o0
  707. be 42f
  708. and %o2, 0xffffffc0, %o3
  709. ld [%o0 - 6], %o4
  710. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  711. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  712. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  713. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  714. subcc %o3, 64, %o3
  715. add %o1, 64, %o1
  716. bne 4b
  717. add %o0, 64, %o0
  718. andcc %o2, 0x30, %o3
  719. be,a 1f
  720. srl %g1, 16, %g2
  721. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  722. subcc %o3, 16, %o3
  723. add %o1, 16, %o1
  724. bne 4b
  725. add %o0, 16, %o0
  726. srl %g1, 16, %g2
  727. 1: st %o4, [%o0 - 6]
  728. b 88f
  729. sth %g2, [%o0 - 2]
  730. 33: ld [%o1], %g2
  731. sub %o2, 4, %o2
  732. srl %g2, 24, %g3
  733. and %o0, 7, %g5
  734. stb %g3, [%o0]
  735. cmp %g5, 5
  736. srl %g2, 8, %g4
  737. sll %g2, 24, %g1
  738. sth %g4, [%o0 + 1]
  739. add %o1, 4, %o1
  740. be 43f
  741. and %o2, 0xffffffc0, %o3
  742. ld [%o0 - 1], %o4
  743. add %o0, 4, %o0
  744. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  745. SMOVE_CHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  746. SMOVE_CHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  747. SMOVE_CHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  748. subcc %o3, 64, %o3
  749. add %o1, 64, %o1
  750. bne 4b
  751. add %o0, 64, %o0
  752. andcc %o2, 0x30, %o3
  753. be,a 1f
  754. srl %g1, 24, %g2
  755. 4: SMOVE_CHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, -1)
  756. subcc %o3, 16, %o3
  757. add %o1, 16, %o1
  758. bne 4b
  759. add %o0, 16, %o0
  760. srl %g1, 24, %g2
  761. 1: st %o4, [%o0 - 5]
  762. b 88f
  763. stb %g2, [%o0 - 1]
  764. 41: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  765. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  766. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  767. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  768. subcc %o3, 64, %o3
  769. add %o1, 64, %o1
  770. bne 41b
  771. add %o0, 64, %o0
  772. andcc %o2, 0x30, %o3
  773. be,a 1f
  774. srl %g1, 16, %g2
  775. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 8, 24, -3)
  776. subcc %o3, 16, %o3
  777. add %o1, 16, %o1
  778. bne 4b
  779. add %o0, 16, %o0
  780. srl %g1, 16, %g2
  781. 1: sth %g2, [%o0 - 3]
  782. srl %g1, 8, %g4
  783. b 88f
  784. stb %g4, [%o0 - 1]
  785. 43: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  786. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  787. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  788. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  789. subcc %o3, 64, %o3
  790. add %o1, 64, %o1
  791. bne 43b
  792. add %o0, 64, %o0
  793. andcc %o2, 0x30, %o3
  794. be,a 1f
  795. srl %g1, 24, %g2
  796. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 24, 8, 3)
  797. subcc %o3, 16, %o3
  798. add %o1, 16, %o1
  799. bne 4b
  800. add %o0, 16, %o0
  801. srl %g1, 24, %g2
  802. 1: stb %g2, [%o0 + 3]
  803. b 88f
  804. add %o0, 4, %o0
  805. 42: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  806. SMOVE_ALIGNCHUNK(o1, o0, 0x10, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  807. SMOVE_ALIGNCHUNK(o1, o0, 0x20, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  808. SMOVE_ALIGNCHUNK(o1, o0, 0x30, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  809. subcc %o3, 64, %o3
  810. add %o1, 64, %o1
  811. bne 42b
  812. add %o0, 64, %o0
  813. andcc %o2, 0x30, %o3
  814. be,a 1f
  815. srl %g1, 16, %g2
  816. 4: SMOVE_ALIGNCHUNK(o1, o0, 0x00, g2, g3, g4, g5, o4, o5, g6, g1, 16, 16, -2)
  817. subcc %o3, 16, %o3
  818. add %o1, 16, %o1
  819. bne 4b
  820. add %o0, 16, %o0
  821. srl %g1, 16, %g2
  822. 1: sth %g2, [%o0 - 2]
  823. /* Fall through */
  824. 88: and %o2, 0xe, %o3
  825. mov %o7, %g2
  826. sll %o3, 3, %o4
  827. add %o0, %o3, %o0
  828. 106: call 100f
  829. add %o1, %o3, %o1
  830. mov %g2, %o7
  831. jmpl %o5 + (89f - 106b), %g0
  832. andcc %o2, 1, %g0
  833. MOVE_SHORTCHUNK(o1, o0, 0x0c, g2, g3)
  834. MOVE_SHORTCHUNK(o1, o0, 0x0a, g2, g3)
  835. MOVE_SHORTCHUNK(o1, o0, 0x08, g2, g3)
  836. MOVE_SHORTCHUNK(o1, o0, 0x06, g2, g3)
  837. MOVE_SHORTCHUNK(o1, o0, 0x04, g2, g3)
  838. MOVE_SHORTCHUNK(o1, o0, 0x02, g2, g3)
  839. MOVE_SHORTCHUNK(o1, o0, 0x00, g2, g3)
  840. 89: be 1f
  841. nop
  842. ldub [%o1], %g2
  843. stb %g2, [%o0]
  844. 1: retl
  845. ld [%sp + 64], %o0
  846. 90: bne 88b
  847. andcc %o2, 8, %g0
  848. be 1f
  849. andcc %o2, 4, %g0
  850. ld [%o1 + 0x00], %g2
  851. ld [%o1 + 0x04], %g3
  852. add %o1, 8, %o1
  853. st %g2, [%o0 + 0x00]
  854. st %g3, [%o0 + 0x04]
  855. add %o0, 8, %o0
  856. 1: b 81b
  857. mov %o2, %g1
  858. 100: retl
  859. sub %o7, %o4, %o5
  860. 110: retl
  861. sub %o7, %g6, %o5
  862. END(memcpy)
  863. libc_hidden_def(memcpy)