<div dir="ltr">Hi, Tim,<br><div><br></div><div>Thanks for your reply. You are right, my MOVE and copyPhysReg are wrong. After I fix that, it works. </div><div><br></div><div>Regards,</div><div><br></div><div>Xiangyang</div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-11-25 17:27 GMT-05:00 Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 25 November 2015 at 14:06, Xiangyang Guo via llvm-dev<br>
<span class=""><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>       const unsigned VReg = RegInfo.createVirtualRegister(&FOO::PRegsRegClass);<br>
>       RegInfo.addLiveIn(VA.getLocReg(), VReg);<br>
>       SDValue ArgIn = DAG.getCopyFromReg(Chain, dl, VReg, RegVT);<br>
<br>
</span>Using MachineFunction::addLiveIn would probably be simpler, but I<br>
*think* this ought to be OK too.<br>
<span class=""><br>
> However, when I use llc and print-after-all to check the machine<br>
> instructions. At very beginning, the machine instructions look like this:<br>
><br>
>     %vreg1<def> = COPY %P1; PRegs:%vreg1<br>
>     %vreg0<def> = COPY %P0; PRegs:%vreg0<br>
>     %vreg3<def> = COPY %vreg0; GRRegsAdditional:%vreg3 PRegs:%vreg0<br>
>     %vreg4<def> = COPY %vreg1; GRRegsAdditional:%vreg4 PRegs:%vreg1<br>
>     %vreg2<def> = ADDINT %vreg3, %vreg4; GRRegsAdditional:%vreg2,%vreg3,%vreg4<br>
>     %R10<def> = COPY %vreg2; GRRegsAdditional:%vreg2 RET %R10<br>
<br>
</span>This looks fine to me.<br>
<span class=""><br>
> And after "Post-RA pseudo instruction expansion pass", it looks like this<br>
<br>
</span>I don't suppose your copyPhysReg implementation does something<br>
degenerate for these? That's the callback that'll be used to actually<br>
implement any COPY pseudo-instructions that need to be materialised,<br>
not any TableGen related patterns you might have (as a general<br>
guideline, if you're writing a pattern for a MOV instruction, you're<br>
probably doing something wrong).<br>
<br>
It's a good idea for copyPhysReg to assert for anything it can't<br>
handle corrrectly.<br>
<br>
If it's not that, the entire output of "llc -debug" would be useful.<br>
Obviously a lot goes on between the two dumps you pasted here. Maybe<br>
some other pass is doing something slightly wrong.<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>