<div dir="ltr">ASM is the text output you want printed in a textual listing of the assembly. The curly braces you see in some text strings like "adcx{l}\t{$src, $dst|$dst, $src}" are there to provide different operand orders for at&t syntax vs intel syntax. Anything after $ matches the name in the outs/in part of the instruction.<div><br></div><div>IIC_SSE_PREFETCH is part of the scheduler system to provide latency/throughput information about the instruction.</div><div><br></div><div>PD indicates the instruction should be on the 0x0f two byte opcode map with a 0x66 prefix.</div><div><br></div><div>Most common other values in place of PD</div><div>TB - 0x0f opcode map no prefix(0x66, 0xf2, 0xf3) and use of one of those prefixes should be ignored by the disassembler.</div><div>PS - 0x0f opcode map no prefix, but if the disassembler sees a prefix it should not decode to this instruction. Should be used when there is another instruction with the same opcode that uses a prefix</div><div>PD - 0x0f opcode map with 0x66 prefix</div><div>XS - 0x0f opcode map with 0xf3 prefix</div><div>XD - 0x0f opcode map with 0xf2 prefix</div><div>T8 - 0x0f 0x38 opcode map with no prefix</div><div>T8PS - 0x0f 0x38 opcode map version of PS from above</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">T8PD - 0x0f 0x38 opcode map version of PD from above</span><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">T8XS - 0x0f 0x38 opcode version of XS from above</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">T8XD - 0x0f 0x38 opcode version of XD from above</span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">TA - 0x0f 0x3a opcode map with no prefix</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">TAPS - 0x0f 0x3a opcode map version of PS from above</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">TAPD - 0x0f 0x3a opcode map version of PD from above</span><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial">TAXS - 0x0f 0x3a opcode version of XS from above</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration-style:initial;text-decoration-color:initial"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">TAXD - 0x0f 0x3a opcode version of XD from above</span></div></span></div><br></span></div><br></span></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Sun, Mar 18, 2018 at 7:39 PM, Gus Smith <span dir="ltr"><<a href="mailto:gushenrysmith@gmail.com" target="_blank">gushenrysmith@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">Craig, thanks for the quick response. That helps a lot. I had no clue they were buried in there, though I guess I should have looked harder -- the hex should have given me a clue, perhaps!</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">For the sake of my own edification (and not taking up too much of your time) I will try to generate it myself. I've found the definition of the "I" class at line 358 of llvm/lib/Target/X86/<wbr>X86InstrFormats.td, which helps a lot.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">Let's assume I want to produce opcode 0x16 (which I'm using because it doesn't seem to be implemented in gem5 otherwise, and would simply produce a warning). Then my guess is that I should use something like:</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">

<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">def CACHEADD : I<0x16, FORMAT, (outs), (ins),</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">                   ASM, [(int_cache_add)]<span style="font-size:12.8px">>, PD;</span></div>

<br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">where FORMAT comes from <a href="http://legup.eecg.utoronto.ca/doxygen/namespacellvm_1_1X86II.html" target="_blank">http://legup.eecg.<wbr>utoronto.ca/doxygen/<wbr>namespacellvm_1_1X86II.html</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">and ASM = ???</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">and i deleted 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">IIC_SSE_PREFETCH (because I'm not sure what this flag indicates, but I assume it's not needed).</span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I'm not sure what that PD is or if it should stay.</span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:12.8px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Looking for input on this! Clearly it's not correct as-is, but I feel like I'm at least understanding parts of it. Thanks!</span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default"><font color="#000000" face="arial, helvetica, sans-serif">For posterity, this page helped a lot, and probably should have been read first: </font><a href="https://llvm.org/docs/TableGen/index.html" target="_blank"><font color="#000000" face="arial, helvetica, sans-serif">https://llvm.org/docs/<wbr>TableGen/index.html</font><br></a>In smaller part, this one helped too, but read the above page first: <a href="https://llvm.org/docs/TableGen/LangRef.html" style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif" target="_blank">https://llvm.org/docs/<wbr>TableGen/LangRef.html</a></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 18, 2018 at 7:43 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Here's a couple examples for mapping an intrinsic to an X86 instruction from X86InstrInfo.td. If you look for int_x86_* in any X86Instr*.td you can find others.<div><br></div><div><div>let Predicates = [HasCLFLUSHOPT], SchedRW = [WriteLoad] in</div><div>def CLFLUSHOPT : I<0xAE, MRM7m, (outs), (ins i8mem:$src),</div><div>                   "clflushopt\t$src", [(int_x86_clflushopt addr:$src)],</div><div>                   IIC_SSE_PREFETCH>, PD;</div><div><br></div><div>let Predicates = [HasCLWB], SchedRW = [WriteLoad] in</div><div>def CLWB       : I<0xAE, MRM6m, (outs), (ins i8mem:$src), "clwb\t$src",</div><div>                   [(int_x86_clwb addr:$src)], IIC_SSE_PREFETCH>, PD;</div></div><div><br></div><div>The encoding information for the binary output is buried in these definitions too. If you tell me what opcode you've chosen I can tell you what the right things are to get the binary output.</div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="m_-5029928306171413065m_9163646921718116986gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote"><div><div class="m_-5029928306171413065h5">On Sun, Mar 18, 2018 at 3:22 PM, Gus Smith via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> 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_-5029928306171413065h5"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">Hello all. LLVM newbie here. If anything seems glaringly wrong with my use of LLVM, that's probably why.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">Here's what I'm trying to do. I have modified the gem5 simulator to accept a "new" x86 instruction. I've done this by just reserving the opcode in gem5's ISA specification, just as all other instructions are specified.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:rgb(0,0,0)">I'm trying to get an LLVM backend to generate this opcode during code generation. My current plan is:</div><div class="gmail_default"><ol><li><font color="#000000" face="arial, helvetica, sans-serif">During an LLVM pass, I'll detect a series of instructions which can be replaced with this new instruction. (The new instruction is a "cache compute" instruction -- in my passes, I replace a series of loads, operations, and stores with this single instruction.) This step is complete.<br></font></li><li><font color="#000000" face="arial, helvetica, sans-serif">I replace the series of instructions with an intrinsic. I have added an intrinsic using the instructions <a href="https://llvm.org/docs/ExtendingLLVM.html#adding-a-new-intrinsic-function" target="_blank">here</a>. This step is complete.</font></li><li><font color="#000000" face="arial, helvetica, sans-serif">During code generation, the intrinsic should be converted to this reserved opcode. This is where I'm stuck.</font></li></ol><div><font color="#000000" face="arial, helvetica, sans-serif">I'm stuck on step 3. I have two main questions that should unblock me:</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Question 1: where is the code that maps from intrinsics to instructions? The link above states: </font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">"Add support to the .td file for the target(s) of your choice in lib/Target/*/*.td. </font><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">This is usually a matter of adding a pattern to the .td file that matches the intrinsic, though it may obviously require adding the instructions you want to generate as well. There are lots of examples in the PowerPC and X86 backend to follow." </span></div><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">However, looking through these examples isn't illuminating anything for me. Any more documentation or high-level explanation on this subject would be really helpful. I have read something about "lowering" of intrinsics; not sure if that's relevant.</span></div><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif"><br></span></div><div><span style="color:rgb(0,0,0);font-family:arial,helvetica,sans-serif">Question 2: will I be able to generate this opcode directly from the intrinsic, or will I have to add the opcode as an LLVM IR instruction and specify how it gets compiled? I can imagine two options: </span></div><div><font color="#000000" face="arial, helvetica, sans-serif">option 1: I can define a "translation" from intrinsic straight to an x86 opcode.</font></div><div><font color="#000000" face="arial, helvetica, sans-serif">option 2: I can define a "translation" (perhaps in a .td file? I think that's what they're used for) which translates my intrinsic into a new instruction, and then I can define another translation which will map the new instruction to my opcode during code gen. If this is the case, I'm not sure there's any point to having an intrinsic; I should just add a new instruction instead.</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Hoping someone can help! As you can tell, I'm a little lost...the documentation for LLVM is great, but it's a little above my level right now :)</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Gus Smith, PSU</font></div><div><br></div></div></div>
<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></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>