<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Ericsson Hilda";
panose-1:0 0 5 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle18
{mso-style-type:personal;
font-family:"Times New Roman",serif;
color:black;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Ericsson Hilda";
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal-compose;
font-family:"Ericsson Hilda";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=SV link="#0563C1" vlink="#954F72"><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>Okay, I managed to figure this out myself and will describe the workaround here in case there is someone else with the same problem. <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>There is apparently a TableGen class called </span><span lang=EN-US style='font-size:12.0pt;color:black'>GINodeEquiv which is used for making a G_* instruction equivalent to a specific ISD node. This can be used as follows, which </span><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>is actually how GlobalISel handles all normal G_* instructions:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>def G_XYZ_COMPARE_SIGNED : GenericInstruction{ ... };<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>def : GINodeEquiv<G_XYZ_COMPARE_SIGNED, XYZ_COMPARE_SIGNED>;</span><span lang=EN-US style='font-size:12.0pt;color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>This way, I can reuse the patterns already defined in the *.td files with minimal modifications.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'>Gabriel<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Ericsson Hilda";mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US>From:</span></b><span lang=EN-US> llvm-dev <llvm-dev-bounces@lists.llvm.org> <b>On Behalf Of </b>Gabriel Hjort Åkerlund via llvm-dev<br><b>Sent:</b> den 27 juli 2020 17:15<br><b>To:</b> llvm-dev@lists.llvm.org<br><b>Subject:</b> [llvm-dev] Porting use of target-specific node types in SelectionISel to GlobalISel?<o:p></o:p></span></p></div></div><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>I am in the process of porting our target to GlobalISel and have encountered the following problem. In our target, the predicate for conditional branching is placed on the branch instruction instead of the compare instruction. To make this work in our SelectionISel-based implementation, we declare our own nodes, e.g.:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>def XYZ_COMPARE_SIGNED : SDNode<"XYZISD::COMPARE_SIGNED", SDT_PHXiCmp, [SDNPHasChain, SDNPOutGlue]>;<o:p></o:p></span></p><div><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></p></div><div><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>During legalization, we lower BR_CC nodes into:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>XYZISD::COMPARE_SIGNED <lhs> <rhs><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>XYZISD::CONDBRANCH <label> <condition code> <condition reg></span><span lang=EN-US style='font-size:12.0pt;color:black'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>These are then used for pattern matching, e.g.:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-family:"Courier New";color:black'>def : Pat<(XYZ_COMPARE_SIGNED i16:$src1, (i16 Imm_m32768_32767_i16:$SImm)), (cmp_nimm16_a16 $src1, imm:$SImm)>;<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;font-family:"Courier New";color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>Now to my question: What is the best way to achieve the same thing in GlobalISel? Is it possible to introduce new node types in GlobalISel? If so, how? If not, what’s a suitable work-around that allows me to reuse the tablegen-declared patterns?<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>Cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:12.0pt;color:black'>Gabriel<o:p></o:p></span></p></div></div></body></html>