ppc: [liftoff] implement cond branch

Change-Id: I0277bd7de282449fde232777b0482cc52a2d0ef6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2844995
Reviewed-by: Milad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#74129}
This commit is contained in:
Junliang Yan 2021-04-22 17:47:46 -04:00 committed by Commit Bot
parent 73607264f8
commit e866b7ab51

View File

@ -45,6 +45,47 @@ inline MemOperand GetHalfStackSlot(int offset, RegPairHalf half) {
return MemOperand(fp, -kInstanceOffset - offset + half_offset);
}
inline constexpr Condition ToCondition(LiftoffCondition liftoff_cond) {
switch (liftoff_cond) {
case kEqual:
return eq;
case kUnequal:
return ne;
case kSignedLessThan:
case kUnsignedLessThan:
return lt;
case kSignedLessEqual:
case kUnsignedLessEqual:
return le;
case kSignedGreaterEqual:
case kUnsignedGreaterEqual:
return ge;
case kSignedGreaterThan:
case kUnsignedGreaterThan:
return gt;
}
}
inline constexpr bool UseSignedOp(LiftoffCondition liftoff_cond) {
switch (liftoff_cond) {
case kEqual:
case kUnequal:
case kSignedLessThan:
case kSignedLessEqual:
case kSignedGreaterThan:
case kSignedGreaterEqual:
return true;
case kUnsignedLessThan:
case kUnsignedLessEqual:
case kUnsignedGreaterThan:
case kUnsignedGreaterEqual:
return false;
default:
UNREACHABLE();
}
return false;
}
} // namespace liftoff
int LiftoffAssembler::PrepareStackFrame() {
@ -526,24 +567,56 @@ void LiftoffAssembler::emit_i64_signextend_i32(LiftoffRegister dst,
bailout(kUnsupportedArchitecture, "emit_i64_signextend_i32");
}
void LiftoffAssembler::emit_jump(Label* label) {
bailout(kUnsupportedArchitecture, "emit_jump");
}
void LiftoffAssembler::emit_jump(Label* label) { b(al, label); }
void LiftoffAssembler::emit_jump(Register target) {
bailout(kUnsupportedArchitecture, "emit_jump");
}
void LiftoffAssembler::emit_jump(Register target) { Jump(target); }
void LiftoffAssembler::emit_cond_jump(LiftoffCondition liftoff_cond,
Label* label, ValueKind kind,
Register lhs, Register rhs) {
bailout(kUnsupportedArchitecture, "emit_cond_jump");
Condition cond = liftoff::ToCondition(liftoff_cond);
bool use_signed = liftoff::UseSignedOp(liftoff_cond);
if (rhs != no_reg) {
switch (kind) {
case kI32:
if (use_signed) {
cmpw(lhs, rhs);
} else {
cmplw(lhs, rhs);
}
break;
case kRef:
case kOptRef:
case kRtt:
case kRttWithDepth:
DCHECK(liftoff_cond == kEqual || liftoff_cond == kUnequal);
V8_FALLTHROUGH;
case kI64:
if (use_signed) {
cmp(lhs, rhs);
} else {
cmpl(lhs, rhs);
}
break;
default:
UNREACHABLE();
}
} else {
DCHECK_EQ(kind, kI32);
CHECK(use_signed);
cmpwi(lhs, Operand::Zero());
}
b(cond, label);
}
void LiftoffAssembler::emit_i32_cond_jumpi(LiftoffCondition liftoff_cond,
Label* label, Register lhs,
int32_t imm) {
bailout(kUnsupportedArchitecture, "emit_i32_cond_jumpi");
Condition cond = liftoff::ToCondition(liftoff_cond);
Cmpwi(lhs, Operand(imm), r0);
b(cond, label);
}
void LiftoffAssembler::emit_i32_eqz(Register dst, Register src) {