-
Notifications
You must be signed in to change notification settings - Fork 8
Notes
Bevin Hansson edited this page Oct 11, 2018
·
7 revisions
Just random notes.
- Use processFunctionBeforeFrameFinalized in TargetFrameInfo to do push-pop optimization. We can eliminate dead frame objects by marking them as such and they will be excluded from the stack.
- LAO is -1 since the SP points to top of stack at function entry.
- Prologue can either use
ADD SP+eif we are GB (what about optz? can they expand the stack somehow?).- Otherwise we need to do some kind of
LD HL, dd; ADD HL, SP; LD SP, HL. This needs to save HL if it's live (an input parameter) - The solution in this case could be to add HL as a CSR. (but then it will be restored? we don't want that.)
- Wait, what about (forgot what i was going to write here lol)
- Basically what we want is simply to add a frame object before/after the CSR frame objects are added, so we can do a
PUSH HLbefore/after CSR and then restore it with a frame index load after the prologue. - This is all a good argument for excluding HL from the calling convention.
- Otherwise we need to do some kind of
Prologue is basically:
if HL is live && (!GB || largeStack):
Push HL (this should have the last frame object index if we do it right)
Push CSR
if GB:
Repeat:
ADD SP-stackSize
else:
LD HL, -stackSize
ADD HL, SP
LD SP, HL
HL = LD16_FI (frameidx of the HL we pushed) (how to make this frameindex access efficient? It's at the very far end of the stack from the HL we just made!)
Epilogue is much harder if HL is live-out, since we can't do the PUSH HL trick on function exit.