Voila, we have reached the last phase ✨. ICG is the third phase of my compiler (Genepiler). It's planned to join my 'Oh My Compiler' project!
The name of this phase is a little bit misleading. The phase compacted the last three phases of a typical compiler (Intermediate Code Generator - Code Optimizer - Target Code Generation).
This phase takes the lexemes from the first phase along with the actions from the second phase and produces java code 🙌
- Step one : Token
- Step two : Parse tree
- Step three: AST
- Step Four: IC
-
build parsing tree
-
show tree
-
simplify tree
-
add lexemes
-
make sure to delete nodes (free/del)
-
lift operands up
-
build AST
-
swap relop with 2 conditions (>=) --> !(<)
-
IC
-
backpatching
-
remove duplicate labels (at most 2)
-
remove print logs
-
consider module file to add your modules in
-
optimize backpatching
-
add arguments (argparse)
-
consider add directory for input and directory for output
-
report
- fix bugs
- consider generalizing the last phase
🤔 I believe I've fixed most of the bugs (maybe all of the them).
- check_type is not working properly in some cases
added a couple of lines to fix it temporarily
- get_val_2 & get_virtual shall be combined. Yet, some functions are not working then
- try to add flag
- let it return a list of virtual nodes to work with separately
-
do not declare multiple (seems to get something wrong) - check logic [not informative]
-
backpatching not working when no labels
- what if num is neg (is that handled?)
- handle range to be general (check phase 1)
- put your code in .j file
- run the folowing command
bash
java -jar jasmin.jar file.j
- now a class file is generated, to run:
java file
- Today: 14 May
- Actual Deadline:
30 May6 Jun - Phase Deadline: 20 May
3 days to just implement this
1 day for the report
- 14 May 2020 Getting to know what's going on
- 15 - 20 May 2020 : Build the program