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

ppc: Add ByteReverse Function

Change-Id: I91ed4bf22231c6080b2c5e445ea407d076baeadc
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3175374Reviewed-by: 's avatarMilad Fa <mfarazma@redhat.com>
Commit-Queue: Junliang Yan <junyan@redhat.com>
Cr-Commit-Position: refs/heads/main@{#76994}
parent aa259e30
......@@ -3516,6 +3516,27 @@ void TurboAssembler::SwapSimd128(MemOperand src, MemOperand dst,
addi(sp, sp, Operand(2 * kSimd128Size));
}
void TurboAssembler::ByteReverseU16(Register dst, Register val) {
subi(sp, sp, Operand(kSystemPointerSize));
sth(val, MemOperand(sp));
lhbrx(dst, MemOperand(r0, sp));
addi(sp, sp, Operand(kSystemPointerSize));
}
void TurboAssembler::ByteReverseU32(Register dst, Register val) {
subi(sp, sp, Operand(kSystemPointerSize));
stw(val, MemOperand(sp));
lwbrx(dst, MemOperand(r0, sp));
addi(sp, sp, Operand(kSystemPointerSize));
}
void TurboAssembler::ByteReverseU64(Register dst, Register val) {
subi(sp, sp, Operand(kSystemPointerSize));
std(val, MemOperand(sp));
ldbrx(dst, MemOperand(r0, sp));
addi(sp, sp, Operand(kSystemPointerSize));
}
void TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) {
CmpS64(x, Operand(y), r0);
beq(dest);
......
......@@ -408,7 +408,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
template <class _type, class bin_op>
void AtomicOps(MemOperand dst, Register value, Register output,
Register scratch, bin_op op) {
Register result, bin_op op) {
Label binop;
lwsync();
bind(&binop);
......@@ -428,19 +428,19 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
default:
UNREACHABLE();
}
op(scratch, output, value);
op(result, output, value);
switch (sizeof(_type)) {
case 1:
stbcx(scratch, dst);
stbcx(result, dst);
break;
case 2:
sthcx(scratch, dst);
sthcx(result, dst);
break;
case 4:
stwcx(scratch, dst);
stwcx(result, dst);
break;
case 8:
stdcx(scratch, dst);
stdcx(result, dst);
break;
default:
UNREACHABLE();
......@@ -599,6 +599,10 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
Simd128Register scratch);
void SwapSimd128(MemOperand src, MemOperand dst, Simd128Register scratch);
void ByteReverseU16(Register dst, Register val);
void ByteReverseU32(Register dst, Register val);
void ByteReverseU64(Register dst, Register val);
// Before calling a C-function from generated code, align arguments on stack.
// After aligning the frame, non-register arguments must be stored in
// sp[0], sp[4], etc., not pushed. The argument count assumes all arguments
......
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