bytecodealliance / bytecodealliance/wasmtime

riscv64: The vxrm and vxsat registers are not preserved or handled

Open
#13,078 0 comments 0 reactions 0 assignees View on GitHub
cranelift:area:riscv64
Dominant language
Rust
Stars
18.6k
Forks
1.8k
Avg merge
1d 19h
Merged PRs (30d)
121

Description

The initial implementation of simd for riscv64, https://github.com/bytecodealliance/wasmtime/issues/6118, states:

> There is additional state that I'm ignoring here:
>
> * vxrm: Vector fixed-point rounding mode register
> * vxsat: Vector fixed-point saturation flag register
>
> Not sure if we need these, but we can handle them in the same manner as vtype, and insert their respective mode switching instructions in the same pass.

According to ABI documentation for riscv64 it looks like both of these registers are not preserved around function calls. Cranelift's implementation of `avg_round` and `sqmul_round_sat` both rely on this (riscv64 instructions `vssrl` and `vsmul`). This seems to work in QEMU because nothing else in Wasmtime modifies the register, but this likely isn't a fully-safe assumption.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.