llvm_unreachable("Tblgen should generate this!");
}
- SDNode *SelectCodeCommon(SDNode *NodeToMatch,
- const unsigned char *MatcherTable,
- unsigned TableSize);
+ void SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
+ unsigned TableSize);
/// \brief Return true if complex patterns for this target can mutate the
/// DAG.
private:
// Calls to these functions are generated by tblgen.
- SDNode *Select_INLINEASM(SDNode *N);
- SDNode *Select_READ_REGISTER(SDNode *N);
- SDNode *Select_WRITE_REGISTER(SDNode *N);
- SDNode *Select_UNDEF(SDNode *N);
+ void Select_INLINEASM(SDNode *N);
+ void Select_READ_REGISTER(SDNode *N);
+ void Select_WRITE_REGISTER(SDNode *N);
+ void Select_UNDEF(SDNode *N);
void CannotYetSelect(SDNode *N);
private:
return !findNonImmUse(Root, N.getNode(), U, Root, Visited, IgnoreChains);
}
-SDNode *SelectionDAGISel::Select_INLINEASM(SDNode *N) {
+void SelectionDAGISel::Select_INLINEASM(SDNode *N) {
SDLoc DL(N);
std::vector<SDValue> Ops(N->op_begin(), N->op_end());
const EVT VTs[] = {MVT::Other, MVT::Glue};
SDValue New = CurDAG->getNode(ISD::INLINEASM, DL, VTs, Ops);
New->setNodeId(-1);
- return New.getNode();
+ ReplaceUses(N, New.getNode());
+ CurDAG->RemoveDeadNode(N);
}
-SDNode
-*SelectionDAGISel::Select_READ_REGISTER(SDNode *Op) {
+void SelectionDAGISel::Select_READ_REGISTER(SDNode *Op) {
SDLoc dl(Op);
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
SDValue New = CurDAG->getCopyFromReg(
Op->getOperand(0), dl, Reg, Op->getValueType(0));
New->setNodeId(-1);
- return New.getNode();
+ ReplaceUses(Op, New.getNode());
+ CurDAG->RemoveDeadNode(Op);
}
-SDNode
-*SelectionDAGISel::Select_WRITE_REGISTER(SDNode *Op) {
+void SelectionDAGISel::Select_WRITE_REGISTER(SDNode *Op) {
SDLoc dl(Op);
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
SDValue New = CurDAG->getCopyToReg(
Op->getOperand(0), dl, Reg, Op->getOperand(2));
New->setNodeId(-1);
- return New.getNode();
+ ReplaceUses(Op, New.getNode());
+ CurDAG->RemoveDeadNode(Op);
}
-SDNode *SelectionDAGISel::Select_UNDEF(SDNode *N) {
- return CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF,N->getValueType(0));
+void SelectionDAGISel::Select_UNDEF(SDNode *N) {
+ SDNode *New =
+ CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF, N->getValueType(0));
+ if (New != N) {
+ ReplaceUses(N, New);
+ CurDAG->RemoveDeadNode(N);
+ }
}
/// GetVBR - decode a vbr encoding whose top bit is set.
};
} // end anonymous namespace
-SDNode *SelectionDAGISel::
-SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
- unsigned TableSize) {
+void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
+ const unsigned char *MatcherTable,
+ unsigned TableSize) {
// FIXME: Should these even be selected? Handle these cases in the caller?
switch (NodeToMatch->getOpcode()) {
default:
case ISD::LIFETIME_START:
case ISD::LIFETIME_END:
NodeToMatch->setNodeId(-1); // Mark selected.
- return nullptr;
+ return;
case ISD::AssertSext:
case ISD::AssertZext:
CurDAG->ReplaceAllUsesOfValueWith(SDValue(NodeToMatch, 0),
NodeToMatch->getOperand(0));
CurDAG->RemoveDeadNode(NodeToMatch);
- return nullptr;
- case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch);
- case ISD::READ_REGISTER: return Select_READ_REGISTER(NodeToMatch);
- case ISD::WRITE_REGISTER: return Select_WRITE_REGISTER(NodeToMatch);
- case ISD::UNDEF: return Select_UNDEF(NodeToMatch);
+ return;
+ case ISD::INLINEASM:
+ Select_INLINEASM(NodeToMatch);
+ return;
+ case ISD::READ_REGISTER:
+ Select_READ_REGISTER(NodeToMatch);
+ return;
+ case ISD::WRITE_REGISTER:
+ Select_WRITE_REGISTER(NodeToMatch);
+ return;
+ case ISD::UNDEF:
+ Select_UNDEF(NodeToMatch);
+ return;
}
assert(!NodeToMatch->isMachineOpcode() && "Node already selected!");
// NodeToMatch was eliminated by CSE when the target changed the DAG.
// We will visit the equivalent node later.
DEBUG(dbgs() << "Node was eliminated by CSE\n");
- return nullptr;
+ return;
}
// If the node had chain/glue results, update our notion of the current
if (IsMorphNodeTo) {
// Update chain uses.
UpdateChains(NodeToMatch, InputChain, ChainNodesMatched, true);
- return Res;
+ if (Res != NodeToMatch) {
+ ReplaceUses(NodeToMatch, Res);
+ CurDAG->RemoveDeadNode(NodeToMatch);
+ }
+ return;
}
continue;
}
"Didn't replace all uses of the node?");
CurDAG->RemoveDeadNode(NodeToMatch);
- // FIXME: We just return here, which interacts correctly with SelectRoot
- // above. We should fix this to not return an SDNode* anymore.
- return nullptr;
+ return;
}
}
while (1) {
if (MatchScopes.empty()) {
CannotYetSelect(NodeToMatch);
- return nullptr;
+ return;
}
// Restore the interpreter state back to the point where the scope was