hash_arm.s 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. #include "textflag.h"
  2. #define R10 g
  3. #define ROUND()\
  4. ADD.S R2,R0,R0;\
  5. ADC R3,R1,R1;\
  6. EOR R2<<13,R0,R8;\
  7. EOR R3>>19,R8,R8;\
  8. EOR R2>>19,R1,R11;\
  9. EOR R3<<13,R11,R11;\
  10. ADD.S R6,R4,R4;\
  11. ADC R7,R5,R5;\
  12. EOR R6<<16,R4,R2;\
  13. EOR R7>>16,R2,R2;\
  14. EOR R6>>16,R5,R3;\
  15. EOR R7<<16,R3,R3;\
  16. ADD.S R2,R1,R1;\
  17. ADC R3,R0,R0;\
  18. EOR R2<<21,R1,R6;\
  19. EOR R3>>11,R6,R6;\
  20. EOR R2>>11,R0,R7;\
  21. EOR R3<<21,R7,R7;\
  22. ADD.S R8,R4,R4;\
  23. ADC R11,R5,R5;\
  24. EOR R8<<17,R4,R2;\
  25. EOR R11>>15,R2,R2;\
  26. EOR R8>>15,R5,R3;\
  27. EOR R11<<17,R3,R3;\
  28. ADD.S R2,R1,R1;\
  29. ADC R3,R0,R0;\
  30. EOR R2<<13,R1,R8;\
  31. EOR R3>>19,R8,R8;\
  32. EOR R2>>19,R0,R11;\
  33. EOR R3<<13,R11,R11;\
  34. ADD.S R6,R5,R5;\
  35. ADC R7,R4,R4;\
  36. EOR R6<<16,R5,R2;\
  37. EOR R7>>16,R2,R2;\
  38. EOR R6>>16,R4,R3;\
  39. EOR R7<<16,R3,R3;\
  40. ADD.S R2,R0,R0;\
  41. ADC R3,R1,R1;\
  42. EOR R2<<21,R0,R6;\
  43. EOR R3>>11,R6,R6;\
  44. EOR R2>>11,R1,R7;\
  45. EOR R3<<21,R7,R7;\
  46. ADD.S R8,R5,R5;\
  47. ADC R11,R4,R4;\
  48. EOR R8<<17,R5,R2;\
  49. EOR R11>>15,R2,R2;\
  50. EOR R8>>15,R4,R3;\
  51. EOR R11<<17,R3,R3;\
  52. // Hash(k0, k1 uint64, b []byte) uint64
  53. TEXT ·Hash(SB),NOSPLIT,$8-36
  54. MOVW R10,sav-8(SP)
  55. MOVW k0_lo+0(FP),R12
  56. MOVW k0_hi+4(FP),R14
  57. MOVW $0x70736575,R0
  58. MOVW $0x736f6d65,R1
  59. MOVW $0x6e657261,R4
  60. MOVW $0x6c796765,R5
  61. EOR R12,R0,R0
  62. EOR R14,R1,R1
  63. EOR R12,R4,R4
  64. EOR R14,R5,R5
  65. MOVW k1_lo+8(FP),R12
  66. MOVW k1_hi+12(FP),R14
  67. MOVW $0x6e646f6d,R2
  68. MOVW $0x646f7261,R3
  69. MOVW $0x79746573,R6
  70. MOVW $0x74656462,R7
  71. EOR R12,R2,R2
  72. EOR R14,R3,R3
  73. EOR R12,R6,R6
  74. EOR R14,R7,R7
  75. MOVW b+16(FP),R10
  76. MOVW b_len+20(FP),R11
  77. ADD R10,R11,R11
  78. MOVW R11,endb-4(SP)
  79. AND.S $3,R10,R8
  80. BNE hashloopunaligned
  81. hashloop:
  82. MOVW endb-4(SP),R11
  83. SUB R10,R11,R11
  84. SUB.S $8,R11
  85. BLO hashend
  86. MOVM.IA.W (R10),[R12,R14]
  87. EOR R12,R6,R6
  88. EOR R14,R7,R7
  89. ROUND()
  90. EOR R12,R0,R0
  91. EOR R14,R1,R1
  92. B hashloop
  93. hashloopunaligned:
  94. MOVW endb-4(SP),R11
  95. SUB R10,R11,R11
  96. SUB.S $8,R11
  97. BLO hashend
  98. MOVB (R10),R12
  99. MOVB 1(R10),R11
  100. ORR R11<<8,R12,R12
  101. MOVB 2(R10),R11
  102. ORR R11<<16,R12,R12
  103. MOVB 3(R10),R11
  104. ORR R11<<24,R12,R12
  105. MOVB 4(R10),R14
  106. MOVB 5(R10),R11
  107. ORR R11<<8,R14,R14
  108. MOVB 6(R10),R11
  109. ORR R11<<16,R14,R14
  110. MOVB 7(R10),R11
  111. ORR R11<<24,R14,R14
  112. ADD $8,R10,R10
  113. EOR R12,R6,R6
  114. EOR R14,R7,R7
  115. ROUND()
  116. EOR R12,R0,R0
  117. EOR R14,R1,R1
  118. B hashloopunaligned
  119. hashend:
  120. MOVW $0x0,R12
  121. MOVW $0x0,R14
  122. RSB $0,R11,R11
  123. AND.S $7,R11
  124. BEQ hashlast
  125. MOVW (R10),R12
  126. SLL $3,R11
  127. AND $63,R11
  128. SUB.S $32,R11,R11
  129. BEQ hashlast
  130. BLO hashhi
  131. MOVW R12<<R11,R12
  132. MOVW R12>>R11,R12
  133. B hashlast
  134. hashhi:
  135. ADD $32,R11
  136. MOVW 4(R10),R14
  137. MOVW R14<<R11,R14
  138. MOVW R14>>R11,R14
  139. hashlast:
  140. MOVW b_len+20(FP),R11
  141. ORR R11<<24,R14,R14
  142. EOR R12,R6,R6
  143. EOR R14,R7,R7
  144. ROUND()
  145. EOR R12,R0,R0
  146. EOR R14,R1,R1
  147. EOR $255,R4
  148. ROUND()
  149. ROUND()
  150. EOR R2,R0,R0
  151. EOR R3,R1,R1
  152. EOR R6,R4,R4
  153. EOR R7,R5,R5
  154. EOR R4,R0,R0
  155. EOR R5,R1,R1
  156. MOVW sav-8(SP),R10
  157. MOVW R0,ret_lo+28(FP)
  158. MOVW R1,ret_hi+32(FP)
  159. RET