Hi I’m getting the following error
<code>LLVM ERROR: Cannot select: t9: i32 = mul nsw t23, t20 t23: i32,ch = load<(dereferenceable load (s32) from %ir.2)> t0, FrameIndex:i32<1>, undef:i32
t5: i32 = FrameIndex<1>
t3: i32 = undef t20: i32,ch = load<(dereferenceable load (s32) from %ir.3)> t0, FrameIndex:i32<2>, undef:i32
t7: i32 = FrameIndex<2>
t3: i32 = undef In function: main
</code>
<code>LLVM ERROR: Cannot select: t9: i32 = mul nsw t23, t20 t23: i32,ch = load<(dereferenceable load (s32) from %ir.2)> t0, FrameIndex:i32<1>, undef:i32
t5: i32 = FrameIndex<1>
t3: i32 = undef t20: i32,ch = load<(dereferenceable load (s32) from %ir.3)> t0, FrameIndex:i32<2>, undef:i32
t7: i32 = FrameIndex<2>
t3: i32 = undef In function: main
</code>
LLVM ERROR: Cannot select: t9: i32 = mul nsw t23, t20 t23: i32,ch = load<(dereferenceable load (s32) from %ir.2)> t0, FrameIndex:i32<1>, undef:i32
t5: i32 = FrameIndex<1>
t3: i32 = undef t20: i32,ch = load<(dereferenceable load (s32) from %ir.3)> t0, FrameIndex:i32<2>, undef:i32
t7: i32 = FrameIndex<2>
t3: i32 = undef In function: main
I have given CUSTOM_MUL iside the TISD in the TIselLowering.h file
<code>namespace TISD {
enum NodeType {
// Start the numbering from where ISD NodeType finishes.
FIRST_NUMBER = ISD::BUILTIN_OP_END,
CUSTOM_MUL,
// Return
Ret,
};
}
</code>
<code>namespace TISD {
enum NodeType {
// Start the numbering from where ISD NodeType finishes.
FIRST_NUMBER = ISD::BUILTIN_OP_END,
CUSTOM_MUL,
// Return
Ret,
};
}
</code>
namespace TISD {
enum NodeType {
// Start the numbering from where ISD NodeType finishes.
FIRST_NUMBER = ISD::BUILTIN_OP_END,
CUSTOM_MUL,
// Return
Ret,
};
}
In TISelLowering.cpp
<code>const char *TTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
case TISD::Ret: return "TISD::Ret";
case TISD::CUSTOM_MUL: return "TISD::CUSTOM_MUL";
default: return NULL;
}
}
</code>
<code>const char *TTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
case TISD::Ret: return "TISD::Ret";
case TISD::CUSTOM_MUL: return "TISD::CUSTOM_MUL";
default: return NULL;
}
}
</code>
const char *TTargetLowering::getTargetNodeName(unsigned Opcode) const {
switch (Opcode) {
case TISD::Ret: return "TISD::Ret";
case TISD::CUSTOM_MUL: return "TISD::CUSTOM_MUL";
default: return NULL;
}
}
In Tinstrinfo.td file, defined the following:
<code>def CUSTOM_MUL : SDNode<"ZSPISD::CUSTOM_MUL", SDTNone, []>;
class MAU32_rr<string opcodestr>
: ZSPInst<(outs Int32Reg : $rZ32),
(ins Int32Reg : $rX32, Int32Reg : $rY32),
opcodestr, "$rZ32, $rX32, $rY32", []>;
def MUL32rr : MAU32_rr<"mul32">;
class PatInt32Int32<SDPatternOperator OpNode, ZSPInst Inst>
: Pat<(OpNode Int32Reg : $rX32, Int32Reg : $rY32),
(Inst Int32Reg : $rX32, Int32Reg : $rY32)>;
def : PatInt32Int32<mul, MUL32rr>;
</code>
<code>def CUSTOM_MUL : SDNode<"ZSPISD::CUSTOM_MUL", SDTNone, []>;
class MAU32_rr<string opcodestr>
: ZSPInst<(outs Int32Reg : $rZ32),
(ins Int32Reg : $rX32, Int32Reg : $rY32),
opcodestr, "$rZ32, $rX32, $rY32", []>;
def MUL32rr : MAU32_rr<"mul32">;
class PatInt32Int32<SDPatternOperator OpNode, ZSPInst Inst>
: Pat<(OpNode Int32Reg : $rX32, Int32Reg : $rY32),
(Inst Int32Reg : $rX32, Int32Reg : $rY32)>;
def : PatInt32Int32<mul, MUL32rr>;
</code>
def CUSTOM_MUL : SDNode<"ZSPISD::CUSTOM_MUL", SDTNone, []>;
class MAU32_rr<string opcodestr>
: ZSPInst<(outs Int32Reg : $rZ32),
(ins Int32Reg : $rX32, Int32Reg : $rY32),
opcodestr, "$rZ32, $rX32, $rY32", []>;
def MUL32rr : MAU32_rr<"mul32">;
class PatInt32Int32<SDPatternOperator OpNode, ZSPInst Inst>
: Pat<(OpNode Int32Reg : $rX32, Int32Reg : $rY32),
(Inst Int32Reg : $rX32, Int32Reg : $rY32)>;
def : PatInt32Int32<mul, MUL32rr>;
Inside TIsekDAGtoDAG.cpp
<code>void TDAGToDAGISel::Select(SDNode *Node) {
SDLoc dl(Node);
unsigned Opcode = Node->getOpcode();
EVT VT = Node->getValueType(0);
switch(Opcode) {
case TISD::CUSTOM_MUL:
{
SDValue Op1 = Node->getOperand(0);
SDValue Op2 = Node->getOperand(1);
SDNode *Result = CurDAG->getMachineNode(T::MUL32rr, SDLoc(Node), MVT::i32, Op1, Op2);
ReplaceNode(Node, Result);
}
}
}
</code>
<code>void TDAGToDAGISel::Select(SDNode *Node) {
SDLoc dl(Node);
unsigned Opcode = Node->getOpcode();
EVT VT = Node->getValueType(0);
switch(Opcode) {
case TISD::CUSTOM_MUL:
{
SDValue Op1 = Node->getOperand(0);
SDValue Op2 = Node->getOperand(1);
SDNode *Result = CurDAG->getMachineNode(T::MUL32rr, SDLoc(Node), MVT::i32, Op1, Op2);
ReplaceNode(Node, Result);
}
}
}
</code>
void TDAGToDAGISel::Select(SDNode *Node) {
SDLoc dl(Node);
unsigned Opcode = Node->getOpcode();
EVT VT = Node->getValueType(0);
switch(Opcode) {
case TISD::CUSTOM_MUL:
{
SDValue Op1 = Node->getOperand(0);
SDValue Op2 = Node->getOperand(1);
SDNode *Result = CurDAG->getMachineNode(T::MUL32rr, SDLoc(Node), MVT::i32, Op1, Op2);
ReplaceNode(Node, Result);
}
}
}
This is the code that I have written? What should I modify?