Rust IR
Ref: https://rust-lang.github.io/rfcs/1211-mir.html
https://rustc-dev-guide.rust-lang.org/mir/index.html
https://doc.rust-lang.org/beta/nightly-rustc/rustc_middle/ty/struct.TyCtxt.html#method.layout_of
HIR
Add a high-level intermediate representation (HIR) to the compiler. This is basically a new (and additional) AST more suited for use by the compiler.
You can view the HIR representation of your code by passing the -Z unpretty=hir-tree flag to rustc:
1 |
|
THIR
https://rustc-dev-guide.rust-lang.org/thir.html
The THIR (“Typed High-Level Intermediate Representation”), previously called HAIR for “High-Level Abstract IR”, is another IR used by rustc that is generated after type checking.
MIR
https://rustc-dev-guide.rust-lang.org/mir/index.html https://rust-lang.github.io/rfcs/1211-mir.html https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/index.html
RUST_LOG=debug RUSTFLAGS=”-Zalways-encode-mir -Zsymbol-mangling-version=v0 -C panic=abort” xargo build -v RUSTFLAGS=”–emit=mir”
Some of the key characteristics of MIR are:
- It is based on a control-flow graph.
- It does not have nested expressions.
- All types in MIR are fully explicit.
Online Compiler to emit MIR, HIR, and LLVM IR:
Rustc
A DefId identifies a particular definition, by combining a crate index and a def index.