Commit 1de07aef authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC/s390: [wasm-simd] Implement i8x16.popcnt

Implementation for PPC will be added in a later CL.

Port dd90d107

Original Commit Message:

    Code sequence from https://github.com/WebAssembly/simd/pull/379, and
    exactly the same as x64, with minor tweaks for
    ExternalReferenceAsOperand.

R=zhin@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: I2be8a9cf04d0b327c15f47c2575877925238353c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2672706Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72510}
parent 357ba1ba
......@@ -2501,6 +2501,7 @@ void InstructionSelector::VisitI16x8ExtMulLowI8x16U(Node* node) {
void InstructionSelector::VisitI16x8ExtMulHighI8x16U(Node* node) {
UNIMPLEMENTED();
}
void InstructionSelector::VisitI8x16Popcnt(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::EmitPrepareResults(
ZoneVector<PushParameter>* results, const CallDescriptor* call_descriptor,
......
......@@ -4282,6 +4282,11 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
#undef SIGN_SELECT
case kS390_I8x16Popcnt: {
__ vpopct(i.OutputSimd128Register(), i.InputSimd128Register(0),
Condition(0), Condition(0), Condition(0));
break;
}
case kS390_StoreCompressTagged: {
CHECK(!instr->HasOutput());
size_t index = 0;
......
......@@ -378,6 +378,7 @@ namespace compiler {
V(S390_I8x16Shuffle) \
V(S390_I8x16Swizzle) \
V(S390_I8x16SignSelect) \
V(S390_I8x16Popcnt) \
V(S390_V64x2AllTrue) \
V(S390_V32x4AllTrue) \
V(S390_V16x8AllTrue) \
......
......@@ -325,6 +325,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kS390_I8x16Shuffle:
case kS390_I8x16Swizzle:
case kS390_I8x16SignSelect:
case kS390_I8x16Popcnt:
case kS390_V64x2AllTrue:
case kS390_V32x4AllTrue:
case kS390_V16x8AllTrue:
......
......@@ -2533,6 +2533,7 @@ void InstructionSelector::VisitWord64AtomicStore(Node* node) {
V(I16x8UConvertI8x16High) \
V(I8x16Neg) \
V(I8x16Abs) \
V(I8x16Popcnt) \
V(S128Not)
#define SIMD_SHIFT_LIST(V) \
......
......@@ -778,20 +778,21 @@ void Simulator::EvalTableInit() {
V(vuplh, VUPLH, 0xE7D5) /* type = VRR_A VECTOR UNPACK LOGICAL HIGH */ \
V(vupl, VUPL, 0xE7D6) /* type = VRR_A VECTOR UNPACK LOW */ \
V(vuph, VUPH, 0xE7D7) /* type = VRR_A VECTOR UNPACK HIGH */ \
V(vmnl, VMNL, 0xE7FC) /* type = VRR_C VECTOR MINIMUM LOGICAL */ \
V(vmxl, VMXL, 0xE7FD) /* type = VRR_C VECTOR MAXIMUM LOGICAL */ \
V(vmn, VMN, 0xE7FE) /* type = VRR_C VECTOR MINIMUM */ \
V(vmx, VMX, 0xE7FF) /* type = VRR_C VECTOR MAXIMUM */ \
V(vceq, VCEQ, 0xE7F8) /* type = VRR_B VECTOR COMPARE EQUAL */ \
V(vx, VX, 0xE76D) /* type = VRR_C VECTOR EXCLUSIVE OR */ \
V(vchl, VCHL, 0xE7F9) /* type = VRR_B VECTOR COMPARE HIGH LOGICAL */ \
V(vch, VCH, 0xE7FB) /* type = VRR_B VECTOR COMPARE HIGH */ \
V(vo, VO, 0xE76A) /* type = VRR_C VECTOR OR */ \
V(vn, VN, 0xE768) /* type = VRR_C VECTOR AND */ \
V(vno, VNO, 0xE768B) /* type = VRR_C VECTOR NOR */ \
V(vlc, VLC, 0xE7DE) /* type = VRR_A VECTOR LOAD COMPLEMENT */ \
V(vsel, VSEL, 0xE78D) /* type = VRR_E VECTOR SELECT */ \
V(vperm, VPERM, 0xE78C) /* type = VRR_E VECTOR PERMUTE */ \
V(vpopct, VPOPCT, 0xE750) /* type = VRR_A VECTOR POPULATION COUNT */ \
V(vmnl, VMNL, 0xE7FC) /* type = VRR_C VECTOR MINIMUM LOGICAL */ \
V(vmxl, VMXL, 0xE7FD) /* type = VRR_C VECTOR MAXIMUM LOGICAL */ \
V(vmn, VMN, 0xE7FE) /* type = VRR_C VECTOR MINIMUM */ \
V(vmx, VMX, 0xE7FF) /* type = VRR_C VECTOR MAXIMUM */ \
V(vceq, VCEQ, 0xE7F8) /* type = VRR_B VECTOR COMPARE EQUAL */ \
V(vx, VX, 0xE76D) /* type = VRR_C VECTOR EXCLUSIVE OR */ \
V(vchl, VCHL, 0xE7F9) /* type = VRR_B VECTOR COMPARE HIGH LOGICAL */ \
V(vch, VCH, 0xE7FB) /* type = VRR_B VECTOR COMPARE HIGH */ \
V(vo, VO, 0xE76A) /* type = VRR_C VECTOR OR */ \
V(vn, VN, 0xE768) /* type = VRR_C VECTOR AND */ \
V(vno, VNO, 0xE768B) /* type = VRR_C VECTOR NOR */ \
V(vlc, VLC, 0xE7DE) /* type = VRR_A VECTOR LOAD COMPLEMENT */ \
V(vsel, VSEL, 0xE78D) /* type = VRR_E VECTOR SELECT */ \
V(vperm, VPERM, 0xE78C) /* type = VRR_E VECTOR PERMUTE */ \
V(vbperm, VBPERM, 0xE785) /* type = VRR_C VECTOR BIT PERMUTE */ \
V(vtm, VTM, 0xE7D8) /* type = VRR_A VECTOR TEST UNDER MASK */ \
V(vesl, VESL, 0xE730) /* type = VRS_A VECTOR ELEMENT SHIFT LEFT */ \
......@@ -3461,6 +3462,33 @@ EVALUATE(VUPLH) {
}
#undef CASE
template <class S>
void VectorPopulationCount(Simulator* sim, int dst, int src) {
FOR_EACH_LANE(i, S) {
sim->set_simd_register_by_lane<S>(
dst, i,
base::bits::CountPopulation(sim->get_simd_register_by_lane<S>(src, i)));
}
}
#define CASE(i, S) \
case i: \
VectorPopulationCount<S>(this, r1, r2); \
break;
EVALUATE(VPOPCT) {
DCHECK_OPCODE(VPOPCT);
DECODE_VRR_A_INSTRUCTION(r1, r2, m5, m4, m3);
USE(m5);
USE(m4);
switch (m3) {
CASE(0, uint8_t);
default:
UNREACHABLE();
}
return length;
}
#undef CASE
template <class S, class D>
void VectorUnpackLow(Simulator* sim, int dst, int src) {
constexpr size_t kItemCount = kSimd128Size / sizeof(D);
......
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