Skip to content

Commit

Permalink
Add f16 and f128 support to Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Jun 13, 2024
1 parent f37104f commit 0cedee1
Show file tree
Hide file tree
Showing 2 changed files with 365 additions and 100 deletions.
8 changes: 5 additions & 3 deletions src/tools/miri/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::time::Duration;

use rand::RngCore;

use rustc_apfloat::ieee::{Double, Single};
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
use rustc_apfloat::Float;
use rustc_hir::{
def::{DefKind, Namespace},
Expand Down Expand Up @@ -1201,12 +1201,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
};

let (val, status) = match fty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F16 =>
float_to_int_inner::<Half>(this, src.to_scalar().to_f16()?, cast_to, round),
FloatTy::F32 =>
float_to_int_inner::<Single>(this, src.to_scalar().to_f32()?, cast_to, round),
FloatTy::F64 =>
float_to_int_inner::<Double>(this, src.to_scalar().to_f64()?, cast_to, round),
FloatTy::F128 => unimplemented!("f16_f128"),
FloatTy::F128 =>
float_to_int_inner::<Quad>(this, src.to_scalar().to_f128()?, cast_to, round),
};

if status.intersects(
Expand Down
Loading

0 comments on commit 0cedee1

Please sign in to comment.