Skip to content

Commit

Permalink
[SIMD] Make swizzle's opcode name consistent (NFC) (#4585)
Browse files Browse the repository at this point in the history
Other opcode ends with `Inxm` or `Fnxm` (where n and m are integers),
while `i8x16.swizzle`'s opcode name doesn't have an `I` in there.
  • Loading branch information
aheejin authored Apr 9, 2022
1 parent 094deb0 commit 5d5e465
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions scripts/gen-s-parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@
("i64x2.extend_high_i32x4_s", "makeUnary(s, UnaryOp::ExtendHighSVecI32x4ToVecI64x2)"),
("i64x2.extend_low_i32x4_u", "makeUnary(s, UnaryOp::ExtendLowUVecI32x4ToVecI64x2)"),
("i64x2.extend_high_i32x4_u", "makeUnary(s, UnaryOp::ExtendHighUVecI32x4ToVecI64x2)"),
("i8x16.swizzle", "makeBinary(s, BinaryOp::SwizzleVec8x16)"),
("i8x16.swizzle", "makeBinary(s, BinaryOp::SwizzleVecI8x16)"),
("i16x8.extadd_pairwise_i8x16_s", "makeUnary(s, UnaryOp::ExtAddPairwiseSVecI8x16ToI16x8)"),
("i16x8.extadd_pairwise_i8x16_u", "makeUnary(s, UnaryOp::ExtAddPairwiseUVecI8x16ToI16x8)"),
("i32x4.extadd_pairwise_i16x8_s", "makeUnary(s, UnaryOp::ExtAddPairwiseSVecI16x8ToI32x4)"),
Expand All @@ -516,7 +516,7 @@
("f64x2.promote_low_f32x4", "makeUnary(s, UnaryOp::PromoteLowVecF32x4ToVecF64x2)"),

# relaxed SIMD ops
("i8x16.relaxed_swizzle", "makeBinary(s, BinaryOp::RelaxedSwizzleVec8x16)"),
("i8x16.relaxed_swizzle", "makeBinary(s, BinaryOp::RelaxedSwizzleVecI8x16)"),
("i32x4.relaxed_trunc_f32x4_s", "makeUnary(s, UnaryOp::RelaxedTruncSVecF32x4ToVecI32x4)"),
("i32x4.relaxed_trunc_f32x4_u", "makeUnary(s, UnaryOp::RelaxedTruncUVecF32x4ToVecI32x4)"),
("i32x4.relaxed_trunc_f64x2_s_zero", "makeUnary(s, UnaryOp::RelaxedTruncZeroSVecF64x2ToVecI32x4)"),
Expand Down
2 changes: 1 addition & 1 deletion src/binaryen-c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ BinaryenOp BinaryenDemoteZeroVecF64x2ToVecF32x4(void) {
BinaryenOp BinaryenPromoteLowVecF32x4ToVecF64x2(void) {
return PromoteLowVecF32x4ToVecF64x2;
}
BinaryenOp BinaryenSwizzleVec8x16(void) { return SwizzleVec8x16; }
BinaryenOp BinaryenSwizzleVecI8x16(void) { return SwizzleVecI8x16; }
BinaryenOp BinaryenRefIsNull(void) { return RefIsNull; }
BinaryenOp BinaryenRefIsFunc(void) { return RefIsFunc; }
BinaryenOp BinaryenRefIsData(void) { return RefIsData; }
Expand Down
2 changes: 1 addition & 1 deletion src/binaryen-c.h
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ BINARYEN_API BinaryenOp BinaryenTruncSatZeroSVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenTruncSatZeroUVecF64x2ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenDemoteZeroVecF64x2ToVecF32x4(void);
BINARYEN_API BinaryenOp BinaryenPromoteLowVecF32x4ToVecF64x2(void);
BINARYEN_API BinaryenOp BinaryenSwizzleVec8x16(void);
BINARYEN_API BinaryenOp BinaryenSwizzleVecI8x16(void);
BINARYEN_API BinaryenOp BinaryenRefIsNull(void);
BINARYEN_API BinaryenOp BinaryenRefIsFunc(void);
BINARYEN_API BinaryenOp BinaryenRefIsData(void);
Expand Down
4 changes: 2 additions & 2 deletions src/gen-s-parser.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2836,7 +2836,7 @@ switch (op[0]) {
case 'r': {
switch (op[8]) {
case 'l':
if (strcmp(op, "i8x16.relaxed_swizzle") == 0) { return makeBinary(s, BinaryOp::RelaxedSwizzleVec8x16); }
if (strcmp(op, "i8x16.relaxed_swizzle") == 0) { return makeBinary(s, BinaryOp::RelaxedSwizzleVecI8x16); }
goto parse_error;
case 'p':
if (strcmp(op, "i8x16.replace_lane") == 0) { return makeSIMDReplace(s, SIMDReplaceOp::ReplaceLaneVecI8x16, 16); }
Expand Down Expand Up @@ -2891,7 +2891,7 @@ switch (op[0]) {
}
}
case 'w':
if (strcmp(op, "i8x16.swizzle") == 0) { return makeBinary(s, BinaryOp::SwizzleVec8x16); }
if (strcmp(op, "i8x16.swizzle") == 0) { return makeBinary(s, BinaryOp::SwizzleVecI8x16); }
goto parse_error;
default: goto parse_error;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ir/cost.h
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,8 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
case NarrowUVecI16x8ToVecI8x16:
case NarrowSVecI32x4ToVecI16x8:
case NarrowUVecI32x4ToVecI16x8:
case SwizzleVec8x16:
case RelaxedSwizzleVec8x16:
case SwizzleVecI8x16:
case RelaxedSwizzleVecI8x16:
case RelaxedQ15MulrSVecI16x8:
ret = 1;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/js/binaryen.js-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ function initializeConstants() {
'TruncSatZeroUVecF64x2ToVecI32x4',
'DemoteZeroVecF64x2ToVecF32x4',
'PromoteLowVecF32x4ToVecF64x2',
'SwizzleVec8x16',
'SwizzleVecI8x16',
'RefIsNull',
'RefIsFunc',
'RefIsData',
Expand Down Expand Up @@ -1597,7 +1597,7 @@ function wrapModule(module, self = {}) {
return preserveStack(() => Module['_BinaryenSIMDShuffle'](module, left, right, i8sToStack(mask)));
},
'swizzle'(left, right) {
return Module['_BinaryenBinary'](module, Module['SwizzleVec8x16'], left, right);
return Module['_BinaryenBinary'](module, Module['SwizzleVecI8x16'], left, right);
},
'splat'(value) {
return Module['_BinaryenUnary'](module, Module['SplatVecI8x16'], value);
Expand Down
4 changes: 2 additions & 2 deletions src/passes/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ struct PrintExpressionContents
o << "i16x8.narrow_i32x4_u";
break;

case SwizzleVec8x16:
case SwizzleVecI8x16:
o << "i8x16.swizzle";
break;

Expand All @@ -1848,7 +1848,7 @@ struct PrintExpressionContents
case RelaxedMaxVecF64x2:
o << "f64x2.relaxed_max";
break;
case RelaxedSwizzleVec8x16:
case RelaxedSwizzleVecI8x16:
o << "i8x16.relaxed_swizzle";
break;
case RelaxedQ15MulrSVecI16x8:
Expand Down
2 changes: 1 addition & 1 deletion src/tools/fuzzing/fuzzing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ Expression* TranslateToFuzzReader::makeBinary(Type type) {
NarrowUVecI16x8ToVecI8x16,
NarrowSVecI32x4ToVecI16x8,
NarrowUVecI32x4ToVecI16x8,
SwizzleVec8x16),
SwizzleVecI8x16),
make(Type::v128),
make(Type::v128)});
}
Expand Down
4 changes: 2 additions & 2 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,8 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
case NarrowUVecI32x4ToVecI16x8:
return left.narrowUToI16x8(right);

case SwizzleVec8x16:
case RelaxedSwizzleVec8x16:
case SwizzleVecI8x16:
case RelaxedSwizzleVecI8x16:
return left.swizzleI8x16(right);

case InvalidBinary:
Expand Down
4 changes: 2 additions & 2 deletions src/wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,10 +464,10 @@ enum BinaryOp {
NarrowUVecI32x4ToVecI16x8,

// SIMD Swizzle
SwizzleVec8x16,
SwizzleVecI8x16,

// Relaxed SIMD
RelaxedSwizzleVec8x16,
RelaxedSwizzleVecI8x16,
RelaxedMinVecF32x4,
RelaxedMaxVecF32x4,
RelaxedMinVecF64x2,
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5575,11 +5575,11 @@ bool WasmBinaryBuilder::maybeVisitSIMDBinary(Expression*& out, uint32_t code) {
break;
case BinaryConsts::I8x16Swizzle:
curr = allocator.alloc<Binary>();
curr->op = SwizzleVec8x16;
curr->op = SwizzleVecI8x16;
break;
case BinaryConsts::I8x16RelaxedSwizzle:
curr = allocator.alloc<Binary>();
curr->op = RelaxedSwizzleVec8x16;
curr->op = RelaxedSwizzleVecI8x16;
break;
case BinaryConsts::F32x4RelaxedMin:
curr = allocator.alloc<Binary>();
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1817,12 +1817,12 @@ void BinaryInstWriter::visitBinary(Binary* curr) {
<< U32LEB(BinaryConsts::I16x8NarrowI32x4U);
break;

case SwizzleVec8x16:
case SwizzleVecI8x16:
o << int8_t(BinaryConsts::SIMDPrefix)
<< U32LEB(BinaryConsts::I8x16Swizzle);
break;

case RelaxedSwizzleVec8x16:
case RelaxedSwizzleVecI8x16:
o << int8_t(BinaryConsts::SIMDPrefix)
<< U32LEB(BinaryConsts::I8x16RelaxedSwizzle);
break;
Expand Down
4 changes: 2 additions & 2 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,8 @@ void FunctionValidator::visitBinary(Binary* curr) {
case NarrowUVecI16x8ToVecI8x16:
case NarrowSVecI32x4ToVecI16x8:
case NarrowUVecI32x4ToVecI16x8:
case SwizzleVec8x16:
case RelaxedSwizzleVec8x16:
case SwizzleVecI8x16:
case RelaxedSwizzleVecI8x16:
case RelaxedQ15MulrSVecI16x8: {
shouldBeEqualOrFirstIsUnreachable(
curr->left->type, Type(Type::v128), curr, "v128 op");
Expand Down
2 changes: 1 addition & 1 deletion test/example/c-api-kitchen-sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void test_core() {
makeBinary(module, BinaryenNarrowUVecI16x8ToVecI8x16(), v128),
makeBinary(module, BinaryenNarrowSVecI32x4ToVecI16x8(), v128),
makeBinary(module, BinaryenNarrowUVecI32x4ToVecI16x8(), v128),
makeBinary(module, BinaryenSwizzleVec8x16(), v128),
makeBinary(module, BinaryenSwizzleVecI8x16(), v128),
// SIMD lane manipulation
makeSIMDExtract(module, BinaryenExtractLaneSVecI8x16()),
makeSIMDExtract(module, BinaryenExtractLaneUVecI8x16()),
Expand Down

0 comments on commit 5d5e465

Please sign in to comment.