mirror of
https://github.com/rust-lang/rust.git
synced 2026-01-25 07:48:44 +00:00
Replace Rvalue::NullaryOp by a variant in mir::Operand. Based on https://github.com/rust-lang/rust/pull/148151 This PR fully removes the MIR `Rvalue::NullaryOp`. After rust-lang/rust#148151, it was only useful for runtime checks like `ub_checks`, `contract_checks` and `overflow_checks`. These are "runtime" checks, boolean constants that may only be `true` in codegen. It depends on a rustc flag passed to codegen, so we need to represent those flags cross-crate. This PR replaces those runtime checks by special variants in MIR `ConstValue`. This allows code that expects constants to manipulate those as such, even if we may not always be able to evaluate them to actual scalars.
This crate is currently developed in-tree together with the compiler.
Our goal is to start publishing stable_mir into crates.io.
Until then, users will use this as any other rustc crate, by installing
the rustup component rustc-dev, and declaring stable-mir as an external crate.
See the StableMIR "Getting Started" guide for more information.
Stable MIR Design
The stable-mir will follow a similar approach to proc-macro2. Its implementation is split between two main crates:
stable_mir: Public crate, to be published on crates.io, which will contain the stable data structure as well as calls torustc_smirAPIs. The translation between stable and internal constructs will also be done in this crate, however, this is currently implemented in therustc_smircrate.1 .rustc_smir: This crate implements the public APIs to the compiler. It is responsible for gathering all the information requested, and providing the data in its unstable form.
I.e.,
tools will depend on stable_mir crate,
which will invoke the compiler using APIs defined in rustc_smir.
I.e.:
┌──────────────────────────────────┐ ┌──────────────────────────────────┐
│ External Tool ┌──────────┐ │ │ ┌──────────┐ Rust Compiler │
│ │ │ │ │ │ │ │
│ │stable_mir| │ │ │rustc_smir│ │
│ │ │ ├──────────►| │ │ │
│ │ │ │◄──────────┤ │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ └──────────┘ │ │ └──────────┘ │
└──────────────────────────────────┘ └──────────────────────────────────┘
More details can be found here: https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view
-
This is currently implemented in the
rustc_smircrate, but we are working to change that. ↩︎