<div dir="ltr">Hi Linhai,<div><br></div><div>See <a href="http://llvm.org/docs/WritingAnLLVMBackend.html#id14">http://llvm.org/docs/WritingAnLLVMBackend.html#id14</a> for a description of how an LLVM backend describes machine instructions. LLVM has its own declarative language for this, called TableGen.</div>
<div><br></div><div>However, the semantics description is limited: you specify instruction behaviour in the form of LLVM IR DAGs that matches the functionality provided by an instruction. As you may have guessed, this will be used by the instruction selection algorithm. It is limited because some instructions may lack such information, requiring custom C++ code to select them.</div>
<div><br></div><div>An easy way to dump all information TableGen has about an architecture (X86, for instance) is to use the llvm-tblgen tool. If you built LLVM yourself, you will have it, but I am not sure if pre-built packages include it. Run it like this:</div>
<div><br></div><div>$ cd <myllvmsrc>/lib/Target/X86 # X86 backend folder</div><div>$ llvm-tblgen -print-records X86.td -I=../../../include &> <myfile.txt></div><div><br></div><div>Now open <myfile.txt>, a huge dump with all TableGen records for this architecture. Search for "-- Defs --", this string marks where all record definitions begin. You will see struct-like entities with all the information TableGen knows about each X86 instruction. What you are looking for is the "Pattern" field, a DAG describing this instruction semantics in terms of the LLVM IR.</div>
<div><br></div><div>Hope this helps,</div><div>Rafael</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Aug 22, 2014 at 12:54 AM, Linhai <span dir="ltr"><<a href="mailto:songlh@cs.wisc.edu" target="_blank">songlh@cs.wisc.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<span style="font-size:13px;font-family:arial,sans-serif">Hi,</span>
<div style="font-family:arial,sans-serif;font-size:13px"><br>
</div>
<div style="font-family:arial,sans-serif;font-size:13px"> I am
wondering whether LLVM code generators have a table describing the
x86-64 instructions semantics, something like a register transfer
language for all x86-64 instructions?<br>
<br>
Thanks a lot!<br>
</div>
</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>