copy_page.S 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. *
  3. * Optimized version of the standard copy_page() function
  4. *
  5. * Inputs:
  6. * in0: address of target page
  7. * in1: address of source page
  8. * Output:
  9. * no return value
  10. *
  11. * Copyright (C) 1999, 2001 Hewlett-Packard Co
  12. * Stephane Eranian <eranian@hpl.hp.com>
  13. * David Mosberger <davidm@hpl.hp.com>
  14. *
  15. * 4/06/01 davidm Tuned to make it perform well both for cached and uncached copies.
  16. */
  17. #include <asm/asmmacro.h>
  18. #include <asm/page.h>
  19. #define PIPE_DEPTH 3
  20. #define EPI p[PIPE_DEPTH-1]
  21. #define lcount r16
  22. #define saved_pr r17
  23. #define saved_lc r18
  24. #define saved_pfs r19
  25. #define src1 r20
  26. #define src2 r21
  27. #define tgt1 r22
  28. #define tgt2 r23
  29. #define srcf r24
  30. #define tgtf r25
  31. #define tgt_last r26
  32. #define Nrot ((8*PIPE_DEPTH+7)&~7)
  33. GLOBAL_ENTRY(copy_page)
  34. .prologue
  35. .save ar.pfs, saved_pfs
  36. alloc saved_pfs=ar.pfs,3,Nrot-3,0,Nrot
  37. .rotr t1[PIPE_DEPTH], t2[PIPE_DEPTH], t3[PIPE_DEPTH], t4[PIPE_DEPTH], \
  38. t5[PIPE_DEPTH], t6[PIPE_DEPTH], t7[PIPE_DEPTH], t8[PIPE_DEPTH]
  39. .rotp p[PIPE_DEPTH]
  40. .save ar.lc, saved_lc
  41. mov saved_lc=ar.lc
  42. mov ar.ec=PIPE_DEPTH
  43. mov lcount=PAGE_SIZE/64-1
  44. .save pr, saved_pr
  45. mov saved_pr=pr
  46. mov pr.rot=1<<16
  47. .body
  48. mov src1=in1
  49. adds src2=8,in1
  50. mov tgt_last = PAGE_SIZE
  51. ;;
  52. adds tgt2=8,in0
  53. add srcf=512,in1
  54. mov ar.lc=lcount
  55. mov tgt1=in0
  56. add tgtf=512,in0
  57. add tgt_last = tgt_last, in0
  58. ;;
  59. 1:
  60. (p[0]) ld8 t1[0]=[src1],16
  61. (EPI) st8 [tgt1]=t1[PIPE_DEPTH-1],16
  62. (p[0]) ld8 t2[0]=[src2],16
  63. (EPI) st8 [tgt2]=t2[PIPE_DEPTH-1],16
  64. cmp.ltu p6,p0 = tgtf, tgt_last
  65. ;;
  66. (p[0]) ld8 t3[0]=[src1],16
  67. (EPI) st8 [tgt1]=t3[PIPE_DEPTH-1],16
  68. (p[0]) ld8 t4[0]=[src2],16
  69. (EPI) st8 [tgt2]=t4[PIPE_DEPTH-1],16
  70. ;;
  71. (p[0]) ld8 t5[0]=[src1],16
  72. (EPI) st8 [tgt1]=t5[PIPE_DEPTH-1],16
  73. (p[0]) ld8 t6[0]=[src2],16
  74. (EPI) st8 [tgt2]=t6[PIPE_DEPTH-1],16
  75. ;;
  76. (p[0]) ld8 t7[0]=[src1],16
  77. (EPI) st8 [tgt1]=t7[PIPE_DEPTH-1],16
  78. (p[0]) ld8 t8[0]=[src2],16
  79. (EPI) st8 [tgt2]=t8[PIPE_DEPTH-1],16
  80. (p6) lfetch [srcf], 64
  81. (p6) lfetch [tgtf], 64
  82. br.ctop.sptk.few 1b
  83. ;;
  84. mov pr=saved_pr,0xffffffffffff0000 // restore predicates
  85. mov ar.pfs=saved_pfs
  86. mov ar.lc=saved_lc
  87. br.ret.sptk.many rp
  88. END(copy_page)