Instruction selection - .td file sytax

Hi,

I’m trying to to something like:
def :PatDSP<(i32 (add ( add (i32 rXRegs:$src2), (shl (i32 rXRegs:$src0), (u3Imm:$src1))),
(shl (i32 rXRegs:$src0), (u3Imm:$src1)))),
(dsp_shiftladd rXRegs:$src0, u3Imm:($src1+1),
rXRegs:$src2)>;

is there a way/syntax to do calculations on the input? I’d like to catch in generic way all imm patterns.

Thanks,
David

Hi David,

you can’t do calculations directly in the tablegen language. However, you can introduce new SD nodes to make some calculations. See e.g. the definition of Log2_32 and it’s use in the HexagonPatterns.td file.

Regards,
Kai

thanks! that helped