Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

172 lines
4.1 KiB

  1. // string.s: function to concatenate 2 strings
  2. // Copyright (c) 2000, Intel Corporation
  3. // All rights reserved.
  4. //
  5. // WARRANTY DISCLAIMER
  6. //
  7. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  8. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  9. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  10. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR ITS
  11. // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  12. // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  13. // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  14. // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  15. // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR TORT (INCLUDING
  16. // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  18. //
  19. // Intel Corporation is the author of this code, and requests that all
  20. // problem reports or change requests be submitted to it directly at
  21. // http://developer.intel.com/opensource.
  22. //
  23. .file "string.s"
  24. .section .text
  25. // -- Begin strcat
  26. .proc strcat#
  27. .global strcat#
  28. .align 32
  29. strcat:
  30. { .mib
  31. alloc r14=ar.pfs,2,6,0,8 //8 rotating registers, 7 locals
  32. mov r11=pr //Save predicate register file
  33. brp.loop.imp .bs1len, .bws1 // Put loop backedge target in TAR
  34. }
  35. // Setup for doing software pipelined loops
  36. { .mib
  37. mov r9=r33
  38. mov pr.rot=0x30000 // p16=p17=1
  39. nop.b 0
  40. };;
  41. { .mib
  42. mov r14=r32
  43. mov ar.ec=0
  44. nop.b 0
  45. } { .mib // Extra bundle to align bs1len.
  46. mov r8=r32
  47. nop.i 0
  48. brp.loop.imp .bcat, .bwcat ;; // Put loop backedge target in TAR
  49. }
  50. .bs1len:
  51. { .mii
  52. ld1.s r37=[r14],1 // *s (r37,r38,r39)
  53. nop.i 0
  54. (p19) chk.s r39,.natfault1_0 //
  55. }
  56. .bws1:
  57. { .mfb
  58. (p19) cmp4.ne p17,p0=r39,r0 // *s==0 (p16,p17,p18)
  59. nop.f 0
  60. (p17) br.wtop.dptk .bs1len ;; //
  61. }
  62. //
  63. // Now concatenate s2 into the end of s1
  64. //
  65. { .mib
  66. add r14=-3,r14 // Since ld1.s is 2 stages ahead
  67. dep r15=1,r0,32,32 // rb = 0xffffffff00000000
  68. clrrrb ;;
  69. } { .mii
  70. // Setup for doing software pipelined loops
  71. or r32=r14,r9
  72. mov pr.rot=0x30000 ;; // p16=p17=1
  73. and r32=3,r32 ;;
  74. } { .mib
  75. cmp4.ne p10,p0=r32,r0
  76. mov ar.ec=0
  77. (p10) br.spnt .b_notaligned ;;
  78. }
  79. .bcat:
  80. { .mii
  81. ld4.s r32=[r9],4 // *s1 (r32,r33,r34)
  82. (p18) chk.s r33,.natfault2_0 //
  83. (p18) pcmp1.eq r16=r33,r15 ;; // r16 !=0 only if a zero byte is found
  84. }
  85. .bwcat:
  86. { .mib
  87. (p19) st4 [r14]=r34,4 // *s2=*s1
  88. (p18) cmp4.eq p17,p0=r16,r0 // zero byte found?
  89. (p17) br.wtop.dptk .bcat ;; //
  90. }
  91. { .mfi
  92. nop.m 0
  93. nop.f 0
  94. czx1.r r16 = r33
  95. } ;;
  96. { .mfi
  97. cmp.leu p2, p0 = 2, r16
  98. nop.f 0
  99. shr.u r35 = r33, 8
  100. }
  101. { .mfi
  102. cmp.eq p4, p0 = 3, r16
  103. nop.f 0
  104. cmp.ne p5, p0 = r0, r16
  105. } ;;
  106. { .mfi
  107. (p5)st1 [r14] = r33, 1
  108. nop.f 0
  109. shr.u r36 = r33, 16
  110. };;
  111. { .mfi
  112. (p2)st1 [r14] = r35,1
  113. nop.f 0
  114. nop.i 0
  115. } ;;
  116. { .mfi
  117. (p4)st1 [r14] = r36,1
  118. nop.f 0
  119. nop.i 0
  120. };;
  121. { .mib
  122. (p0) st1 [r14] = r0
  123. nop.i 0
  124. clrrrb
  125. } ;;
  126. { .mib
  127. nop.m 0
  128. mov pr=r11,0x1003e
  129. br.ret.sptk.many b0 ;;
  130. }
  131. .b_notaligned:
  132. { .mmi
  133. ld1 r32=[r9],1 ;; // 2 cycle load causes 1 cycle stall
  134. st1 [r14]=r32,1 // 3 cycles between st1 to avoid flush
  135. cmp4.ne.unc p7,p0=r32,r0 ;; // Extra stop bit to force 3 cycles
  136. } { .mib
  137. nop.m 0
  138. nop.i 0
  139. (p7) br.cond.dptk .b_notaligned ;;
  140. } { .mib
  141. nop.m 0
  142. mov pr=r11,0x1003e
  143. br.ret.sptk.many b0 ;;
  144. }
  145. .natfault1_0:
  146. { .mmi
  147. add r39=-3,r14 ;;
  148. ld1 r39=[r39] // Redo the load
  149. nop.i 0
  150. } { .mib
  151. nop.m 0
  152. nop.i 0
  153. br.sptk .bws1 ;;
  154. }
  155. .natfault2_0:
  156. { .mmi
  157. add r33=-8,r9 ;;
  158. ld4 r33=[r33] // *s1 (r32,r33,r34)
  159. nop.i 0;;
  160. } { .mib
  161. nop.m 0
  162. (p18) pcmp1.eq r16=r33,r15 // r16 !=0 only if a zero byte is found
  163. br.sptk .bwcat ;;
  164. }
  165. _2_1_2auto_size == 0x0
  166. // -- End strcat
  167. .endp strcat#
  168. // mark_proc_addr_taken strcat;
  169. // End