bytecodealliance / bytecodealliance/wasmtime
How should CLIF `*_imm` instructions apply to `i128` types?
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 126
Description
Currently CLIF allows instructions such as `iadd_imm.i128 v0, 100`. The immediate is limited to 64-bits, however. [During legalization](https://github.com/bytecodealliance/wasmtime/blob/33e8b3d955697587b23cf39d87fbcbdb4d26b0c9/cranelift/codegen/src/legalizer/mod.rs#L229-L236) the `*_imm` instructions are replaced with constant+op, and there's a list of whether i128 immediates are sign or zero extended. Currently though it's a bit arbitrary as to which instructions are sign-extended (`iadd`, `irsub`, `imul`, `sdiv`, `srem`) and which aren't (`bor`, `band`, ...).
Personally I'd say that in both situations the desired 128-bit immediate could be either zero or sign extended so it's not necessarily always correct to infer from the instruction itself.
Should CLIF always sign extend? Always zero extend? Disallow the 128-bit type with these instructions?
Contributor guide
Assessment
This issue has not been assessed yet.