<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi Yao,</p>
<p>I'm working on a downstream target that was built from the ground
up using GlobalISel only. I can definitely confirm what Quentin
already said. For us the most challenging part was the legalizer.
You have to be careful not to introduce hidden infinite loops
through conflicting legalization actions. Also because of some
edge-cases that are not fully supported yet, it can sometimes be
difficult to come up with a set of actions that can handle
anything that is thrown at you or maybe you'll even find that the
current implementation cannot handle the edge-case your target
presents. We certainly had to commit some patches in there to make
everything work for us. That is something that will be solved the
more adopters there are for it. You could say that it is in a
working state for the existing upstream targets but if your target
is something new, then it will most certainly uncover some
edge-case that simply nobody thought of yet.<br>
</p>
<p>Don't let that deter you from using GISel though. The advantages
it offers over SelDAG definitely outweigh some of the pitfalls
that come with "early" adoption and the amount of testability and
flexibility you gain more than makes up for it.<br>
</p>
<p>As for TableGen selection support: we found that simple
instructions and some of the more "straight-forward" complex ones
could easily be done with TableGen. Things like memops or
instructions where TableGen has difficulty to infer the correct
types, also instructions with more than one definition, we had to
do in C++. However none of us had worked with TableGen before and
by now we have learned some more tricks that would certainly allow
us to migrate more of our C++ patterns to TableGen.</p>
<p>Overall we are pretty happy with GlobalISel and recently I see
more and more patches popping up on Phabricator for it. If you are
planning to create a new backend, I can definitely recommend
GlobalISel!</p>
<p>Cheers,</p>
<p>Dominik<br>
</p>
<div class="moz-cite-prefix">Am 22.02.21 um 19:42 schrieb Quentin
Colombet via llvm-dev:<br>
</div>
<blockquote type="cite"
cite="mid:7BE1F7AF-CBB8-4453-A483-FBC253FF58A1@apple.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Feb 22, 2021, at 10:40 AM, Quentin Colombet
via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org"
class="" moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<meta charset="UTF-8" class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; float: none; display: inline
!important;" class="">Hi Yao,</span><br class=""
style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;" class=""><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=""
moz-do-not-send="true">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 class="" style="font-family:
"Lucida Grande", "Lucida Sans
Unicode", Geneva, Verdana, sans-serif;
font-size: 14px;">SelectionDAG</span>" and "<span
class="" style="font-family: "Lucida
Grande", "Lucida Sans Unicode",
Geneva, Verdana, sans-serif; font-size: 14px;">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 class=""
style="color: rgb(15, 23, 33); font-family:
"Helvetica Neue"; font-size: 14px;">ut
not limited to</span>) :</div>
<div class="">1. What's the plan for "GlobalISel" to
replace the "SelectionDAG"?</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">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 class="">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 class=""><br class="">
</div>
<div class="">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 class=""
style="font-family: Menlo; font-size: 11px;">GINodeEquiv</span>).</div>
<div class=""><br class="">
</div>
<div class="">You can see what is currently supported or
not for your target by using<span
class="Apple-converted-space"> </span><span class=""
style="font-size: 11px;"><font class="" face="Menlo">-debug-only</font> </span><span
class="" style="font-family: Menlo; font-size: 11px;">gisel-emitter</span> and <font
class="" face="Menlo"><span class="" style="font-size:
11px;">-warn-on-skipped-patterns </span></font>on
your tablegen command when generating the selection
tables.</div>
<div class="">This could be improved of course!</div>
<div class=""><br class="">
</div>
<div class="">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 class=""
style="font-family: Menlo; font-size: 11px;">llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp </span>for
example.</div>
<div class=""><br class="">
</div>
<div class="">Take a look at the tutorial we made a few
years ago for more details about how to do the
targeting:</div>
<div class=""><a
href="https://www.youtube.com/watch?v=Zh4R40ZyJ2k"
class="" moz-do-not-send="true">2017 LLVM Developers’
Meeting: J. Bogner & A. Nandakumar & D.
Sanders “Tutorial: GlobalISel ”</a></div>
<div class=""><br class="">
</div>
<div class="">And more recently:</div>
<div class=""><a
href="https://www.youtube.com/watch?v=8427bl_7k1g"
class="" moz-do-not-send="true">2019 LLVM Developers’
Meeting: V. Keles & D. Sanders “Generating
Optimized Code with GlobalISel”</a></div>
<div class=""><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 class=""><br class="">
</div>
<div class="">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 class="">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="">
<span class="Apple-converted-space"> </span><a
href="https://llvm.org/docs/GlobalISel/index.html" class=""
moz-do-not-send="true">https://llvm.org/docs/GlobalISel/index.html</a><br
class="">
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
<div class="">I think the closest thing to a design/spec
doc that is not completely out of date is probably this
talk:</div>
<div class=""><a
href="https://www.youtube.com/watch?v=6tfb344A7w8&t=11s"
class="" moz-do-not-send="true">2016 LLVM Developers’
Meeting: A. Bougacha & Q. Colombet & T.
Northover “Global Instr.."</a></div>
<div class=""><br class="">
</div>
</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>Actually this one may be more accurate:</div>
<div><a
href="https://www.youtube.com/watch?v=McByO0QgqCY&t=845s"
class="" moz-do-not-send="true">2017 LLVM Developers’
Meeting: “GlobalISel: Past, Present, and Future ”</a></div>
<br class="">
<blockquote type="cite" class="">
<div class="">
<div style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;" class="">
<div class="">If you have specific questions feel free to
reach out.</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">-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>
--<span class="Apple-converted-space"> </span><br
class="">
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr" class="">Name: zhongxiao yao
<div class="">Email:<span
class="Apple-converted-space"> </span><a
href="mailto:zhongxiao.yzx@gmail.com"
target="_blank" class=""
moz-do-not-send="true">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=""
moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br
class="">
<a
href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
class="" moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br
class="">
</div>
</blockquote>
</div>
<br class="" style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none;">
<span style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; float: none; display: inline
!important;" class="">_______________________________________________</span><br
style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"
class="">
<span style="caret-color: rgb(0, 0, 0); font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; text-align: start; text-indent:
0px; text-transform: none; white-space: normal;
word-spacing: 0px; -webkit-text-stroke-width: 0px;
text-decoration: none; float: none; display: inline
!important;" class="">LLVM Developers mailing list</span><br
style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"
class="">
<a href="mailto:llvm-dev@lists.llvm.org" style="font-family:
Helvetica; font-size: 12px; font-style: normal;
font-variant-caps: normal; font-weight: normal;
letter-spacing: normal; orphans: auto; text-align: start;
text-indent: 0px; text-transform: none; white-space:
normal; widows: auto; word-spacing: 0px;
-webkit-text-size-adjust: auto; -webkit-text-stroke-width:
0px;" class="" moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br
style="caret-color: rgb(0, 0, 0); font-family: Helvetica;
font-size: 12px; font-style: normal; font-variant-caps:
normal; font-weight: normal; letter-spacing: normal;
text-align: start; text-indent: 0px; text-transform: none;
white-space: normal; word-spacing: 0px;
-webkit-text-stroke-width: 0px; text-decoration: none;"
class="">
<a
href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
style="font-family: Helvetica; font-size: 12px;
font-style: normal; font-variant-caps: normal;
font-weight: normal; letter-spacing: normal; orphans:
auto; text-align: start; text-indent: 0px; text-transform:
none; white-space: normal; widows: auto; word-spacing:
0px; -webkit-text-size-adjust: auto;
-webkit-text-stroke-width: 0px;" class=""
moz-do-not-send="true">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div>
</blockquote>
</div>
<br class="">
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
----------------------------------------------------------------------
Dominik Montada Email: <a class="moz-txt-link-abbreviated" href="mailto:dominik.montada@hightec-rt.com">dominik.montada@hightec-rt.com</a>
HighTec EDV-Systeme GmbH Phone: +49 681 92613 19
Europaallee 19 Fax: +49-681-92613-26
D-66113 Saarbrücken WWW: <a class="moz-txt-link-freetext" href="http://www.hightec-rt.com">http://www.hightec-rt.com</a>
Managing Director: Vera Strothmann
Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222
This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient please notify the sender immediately
and destroy this e-mail. Any unauthorised copying, disclosure or
distribution of the material in this e-mail is strictly forbidden.
---</pre>
</body>
</html>