1200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung%default {"preinstr":"", "result0":"a0", "result1":"a1", "chkzero":"0", "arg0":"a0", "arg1":"a1", "arg2":"a2", "arg3":"a3"} 2200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung /* 3200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * Generic 64-bit "/2addr" binary operation. Provide an "instr" line 4200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * that specifies an instruction that performs "result = a0-a1 op a2-a3". 5200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * This could be a MIPS instruction or a function call. (If the result 684603bf8535ba8390e0461b9d9c7917939e26312Alexey Frunze * comes back in a register pair other than a0-a1, you can override "result".) 7200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * 8200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * If "chkzero" is set to 1, we perform a divide-by-zero check on 984603bf8535ba8390e0461b9d9c7917939e26312Alexey Frunze * vB (a2-a3). Useful for integer division and modulus. 10200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * 11200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * For: add-long/2addr, sub-long/2addr, div-long/2addr, rem-long/2addr, 12200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung * and-long/2addr, or-long/2addr, xor-long/2addr 13200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung */ 14200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung /* binop/2addr vA, vB */ 15200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung GET_OPA4(rOBJ) # rOBJ <- A+ 16200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung GET_OPB(a1) # a1 <- B 17200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung EAS2(a1, rFP, a1) # a1 <- &fp[B] 18200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung EAS2(t0, rFP, rOBJ) # t0 <- &fp[A] 1984603bf8535ba8390e0461b9d9c7917939e26312Alexey Frunze LOAD64($arg2, $arg3, a1) # a2/a3 <- vB/vB+1 2084603bf8535ba8390e0461b9d9c7917939e26312Alexey Frunze LOAD64($arg0, $arg1, t0) # a0/a1 <- vA/vA+1 21200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung .if $chkzero 22200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung or t0, $arg2, $arg3 # second arg (a2-a3) is zero? 23200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung beqz t0, common_errDivideByZero 24200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung .endif 25200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung FETCH_ADVANCE_INST(1) # advance rPC, load rINST 26200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung 27200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung $preinstr # optional op 28200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung $instr # result <- op, a0-a3 changed 29200f040af3e4fe9e178cb63c90860d58d90ef665Douglas Leung GET_INST_OPCODE(t0) # extract opcode from rINST 3084603bf8535ba8390e0461b9d9c7917939e26312Alexey Frunze SET_VREG64_GOTO($result0, $result1, rOBJ, t0) # vA/vA+1 <- $result0/$result1 31