blob: f96fdb23f07b60da064feb66f220fd89c3e3e3db [file] [log] [blame]
Douglas Leung200f0402016-02-25 20:05:47 -08001%default {"preinstr":"", "result0":"a0", "result1":"a1", "chkzero":"0", "arg0":"a0", "arg1":"a1", "arg2":"a2", "arg3":"a3"}
2 /*
3 * Generic 64-bit "/2addr" binary operation. Provide an "instr" line
4 * that specifies an instruction that performs "result = a0-a1 op a2-a3".
5 * This could be a MIPS instruction or a function call. (If the result
Alexey Frunze84603bf2016-10-21 19:54:43 -07006 * comes back in a register pair other than a0-a1, you can override "result".)
Douglas Leung200f0402016-02-25 20:05:47 -08007 *
8 * If "chkzero" is set to 1, we perform a divide-by-zero check on
Alexey Frunze84603bf2016-10-21 19:54:43 -07009 * vB (a2-a3). Useful for integer division and modulus.
Douglas Leung200f0402016-02-25 20:05:47 -080010 *
11 * For: add-long/2addr, sub-long/2addr, div-long/2addr, rem-long/2addr,
12 * and-long/2addr, or-long/2addr, xor-long/2addr
Douglas Leung200f0402016-02-25 20:05:47 -080013 */
14 /* binop/2addr vA, vB */
15 GET_OPA4(rOBJ) # rOBJ <- A+
16 GET_OPB(a1) # a1 <- B
17 EAS2(a1, rFP, a1) # a1 <- &fp[B]
18 EAS2(t0, rFP, rOBJ) # t0 <- &fp[A]
Alexey Frunze84603bf2016-10-21 19:54:43 -070019 LOAD64($arg2, $arg3, a1) # a2/a3 <- vB/vB+1
20 LOAD64($arg0, $arg1, t0) # a0/a1 <- vA/vA+1
Douglas Leung200f0402016-02-25 20:05:47 -080021 .if $chkzero
22 or t0, $arg2, $arg3 # second arg (a2-a3) is zero?
23 beqz t0, common_errDivideByZero
24 .endif
25 FETCH_ADVANCE_INST(1) # advance rPC, load rINST
26
27 $preinstr # optional op
28 $instr # result <- op, a0-a3 changed
29 GET_INST_OPCODE(t0) # extract opcode from rINST
Alexey Frunze84603bf2016-10-21 19:54:43 -070030 SET_VREG64_GOTO($result0, $result1, rOBJ, t0) # vA/vA+1 <- $result0/$result1