<div dir="ltr">Dear Tim,<div>Thank you for your thorough reply. So, based on your reply I get every operand and check them to be (isDef && !isimplicit). Now my problem is that it gives me the physical register number.i.e, for example, instead of r0, it returnĀ %physreg66. Could you please help me on how to convert these physical register number to the ARM related register? I mean the 15 GPRs in ARM.</div><div>Thank you,</div><div>Fami</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Dec 19, 2015 at 5:02 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Fami,<br>
<br>
On 19 December 2015 at 11:34, fateme Hoseini via llvm-dev<br>
<span class=""><<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
> I get my machine instruction, but I don't know how to get dest reg. I looked<br>
> at MachineInstr.h but couldn't find it out.<br>
<br>
</span>You probably want to iterate through the instruction's operands<br>
(MachineInstr::operands_begin/end) looking for defines ("isDef") of<br>
the registers you care about. Some instructions will write multiple<br>
registers (e.g. ldrd), and the information is in a certain sense<br>
approximate (an empty inline asm block may be marked as writing some<br>
registers, but not actually do anything).<br>
<br>
A call instruction "BL" also gets marked with the registers the<br>
function uses for return values so that LLVM can track data-flow. You<br>
may or may not want that, if not then looking for non-implicit<br>
(!isImplicit) defines might be a better approximation.<br>
<br>
Finally, you probably have to be aware of subregisters even for GPRs,<br>
the ARM-mode ldrd instructions can only take sequential pairs, which<br>
LLVM models as a separate register called something like R0_R1.<br>
<span class=""><br>
> Also I want to know which instructions to excluse from this routine, for<br>
> example str instruction does not write to a dest reg or branch instruction.<br>
<br>
</span>That's why you should check isDef for the ones you're after.<br>
<br>
Cheers.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div>