blob: 6652b71a81a383bd3e8bc49f5f0efcf9a92146f3 [file] [log] [blame]
/*
* Signed 64-bit integer multiply.
*
* For JIT: op1 in r0/r1, op2 in r2/r3, return in r0/r1
*
* Consider WXxYZ (r1r0 x r3r2) with a long multiply:
* WX
* x YZ
* --------
* ZW ZX
* YW YX
*
* The low word of the result holds ZX, the high word holds
* (ZW+YX) + (the high overflow from ZX). YW doesn't matter because
* it doesn't fit in the low 64 bits.
*
* Unlike most ARM math operations, multiply instructions have
* restrictions on using the same register more than once (Rd and Rm
* cannot be the same).
*/
/* mul-long vAA, vBB, vCC */
mul ip, r2, r1 @ ip<- ZxW
umull r9, r10, r2, r0 @ r9/r10 <- ZxX
mla r2, r0, r3, ip @ r2<- YxX + (ZxW)
mov r0, r9
add r1, r2, r10 @ r1<- r10 + low(ZxW + (YxX))
bx lr