Closed matsc-at-sics-se closed 6 years ago
Some more thoughts.
On ARM, transformations that expose the stack pointer in sp-relative reads/writes/leas seem to happen in uni export. I suppose X86 can do the same.
Here is an idea for handling temporaries allocated to the memory register bank on X86. X86 has plenty of instructions of the forms:
plus some variants, for most ALU operations.
Suppose that we introduce Unison pseudos ("u" for Unison) for most instructions with memory operands:
Then uni export can transform them to native X86:
and an ADD64* selected by llvm can be turned into a choice
{ADD64ur, ADD64ru, ADD64rr}
Congruent memory operands is a new(?) Unison feature, which likely interferes with their current preassignment logic. So that algorithm needs revisiting.
I added an ImportPostLift transformation that turns things like:
o97: [t94] <- MOV32rm [%stack.0,4,t93,0,_] (mem: 0)
frame:
%stack.0: offset = 80, size = 12, align = 8
into:
o97: [t94] <- MOV32rm [rsp,4,t93,80,_] (mem: 0)
It seems to work for now, but may need revisiting when stack frames are sorted out.
Largely handled in the closed issue #14 . Closing the issue. Temporaries residing in memory and congruent memory operands will be the topic of another issue.
I'm not sure where in the tool-chain this should go, but here are some initial thoughts. This issue is strongly related to spilling.
From SU_init_alloc_mem.uni:
Now pretend that the last line had read:
Then somewhere the two operations should be transformed into:
Note that o53/t69 is in fact rematerializable, provided that %rsp does not change in the mean time. That could depend on context and is related to ADJSTACKCALL* magic.
Finally, the "memory" part of the register array should roughly correspond to the stack frame, I guess.