diff options
author | Ng Zhi An <zhin@chromium.org> | 2021-09-23 12:38:06 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-23 12:38:06 -0700 |
commit | 31252873463fd142a1eabb71b965da04a23a00e2 (patch) | |
tree | 0fe663c3e5ec0d95a0148e888837b50790e6ac29 /src | |
parent | 675295888609a688ee81dc9ad2024169da5aa7ed (diff) | |
download | binaryen-31252873463fd142a1eabb71b965da04a23a00e2.tar.gz binaryen-31252873463fd142a1eabb71b965da04a23a00e2.tar.bz2 binaryen-31252873463fd142a1eabb71b965da04a23a00e2.zip |
Add feature flag for relaxed-simd (#4183)
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 3 | ||||
-rw-r--r-- | src/binaryen-c.h | 1 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 1 | ||||
-rw-r--r-- | src/tools/tool-options.h | 1 | ||||
-rw-r--r-- | src/wasm-binary.h | 1 | ||||
-rw-r--r-- | src/wasm-features.h | 7 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 4 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 1 |
8 files changed, 18 insertions, 1 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 68b0f86c2..72598d0dc 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -249,6 +249,9 @@ BinaryenFeatures BinaryenFeatureMemory64(void) { BinaryenFeatures BinaryenFeatureTypedFunctionReferences(void) { return static_cast<BinaryenFeatures>(FeatureSet::TypedFunctionReferences); } +BinaryenFeatures BinaryenFeatureRelaxedSIMD(void) { + return static_cast<BinaryenFeatures>(FeatureSet::RelaxedSIMD); +} BinaryenFeatures BinaryenFeatureAll(void) { return static_cast<BinaryenFeatures>(FeatureSet::All); } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index b2c4351b1..f9c8719dd 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -161,6 +161,7 @@ BINARYEN_API BinaryenFeatures BinaryenFeatureMultivalue(void); BINARYEN_API BinaryenFeatures BinaryenFeatureGC(void); BINARYEN_API BinaryenFeatures BinaryenFeatureMemory64(void); BINARYEN_API BinaryenFeatures BinaryenFeatureTypedFunctionReferences(void); +BINARYEN_API BinaryenFeatures BinaryenFeatureRelaxedSIMD(void); BINARYEN_API BinaryenFeatures BinaryenFeatureAll(void); // Modules diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 94f2d446c..4c5f5ed3b 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -144,6 +144,7 @@ function initializeConstants() { 'GC', 'Memory64', 'TypedFunctionReferences', + 'RelaxedSIMD', 'All' ].forEach(name => { Module['Features'][name] = Module['_BinaryenFeature' + name](); diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index 0c40721d3..4b589b5b2 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -85,6 +85,7 @@ struct ToolOptions : public Options { .addFeature(FeatureSet::TypedFunctionReferences, "typed function references") .addFeature(FeatureSet::GCNNLocals, "GC non-null locals") + .addFeature(FeatureSet::RelaxedSIMD, "relaxed SIMD") .add("--no-validation", "-n", "Disables validation, assumes inputs are correct", diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 057a2a981..aea9e56d8 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -422,6 +422,7 @@ extern const char* MultivalueFeature; extern const char* GCFeature; extern const char* Memory64Feature; extern const char* TypedFunctionReferencesFeature; +extern const char* RelaxedSIMDFeature; enum Subsection { NameModule = 0, diff --git a/src/wasm-features.h b/src/wasm-features.h index e28dcf4d1..7311aadd3 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -41,7 +41,8 @@ struct FeatureSet { TypedFunctionReferences = 1 << 12, // TODO: Remove this feature when the wasm spec stabilizes. GCNNLocals = 1 << 13, - All = (1 << 14) - 1 + RelaxedSIMD = 1 << 14, + All = (1 << 15) - 1 }; static std::string toString(Feature f) { @@ -74,6 +75,8 @@ struct FeatureSet { return "typed-function-references"; case GCNNLocals: return "gc-nn-locals"; + case RelaxedSIMD: + return "relaxed-simd"; default: WASM_UNREACHABLE("unexpected feature"); } @@ -118,6 +121,7 @@ struct FeatureSet { return (features & TypedFunctionReferences) != 0; } bool hasGCNNLocals() const { return (features & GCNNLocals) != 0; } + bool hasRelaxedSIMD() const { return (features & RelaxedSIMD) != 0; } bool hasAll() const { return (features & All) != 0; } void set(FeatureSet f, bool v = true) { @@ -139,6 +143,7 @@ struct FeatureSet { set(TypedFunctionReferences, v); } void setGCNNLocals(bool v = true) { set(GCNNLocals, v); } + void setRelaxedSIMD(bool v = true) { set(RelaxedSIMD, v); } void setMVP() { features = MVP; } void setAll() { // Do not set GCNNLocals, which forces the user to opt in to that feature diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index 74895c868..cd1cfaa0f 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1048,6 +1048,8 @@ void WasmBinaryWriter::writeFeaturesSection() { return BinaryConsts::UserSections::Memory64Feature; case FeatureSet::TypedFunctionReferences: return BinaryConsts::UserSections::TypedFunctionReferencesFeature; + case FeatureSet::RelaxedSIMD: + return BinaryConsts::UserSections::RelaxedSIMDFeature; default: WASM_UNREACHABLE("unexpected feature flag"); } @@ -3263,6 +3265,8 @@ void WasmBinaryBuilder::readFeatures(size_t payloadLen) { } else if (name == BinaryConsts::UserSections::TypedFunctionReferencesFeature) { feature = FeatureSet::TypedFunctionReferences; + } else if (name == BinaryConsts::UserSections::RelaxedSIMDFeature) { + feature = FeatureSet::RelaxedSIMD; } else { // Silently ignore unknown features (this may be and old binaryen running // on a new wasm). diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index 792e43cbe..8565bfaa5 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -48,6 +48,7 @@ const char* MultivalueFeature = "multivalue"; const char* GCFeature = "gc"; const char* Memory64Feature = "memory64"; const char* TypedFunctionReferencesFeature = "typed-function-references"; +const char* RelaxedSIMDFeature = "relaxed-simd"; } // namespace UserSections } // namespace BinaryConsts |