10
10
//! - minstreth
11
11
//! - mhpmcounter<3-31>h
12
12
//! - 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.
13
38
14
39
#[ macro_use]
15
40
mod macros;
16
41
17
- // User Floating-Point CSRs
18
- // TODO: frm, fflags
19
- pub mod fcsr;
20
-
21
42
// User Counter/Timers
22
43
pub mod cycle;
23
44
pub mod cycleh;
@@ -29,7 +50,6 @@ pub mod time;
29
50
pub mod timeh;
30
51
31
52
// Supervisor Trap Setup
32
- // TODO: sedeleg, sideleg
33
53
pub mod scounteren;
34
54
pub mod sie;
35
55
pub mod sstatus;
0 commit comments