Xiaochu Liu via llvm-dev
2015-Aug-27 01:51 UTC
[llvm-dev] preserve registers across function call
Hi Marcello, Thanks for your reply. I will try to pass down the mask! I have one more question. In my backend I return CSR_RegMask in getCallPreservedMask and return CSR_SaveList in getCalleeSavedRegs. Is that a correct setup? I dumped the regmask and found that callee saved regs are marked 1 and non-callee saved regs are 0. Thanks, Xiaochu On Wed, Aug 26, 2015 at 5:58 PM Marcello Maggioni <mmaggioni at apple.com> wrote:> Is the preserved mask passed down to your Call instruction in LowerCall ? > > Marcello > > On 26 Aug 2015, at 17:52, Xiaochu Liu via llvm-dev < > llvm-dev at lists.llvm.org> wrote: > > Dear there, > > I was wondering how to preserve registers (caller saved) across calls. I > implemented getCalleeSavedRegs and getCallPreservedMask. But the > non-callee-saved registers are still not saved by caller. I want to spill > these registers in use on stack right before the call. From my > understanding, the register allocator in llvm will do the spill and > restoring automatically? Is there anything I was supposed to do to make it > happen? > > Thanks, > Xiaochu > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > > https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=THu9ANfN9LYlQTYNQdmA7D-MsdMl2OioTAKXjMfn7i4&m=T0_ZG8YhyugTycTFs3lQPt6d4mu6n739A4TOI-X1aJ0&s=xBBwHMhNOhAnZr_RXMJN6_kyjY2Wnap1c9aCtrfM7T8&e> > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150827/d23075f6/attachment.html>
Marcello Maggioni via llvm-dev
2015-Aug-27 04:51 UTC
[llvm-dev] preserve registers across function call
Yes, RegMask is what you should use for the CallPreservedMask. It means that the registers set as 1 are preserved from the Call (the callee saved) and the ones marked as 0 need to be saved instead. Cheers, Marcello> On 26 Aug 2015, at 18:51, Xiaochu Liu <xiaochu1122 at gmail.com> wrote: > > Hi Marcello, > > Thanks for your reply. I will try to pass down the mask! > I have one more question. In my backend I return CSR_RegMask in getCallPreservedMask and return CSR_SaveList in getCalleeSavedRegs. Is that a correct setup? I dumped the regmask and found that callee saved regs are marked 1 and non-callee saved regs are 0. > > Thanks, > Xiaochu > > > > On Wed, Aug 26, 2015 at 5:58 PM Marcello Maggioni <mmaggioni at apple.com <mailto:mmaggioni at apple.com>> wrote: > Is the preserved mask passed down to your Call instruction in LowerCall ? > > Marcello > >> On 26 Aug 2015, at 17:52, Xiaochu Liu via llvm-dev <llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org>> wrote: >> > >> Dear there, >> >> I was wondering how to preserve registers (caller saved) across calls. I implemented getCalleeSavedRegs and getCallPreservedMask. But the non-callee-saved registers are still not saved by caller. I want to spill these registers in use on stack right before the call. From my understanding, the register allocator in llvm will do the spill and restoring automatically? Is there anything I was supposed to do to make it happen? >> >> Thanks, >> Xiaochu > >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org <mailto:llvm-dev at lists.llvm.org> >> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=THu9ANfN9LYlQTYNQdmA7D-MsdMl2OioTAKXjMfn7i4&m=T0_ZG8YhyugTycTFs3lQPt6d4mu6n739A4TOI-X1aJ0&s=xBBwHMhNOhAnZr_RXMJN6_kyjY2Wnap1c9aCtrfM7T8&e= <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=THu9ANfN9LYlQTYNQdmA7D-MsdMl2OioTAKXjMfn7i4&m=T0_ZG8YhyugTycTFs3lQPt6d4mu6n739A4TOI-X1aJ0&s=xBBwHMhNOhAnZr_RXMJN6_kyjY2Wnap1c9aCtrfM7T8&e=> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150826/405c6325/attachment.html>
Xiaochu Liu via llvm-dev
2015-Aug-27 16:57 UTC
[llvm-dev] preserve registers across function call
Thank you so much, Marcello! Regards, Xiaochu On Wed, Aug 26, 2015 at 9:51 PM Marcello Maggioni <mmaggioni at apple.com> wrote:> Yes, RegMask is what you should use for the CallPreservedMask. > It means that the registers set as 1 are preserved from the Call (the > callee saved) and the ones marked as 0 need to be saved instead. > > Cheers, > Marcello > > On 26 Aug 2015, at 18:51, Xiaochu Liu <xiaochu1122 at gmail.com> wrote: > > Hi Marcello, > > Thanks for your reply. I will try to pass down the mask! > I have one more question. In my backend I return CSR_RegMask in > getCallPreservedMask and return CSR_SaveList in getCalleeSavedRegs. Is > that a correct setup? I dumped the regmask and found that callee saved regs > are marked 1 and non-callee saved regs are 0. > > Thanks, > Xiaochu > > > > On Wed, Aug 26, 2015 at 5:58 PM Marcello Maggioni <mmaggioni at apple.com> > wrote: > >> Is the preserved mask passed down to your Call instruction in LowerCall ? >> >> Marcello >> >> On 26 Aug 2015, at 17:52, Xiaochu Liu via llvm-dev < >> llvm-dev at lists.llvm.org> wrote: >> >> Dear there, >> >> I was wondering how to preserve registers (caller saved) across calls. I >> implemented getCalleeSavedRegs and getCallPreservedMask. But the >> non-callee-saved registers are still not saved by caller. I want to spill >> these registers in use on stack right before the call. From my >> understanding, the register allocator in llvm will do the spill and >> restoring automatically? Is there anything I was supposed to do to make it >> happen? >> >> Thanks, >> Xiaochu >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> >> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=THu9ANfN9LYlQTYNQdmA7D-MsdMl2OioTAKXjMfn7i4&m=T0_ZG8YhyugTycTFs3lQPt6d4mu6n739A4TOI-X1aJ0&s=xBBwHMhNOhAnZr_RXMJN6_kyjY2Wnap1c9aCtrfM7T8&e>> >> >> >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150827/f0fbd5dc/attachment.html>