Skip to content

Commit c6ea29f

Browse files
committed
Auto merge of #147512 - Zalathar:rollup-p8kb5f7, r=Zalathar
Rollup of 12 pull requests Successful merges: - rust-lang/rust#146568 (Port the implemention of SIMD intrinsics from Miri to const-eval) - rust-lang/rust#147373 (give a better example why `std` modules named like primitives are needed) - rust-lang/rust#147419 (bootstrap: add `Builder::rustc_cmd` that includes the lib path) - rust-lang/rust#147420 (Add diagnostic items for `pub mod consts` of FP types) - rust-lang/rust#147457 (specialize slice::fill to use memset when possible) - rust-lang/rust#147467 (Fix double warnings on `#[no_mangle]`) - rust-lang/rust#147470 (Clarify how to remediate the panic_immediate_abort error) - rust-lang/rust#147480 (Do not invalidate CFG caches in CtfeLimit.) - rust-lang/rust#147481 (format: some small cleanup) - rust-lang/rust#147488 (refactor: Remove `LLVMRustInsertPrivateGlobal` and `define_private_global`) - rust-lang/rust#147489 (Prefer to use repeat_n over repeat().take()) - rust-lang/rust#147506 (compiletest: Isolate public APIs and minimize public surface area) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b8cda32 + b17aa3f commit c6ea29f

File tree

3 files changed

+45
-790
lines changed

3 files changed

+45
-790
lines changed

src/helpers.rs

Lines changed: 1 addition & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::{cmp, iter};
55
use rand::RngCore;
66
use rustc_abi::{Align, ExternAbi, FieldIdx, FieldsShape, Size, Variants};
77
use rustc_apfloat::Float;
8-
use rustc_apfloat::ieee::{Double, Half, Quad, Single};
98
use rustc_hir::Safety;
109
use rustc_hir::def::{DefKind, Namespace};
1110
use rustc_hir::def_id::{CRATE_DEF_INDEX, CrateNum, DefId, LOCAL_CRATE};
@@ -14,7 +13,7 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
1413
use rustc_middle::middle::dependency_format::Linkage;
1514
use rustc_middle::middle::exported_symbols::ExportedSymbol;
1615
use rustc_middle::ty::layout::{LayoutOf, MaybeResult, TyAndLayout};
17-
use rustc_middle::ty::{self, FloatTy, IntTy, Ty, TyCtxt, UintTy};
16+
use rustc_middle::ty::{self, IntTy, Ty, TyCtxt, UintTy};
1817
use rustc_session::config::CrateType;
1918
use rustc_span::{Span, Symbol};
2019
use rustc_symbol_mangling::mangle_internal_symbol;
@@ -961,75 +960,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
961960
this.alloc_mark_immutable(provenance.get_alloc_id().unwrap()).unwrap();
962961
}
963962

964-
/// Converts `src` from floating point to integer type `dest_ty`
965-
/// after rounding with mode `round`.
966-
/// Returns `None` if `f` is NaN or out of range.
967-
fn float_to_int_checked(
968-
&self,
969-
src: &ImmTy<'tcx>,
970-
cast_to: TyAndLayout<'tcx>,
971-
round: rustc_apfloat::Round,
972-
) -> InterpResult<'tcx, Option<ImmTy<'tcx>>> {
973-
let this = self.eval_context_ref();
974-
975-
fn float_to_int_inner<'tcx, F: rustc_apfloat::Float>(
976-
ecx: &MiriInterpCx<'tcx>,
977-
src: F,
978-
cast_to: TyAndLayout<'tcx>,
979-
round: rustc_apfloat::Round,
980-
) -> (Scalar, rustc_apfloat::Status) {
981-
let int_size = cast_to.layout.size;
982-
match cast_to.ty.kind() {
983-
// Unsigned
984-
ty::Uint(_) => {
985-
let res = src.to_u128_r(int_size.bits_usize(), round, &mut false);
986-
(Scalar::from_uint(res.value, int_size), res.status)
987-
}
988-
// Signed
989-
ty::Int(_) => {
990-
let res = src.to_i128_r(int_size.bits_usize(), round, &mut false);
991-
(Scalar::from_int(res.value, int_size), res.status)
992-
}
993-
// Nothing else
994-
_ =>
995-
span_bug!(
996-
ecx.cur_span(),
997-
"attempted float-to-int conversion with non-int output type {}",
998-
cast_to.ty,
999-
),
1000-
}
1001-
}
1002-
1003-
let ty::Float(fty) = src.layout.ty.kind() else {
1004-
bug!("float_to_int_checked: non-float input type {}", src.layout.ty)
1005-
};
1006-
1007-
let (val, status) = match fty {
1008-
FloatTy::F16 =>
1009-
float_to_int_inner::<Half>(this, src.to_scalar().to_f16()?, cast_to, round),
1010-
FloatTy::F32 =>
1011-
float_to_int_inner::<Single>(this, src.to_scalar().to_f32()?, cast_to, round),
1012-
FloatTy::F64 =>
1013-
float_to_int_inner::<Double>(this, src.to_scalar().to_f64()?, cast_to, round),
1014-
FloatTy::F128 =>
1015-
float_to_int_inner::<Quad>(this, src.to_scalar().to_f128()?, cast_to, round),
1016-
};
1017-
1018-
if status.intersects(
1019-
rustc_apfloat::Status::INVALID_OP
1020-
| rustc_apfloat::Status::OVERFLOW
1021-
| rustc_apfloat::Status::UNDERFLOW,
1022-
) {
1023-
// Floating point value is NaN (flagged with INVALID_OP) or outside the range
1024-
// of values of the integer type (flagged with OVERFLOW or UNDERFLOW).
1025-
interp_ok(None)
1026-
} else {
1027-
// Floating point value can be represented by the integer type after rounding.
1028-
// The INEXACT flag is ignored on purpose to allow rounding.
1029-
interp_ok(Some(ImmTy::from_scalar(val, cast_to)))
1030-
}
1031-
}
1032-
1033963
/// Returns an integer type that is twice wide as `ty`
1034964
fn get_twice_wide_int_ty(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
1035965
let this = self.eval_context_ref();
@@ -1194,20 +1124,6 @@ pub(crate) fn bool_to_simd_element(b: bool, size: Size) -> Scalar {
11941124
Scalar::from_int(val, size)
11951125
}
11961126

1197-
pub(crate) fn simd_element_to_bool(elem: ImmTy<'_>) -> InterpResult<'_, bool> {
1198-
assert!(
1199-
matches!(elem.layout.ty.kind(), ty::Int(_) | ty::Uint(_)),
1200-
"SIMD mask element type must be an integer, but this is `{}`",
1201-
elem.layout.ty
1202-
);
1203-
let val = elem.to_scalar().to_int(elem.layout.size)?;
1204-
interp_ok(match val {
1205-
0 => false,
1206-
-1 => true,
1207-
_ => throw_ub_format!("each element of a SIMD mask must be all-0-bits or all-1-bits"),
1208-
})
1209-
}
1210-
12111127
/// Check whether an operation that writes to a target buffer was successful.
12121128
/// Accordingly select return value.
12131129
/// Local helper function to be used in Windows shims.

src/intrinsics/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
118118
return this.emulate_atomic_intrinsic(name, generic_args, args, dest);
119119
}
120120
if let Some(name) = intrinsic_name.strip_prefix("simd_") {
121-
return this.emulate_simd_intrinsic(name, generic_args, args, dest);
121+
return this.emulate_simd_intrinsic(name, args, dest);
122122
}
123123

124124
match intrinsic_name {

0 commit comments

Comments
 (0)