Skip to content

Commit 6c2d0e2

Browse files
authored
1 parent 459bc07 commit 6c2d0e2

17 files changed

Lines changed: 493 additions & 70 deletions

File tree

scripts/gen-s-parser.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@
452452
("i64x2.extmul_high_i32x4_s", "makeBinary(BinaryOp::ExtMulHighSVecI64x2)"),
453453
("i64x2.extmul_low_i32x4_u", "makeBinary(BinaryOp::ExtMulLowUVecI64x2)"),
454454
("i64x2.extmul_high_i32x4_u", "makeBinary(BinaryOp::ExtMulHighUVecI64x2)"),
455+
("f16x8.abs", "makeUnary(UnaryOp::AbsVecF16x8)"),
456+
("f16x8.neg", "makeUnary(UnaryOp::NegVecF16x8)"),
457+
("f16x8.sqrt", "makeUnary(UnaryOp::SqrtVecF16x8)"),
455458
("f16x8.add", "makeBinary(BinaryOp::AddVecF16x8)"),
456459
("f16x8.sub", "makeBinary(BinaryOp::SubVecF16x8)"),
457460
("f16x8.mul", "makeBinary(BinaryOp::MulVecF16x8)"),
@@ -460,6 +463,10 @@
460463
("f16x8.max", "makeBinary(BinaryOp::MaxVecF16x8)"),
461464
("f16x8.pmin", "makeBinary(BinaryOp::PMinVecF16x8)"),
462465
("f16x8.pmax", "makeBinary(BinaryOp::PMaxVecF16x8)"),
466+
("f16x8.ceil", "makeUnary(UnaryOp::CeilVecF16x8)"),
467+
("f16x8.floor", "makeUnary(UnaryOp::FloorVecF16x8)"),
468+
("f16x8.trunc", "makeUnary(UnaryOp::TruncVecF16x8)"),
469+
("f16x8.nearest", "makeUnary(UnaryOp::NearestVecF16x8)"),
463470
("f32x4.abs", "makeUnary(UnaryOp::AbsVecF32x4)"),
464471
("f32x4.neg", "makeUnary(UnaryOp::NegVecF32x4)"),
465472
("f32x4.sqrt", "makeUnary(UnaryOp::SqrtVecF32x4)"),

src/gen-s-parser.inc

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,26 @@ switch (buf[0]) {
309309
switch (buf[1]) {
310310
case '1': {
311311
switch (buf[6]) {
312-
case 'a':
313-
if (op == "f16x8.add"sv) {
314-
CHECK_ERR(makeBinary(ctx, pos, annotations, BinaryOp::AddVecF16x8));
312+
case 'a': {
313+
switch (buf[7]) {
314+
case 'b':
315+
if (op == "f16x8.abs"sv) {
316+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::AbsVecF16x8));
317+
return Ok{};
318+
}
319+
goto parse_error;
320+
case 'd':
321+
if (op == "f16x8.add"sv) {
322+
CHECK_ERR(makeBinary(ctx, pos, annotations, BinaryOp::AddVecF16x8));
323+
return Ok{};
324+
}
325+
goto parse_error;
326+
default: goto parse_error;
327+
}
328+
}
329+
case 'c':
330+
if (op == "f16x8.ceil"sv) {
331+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::CeilVecF16x8));
315332
return Ok{};
316333
}
317334
goto parse_error;
@@ -338,6 +355,12 @@ switch (buf[0]) {
338355
default: goto parse_error;
339356
}
340357
}
358+
case 'f':
359+
if (op == "f16x8.floor"sv) {
360+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::FloorVecF16x8));
361+
return Ok{};
362+
}
363+
goto parse_error;
341364
case 'g': {
342365
switch (buf[7]) {
343366
case 'e':
@@ -395,12 +418,29 @@ switch (buf[0]) {
395418
default: goto parse_error;
396419
}
397420
}
398-
case 'n':
399-
if (op == "f16x8.ne"sv) {
400-
CHECK_ERR(makeBinary(ctx, pos, annotations, BinaryOp::NeVecF16x8));
401-
return Ok{};
421+
case 'n': {
422+
switch (buf[8]) {
423+
case '\0':
424+
if (op == "f16x8.ne"sv) {
425+
CHECK_ERR(makeBinary(ctx, pos, annotations, BinaryOp::NeVecF16x8));
426+
return Ok{};
427+
}
428+
goto parse_error;
429+
case 'a':
430+
if (op == "f16x8.nearest"sv) {
431+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::NearestVecF16x8));
432+
return Ok{};
433+
}
434+
goto parse_error;
435+
case 'g':
436+
if (op == "f16x8.neg"sv) {
437+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::NegVecF16x8));
438+
return Ok{};
439+
}
440+
goto parse_error;
441+
default: goto parse_error;
402442
}
403-
goto parse_error;
443+
}
404444
case 'p': {
405445
switch (buf[8]) {
406446
case 'a':
@@ -432,6 +472,12 @@ switch (buf[0]) {
432472
return Ok{};
433473
}
434474
goto parse_error;
475+
case 'q':
476+
if (op == "f16x8.sqrt"sv) {
477+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::SqrtVecF16x8));
478+
return Ok{};
479+
}
480+
goto parse_error;
435481
case 'u':
436482
if (op == "f16x8.sub"sv) {
437483
CHECK_ERR(makeBinary(ctx, pos, annotations, BinaryOp::SubVecF16x8));
@@ -441,6 +487,12 @@ switch (buf[0]) {
441487
default: goto parse_error;
442488
}
443489
}
490+
case 't':
491+
if (op == "f16x8.trunc"sv) {
492+
CHECK_ERR(makeUnary(ctx, pos, annotations, UnaryOp::TruncVecF16x8));
493+
return Ok{};
494+
}
495+
goto parse_error;
444496
default: goto parse_error;
445497
}
446498
}

src/ir/child-typer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,13 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> {
372372
case NegVecI16x8:
373373
case NegVecI32x4:
374374
case NegVecI64x2:
375+
case AbsVecF16x8:
376+
case NegVecF16x8:
377+
case SqrtVecF16x8:
378+
case CeilVecF16x8:
379+
case FloorVecF16x8:
380+
case TruncVecF16x8:
381+
case NearestVecF16x8:
375382
case AbsVecF32x4:
376383
case NegVecF32x4:
377384
case SqrtVecF32x4:

src/ir/cost.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,13 @@ struct CostAnalyzer : public OverriddenVisitor<CostAnalyzer, CostType> {
206206
case NegVecI64x2:
207207
case AllTrueVecI64x2:
208208
case BitmaskVecI64x2:
209+
case AbsVecF16x8:
210+
case NegVecF16x8:
211+
case SqrtVecF16x8:
212+
case CeilVecF16x8:
213+
case FloorVecF16x8:
214+
case TruncVecF16x8:
215+
case NearestVecF16x8:
209216
case AbsVecF32x4:
210217
case NegVecF32x4:
211218
case SqrtVecF32x4:

src/literal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ class Literal {
618618
Literal extMulHighSI64x2(const Literal& other) const;
619619
Literal extMulLowUI64x2(const Literal& other) const;
620620
Literal extMulHighUI64x2(const Literal& other) const;
621+
Literal absF16x8() const;
622+
Literal negF16x8() const;
623+
Literal sqrtF16x8() const;
621624
Literal addF16x8(const Literal& other) const;
622625
Literal subF16x8(const Literal& other) const;
623626
Literal mulF16x8(const Literal& other) const;
@@ -626,6 +629,10 @@ class Literal {
626629
Literal maxF16x8(const Literal& other) const;
627630
Literal pminF16x8(const Literal& other) const;
628631
Literal pmaxF16x8(const Literal& other) const;
632+
Literal ceilF16x8() const;
633+
Literal floorF16x8() const;
634+
Literal truncF16x8() const;
635+
Literal nearestF16x8() const;
629636
Literal absF32x4() const;
630637
Literal negF32x4() const;
631638
Literal sqrtF32x4() const;

src/passes/Print.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,27 @@ struct PrintExpressionContents
12091209
case BitmaskVecI64x2:
12101210
o << "i64x2.bitmask";
12111211
break;
1212+
case AbsVecF16x8:
1213+
o << "f16x8.abs";
1214+
break;
1215+
case NegVecF16x8:
1216+
o << "f16x8.neg";
1217+
break;
1218+
case SqrtVecF16x8:
1219+
o << "f16x8.sqrt";
1220+
break;
1221+
case CeilVecF16x8:
1222+
o << "f16x8.ceil";
1223+
break;
1224+
case FloorVecF16x8:
1225+
o << "f16x8.floor";
1226+
break;
1227+
case TruncVecF16x8:
1228+
o << "f16x8.trunc";
1229+
break;
1230+
case NearestVecF16x8:
1231+
o << "f16x8.nearest";
1232+
break;
12121233
case AbsVecF32x4:
12131234
o << "f32x4.abs";
12141235
break;

src/tools/fuzzing/fuzzing.cpp

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3109,31 +3109,42 @@ Expression* TranslateToFuzzReader::makeUnary(Type type) {
31093109
case 3:
31103110
return buildUnary({SplatVecF64x2, make(Type::f64)});
31113111
case 4:
3112-
return buildUnary({pick(NotVec128,
3113-
// TODO: add additional SIMD instructions
3114-
NegVecI8x16,
3115-
NegVecI16x8,
3116-
NegVecI32x4,
3117-
NegVecI64x2,
3118-
AbsVecF32x4,
3119-
NegVecF32x4,
3120-
SqrtVecF32x4,
3121-
AbsVecF64x2,
3122-
NegVecF64x2,
3123-
SqrtVecF64x2,
3124-
TruncSatSVecF32x4ToVecI32x4,
3125-
TruncSatUVecF32x4ToVecI32x4,
3126-
ConvertSVecI32x4ToVecF32x4,
3127-
ConvertUVecI32x4ToVecF32x4,
3128-
ExtendLowSVecI8x16ToVecI16x8,
3129-
ExtendHighSVecI8x16ToVecI16x8,
3130-
ExtendLowUVecI8x16ToVecI16x8,
3131-
ExtendHighUVecI8x16ToVecI16x8,
3132-
ExtendLowSVecI16x8ToVecI32x4,
3133-
ExtendHighSVecI16x8ToVecI32x4,
3134-
ExtendLowUVecI16x8ToVecI32x4,
3135-
ExtendHighUVecI16x8ToVecI32x4),
3136-
make(Type::v128)});
3112+
return buildUnary(
3113+
{pick(FeatureOptions<UnaryOp>()
3114+
.add(FeatureSet::SIMD,
3115+
NotVec128,
3116+
// TODO: add additional SIMD instructions
3117+
NegVecI8x16,
3118+
NegVecI16x8,
3119+
NegVecI32x4,
3120+
NegVecI64x2,
3121+
AbsVecF32x4,
3122+
NegVecF32x4,
3123+
SqrtVecF32x4,
3124+
AbsVecF64x2,
3125+
NegVecF64x2,
3126+
SqrtVecF64x2,
3127+
TruncSatSVecF32x4ToVecI32x4,
3128+
TruncSatUVecF32x4ToVecI32x4,
3129+
ConvertSVecI32x4ToVecF32x4,
3130+
ConvertUVecI32x4ToVecF32x4,
3131+
ExtendLowSVecI8x16ToVecI16x8,
3132+
ExtendHighSVecI8x16ToVecI16x8,
3133+
ExtendLowUVecI8x16ToVecI16x8,
3134+
ExtendHighUVecI8x16ToVecI16x8,
3135+
ExtendLowSVecI16x8ToVecI32x4,
3136+
ExtendHighSVecI16x8ToVecI32x4,
3137+
ExtendLowUVecI16x8ToVecI32x4,
3138+
ExtendHighUVecI16x8ToVecI32x4)
3139+
.add(FeatureSet::FP16,
3140+
AbsVecF16x8,
3141+
NegVecF16x8,
3142+
SqrtVecF16x8,
3143+
CeilVecF16x8,
3144+
FloorVecF16x8,
3145+
TruncVecF16x8,
3146+
NearestVecF16x8)),
3147+
make(Type::v128)});
31373148
}
31383149
WASM_UNREACHABLE("invalid value");
31393150
}

src/wasm-binary.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,13 @@ enum ASTNodes {
10591059
F16x8Splat = 0x120,
10601060
F16x8ExtractLane = 0x121,
10611061
F16x8ReplaceLane = 0x122,
1062+
F16x8Abs = 0x130,
1063+
F16x8Neg = 0x131,
1064+
F16x8Sqrt = 0x132,
1065+
F16x8Ceil = 0x133,
1066+
F16x8Floor = 0x134,
1067+
F16x8Trunc = 0x135,
1068+
F16x8Nearest = 0x136,
10621069
F16x8Eq = 0x137,
10631070
F16x8Ne = 0x138,
10641071
F16x8Lt = 0x139,

src/wasm-interpreter.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,20 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
531531
return value.allTrueI64x2();
532532
case BitmaskVecI64x2:
533533
return value.bitmaskI64x2();
534+
case AbsVecF16x8:
535+
return value.absF16x8();
536+
case NegVecF16x8:
537+
return value.negF16x8();
538+
case SqrtVecF16x8:
539+
return value.sqrtF16x8();
540+
case CeilVecF16x8:
541+
return value.ceilF16x8();
542+
case FloorVecF16x8:
543+
return value.floorF16x8();
544+
case TruncVecF16x8:
545+
return value.truncF16x8();
546+
case NearestVecF16x8:
547+
return value.nearestF16x8();
534548
case AbsVecF32x4:
535549
return value.absF32x4();
536550
case NegVecF32x4:

src/wasm.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,13 @@ enum UnaryOp {
179179
NegVecI64x2,
180180
AllTrueVecI64x2,
181181
BitmaskVecI64x2,
182+
AbsVecF16x8,
183+
NegVecF16x8,
184+
SqrtVecF16x8,
185+
CeilVecF16x8,
186+
FloorVecF16x8,
187+
TruncVecF16x8,
188+
NearestVecF16x8,
182189
AbsVecF32x4,
183190
NegVecF32x4,
184191
SqrtVecF32x4,

0 commit comments

Comments
 (0)