Can somebody point me at some introductionary material (or approachable code base) to writing an <i>optimizing</i> compiler?<p>There seem to be a lot of very good tutorials on writing a simple compiler, like
<a href="http:&#x2F;&#x2F;scheme2006.cs.uchicago.edu&#x2F;11-ghuloum.pdf" rel="nofollow">http:&#x2F;&#x2F;scheme2006.cs.uchicago.edu&#x2F;11-ghuloum.pdf</a>
<a href="http:&#x2F;&#x2F;compilers.iecc.com&#x2F;crenshaw&#x2F;" rel="nofollow">http:&#x2F;&#x2F;compilers.iecc.com&#x2F;crenshaw&#x2F;</a><p>There are also readable code bases like tinyc or this one.<p>However these always use a simple template based approach to code generation and stop there.<p>Of course there are real world compiler (lvm, gcc, ...). However because of their size and complexity it&#x27;s hard to learn from them.<p>What I am interested in would be going from:
&quot;I have an AST and for this node type I output this assembly.&quot;
to
&quot;I translate the AST to an IR. Transform an the IR in multiple passes and finally output decent asm.&quot;<p>That is, something that talks about CFG analysis, register scheduling or maybe SSA form? I have read papers on SSA and Sea-of-Nodes IRs, but these of course always assume that you know how and why to use them. A more approachable text&#x2F;github-repo that shows how to take the step from template base code gen to more advanced techniques would be great.<p>(I hope it is ok to ask this here. Did not want to hijack the thread.)