Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/inst/F/fadd.s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ access:
vu: always
data_independent_timing: true
operation(): |
check_f_ok($encoding);
RoundingMode mode = rm_to_mode(X[rm], $encoding);
X[fd] = f32_add(X[fs1], X[fs2], mode);

Expand Down
16 changes: 2 additions & 14 deletions arch/inst/F/fcvt.s.w.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,8 @@ access:
data_independent_timing: false
operation(): |
check_f_ok($encoding);

Bits<32> int_value = X[rs1];

Bits<1> sign = int_value[31];

RoundingMode rounding_mode = rm_to_mode(rm, $encoding);

if ((int_value & 32'h7fff_ffff) == 0) {
X[fd] = (sign == 1) ? packToF32UI(1, 0x9E, 0) : 0;
} else {
Bits<32> absA = (sign == 1) ? -int_value : int_value;
X[fd] = softfloat_normRoundPackToF32( sign, 0x9C, absA, rounding_mode );
}

RoundingMode rounding_mode = rm_to_mode(X[rm], $encoding);
X[fd] = i32_to_f32(X[rs1], rounding_mode);
mark_f_state_dirty();

sail(): |
Expand Down
1 change: 1 addition & 0 deletions arch/inst/F/fsub.s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ access:
vu: always
data_independent_timing: true
operation(): |
check_f_ok($encoding);
RoundingMode mode = rm_to_mode(X[rm], $encoding);
X[fd] = f32_sub(X[fs1], X[fs2], mode);
sail(): |
Expand Down
19 changes: 19 additions & 0 deletions arch/isa/fp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,22 @@ function f32_sub {
}
}
}

function i32_to_f32 {
returns U32
arguments
U32 a,
RoundingMode mode
description {
Converts 32-bit signed integer to 32-bit floating point
}
body {
# sign of integer, it is 1 when negative
Bits<1> sign = a[31];
if ((a & 0x7FFFFFFF) == 0) {
return (sign == 1) ? packToF32UI(1, 0x9E, 0) : packToF32UI(0, 0, 0);
}
U32 magnitude_of_A = returnMag(a);
return softfloat_normRoundPackToF32(sign, 0x9C, magnitude_of_A, mode);
}
}
Loading