# HIR Dump for GCC Rust Frontend
## Personal Information
- Name: Jiakun Fan
- Email: vincentdftbg@gmail.com
- Github: [chosen-ox](https://github.com/chosen-ox)
- Location: Shenzhen, China
- Time Zone: UTC+8
- University: Chinese University of Hong Kong (shenzhen)
- Major: Computer Engnieering
## Project Description
- Name: [HIR Dump](https://hackmd.io/@Rust-GCC/B1yEfRBjj#Project-A---HIR-Dump)
- Mentor: [Arthur](https://github.com/CohenArthur)
- Goal: implement an HIR dump by leveraging work already done for AST dump.
## About me
- My major programming language is C++, Rust. I am interested in parallel system, compiler and operating system.
- This semester I am taking [CS255: Advanced Compilers](https://www.cs.rochester.edu/u/sree/courses/csc-255-455/spring-2021/) (physically in [UR](https://www.rochester.edu/) as an exchange student). I implemented some basic transform between AST, CFG, BB which is useful for me to understand and improve GCCRust.
## Homework
- Download GCCRust from github and build it successfully on my machine. I also build it on github [codespace](https://github.com/features/codespaces) for convenience.
- Review code of GCCRust and understand the basic workflow of GCCRust. In the process, I found some TODOs and started a [PR#1972](https://github.com/Rust-GCC/gccrs/pull/1972). With the help of GCCRust developers, I succeeded merging my first commit. And then I focused on HIR dump. Opened my second [PR#1976](https://github.com/Rust-GCC/gccrs/pull/1976) to improve HIR dump. Thanks to [Jdupak](https://github.com/jdupak) and Arthur for providing me with many suggestions.
- Rust mechanism is complex. I started to read some docs like [rustc book](https://doc.rust-lang.org/rustc/what-is-rustc.html), [rustc development guide](https://rustc-dev-guide.rust-lang.org/), [rust reference](https://doc.rust-lang.org/reference/).
## Plan
- **Eliminate the overlap between AST and HIR nodes:** The overlap between AST and HIR nodes makes it more difficult to pretty-dump HIR nodes(diccussed in [PR#1976](https://github.com/Rust-GCC/gccrs/pull/1976#issuecomment-1468352637)). Because AST types accepting HIR visitors will have an effect on compilation speed overall. I will try to eliminate the overlap without voliating the existing logic and code.
- **Implement exisiting visit function in [rust-hir-dump.h](https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/hir/rust-hir-dump.h#L40-L185) and add new visit function:** First implement existing visit function. Then add new visit function based on those.
- **Add testsuites for HIR dump:** Add as many as possible cases to test if HIR dump does well. If time permits, write a doc for using and testing HIR dump.
## Timeline
### official overview
* May 4 - 18:00 UTC:Accepted GSoC contributor projects announced
* May 4 - 28:Community Bonding Period | GSoC contributors get to know mentors, read documentation, get up to speed to begin working on their projects
* May 29: Coding officially begins!
* July 10 - 18:00 UTC:Mentors and GSoC contributors can begin submitting midterm evaluations
* July 14 - 18:00 UTC:Midterm evaluation deadline (standard coding period)
* July 14 - August 21:Work Period | GSoC contributors work on their project with guidance from Mentors
* August 21 - 28 - 18:00 UTC:Final week: GSoC contributors submit their final work product and their final mentor evaluation (standard coding period)
* August 28 - September 4 - 18:00 UTC:Mentors submit final GSoC contributor evaluations (standard coding period)
* September 5:Initial results of Google Summer of Code 2023 announced
### details
- **Before May 29:** Read source code and disscuss the possible taks and implementations with mentors via issue, pr or zulip.
- **May 29 - June 25:** View the AST and HIR nodes to eliminate possible overlaps (`AST::AttrVec` and `AST::Lifetime::LifetimeType`). Talk to mentors and refactor AST and HIR nodes.
- **June 26 - July 14:**
- Implement visit functions in [rust-hir-dump.h](https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/hir/rust-hir-dump.h#L40-L184). Replace use of `AST::AttrVec` to `HIR::AttrVec`.
- Write the midterm evaluation.
- **July 15 - July 30:**
- Add possible new visit function for dumping HIR according to possible new HIR class.
- **July 31 - August 20:** Add testsuites for HIR dump, write a doc for using and testing HIR dump.
- **August 21 - August 28:** Submit the final work product and write the final evaluation.
## Why me
- I use GNU tools on a daily basis, and they have been invaluable to me. I am excited to have the opportunity to contribute to the GCC project and am committed to doing my best. I hope to makie a positive impact on the free software community.
- To prepare for this project, I am taking a compiler course and reading Rust documentation. I am particularly drawn to Rust as I believe it is the future of programming languages. I am confident in my ability to tackle this project and look forward to the challenge.