Commit c9023c2c authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

s390: [wasm-simd] Implement simd shuffle

Change-Id: I3da840cdabf6d0ed8c4d823855acb999a0167167
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2073206Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#66467}
parent a8c8e87d
......@@ -3689,6 +3689,21 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
#undef BINOP_EXTRACT
case kS390_S8x16Shuffle: {
Simd128Register dst = i.OutputSimd128Register(),
src0 = i.InputSimd128Register(0),
src1 = i.InputSimd128Register(1);
int32_t k8x16_indices[] = {i.InputInt32(2), i.InputInt32(3),
i.InputInt32(4), i.InputInt32(5)};
// create 2 * 8 byte inputs indicating new indices
for (int i = 0, j = 0; i < 2; i++, j = +2) {
__ lgfi(i < 1 ? ip : r0, Operand(k8x16_indices[j + 1]));
__ aih(i < 1 ? ip : r0, Operand(k8x16_indices[j]));
}
__ vlvgp(kScratchDoubleReg, ip, r0);
__ vperm(dst, src0, src1, kScratchDoubleReg, Condition(0), Condition(0));
break;
}
default:
UNREACHABLE();
}
......
......@@ -300,6 +300,7 @@ namespace compiler {
V(S390_I8x16SubSaturateS) \
V(S390_I8x16AddSaturateU) \
V(S390_I8x16SubSaturateU) \
V(S390_S8x16Shuffle) \
V(S390_S1x4AnyTrue) \
V(S390_S1x8AnyTrue) \
V(S390_S1x16AnyTrue) \
......
......@@ -246,6 +246,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kS390_I8x16SubSaturateS:
case kS390_I8x16AddSaturateU:
case kS390_I8x16SubSaturateU:
case kS390_S8x16Shuffle:
case kS390_S1x4AnyTrue:
case kS390_S1x8AnyTrue:
case kS390_S1x16AnyTrue:
......
......@@ -2718,6 +2718,34 @@ SIMD_CONVERSION_LIST(SIMD_VISIT_CONVERSION)
#undef SIMD_CONVERSION_LIST
#undef SIMD_TYPES
void InstructionSelector::VisitS8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
S390OperandGenerator g(this);
Node* input0 = node->InputAt(0);
Node* input1 = node->InputAt(1);
// input registers are each in reverse order, we will have to remap the
// shuffle indices
int max_index = 15;
int total_lane_count = 2 * kSimd128Size;
uint8_t shuffle_remapped[kSimd128Size];
for (int i = 0; i < kSimd128Size; i++) {
uint8_t current_index = shuffle[i];
shuffle_remapped[i] = (current_index <= max_index
? max_index - current_index
: total_lane_count - current_index + max_index);
}
Emit(kS390_S8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0),
g.UseRegister(input1),
// Pack4Lanes reverses the bytes, therefore we will need to pass it in
// reverse
g.UseImmediate(Pack4Lanes(shuffle_remapped + 12)),
g.UseImmediate(Pack4Lanes(shuffle_remapped + 8)),
g.UseImmediate(Pack4Lanes(shuffle_remapped + 4)),
g.UseImmediate(Pack4Lanes(shuffle_remapped)));
}
void InstructionSelector::VisitS128Zero(Node* node) {
S390OperandGenerator g(this);
Emit(kS390_S128Zero, g.DefineAsRegister(node), g.DefineAsRegister(node));
......@@ -2771,8 +2799,6 @@ void InstructionSelector::VisitF32x4Min(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitF32x4Max(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS8x16Shuffle(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitS8x16Swizzle(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitF64x2Splat(Node* node) { UNIMPLEMENTED(); }
......
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