Error: Varible not defined for immediate instructions

I am writing simple patterns to learn how to make a Backend.
I was able to make mul and add instructions in one mla instruction. However, I couldn’t make for an instruction that has immediate. The pattern definition and error are below.

//pattern for sladd
def : Pat<  (add (slli GPR:$src1, 1), GPR:$src2),
            (sladd GPR:$src1, GPR:$src2)>;
/llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.td:1674:19: error: Variable not defined: 'slli'
def : Pat<  (add (slli GPR:$src1, uimmlog2xlen:1), GPR:$src2),
                  ^

Could you help me about this?
I also tried to add uimmlog2xlen: before the constant number but It gives a different error which I think not directing the solution.

The main problem is that the source pattern has to be expressed in terms of the SDNodes in TargetSelectionDAG.td (or custom ones for your backend), not the actual instructions you want to emit. And the left shift node is called shl.

So, why does it work for this?

def : Pat<  (add (mul GPR:$src1, GPR:$src2), GPR:$src3),
            (MLA GPR:$src1, GPR:$src2, GPR:$src3)>;

This is written in also RISCVInstrInfo.td
Should I understand that we should write it in TargetSelectionDAG.td when instruction includes immediate value?

That one works because mul and add are defined in TargetSelectionDAG.td as the operators performing those operations. You don’t need to modify TargetSelectionDAG.td at all for this, but it can be useful to read through it to find out what operations you can write patterns for and how.

I think this pattern should work for you (assuming you’ve defined sladd elsewhere):

def : Pat<  (add (shl GPR:$src1, 1), GPR:$src2),
            (sladd GPR:$src1, GPR:$src2)>;

Thank you so much.
After I read TargetSelectionDAG.td and RISCVInstrInfo.td. I find several examples and tried for a working one. Then, I found it.
When I made it (shl GPR:$src1, (i32 1)) instead of (shl GPR:$src1, 1), It works successfully.

(shl GPR:$src1, 1) This gives an error by building like that:

def : Pat<  (add (shl GPR:$src1, 1), GPR:$src2),
^

I will read that file more by now but I am struggling with understanding. Do you have any other source suggestions?