What does the "set" and "add" keyword mean in Tablegen Lauguage?

I found a code section like that :

class ArighLogicI<bits<8> op, string instrAsmm, SDNode opNode,
                  Operand od, PatLeaf immType, RegisterClass regClass>
                  : FL<op, (outs GPROut:$ra), (ins regClass:$rb, od:$imm16),
                  [(set GPROut:$ra, (opNode regClass:$rb, immType:$imm16))], IIAlu> {
            let isReMaterializable = 1;  // isReMaterializable - could this instruction be materialized again ?

For the [(set GPROut:$ra, (opNode regClass:$rb, immType:$imm16))], I know it’s a DAG pattern which indicates this instr should fulfill the pattern like

But I still don’t get where and how should I use the keyword “set” and “add”

The DAG doesn’t look like that, it looks like:


A set node is an assignment node, i.e. it’s matching $ra = ... in the DAG, and is a special operator known to TableGen. An add node is just an ISD::ADD, matching a normal integer add in the DAG. So combined this is matching $ra = $rb + $imm16 in the DAG (represented probably as something like t2: i32 = add t0, t1).

1 Like

Your description is so clear !
Thank a lot.