[fpc-devel] Is there a way to make Register Allocation inside of Interrupt Service Routines more efficient when using inline-assembler?
Sergei Gorelkin
sergei_gorelkin at mail.ru
Sun Aug 21 13:18:37 CEST 2016
21.08.2016 13:25, Karoly Balogh (Charlie/SGR) пишет:
>
> Well, one possible optimization would be to only save all volatiles if the
> interrupt routine actually calls another function. Otherwise only save the
> ones used by the current proc. This would allow some very small and very
> fast interrupt functions, right? I'm not sure though if there's an easy
> way to determine if there is a function call inside the function I'm
> generating code for.
>
> Maybe at the point of generating a function call, if the current proc is
> an interrupt, mark all volatiles as used somehow?
What you suggest is already implemented for ages. Any call node allocates all volatile registers
before doing the call and releases them afterwards, to indicate that these registers are modified by
callee. The same is done when a call to helper function is generated at low level (see
thlcg.g_call_system_proc). Furthermore, any call sets pi_do_call in current_procinfo.flags, to
simplify checking the case.
There's no difference in processing calls between 'interrupt' and regular caller procedures. The
difference only appears when generating caller's prologue/epilogue: a regular procedure won't save
volatile registers even if they are used, but 'interrupt' one will save them because it considers
all registers non-volatile.
The things are a bit trickier with inline assembler, because in general author may write anything
there, and compiler does no deep checks. For this reason, an assembler block without a list of
modified registers is historically considered equal to a call (i.e. modifies all volatile
registers). An explicit list of modified registers overrides that behavior, however.
Regards,
Sergei
More information about the fpc-devel
mailing list