[llvm-dev] Re-using a node in a DAG output pattern in TableGen

Cyril Six via llvm-dev llvm-dev at lists.llvm.org
Wed Nov 24 02:15:48 PST 2021


Thank you! 


Cyril Six 
Compiler Engineer • Kalray 
Phone: 
csix at kalrayinc.com • [ https://www.kalrayinc.com/ | www.kalrayinc.com ] 

[ https://www.kalrayinc.com/ |   ] 

Please consider the environment before printing this e-mail. 
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. 



From: "Jason Eckhardt" <jeckhardt at nvidia.com> 
To: "llvm-dev" <llvm-dev at lists.llvm.org>, "Cyril Six" <csix at kalrayinc.com> 
Sent: Monday, November 8, 2021 4:31:17 PM 
Subject: Re: Re-using a node in a DAG output pattern in TableGen 

You might give OutPatFrag a try: 

// OutPatFrag is a pattern fragment that is used as part of an output pattern 
// (not an input pattern). These do not have predicates or transforms, but are 
// used to avoid repeated subexpressions in output patterns. 
class OutPatFrag<dag ops, dag frag> 
: PatFrag<ops, frag, [{}], NOOP_SDNodeXForm>; 



To declare a filtering error, please use the following [ https://www.security-mail.net/reporter.php?mid=3180.618942c8.9c2f1.0&r=csix%40kalrayinc.com&s=jeckhardt%40nvidia.com&o=Re%3A+Re-using+a+node+in+a+DAG+output+pattern+in+TableGen&verdict=C&c=7b8e6bd9361d7d5746aca57ad0ae4985dffdb73f | link ] 


From: llvm-dev <llvm-dev-bounces at lists.llvm.org> on behalf of Cyril Six via llvm-dev <llvm-dev at lists.llvm.org> 
Sent: Monday, November 8, 2021 6:37 AM 
To: llvm-dev <llvm-dev at lists.llvm.org> 
Subject: [llvm-dev] Re-using a node in a DAG output pattern in TableGen 
External email: Use caution opening links or attachments 
Hello, 

I currently have an instruction selection pattern that looks like this : 




def : Pat<myinputop type:$v0 type:$v1, 
(COMPNHQ 
(ADDHQrr 
(SLLHQSri $v0, 8), 
(SLLHQSri $v1, 8), 
), 
(SLLHQSri $v0, 8), 
comparison_ltu 
)>; 



This output pattern is supposed to be a DAG: the node (SLLHQSri $v0, 8) is used two times. 

Experimentally, TableGen seems to recognize it as such (the node `(SLLHQSri $v0, 8)` will not be duplicated). 

I am wondering if there is a way to avoid having to repeat (SLLHQSri $v0, 8) in the syntax of TableGen, something like: 

BQ_BEGIN

def : Pat<inputpattern type:$v0 type:$v1, 
(COMPNHQ 
(ADDHQrr 
(SLLHQSri $v0, 8):$myvar, 
(SLLHQSri $v1, 8), 
), 
$myvar, 
comparison_ltu 
)>; 

BQ_END

If I try this, I get the error "Node 'myvar' in output pattern but not input pattern". 

Does anyone know if there is a way to name nodes from an output pattern to produce a non-tree output DAG? 

Do you know of any existing pattern featuring output DAG that are not trees? 

Thanks 

Cyril Six 
Compiler Engineer • Kalray 
Phone: 
csix at kalrayinc.com • [ 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 | 
www.kalrayinc.com ] 

[ 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 ] 
	
Intelligent Data Processing 
>From Cloud to Edge 

Please consider the environment before printing this e-mail. 
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. 




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211124/6f4247d9/attachment.html>


More information about the llvm-dev mailing list