diff options
author | Alon Zakai <alonzakai@gmail.com> | 2017-07-28 15:45:27 -0700 |
---|---|---|
committer | Alon Zakai (kripken) <alonzakai@gmail.com> | 2017-07-29 19:18:54 -0700 |
commit | db51c2efa3a9c2da064db199792b3bf0de4e850f (patch) | |
tree | 648faeebd3fbc8150cd3dcba178c0fba286b6973 /src/ast/bits.h | |
parent | bd7f7ca58a93f438bd278e6ecb13afb685e5ed6e (diff) | |
download | binaryen-db51c2efa3a9c2da064db199792b3bf0de4e850f.tar.gz binaryen-db51c2efa3a9c2da064db199792b3bf0de4e850f.tar.bz2 binaryen-db51c2efa3a9c2da064db199792b3bf0de4e850f.zip |
refactor effective shift size computation
Diffstat (limited to 'src/ast/bits.h')
-rw-r--r-- | src/ast/bits.h | 11 |
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 |