This is a question about writing compilers. I need...
# thinking-together
d
This is a question about writing compilers. I need to design an IR. Mine is for a pure functional + imperative language. What currently seems popular is SSA with block parameters, not phi nodes, which at least handles the imperative side of my language. My special concern is supporting efficient compile time evaluation (as well as partial evaluation). I guess I want the IR to be a compromise between supporting a fast interpreter (for compile time evaluation) vs supporting conventional compiler optimizations. Does anybody have experience with this?
a
looks like this could be interesting for you, but I'm not on the topic so cant say for sure https://futureofcoding.slack.com/archives/C0120A3L30R/p1639986127090700
a
I don't have real experience with this (and I'm probably too late anyway) but you don't have to (to large extent you can't) stick with single IR for everything. For the start you're going to begin with AST and I would define a compile-time interpreter/evaluator right at this stage. Or you can transform to A-normal form which is equivalent to SSA but looks like very simple functional language which again is easy to interpret. For lower-level optimisations I'd go with Sea-of-Nodes(-like) IR. And then maybe another (serial) IR for register allocation/instruction selection phase(s).