arm64: fix slots with offset >32k
commit367c8215d99054892740ad74c690b106c45ebf60
authorQuentin Carbonneaux <quentin@c9x.me>
Sun, 5 Dec 2021 20:25:00 +0000 (5 21:25 +0100)
committerQuentin Carbonneaux <quentin@c9x.me>
Sun, 5 Dec 2021 21:06:23 +0000 (5 22:06 +0100)
tree3ef0d974a740524e684b73ea26c59cafb4ca9416
parentbf153b359e9ce3ebef9bca899eb7ed5bd9045c11
arm64: fix slots with offset >32k

When slots are used with a large offset,
the emitter generates invalid assembly
code. That is caught later on by the
assembler, but it prevents compilation
of programs with large stack frames.

When a slot offset is too large to be
expressed as a constant offset to x29
(the frame pointer), emitins() inserts
a late Oaddr instruction to x16 and
replaces the large slot reference with
x16.

This change also gave me the opportunity
to refactor the save/restore logic for
callee-save registers.

This fixes the following Hare issue:
https://todo.sr.ht/~sircmpwn/hare/387
arm64/emit.c