Skip to content

Commit

Permalink
[wasm-simd] Rename shuffle & swizzle instructions to match spec
Browse files Browse the repository at this point in the history
These instructions were changed from "s8x16" to "i8x16" prefixes in
WebAssembly/simd#321.

This CL updates all V8 code, including arch-specific code, to match.

Bug: v8:10946, v8:10933
Change-Id: I26ef9ad77571f94501d42c1d65f57380fd507f3d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2432068
Reviewed-by: Zhi An Ng <[email protected]>
Commit-Queue: Adam Klein <[email protected]>
Cr-Commit-Position: refs/heads/master@{#70143}
  • Loading branch information
ajklein authored and Commit Bot committed Sep 25, 2020
1 parent 2221f09 commit 74794fb
Show file tree
Hide file tree
Showing 59 changed files with 166 additions and 170 deletions.
4 changes: 2 additions & 2 deletions src/compiler/backend/arm/code-generator-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3097,7 +3097,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
i.InputSimd128Register(1), i.InputInt4(2));
break;
}
case kArmS8x16Swizzle: {
case kArmI8x16Swizzle: {
Simd128Register dst = i.OutputSimd128Register(),
tbl = i.InputSimd128Register(0),
src = i.InputSimd128Register(1);
Expand All @@ -3106,7 +3106,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vtbl(dst.high(), table, src.high());
break;
}
case kArmS8x16Shuffle: {
case kArmI8x16Shuffle: {
Simd128Register dst = i.OutputSimd128Register(),
src0 = i.InputSimd128Register(0),
src1 = i.InputSimd128Register(1);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/arm/instruction-codes-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ namespace compiler {
V(ArmS8x16TransposeLeft) \
V(ArmS8x16TransposeRight) \
V(ArmS8x16Concat) \
V(ArmS8x16Swizzle) \
V(ArmS8x16Shuffle) \
V(ArmI8x16Swizzle) \
V(ArmI8x16Shuffle) \
V(ArmS32x2Reverse) \
V(ArmS16x4Reverse) \
V(ArmS16x2Reverse) \
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/arm/instruction-scheduler-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kArmS8x16TransposeLeft:
case kArmS8x16TransposeRight:
case kArmS8x16Concat:
case kArmS8x16Swizzle:
case kArmS8x16Shuffle:
case kArmI8x16Swizzle:
case kArmI8x16Shuffle:
case kArmS32x2Reverse:
case kArmS16x4Reverse:
case kArmS16x2Reverse:
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/backend/arm/instruction-selector-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2870,7 +2870,7 @@ void ArrangeShuffleTable(ArmOperandGenerator* g, Node* input0, Node* input1,

} // namespace

void InstructionSelector::VisitS8x16Shuffle(Node* node) {
void InstructionSelector::VisitI8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
Expand Down Expand Up @@ -2923,18 +2923,18 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
// Code generator uses vtbl, arrange sources to form a valid lookup table.
InstructionOperand src0, src1;
ArrangeShuffleTable(&g, input0, input1, &src0, &src1);
Emit(kArmS8x16Shuffle, g.DefineAsRegister(node), src0, src1,
Emit(kArmI8x16Shuffle, g.DefineAsRegister(node), src0, src1,
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12)));
}

void InstructionSelector::VisitS8x16Swizzle(Node* node) {
void InstructionSelector::VisitI8x16Swizzle(Node* node) {
ArmOperandGenerator g(this);
// We don't want input 0 (the table) to be the same as output, since we will
// modify output twice (low and high), and need to keep the table the same.
Emit(kArmS8x16Swizzle, g.DefineAsRegister(node),
Emit(kArmI8x16Swizzle, g.DefineAsRegister(node),
g.UseUniqueRegister(node->InputAt(0)), g.UseRegister(node->InputAt(1)));
}

Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/arm64/code-generator-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2551,12 +2551,12 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
i.InputSimd128Register(1).V16B(), i.InputInt4(2));
break;
}
case kArm64S8x16Swizzle: {
case kArm64I8x16Swizzle: {
__ Tbl(i.OutputSimd128Register().V16B(), i.InputSimd128Register(0).V16B(),
i.InputSimd128Register(1).V16B());
break;
}
case kArm64S8x16Shuffle: {
case kArm64I8x16Shuffle: {
Simd128Register dst = i.OutputSimd128Register().V16B(),
src0 = i.InputSimd128Register(0).V16B(),
src1 = i.InputSimd128Register(1).V16B();
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/arm64/instruction-codes-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ namespace compiler {
V(Arm64S8x16TransposeLeft) \
V(Arm64S8x16TransposeRight) \
V(Arm64S8x16Concat) \
V(Arm64S8x16Swizzle) \
V(Arm64S8x16Shuffle) \
V(Arm64I8x16Swizzle) \
V(Arm64I8x16Shuffle) \
V(Arm64S32x2Reverse) \
V(Arm64S16x4Reverse) \
V(Arm64S16x2Reverse) \
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/arm64/instruction-scheduler-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kArm64S8x16TransposeLeft:
case kArm64S8x16TransposeRight:
case kArm64S8x16Concat:
case kArm64S8x16Swizzle:
case kArm64S8x16Shuffle:
case kArm64I8x16Swizzle:
case kArm64I8x16Shuffle:
case kArm64S32x2Reverse:
case kArm64S16x4Reverse:
case kArm64S16x2Reverse:
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/backend/arm64/instruction-selector-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,7 @@ void InstructionSelector::VisitWord64Ror(Node* node) {
V(Float64Max, kArm64Float64Max) \
V(Float32Min, kArm64Float32Min) \
V(Float64Min, kArm64Float64Min) \
V(S8x16Swizzle, kArm64S8x16Swizzle)
V(I8x16Swizzle, kArm64I8x16Swizzle)

#define RR_VISITOR(Name, opcode) \
void InstructionSelector::Visit##Name(Node* node) { \
Expand Down Expand Up @@ -3611,7 +3611,7 @@ void ArrangeShuffleTable(Arm64OperandGenerator* g, Node* input0, Node* input1,

} // namespace

void InstructionSelector::VisitS8x16Shuffle(Node* node) {
void InstructionSelector::VisitI8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
Expand Down Expand Up @@ -3661,7 +3661,7 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
// Code generator uses vtbl, arrange sources to form a valid lookup table.
InstructionOperand src0, src1;
ArrangeShuffleTable(&g, input0, input1, &src0, &src1);
Emit(kArm64S8x16Shuffle, g.DefineAsRegister(node), src0, src1,
Emit(kArm64I8x16Shuffle, g.DefineAsRegister(node), src0, src1,
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)),
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/ia32/code-generator-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3716,7 +3716,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Andnps(dst, src1);
break;
}
case kIA32S8x16Swizzle: {
case kIA32I8x16Swizzle: {
DCHECK_EQ(i.OutputSimd128Register(), i.InputSimd128Register(0));
XMMRegister dst = i.OutputSimd128Register();
XMMRegister mask = i.TempSimd128Register(0);
Expand All @@ -3729,7 +3729,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Pshufb(dst, mask);
break;
}
case kIA32S8x16Shuffle: {
case kIA32I8x16Shuffle: {
XMMRegister dst = i.OutputSimd128Register();
Operand src0 = i.InputOperand(0);
Register tmp = i.TempRegister(0);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/ia32/instruction-codes-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ namespace compiler {
V(SSES128Select) \
V(AVXS128Select) \
V(IA32S128AndNot) \
V(IA32S8x16Swizzle) \
V(IA32S8x16Shuffle) \
V(IA32I8x16Swizzle) \
V(IA32I8x16Shuffle) \
V(IA32S8x16LoadSplat) \
V(IA32S16x8LoadSplat) \
V(IA32S32x4LoadSplat) \
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/ia32/instruction-scheduler-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kSSES128Select:
case kAVXS128Select:
case kIA32S128AndNot:
case kIA32S8x16Swizzle:
case kIA32S8x16Shuffle:
case kIA32I8x16Swizzle:
case kIA32I8x16Shuffle:
case kIA32S32x4Swizzle:
case kIA32S32x4Shuffle:
case kIA32S16x8Blend:
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/backend/ia32/instruction-selector-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2687,7 +2687,7 @@ bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table,

} // namespace

void InstructionSelector::VisitS8x16Shuffle(Node* node) {
void InstructionSelector::VisitI8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
Expand All @@ -2706,7 +2706,7 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
// We generally need UseRegister for input0, Use for input1.
bool src0_needs_reg = true;
bool src1_needs_reg = false;
ArchOpcode opcode = kIA32S8x16Shuffle; // general shuffle is the default
ArchOpcode opcode = kIA32I8x16Shuffle; // general shuffle is the default

uint8_t offset;
uint8_t shuffle32x4[4];
Expand Down Expand Up @@ -2794,7 +2794,7 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
src0_needs_reg = true;
imms[imm_count++] = index;
}
if (opcode == kIA32S8x16Shuffle) {
if (opcode == kIA32I8x16Shuffle) {
// Use same-as-first for general swizzle, but not shuffle.
no_same_as_first = !is_swizzle;
src0_needs_reg = !no_same_as_first;
Expand Down Expand Up @@ -2827,10 +2827,10 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
Emit(opcode, 1, &dst, input_count, inputs, temp_count, temps);
}

void InstructionSelector::VisitS8x16Swizzle(Node* node) {
void InstructionSelector::VisitI8x16Swizzle(Node* node) {
IA32OperandGenerator g(this);
InstructionOperand temps[] = {g.TempSimd128Register()};
Emit(kIA32S8x16Swizzle, g.DefineSameAsFirst(node),
Emit(kIA32I8x16Swizzle, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)),
arraysize(temps), temps);
}
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/backend/instruction-selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2219,10 +2219,10 @@ void InstructionSelector::VisitNode(Node* node) {
return MarkAsSimd128(node), VisitS128Select(node);
case IrOpcode::kS128AndNot:
return MarkAsSimd128(node), VisitS128AndNot(node);
case IrOpcode::kS8x16Swizzle:
return MarkAsSimd128(node), VisitS8x16Swizzle(node);
case IrOpcode::kS8x16Shuffle:
return MarkAsSimd128(node), VisitS8x16Shuffle(node);
case IrOpcode::kI8x16Swizzle:
return MarkAsSimd128(node), VisitI8x16Swizzle(node);
case IrOpcode::kI8x16Shuffle:
return MarkAsSimd128(node), VisitI8x16Shuffle(node);
case IrOpcode::kV64x2AnyTrue:
return MarkAsWord32(node), VisitV64x2AnyTrue(node);
case IrOpcode::kV64x2AllTrue:
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips/code-generator-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3274,7 +3274,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ sldi_b(dst, i.InputSimd128Register(1), i.InputInt4(2));
break;
}
case kMipsS8x16Shuffle: {
case kMipsI8x16Shuffle: {
CpuFeatureScope msa_scope(tasm(), MIPS_SIMD);
Simd128Register dst = i.OutputSimd128Register(),
src0 = i.InputSimd128Register(0),
Expand All @@ -3299,7 +3299,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vshf_b(dst, src1, src0);
break;
}
case kMipsS8x16Swizzle: {
case kMipsI8x16Swizzle: {
Simd128Register dst = i.OutputSimd128Register(),
tbl = i.InputSimd128Register(0),
ctl = i.InputSimd128Register(1);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips/instruction-codes-mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ namespace compiler {
V(MipsS8x16PackOdd) \
V(MipsS8x16InterleaveEven) \
V(MipsS8x16InterleaveOdd) \
V(MipsS8x16Shuffle) \
V(MipsS8x16Swizzle) \
V(MipsI8x16Shuffle) \
V(MipsI8x16Swizzle) \
V(MipsS8x16Concat) \
V(MipsS8x8Reverse) \
V(MipsS8x4Reverse) \
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips/instruction-scheduler-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMipsS8x16InterleaveRight:
case kMipsS8x16PackEven:
case kMipsS8x16PackOdd:
case kMipsS8x16Shuffle:
case kMipsS8x16Swizzle:
case kMipsI8x16Shuffle:
case kMipsI8x16Swizzle:
case kMipsS8x2Reverse:
case kMipsS8x4Reverse:
case kMipsS8x8Reverse:
Expand Down
11 changes: 5 additions & 6 deletions src/compiler/backend/mips/instruction-selector-mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2378,7 +2378,7 @@ bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table,

} // namespace

void InstructionSelector::VisitS8x16Shuffle(Node* node) {
void InstructionSelector::VisitI8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
Expand All @@ -2404,23 +2404,22 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4)));
return;
}
Emit(kMipsS8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0),
Emit(kMipsI8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0),
g.UseRegister(input1),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12)));
}

void InstructionSelector::VisitS8x16Swizzle(Node* node) {
void InstructionSelector::VisitI8x16Swizzle(Node* node) {
MipsOperandGenerator g(this);
InstructionOperand temps[] = {g.TempSimd128Register()};
// We don't want input 0 or input 1 to be the same as output, since we will
// modify output before do the calculation.
Emit(kMipsS8x16Swizzle, g.DefineAsRegister(node),
Emit(kMipsI8x16Swizzle, g.DefineAsRegister(node),
g.UseUniqueRegister(node->InputAt(0)),
g.UseUniqueRegister(node->InputAt(1)),
arraysize(temps), temps);
g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps);
}

void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips64/code-generator-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3497,7 +3497,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ sldi_b(dst, i.InputSimd128Register(1), i.InputInt4(2));
break;
}
case kMips64S8x16Shuffle: {
case kMips64I8x16Shuffle: {
CpuFeatureScope msa_scope(tasm(), MIPS_SIMD);
Simd128Register dst = i.OutputSimd128Register(),
src0 = i.InputSimd128Register(0),
Expand All @@ -3522,7 +3522,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vshf_b(dst, src1, src0);
break;
}
case kMips64S8x16Swizzle: {
case kMips64I8x16Swizzle: {
Simd128Register dst = i.OutputSimd128Register(),
tbl = i.InputSimd128Register(0),
ctl = i.InputSimd128Register(1);
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips64/instruction-codes-mips64.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ namespace compiler {
V(Mips64S8x16PackOdd) \
V(Mips64S8x16InterleaveEven) \
V(Mips64S8x16InterleaveOdd) \
V(Mips64S8x16Shuffle) \
V(Mips64S8x16Swizzle) \
V(Mips64I8x16Shuffle) \
V(Mips64I8x16Swizzle) \
V(Mips64S8x16Concat) \
V(Mips64S8x8Reverse) \
V(Mips64S8x4Reverse) \
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/backend/mips64/instruction-scheduler-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kMips64S8x2Reverse:
case kMips64S8x4Reverse:
case kMips64S8x8Reverse:
case kMips64S8x16Shuffle:
case kMips64S8x16Swizzle:
case kMips64I8x16Shuffle:
case kMips64I8x16Swizzle:
case kMips64Sar:
case kMips64Seb:
case kMips64Seh:
Expand Down
11 changes: 5 additions & 6 deletions src/compiler/backend/mips64/instruction-selector-mips64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3080,7 +3080,7 @@ bool TryMatchArchShuffle(const uint8_t* shuffle, const ShuffleEntry* table,

} // namespace

void InstructionSelector::VisitS8x16Shuffle(Node* node) {
void InstructionSelector::VisitI8x16Shuffle(Node* node) {
uint8_t shuffle[kSimd128Size];
bool is_swizzle;
CanonicalizeShuffle(node, shuffle, &is_swizzle);
Expand All @@ -3106,23 +3106,22 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle32x4)));
return;
}
Emit(kMips64S8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0),
Emit(kMips64I8x16Shuffle, g.DefineAsRegister(node), g.UseRegister(input0),
g.UseRegister(input1),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 4)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 8)),
g.UseImmediate(wasm::SimdShuffle::Pack4Lanes(shuffle + 12)));
}

void InstructionSelector::VisitS8x16Swizzle(Node* node) {
void InstructionSelector::VisitI8x16Swizzle(Node* node) {
Mips64OperandGenerator g(this);
InstructionOperand temps[] = {g.TempSimd128Register()};
// We don't want input 0 or input 1 to be the same as output, since we will
// modify output before do the calculation.
Emit(kMips64S8x16Swizzle, g.DefineAsRegister(node),
Emit(kMips64I8x16Swizzle, g.DefineAsRegister(node),
g.UseUniqueRegister(node->InputAt(0)),
g.UseUniqueRegister(node->InputAt(1)),
arraysize(temps), temps);
g.UseUniqueRegister(node->InputAt(1)), arraysize(temps), temps);
}

void InstructionSelector::VisitSignExtendWord8ToInt32(Node* node) {
Expand Down
Loading

0 comments on commit 74794fb

Please sign in to comment.