summaryrefslogtreecommitdiff
path: root/src/wasm-features.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm-features.h')
-rw-r--r--src/wasm-features.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/wasm-features.h b/src/wasm-features.h
index 49f49db09..6c58f1642 100644
--- a/src/wasm-features.h
+++ b/src/wasm-features.h
@@ -18,6 +18,9 @@
#define wasm_features_h
#include <stdint.h>
+#include <string>
+
+#include "compiler-support.h"
struct FeatureSet {
enum Feature : uint32_t {
@@ -31,6 +34,18 @@ struct FeatureSet {
All = Atomics | MutableGlobals | TruncSat | SIMD | BulkMemory | SignExt
};
+ static std::string toString(Feature f) {
+ switch (f) {
+ case Atomics: return "threads";
+ case MutableGlobals: return "mutable-globals";
+ case TruncSat: return "nontrapping-float-to-int";
+ case SIMD: return "simd";
+ case BulkMemory: return "bulk-memory";
+ case SignExt: return "sign-ext";
+ default: WASM_UNREACHABLE();
+ }
+ }
+
FeatureSet() : features(MVP) {}
FeatureSet(uint32_t features) : features(features) {}
@@ -59,6 +74,16 @@ struct FeatureSet {
features = features & ~other.features & All;
}
+ template<typename F>
+ void iterFeatures(F f) {
+ if (hasAtomics()) f(Atomics);
+ if (hasMutableGlobals()) f(MutableGlobals);
+ if (hasTruncSat()) f(TruncSat);
+ if (hasSIMD()) f(SIMD);
+ if (hasBulkMemory()) f(BulkMemory);
+ if (hasSignExt()) f(SignExt);
+ }
+
bool operator<=(const FeatureSet& other) {
return !(features & ~other.features);
}