I'm writing a compiler that compiles to C. This means that most of the time I piggyback on top of C for optimisations and generating code for multiple platforms.
Right now I can think of a few reasons why it might be beneficial:
- I can perform specific optimisations for my language
- It will be easier to translate the simplified SSA into C than it would be to handle all the edge cases in translating my semi-complex language to C
- It will make certain analysis on the code easier
I can think of a few drawbacks:
- The compiler is slower as I'll have to generate SSA IR
But is it worth it?
My main question is that will C be able to optimise code translated from an SSA IR well or better?
I imagine that the code the SSA form translates to will have labels and jumps everywhere. It wont use C constructs like for loops or if statements, etc. Will C find this easier or harder to optimise?
I'm keen on doing this purely to learn more about the SSA form, as well as if I eventually generate code for LLVM, it will be a bit easier.
Bonus question: is there a different IR I can look into that may be more suited to the problem at hand?