Skip to content

Commit c1032d4

Browse files
committed
Add changes for 32-bit floating point subtraction
1 parent b351e7e commit c1032d4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

arch/inst/F/fsub.s.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ kind: instruction
55
name: fsub.s
66
long_name: No synopsis available.
77
description: |
8-
No description available.
8+
Do the single-precision floating-point subtraction of fs2 from fs1 and store the result in fd. rm is the dynamic Rounding Mode.
99
definedBy: F
1010
assembly: fd, fs1, fs2, rm
1111
encoding:
@@ -26,7 +26,8 @@ access:
2626
vu: always
2727
data_independent_timing: true
2828
operation(): |
29-
29+
RoundingMode mode = rm_to_mode(X[rm], $encoding);
30+
X[fd] = f32_sub(X[fs1], X[fs2], mode);
3031
sail(): |
3132
{
3233
let rs1_val_32b = F_or_X_S(rs1);

arch/isa/fp.idl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,3 +861,24 @@ function f32_add {
861861
}
862862
}
863863
}
864+
865+
function f32_sub {
866+
returns U32
867+
arguments
868+
U32 a,
869+
U32 b,
870+
RoundingMode mode
871+
description {
872+
Returns difference of 2 floating point numbers
873+
}
874+
body {
875+
U32 a_xor_b = a ^ b;
876+
if (signF32UI(a_xor_b) == 1) {
877+
# add if signs are different
878+
return softfloat_addMagsF32(a,b,mode);
879+
} else {
880+
# subtract if signs are the same
881+
return softfloat_subMagsF32(a,b,mode);
882+
}
883+
}
884+
}

0 commit comments

Comments
 (0)