fix android clang does not support =d constraint

This commit is contained in:
kbkpbot 2025-08-08 15:37:01 +08:00
parent 029e1f885e
commit 53dbb562c9

View file

@ -14,18 +14,16 @@ fn C._udiv128(hi u64, lo u64, y u64, rem &u64) u64
// This function's execution time does not depend on the inputs.
@[inline]
pub fn mul_64(x u64, y u64) (u64, u64) {
mut hi := u64(0)
mut lo := u64(0)
mut hi := y
mut lo := x
$if msvc {
lo = C._umul128(x, y, &hi)
} $else {
asm amd64 {
mulq rdx
; =d (hi)
=a (lo)
; a (x)
d (y)
; cc
; +a (lo)
+d (hi)
; ; cc
}
}
return hi, lo
@ -36,8 +34,8 @@ pub fn mul_64(x u64, y u64) (u64, u64) {
// half returned in lo.
@[inline]
pub fn mul_add_64(x u64, y u64, z u64) (u64, u64) {
mut hi := u64(0)
mut lo := u64(0)
mut hi := y
mut lo := x
$if msvc {
lo = C._umul128(x, y, &hi)
carry := C._addcarry_u64(0, lo, z, &lo)
@ -47,11 +45,9 @@ pub fn mul_add_64(x u64, y u64, z u64) (u64, u64) {
mulq rdx
addq rax, z
adcq rdx, 0
; =d (hi)
=a (lo)
; a (x)
d (y)
r (z)
; +a (lo)
+d (hi)
; r (z)
; cc
}
}
@ -72,18 +68,16 @@ pub fn div_64(hi u64, lo u64, y1 u64) (u64, u64) {
panic(overflow_error)
}
mut quo := u64(0)
mut rem := u64(0)
mut quo := lo
mut rem := hi
$if msvc {
quo = C._udiv128(hi, lo, y, &rem)
} $else {
asm amd64 {
div y
; =a (quo)
=d (rem)
; d (hi)
a (lo)
r (y)
; +a (quo)
+d (rem)
; r (y)
; cc
}
}