3
3
pub use super :: misa:: XLEN ;
4
4
#[ cfg( not( target_arch = "riscv32" ) ) ]
5
5
use crate :: bits:: { bf_extract, bf_insert} ;
6
- #[ cfg( target_arch = "riscv32" ) ]
7
- use crate :: result:: Error ;
8
- use crate :: result:: Result ;
9
6
10
7
#[ cfg( not( target_arch = "riscv32" ) ) ]
11
8
read_write_csr ! {
@@ -253,28 +250,13 @@ impl Mstatus {
253
250
/// Note this updates a previously read [`Mstatus`] value, but does not
254
251
/// affect the mstatus CSR itself.
255
252
///
256
- /// **NOTE**: panics on RISCV-32 platforms.
257
- #[ inline]
258
- pub fn set_uxl ( & mut self , uxl : XLEN ) {
259
- self . try_set_uxl ( uxl) . unwrap ( ) ;
260
- }
261
-
262
- /// Attempts to update Effective xlen in U-mode (i.e., `UXLEN`).
253
+ /// # Note
263
254
///
264
- /// Note this updates a previously read [`Mstatus`] value, but does not
265
- /// affect the mstatus CSR itself.
255
+ /// In RISCV-32, `UXL` does not exist, and `UXLEN` is always [`XLEN::XLEN32`].
266
256
#[ inline]
267
- #[ cfg_attr( not( target_arch = "riscv64" ) , allow( unused_variables) ) ]
268
- pub fn try_set_uxl ( & mut self , uxl : XLEN ) -> Result < ( ) > {
269
- match ( ) {
270
- #[ cfg( not( target_arch = "riscv32" ) ) ]
271
- ( ) => {
272
- self . bits = bf_insert ( self . bits , 32 , 2 , uxl as usize ) ;
273
- Ok ( ( ) )
274
- }
275
- #[ cfg( target_arch = "riscv32" ) ]
276
- ( ) => Err ( Error :: Unimplemented ) ,
277
- }
257
+ #[ cfg( not( target_arch = "riscv32" ) ) ]
258
+ pub fn set_uxl ( & mut self , uxl : XLEN ) {
259
+ self . bits = bf_insert ( self . bits , 32 , 2 , uxl as usize ) ;
278
260
}
279
261
280
262
/// Effective xlen in S-mode (i.e., `SXLEN`).
@@ -295,28 +277,13 @@ impl Mstatus {
295
277
/// Note this updates a previously read [`Mstatus`] value, but does not
296
278
/// affect the mstatus CSR itself.
297
279
///
298
- /// **NOTE**: panics on RISCV-32 platforms.
299
- #[ inline]
300
- pub fn set_sxl ( & mut self , sxl : XLEN ) {
301
- self . try_set_sxl ( sxl) . unwrap ( ) ;
302
- }
303
-
304
- /// Attempts to update Effective xlen in S-mode (i.e., `SXLEN`).
280
+ /// # Note
305
281
///
306
- /// Note this updates a previously read [`Mstatus`] value, but does not
307
- /// affect the mstatus CSR itself.
282
+ /// In RISCV-32, `SXL` does not exist, and `SXLEN` is always [`XLEN::XLEN32`].
308
283
#[ inline]
309
- #[ cfg_attr( not( target_arch = "riscv64" ) , allow( unused_variables) ) ]
310
- pub fn try_set_sxl ( & mut self , sxl : XLEN ) -> Result < ( ) > {
311
- match ( ) {
312
- #[ cfg( not( target_arch = "riscv32" ) ) ]
313
- ( ) => {
314
- self . bits = bf_insert ( self . bits , 34 , 2 , sxl as usize ) ;
315
- Ok ( ( ) )
316
- }
317
- #[ cfg( target_arch = "riscv32" ) ]
318
- ( ) => Err ( Error :: Unimplemented ) ,
319
- }
284
+ #[ cfg( not( target_arch = "riscv32" ) ) ]
285
+ pub fn set_sxl ( & mut self , sxl : XLEN ) {
286
+ self . bits = bf_insert ( self . bits , 34 , 2 , sxl as usize ) ;
320
287
}
321
288
322
289
/// S-mode non-instruction-fetch memory endianness.
0 commit comments