diff options
author | Frank Emrich <git@emrich.io> | 2023-10-05 17:18:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 16:18:03 +0000 |
commit | 5597ad587857f5f20b23fbd45a94abd98deaf25c (patch) | |
tree | d9229aec42410e09043715e0d83903f391b172e9 /src | |
parent | db68bae222b835f8190013dca45854c7cc07dadf (diff) | |
download | binaryen-5597ad587857f5f20b23fbd45a94abd98deaf25c.tar.gz binaryen-5597ad587857f5f20b23fbd45a94abd98deaf25c.tar.bz2 binaryen-5597ad587857f5f20b23fbd45a94abd98deaf25c.zip |
[typed-cont] Add feature flag (#5996)
This PR is part of a series that adds basic support for the [typed continuations
proposal](https://github.com/wasmfx/specfx).
This particular PR simply extends `FeatureSet` with a corresponding entry for
this proposal.
Diffstat (limited to 'src')
-rw-r--r-- | src/tools/tool-options.h | 1 | ||||
-rw-r--r-- | src/wasm-binary.h | 1 | ||||
-rw-r--r-- | src/wasm-features.h | 9 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 5 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 1 |
5 files changed, 16 insertions, 1 deletions
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h index f7dd791b4..6d68ff3c1 100644 --- a/src/tools/tool-options.h +++ b/src/tools/tool-options.h @@ -93,6 +93,7 @@ struct ToolOptions : public Options { .addFeature(FeatureSet::ExtendedConst, "extended const expressions") .addFeature(FeatureSet::Strings, "strings") .addFeature(FeatureSet::MultiMemory, "multimemory") + .addFeature(FeatureSet::TypedContinuations, "typed continuations") .add("--enable-typed-function-references", "", "Deprecated compatibility flag", diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 72b61223f..8a4d6969f 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -502,6 +502,7 @@ extern const char* RelaxedSIMDFeature; extern const char* ExtendedConstFeature; extern const char* StringsFeature; extern const char* MultiMemoryFeature; +extern const char* TypedContinuationsFeature; enum Subsection { NameModule = 0, diff --git a/src/wasm-features.h b/src/wasm-features.h index f8d006e78..2ace67c27 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -44,11 +44,12 @@ struct FeatureSet { ExtendedConst = 1 << 13, Strings = 1 << 14, MultiMemory = 1 << 15, + TypedContinuations = 1 << 16, MVP = None, // Keep in sync with llvm default features: // https://github.com/llvm/llvm-project/blob/c7576cb89d6c95f03968076e902d3adfd1996577/clang/lib/Basic/Targets/WebAssembly.cpp#L150-L153 Default = SignExt | MutableGlobals, - All = (1 << 16) - 1, + All = (1 << 17) - 1, }; static std::string toString(Feature f) { @@ -85,6 +86,8 @@ struct FeatureSet { return "strings"; case MultiMemory: return "multimemory"; + case TypedContinuations: + return "typed-continuations"; default: WASM_UNREACHABLE("unexpected feature"); } @@ -129,6 +132,9 @@ struct FeatureSet { bool hasExtendedConst() const { return (features & ExtendedConst) != 0; } bool hasStrings() const { return (features & Strings) != 0; } bool hasMultiMemory() const { return (features & MultiMemory) != 0; } + bool hasTypedContinuations() const { + return (features & TypedContinuations) != 0; + } bool hasAll() const { return (features & All) != 0; } void set(FeatureSet f, bool v = true) { @@ -150,6 +156,7 @@ struct FeatureSet { void setExtendedConst(bool v = true) { set(ExtendedConst, v); } void setStrings(bool v = true) { set(Strings, v); } void setMultiMemory(bool v = true) { set(MultiMemory, v); } + void setTypedContinuations(bool v = true) { set(TypedContinuations, v); } void setMVP() { features = MVP; } void setAll() { features = All; } diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index e9adc5e0e..b3108100f 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -1256,6 +1256,8 @@ void WasmBinaryWriter::writeFeaturesSection() { return BinaryConsts::CustomSections::StringsFeature; case FeatureSet::MultiMemory: return BinaryConsts::CustomSections::MultiMemoryFeature; + case FeatureSet::TypedContinuations: + return BinaryConsts::CustomSections::TypedContinuationsFeature; default: WASM_UNREACHABLE("unexpected feature flag"); } @@ -3708,6 +3710,9 @@ void WasmBinaryReader::readFeatures(size_t payloadLen) { feature = FeatureSet::Strings; } else if (name == BinaryConsts::CustomSections::MultiMemoryFeature) { feature = FeatureSet::MultiMemory; + } else if (name == + BinaryConsts::CustomSections::TypedContinuationsFeature) { + feature = FeatureSet::TypedContinuations; } 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 21dc6e25e..e5f3deb33 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -51,6 +51,7 @@ const char* RelaxedSIMDFeature = "relaxed-simd"; const char* ExtendedConstFeature = "extended-const"; const char* StringsFeature = "strings"; const char* MultiMemoryFeature = "multimemory"; +const char* TypedContinuationsFeature = "typed-continuations"; } // namespace CustomSections } // namespace BinaryConsts |