Commit 4da2a843 authored by Junliang Yan's avatar Junliang Yan Committed by V8 LUCI CQ

ppc: [liftoff] implement 32-bit divide for liftoff

Change-Id: I5bab2fec2fc2b7256580982e6433f98f93b2c2f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3088186Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#76238}
parent aa04a967
......@@ -2759,6 +2759,27 @@ void TurboAssembler::MulS32(Register dst, Register src, Register value, OEBit s,
extsw(dst, dst, r);
}
void TurboAssembler::DivS64(Register dst, Register src, Register value, OEBit s,
RCBit r) {
divd(dst, src, value, s, r);
}
void TurboAssembler::DivU64(Register dst, Register src, Register value, OEBit s,
RCBit r) {
divdu(dst, src, value, s, r);
}
void TurboAssembler::DivS32(Register dst, Register src, Register value, OEBit s,
RCBit r) {
divw(dst, src, value, s, r);
extsw(dst, dst);
}
void TurboAssembler::DivU32(Register dst, Register src, Register value, OEBit s,
RCBit r) {
divwu(dst, src, value, s, r);
ZeroExtWord32(dst, dst);
}
void TurboAssembler::AndU64(Register dst, Register src, const Operand& value,
Register scratch, RCBit r) {
if (is_uint16(value.immediate()) && r == SetRC) {
......
......@@ -201,6 +201,14 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
Register scratch = r0, OEBit s = LeaveOE, RCBit r = LeaveRC);
void MulS32(Register dst, Register src, Register value, OEBit s = LeaveOE,
RCBit r = LeaveRC);
void DivS64(Register dst, Register src, Register value, OEBit s = LeaveOE,
RCBit r = LeaveRC);
void DivU64(Register dst, Register src, Register value, OEBit s = LeaveOE,
RCBit r = LeaveRC);
void DivS32(Register dst, Register src, Register value, OEBit s = LeaveOE,
RCBit r = LeaveRC);
void DivU32(Register dst, Register src, Register value, OEBit s = LeaveOE,
RCBit r = LeaveRC);
void AndU64(Register dst, Register src, const Operand& value,
Register scratch = r0, RCBit r = SetRC);
......
......@@ -924,12 +924,27 @@ BINOP_LIST(EMIT_BINOP_FUNCTION)
void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs,
Label* trap_div_by_zero,
Label* trap_div_unrepresentable) {
bailout(kUnsupportedArchitecture, "i32_divs");
Label cont;
// Check for division by zero.
CmpS32(rhs, Operand::Zero(), r0);
b(eq, trap_div_by_zero);
// Check for kMinInt / -1. This is unrepresentable.
CmpS32(rhs, Operand(-1), r0);
bne(&cont);
CmpS32(lhs, Operand(kMinInt), r0);
b(eq, trap_div_unrepresentable);
bind(&cont);
DivS32(dst, lhs, rhs);
}
void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs,
Label* trap_div_by_zero) {
bailout(kUnsupportedArchitecture, "i32_divu");
CmpS32(rhs, Operand::Zero(), r0);
beq(trap_div_by_zero);
DivU32(dst, lhs, rhs);
}
void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs,
......
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