fe-lang / sonatina

Apache License 2.0
47 stars 6 forks source link

Introduce `SideEffect` #75

Closed Y-Nak closed 1 month ago

Y-Nak commented 1 month ago

Please start reviewing after #69.

I've added the SideEffect enum. In the current implementation, only None, Read, Write can be specified. Read can be analogized to reading from memory. While it does not affect the state, it indicates that it can be influenced by the state. Write can be analogized to writing to memory, and it affects the state.

This is a very simple model, but it provides minimal necessary information for several optimizations, such as ADCE (Aggressive Dead Code Elimination) and instruction reordering, which I feel can have a relatively significant impact.

In the future, I would like to have a more rigorous model, and I plan to work on that in collaboration with Lane.