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

7 views
Skip to first unread message

Cyril Six via llvm-dev

unread,
Nov 8, 2021, 7:37:42 AM11/8/21
to llvm-dev
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:
cs...@kalrayinc.comwww.kalrayinc.com

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.

Jason Eckhardt via llvm-dev

unread,
Nov 8, 2021, 10:31:28 AM11/8/21
to llvm-dev, Cyril Six
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...@lists.llvm.org> on behalf of Cyril Six via llvm-dev <llvm...@lists.llvm.org>
Sent: Monday, November 8, 2021 6:37 AM
To: llvm-dev <llvm...@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

Cyril Six via llvm-dev

unread,
Nov 24, 2021, 5:15:59 AM11/24/21
to Jason Eckhardt, llvm-dev
Thank you!


Cyril Six
Compiler Engineer • Kalray
Phone:
cs...@kalrayinc.comwww.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" <jeck...@nvidia.com>
To: "llvm-dev" <llvm...@lists.llvm.org>, "Cyril Six" <cs...@kalrayinc.com>
Sent: Monday, November 8, 2021 4:31:17 PM
Subject: Re: Re-using a node in a DAG output pattern in TableGen
Reply all
Reply to author
Forward
0 new messages