<div dir="ltr"><div>(Sorry about the wall of text, it ended up as a brain dump of a bunch of backend-related documentation that I know about/have bookmarked in the past. Hopefully there's something useful in there.)</div>
<div><br></div>If you haven't stumbled across them already, these might be helpful:<div><br></div><div><a href="http://llvm.org/devmtg/2009-10/Korobeynikov_BackendTutorial.pdf">http://llvm.org/devmtg/2009-10/Korobeynikov_BackendTutorial.pdf</a></div>
<div><a href="http://jonathan2251.github.io/lbd/">http://jonathan2251.github.io/lbd/</a><br></div><div><a href="http://eli.thegreenplace.net/2013/02/25/a-deeper-look-into-the-llvm-code-generator-part-1/">http://eli.thegreenplace.net/2013/02/25/a-deeper-look-into-the-llvm-code-generator-part-1/</a><br>
</div><div><a href="http://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm/">http://eli.thegreenplace.net/2012/11/24/life-of-an-instruction-in-llvm/</a><br></div><div><br></div><div>Another good source of documentation is simply to look at the commits that introduce new backends, e.g. the initial commits for SystemZ and AArch64 come to mind. If you use git, something like this might be handy:</div>
<div><br></div><div>    git log -p -n1 $(git log --pretty='format:%H' lib/Target/AArch64/ | tail -n1) >initial.patch<br></div><div><br></div><div>Generally the most consistent source of good documentation is the devmeetings, so definitely browse what's available at <<a href="http://llvm.org/devmtg/">http://llvm.org/devmtg/</a>> (even quite old ones can still be really useful, such as Anton's slides). Also, as I'm sure you've heard, a lot of that backend stuff is slated for change (getting rid of SelectionDAG, global-isel, separating the MI layer, etc.), although the process will probably take a long time.</div>
<div><br></div><div>There's also a lot of backend-related knowledge encoded (trapped?) inside of the TableGen backends, and AFAIK the only way to really puzzle out the deep details there is to look at the source code of the TableGen backends in utils/TableGen/ and correlating that with the generated .inc files (look in your build dir) and where those .inc files are included inside lib/Target/$ARCH/; see utils/TableGen/TableGenBackends.h for an overview of what's there. There is some rough documentation about them in <<a href="http://llvm.org/docs/WritingAnLLVMBackend.html">http://llvm.org/docs/WritingAnLLVMBackend.html</a>> and <<a href="http://llvm.org/docs/CodeGenerator.html">http://llvm.org/docs/CodeGenerator.html</a>>.</div>
<div><br></div><div>The actual TableGen "language" is documented fairly poorly but actually has real dedicated documentation available (<<a href="http://llvm.org/docs/TableGenFundamentals.html">http://llvm.org/docs/TableGenFundamentals.html</a>>, <<a href="http://llvm.org/docs/TableGen/LangRef.html">http://llvm.org/docs/TableGen/LangRef.html</a>>). There's also tests/TableGen/ which might be useful. To learn about the in-code data structures that are produced by TableGen and manipulated by the TableGen backends, you basically need to look at include/llvm/TableGen/Record.h and lib/TableGen. Beware: the TableGen code is not quite up to par with the rest of the codebase. Also, don't assume that there's some coherent "underlying structure" to the TableGen language; it's mostly a product of long periods of neglect punctuated by quick hacks when a developer gets frustrated by clunky existing ways to express something (or inability to express something).</div>
<div><br></div><div>The only documentation (besids the code itself) we have about the MI layer is the short section <<a href="http://llvm.org/docs/CodeGenerator.html#machine-code-description-classes">http://llvm.org/docs/CodeGenerator.html#machine-code-description-classes</a>>. You can get an idea of the scope of the MI layer from the plans laid out in <<a href="http://thread.gmane.org/gmane.comp.compilers.llvm.devel/65434">http://thread.gmane.org/gmane.comp.compilers.llvm.devel/65434</a>>. Other than that you'll probably have to go digging in the source or ask on the mailing lists.</div>
<div><br></div><div>There's a blog post about MC <<a href="http://blog.llvm.org/2010/04/intro-to-llvm-mc-project.html">http://blog.llvm.org/2010/04/intro-to-llvm-mc-project.html</a>> and an old dev meeting talk by Daniel Dunba, along with a section here <<a href="http://llvm.org/docs/CodeGenerator.html#the-mc-layer">http://llvm.org/docs/CodeGenerator.html#the-mc-layer</a>>r. There's also a quite thorough tutorial specifically about implementing an integrated assembler <<a href="http://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html">http://www.embecosm.com/appnotes/ean10/ean10-howto-llvmas-1.0.html</a>>. Other than that, I don't know very much material to recommend about MC.</div>
<div><br></div><div>If you gain any insight about a specific thing in the course of your backend project, please feel free to share that knowledge by documenting <<a href="http://llvm.org/docs/SphinxQuickstartTemplate.html">http://llvm.org/docs/SphinxQuickstartTemplate.html</a>>.<br>
</div><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Sep 23, 2013 at 8:29 PM, Preston Briggs <span dir="ltr"><<a href="mailto:preston.briggs@gmail.com" target="_blank">preston.briggs@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">When I registered for dev conference, there was a field asking what I was particularly interested in learning. I didn't fill it out then , but it occurs to me now that I'd really enjoy a tutorial on how to develop a new back end.<div>

<br></div><div>I spent some time recently reviewing existing material (documentation and code) and not making a lot of progress. Indeed, under some time pressure, I'm writing my own back end.</div><div><br></div><div>

A chance to work through the material with some guidance would be greatly appreciated.</div><div><br></div><div>Thanks,</div><div>Preston</div><div><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>