Commit 339dde1c authored by Junliang Yan's avatar Junliang Yan Committed by V8 LUCI CQ

ppc: [liftoff] implement 64-bit div and mod

Change-Id: Ib0a630d0fb5e07e3cec77ce418827f746e64a656
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3088548Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#76242}
parent 8a92e2b0
......@@ -982,28 +982,68 @@ bool LiftoffAssembler::emit_i64_divs(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs,
Label* trap_div_by_zero,
Label* trap_div_unrepresentable) {
bailout(kUnsupportedArchitecture, "i64_divs");
constexpr int64_t kMinInt64 = static_cast<int64_t>(1) << 63;
Label cont;
// Check for division by zero.
CmpS64(rhs.gp(), Operand::Zero(), r0);
beq(trap_div_by_zero);
// Check for kMinInt / -1. This is unrepresentable.
CmpS64(rhs.gp(), Operand(-1), r0);
bne(&cont);
CmpS64(lhs.gp(), Operand(kMinInt64), r0);
beq(trap_div_unrepresentable);
bind(&cont);
DivS64(dst.gp(), lhs.gp(), rhs.gp());
return true;
}
bool LiftoffAssembler::emit_i64_divu(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs,
Label* trap_div_by_zero) {
bailout(kUnsupportedArchitecture, "i64_divu");
CmpS64(rhs.gp(), Operand::Zero(), r0);
beq(trap_div_by_zero);
// Do div.
DivU64(dst.gp(), lhs.gp(), rhs.gp());
return true;
}
bool LiftoffAssembler::emit_i64_rems(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs,
Label* trap_div_by_zero) {
bailout(kUnsupportedArchitecture, "i64_rems");
constexpr int64_t kMinInt64 = static_cast<int64_t>(1) << 63;
Label trap_div_unrepresentable;
Label done;
Label cont;
// Check for division by zero.
CmpS64(rhs.gp(), Operand::Zero(), r0);
beq(trap_div_by_zero);
// Check for kMinInt / -1. This is unrepresentable.
CmpS64(rhs.gp(), Operand(-1), r0);
bne(&cont);
CmpS64(lhs.gp(), Operand(kMinInt64), r0);
beq(&trap_div_unrepresentable);
bind(&cont);
ModS64(dst.gp(), lhs.gp(), rhs.gp());
bne(&done);
bind(&trap_div_unrepresentable);
mov(dst.gp(), Operand(0));
bind(&done);
return true;
}
bool LiftoffAssembler::emit_i64_remu(LiftoffRegister dst, LiftoffRegister lhs,
LiftoffRegister rhs,
Label* trap_div_by_zero) {
bailout(kUnsupportedArchitecture, "i64_remu");
CmpS64(rhs.gp(), Operand::Zero(), r0);
beq(trap_div_by_zero);
ModU64(dst.gp(), lhs.gp(), rhs.gp());
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment