Module intrinsics

Compiler intrinsics.

The functions in this module are implementation details of core and should not be used outside of the standard library. We generally provide access to intrinsics via stable wrapper functions. Use these instead.

These are the imports making intrinsics available to Rust code. The actual implementations live in the compiler. Some of these intrinsics are lowered to MIR in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_mir_transform/src/lower_intrinsics.rs. The remaining intrinsics are implemented for the LLVM backend in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs and https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_codegen_llvm/src/intrinsic.rs, and for const evaluation in https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_const_eval/src/interpret/intrinsics.rs.

Const intrinsics

In order to make an intrinsic unstable usable at compile-time, copy the implementation from https://github.com/rust-lang/miri/blob/master/src/intrinsics to https://github.com/rust-lang/rust/blob/HEAD/compiler/rustc_const_eval/src/interpret/intrinsics.rs and make the intrinsic declaration below a const fn. This should be done in coordination with wg-const-eval.

If an intrinsic is supposed to be used from a const fn with a rustc_const_stable attribute, #[rustc_intrinsic_const_stable_indirect] needs to be added to the intrinsic. Such a change requires T-lang approval, because it may bake a feature into the language that cannot be replicated in user code without compiler support.

Volatiles

The volatile intrinsics provide operations intended to act on I/O memory, which are guaranteed to not be reordered by the compiler across other volatile intrinsics. See [read_volatile][ptr::read_volatile] and [write_volatile][ptr::write_volatile].

Atomics

The atomic intrinsics provide common atomic operations on machine words, with multiple possible memory orderings. See the [atomic types][atomic] docs for details.

Unwinding

Rust intrinsics may, in general, unwind. If an intrinsic can never unwind, add the #[rustc_nounwind] attribute so that the compiler can make use of this fact.

However, even for intrinsics that may unwind, rustc assumes that a Rust intrinsics will never initiate a foreign (non-Rust) unwind, and thus for panic=abort we can always assume that these intrinsics cannot unwind.

Modules

Enums

Functions