<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Oct 29, 2013 at 1:21 PM, Jim Grosbach <span dir="ltr"><<a href="mailto:grosbach@apple.com" target="_blank">grosbach@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class="im">
<div>On Oct 26, 2013, at 5:02 PM, Chris Lattner <<a href="mailto:clattner@apple.com" target="_blank">clattner@apple.com</a>> wrote:</div><br><blockquote type="cite"><div style="word-wrap:break-word"><div><div>On Oct 25, 2013, at 5:22 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>> wrote:</div>
<blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">I’m not sure macros are a good analogy, but there are other pseudo-instructions that we’re not always able to reconstruct in disassembled code back to how the user wrote them. Or if we do, it’s purely via heuristic methods. I don’t see this as a big issue.</div>
</blockquote></div></div></div></blockquote><div><br></div><div>I agree.  These pseudo instructions seem like pure syntactic sugar that should never be produced by the disassembler.  That doesn't make them bad, in fact it makes them simpler to implement and reason about.</div>
<div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div><div>Do the ARM usages include allowing a single pseudo-instruction to expand to multiple real instructions? For example, a movw/movt pair? If so, I’m *very* opposed to that part. </div>
</div></blockquote></div></div></div></blockquote><div><br></div><div>Why?  For people writing assembly manually, having pseudo instructions to encapsulate common patterns is very useful.</div><div><br></div></div></div></blockquote>
<div><br></div></div><div>An assembler is not a compiler. When reading the assembly code, it should be clear what instructions are actually going into the output.</div></div></div></blockquote><div><br></div><div>This is mostly true in the case of kernel code when you're writing in assembler because of 1) extreme constraints that you can't really work with from C (e.g. no stack available, need to avoid touching certain registers, etc.) or 2) Need access to special instructions.</div>
<div><br></div><div>However, it is definitely not the case when the purpose of writing assembly code is in order to generate extremely high performance code, where essentially the assembler *is* used as a sort of domain-specific compiler (this is why basically all quality assemblers have powerful macro systems (I believe many are turing-complete, actually)). There is also a portability aspect where roughly the same code works for multiple targets, with minor variations. For example, check out these from x264 (a video encoder, and one of the most highly optimized programs in existence):</div>
<div><br></div><div>"domain-specific compiler":</div><div><a href="http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l881">http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l881</a></div>
<div><br></div><div><a href="http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l590">http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l590</a></div>
<div><br></div><div><a href="http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/dct-64.asm;h=c1aff843101f0081686f07ebe04908c7aa803e4a;hb=HEAD#l394">http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/dct-64.asm;h=c1aff843101f0081686f07ebe04908c7aa803e4a;hb=HEAD#l394</a><br>
</div><div><br></div><div>"portability":</div><div><a href="http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l88">http://git.videolan.org/?p=x264.git;a=blob;f=common/x86/x86inc.asm;h=ef45a2905bd8e3d920aa74d23a32fc0c169d9a57;hb=HEAD#l88</a></div>
<div><br></div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><div class="im"><br><blockquote type="cite"><div style="word-wrap:break-word"><div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">A single assembler instruction, pseudo or otherwise, should represent a single instruction in the final output. Even with a single instruction, I’m still leery, as it makes the source unclear whether a constant load is a plain ‘move’ instruction or a memory reference. That makes it very difficult to read the assembly and do any sort of thinking about performance considerations.</div>
</blockquote></div></div></div></blockquote><div><br></div><div>No one is compelled to use these if they don't want to.</div><div><br></div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div>x86 has this issue to an extent that goes far beyond what you describe here, and FWIW I've never seen a situation where it has been a problem. Usually when doing instruction-level/uarch-level optimization I find myself disassembling raw bytes in memory or in linked executables (or showing relocations in object files). The point of source code (even assembler) is to abstract over what is happening in the machine; when you specifically want to know what is happening in the machine you should use a tool designed to show you that, i.e. a disassembler (that shows raw bytes too).<br>

</div><div><br></div><div>Also, I think the fact that there are high-profile users (well, I guess they are potential users since this is currently broken) that use this feature overrides any "elegance"/"simplicity" concern about an instruction expanding differently, for the purposes of "is it acceptable to support this feature in LLVM if someone will do the work to implement and maintain it?".</div>

</div></div></div></blockquote><br></div><div>Given that this pseudo instruction is widely implemented and empirically used by important code bases like the Linux kernel, it seems like a no-brainer to support it IMO.</div>
<div><br></div><div>-Chris</div><br></div></blockquote></div></div><br></div></blockquote></div><br></div></div>