Sync from rust 9c3ad802d9b9633d60d3a74668eb1be819212d34
This commit is contained in:
commit
dd7117b543
@ -4,17 +4,14 @@
|
|||||||
|
|
||||||
// Test that the simd_f{min,max} intrinsics produce the correct results.
|
// Test that the simd_f{min,max} intrinsics produce the correct results.
|
||||||
|
|
||||||
#![feature(repr_simd, platform_intrinsics)]
|
#![feature(repr_simd, core_intrinsics)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
#[repr(simd)]
|
#[repr(simd)]
|
||||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||||
struct f32x4(pub f32, pub f32, pub f32, pub f32);
|
struct f32x4(pub f32, pub f32, pub f32, pub f32);
|
||||||
|
|
||||||
extern "platform-intrinsic" {
|
use std::intrinsics::simd::*;
|
||||||
fn simd_fmin<T>(x: T, y: T) -> T;
|
|
||||||
fn simd_fmax<T>(x: T, y: T) -> T;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = f32x4(1.0, 2.0, 3.0, 4.0);
|
let x = f32x4(1.0, 2.0, 3.0, 4.0);
|
||||||
|
@ -525,8 +525,11 @@ pub struct Unique<T: ?Sized> {
|
|||||||
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
||||||
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
impl<T: ?Sized, U: ?Sized> DispatchFromDyn<Unique<U>> for Unique<T> where T: Unsize<U> {}
|
||||||
|
|
||||||
|
#[lang = "global_alloc_ty"]
|
||||||
|
pub struct Global;
|
||||||
|
|
||||||
#[lang = "owned_box"]
|
#[lang = "owned_box"]
|
||||||
pub struct Box<T: ?Sized, A = ()>(Unique<T>, A);
|
pub struct Box<T: ?Sized, A = Global>(Unique<T>, A);
|
||||||
|
|
||||||
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
|
||||||
|
|
||||||
@ -536,7 +539,7 @@ impl<T> Box<T> {
|
|||||||
let size = intrinsics::size_of::<T>();
|
let size = intrinsics::size_of::<T>();
|
||||||
let ptr = libc::malloc(size);
|
let ptr = libc::malloc(size);
|
||||||
intrinsics::copy(&val as *const T as *const u8, ptr, size);
|
intrinsics::copy(&val as *const T as *const u8, ptr, size);
|
||||||
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, ())
|
Box(Unique { pointer: NonNull(ptr as *const T), _marker: PhantomData }, Global)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
47
patches/0029-stdlib-rawdylib-processprng.patch
Normal file
47
patches/0029-stdlib-rawdylib-processprng.patch
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
From 9f65e742ba3e41474e6126c6c4469c48eaa6ca7e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Chris Denton <chris@chrisdenton.dev>
|
||||||
|
Date: Tue, 20 Feb 2024 16:01:40 -0300
|
||||||
|
Subject: [PATCH] Don't use raw-dylib in std
|
||||||
|
|
||||||
|
---
|
||||||
|
library/std/src/sys/pal/windows/c.rs | 2 +-
|
||||||
|
library/std/src/sys/pal/windows/rand.rs | 3 +--
|
||||||
|
2 files changed, 2 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/library/std/src/sys/pal/windows/c.rs b/library/std/src/sys/pal/windows/c.rs
|
||||||
|
index ad8e01bfa9b..9ca8e4c16ce 100644
|
||||||
|
--- a/library/std/src/sys/pal/windows/c.rs
|
||||||
|
+++ b/library/std/src/sys/pal/windows/c.rs
|
||||||
|
@@ -323,7 +323,7 @@ pub unsafe fn NtWriteFile(
|
||||||
|
|
||||||
|
// Use raw-dylib to import ProcessPrng as we can't rely on there being an import library.
|
||||||
|
cfg_if::cfg_if! {
|
||||||
|
-if #[cfg(not(target_vendor = "win7"))] {
|
||||||
|
+if #[cfg(any())] {
|
||||||
|
#[cfg(target_arch = "x86")]
|
||||||
|
#[link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated")]
|
||||||
|
extern "system" {
|
||||||
|
diff --git a/library/std/src/sys/pal/windows/rand.rs b/library/std/src/sys/pal/windows/rand.rs
|
||||||
|
index e427546222a..f2fe42a4d51 100644
|
||||||
|
--- a/library/std/src/sys/pal/windows/rand.rs
|
||||||
|
+++ b/library/std/src/sys/pal/windows/rand.rs
|
||||||
|
@@ -2,7 +2,7 @@
|
||||||
|
use core::mem;
|
||||||
|
use core::ptr;
|
||||||
|
|
||||||
|
-#[cfg(not(target_vendor = "win7"))]
|
||||||
|
+#[cfg(any())]
|
||||||
|
#[inline]
|
||||||
|
pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
|
let mut v = (0, 0);
|
||||||
|
@@ -13,7 +13,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
-#[cfg(target_vendor = "win7")]
|
||||||
|
pub fn hashmap_random_keys() -> (u64, u64) {
|
||||||
|
use crate::ffi::c_void;
|
||||||
|
use crate::io;
|
||||||
|
--
|
||||||
|
2.42.0.windows.2
|
||||||
|
|
@ -8,7 +8,7 @@ use rustc_session::Session;
|
|||||||
pub(crate) struct ArArchiveBuilderBuilder;
|
pub(crate) struct ArArchiveBuilderBuilder;
|
||||||
|
|
||||||
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
|
impl ArchiveBuilderBuilder for ArArchiveBuilderBuilder {
|
||||||
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder<'a> + 'a> {
|
fn new_archive_builder<'a>(&self, sess: &'a Session) -> Box<dyn ArchiveBuilder + 'a> {
|
||||||
Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols))
|
Box::new(ArArchiveBuilder::new(sess, get_native_object_symbols))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,10 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type {
|
|||||||
Integer::I64 => types::I64,
|
Integer::I64 => types::I64,
|
||||||
Integer::I128 => types::I128,
|
Integer::I128 => types::I128,
|
||||||
},
|
},
|
||||||
|
Primitive::F16 => unimplemented!("f16_f128"),
|
||||||
Primitive::F32 => types::F32,
|
Primitive::F32 => types::F32,
|
||||||
Primitive::F64 => types::F64,
|
Primitive::F64 => types::F64,
|
||||||
|
Primitive::F128 => unimplemented!("f16_f128"),
|
||||||
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
// FIXME(erikdesjardins): handle non-default addrspace ptr sizes
|
||||||
Primitive::Pointer(_) => pointer_ty(tcx),
|
Primitive::Pointer(_) => pointer_ty(tcx),
|
||||||
}
|
}
|
||||||
@ -61,8 +63,10 @@ fn clif_type_from_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<types::Typ
|
|||||||
},
|
},
|
||||||
ty::Char => types::I32,
|
ty::Char => types::I32,
|
||||||
ty::Float(size) => match size {
|
ty::Float(size) => match size {
|
||||||
|
FloatTy::F16 => unimplemented!("f16_f128"),
|
||||||
FloatTy::F32 => types::F32,
|
FloatTy::F32 => types::F32,
|
||||||
FloatTy::F64 => types::F64,
|
FloatTy::F64 => types::F64,
|
||||||
|
FloatTy::F128 => unimplemented!("f16_f128"),
|
||||||
},
|
},
|
||||||
ty::FnPtr(_) => pointer_ty(tcx),
|
ty::FnPtr(_) => pointer_ty(tcx),
|
||||||
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
|
ty::RawPtr(TypeAndMut { ty: pointee_ty, mutbl: _ }) | ty::Ref(_, pointee_ty, _) => {
|
||||||
|
@ -23,7 +23,7 @@ use rustc_middle::ty::layout::{HasParamEnv, ValidityRequirement};
|
|||||||
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
|
use rustc_middle::ty::print::{with_no_trimmed_paths, with_no_visible_paths};
|
||||||
use rustc_middle::ty::GenericArgsRef;
|
use rustc_middle::ty::GenericArgsRef;
|
||||||
use rustc_span::source_map::Spanned;
|
use rustc_span::source_map::Spanned;
|
||||||
use rustc_span::symbol::{kw, sym, Symbol};
|
use rustc_span::symbol::{sym, Symbol};
|
||||||
|
|
||||||
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
|
pub(crate) use self::llvm::codegen_llvm_intrinsic_call;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
@ -1132,7 +1132,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
ret.write_cvalue(fx, val);
|
ret.write_cvalue(fx, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
kw::Try => {
|
sym::catch_unwind => {
|
||||||
intrinsic_args!(fx, args => (f, data, catch_fn); intrinsic);
|
intrinsic_args!(fx, args => (f, data, catch_fn); intrinsic);
|
||||||
let f = f.load_scalar(fx);
|
let f = f.load_scalar(fx);
|
||||||
let data = data.load_scalar(fx);
|
let data = data.load_scalar(fx);
|
||||||
@ -1152,17 +1152,26 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
ret.write_cvalue(fx, ret_val);
|
ret.write_cvalue(fx, ret_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
sym::fadd_fast | sym::fsub_fast | sym::fmul_fast | sym::fdiv_fast | sym::frem_fast => {
|
sym::fadd_fast
|
||||||
|
| sym::fsub_fast
|
||||||
|
| sym::fmul_fast
|
||||||
|
| sym::fdiv_fast
|
||||||
|
| sym::frem_fast
|
||||||
|
| sym::fadd_algebraic
|
||||||
|
| sym::fsub_algebraic
|
||||||
|
| sym::fmul_algebraic
|
||||||
|
| sym::fdiv_algebraic
|
||||||
|
| sym::frem_algebraic => {
|
||||||
intrinsic_args!(fx, args => (x, y); intrinsic);
|
intrinsic_args!(fx, args => (x, y); intrinsic);
|
||||||
|
|
||||||
let res = crate::num::codegen_float_binop(
|
let res = crate::num::codegen_float_binop(
|
||||||
fx,
|
fx,
|
||||||
match intrinsic {
|
match intrinsic {
|
||||||
sym::fadd_fast => BinOp::Add,
|
sym::fadd_fast | sym::fadd_algebraic => BinOp::Add,
|
||||||
sym::fsub_fast => BinOp::Sub,
|
sym::fsub_fast | sym::fsub_algebraic => BinOp::Sub,
|
||||||
sym::fmul_fast => BinOp::Mul,
|
sym::fmul_fast | sym::fmul_algebraic => BinOp::Mul,
|
||||||
sym::fdiv_fast => BinOp::Div,
|
sym::fdiv_fast | sym::fdiv_algebraic => BinOp::Div,
|
||||||
sym::frem_fast => BinOp::Rem,
|
sym::frem_fast | sym::frem_algebraic => BinOp::Rem,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
x,
|
x,
|
||||||
@ -1246,7 +1255,17 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||||||
|
|
||||||
// Unimplemented intrinsics must have a fallback body. The fallback body is obtained
|
// Unimplemented intrinsics must have a fallback body. The fallback body is obtained
|
||||||
// by converting the `InstanceDef::Intrinsic` to an `InstanceDef::Item`.
|
// by converting the `InstanceDef::Intrinsic` to an `InstanceDef::Item`.
|
||||||
_ => return Err(Instance::new(instance.def_id(), instance.args)),
|
_ => {
|
||||||
|
let intrinsic = fx.tcx.intrinsic(instance.def_id()).unwrap();
|
||||||
|
if intrinsic.must_be_overridden {
|
||||||
|
span_bug!(
|
||||||
|
source_info.span,
|
||||||
|
"intrinsic {} must be overridden by codegen_cranelift, but isn't",
|
||||||
|
intrinsic.name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Err(Instance::new(instance.def_id(), instance.args));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ret_block = fx.get_block(destination.unwrap());
|
let ret_block = fx.get_block(destination.unwrap());
|
||||||
|
@ -743,7 +743,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
simd_reduce(fx, v, None, ret, &|fx, _ty, a, b| fx.bcx.ins().bxor(a, b));
|
simd_reduce(fx, v, None, ret, &|fx, _ty, a, b| fx.bcx.ins().bxor(a, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
sym::simd_reduce_min | sym::simd_reduce_min_nanless => {
|
sym::simd_reduce_min => {
|
||||||
intrinsic_args!(fx, args => (v); intrinsic);
|
intrinsic_args!(fx, args => (v); intrinsic);
|
||||||
|
|
||||||
if !v.layout().ty.is_simd() {
|
if !v.layout().ty.is_simd() {
|
||||||
@ -762,7 +762,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sym::simd_reduce_max | sym::simd_reduce_max_nanless => {
|
sym::simd_reduce_max => {
|
||||||
intrinsic_args!(fx, args => (v); intrinsic);
|
intrinsic_args!(fx, args => (v); intrinsic);
|
||||||
|
|
||||||
if !v.layout().ty.is_simd() {
|
if !v.layout().ty.is_simd() {
|
||||||
|
@ -74,10 +74,6 @@ fn unsize_ptr<'tcx>(
|
|||||||
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
| (&ty::RawPtr(ty::TypeAndMut { ty: a, .. }), &ty::RawPtr(ty::TypeAndMut { ty: b, .. })) => {
|
||||||
(src, unsized_info(fx, *a, *b, old_info))
|
(src, unsized_info(fx, *a, *b, old_info))
|
||||||
}
|
}
|
||||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) if def_a.is_box() && def_b.is_box() => {
|
|
||||||
let (a, b) = (src_layout.ty.boxed_ty(), dst_layout.ty.boxed_ty());
|
|
||||||
(src, unsized_info(fx, a, b, old_info))
|
|
||||||
}
|
|
||||||
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
(&ty::Adt(def_a, _), &ty::Adt(def_b, _)) => {
|
||||||
assert_eq!(def_a, def_b);
|
assert_eq!(def_a, def_b);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user