Craig Topper via llvm-dev
2016-Sep-23 15:20 UTC
[llvm-dev] Misuse of MRI.getRegClass in multiple target's FastIsel code
This code or subtle variations of it appears in multiple targets. It tries to convert from a register to a register class using getRegClass, but getRegClass is really supposed to take a register class enum value and get the register class object for it. It doesn't convert a register to a class. In fact there's not always a single or canonical class for a given register. What is the right way to do this? unsigned SrcReg = Reg + VA.getValNo(); unsigned DestReg = VA.getLocReg(); // Avoid a cross-class copy. This is very unlikely. if (!MRI.getRegClass(SrcReg)->contains(DestReg)) return false; ~Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160923/3927db50/attachment.html>
Krzysztof Parzyszek via llvm-dev
2016-Sep-23 15:30 UTC
[llvm-dev] Misuse of MRI.getRegClass in multiple target's FastIsel code
MachineRegisterInfo::getRegClass does take a virtual register and returns the TargetRegisterClass of that register. You're thinking about TargetRegisterInfo::getRegClass. -Krzysztof On 9/23/2016 10:20 AM, Craig Topper via llvm-dev wrote:> This code or subtle variations of it appears in multiple targets. It > tries to convert from a register to a register class using getRegClass, > but getRegClass is really supposed to take a register class enum value > and get the register class object for it. It doesn't convert a register > to a class. In fact there's not always a single or canonical class for a > given register. > > What is the right way to do this? > > unsigned SrcReg = Reg + VA.getValNo(); > unsigned DestReg = VA.getLocReg(); > // Avoid a cross-class copy. This is very unlikely. > if (!MRI.getRegClass(SrcReg)->contains(DestReg)) > return false; > > > ~Craig > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Craig Topper via llvm-dev
2016-Sep-23 15:31 UTC
[llvm-dev] Misuse of MRI.getRegClass in multiple target's FastIsel code
Yeah I just noticed that. Thanks! ~Craig On Fri, Sep 23, 2016 at 8:30 AM, Krzysztof Parzyszek via llvm-dev < llvm-dev at lists.llvm.org> wrote:> MachineRegisterInfo::getRegClass does take a virtual register and returns > the TargetRegisterClass of that register. You're thinking about > TargetRegisterInfo::getRegClass. > > -Krzysztof > > > On 9/23/2016 10:20 AM, Craig Topper via llvm-dev wrote: > >> This code or subtle variations of it appears in multiple targets. It >> tries to convert from a register to a register class using getRegClass, >> but getRegClass is really supposed to take a register class enum value >> and get the register class object for it. It doesn't convert a register >> to a class. In fact there's not always a single or canonical class for a >> given register. >> >> What is the right way to do this? >> >> unsigned SrcReg = Reg + VA.getValNo(); >> unsigned DestReg = VA.getLocReg(); >> // Avoid a cross-class copy. This is very unlikely. >> if (!MRI.getRegClass(SrcReg)->contains(DestReg)) >> return false; >> >> >> ~Craig >> >> >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >> >> > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted > by The Linux Foundation > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160923/2de737d0/attachment.html>