-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
riscv64: Refactor FRM and fcvt-to-int management (#7327)
* riscv64: Specify rounding modes in instructions This commit updates how floating-point instructions specify their float rounding mode (FRM). Previously instructions stored `Option<FRM>` and this would mostly be `None`. All floating-point instructions in RISC-V have a 3-bit `rm` field, and most encode the FRM into this field but some have a require encoding of this field. For example `fsgnj.s` uses the `rm` field to differentiate between `fsgnj`, `fsgnjx`, and `fsgnjn`. Instructions like `fadd` however use this field for a rounding mode. All FPU instructions now store `FRM` directly. Instruction helpers like `fadd` require this to be specified explicitly. Instructions helpers like for `fsgnj` do not take this as an argument and hardcode the field as necessary. This means that all lowerings of floating point instructions, where relevant, now specify a rounding mode. Previously the default rounding mode was to use the `fcsr` register, meaning that the rounding mode would be determined dynamically at runtime depending on the status of this register. Cranelift semantics, however, are derivative of WebAssembly semantics which specify round-to-nearest ties-to-even. This PR additionally fixes this discrepancy by using `FRM::RNE` in all existing instructions instead of `FRM::Fcsr`. * riscv64: Refactor float-to-int conversions This commit removes the `FcvtToInt` macro-instruction in the riscv64 backend in favor of decomposing it into individual operation for `fcvt_to_{s,u}int*` instructions. This additionally provides a slightly different lowering for the `*_sat` operations which doesn't use branches. The non-saturating operations continue to have a number of branches and their code has changed slightly due to how immediates are loaded. Overall everything is in ISLE now instead of split a bit. * riscv64: Clean up some dead code in the backend Don't put `#![allow(dead_code)]` at the root, instead place it on some smaller items. * Fix emission tests * Add regression tests and bless output Closes #5992 Closes #5993 * Enable i8/i16 saturating float-to-int in fuzzgen * Better `fcvt_*_bound` implementations * Fix typo in match orderings * Fix tests on x64 Where float-to-int isn't implemented for i8/i16
- Loading branch information
1 parent
5adcbb9
commit 72aaff5
Showing
22 changed files
with
1,504 additions
and
1,295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.