fe_arm64.s 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2020 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. //go:build arm64 && gc && !purego
  5. #include "textflag.h"
  6. // carryPropagate works exactly like carryPropagateGeneric and uses the
  7. // same AND, ADD, and LSR+MADD instructions emitted by the compiler, but
  8. // avoids loading R0-R4 twice and uses LDP and STP.
  9. //
  10. // See https://golang.org/issues/43145 for the main compiler issue.
  11. //
  12. // func carryPropagate(v *Element)
  13. TEXT ·carryPropagate(SB),NOFRAME|NOSPLIT,$0-8
  14. MOVD v+0(FP), R20
  15. LDP 0(R20), (R0, R1)
  16. LDP 16(R20), (R2, R3)
  17. MOVD 32(R20), R4
  18. AND $0x7ffffffffffff, R0, R10
  19. AND $0x7ffffffffffff, R1, R11
  20. AND $0x7ffffffffffff, R2, R12
  21. AND $0x7ffffffffffff, R3, R13
  22. AND $0x7ffffffffffff, R4, R14
  23. ADD R0>>51, R11, R11
  24. ADD R1>>51, R12, R12
  25. ADD R2>>51, R13, R13
  26. ADD R3>>51, R14, R14
  27. // R4>>51 * 19 + R10 -> R10
  28. LSR $51, R4, R21
  29. MOVD $19, R22
  30. MADD R22, R10, R21, R10
  31. STP (R10, R11), 0(R20)
  32. STP (R12, R13), 16(R20)
  33. MOVD R14, 32(R20)
  34. RET