summaryrefslogtreecommitdiffstats
path: root/library/core/src/intrinsics.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-19 09:26:03 +0000
commit9918693037dce8aa4bb6f08741b6812923486c18 (patch)
tree21d2b40bec7e6a7ea664acee056eb3d08e15a1cf /library/core/src/intrinsics.rs
parentReleasing progress-linux version 1.75.0+dfsg1-5~progress7.99u1. (diff)
downloadrustc-9918693037dce8aa4bb6f08741b6812923486c18.tar.xz
rustc-9918693037dce8aa4bb6f08741b6812923486c18.zip
Merging upstream version 1.76.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/intrinsics.rs')
-rw-r--r--library/core/src/intrinsics.rs49
1 files changed, 43 insertions, 6 deletions
diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs
index c5aef67b5..5107ba1a9 100644
--- a/library/core/src/intrinsics.rs
+++ b/library/core/src/intrinsics.rs
@@ -59,6 +59,7 @@ use crate::marker::Tuple;
use crate::mem;
pub mod mir;
+pub mod simd;
// These imports are used for simplifying intra-doc links
#[allow(unused_imports)]
@@ -341,6 +342,9 @@ extern "rust-intrinsic" {
/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`].
#[rustc_nounwind]
pub fn atomic_load_relaxed<T: Copy>(src: *const T) -> T;
+ /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model!
+ /// In terms of the Rust Abstract Machine, this operation is equivalent to `src.read()`,
+ /// i.e., it performs a non-atomic read.
#[rustc_nounwind]
pub fn atomic_load_unordered<T: Copy>(src: *const T) -> T;
@@ -365,6 +369,9 @@ extern "rust-intrinsic" {
/// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`].
#[rustc_nounwind]
pub fn atomic_store_relaxed<T: Copy>(dst: *mut T, val: T);
+ /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model!
+ /// In terms of the Rust Abstract Machine, this operation is equivalent to `dst.write(val)`,
+ /// i.e., it performs a non-atomic write.
#[rustc_nounwind]
pub fn atomic_store_unordered<T: Copy>(dst: *mut T, val: T);
@@ -1900,6 +1907,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::ctlz;
///
@@ -1912,6 +1920,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::ctlz;
///
@@ -1933,6 +1942,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::ctlz_nonzero;
///
@@ -1959,6 +1969,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::cttz;
///
@@ -1971,6 +1982,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::cttz;
///
@@ -1992,6 +2004,7 @@ extern "rust-intrinsic" {
///
/// ```
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
///
/// use std::intrinsics::cttz_nonzero;
///
@@ -2312,6 +2325,10 @@ extern "rust-intrinsic" {
/// Emits a `!nontemporal` store according to LLVM (see their docs).
/// Probably will never become stable.
+ ///
+ /// Do NOT use this intrinsic; "nontemporal" operations do not exist in our memory model!
+ /// It exists to support current stdarch, but the plan is to change stdarch and remove this intrinsic.
+ /// See <https://github.com/rust-lang/rust/issues/114582> for some more discussion.
#[rustc_nounwind]
pub fn nontemporal_store<T>(ptr: *mut T, val: T);
@@ -2453,6 +2470,7 @@ extern "rust-intrinsic" {
/// ```no_run
/// #![feature(const_eval_select)]
/// #![feature(core_intrinsics)]
+ /// # #![allow(internal_features)]
/// use std::hint::unreachable_unchecked;
/// use std::intrinsics::const_eval_select;
///
@@ -2487,12 +2505,6 @@ extern "rust-intrinsic" {
where
G: FnOnce<ARG, Output = RET>,
F: FnOnce<ARG, Output = RET>;
-
- /// This method creates a pointer to any `Some` value. If the argument is
- /// `None`, an invalid within-bounds pointer (that is still acceptable for
- /// constructing an empty slice) is returned.
- #[rustc_nounwind]
- pub fn option_payload_ptr<T>(arg: *const Option<T>) -> *const T;
}
// Some functions are defined here because they accidentally got made
@@ -2855,3 +2867,28 @@ pub const unsafe fn write_bytes<T>(dst: *mut T, val: u8, count: usize) {
write_bytes(dst, val, count)
}
}
+
+/// Inform Miri that a given pointer definitely has a certain alignment.
+#[cfg(miri)]
+pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize) {
+ extern "Rust" {
+ /// Miri-provided extern function to promise that a given pointer is properly aligned for
+ /// "symbolic" alignment checks. Will fail if the pointer is not actually aligned or `align` is
+ /// not a power of two. Has no effect when alignment checks are concrete (which is the default).
+ fn miri_promise_symbolic_alignment(ptr: *const (), align: usize);
+ }
+
+ fn runtime(ptr: *const (), align: usize) {
+ // SAFETY: this call is always safe.
+ unsafe {
+ miri_promise_symbolic_alignment(ptr, align);
+ }
+ }
+
+ const fn compiletime(_ptr: *const (), _align: usize) {}
+
+ // SAFETY: the extra behavior at runtime is for UB checks only.
+ unsafe {
+ const_eval_select((ptr, align), compiletime, runtime);
+ }
+}