1
Fork 0

Add stubs for f16 and f128 to miri

This commit is contained in:
Trevor Gross 2024-02-28 03:55:14 -05:00
parent ae70502a2e
commit c17a516a3a

View file

@ -83,8 +83,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let op = op.to_scalar(); let op = op.to_scalar();
// "Bitwise" operation, no NaN adjustments // "Bitwise" operation, no NaN adjustments
match float_ty { match float_ty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => Scalar::from_f32(op.to_f32()?.abs()), FloatTy::F32 => Scalar::from_f32(op.to_f32()?.abs()),
FloatTy::F64 => Scalar::from_f64(op.to_f64()?.abs()), FloatTy::F64 => Scalar::from_f64(op.to_f64()?.abs()),
FloatTy::F128 => unimplemented!("f16_f128"),
} }
} }
Op::Sqrt => { Op::Sqrt => {
@ -93,6 +95,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
}; };
// FIXME using host floats // FIXME using host floats
match float_ty { match float_ty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => { FloatTy::F32 => {
let f = op.to_scalar().to_f32()?; let f = op.to_scalar().to_f32()?;
let res = f.to_host().sqrt().to_soft(); let res = f.to_host().sqrt().to_soft();
@ -105,6 +108,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let res = this.adjust_nan(res, &[f]); let res = this.adjust_nan(res, &[f]);
Scalar::from(res) Scalar::from(res)
} }
FloatTy::F128 => unimplemented!("f16_f128"),
} }
} }
Op::Round(rounding) => { Op::Round(rounding) => {
@ -112,6 +116,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name) span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name)
}; };
match float_ty { match float_ty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => { FloatTy::F32 => {
let f = op.to_scalar().to_f32()?; let f = op.to_scalar().to_f32()?;
let res = f.round_to_integral(rounding).value; let res = f.round_to_integral(rounding).value;
@ -124,6 +129,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let res = this.adjust_nan(res, &[f]); let res = this.adjust_nan(res, &[f]);
Scalar::from_f64(res) Scalar::from_f64(res)
} }
FloatTy::F128 => unimplemented!("f16_f128"),
} }
} }
Op::Numeric(name) => { Op::Numeric(name) => {
@ -267,6 +273,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name) span_bug!(this.cur_span(), "{} operand is not a float", intrinsic_name)
}; };
let val = match float_ty { let val = match float_ty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => { FloatTy::F32 => {
let a = a.to_f32()?; let a = a.to_f32()?;
let b = b.to_f32()?; let b = b.to_f32()?;
@ -283,6 +290,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let res = this.adjust_nan(res, &[a, b, c]); let res = this.adjust_nan(res, &[a, b, c]);
Scalar::from(res) Scalar::from(res)
} }
FloatTy::F128 => unimplemented!("f16_f128"),
}; };
this.write_scalar(val, &dest)?; this.write_scalar(val, &dest)?;
} }
@ -724,6 +732,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let left = left.to_scalar(); let left = left.to_scalar();
let right = right.to_scalar(); let right = right.to_scalar();
Ok(match float_ty { Ok(match float_ty {
FloatTy::F16 => unimplemented!("f16_f128"),
FloatTy::F32 => { FloatTy::F32 => {
let left = left.to_f32()?; let left = left.to_f32()?;
let right = right.to_f32()?; let right = right.to_f32()?;
@ -744,6 +753,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
let res = this.adjust_nan(res, &[left, right]); let res = this.adjust_nan(res, &[left, right]);
Scalar::from_f64(res) Scalar::from_f64(res)
} }
FloatTy::F128 => unimplemented!("f16_f128"),
}) })
} }
} }