r/Compilers • u/juicyroaster • May 16 '26
IR for my compiler
Since few days, I have been working on a compiler written in python. I have successfully implemented a frontend and I want a backend to generate IR for. I have decided to make my own IR but I don't know a lot about them. Can y'all please provide me with information with types of IR, optimization tricks they utilise, and how they are implemented or work. Any type of material will be thankful.
4
Upvotes
7
u/Falcon731 May 16 '26
I will probably get downvoted to oblivion for saying this - but for a hobby compiler where optimisation is not the main goal, SSA is an overkill.
For my compiler, I use a basic three-address-code scheme, and find that seems to be about the right balance.
Effectively my IR is like a RISC assembly, but with infinite registers and no limitations on immediate values.
6
u/knue82 May 16 '26
CFG with the address code in SSA form is arguably the most straightforward one where you find most resources. If you are feeling adventurous, you can also try sea of nodes.
1
u/notyetfallenicarus May 16 '26
A noob here. What is that compiler compiling? And what does implemented a frontend mean in this post's context?
2
u/[deleted] May 16 '26
[removed] — view removed comment
1
u/[deleted] May 16 '26
[removed] — view removed comment