Skip to content

Commit 7874766

Browse files
committed
Sync from rust 85abb27
2 parents 2695a19 + 309d6b0 commit 7874766

File tree

5 files changed

+31
-126
lines changed

5 files changed

+31
-126
lines changed

example/mini_core.rs

+13-52
Original file line numberDiff line numberDiff line change
@@ -620,70 +620,31 @@ pub union MaybeUninit<T> {
620620

621621
pub mod intrinsics {
622622
#[rustc_intrinsic]
623-
#[rustc_intrinsic_must_be_overridden]
624-
pub fn abort() -> ! {
625-
loop {}
626-
}
623+
pub fn abort() -> !;
627624
#[rustc_intrinsic]
628-
#[rustc_intrinsic_must_be_overridden]
629-
pub fn size_of<T>() -> usize {
630-
loop {}
631-
}
625+
pub fn size_of<T>() -> usize;
632626
#[rustc_intrinsic]
633-
#[rustc_intrinsic_must_be_overridden]
634-
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize {
635-
loop {}
636-
}
627+
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize;
637628
#[rustc_intrinsic]
638-
#[rustc_intrinsic_must_be_overridden]
639-
pub fn min_align_of<T>() -> usize {
640-
loop {}
641-
}
629+
pub fn min_align_of<T>() -> usize;
642630
#[rustc_intrinsic]
643-
#[rustc_intrinsic_must_be_overridden]
644-
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize {
645-
loop {}
646-
}
631+
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize;
647632
#[rustc_intrinsic]
648-
#[rustc_intrinsic_must_be_overridden]
649-
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) {
650-
loop {}
651-
}
633+
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize);
652634
#[rustc_intrinsic]
653-
#[rustc_intrinsic_must_be_overridden]
654-
pub unsafe fn transmute<T, U>(_e: T) -> U {
655-
loop {}
656-
}
635+
pub unsafe fn transmute<T, U>(_e: T) -> U;
657636
#[rustc_intrinsic]
658-
#[rustc_intrinsic_must_be_overridden]
659-
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 {
660-
loop {}
661-
}
637+
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32;
662638
#[rustc_intrinsic]
663-
#[rustc_intrinsic_must_be_overridden]
664-
pub fn needs_drop<T: ?::Sized>() -> bool {
665-
loop {}
666-
}
639+
pub fn needs_drop<T: ?::Sized>() -> bool;
667640
#[rustc_intrinsic]
668-
#[rustc_intrinsic_must_be_overridden]
669-
pub fn bitreverse<T>(_x: T) -> T {
670-
loop {}
671-
}
641+
pub fn bitreverse<T>(_x: T) -> T;
672642
#[rustc_intrinsic]
673-
#[rustc_intrinsic_must_be_overridden]
674-
pub fn bswap<T>(_x: T) -> T {
675-
loop {}
676-
}
643+
pub fn bswap<T>(_x: T) -> T;
677644
#[rustc_intrinsic]
678-
#[rustc_intrinsic_must_be_overridden]
679-
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) {
680-
loop {}
681-
}
645+
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize);
682646
#[rustc_intrinsic]
683-
#[rustc_intrinsic_must_be_overridden]
684-
pub unsafe fn unreachable() -> ! {
685-
loop {}
686-
}
647+
pub unsafe fn unreachable() -> !;
687648
}
688649

689650
pub mod libc {

patches/0029-stdlib-Disable-f16-and-f128-in-compiler-builtins.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ index 7165c3e48af..968552ad435 100644
1616

1717
[dependencies]
1818
core = { path = "../core", public = true }
19-
-compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std'] }
20-
+compiler_builtins = { version = "=0.1.146", features = ['rustc-dep-of-std', 'no-f16-f128'] }
19+
-compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std'] }
20+
+compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std', 'no-f16-f128'] }
2121

2222
[dev-dependencies]
2323
rand = { version = "0.8.5", default-features = false, features = ["alloc"] }

src/abi/mod.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,13 @@ pub(crate) fn codegen_terminator_call<'tcx>(
402402

403403
if is_call_from_compiler_builtins_to_upstream_monomorphization(fx.tcx, instance) {
404404
if target.is_some() {
405-
let caller = with_no_trimmed_paths!(fx.tcx.def_path_str(fx.instance.def_id()));
406-
let callee = with_no_trimmed_paths!(fx.tcx.def_path_str(def_id));
407-
fx.tcx.dcx().emit_err(CompilerBuiltinsCannotCall { caller, callee });
405+
let caller_def = fx.instance.def_id();
406+
let e = CompilerBuiltinsCannotCall {
407+
span: fx.tcx.def_span(caller_def),
408+
caller: with_no_trimmed_paths!(fx.tcx.def_path_str(caller_def)),
409+
callee: with_no_trimmed_paths!(fx.tcx.def_path_str(def_id)),
410+
};
411+
fx.tcx.dcx().emit_err(e);
408412
} else {
409413
fx.bcx.ins().trap(TrapCode::user(2).unwrap());
410414
return;

src/intrinsics/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,10 @@ fn codegen_float_intrinsic_call<'tcx>(
340340
sym::ceilf64 => ("ceil", 1, fx.tcx.types.f64, types::F64),
341341
sym::truncf32 => ("truncf", 1, fx.tcx.types.f32, types::F32),
342342
sym::truncf64 => ("trunc", 1, fx.tcx.types.f64, types::F64),
343-
sym::rintf32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
344-
sym::rintf64 => ("rint", 1, fx.tcx.types.f64, types::F64),
343+
sym::round_ties_even_f32 => ("rintf", 1, fx.tcx.types.f32, types::F32),
344+
sym::round_ties_even_f64 => ("rint", 1, fx.tcx.types.f64, types::F64),
345345
sym::roundf32 => ("roundf", 1, fx.tcx.types.f32, types::F32),
346346
sym::roundf64 => ("round", 1, fx.tcx.types.f64, types::F64),
347-
sym::roundevenf32 => ("roundevenf", 1, fx.tcx.types.f32, types::F32),
348-
sym::roundevenf64 => ("roundeven", 1, fx.tcx.types.f64, types::F64),
349-
sym::nearbyintf32 => ("nearbyintf", 1, fx.tcx.types.f32, types::F32),
350-
sym::nearbyintf64 => ("nearbyint", 1, fx.tcx.types.f64, types::F64),
351347
sym::sinf32 => ("sinf", 1, fx.tcx.types.f32, types::F32),
352348
sym::sinf64 => ("sin", 1, fx.tcx.types.f64, types::F64),
353349
sym::cosf32 => ("cosf", 1, fx.tcx.types.f32, types::F32),
@@ -399,16 +395,18 @@ fn codegen_float_intrinsic_call<'tcx>(
399395
| sym::ceilf64
400396
| sym::truncf32
401397
| sym::truncf64
402-
| sym::nearbyintf32
403-
| sym::nearbyintf64
398+
| sym::round_ties_even_f32
399+
| sym::round_ties_even_f64
404400
| sym::sqrtf32
405401
| sym::sqrtf64 => {
406402
let val = match intrinsic {
407403
sym::fabsf32 | sym::fabsf64 => fx.bcx.ins().fabs(args[0]),
408404
sym::floorf32 | sym::floorf64 => fx.bcx.ins().floor(args[0]),
409405
sym::ceilf32 | sym::ceilf64 => fx.bcx.ins().ceil(args[0]),
410406
sym::truncf32 | sym::truncf64 => fx.bcx.ins().trunc(args[0]),
411-
sym::nearbyintf32 | sym::nearbyintf64 => fx.bcx.ins().nearest(args[0]),
407+
sym::round_ties_even_f32 | sym::round_ties_even_f64 => {
408+
fx.bcx.ins().nearest(args[0])
409+
}
412410
sym::sqrtf32 | sym::sqrtf64 => fx.bcx.ins().sqrt(args[0]),
413411
_ => unreachable!(),
414412
};

src/intrinsics/simd.rs

+2-60
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
116116
});
117117
}
118118

119-
// simd_shuffle_generic<T, U, const I: &[u32]>(x: T, y: T) -> U
120-
sym::simd_shuffle_generic => {
119+
// simd_shuffle_const_generic<T, U, const I: &[u32]>(x: T, y: T) -> U
120+
sym::simd_shuffle_const_generic => {
121121
let [x, y] = args else {
122122
bug!("wrong number of args for intrinsic {intrinsic}");
123123
};
@@ -460,64 +460,6 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
460460
});
461461
}
462462

463-
sym::simd_fpow => {
464-
intrinsic_args!(fx, args => (a, b); intrinsic);
465-
466-
if !a.layout().ty.is_simd() {
467-
report_simd_type_validation_error(fx, intrinsic, span, a.layout().ty);
468-
return;
469-
}
470-
471-
simd_pair_for_each_lane(fx, a, b, ret, &|fx, lane_ty, _ret_lane_ty, a_lane, b_lane| {
472-
match lane_ty.kind() {
473-
ty::Float(FloatTy::F32) => fx.lib_call(
474-
"powf",
475-
vec![AbiParam::new(types::F32), AbiParam::new(types::F32)],
476-
vec![AbiParam::new(types::F32)],
477-
&[a_lane, b_lane],
478-
)[0],
479-
ty::Float(FloatTy::F64) => fx.lib_call(
480-
"pow",
481-
vec![AbiParam::new(types::F64), AbiParam::new(types::F64)],
482-
vec![AbiParam::new(types::F64)],
483-
&[a_lane, b_lane],
484-
)[0],
485-
_ => unreachable!("{:?}", lane_ty),
486-
}
487-
});
488-
}
489-
490-
sym::simd_fpowi => {
491-
intrinsic_args!(fx, args => (a, exp); intrinsic);
492-
let exp = exp.load_scalar(fx);
493-
494-
if !a.layout().ty.is_simd() {
495-
report_simd_type_validation_error(fx, intrinsic, span, a.layout().ty);
496-
return;
497-
}
498-
499-
simd_for_each_lane(
500-
fx,
501-
a,
502-
ret,
503-
&|fx, lane_ty, _ret_lane_ty, lane| match lane_ty.kind() {
504-
ty::Float(FloatTy::F32) => fx.lib_call(
505-
"__powisf2", // compiler-builtins
506-
vec![AbiParam::new(types::F32), AbiParam::new(types::I32)],
507-
vec![AbiParam::new(types::F32)],
508-
&[lane, exp],
509-
)[0],
510-
ty::Float(FloatTy::F64) => fx.lib_call(
511-
"__powidf2", // compiler-builtins
512-
vec![AbiParam::new(types::F64), AbiParam::new(types::I32)],
513-
vec![AbiParam::new(types::F64)],
514-
&[lane, exp],
515-
)[0],
516-
_ => unreachable!("{:?}", lane_ty),
517-
},
518-
);
519-
}
520-
521463
sym::simd_fsin
522464
| sym::simd_fcos
523465
| sym::simd_fexp

0 commit comments

Comments
 (0)