<div dir="ltr"><div>Thank you for the instructions, Aaron and Nicolai!</div><div><br></div><div>Raising a binary to LLVM IR, or raising to MIR is a reasonable solution for me. However, given Nicolai's information that not all target-specific instructions are representable in MIR, I got two questions that need your help:</div><div><br></div><div>1. Why MIR does not necessarily represent all target specific instructions for certain hardware? If someone added those support, will this violate some design principles of MIR?</div><div><br></div><div>2. Instead of IR/MIR raising, I am wondering whether a third path is possible to solve the problem of analyzing assembly code:</div><div><b> - write simple LLVM pass in the `MC` layer to process information not available in MIR/IR and </b></div><div><b> - passing analysis result from IR/MIR pass to the MC layer pass where we can enhance the result with missing representations.</b></div><div>So the second question is whether it is possible to write passes directly in the MC layer? If so, is there any documentation or example for that?<br></div><div><br></div><div><br></div><div>Thank you in advance!</div><div><br></div><div>Best Regards,</div><div>Lele</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 25, 2019 at 9:15 AM Aaron Smith <<a href="mailto:aaron.lee.smith@gmail.com" target="_blank">aaron.lee.smith@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Llvm-mctoll will raise a binary back to LLVM IR. <div>Not exactly what you want but it might be something you can leverage.</div><div><br></div><div><a href="https://github.com/microsoft/llvm-mctoll" target="_blank">https://github.com/microsoft/llvm-mctoll</a> </div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 25, 2019 at 1:19 PM Nicolai Hähnle via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Nov 21, 2019 at 3:37 AM Lele Ma via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> My goal is to write LLVM Machine IR (MIR) passes to analyze the assembly source code. But it seems I need to find a way to translate the handwritten assembly code into MIR format first.<br>
><br>
> Is there any materials, or any modules in LLVM source code, that can help to translate assembly code into LLVM MIR for analysis?<br>
><br>
> Or is there any easier ways to analyze assembly code in MIR passes without translating it?<br>
<br>
MachineIR is designed for code generation, not for general assembly<br>
representation. MIR is even not necessarily able to represent all<br>
assembly instructions that a target's hardware supports. The<br>
disassembler produces MCInsts, and if you wanted to go from there back<br>
to MachineIR, you'd have to write your own target-specific code to do<br>
so.<br>
<br>
Cheers,<br>
Nicolai<br>
<br>
<br>
<br>
><br>
> Best Regards,<br>
> Lele Ma<br>
><br>
><br>
> _______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br>
<br>
<br>
-- <br>
Lerne, wie die Welt wirklich ist,<br>
aber vergiss niemals, wie sie sein sollte.<br>
_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div></div>