<div dir="ltr"><div>Hi Tim,<br>I'm sorry to bother you again. Since I have met the problem, how to check used registers and avoid clobbering live registers, which you mentioned in the email. <br></div>I am working in the function X86InstrInfo::storeRegToStackSlot, which is in lib/Target/X86/X86InstrInfo.cpp. <br><div>And I have an extra problem, may I use MOV64mr and two addReg to set two registers as its arguments? I want to use content of one register as the address to be stored, and content of the other register as the source. <br></div><div><br>Thanks a lot!<br></div><div>Will<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-04-13 22:11 GMT+08:00 Will Lester <span dir="ltr"><<a href="mailto:hslester96@gmail.com" target="_blank">hslester96@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks for your help! I'm much more clear about this problem. <br></div><span class="HOEnZb"><font color="#888888">Will<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-04-13 17:53 GMT+08: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">Hi Will,<br>
<br>
On 13 April 2018 at 09:50, Will Lester via llvm-dev<br>
<span><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> I have used BuildMI to build a MachineInstr. But it seems that a call<br>
> MachineInstr only has one parameter which is a<br>
> register(%physreg44<imp-use>?)<wbr>.<br>
<br>
</span>This depends on the target, but calls normally have a few operands:<br>
<br>
  + The callee (a register or a global address or something).<br>
  + A regmask indicating which registers the call preserves.<br>
  + A list of imp-uses and imp-defs for the registers used to pass and<br>
return parameters.<br>
<br>
If you writie a .ll file that makes a call you should be able to see<br>
all these components in the generated MIR.<br>
<span><br>
> Therefore how can I set the callee function and the arguments of the function?<br>
<br>
</span>For a direct call, you'd normally use MachineInstrBuilder's<br>
addGlobalAddress to set the callee. You have to emit separate moves<br>
and stores before the call to put the arguments in the correct<br>
registers and stack slots. Be careful not to clobber live registers!<br>
<br>
We can probably give a few more details (like the call instruction to<br>
use, and which registers pass parameters; maybe some extra quirks) if<br>
we know the actual target you're compiling for, but the outline above<br>
won't change significantly.<br>
<br>
Cheers.<br>
<span class="m_-9031327946135451323HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>