|
| 1 | +This crate is currently developed in-tree together with the compiler. |
| 2 | + |
| 3 | +Our goal is to start publishing `stable_mir` into crates.io. |
| 4 | +Until then, users will use this as any other rustc crate, by installing |
| 5 | +the rustup component `rustc-dev`, and declaring `stable-mir` as an external crate. |
| 6 | + |
| 7 | +See the StableMIR ["Getting Started"](https://rust-lang.github.io/project-stable-mir/getting-started.html) |
| 8 | +guide for more information. |
| 9 | + |
| 10 | +## Stable MIR Design |
| 11 | + |
| 12 | +The stable-mir will follow a similar approach to proc-macro2. Its |
| 13 | +implementation is split between two main crates: |
| 14 | + |
| 15 | +- `stable_mir`: Public crate, to be published on crates.io, which will contain |
| 16 | +the stable data structure as well as calls to `rustc_smir` APIs. The |
| 17 | +translation between stable and internal constructs will also be done in this crate, |
| 18 | +however, this is currently implemented in the `rustc_smir` crate.[^translation]. |
| 19 | +- `rustc_smir`: This crate implements the public APIs to the compiler. |
| 20 | +It is responsible for gathering all the information requested, and providing |
| 21 | +the data in its unstable form. |
| 22 | + |
| 23 | +[^translation]: This is currently implemented in the `rustc_smir` crate, |
| 24 | +but we are working to change that. |
| 25 | + |
| 26 | +I.e., |
| 27 | +tools will depend on `stable_mir` crate, |
| 28 | +which will invoke the compiler using APIs defined in `rustc_smir`. |
| 29 | + |
| 30 | +I.e.: |
| 31 | + |
| 32 | +``` |
| 33 | + ┌──────────────────────────────────┐ ┌──────────────────────────────────┐ |
| 34 | + │ External Tool ┌──────────┐ │ │ ┌──────────┐ Rust Compiler │ |
| 35 | + │ │ │ │ │ │ │ │ |
| 36 | + │ │stable_mir| │ │ │rustc_smir│ │ |
| 37 | + │ │ │ ├──────────►| │ │ │ |
| 38 | + │ │ │ │◄──────────┤ │ │ │ |
| 39 | + │ │ │ │ │ │ │ │ |
| 40 | + │ │ │ │ │ │ │ │ |
| 41 | + │ └──────────┘ │ │ └──────────┘ │ |
| 42 | + └──────────────────────────────────┘ └──────────────────────────────────┘ |
| 43 | +``` |
| 44 | + |
| 45 | +More details can be found here: |
| 46 | +https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view |
0 commit comments