<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000">Thank you!<br><br><div id="ac9cfb83-c942-45a7-8fb1-2c3ed726de6f" data-marker=""><div><br></div> <div style="font-size:9pt;font-family:'arial' , 'helvetica' , sans-serif"> <span style="color:#144444;font-size:9pt"><strong>Cyril Six</strong></span><br> <span style="color:#144444;font-size:9pt"><strong>Compiler Engineer • Kalray</strong></span><br> <span style="color:#144444;font-size:8pt">Phone: </span><br> <span style="color:#11588f;font-size:8pt"><u>csix@kalrayinc.com</u> • <a href="https://www.kalrayinc.com" style="color:#11588f" target="_blank" rel="nofollow noopener noreferrer"><u>www.kalrayinc.com</u></a></span> </div> <br> <table cellpadding="0px" border="0px"><tbody><tr><td> <div> <a href="https://www.kalrayinc.com" target="_blank" rel="nofollow noopener noreferrer"> <img src="http://data.kalrayinc.com/Kalray_72.png" alt="Kalray logo"></a> </div> </td></tr></tbody></table> <br>   <span style="color:#7db621;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif"><strong> Please consider the environment before printing this e-mail.</strong></span> <div> <span style="color:#144444;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif;display:block;line-height:100%">This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.</span></div> <br></div><br><div id="content_out_csix_kalrayinc.com"></div><hr id="zwchr" data-marker=""><div data-marker=""><b>From: </b>"Jason Eckhardt" <jeckhardt@nvidia.com><br><b>To: </b>"llvm-dev" <llvm-dev@lists.llvm.org>, "Cyril Six" <csix@kalrayinc.com><br><b>Sent: </b>Monday, November 8, 2021 4:31:17 PM<br><b>Subject: </b>Re: Re-using a node in a DAG output pattern in TableGen<br></div><br><div data-marker=""><style style="display:none">/*<![CDATA[*/P {
        margin-top: 0;
        margin-bottom: 0;
}
/*]]>*/</style>
<div style="font-family:'calibri' , 'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
You might give OutPatFrag a try:<br>
</div>
<div style="font-family:'calibri' , 'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div style="font-family:'calibri' , 'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
// OutPatFrag is a pattern fragment that is used as part of an output pattern
<div>// (not an input pattern). These do not have predicates or transforms, but are</div>
<div>// used to avoid repeated subexpressions in output patterns.</div>
<div>class OutPatFrag<dag ops, dag frag></div>
 : PatFrag<ops, frag, [{}], NOOP_SDNodeXForm>;</div>
<div style="font-family:'calibri' , 'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )">
<br>
</div>
<div id="appendonsend"></div>
<p id="fb_identificator"></p><p></p><hr style="display:inline-block;width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Cyril Six via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Sent:</b> Monday, November 8, 2021 6:37 AM<br>
<b>To:</b> llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> [llvm-dev] Re-using a node in a DAG output pattern in TableGen</font>
<div> </div>
</div>
<div>
<table border="1" bgcolor="#FFEB9C"><tbody><tr><td><font size="1" face="verdana" color="black"><b>External email: Use caution opening links or attachments</b>
</font></td></tr></tbody></table>
<br>
<div>
<div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:#000000">
<div>Hello,<br>
</div>
<div><br>
</div>
<div>I currently have an instruction selection pattern that looks like this :<br>
</div>
<div><br>
</div>
<blockquote>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">def : Pat<myinputop type:$v0 type:$v1,</span><br>
</div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">          (COMPNHQ</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            (ADDHQrr</span><br>
</div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">              (SLLHQSri $v0, 8),<br>
</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">              (SLLHQSri $v1, 8),<br>
</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            ),<br>
</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            (SLLHQSri $v0, 8),<br>
</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            comparison_ltu<br>
</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">          )>;</span></div>
</blockquote>
<div><span style="font-family:'arial' , 'helvetica' , sans-serif">This output pattern is supposed to be a DAG: the node (SLLHQSri $v0, 8) is used two times.<br>
</span></div>
<div><span style="font-family:'arial' , 'helvetica' , sans-serif"><br>
</span></div>
<div><span style="font-family:'arial' , 'helvetica' , sans-serif">Experimentally, TableGen seems to recognize it as such (the node `(SLLHQSri $v0, 8)` will not be duplicated).<br>
</span></div>
<div><span style="font-family:'arial' , 'helvetica' , sans-serif"><br>
</span></div>
<div><span style="font-family:'arial' , 'helvetica' , sans-serif">I am wondering if there is a way to avoid having to repeat (SLLHQSri $v0, 8) in the syntax of TableGen, something like:</span><span style="font-family:'arial' , 'helvetica' , sans-serif"></span></div>
<div>
<blockquote>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">def : Pat<inputpattern type:$v0 type:$v1,</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">          (COMPNHQ</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            (ADDHQrr</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">              (SLLHQSri $v0, 8):$myvar,</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">              (SLLHQSri $v1, 8),</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            ),</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            $myvar,</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">            comparison_ltu</span></div>
<div><span style="font-family:'courier new' , 'courier' , 'monaco' , monospace , sans-serif">          )>;</span></div>
</blockquote>
</div>
<div>If I try this, I get the error "Node 'myvar' in output pattern but not input pattern".<br>
</div>
<div><br>
</div>
<div>Does anyone know if there is a way to name nodes from an output pattern to produce a non-tree output DAG?<br>
</div>
<div><br>
</div>
<div>Do you know of any existing pattern featuring output DAG that are not trees?</div>
<div><br>
</div>
<div>Thanks<br>
</div>
<div>
<div><br>
</div>
<div style="font-size:9pt;font-family:'arial' , 'helvetica' , sans-serif"><span style="color:#144444;font-size:9pt"><strong>Cyril Six</strong></span><br>
<span style="color:#144444;font-size:9pt"><strong>Compiler Engineer • Kalray</strong></span><br>
<span style="color:#144444;font-size:8pt">Phone: </span><br>
<span style="color:#11588f;font-size:8pt"><u>csix@kalrayinc.com</u> • <a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C1bf04ec61fbb4f4958a908d9a2b48d7d%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637719718619602934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RtINTAlB1bxfjgh9PqVW7J%2FZ6pXFOUPPlAWtyK70t2U%3D&reserved=0" rel="nofollow noopener noreferrer nofollow noopener noreferrer" style="color:#11588f" target="_blank">
<u>www.kalrayinc.com</u></a></span> </div>
<br>
<table cellpadding="0px" border="0px"><tbody><tr><td>
<div><a href="https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.kalrayinc.com%2F&data=04%7C01%7Cjeckhardt%40nvidia.com%7C1bf04ec61fbb4f4958a908d9a2b48d7d%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C637719718619612928%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=9kPWz9fpnv2ZIP%2Fg6CVNCevmc141CEV2ZdG9EtDsxcU%3D&reserved=0" rel="nofollow noopener noreferrer nofollow noopener noreferrer" target="_blank"><img alt="Kalray logo" src="https://www.kalrayinc.com/IMG/png/Logo_Kalray_141x39.png"></a>
</div>
</td><td>
<div style="padding-left:10px;border-left:1px solid #58585a"><span style="color:#144444;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif;display:block;line-height:120%">Intelligent Data Processing<br>
>From Cloud to Edge</span></div>
</td></tr></tbody></table>
<br>
<span style="color:#7db621;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif"><strong>Please consider the environment before printing this e-mail.</strong></span>
<div><span style="color:#144444;font-size:8pt;font-family:'arial' , 'helvetica' , sans-serif;display:block;line-height:100%">This message contains information that may be privileged or confidential and is the property of Kalray S.A. It is intended only for
 the person to whom it is addressed. If you are not the intended recipient, you are not authorized to print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately
 and delete all copies of this message.</span></div>
<br>
</div>
</div>
<div id="x_content_out_csix_kalrayinc.com"></div>
</div>
</div><br></div></div></body></html>