<div dir="ltr">Hi Krzysztof<div><br></div><div>Having read your email in more detail. I think I understand better. You mean the first few instructions are something related to frame setup which is not shown in the MIR code.</div><div><br></div><div>Is it possible to dump both the frame setup/cleanup MIR and the MIR I have at this moment? Now I execute my pass inside the addPreRegAlloc() function. Any suggestions on where should I add the pass so that I can obtain the information I need. Many thanks and sorry for not understanding your suggestion for the first time.</div><div><br></div><div>Regards</div><div>Muhui </div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-06-15 12:43 GMT-04:00 Muhui Jiang <span dir="ltr"><<a href="mailto:jiangmuhui@gmail.com" target="_blank">jiangmuhui@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">Hi Krzysztof<div><br></div><div>Thank you very much for your quick and clear reply. I know that MIR may not match hardware instructions directly. However, I think the semantics should be similar. </div><div><br></div><div>For example, the first instruction is a store-multiple instruction in ARM. I think the first four MIR I shown should have the similar semantics<span style="font-size:14px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span> with the first three hardware instructions. I still cannot see the relationships between them. Also, what does gpr mean.. Do I lost some information? Thank you so much if you can explain it in a little bit detail.</span></span></div><div><span style="font-size:14px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span><br></span></span></div><div><span style="font-size:14px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span>Regards</span></span></div><span class="HOEnZb"><font color="#888888"><div><span style="font-size:14px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><span>Muhui</span></span></div><div><br></div><div><br></div></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-06-15 12:33 GMT-04:00 Krzysztof Parzyszek via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That's a store-multiple that saves a few registers at the entry to the function. It's a part of the frame setup and it's generated during prolog/epilog insertion.<br>
<br>
The MIR code that you're showing is from before the frame creation, so it does not contain the instructions that do frame setup/cleanup.<br>
<br>
$noreg means "no register". It's used when an instruction required an operand that is a register, but none is specified. It's like a null-pointer but for registers. The instructions represented by MachineInstr do not have to match hardware instructions directly, many of them are instructions for compiler's internal use, so you can see things that don't match the final assembly.<br>
<br>
-Krzysztof<div><div class="m_-5203402817644506176h5"><br>
<br>
<br>
On 6/15/2018 11:28 AM, Muhui Jiang via llvm-dev wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_-5203402817644506176h5">
Hi<br>
<br>
I write a machinefunction pass to print all the machinefunction's machine instructions.<br>
<br>
My target architecture is ARM. However, I don't understand some part of the machine instructions.<br>
<br>
Below is some of the assembly language for function A.<br>
<br>
.text:0001C034 STMFD SP!, {R4,R10,R11,LR}<br>
.text:0001C038 ADD R11, SP, #8<br>
.text:0001C03C SUB SP, SP, #0x20<br>
.text:0001C040 STR R0, [R11,#statbuf]<br>
.text:0001C044 STR R1, [SP,#0x28+var_14]<br>
.text:0001C048 LDR R0, [SP,#0x28+var_14]<br>
.text:0001C04C LDR R0, [R0]<br>
.text:0001C050 STR R0, [SP,#0x28+ts]<br>
.text:0001C054 LDR R0, [SP,#0x28+ts]<br>
.text:0001C058 LDR R0, [R0,#4]<br>
.text:0001C05C CMN R0, #0xC0000002<br>
.text:0001C060 BNE loc_1C088<br>
.text:0001C064 B loc_1C068<br>
<br>
<br>
Below is the corresponding MachineInstr<br>
<br>
%1:gpr = COPY $r1<br>
<br>
%0:gpr = COPY $r0<br>
<br>
%3:gpr = COPY %1:gpr<br>
<br>
%2:gpr = COPY %0:gpr<br>
<br>
STRi12 %0:gpr, %stack.1.statbuf.addr, 0, 14, $noreg :: (store 4<br>
into %ir.statbuf.addr)<br>
<br>
STRi12 %1:gpr, %stack.2.ts.addr, 0, 14, $noreg :: (store 4 into<br>
%ir.ts.addr)<br>
<br>
%4:gpr = LDRi12 %stack.2.ts.addr, 0, 14, $noreg<br>
<br>
%5:gpr = LDRi12 killed %4:gpr, 0, 14, $noreg<br>
<br>
STRi12 killed %5:gpr, %stack.3.timespec, 0, 14, $noreg<br>
<br>
%6:gpr = LDRi12 %stack.3.timespec, 0, 14, $noreg<br>
<br>
%7:gpr = LDRi12 killed %6:gpr, 4, 14, $noreg<br>
<br>
CMNri killed %7:gpr, -1073741822, 14, $noreg<br>
<br>
Bcc %bb.3, 1, $cpsr<br>
<br>
B %bb.1<br>
<br>
<br>
I don't know how "STMFD SP!, {R4,R10,R11,LR}" is translated into the machineinstr. Also, what does $noreg mean? what does gpr and the value in front of it mean? It would be great if someone who are familiar with this can explain it to me or give me some reference. Thank you very much.<br>
<br>
Regards<br>
Muhui<br>
<br>
<br></div></div>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br><span class="m_-5203402817644506176HOEnZb"><font color="#888888">
</font></span></blockquote><span class="m_-5203402817644506176HOEnZb"><font color="#888888">
<br>
-- <br>
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>