summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ir/features.h8
-rw-r--r--src/tools/tool-options.h10
-rw-r--r--src/wasm.h6
3 files changed, 22 insertions, 2 deletions
diff --git a/src/ir/features.h b/src/ir/features.h
index ed7fb6ff5..505e239a5 100644
--- a/src/ir/features.h
+++ b/src/ir/features.h
@@ -76,6 +76,14 @@ inline FeatureSet get(UnaryOp op) {
ret.setSIMD();
break;
}
+ case ExtendS8Int32:
+ case ExtendS16Int32:
+ case ExtendS8Int64:
+ case ExtendS16Int64:
+ case ExtendS32Int64: {
+ ret.setSignExt();
+ break;
+ }
default: {}
}
return ret;
diff --git a/src/tools/tool-options.h b/src/tools/tool-options.h
index 5620883ec..671085a4e 100644
--- a/src/tools/tool-options.h
+++ b/src/tools/tool-options.h
@@ -39,6 +39,16 @@ struct ToolOptions : public Options {
[this](Options *o, const std::string& arguments) {
passOptions.features = FeatureSet::All;
})
+ .add("--enable-sign-ext", "", "Enable sign extension operations",
+ Options::Arguments::Zero,
+ [this](Options *o, const std::string& arguments) {
+ passOptions.features.setSignExt();
+ })
+ .add("--disable-sign-ext", "", "Disable sign extension operations",
+ Options::Arguments::Zero,
+ [this](Options *o, const std::string& arguments) {
+ passOptions.features.setSignExt(false);
+ })
.add("--enable-threads", "", "Enable atomic operations",
Options::Arguments::Zero,
[this](Options *o, const std::string& arguments) {
diff --git a/src/wasm.h b/src/wasm.h
index a16dab478..5f38b2a2e 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -46,7 +46,8 @@ struct FeatureSet {
TruncSat = 1 << 2,
SIMD = 1 << 3,
BulkMemory = 1 << 4,
- All = Atomics | MutableGlobals | TruncSat | SIMD | BulkMemory
+ SignExt = 1 << 5,
+ All = Atomics | MutableGlobals | TruncSat | SIMD | BulkMemory | SignExt
};
FeatureSet() : features(MVP) {}
@@ -59,6 +60,7 @@ struct FeatureSet {
bool hasTruncSat() const { return features & TruncSat; }
bool hasSIMD() const { return features & SIMD; }
bool hasBulkMemory() const { return features & BulkMemory; }
+ bool hasSignExt() const { return features & SignExt; }
bool hasAll() const { return features & All; }
void makeMVP() { features = MVP; }
@@ -68,6 +70,7 @@ struct FeatureSet {
void setTruncSat(bool v = true) { set(TruncSat, v); }
void setSIMD(bool v = true) { set(SIMD, v); }
void setBulkMemory(bool v = true) { set(BulkMemory, v); }
+ void setSignExt(bool v = true) { set(SignExt, v); }
void setAll(bool v = true) { features = v ? All : MVP; }
bool operator<=(const FeatureSet& other) {
@@ -114,7 +117,6 @@ enum UnaryOp {
PromoteFloat32, // f32 to f64
DemoteFloat64, // f64 to f32
ReinterpretInt32, ReinterpretInt64, // reinterpret bits to float
- // The following sign-extention operators go along with wasm atomics support.
// Extend signed subword-sized integer. This differs from e.g. ExtendSInt32
// because the input integer is in an i64 value insetad of an i32 value.
ExtendS8Int32, ExtendS16Int32, ExtendS8Int64, ExtendS16Int64, ExtendS32Int64,