2024-09-13 16:01:02 -05:00
|
|
|
This crate is currently developed in-tree together with the compiler.
|
2022-06-02 05:07:25 -05:00
|
|
|
|
2024-09-13 16:01:02 -05:00
|
|
|
Our goal is to start publishing `stable_mir` into crates.io.
|
2024-10-24 18:19:55 -05:00
|
|
|
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"](https://rust-lang.github.io/project-stable-mir/getting-started.html)
|
|
|
|
guide for more information.
|
2023-03-03 19:08:49 -06:00
|
|
|
|
|
|
|
## Stable MIR Design
|
|
|
|
|
2024-10-24 18:12:31 -05:00
|
|
|
The stable-mir will follow a similar approach to proc-macro2. Its
|
|
|
|
implementation is split between two main crates:
|
2023-03-03 19:08:49 -06:00
|
|
|
|
|
|
|
- `stable_mir`: Public crate, to be published on crates.io, which will contain
|
2024-10-24 18:19:55 -05:00
|
|
|
the stable data structure as well as calls to `rustc_smir` APIs. The
|
|
|
|
translation between stable and internal constructs will also be done in this crate,
|
|
|
|
however, this is currently implemented in the `rustc_smir` crate.[^translation].
|
2024-09-13 16:01:02 -05:00
|
|
|
- `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.
|
2023-03-03 19:08:49 -06:00
|
|
|
|
2024-10-24 18:19:55 -05:00
|
|
|
[^translation]: This is currently implemented in the `rustc_smir` crate,
|
|
|
|
but we are working to change that.
|
|
|
|
|
2024-09-13 16:01:02 -05:00
|
|
|
I.e.,
|
|
|
|
tools will depend on `stable_mir` crate,
|
|
|
|
which will invoke the compiler using APIs defined in `rustc_smir`.
|
|
|
|
|
|
|
|
I.e.:
|
2023-03-03 19:08:49 -06:00
|
|
|
|
|
|
|
```
|
|
|
|
┌──────────────────────────────────┐ ┌──────────────────────────────────┐
|
|
|
|
│ External Tool ┌──────────┐ │ │ ┌──────────┐ Rust Compiler │
|
|
|
|
│ │ │ │ │ │ │ │
|
|
|
|
│ │stable_mir| │ │ │rustc_smir│ │
|
|
|
|
│ │ │ ├──────────►| │ │ │
|
|
|
|
│ │ │ │◄──────────┤ │ │ │
|
|
|
|
│ │ │ │ │ │ │ │
|
|
|
|
│ │ │ │ │ │ │ │
|
|
|
|
│ └──────────┘ │ │ └──────────┘ │
|
|
|
|
└──────────────────────────────────┘ └──────────────────────────────────┘
|
|
|
|
```
|
|
|
|
|
|
|
|
More details can be found here:
|
|
|
|
https://hackmd.io/XhnYHKKuR6-LChhobvlT-g?view
|