<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Yao,<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Feb 19, 2021, at 5:59 AM, yao zhongxiao via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Dear LLVMer<br class=""><br class="">I read the Instruction selection in LLVM recently.<div class="">I find the most important two frameworks "<span style="font-family: "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-size: 14px;" class="">SelectionDAG</span>" and "<span style="font-family: "Lucida Grande", "Lucida Sans Unicode", Geneva, Verdana, sans-serif; font-size: 14px;" class="">GlobalISel</span>".</div><div class="">As far as I know, the "SelectionDAG" is the default framework and GlobalISel is ongoing now!<br class=""><br class=""></div><div class="">Can someone give some detailed information about the Instruction selection frameworks?</div><div class="">such as(including b<span style="color:rgb(15,23,33);font-family:"Helvetica Neue";font-size:14px" class="">ut not limited to</span>) :</div>





<div class="">1. What's the plan for "GlobalISel" to replace the "SelectionDAG"?</div></div></div></blockquote><div><br class=""></div><div>The plan is for GlobalISel to replace SelectionDAG in the future. The main hurdle for GlobalISel adoption right now is that the work around  providing better tablegen support is progressing at a slow pace.</div><div>That’s not a blocker, but that means more hand written code for adopters.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">2. GlobalISel uses its own instruction pattern matcher,  </div><div class="">   how will the target instruction description be with tablegen, especially the DAG type in tablegen?</div></div></div></blockquote><div><br class=""></div><div>GlobalISel has an importer mechanism that automatically reuse the existing SDISel patterns from tablegen. The importer is not complete though and in particular, some patterns are currently not possible to import or require a bit of help from the developer (see the documentation around <span style="font-family: Menlo; font-size: 11px;" class="">GINodeEquiv</span>).</div><div><br class=""></div><div>You can see what is currently supported or not for your target by using <span style="font-size: 11px;" class=""><font face="Menlo" class="">-debug-only</font> </span><span style="font-family: Menlo; font-size: 11px;" class="">gisel-emitter</span> and <font face="Menlo" class=""><span style="font-size: 11px;" class="">-warn-on-skipped-patterns </span></font>on your tablegen command when generating the selection tables.</div><div>This could be improved of course!</div><div><br class=""></div><div>As far as describing the types and such, GISel uses LLT. The main place where you have to do that is in the LegalizerInfo where you describe what is and what is not legal. Take a look at <span style="font-family: Menlo; font-size: 11px;" class="">llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp </span>for example.</div><div><br class=""></div><div>Take a look at the tutorial we made a few years ago for more details about how to do the targeting:</div><div><a href="https://www.youtube.com/watch?v=Zh4R40ZyJ2k" class="">2017 LLVM Developers’ Meeting: J. Bogner & A. Nandakumar & D. Sanders “Tutorial: GlobalISel ”</a></div><div><br class=""></div><div>And more recently:</div><div><a href="https://www.youtube.com/watch?v=8427bl_7k1g" class="">2019 LLVM Developers’ Meeting: V. Keles & D. Sanders “Generating Optimized Code with GlobalISel”</a></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">3. "SelectionDAG" is the framework in the trunk, </div><div class="">     what's the suggestion to following the upcoming "GlobalISel" if we maintain a downstream project?<br class=""></div></div></div></blockquote><div><br class=""></div><div>I would recommend to use GlobalISel. It is faster, more testable, more flexible, and offers optimization opportunities that are just impossible with SDISel.</div><div>The downsides are missing proper tablegen support and it can be rough on the edges since it hasn’t been as widely use yet. Both these downsides will improve as time goes by and as always, patch welcome :).</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">4. Can someone share some detailed docs or design paper except the following docs<br class="">    <a href="https://llvm.org/docs/GlobalISel/index.html" class="">https://llvm.org/docs/GlobalISel/index.html</a><br class=""></div></div></div></blockquote><div><br class=""></div><div>I think the closest thing to a design/spec doc that is not completely out of date is probably this talk:</div><div><a href="https://www.youtube.com/watch?v=6tfb344A7w8&t=11s" class="">2016 LLVM Developers’ Meeting: A. Bougacha & Q. Colombet & T. Northover “Global Instr.."</a></div><div><br class=""></div><div>If you have specific questions feel free to reach out.</div><div><br class=""></div><div>Cheers,</div><div>-Quentin</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">    </div><div class=""><br class=""></div><div class="">Thanks.</div><div class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">Name: zhongxiao yao<div class="">Email: <a href="mailto:zhongxiao.yzx@gmail.com" target="_blank" class="">zhongxiao.yzx@gmail.com</a></div></div></div></div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></body></html>