I made a handwritten parser for a nontrivial programming language a while back, and all the time my intention was to try to use llvm as the backend. But all the tutorials I've come across simply tell you how to use certain features of llvm, without explaining the underlying theory etc. For example, I still don't really understand what SSA is. Does anyone know of a good llvm resource where I could read up on this stuff? Because it's really hard to implement my own stuff based on tutorials I don't quite understand :P
The simplest way of understanding SSA is that instead of having to worry about things like register use or push/popping the stack yourself, you let the backend (LLVM) figure it out for you.
For example, in basic assembly on the x86, if you want to multiply two values you would have to do things like:
1 2 3 4 5 6
call some_function ;with returns a value in eax
move eax to ecx ;because I want to save the current value in eax
mul eax with something
save edx:eax ; the value just computed
move ecx to eax ;because I'm going to use that value again
do something with eax
It can get messy fast, and we humans don't usually care to take the time to do it the most efficient way possible. Not to mention that any change in the algorithm makes a rearrangement likely.
With SSA, you can just say:
1 2 3
%1 = some_function()
%2 = %1 * something
do something with %1
It is cleaner and easier to read and maintain. Where LLVM finds place for all those %x values is not important to us -- it will do a good job.