abi: add a rust-preserve-none calling convention
This is the conceptual opposite of the rust-cold calling convention and is particularly useful in combination with the new `explicit_tail_calls` feature.
For relatively tight loops implemented with tail calling (`become`) each of the function with the regular calling convention is still responsible for restoring the initial value of the preserved registers. So it is not unusual to end up with a situation where each step in the tail call loop is spilling and reloading registers, along the lines of:
foo:
push r12
; do things
pop r12
jmp next_step
This adds up quickly, especially when most of the clobberable registers are already used to pass arguments or other uses.
I was thinking of making the name of this ABI a little less LLVM-derived and more like a conceptual inverse of `rust-cold`, but could not come with a great name (`rust-cold` is itself not a great name: cold in what context? from which perspective? is it supposed to mean that the function is rarely called?)
|
||
|---|---|---|
| .. | ||
| src | ||
| Cargo.toml | ||
| README.md | ||
| rust-toolchain.toml | ||
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. ↩︎