A quick look at destination-driven code generation
bernsteinbear.com
bernsteinbear.com
[0] https://github.com/lboasso/oberonc/blob/master/doc/Moe00b.pd...
The relevant section is 10.2. But its mechanism is the “inverse” of destination driven code generation as I understand it. In Wirth’s Item approach the callee picks a location and tells the caller where to look. Whereas in destination driven code generation the caller tells the callee where to put the result.
[0] https://www.research-collection.ethz.ch/bitstream/handle/20....
If that's the problem statement, then you may as well perform register allocation: all you need is Sethi–Ullman's algorithm [0][1], and it's quite simple.
Register allocation only becomes complicated when the control flow comes into the picture, especially the loops. Even then, there are some more or less obvious ways to do it, if you don't want to do graph colouring after Chaitin et al. (remember, people had to write register allocators before Chaitin's publication in 1981). For instance, you can do what the very first FORTRAN compiler did: you look at registerts as a cache for memory, in which case the Bélády's algorithm can be used for spilling. And with loops over arrays you can leverage the knowledge that you're looping over arrays quite nicely [2].
[0] https://en.wikipedia.org/wiki/Sethi%E2%80%93Ullman_algorithm
[1] https://dl.acm.org/doi/pdf/10.1145/321607.321620
[2] https://archive.computerhistory.org/resources/text/Fortran/1...
BTW I really like the design of Virgil described in "Harmonizing Classes, Functions, Tuples,and Type Parameters in Virgil III", bravo!