ISelLowring - create new custom instruction in some custom function

Hello,

I am writing a lowering function for some store instructions in my target.
In it, i want to generate a new instruction that itself needs a custom lowering function (that already exists).

I am getting the following error:
Assertion failed: TLI.getTypeAction(*DAG.getContext(), Node->getValueType(i)) == TargetLowering::TypeLegal && "Unexpected illegal type!", file llvm-project\llvm\lib\CodeGen\SelectionDAG\LegalizeDAG.cpp, line 972
Because the new instruction i have created is not TypeLegal, it’s custom.

My question is - it’s legal to return illigal instruction from a custom function? if yes, how can i fix my solution?

Thanks in advanced!

The first thing that gets legalized (lowered) are types. Legalization of operations follows, so when you insert new nodes into the DAG at this stage, they should have legal types.

you shall post your instruction defination out here.