Commit 2c055469 authored by Junliang Yan's avatar Junliang Yan Committed by Commit Bot

s390x: Add CountTrailingZerosU32/U64 to TFAssem

Change-Id: Idf653061a88beb348fa13e907932ca68f2d6d05b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2685366Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72636}
parent 518ee01d
...@@ -4712,6 +4712,47 @@ void TurboAssembler::CountLeadingZerosU64(Register dst, Register src, ...@@ -4712,6 +4712,47 @@ void TurboAssembler::CountLeadingZerosU64(Register dst, Register src,
mov(dst, scratch_pair); mov(dst, scratch_pair);
} }
void TurboAssembler::CountTrailingZerosU32(Register dst, Register src,
Register scratch_pair) {
Register scratch0 = scratch_pair;
Register scratch1 = Register::from_code(scratch_pair.code() + 1);
DCHECK(!AreAliased(dst, scratch0, scratch1));
DCHECK(!AreAliased(src, scratch0, scratch1));
Label done;
// Check if src is all zeros.
ltr(scratch1, src);
mov(dst, Operand(32));
beq(&done);
llgfr(scratch1, scratch1);
lcgr(scratch0, scratch1);
ngr(scratch1, scratch0);
flogr(scratch0, scratch1);
mov(dst, Operand(63));
SubS64(dst, scratch0);
bind(&done);
}
void TurboAssembler::CountTrailingZerosU64(Register dst, Register src,
Register scratch_pair) {
Register scratch0 = scratch_pair;
Register scratch1 = Register::from_code(scratch_pair.code() + 1);
DCHECK(!AreAliased(dst, scratch0, scratch1));
DCHECK(!AreAliased(src, scratch0, scratch1));
Label done;
// Check if src is all zeros.
ltgr(scratch1, src);
mov(dst, Operand(64));
beq(&done);
lcgr(scratch0, scratch1);
ngr(scratch0, scratch1);
flogr(scratch0, scratch0);
mov(dst, Operand(63));
SubS64(dst, scratch0);
bind(&done);
}
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
...@@ -495,9 +495,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -495,9 +495,6 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Popcnt64(Register dst, Register src); void Popcnt64(Register dst, Register src);
#endif #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, const Operand& src);
void mov(Register dst, Register src); void mov(Register dst, Register src);
...@@ -1030,6 +1027,16 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -1030,6 +1027,16 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void DecompressAnyTagged(Register destination, MemOperand field_operand); void DecompressAnyTagged(Register destination, MemOperand field_operand);
void DecompressAnyTagged(Register destination, Register source); void DecompressAnyTagged(Register destination, Register source);
// CountLeadingZeros will corrupt the scratch register pair (eg. r0:r1)
void CountLeadingZerosU32(Register dst, Register src,
Register scratch_pair = r0);
void CountLeadingZerosU64(Register dst, Register src,
Register scratch_pair = r0);
void CountTrailingZerosU32(Register dst, Register src,
Register scratch_pair = r0);
void CountTrailingZerosU64(Register dst, Register src,
Register scratch_pair = r0);
private: private:
static const int kSmiShift = kSmiTagSize + kSmiShiftSize; static const int kSmiShift = kSmiTagSize + kSmiShiftSize;
......
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