From df9389509c703ec0583d16a70306dbdd07426c56 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Fri, 12 Feb 2021 23:12:51 +0000 Subject: Print the features section in a comment (#3563) --- src/passes/Print.cpp | 4 ++++ src/wasm-features.h | 15 +++++++++++++++ 2 files changed, 19 insertions(+) (limited to 'src') diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 9b59de444..a10467018 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -3240,6 +3240,10 @@ struct PrintSExpression : public OverriddenVisitor { } o << maybeNewLine; } + if (curr->hasFeaturesSection) { + doIndent(o, indent); + o << ";; features section: " << curr->features.toString() << '\n'; + } decIndent(); o << maybeNewLine; currModule = nullptr; diff --git a/src/wasm-features.h b/src/wasm-features.h index d2e3f343f..237dc7757 100644 --- a/src/wasm-features.h +++ b/src/wasm-features.h @@ -75,6 +75,21 @@ struct FeatureSet { } } + std::string toString() { + std::string ret; + uint32_t x = 1; + while (x & Feature::All) { + if (features & x) { + if (!ret.empty()) { + ret += ", "; + } + ret += toString(Feature(x)); + } + x <<= 1; + } + return ret; + } + FeatureSet() : features(MVP) {} FeatureSet(uint32_t features) : features(features) {} operator uint32_t() const { return features; } -- cgit v1.2.3