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

Jason Eckhardt via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 8 07:31:17 PST 2021


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>;

________________________________
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:
def : Pat<inputpattern type:$v0 type:$v1,
          (COMPNHQ
            (ADDHQrr
              (SLLHQSri $v0, 8):$myvar,
              (SLLHQSri $v1, 8),
            ),
            $myvar,
            comparison_ltu
          )>;
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 • 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%7C637719718619602934%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RtINTAlB1bxfjgh9PqVW7J%2FZ6pXFOUPPlAWtyK70t2U%3D&reserved=0>

[Kalray logo]<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/20211108/62feb63c/attachment-0001.html>


More information about the llvm-dev mailing list