On 09/09/2016 04:58 AM, Bernd Schmidt wrote:
On 09/08/2016 07:20 PM, Jeff Law wrote:
On 08/29/2016 03:31 AM, Bernd Schmidt wrote:
How do these actually know where to save/restore registers? The frame
pointer may have been eliminated, and SP isn't necessarily constant
during the function. Seems like you'd have to calculate CFA reg/offset
much like dwarf2out does and pass it to this hook.
So I think the confusion here is these hooks are independent of
placement. ie, the target independent code does something like:

FOR_EACH_BB
  Build the component bitmap using the incoming edge components
  Emit the prologue components at the start of the block
  Emit the epilogue components at the end of the block


The components handled by a particular block start are set/cleared by
the other hooks.

Hmm? The problem is that you can't generally emit a save/restore
independent of placement, because you may not know which offset to use
from whichever base register. But these offsets aren't necessarily
constant throughout the function. Segher explained that the algorithm
deals with this by giving up in many cases, which of course limits the
usefulness. It probably makes it unusable entirely on targets that want
to use pushes for function args.
On a target with ACCUMULATE_OUTGOING_ARGS the offsets are generally going to be constant. For a target that's pushing args and not using a frame pointer, this isn't likely to work. But that's OK as those targets wouldn't define the hooks or would test for those cases within the given hooks. I can envision (but will certainly not implement) separate shrink wrapping on m68k with a frame pointer in Segher's framework.

Essentially the hooks push these decisions into the target machine, which is where they belong. FUrthermore, the hooks can build a custom sequence for each insertion point.

That allows (as an example) the PPC LR save/restore sequence to use r0 as an intermediate register for that case. We could use those mechanisms to ensure there's a scratch register at the insertion point for address computations on targets that need them, etc.



Jeff

Reply via email to