bytecodealliance / wasmtime

A fast and secure runtime for WebAssembly
https://wasmtime.dev/
Apache License 2.0
14.81k stars 1.24k forks source link

Replace `simm32` extractor with `i32_from_iconst` #8842

Closed alexcrichton closed 1 week ago

alexcrichton commented 1 week ago

This commit removes the simm32 extractor from lowerings as it's not as useful as it was when it was first introduced. Nowadays an Imm64 needs to be interpreted with the type known as well to understand whether bits being masked off is significant or not. The old simm32 extractor only took Imm64 meaning that it was unable to do this and wouldn't match negative numbers. This is because the high 32 bits of Imm64 were always zero and simm64 would take the i64 value from Imm64 and try to convert it to an i32.

This commit replaces simm32, and uses of it, with a new extractor i32_from_iconst. This matches the preexisting i64_from_iconst and is able to take the type of the value into account and produce a correctly sign-extended value.

cc #8706