Define HIR more specifically

IR is a foreign acronym to me, so having it fully expressed in the beginning as Intermediate Representation helps me comprehend the subject.
This commit is contained in:
Alex Kitchens 2018-05-17 12:53:11 -05:00 committed by Who? Me?!
parent 379ce9ae66
commit 75db8b32d4
2 changed files with 8 additions and 7 deletions

View File

@ -104,8 +104,8 @@ take:
nodes, and hence may strip things out of the AST as well. nodes, and hence may strip things out of the AST as well.
3. **Lowering to HIR** 3. **Lowering to HIR**
- Once name resolution completes, we convert the AST into the HIR, - Once name resolution completes, we convert the AST into the HIR,
or "high-level IR". The HIR is defined in `src/librustc/hir/`; or "[high-level intermediate representation]". The HIR is defined in
that module also includes the lowering code. `src/librustc/hir/`; that module also includes the lowering code.
- The HIR is a lightly desugared variant of the AST. It is more processed - The HIR is a lightly desugared variant of the AST. It is more processed
than the AST and more suitable for the analyses that follow. than the AST and more suitable for the analyses that follow.
It is **not** required to match the syntax of the Rust language. It is **not** required to match the syntax of the Rust language.
@ -138,3 +138,4 @@ take:
[query model]: query.html [query model]: query.html
[high-level intermediate representation]: hir.html

View File

@ -1,10 +1,10 @@
# The HIR # The HIR
The HIR "High-level IR" is the primary IR used in most of rustc. It is a The HIR "High-Level Intermediate Representation" is the primary IR used in
compiler-friendly representation of the abstract syntax tree (AST) that is most of rustc. It is a compiler-friendly representation of the abstract syntax
generated after parsing, macro expansion, and name resolution. tree (AST) that is generated after parsing, macro expansion, and name
Many parts of HIR resemble Rust surface syntax quite closely, with the resolution. Many parts of HIR resemble Rust surface syntax quite closely, with
exception that some of Rust's expression forms have been desugared away. For the exception that some of Rust's expression forms have been desugared away. For
example, `for` loops are converted into a `loop` and do not appear in the HIR. example, `for` loops are converted into a `loop` and do not appear in the HIR.
This makes HIR more amenable to analysis than a normal AST. This makes HIR more amenable to analysis than a normal AST.