Commit 97bde191 authored by Milad Farazmand's avatar Milad Farazmand Committed by Commit Bot

[s390][wasm-simd] Implement v128.const

Port 871183ea

Original Commit Message:

     - Add wasm opcode, decode and compiler code for v128.const
     - Add codegen implementations for v128.const on x64/Arm64
     - Reuse/Rename some shuffle specific methods to handle generic
     128-bit immediates
     - Tests

R=gdeepti@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ia4990f768b6fac0ac72cf79129a53b531c9c2fa9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2280541Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#68691}
parent 4deef4d7
......@@ -2712,9 +2712,9 @@ void InstructionSelector::VisitI32x4DotI16x8S(Node* node) { UNIMPLEMENTED(); }
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32 && !V8_TARGET_ARCH_ARM64
// && !V8_TARGET_ARCH_ARM
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_S390X
void InstructionSelector::VisitS128Const(Node* node) { UNIMPLEMENTED(); }
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_S390X
void InstructionSelector::VisitFinishRegion(Node* node) { EmitIdentity(node); }
......
......@@ -3918,6 +3918,21 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
Condition(0));
break;
}
case kS390_S128Const: {
#ifdef V8_TARGET_BIG_ENDIAN
for (int index = 0, j = 0; index < 2; index++, j = +2) {
__ lgfi(index < 1 ? ip : r0, Operand(i.InputInt32(j)));
__ iihf(index < 1 ? ip : r0, Operand(i.InputInt32(j + 1)));
}
#else
for (int index = 0, j = 0; index < 2; index++, j = +2) {
__ lgfi(index < 1 ? r0 : ip, Operand(i.InputInt32(j)));
__ iihf(index < 1 ? r0 : ip, Operand(i.InputInt32(j + 1)));
}
#endif
__ vlvgp(i.OutputSimd128Register(), r0, ip);
break;
}
case kS390_S128Zero: {
Simd128Register dst = i.OutputSimd128Register();
__ vx(dst, dst, dst, Condition(0), Condition(0), Condition(0));
......
......@@ -378,6 +378,7 @@ namespace compiler {
V(S390_S128And) \
V(S390_S128Or) \
V(S390_S128Xor) \
V(S390_S128Const) \
V(S390_S128Zero) \
V(S390_S128Not) \
V(S390_S128Select) \
......
......@@ -324,6 +324,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kS390_S128And:
case kS390_S128Or:
case kS390_S128Xor:
case kS390_S128Const:
case kS390_S128Zero:
case kS390_S128Not:
case kS390_S128Select:
......
......@@ -2876,6 +2876,28 @@ void InstructionSelector::VisitS8x16Swizzle(Node* node) {
g.UseUniqueRegister(node->InputAt(1)));
}
void InstructionSelector::VisitS128Const(Node* node) {
S390OperandGenerator g(this);
static const int kUint32Immediates = 4;
uint32_t val[kUint32Immediates];
STATIC_ASSERT(sizeof(val) == kSimd128Size);
memcpy(val, S128ImmediateParameterOf(node->op()).data(), kSimd128Size);
// If all bytes are zeros, avoid emitting code for generic constants
bool all_zeros = !(val[0] && val[1] && val[2] && val[3]);
InstructionOperand dst = g.DefineAsRegister(node);
if (all_zeros) {
Emit(kS390_S128Zero, dst);
} else {
// We have to use Pack4Lanes to reverse the bytes (lanes) on BE,
// Which in this case is ineffective on LE.
Emit(kS390_S128Const, g.DefineAsRegister(node),
g.UseImmediate(Pack4Lanes(reinterpret_cast<uint8_t*>(val))),
g.UseImmediate(Pack4Lanes(reinterpret_cast<uint8_t*>(val) + 4)),
g.UseImmediate(Pack4Lanes(reinterpret_cast<uint8_t*>(val) + 8)),
g.UseImmediate(Pack4Lanes(reinterpret_cast<uint8_t*>(val) + 12)));
}
}
void InstructionSelector::VisitS128Zero(Node* node) {
S390OperandGenerator g(this);
Emit(kS390_S128Zero, g.DefineAsRegister(node));
......
......@@ -3689,7 +3689,7 @@ void RunSimdConstTest(ExecutionTier execution_tier, LowerSimd lower_simd,
}
}
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X
WASM_SIMD_TEST_NO_LOWERING(S128Const) {
std::array<uint8_t, kSimd128Size> expected;
// Test for generic constant
......@@ -3716,7 +3716,7 @@ WASM_SIMD_TEST_NO_LOWERING(S128ConstAllOnes) {
}
RunSimdConstTest(execution_tier, lower_simd, expected);
}
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_S390X
void RunI8x16MixedRelationalOpTest(ExecutionTier execution_tier,
LowerSimd lower_simd, WasmOpcode opcode,
......
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