Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update links #1942

Merged
merged 4 commits into from
Mar 24, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions text/1211-mir.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,22 @@ rest of the design:

### Prototype

The MIR design being described here [has been prototyped][proto-crate]
and can be viewed in the `nikomatsakis` repository on github. In
particular, [the `repr` module][repr] defines the MIR representation,
and [the `build` module][build] contains the code to create a MIR
The MIR design being described can be found [here][crate]. In
particular, [this module][mir] defines the MIR representation,
and [this `build` module][build] contains the code to create a MIR
representation from an AST-like form.

For increased flexibility, as well as to make the code simpler, the
prototype is not coded directly against the compiler's AST, but rather
against an idealized representation defined by [the `HIR` trait][hir].
Note that this HIR trait is entirely independent from the HIR discussed by
against an idealized representation defined by [the `HAIR` trait][hair].
Note that this HAIR trait is entirely independent from the HIR discussed by
nrc in [RFC 1191][1191] -- you can think of it as an abstract trait
that any high-level Rust IR could implement, including our current
AST. Moreover, it's just an implementation detail and not part of the
MIR being proposed here per se. Still, if you want to read the code,
you have to understand its design.

The `HIR` trait contains a number of opaque associated types for the
The `HAIR` trait contains a number of opaque associated types for the
various aspects of the compiler. For example, the type `H::Expr`
represents an expression. In order to find out what kind of expression
it is, the `mirror` method is called, which converts an `H::Expr` into
Expand All @@ -230,19 +229,19 @@ themselves, or else they may be additional `H::Expr` nodes. This
allows the tree that is exported to differ in small ways from the
actual tree within the compiler; the primary intention is to use this
to model "adjustments" like autoderef. The code to convert from our
current AST to the HIR is not yet complete, but it can be found in the
[`tcx` module][tcx].
current AST to the HAIR is not yet complete, but it can be found
[here][hair-mod].

Note that the HIR mirroring system is an experiment and not really
Note that the HAIR mirroring system is an experiment and not really
part of the MIR itself. It does however present an interesting option
for (eventually) stabilizing access to the compiler's internals.

[proto-crate]: https://github.com/nikomatsakis/rust/tree/mir/src/librustc_mir
[repr]: https://github.com/nikomatsakis/rust/blob/mir/src/librustc_mir/repr.rs
[build]: https://github.com/nikomatsakis/rust/tree/mir/src/librustc_mir/build
[hir]: https://github.com/nikomatsakis/rust/blob/mir/src/librustc_mir/hir.rs
[crate]: https://github.com/rust-lang/rust/tree/2532ad7d0b2edac1909ef0ef346230331200790b/src/librustc/mir
[mir]: https://github.com/rust-lang/rust/blob/2532ad7d0b2edac1909ef0ef346230331200790b/src/librustc/mir/mod.rs
[build]: https://github.com/rust-lang/rust/tree/fc04eaacc5bd5760e98cd3aa390dcc3ae795d12f/src/librustc_mir/build
[hair]: https://github.com/rust-lang/rust/tree/fc04eaacc5bd5760e98cd3aa390dcc3ae795d12f/src/librustc_mir/hair
[1191]: https://github.com/rust-lang/rfcs/pull/1191
[tcx]: https://github.com/nikomatsakis/rust/blob/mir/src/librustc_mir/tcx/mod.rs
[hair-mod]: https://github.com/rust-lang/rust/blob/21c61336bb9e327b90f4cb8e87a948be40eeafe5/src/librustc_mir/hair/mod.rs

### Overview of the MIR

Expand Down Expand Up @@ -660,6 +659,8 @@ more generalized protocol that [RFC 809][809] specifies works in
more-or-less exactly the same way: when that is adopted uniformly, the
need for shallow drop and the Box rvalue will go away.

[809]: https://github.com/rust-lang/rfcs/blob/master/text/0809-box-and-in-for-stdlib.md

### Phasing

Ideally, the translation to MIR would be done during type checking,
Expand Down Expand Up @@ -782,7 +783,7 @@ which desugars to a temporary and a constant reference:

tmp0 = foo;
tmp1 = 3
x = tmp(tmp1)
x = tmp0(tmp1)

There is no particular *harm* in such constants: it would be very easy
to optimize them away when reducing to LLVM bitcode, and if we do not
Expand Down