[llvm] r269236 - SDAG: Add a helper to replace and remove a node during ISel
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 11 14:13:17 PDT 2016
Author: bogner
Date: Wed May 11 16:13:17 2016
New Revision: 269236
URL: http://llvm.org/viewvc/llvm-project?rev=269236&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h?rev=269236&r1=269235&r2=269236&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGISel.h Wed May 11 16:13:17 2016
@@ -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.
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=269236&r1=269235&r2=269236&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed May 11 16:13:17 2016
@@ -2014,8 +2014,7 @@ void X86DAGToDAGISel::Select(SDNode *Nod
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 *Nod
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 *Nod
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;
}
More information about the llvm-commits
mailing list