diff options
author | John Hodge <tpg@mutabah.net> | 2016-08-11 22:10:42 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2016-08-11 22:10:42 +0800 |
commit | a8d69d26a65278f326d72e163c598be5e1b8204f (patch) | |
tree | 565c3b0cd0edb03bc601eb5b0af73cbccbbf0580 | |
parent | 6616b8905392aa7faebc864534aa74cf461af758 (diff) | |
download | mrust-a8d69d26a65278f326d72e163c598be5e1b8204f.tar.gz |
Notes - Add MIR doc (rough outline)
-rw-r--r-- | Notes/MIR.md | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Notes/MIR.md b/Notes/MIR.md new file mode 100644 index 00000000..dbeb131c --- /dev/null +++ b/Notes/MIR.md @@ -0,0 +1,49 @@ +% Mid-level intermediate representation + + +See https://github.com/rust-lang/rfcs/blob/master/text/1211-mir.md + + +Overview +======== + +Graph of "Basic Blocks" +- Stored as a vector, integer indexes between each other +- All function calls terminate their block +- Varaibles are single-assigment, but mutable via &mut or field accesses + + +Types +===== + +LValues (assignable locations) +------------------------------ + +- `B` - User-declared binding (with a name and slot index) +- `TEMP` - Compiler-inserted temporary (with just an index) +- `ARG` - Function argument (with index only) +- `STATIC` - Reference to a `static` or `static mut` +- `RETURN` - The function's return value +- `LVALUE.f` - Refers to the field `f` of the inner `LVALUE` +- `*LVALUE` - Dereference a pointer (&-ptr or rawptr) +- `LVALUE[LVALUE]` - Index into an array (slice accesses use operator overloads) +- `(LVALUE as VARIANT)` - Downcast `LVALUE` into the specified enum variant (to access it as that variant) + +RValues (usable values) +----------------------- + +- `use(LVALUE)` - Read out of an LVALUE +- `&'rgn LVALUE` - Immutably borrow an LVALUE +- `&'rgn mut LVALUE` - Mutably borrow an LVALUE +- `LVALUE as TYPE` - Primitive cast operation +- `LVALUE <op> LVALUE` - Binary operation (on numeric primitives only) +- `<op> LVALUE` - Unary operation (numeric primitives and booleans only) +- `[LVALUE; LVALUE]` - Construct a sized array +- `[LVALUE, ...]` - Construct a literal array +- `(LVALUE, ...)` - Construct a tuple +- `PATH { f: LVALUE, ... }` - Construct a named struct +- `meta(LVALUE)` - Extract the fat pointer metadata for an lvalue +- `fatptr(LVALUE, LVALUE)` - Construct a fat pointer from a pair of lvalues +- `CONSTANT` - Subset of RValues that are known at compile-time + + |