1010//! - minstreth
1111//! - mhpmcounter<3-31>h
1212//! - mstatush
13+ //!
14+ //! # On Floating-Point CSRs
15+ //!
16+ //! We are deliberately *not* providing instructions that could change the floating-point rounding
17+ //! mode or exception behavior or read the accrued exceptions flags: `frcsr`, `fscsr`, `fsrm`,
18+ //! `frflags`, `fsflags`.
19+ //!
20+ //! Rust makes no guarantees whatsoever about the contents of the accrued exceptions register: Rust
21+ //! floating-point operations may or may not result in this register getting updated with exception
22+ //! state, and the register can change between two invocations of this function even when no
23+ //! floating-point operations appear in the source code (since floating-point operations appearing
24+ //! earlier or later can be reordered).
25+ //!
26+ //! Modifying the rounding mode leads to **immediate Undefined Behavior**: Rust assumes that the
27+ //! default rounding mode is always set and will optimize accordingly. This even applies when the
28+ //! rounding mode is altered and later reset to its original value without any floating-point
29+ //! operations appearing in the source code between those operations (since floating-point
30+ //! operations appearing earlier or later can be reordered).
31+ //!
32+ //! If you need to perform some floating-point operations and check whether they raised an
33+ //! exception, use a single inline assembly block for the entire sequence of operations.
34+ //!
35+ //! If you need to perform some floating-point operations under a different rounding mode, use a
36+ //! single inline assembly block and make sure to restore the original rounding mode before the end
37+ //! of the block.
1338
1439#[ macro_use]
1540mod macros;
1641
17- // User Floating-Point CSRs
18- // TODO: frm, fflags
19- pub mod fcsr;
20-
2142// User Counter/Timers
2243pub mod cycle;
2344pub mod cycleh;
@@ -29,7 +50,6 @@ pub mod time;
2950pub mod timeh;
3051
3152// Supervisor Trap Setup
32- // TODO: sedeleg, sideleg
3353pub mod scounteren;
3454pub mod sie;
3555pub mod sstatus;
0 commit comments