<div dir="ltr">That wasn't the part that confused me. What confused me was what you expected to be encoded into the instruction. Your math indicated that you multiple n by 3 and added 1 to it to get your 13 bytes. So that means you intend to use 4 bytes to store an address in 32 bits which implied to me that you intended to have a fixed address encoded. But what if the address in in a register as would often be the case in real code. For example, when a pointer is passed as operand to a function. Most X86 instructions support a format of (base + scale * index + displacement) where any of those pieces are optional, but it takes up to 6 bytes to encode them.</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 Tue, Mar 20, 2018 at 10:25 AM, 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">Whoops - sorry for the confusion. n would be set in stone beforehand. I basically meant to indicate that we'd either be looking at a 32 bit or 64 bit system, ie 4 byte or 8 byte addresses. <div class="HOEnZb"><div class="h5"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Mar 20, 2018, 1:07 PM Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Gus,<div><br></div><div>When you say "n byte destination" you mean you want to encode an n byte address as a constant within the instruction? That would mean you couldn't encode an address that comes from a register.</div></div><div class="gmail_extra"><br clear="all"><div><div class="m_-7441932123683928331m_-2442729590877849686gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Mar 20, 2018 at 9:48 AM, 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><div class="gmail_extra"><div class="gmail_quote"><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:#000000">Hi all. </div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000">tl;dr: I would like to add a long x86 instruction which doesn't conform to any existing format that I know; I'm not sure where to start.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000">I am attempting to add an instruction into X86, to be simulated in gem5. I've already added a simple, opcode-only instruction which I can successfully decode and run in gem5, so I am roughly familiar with .td files and how backends are built out of them.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif;color:#000000">My goal now is to make a more complex instruction -- specifically, I need to add large operands. The format would look something like this:</div><div class="gmail_default"><ul><li><font color="#000000" face="arial, helvetica, sans-serif">1 byte opcode (0x06, which I hijacked from PUSHES, which isn't implemented in gem5)</font></li><li><font color="#000000" face="arial, helvetica, sans-serif">n byte destination (memory location)</font></li><li><font color="#000000" face="arial, helvetica, sans-serif">n byte source (memory location)</font></li><li><font color="#000000" face="arial, helvetica, sans-serif">n byte source (memory location or immediate)</font></li></ul><div><font color="#000000" face="arial, helvetica, sans-serif">If n=4, then the total opcode length is 13 bytes, which is under the 15 byte x86 limit.</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">As far as I know, this doesn't conform to any existing x86 format. Because that's the case, I'm not sure how to go about encoding an instruction like this; presumably, I can't use the existing I<..> class, which is what I'd used previously.</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Can anyone point me in the general direction of what I will need to do to encode this rather arbitrary instruction format? Should I look into implementing a new Instruction class? Is there an easier way?</font></div><div><font color="#000000" face="arial, helvetica, sans-serif"><br></font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Thanks,</font></div><div><font color="#000000" face="arial, helvetica, sans-serif">Gus Smith, PSU</font></div></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">______________________________<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>
</div></div></blockquote></div><br></div>