Skip to content

Commit 8421c56

Browse files
committed
perf(port_riscv): clear mstatus.FS[1] on trap entry
> Clear `mstatus.FS[1]` to indicate that FP registers are not in use in > the current invocation of the trap handler (it'll be set again on > first use).
1 parent eba8133 commit 8421c56

File tree

1 file changed

+5
-1
lines changed
  • src/constance_port_riscv/src/threading

1 file changed

+5
-1
lines changed

src/constance_port_riscv/src/threading/imp.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,9 @@ impl State {
12251225
12261226
" if cfg!(target_feature = "f") { "
12271227
# If FP registers are in use, push FLS.F to the background
1228-
# context's stack
1228+
# context's stack. Clear `mstatus.FS[1]` to indicate that
1229+
# FP registers are not in use in the current invocation of
1230+
# the trap handler (it'll be set again on first use).
12291231
#
12301232
# <a2 = mstatus_part>
12311233
# if mstatus_part.FS[1] != 0:
@@ -1235,6 +1237,7 @@ impl State {
12351237
# sp['fa0'-'fa7'] = [fa0-fa7];
12361238
# sp['ft8'-'ft11'] = [ft8-ft11];
12371239
# sp.fcsr = fcsr;
1240+
# mstatus.FS[1] = 0;
12381241
#
12391242
# let background_sp = sp;
12401243
# <a2 = mstatus_part>
@@ -1243,6 +1246,7 @@ impl State {
12431246
and a1, a1, a2
12441247
beqz a1, 0f # → PushFLSFEnd
12451248
1249+
csrc mstatus, a1
12461250
csrr a1, fcsr
12471251
12481252
addi sp, sp, -{FLSF_SIZE}

0 commit comments

Comments
 (0)