|
An incomplete short summary of all the compiler phases & traversals.
|
|
This file holds an incomplete short summary of all the compiler phases & traversals.
|
|
|
|
|
|
If you are reading a traversal you can come here and create or improve a summary of it to improve your and later others understanding of the traversal and the compiler as a whole.
|
|
If you are reading a traversal you can come here and create or improve a summary of it to improve your and later others understanding of the traversal and the compiler as a whole.
|
|
|
|
|
|
For the full picture of each traversal see the corresponding file in the `src` directory.
|
|
For the full picture of each traversal see the corresponding file in the `src` directory.
|
|
|
|
|
|
|
|
The sac compiler operates in many phases.
|
|
|
|
Each phase is a composition of traversals and there are many traversals.
|
|
|
|
It is best to work on a need to know basis with the traversals but it is good to have a rough idea of what each phase does.
|
|
|
|
|
|
|
|
# Breaking at interesting phases
|
|
|
|
|
|
|
|
You can stop at a certain phase by using the `-b` flag.
|
|
|
|
For instance `-b 1` will stop after the first phase.
|
|
|
|
It is a good idea to write a simple program and run the compiler increasing the number after the `-b` flag to see what each phase does.
|
|
|
|
It is also a good idea to run with `-noprelude` to remove the prelude from the output which is introduced in phase 4.
|
|
|
|
It is also a good idea to run with `-v 3` to see the names of each traversal in each phase.
|
|
|
|
|
|
|
|
Looking before opt (optimizations), currently 10 or ewl and after opt is always interesting.
|
|
|
|
After opt if you don't have with loops you can mostly skip to 16 or mem.
|
|
|
|
After `mem` the code starts to looks a lot less readable.
|
|
|
|
|
|
|
|
The code gen phase (22 or cg) is quite interesting if you do `-b cg` you will get nothing.
|
|
|
|
At the end of dm `-b dm` there are only assignments, primitive functions and do-while loops and conditions left.
|
|
|
|
(The do-while loops and conditions are reintroduced in ussa:f2l)
|
|
|
|
|
|
|
|
With `-b cg:cpl` is an crazy traversal of 10k loc which turns all the assignments and primitive functions into [intermediate code macros]() (CPL)
|
|
|
|
At this point the code is actually quite readable again because all the primitive functions applications and assignments are turned into macros.
|
|
|
|
|
|
|
|
# Phases
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## 1: Loading SAC program ...
|
|
|
|
|
|
|
|
Locate and load the given SAC program source code.
|
|
|
|
Run the C preprocessor on the source code.
|
|
|
|
Lex and parse it into an ast.
|
|
|
|
|
|
|
|
## 2: Preprocessing type patterns ...
|
|
|
|
|
|
|
|
Run the type pattern preprocessor on the ast.
|
|
|
|
|
|
|
|
## 3: Preprocessing SAC program ...
|
|
|
|
|
|
|
|
## 4: Running module system ...
|
|
|
|
|
|
|
|
## 5: Simplifying source code ...
|
|
|
|
|
|
|
|
## 6: Converting to static single assignment form ...
|
|
|
|
|
|
|
|
## 7: Running type inference system ...
|
|
|
|
|
|
|
|
## 8: Processing exports ...
|
|
|
|
|
|
|
|
## 9: Preparing for code optimization ...
|
|
|
|
|
|
|
|
## 10: Enhancing with-loops ...
|
|
|
|
|
|
|
|
## 11: Running SAC optimizations ...
|
|
|
|
|
|
|
|
## 12: Automatic parallelisation for GPUs skipped.
|
|
|
|
|
|
|
|
## 13: Transforming with-loop representation ...
|
|
|
|
|
|
|
|
## 14: Running 3rd generation multithreading skipped.
|
|
|
|
|
|
|
|
## 15: Introducing task parallelization skipped.
|
|
|
|
|
|
|
|
## 16: Introducing memory management instructions ...
|
|
|
|
|
|
|
|
## 17: Introduce profiling instruction ...
|
|
|
|
|
|
|
|
## 18: Converting from static single assignment form ...
|
|
|
|
|
|
|
|
## 19: Running automatic parallelisation skipped.
|
|
|
|
|
|
|
|
## 20: Preparing C code generation ...
|
|
|
|
|
|
|
|
## 21: Distributed Memory skipped.
|
|
|
|
|
|
|
|
## 23: Generating Code ...
|
|
|
|
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
# Traversals
|
|
|
|
|
|
# Loading SAC program
|
|
# Loading SAC program
|
|
|
|
|
|
In this phase the compiler loads the given SAC program.
|
|
In this phase the compiler loads the given SAC program.
|
... | @@ -191,3 +274,4 @@ To make sure the renaming is consistent with the previous 2 phases the same rena |
... | @@ -191,3 +274,4 @@ To make sure the renaming is consistent with the previous 2 phases the same rena |
|
## Hiding struct definition behind typedefs and accessors (hs)
|
|
## Hiding struct definition behind typedefs and accessors (hs)
|
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
|
\ No newline at end of file |