summaryrefslogtreecommitdiff
path: root/src/ast/bits.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast/bits.h')
-rw-r--r--src/ast/bits.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/ast/bits.h b/src/ast/bits.h
index d88cb5edb..c7d2ea4f0 100644
--- a/src/ast/bits.h
+++ b/src/ast/bits.h
@@ -39,6 +39,17 @@ struct Bits {
// this is indeed a mask
return 32 - CountLeadingZeroes(mask);
}
+
+ // gets the number of effective shifts a shift operation does. In
+ // wasm, only 5 bits matter for 32-bit shifts, and 6 for 64.
+ static uint32_t getEffectiveShifts(Const* amount) {
+ if (amount->type == i32) {
+ return amount->value.geti32() & 31;
+ } else if (amount->type == i64) {
+ return amount->value.geti64() & 63;
+ }
+ WASM_UNREACHABLE();
+ }
};
} // namespace wasm