Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions src/wasm/wasm-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ir/stack-utils.h"
#include "ir/utils.h"
#include "support/colors.h"
#include "wasm-features.h"
#include "wasm-type.h"
#include "wasm-validator.h"
#include "wasm.h"
Expand Down Expand Up @@ -1500,9 +1501,31 @@ void FunctionValidator::visitSIMDShuffle(SIMDShuffle* curr) {
}

void FunctionValidator::visitSIMDTernary(SIMDTernary* curr) {
shouldBeTrue(getModule()->features.hasSIMD(),
curr,
"SIMD operations require SIMD [--enable-simd]");
FeatureSet required = FeatureSet::None;
switch (curr->op) {
case RelaxedMaddVecF16x8:
case RelaxedNmaddVecF16x8:
required |= FeatureSet::FP16;
[[fallthrough]];
case LaneselectI8x16:
case LaneselectI16x8:
case LaneselectI32x4:
case LaneselectI64x2:
case RelaxedMaddVecF32x4:
case RelaxedNmaddVecF32x4:
case RelaxedMaddVecF64x2:
case RelaxedNmaddVecF64x2:
case DotI8x16I7x16AddSToVecI32x4:
required |= FeatureSet::RelaxedSIMD;
[[fallthrough]];
case Bitselect:
required |= FeatureSet::SIMD;
}
if (!shouldBeTrue(required <= getModule()->features,
curr,
"SIMD ternary operation requires additional features")) {
getStream() << getMissingFeaturesList(*getModule(), required) << '\n';
}
shouldBeEqualOrFirstIsUnreachable(
curr->type, Type(Type::v128), curr, "SIMD ternary must have type v128");
shouldBeEqualOrFirstIsUnreachable(
Expand Down
10 changes: 10 additions & 0 deletions test/lit/validation/simd-ternary.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
;; RUN: not wasm-opt --enable-simd %s 2>&1 | filecheck %s

;; CHECK: SIMD ternary operation requires additional features, on
;; CHECK: [--enable-relaxed-simd --enable-fp16]

(module
(func $fp16 (param v128 v128 v128)
(f16x8.relaxed_madd (local.get 0) (local.get 1) (local.get 2))
)
)
Loading