<div dir="ltr"><div>Node results are always legalized first. So ReplaceNodeResults will be called first. The custom code generated must start and end with the illegal types. Instructions like concat_vectors, extract_subvector, zero_extend, sign_extend, truncate, and build_pair will be used to bridge between the illegal types and the legal type your custom code uses. All of the nodes that are custom emitted will also go through type legalization. So those connecting nodes will also get legalized.</div><div><br></div><div>If the node that's being custom legalized is something that has the result type and the input type always the same like an add instruction. Then legalizing the output should be enough to fully replace the node. If some instruction that doesn't have a fixed relationship between input and output type and they are both illegal then its up to the custom code that handles the result as to whether or not it wants to fix the input too. Once the new code has been emitted from ReplaceNodeResults then the original node is dead and will be not be legalized further. Only the custom code that replace it will be looked at. It's fine to emit code from ReplaceNodeResults with illegal types as long as some of the types are legal or you emit different nodes than what you started with that can undergo their own legalization.</div><div><br></div><div>I hope that helped.</div><div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 28, 2020 at 12:40 PM Przemyslaw Ossowski <<a href="mailto:przemyslaw.ossowski@googlemail.com">przemyslaw.ossowski@googlemail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thank you Craig for explanation.</div><div><br></div><div>Could be the same algorithm used for custom legalizing given node in LowerOperation and
ReplaceNodeResults in case results and inputs of the node are illegal?</div><div>Or actually such situation is impossible and for given node either LowerOperation or
ReplaceNodeResults can be only called?</div><div><br></div><div>Przemek<br></div></div><div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">wt., 28 sty 2020, 18:48 użytkownik Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> napisał:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="auto">ReplaceNodeResults is called by the type legalizer for custom legalizing any of the results of a node that have an illegal type.</div></div><div dir="auto"><br></div><div dir="auto">LowerOperation is called by the type legalizer to custom legalize node inputs that have an illegal type. I believe technically it calls LowerOperationWrapper, but that forwards to LowerOperation by default.</div><div dir="auto"><br></div><div dir="auto">LowerOperation is also called for custom legalizing nodes with legal types after type legalization by both the vector op legalizer and the DAG legalizer. In those cases LowerOperation is called directly and does not call LowerOperationWrapper.</div></div><div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 28, 2020 at 9:10 AM Przemyslaw Ossowski via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Hi,<span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">I see that for different targets in classes which inherits
from TargetLowering there are implemented both methods:<span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">LowerOperation and ReplaceNodeResults<span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">What decides that for one given ISD we have to add handling
in LowerOperation and for other in ReplaceNodeResults, when for both SetOperationAction
is configured to be Custom?</p><p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><br><span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Is it related with number of results of given operation
and LowerOperation is called when there is only one SDValue?<span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif"><span> </span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Thanks,<span></span></p>
<p class="MsoNormal" style="margin:0in 0in 0.0001pt;font-size:11pt;font-family:Calibri,sans-serif">Przemek<span></span></p>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" rel="noreferrer" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
</div>-- <br><div dir="ltr">~Craig</div>
</blockquote></div></div></div>
</blockquote></div>