1. 19

    1. 4

      This sounds a lot like something I came up with on my own when implementing a Smalltalk compiler as a college project. Same basic idea, tell the recursive expression code generator where it should put its output. IIRC I also had a “don’t care” register ID I could pass if the caller had no preference; the actual destination register was returned from the call. This improved the code gen a bit more.

    2. 2

      Let’s […] see if we can improve the generated code without going full regalloc.

      Hah, famous last words.

      I recently went down this rabbit hole. I was working on a compiler project, and thought it would be fun to do the SSA->ASM phase myself. I realised that register allocation is a central part of that phase. I learned a lot, but ended up replacing my with LLVM because I was getting distracted from the original intent of the project.

    3. 2

      Kind of like Tower of Hanoi.