Commit 2071cfd7 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

s390x: refactor CountLeadingZeros

Change-Id: Ic973b6342a6b91fe9068ee1ffe4e83a138fb2fa4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2679269Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72564}
parent c6183298
......@@ -4697,6 +4697,21 @@ void TurboAssembler::CallForDeoptimization(Builtins::Name target, int,
void TurboAssembler::Trap() { stop(); }
void TurboAssembler::DebugBreak() { stop(); }
void TurboAssembler::CountLeadingZerosU32(Register dst, Register src,
Register scratch_pair) {
llgfr(dst, src);
flogr(scratch_pair,
dst); // will modify a register pair scratch and scratch + 1
AddS32(dst, scratch_pair, Operand(-32));
}
void TurboAssembler::CountLeadingZerosU64(Register dst, Register src,
Register scratch_pair) {
flogr(scratch_pair,
src); // will modify a register pair scratch and scratch + 1
mov(dst, scratch_pair);
}
} // namespace internal
} // namespace v8
......
......@@ -495,6 +495,9 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Popcnt64(Register dst, Register src);
#endif
// CountLeadingZeros will corrupt the scratch register pair (eg. r0:r1)
void CountLeadingZerosU32(Register dst, Register src, Register scratch_pair);
void CountLeadingZerosU64(Register dst, Register src, Register scratch_pair);
void mov(Register dst, const Operand& src);
void mov(Register dst, Register src);
......
......@@ -1891,16 +1891,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
ASSEMBLE_UNARY_OP(D_DInstr(lcdbr), nullInstr, nullInstr);
break;
case kS390_Cntlz32: {
__ llgfr(i.OutputRegister(), i.InputRegister(0));
__ flogr(r0, i.OutputRegister());
__ AddS32(i.OutputRegister(), r0, Operand(-32));
// No need to zero-ext b/c llgfr is done already
__ CountLeadingZerosU32(i.OutputRegister(), i.InputRegister(0), r0);
break;
}
#if V8_TARGET_ARCH_S390X
case kS390_Cntlz64: {
__ flogr(r0, i.InputRegister(0));
__ mov(i.OutputRegister(), r0);
__ CountLeadingZerosU64(i.OutputRegister(), i.InputRegister(0), r0);
break;
}
#endif
......
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