Steve Ellcey <[email protected]> writes: > On Wed, 2018-05-16 at 17:30 +0100, Richard Earnshaw (lists) wrote: >> On 16/05/18 17:21, Steve Ellcey wrote: >> > >> > It doesn't look like GCC has any existing mechanism for having different >> > sets of caller saved/callee saved registers depending on the function >> > attributes of the calling or called function. >> > >> > Changing what registers a callee function saves and restores shouldn't >> > be too difficult since that can be done when generating the prologue >> > and epilogue code but changing what registers a caller saves/restores >> > when doing the call seems trickier. The macro >> > TARGET_HARD_REGNO_CALL_PART_CLOBBERED doesn't know anything about the >> > function being called. It returns true/false depending on just the >> > register number and mode. >> > >> > Steve Ellcey >> > [email protected] >> > >> >> Actually, we can. See, for example, the attribute((pcs)) for the ARM >> port. I think we could probably handle this automagically for the SVE >> vector calling convention in AArch64. >> >> R. > > Interesting, it looks like one could use aarch64_emit_call to emit > extra use_reg / clobber_reg instructions but in this case we want to > tell the caller that some registers are not being clobbered by the > callee. The ARM port does not > define TARGET_HARD_REGNO_CALL_PART_CLOBBERED and that seemed like one > of the most problamatic issues with Aarch64. Maybe we would have to > undefine this for aarch64 and use explicit clobbers to say what > floating point registers / vector registers are clobbered for each > call? I wonder how that would affect register allocation.
TARGET_HARD_REGNO_CALL_PART_CLOBBERED is the only current way of saying that an rtl instruction preserves the low part of a register but clobbers the high part. We would need something like Alan H's CLOBBER_HIGH patches to do it using explicit clobbers. Another approach would be to piggy-back on the -fipa-ra infrastructure and record that vector PCS functions only clobber Q0-Q7. If -fipa-ra knows that a function doesn't clobber Q8-Q15 then that should override TARGET_HARD_REGNO_CALL_PART_CLOBBERED. (I'm not sure whether it does in practice, but it should :-) And if it doesn't that's a bug that's worth fixing for its own sake.) Thanks, Richard
