[llvm-dev] Marking a register as reserved midway through register allocation
Dylan McKay via llvm-dev
llvm-dev at lists.llvm.org
Sun Apr 30 20:27:53 PDT 2017
I'm attempting to rewrite something that the AVR backend used to support
(through an extremely dirty hack that was reverted before the upstreaming
of the target).
The removal of the hack can be seen on GitHub
On the AVR architecture, the stack pointer is not in a standard register,
but rather it is a special register which can only be accessed via I/O
instructions. In order to implement stack spilling/restoring we need to
adjust the stack pointer, which is a problem because we need the value of
SP to be in a general purpose register for us to perform arithmetic on it.
In AVR-GCC, a frame pointer (the 'Y' register) is reserved if there are any
spills in a method. This works fine because we can easily perform
arithmetic on it and then save it into the real stack pointer via IO
I would like to do the same for LLVM. This is tricky however, because we
don't know if we need a frame pointer until we've finished register
allocation and we've seen a spill.
In the event that we do see a spill, it is likely that the 'Y' register has
already been allocated to some other variable, and so we somehow need to
deallocate it and then rewind the regalloc. That is what the old hack above
Is there any way today I can deallocate a register and rewind allocation
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev