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

PPC: [wasm-simd] Implement simd Splat

This CL introduces a new XX1-Form instruction as well as
separates VX-Form instructions to be used for implementing
simd Splat:

- I32x4
- I8x16
- I16x8

Change-Id: If81bbc87b45993ba6fa3e0146dd34496e247dd50
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2165866Reviewed-by: 's avatarJunliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#67393}
parent 91c7ba99
......@@ -1757,6 +1757,12 @@ void Assembler::fmsub(const DoubleRegister frt, const DoubleRegister fra,
frc.code() * B6 | rc);
}
// Vector instructions
void Assembler::mtvsrd(const DoubleRegister rt, const Register ra) {
int TX = 1;
emit(MTVSRD | rt.code() * B21 | ra.code() * B16 | TX);
}
// Pseudo instructions.
void Assembler::nop(int type) {
Register reg = r0;
......
......@@ -434,6 +434,20 @@ class Assembler : public AssemblerBase {
PPC_XX3_OPCODE_LIST(DECLARE_PPC_XX3_INSTRUCTIONS)
#undef DECLARE_PPC_XX3_INSTRUCTIONS
#define DECLARE_PPC_VX_INSTRUCTIONS_A_FORM(name, instr_name, instr_value) \
inline void name(const DoubleRegister rt, const DoubleRegister rb, \
const Operand& imm) { \
vx_form(instr_name, rt, rb, imm); \
}
inline void vx_form(Instr instr, DoubleRegister rt, DoubleRegister rb,
const Operand& imm) {
emit(instr | rt.code() * B21 | imm.immediate() * B16 | rb.code() * B11);
}
PPC_VX_OPCODE_A_FORM_LIST(DECLARE_PPC_VX_INSTRUCTIONS_A_FORM)
#undef DECLARE_PPC_VX_INSTRUCTIONS_A_FORM
RegList* GetScratchRegisterList() { return &scratch_register_list_; }
// ---------------------------------------------------------------------------
// Code generation
......@@ -920,6 +934,9 @@ class Assembler : public AssemblerBase {
const DoubleRegister frc, const DoubleRegister frb,
RCBit rc = LeaveRC);
// Vector instructions
void mtvsrd(const DoubleRegister rt, const Register ra);
// Pseudo instructions
// Different nop operations are used by the code generator to detect certain
......
......@@ -2192,7 +2192,15 @@ using Instr = uint32_t;
/* Rotate Left Word then AND with Mask */ \
V(rlwnm, RLWNMX, 0x5C000000)
#define PPC_VX_OPCODE_LIST(V) \
#define PPC_VX_OPCODE_A_FORM_LIST(V) \
/* Vector Splat Byte */ \
V(vspltb, VSPLTB, 0x1000020C) \
/* Vector Splat Word */ \
V(vspltw, VSPLTW, 0x1000028C) \
/* Vector Splat Halfword */ \
V(vsplth, VSPLTH, 0x1000024C)
#define PPC_VX_OPCODE_UNUSED_LIST(V) \
/* Decimal Add Modulo */ \
V(bcdadd, BCDADD, 0xF0000400) \
/* Decimal Subtract Modulo */ \
......@@ -2427,18 +2435,12 @@ using Instr = uint32_t;
V(vslo, VSLO, 0x1000040C) \
/* Vector Shift Left Word */ \
V(vslw, VSLW, 0x10000184) \
/* Vector Splat Byte */ \
V(vspltb, VSPLTB, 0x1000020C) \
/* Vector Splat Halfword */ \
V(vsplth, VSPLTH, 0x1000024C) \
/* Vector Splat Immediate Signed Byte */ \
V(vspltisb, VSPLTISB, 0x1000030C) \
/* Vector Splat Immediate Signed Halfword */ \
V(vspltish, VSPLTISH, 0x1000034C) \
/* Vector Splat Immediate Signed Word */ \
V(vspltisw, VSPLTISW, 0x1000038C) \
/* Vector Splat Word */ \
V(vspltw, VSPLTW, 0x1000028C) \
/* Vector Shift Right */ \
V(vsr, VSR, 0x100002C4) \
/* Vector Shift Right Algebraic Byte */ \
......@@ -2534,6 +2536,10 @@ using Instr = uint32_t;
/* Vector Merge Odd Word */ \
V(vmrgow, VMRGOW, 0x1000068C)
#define PPC_VX_OPCODE_LIST(V) \
PPC_VX_OPCODE_A_FORM_LIST(V) \
PPC_VX_OPCODE_UNUSED_LIST(V)
#define PPC_XS_OPCODE_LIST(V) \
/* Shift Right Algebraic Doubleword Immediate */ \
V(sradi, SRADIX, 0x7C000674)
......
......@@ -2146,6 +2146,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
}
#endif // V8_TARGET_ARCH_PPC64
case kPPC_I32x4Splat: {
Simd128Register dst = i.OutputSimd128Register();
__ mtvsrd(dst, i.InputRegister(0));
__ vspltw(dst, dst, Operand(1));
break;
}
case kPPC_I16x8Splat: {
Simd128Register dst = i.OutputSimd128Register();
__ mtvsrd(dst, i.InputRegister(0));
__ vsplth(dst, dst, Operand(3));
break;
}
case kPPC_I8x16Splat: {
Simd128Register dst = i.OutputSimd128Register();
__ mtvsrd(dst, i.InputRegister(0));
__ vspltb(dst, dst, Operand(7));
break;
}
default:
UNREACHABLE();
}
......
......@@ -189,7 +189,10 @@ namespace compiler {
V(PPC_AtomicXorInt8) \
V(PPC_AtomicXorInt16) \
V(PPC_AtomicXorInt32) \
V(PPC_AtomicXorInt64)
V(PPC_AtomicXorInt64) \
V(PPC_I32x4Splat) \
V(PPC_I16x8Splat) \
V(PPC_I8x16Splat)
// Addressing modes represent the "shape" of inputs to an instruction.
// Many instructions support multiple addressing modes. Addressing modes
......
......@@ -113,6 +113,9 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kPPC_CompressSigned:
case kPPC_CompressPointer:
case kPPC_CompressAny:
case kPPC_I32x4Splat:
case kPPC_I16x8Splat:
case kPPC_I8x16Splat:
return kNoOpcodeFlags;
case kPPC_LoadWordS8:
......
......@@ -2096,6 +2096,21 @@ void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) {
UNREACHABLE();
}
#define SIMD_TYPES(V) \
V(I32x4) \
V(I16x8) \
V(I8x16)
#define SIMD_VISIT_SPLAT(Type) \
void InstructionSelector::Visit##Type##Splat(Node* node) { \
PPCOperandGenerator g(this); \
Emit(kPPC_##Type##Splat, g.DefineAsRegister(node), \
g.UseRegister(node->InputAt(0))); \
}
SIMD_TYPES(SIMD_VISIT_SPLAT)
#undef SIMD_VISIT_SPLAT
#undef SIMD_TYPES
#define SIMD_VISIT_EXTRACT_LANE(Type, Sign) \
void InstructionSelector::Visit##Type##ExtractLane##Sign(Node* node) { \
UNIMPLEMENTED(); \
......@@ -2109,8 +2124,6 @@ SIMD_VISIT_EXTRACT_LANE(I8x16, U)
SIMD_VISIT_EXTRACT_LANE(I8x16, S)
#undef SIMD_VISIT_EXTRACT_LANE
void InstructionSelector::VisitI32x4Splat(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI32x4ReplaceLane(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI32x4Add(Node* node) { UNIMPLEMENTED(); }
......@@ -2147,8 +2160,6 @@ void InstructionSelector::VisitI32x4GtU(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI32x4GeU(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI16x8Splat(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI16x8ReplaceLane(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI16x8Shl(Node* node) { UNIMPLEMENTED(); }
......@@ -2211,8 +2222,6 @@ void InstructionSelector::VisitI8x16RoundingAverageU(Node* node) {
void InstructionSelector::VisitI8x16Neg(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16Splat(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16ReplaceLane(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI8x16Add(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