SDAG: Add a helper to replace and remove a node during ISel
It's very common to want to replace a node and then remove it since it's dead, especially as we port backends from the SDNode *Select API to the void Select one. This helper makes this sequence a bit less verbose. llvm-svn: 269236
This commit is contained in:
parent
b3534c494f
commit
31d7da3b5f
|
@ -234,6 +234,11 @@ protected:
|
|||
CurDAG->ReplaceAllUsesWith(F, T);
|
||||
}
|
||||
|
||||
/// Replace all uses of \c F with \c T, then remove \c F from the DAG.
|
||||
void ReplaceNode(SDNode *F, SDNode *T) {
|
||||
CurDAG->ReplaceAllUsesWith(F, T);
|
||||
CurDAG->RemoveDeadNode(F);
|
||||
}
|
||||
|
||||
/// SelectInlineAsmMemoryOperands - Calls to this are automatically generated
|
||||
/// by tblgen. Others should not call it.
|
||||
|
|
|
@ -2014,8 +2014,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
|
|||
break;
|
||||
}
|
||||
case X86ISD::GlobalBaseReg:
|
||||
ReplaceUses(Node, getGlobalBaseReg());
|
||||
CurDAG->RemoveDeadNode(Node);
|
||||
ReplaceNode(Node, getGlobalBaseReg());
|
||||
return;
|
||||
|
||||
case X86ISD::SHRUNKBLEND: {
|
||||
|
@ -2127,8 +2126,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
|
|||
SDValue Ops[] = {N1, InFlag};
|
||||
SDNode *CNode = CurDAG->getMachineNode(Opc, dl, VTs, Ops);
|
||||
|
||||
ReplaceUses(SDValue(Node, 0), SDValue(CNode, 0));
|
||||
ReplaceUses(SDValue(Node, 1), SDValue(CNode, 1));
|
||||
ReplaceNode(Node, CNode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2152,9 +2150,7 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
|
|||
SDValue Ops[] = {N1, InFlag};
|
||||
SDNode *CNode = CurDAG->getMachineNode(Opc, dl, VTs, Ops);
|
||||
|
||||
ReplaceUses(SDValue(Node, 0), SDValue(CNode, 0));
|
||||
ReplaceUses(SDValue(Node, 1), SDValue(CNode, 1));
|
||||
ReplaceUses(SDValue(Node, 2), SDValue(CNode, 2));
|
||||
ReplaceUses(Node, CNode);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue