@@ -6,7 +6,6 @@ use std::{cmp, iter};
66use rand:: RngCore ;
77use rustc_abi:: { Align , ExternAbi , FieldIdx , FieldsShape , Size , Variants } ;
88use rustc_apfloat:: Float ;
9- use rustc_apfloat:: ieee:: { Double , Half , Quad , Single } ;
109use rustc_hash:: FxHashSet ;
1110use rustc_hir:: Safety ;
1211use rustc_hir:: def:: { DefKind , Namespace } ;
@@ -16,7 +15,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1615use rustc_middle:: middle:: dependency_format:: Linkage ;
1716use rustc_middle:: middle:: exported_symbols:: ExportedSymbol ;
1817use rustc_middle:: ty:: layout:: { LayoutOf , MaybeResult , TyAndLayout } ;
19- use rustc_middle:: ty:: { self , FloatTy , IntTy , Ty , TyCtxt , UintTy } ;
18+ use rustc_middle:: ty:: { self , IntTy , Ty , TyCtxt , UintTy } ;
2019use rustc_session:: config:: CrateType ;
2120use rustc_span:: { Span , Symbol } ;
2221use rustc_symbol_mangling:: mangle_internal_symbol;
@@ -966,75 +965,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
966965 this. alloc_mark_immutable ( provenance. get_alloc_id ( ) . unwrap ( ) ) . unwrap ( ) ;
967966 }
968967
969- /// Converts `src` from floating point to integer type `dest_ty`
970- /// after rounding with mode `round`.
971- /// Returns `None` if `f` is NaN or out of range.
972- fn float_to_int_checked (
973- & self ,
974- src : & ImmTy < ' tcx > ,
975- cast_to : TyAndLayout < ' tcx > ,
976- round : rustc_apfloat:: Round ,
977- ) -> InterpResult < ' tcx , Option < ImmTy < ' tcx > > > {
978- let this = self . eval_context_ref ( ) ;
979-
980- fn float_to_int_inner < ' tcx , F : rustc_apfloat:: Float > (
981- ecx : & MiriInterpCx < ' tcx > ,
982- src : F ,
983- cast_to : TyAndLayout < ' tcx > ,
984- round : rustc_apfloat:: Round ,
985- ) -> ( Scalar , rustc_apfloat:: Status ) {
986- let int_size = cast_to. layout . size ;
987- match cast_to. ty . kind ( ) {
988- // Unsigned
989- ty:: Uint ( _) => {
990- let res = src. to_u128_r ( int_size. bits_usize ( ) , round, & mut false ) ;
991- ( Scalar :: from_uint ( res. value , int_size) , res. status )
992- }
993- // Signed
994- ty:: Int ( _) => {
995- let res = src. to_i128_r ( int_size. bits_usize ( ) , round, & mut false ) ;
996- ( Scalar :: from_int ( res. value , int_size) , res. status )
997- }
998- // Nothing else
999- _ =>
1000- span_bug ! (
1001- ecx. cur_span( ) ,
1002- "attempted float-to-int conversion with non-int output type {}" ,
1003- cast_to. ty,
1004- ) ,
1005- }
1006- }
1007-
1008- let ty:: Float ( fty) = src. layout . ty . kind ( ) else {
1009- bug ! ( "float_to_int_checked: non-float input type {}" , src. layout. ty)
1010- } ;
1011-
1012- let ( val, status) = match fty {
1013- FloatTy :: F16 =>
1014- float_to_int_inner :: < Half > ( this, src. to_scalar ( ) . to_f16 ( ) ?, cast_to, round) ,
1015- FloatTy :: F32 =>
1016- float_to_int_inner :: < Single > ( this, src. to_scalar ( ) . to_f32 ( ) ?, cast_to, round) ,
1017- FloatTy :: F64 =>
1018- float_to_int_inner :: < Double > ( this, src. to_scalar ( ) . to_f64 ( ) ?, cast_to, round) ,
1019- FloatTy :: F128 =>
1020- float_to_int_inner :: < Quad > ( this, src. to_scalar ( ) . to_f128 ( ) ?, cast_to, round) ,
1021- } ;
1022-
1023- if status. intersects (
1024- rustc_apfloat:: Status :: INVALID_OP
1025- | rustc_apfloat:: Status :: OVERFLOW
1026- | rustc_apfloat:: Status :: UNDERFLOW ,
1027- ) {
1028- // Floating point value is NaN (flagged with INVALID_OP) or outside the range
1029- // of values of the integer type (flagged with OVERFLOW or UNDERFLOW).
1030- interp_ok ( None )
1031- } else {
1032- // Floating point value can be represented by the integer type after rounding.
1033- // The INEXACT flag is ignored on purpose to allow rounding.
1034- interp_ok ( Some ( ImmTy :: from_scalar ( val, cast_to) ) )
1035- }
1036- }
1037-
1038968 /// Returns an integer type that is twice wide as `ty`
1039969 fn get_twice_wide_int_ty ( & self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
1040970 let this = self . eval_context_ref ( ) ;
@@ -1199,20 +1129,6 @@ pub(crate) fn bool_to_simd_element(b: bool, size: Size) -> Scalar {
11991129 Scalar :: from_int ( val, size)
12001130}
12011131
1202- pub ( crate ) fn simd_element_to_bool ( elem : ImmTy < ' _ > ) -> InterpResult < ' _ , bool > {
1203- assert ! (
1204- matches!( elem. layout. ty. kind( ) , ty:: Int ( _) | ty:: Uint ( _) ) ,
1205- "SIMD mask element type must be an integer, but this is `{}`" ,
1206- elem. layout. ty
1207- ) ;
1208- let val = elem. to_scalar ( ) . to_int ( elem. layout . size ) ?;
1209- interp_ok ( match val {
1210- 0 => false ,
1211- -1 => true ,
1212- _ => throw_ub_format ! ( "each element of a SIMD mask must be all-0-bits or all-1-bits" ) ,
1213- } )
1214- }
1215-
12161132/// Check whether an operation that writes to a target buffer was successful.
12171133/// Accordingly select return value.
12181134/// Local helper function to be used in Windows shims.
0 commit comments