Skip to content

Commit 5aee853

Browse files
committed
Fix and simplify fmv execute clauses
Simplify the implementations with fewer intermediate variables, and fix compilation of RV64F. I also added relevant quote from the spec because the spec for these instructions is very confusing. This is a prime candidate for getting Sail code into the spec.
1 parent fae8e8b commit 5aee853

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

model/riscv_insts_dext.sail

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -934,18 +934,14 @@ function clause execute (F_UN_TYPE_D(rs1, rd, FCLASS_D)) = {
934934
}
935935

936936
function clause execute (F_UN_TYPE_D(rs1, rd, FMV_X_D)) = {
937-
assert(xlen >= 64);
938-
let rs1_val_D = F(rs1)[63..0];
939-
let rd_val_X : xlenbits = sign_extend(rs1_val_D);
940-
X(rd) = rd_val_X;
937+
assert(xlen >= 64 & flen >= 64);
938+
X(rd) = sign_extend(F(rs1)[63..0]);
941939
RETIRE_SUCCESS
942940
}
943941

944942
function clause execute (F_UN_TYPE_D(rs1, rd, FMV_D_X)) = {
945-
assert(xlen >= 64);
946-
let rs1_val_X = X(rs1);
947-
let rd_val_D = rs1_val_X [63..0];
948-
F(rd) = rd_val_D;
943+
assert(xlen >= 64 & flen >= 64);
944+
F(rd) = nan_box(X(rs1)[63..0]);
949945
RETIRE_SUCCESS
950946
}
951947

model/riscv_insts_fext.sail

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,16 +1061,12 @@ function clause execute (F_UN_TYPE_S(rs1, rd, FCLASS_S)) = {
10611061
}
10621062

10631063
function clause execute (F_UN_TYPE_S(rs1, rd, FMV_X_W)) = {
1064-
let rs1_val_S = F(rs1)[31..0];
1065-
let rd_val_X : xlenbits = sign_extend(rs1_val_S);
1066-
X(rd) = rd_val_X;
1064+
X(rd) = sign_extend(F(rs1)[31..0]);
10671065
RETIRE_SUCCESS
10681066
}
10691067

10701068
function clause execute (F_UN_TYPE_S(rs1, rd, FMV_W_X)) = {
1071-
let rs1_val_X = X(rs1);
1072-
let rd_val_S = rs1_val_X [31..0];
1073-
F(rd) = nan_box (rd_val_S);
1069+
F(rd) = nan_box(X(rs1)[31..0]);
10741070
RETIRE_SUCCESS
10751071
}
10761072

0 commit comments

Comments
 (0)