Expand description
An interpreter for MIR used in CTFE and by miri
Re-exportsΒ§
pub use self::call::FnArg;pub use self::eval_context::InterpCx;use self::eval_context::from_known_layout;πuse self::eval_context::mir_assign_valid_types;πpub use self::intern::HasStaticRootDefId;pub use self::intern::InternError;pub use self::intern::InternKind;pub use self::intern::intern_const_alloc_for_constprop;pub use self::intern::intern_const_alloc_recursive;pub use self::intrinsics::VarArgCompatible;pub use self::machine::AllocMap;pub use self::machine::Machine;pub use self::machine::MayLeak;pub use self::machine::RetagMode;pub use self::machine::ReturnAction;pub use self::machine::compile_time_machine;pub use self::memory::AllocInfo;pub use self::memory::AllocKind;pub use self::memory::AllocRef;pub use self::memory::AllocRefMut;pub use self::memory::FnVal;pub use self::memory::Memory;pub use self::memory::MemoryKind;use self::operand::Operand;πpub use self::operand::ImmTy;pub use self::operand::Immediate;pub use self::operand::OpTy;pub use self::operator::AtomicRmwOp;pub use self::place::MPlaceTy;pub use self::place::MemPlaceMeta;pub use self::place::PlaceTy;pub use self::place::Writeable;use self::place::MemPlace;πuse self::place::Place;πpub use self::projection::OffsetMode;pub use self::projection::Projectable;pub use self::stack::Frame;pub use self::stack::FrameInfo;pub use self::stack::LocalState;pub use self::stack::ReturnContinuation;pub use self::util::EnteredTraceSpan;pub(crate) use self::util::create_static_alloc;πpub(crate) use self::util::ensure_monomorphic_enough;πpub(crate) use self::util::type_implements_dyn_trait;πpub use self::validity::CtfeValidationMode;pub use self::validity::RangeSet;pub use self::validity::RefTracking;pub use self::visitor::ValueVisitor;pub use rustc_middle::mir::interpret::*;
ModulesΒ§
- call π
- Manages calling a concrete function (with known MIR body) with argument passing, and returning the return value to the caller.
- cast π
- discriminant π
- Functions for reading and writing discriminants of multi-variant layouts (enums and coroutines).
- eval_
context π - intern π
- This module specifies the type based interner for constants.
- intrinsics π
- Intrinsics and other functions that the interpreter executes without looking at their MIR. Intrinsics/functions supported here are shared by CTFE and miri.
- machine π
- This module contains everything needed to instantiate an interpreter. This separation exists to ensure that no fancy miri features like interpreting common C functions leak into CTFE.
- memory π
- The memory subsystem.
- operand π
- Functions concerning immediate values and operands, and reading from operands. All high-level functions to read from memory work on operands as sources.
- operator π
- place π
- Computations on places β field projections, going from mir::Place, and writing into a place. All high-level functions to write to memory work on places as destinations.
- projection π
- This file implements βplace projectionsβ; basically a symmetric API for 3 types: MPlaceTy, OpTy, PlaceTy.
- stack π
- Manages the low-level pushing and popping of stack frames and the (de)allocation of local variables.
For handling of argument passing and return values, see the
callmodule. - step π
- This module contains the
InterpCxmethods for executing a single step of the interpreter. - traits π
- util π
- validity π
- Check the validity invariant of a given value, and tell the user
where in the value it got violated.
In const context, this goes even further and tries to approximate const safety.
Thatβs useful because it means other passes (e.g. promotion) can rely on
consts to be const-safe. - visitor π
- Visitor for a run-time value with a given layout: Traverse enums, structs and other compound types until we arrive at the leaves, with custom handling for primitive types.