[llvm-dev] Specifying DAG patterns in the instruction

Rail Shafigulin via llvm-dev
Mon, 01 Feb 2016 22:16:25 -0000

On Sat, Jan 30, 2016 at 5:32 PM, Dylan McKay <dylanmckay34 at gmail.com>
wrote:

> TableGen, as a DSL language, is made up of records. Every def corresponds
> to a record. For example, TableGen has a class Register, and your backend
> will define records by def GPR8 : Register<...>. You are correct in
> saying that the record definition is one of the SDNode values. These
> correspond 1:1 to llvm::ISD::NodeType
>
<http://llvm.org/docs/doxygen/html/namespacellvm_1_1ISD.html#a22ea9cec080dd5f4f47ba234c2f59110>
> .
>
> (DEF a, b) corresponds to
>
>     --------- a
>    /
> DEF
>    \
>     ----------b
>
> A more complicated example, regarding that a and b themselves can be
> nested DAGs.
>
>                      a
>                    /
>      --------- add
>     /              \
>    /                 b
> DEF
>    \                 c
>     \              /
>      ---------- sub
>                    \
>                     d
>
> And so on and so fourth.
>

My next question is about the nodes of the Selection DAG. Based on what I'm
seeing the nodes can either be registers or they can be instructions. If I
understand correctly llvm::ISD::NodeType
<http://llvm.org/docs/doxygen/html/namespacellvm_1_1ISD.html#a22ea9cec080dd5f4f47ba234c2f59110>
tells
me the type of the node (register, add instruction, pseudo instruction,
etc).

What does a DAG set operation do? Does it create new node?

Here is the example:

(set GPR:$rD, (add (i32 GPR:$rA), (i32 GPR:$rB)))

And here is what I assume this to look like:


                                 --------------- GPR:$rA
                                /
                               /
GPR:$rd ----------- add
                               \
                                \
                                 --------------- GRP:$rb

Am I correct?

Any help is appreciated.

​
>
--
Rail Shafigulin
Software Engineer
Esencia Technologies
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20160201/37a18b76/attachment.html>