Skip to content

Commit 6b41a65

Browse files
committed
Add f16 and f128 support to Miri
1 parent 50a4ca6 commit 6b41a65

File tree

2 files changed

+365
-100
lines changed

2 files changed

+365
-100
lines changed

src/tools/miri/src/helpers.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::Duration;
77

88
use rand::RngCore;
99

10-
use rustc_apfloat::ieee::{Double, Single};
10+
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
1111
use rustc_apfloat::Float;
1212
use rustc_hir::{
1313
def::{DefKind, Namespace},
@@ -1201,12 +1201,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
12011201
};
12021202

12031203
let (val, status) = match fty {
1204-
FloatTy::F16 => unimplemented!("f16_f128"),
1204+
FloatTy::F16 =>
1205+
float_to_int_inner::<Half>(this, src.to_scalar().to_f16()?, cast_to, round),
12051206
FloatTy::F32 =>
12061207
float_to_int_inner::<Single>(this, src.to_scalar().to_f32()?, cast_to, round),
12071208
FloatTy::F64 =>
12081209
float_to_int_inner::<Double>(this, src.to_scalar().to_f64()?, cast_to, round),
1209-
FloatTy::F128 => unimplemented!("f16_f128"),
1210+
FloatTy::F128 =>
1211+
float_to_int_inner::<Quad>(this, src.to_scalar().to_f128()?, cast_to, round),
12101212
};
12111213

12121214
if status.intersects(

0 commit comments

Comments
 (0)