summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-validator.cpp
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2019-01-02 13:15:59 -0800
committerGitHub <noreply@github.com>2019-01-02 13:15:59 -0800
commit5ebf2745783417c0cb7d9e3d71849c617a1672ad (patch)
tree9ecb1c772ce3fde4aaaeabb99cbb6feb4cdd9c1d /src/wasm/wasm-validator.cpp
parent18fb2c238f3b4c04e3666d8a0d34492936a6bcc0 (diff)
downloadbinaryen-5ebf2745783417c0cb7d9e3d71849c617a1672ad.tar.gz
binaryen-5ebf2745783417c0cb7d9e3d71849c617a1672ad.tar.bz2
binaryen-5ebf2745783417c0cb7d9e3d71849c617a1672ad.zip
Refactor Features code (#1848)
Add features.h which centralizes all the feature detection code. (I'll need this in another place than the validator which is where it was til now.)
Diffstat (limited to 'src/wasm/wasm-validator.cpp')
-rw-r--r--src/wasm/wasm-validator.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index d11d02353..b018db2d0 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -24,10 +24,10 @@
#include "wasm-validator.h"
#include "ir/utils.h"
#include "ir/branch-utils.h"
+#include "ir/features.h"
#include "ir/module-utils.h"
#include "support/colors.h"
-
namespace wasm {
// Print anything that can be streamed to an ostream
@@ -823,6 +823,7 @@ void FunctionValidator::visitBinary(Binary* curr) {
}
case InvalidBinary: WASM_UNREACHABLE();
}
+ shouldBeTrue(Features::get(curr->op) <= info.features, curr, "all used features should be allowed");
}
void FunctionValidator::visitUnary(Unary* curr) {
@@ -897,7 +898,6 @@ void FunctionValidator::visitUnary(Unary* curr) {
case TruncSatSFloat32ToInt64:
case TruncSatUFloat32ToInt32:
case TruncSatUFloat32ToInt64: {
- shouldBeTrue(info.features.hasTruncSat(), curr, "nontrapping float-to-int conversions are disabled");
shouldBeEqual(curr->value->type, f32, curr, "trunc type must be correct");
break;
}
@@ -912,7 +912,6 @@ void FunctionValidator::visitUnary(Unary* curr) {
case TruncSatSFloat64ToInt64:
case TruncSatUFloat64ToInt32:
case TruncSatUFloat64ToInt64: {
- shouldBeTrue(info.features.hasTruncSat(), curr, "nontrapping float-to-int conversions are disabled");
shouldBeEqual(curr->value->type, f64, curr, "trunc type must be correct");
break;
}
@@ -1007,6 +1006,7 @@ void FunctionValidator::visitUnary(Unary* curr) {
break;
case InvalidUnary: WASM_UNREACHABLE();
}
+ shouldBeTrue(Features::get(curr->op) <= info.features, curr, "all used features should be allowed");
}
void FunctionValidator::visitSelect(Select* curr) {