checksum_32.S 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* checksum.S: Sparc optimized checksum code.
  3. *
  4. * Copyright(C) 1995 Linus Torvalds
  5. * Copyright(C) 1995 Miguel de Icaza
  6. * Copyright(C) 1996 David S. Miller
  7. * Copyright(C) 1997 Jakub Jelinek
  8. *
  9. * derived from:
  10. * Linux/Alpha checksum c-code
  11. * Linux/ix86 inline checksum assembly
  12. * RFC1071 Computing the Internet Checksum (esp. Jacobsons m68k code)
  13. * David Mosberger-Tang for optimized reference c-code
  14. * BSD4.4 portable checksum routine
  15. */
  16. #include <asm/errno.h>
  17. #include <asm/export.h>
  18. #define CSUM_BIGCHUNK(buf, offset, sum, t0, t1, t2, t3, t4, t5) \
  19. ldd [buf + offset + 0x00], t0; \
  20. ldd [buf + offset + 0x08], t2; \
  21. addxcc t0, sum, sum; \
  22. addxcc t1, sum, sum; \
  23. ldd [buf + offset + 0x10], t4; \
  24. addxcc t2, sum, sum; \
  25. addxcc t3, sum, sum; \
  26. ldd [buf + offset + 0x18], t0; \
  27. addxcc t4, sum, sum; \
  28. addxcc t5, sum, sum; \
  29. addxcc t0, sum, sum; \
  30. addxcc t1, sum, sum;
  31. #define CSUM_LASTCHUNK(buf, offset, sum, t0, t1, t2, t3) \
  32. ldd [buf - offset - 0x08], t0; \
  33. ldd [buf - offset - 0x00], t2; \
  34. addxcc t0, sum, sum; \
  35. addxcc t1, sum, sum; \
  36. addxcc t2, sum, sum; \
  37. addxcc t3, sum, sum;
  38. /* Do end cruft out of band to get better cache patterns. */
  39. csum_partial_end_cruft:
  40. be 1f ! caller asks %o1 & 0x8
  41. andcc %o1, 4, %g0 ! nope, check for word remaining
  42. ldd [%o0], %g2 ! load two
  43. addcc %g2, %o2, %o2 ! add first word to sum
  44. addxcc %g3, %o2, %o2 ! add second word as well
  45. add %o0, 8, %o0 ! advance buf ptr
  46. addx %g0, %o2, %o2 ! add in final carry
  47. andcc %o1, 4, %g0 ! check again for word remaining
  48. 1: be 1f ! nope, skip this code
  49. andcc %o1, 3, %o1 ! check for trailing bytes
  50. ld [%o0], %g2 ! load it
  51. addcc %g2, %o2, %o2 ! add to sum
  52. add %o0, 4, %o0 ! advance buf ptr
  53. addx %g0, %o2, %o2 ! add in final carry
  54. andcc %o1, 3, %g0 ! check again for trailing bytes
  55. 1: be 1f ! no trailing bytes, return
  56. addcc %o1, -1, %g0 ! only one byte remains?
  57. bne 2f ! at least two bytes more
  58. subcc %o1, 2, %o1 ! only two bytes more?
  59. b 4f ! only one byte remains
  60. or %g0, %g0, %o4 ! clear fake hword value
  61. 2: lduh [%o0], %o4 ! get hword
  62. be 6f ! jmp if only hword remains
  63. add %o0, 2, %o0 ! advance buf ptr either way
  64. sll %o4, 16, %o4 ! create upper hword
  65. 4: ldub [%o0], %o5 ! get final byte
  66. sll %o5, 8, %o5 ! put into place
  67. or %o5, %o4, %o4 ! coalese with hword (if any)
  68. 6: addcc %o4, %o2, %o2 ! add to sum
  69. 1: retl ! get outta here
  70. addx %g0, %o2, %o0 ! add final carry into retval
  71. /* Also do alignment out of band to get better cache patterns. */
  72. csum_partial_fix_alignment:
  73. cmp %o1, 6
  74. bl cpte - 0x4
  75. andcc %o0, 0x2, %g0
  76. be 1f
  77. andcc %o0, 0x4, %g0
  78. lduh [%o0 + 0x00], %g2
  79. sub %o1, 2, %o1
  80. add %o0, 2, %o0
  81. sll %g2, 16, %g2
  82. addcc %g2, %o2, %o2
  83. srl %o2, 16, %g3
  84. addx %g0, %g3, %g2
  85. sll %o2, 16, %o2
  86. sll %g2, 16, %g3
  87. srl %o2, 16, %o2
  88. andcc %o0, 0x4, %g0
  89. or %g3, %o2, %o2
  90. 1: be cpa
  91. andcc %o1, 0xffffff80, %o3
  92. ld [%o0 + 0x00], %g2
  93. sub %o1, 4, %o1
  94. addcc %g2, %o2, %o2
  95. add %o0, 4, %o0
  96. addx %g0, %o2, %o2
  97. b cpa
  98. andcc %o1, 0xffffff80, %o3
  99. /* The common case is to get called with a nicely aligned
  100. * buffer of size 0x20. Follow the code path for that case.
  101. */
  102. .globl csum_partial
  103. EXPORT_SYMBOL(csum_partial)
  104. csum_partial: /* %o0=buf, %o1=len, %o2=sum */
  105. andcc %o0, 0x7, %g0 ! alignment problems?
  106. bne csum_partial_fix_alignment ! yep, handle it
  107. sethi %hi(cpte - 8), %g7 ! prepare table jmp ptr
  108. andcc %o1, 0xffffff80, %o3 ! num loop iterations
  109. cpa: be 3f ! none to do
  110. andcc %o1, 0x70, %g1 ! clears carry flag too
  111. 5: CSUM_BIGCHUNK(%o0, 0x00, %o2, %o4, %o5, %g2, %g3, %g4, %g5)
  112. CSUM_BIGCHUNK(%o0, 0x20, %o2, %o4, %o5, %g2, %g3, %g4, %g5)
  113. CSUM_BIGCHUNK(%o0, 0x40, %o2, %o4, %o5, %g2, %g3, %g4, %g5)
  114. CSUM_BIGCHUNK(%o0, 0x60, %o2, %o4, %o5, %g2, %g3, %g4, %g5)
  115. addx %g0, %o2, %o2 ! sink in final carry
  116. subcc %o3, 128, %o3 ! detract from loop iters
  117. bne 5b ! more to do
  118. add %o0, 128, %o0 ! advance buf ptr
  119. andcc %o1, 0x70, %g1 ! clears carry flag too
  120. 3: be cpte ! nope
  121. andcc %o1, 0xf, %g0 ! anything left at all?
  122. srl %g1, 1, %o4 ! compute offset
  123. sub %g7, %g1, %g7 ! adjust jmp ptr
  124. sub %g7, %o4, %g7 ! final jmp ptr adjust
  125. jmp %g7 + %lo(cpte - 8) ! enter the table
  126. add %o0, %g1, %o0 ! advance buf ptr
  127. cptbl: CSUM_LASTCHUNK(%o0, 0x68, %o2, %g2, %g3, %g4, %g5)
  128. CSUM_LASTCHUNK(%o0, 0x58, %o2, %g2, %g3, %g4, %g5)
  129. CSUM_LASTCHUNK(%o0, 0x48, %o2, %g2, %g3, %g4, %g5)
  130. CSUM_LASTCHUNK(%o0, 0x38, %o2, %g2, %g3, %g4, %g5)
  131. CSUM_LASTCHUNK(%o0, 0x28, %o2, %g2, %g3, %g4, %g5)
  132. CSUM_LASTCHUNK(%o0, 0x18, %o2, %g2, %g3, %g4, %g5)
  133. CSUM_LASTCHUNK(%o0, 0x08, %o2, %g2, %g3, %g4, %g5)
  134. addx %g0, %o2, %o2 ! fetch final carry
  135. andcc %o1, 0xf, %g0 ! anything left at all?
  136. cpte: bne csum_partial_end_cruft ! yep, handle it
  137. andcc %o1, 8, %g0 ! check how much
  138. cpout: retl ! get outta here
  139. mov %o2, %o0 ! return computed csum
  140. /* Work around cpp -rob */
  141. #define ALLOC #alloc
  142. #define EXECINSTR #execinstr
  143. #define EX(x,y) \
  144. 98: x,y; \
  145. .section __ex_table,ALLOC; \
  146. .align 4; \
  147. .word 98b, cc_fault; \
  148. .text; \
  149. .align 4
  150. #define EXT(start,end) \
  151. .section __ex_table,ALLOC; \
  152. .align 4; \
  153. .word start, 0, end, cc_fault; \
  154. .text; \
  155. .align 4
  156. /* This aligned version executes typically in 8.5 superscalar cycles, this
  157. * is the best I can do. I say 8.5 because the final add will pair with
  158. * the next ldd in the main unrolled loop. Thus the pipe is always full.
  159. * If you change these macros (including order of instructions),
  160. * please check the fixup code below as well.
  161. */
  162. #define CSUMCOPY_BIGCHUNK_ALIGNED(src, dst, sum, off, t0, t1, t2, t3, t4, t5, t6, t7) \
  163. ldd [src + off + 0x00], t0; \
  164. ldd [src + off + 0x08], t2; \
  165. addxcc t0, sum, sum; \
  166. ldd [src + off + 0x10], t4; \
  167. addxcc t1, sum, sum; \
  168. ldd [src + off + 0x18], t6; \
  169. addxcc t2, sum, sum; \
  170. std t0, [dst + off + 0x00]; \
  171. addxcc t3, sum, sum; \
  172. std t2, [dst + off + 0x08]; \
  173. addxcc t4, sum, sum; \
  174. std t4, [dst + off + 0x10]; \
  175. addxcc t5, sum, sum; \
  176. std t6, [dst + off + 0x18]; \
  177. addxcc t6, sum, sum; \
  178. addxcc t7, sum, sum;
  179. /* 12 superscalar cycles seems to be the limit for this case,
  180. * because of this we thus do all the ldd's together to get
  181. * Viking MXCC into streaming mode. Ho hum...
  182. */
  183. #define CSUMCOPY_BIGCHUNK(src, dst, sum, off, t0, t1, t2, t3, t4, t5, t6, t7) \
  184. ldd [src + off + 0x00], t0; \
  185. ldd [src + off + 0x08], t2; \
  186. ldd [src + off + 0x10], t4; \
  187. ldd [src + off + 0x18], t6; \
  188. st t0, [dst + off + 0x00]; \
  189. addxcc t0, sum, sum; \
  190. st t1, [dst + off + 0x04]; \
  191. addxcc t1, sum, sum; \
  192. st t2, [dst + off + 0x08]; \
  193. addxcc t2, sum, sum; \
  194. st t3, [dst + off + 0x0c]; \
  195. addxcc t3, sum, sum; \
  196. st t4, [dst + off + 0x10]; \
  197. addxcc t4, sum, sum; \
  198. st t5, [dst + off + 0x14]; \
  199. addxcc t5, sum, sum; \
  200. st t6, [dst + off + 0x18]; \
  201. addxcc t6, sum, sum; \
  202. st t7, [dst + off + 0x1c]; \
  203. addxcc t7, sum, sum;
  204. /* Yuck, 6 superscalar cycles... */
  205. #define CSUMCOPY_LASTCHUNK(src, dst, sum, off, t0, t1, t2, t3) \
  206. ldd [src - off - 0x08], t0; \
  207. ldd [src - off - 0x00], t2; \
  208. addxcc t0, sum, sum; \
  209. st t0, [dst - off - 0x08]; \
  210. addxcc t1, sum, sum; \
  211. st t1, [dst - off - 0x04]; \
  212. addxcc t2, sum, sum; \
  213. st t2, [dst - off - 0x00]; \
  214. addxcc t3, sum, sum; \
  215. st t3, [dst - off + 0x04];
  216. /* Handle the end cruft code out of band for better cache patterns. */
  217. cc_end_cruft:
  218. be 1f
  219. andcc %o3, 4, %g0
  220. EX(ldd [%o0 + 0x00], %g2)
  221. add %o1, 8, %o1
  222. addcc %g2, %g7, %g7
  223. add %o0, 8, %o0
  224. addxcc %g3, %g7, %g7
  225. EX(st %g2, [%o1 - 0x08])
  226. addx %g0, %g7, %g7
  227. andcc %o3, 4, %g0
  228. EX(st %g3, [%o1 - 0x04])
  229. 1: be 1f
  230. andcc %o3, 3, %o3
  231. EX(ld [%o0 + 0x00], %g2)
  232. add %o1, 4, %o1
  233. addcc %g2, %g7, %g7
  234. EX(st %g2, [%o1 - 0x04])
  235. addx %g0, %g7, %g7
  236. andcc %o3, 3, %g0
  237. add %o0, 4, %o0
  238. 1: be 1f
  239. addcc %o3, -1, %g0
  240. bne 2f
  241. subcc %o3, 2, %o3
  242. b 4f
  243. or %g0, %g0, %o4
  244. 2: EX(lduh [%o0 + 0x00], %o4)
  245. add %o0, 2, %o0
  246. EX(sth %o4, [%o1 + 0x00])
  247. be 6f
  248. add %o1, 2, %o1
  249. sll %o4, 16, %o4
  250. 4: EX(ldub [%o0 + 0x00], %o5)
  251. EX(stb %o5, [%o1 + 0x00])
  252. sll %o5, 8, %o5
  253. or %o5, %o4, %o4
  254. 6: addcc %o4, %g7, %g7
  255. 1: retl
  256. addx %g0, %g7, %o0
  257. /* Also, handle the alignment code out of band. */
  258. cc_dword_align:
  259. cmp %g1, 16
  260. bge 1f
  261. srl %g1, 1, %o3
  262. 2: cmp %o3, 0
  263. be,a ccte
  264. andcc %g1, 0xf, %o3
  265. andcc %o3, %o0, %g0 ! Check %o0 only (%o1 has the same last 2 bits)
  266. be,a 2b
  267. srl %o3, 1, %o3
  268. 1: andcc %o0, 0x1, %g0
  269. bne ccslow
  270. andcc %o0, 0x2, %g0
  271. be 1f
  272. andcc %o0, 0x4, %g0
  273. EX(lduh [%o0 + 0x00], %g4)
  274. sub %g1, 2, %g1
  275. EX(sth %g4, [%o1 + 0x00])
  276. add %o0, 2, %o0
  277. sll %g4, 16, %g4
  278. addcc %g4, %g7, %g7
  279. add %o1, 2, %o1
  280. srl %g7, 16, %g3
  281. addx %g0, %g3, %g4
  282. sll %g7, 16, %g7
  283. sll %g4, 16, %g3
  284. srl %g7, 16, %g7
  285. andcc %o0, 0x4, %g0
  286. or %g3, %g7, %g7
  287. 1: be 3f
  288. andcc %g1, 0xffffff80, %g0
  289. EX(ld [%o0 + 0x00], %g4)
  290. sub %g1, 4, %g1
  291. EX(st %g4, [%o1 + 0x00])
  292. add %o0, 4, %o0
  293. addcc %g4, %g7, %g7
  294. add %o1, 4, %o1
  295. addx %g0, %g7, %g7
  296. b 3f
  297. andcc %g1, 0xffffff80, %g0
  298. /* Sun, you just can't beat me, you just can't. Stop trying,
  299. * give up. I'm serious, I am going to kick the living shit
  300. * out of you, game over, lights out.
  301. */
  302. .align 8
  303. .globl __csum_partial_copy_sparc_generic
  304. EXPORT_SYMBOL(__csum_partial_copy_sparc_generic)
  305. __csum_partial_copy_sparc_generic:
  306. /* %o0=src, %o1=dest, %g1=len, %g7=sum */
  307. xor %o0, %o1, %o4 ! get changing bits
  308. andcc %o4, 3, %g0 ! check for mismatched alignment
  309. bne ccslow ! better this than unaligned/fixups
  310. andcc %o0, 7, %g0 ! need to align things?
  311. bne cc_dword_align ! yes, we check for short lengths there
  312. andcc %g1, 0xffffff80, %g0 ! can we use unrolled loop?
  313. 3: be 3f ! nope, less than one loop remains
  314. andcc %o1, 4, %g0 ! dest aligned on 4 or 8 byte boundary?
  315. be ccdbl + 4 ! 8 byte aligned, kick ass
  316. 5: CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  317. CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  318. CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  319. CSUMCOPY_BIGCHUNK(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  320. 10: EXT(5b, 10b) ! note for exception handling
  321. sub %g1, 128, %g1 ! detract from length
  322. addx %g0, %g7, %g7 ! add in last carry bit
  323. andcc %g1, 0xffffff80, %g0 ! more to csum?
  324. add %o0, 128, %o0 ! advance src ptr
  325. bne 5b ! we did not go negative, continue looping
  326. add %o1, 128, %o1 ! advance dest ptr
  327. 3: andcc %g1, 0x70, %o2 ! can use table?
  328. ccmerge:be ccte ! nope, go and check for end cruft
  329. andcc %g1, 0xf, %o3 ! get low bits of length (clears carry btw)
  330. srl %o2, 1, %o4 ! begin negative offset computation
  331. sethi %hi(12f), %o5 ! set up table ptr end
  332. add %o0, %o2, %o0 ! advance src ptr
  333. sub %o5, %o4, %o5 ! continue table calculation
  334. sll %o2, 1, %g2 ! constant multiplies are fun...
  335. sub %o5, %g2, %o5 ! some more adjustments
  336. jmp %o5 + %lo(12f) ! jump into it, duff style, wheee...
  337. add %o1, %o2, %o1 ! advance dest ptr (carry is clear btw)
  338. cctbl: CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x68,%g2,%g3,%g4,%g5)
  339. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x58,%g2,%g3,%g4,%g5)
  340. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x48,%g2,%g3,%g4,%g5)
  341. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x38,%g2,%g3,%g4,%g5)
  342. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x28,%g2,%g3,%g4,%g5)
  343. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x18,%g2,%g3,%g4,%g5)
  344. CSUMCOPY_LASTCHUNK(%o0,%o1,%g7,0x08,%g2,%g3,%g4,%g5)
  345. 12: EXT(cctbl, 12b) ! note for exception table handling
  346. addx %g0, %g7, %g7
  347. andcc %o3, 0xf, %g0 ! check for low bits set
  348. ccte: bne cc_end_cruft ! something left, handle it out of band
  349. andcc %o3, 8, %g0 ! begin checks for that code
  350. retl ! return
  351. mov %g7, %o0 ! give em the computed checksum
  352. ccdbl: CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x00,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  353. CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x20,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  354. CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x40,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  355. CSUMCOPY_BIGCHUNK_ALIGNED(%o0,%o1,%g7,0x60,%o4,%o5,%g2,%g3,%g4,%g5,%o2,%o3)
  356. 11: EXT(ccdbl, 11b) ! note for exception table handling
  357. sub %g1, 128, %g1 ! detract from length
  358. addx %g0, %g7, %g7 ! add in last carry bit
  359. andcc %g1, 0xffffff80, %g0 ! more to csum?
  360. add %o0, 128, %o0 ! advance src ptr
  361. bne ccdbl ! we did not go negative, continue looping
  362. add %o1, 128, %o1 ! advance dest ptr
  363. b ccmerge ! finish it off, above
  364. andcc %g1, 0x70, %o2 ! can use table? (clears carry btw)
  365. ccslow: cmp %g1, 0
  366. mov 0, %g5
  367. bleu 4f
  368. andcc %o0, 1, %o5
  369. be,a 1f
  370. srl %g1, 1, %g4
  371. sub %g1, 1, %g1
  372. EX(ldub [%o0], %g5)
  373. add %o0, 1, %o0
  374. EX(stb %g5, [%o1])
  375. srl %g1, 1, %g4
  376. add %o1, 1, %o1
  377. 1: cmp %g4, 0
  378. be,a 3f
  379. andcc %g1, 1, %g0
  380. andcc %o0, 2, %g0
  381. be,a 1f
  382. srl %g4, 1, %g4
  383. EX(lduh [%o0], %o4)
  384. sub %g1, 2, %g1
  385. srl %o4, 8, %g2
  386. sub %g4, 1, %g4
  387. EX(stb %g2, [%o1])
  388. add %o4, %g5, %g5
  389. EX(stb %o4, [%o1 + 1])
  390. add %o0, 2, %o0
  391. srl %g4, 1, %g4
  392. add %o1, 2, %o1
  393. 1: cmp %g4, 0
  394. be,a 2f
  395. andcc %g1, 2, %g0
  396. EX(ld [%o0], %o4)
  397. 5: srl %o4, 24, %g2
  398. srl %o4, 16, %g3
  399. EX(stb %g2, [%o1])
  400. srl %o4, 8, %g2
  401. EX(stb %g3, [%o1 + 1])
  402. add %o0, 4, %o0
  403. EX(stb %g2, [%o1 + 2])
  404. addcc %o4, %g5, %g5
  405. EX(stb %o4, [%o1 + 3])
  406. addx %g5, %g0, %g5 ! I am now to lazy to optimize this (question it
  407. add %o1, 4, %o1 ! is worthy). Maybe some day - with the sll/srl
  408. subcc %g4, 1, %g4 ! tricks
  409. bne,a 5b
  410. EX(ld [%o0], %o4)
  411. sll %g5, 16, %g2
  412. srl %g5, 16, %g5
  413. srl %g2, 16, %g2
  414. andcc %g1, 2, %g0
  415. add %g2, %g5, %g5
  416. 2: be,a 3f
  417. andcc %g1, 1, %g0
  418. EX(lduh [%o0], %o4)
  419. andcc %g1, 1, %g0
  420. srl %o4, 8, %g2
  421. add %o0, 2, %o0
  422. EX(stb %g2, [%o1])
  423. add %g5, %o4, %g5
  424. EX(stb %o4, [%o1 + 1])
  425. add %o1, 2, %o1
  426. 3: be,a 1f
  427. sll %g5, 16, %o4
  428. EX(ldub [%o0], %g2)
  429. sll %g2, 8, %o4
  430. EX(stb %g2, [%o1])
  431. add %g5, %o4, %g5
  432. sll %g5, 16, %o4
  433. 1: addcc %o4, %g5, %g5
  434. srl %g5, 16, %o4
  435. addx %g0, %o4, %g5
  436. orcc %o5, %g0, %g0
  437. be 4f
  438. srl %g5, 8, %o4
  439. and %g5, 0xff, %g2
  440. and %o4, 0xff, %o4
  441. sll %g2, 8, %g2
  442. or %g2, %o4, %g5
  443. 4: addcc %g7, %g5, %g7
  444. retl
  445. addx %g0, %g7, %o0
  446. /* We do these strange calculations for the csum_*_from_user case only, ie.
  447. * we only bother with faults on loads... */
  448. cc_fault:
  449. ret
  450. clr %o0