forked from OSchip/llvm-project
SDAG: Make SelectCodeCommon return void
This means SelectCode unconditionally returns nullptr now. I'll follow up with a change to make that return void as well, but it seems best to keep that one very mechanical. This is part of the work to have Select return void instead of an SDNode *, which is in turn part of llvm.org/pr26808. llvm-svn: 269136
This commit is contained in:
parent
c92b8e51ae
commit
1df01f0e31
|
@ -274,9 +274,8 @@ public:
|
||||||
llvm_unreachable("Tblgen should generate this!");
|
llvm_unreachable("Tblgen should generate this!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNode *SelectCodeCommon(SDNode *NodeToMatch,
|
void SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
const unsigned char *MatcherTable,
|
unsigned TableSize);
|
||||||
unsigned TableSize);
|
|
||||||
|
|
||||||
/// \brief Return true if complex patterns for this target can mutate the
|
/// \brief Return true if complex patterns for this target can mutate the
|
||||||
/// DAG.
|
/// DAG.
|
||||||
|
@ -287,10 +286,10 @@ public:
|
||||||
private:
|
private:
|
||||||
|
|
||||||
// Calls to these functions are generated by tblgen.
|
// Calls to these functions are generated by tblgen.
|
||||||
SDNode *Select_INLINEASM(SDNode *N);
|
void Select_INLINEASM(SDNode *N);
|
||||||
SDNode *Select_READ_REGISTER(SDNode *N);
|
void Select_READ_REGISTER(SDNode *N);
|
||||||
SDNode *Select_WRITE_REGISTER(SDNode *N);
|
void Select_WRITE_REGISTER(SDNode *N);
|
||||||
SDNode *Select_UNDEF(SDNode *N);
|
void Select_UNDEF(SDNode *N);
|
||||||
void CannotYetSelect(SDNode *N);
|
void CannotYetSelect(SDNode *N);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -2085,7 +2085,7 @@ bool SelectionDAGISel::IsLegalToFold(SDValue N, SDNode *U, SDNode *Root,
|
||||||
return !findNonImmUse(Root, N.getNode(), U, Root, Visited, IgnoreChains);
|
return !findNonImmUse(Root, N.getNode(), U, Root, Visited, IgnoreChains);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNode *SelectionDAGISel::Select_INLINEASM(SDNode *N) {
|
void SelectionDAGISel::Select_INLINEASM(SDNode *N) {
|
||||||
SDLoc DL(N);
|
SDLoc DL(N);
|
||||||
|
|
||||||
std::vector<SDValue> Ops(N->op_begin(), N->op_end());
|
std::vector<SDValue> Ops(N->op_begin(), N->op_end());
|
||||||
|
@ -2094,11 +2094,11 @@ SDNode *SelectionDAGISel::Select_INLINEASM(SDNode *N) {
|
||||||
const EVT VTs[] = {MVT::Other, MVT::Glue};
|
const EVT VTs[] = {MVT::Other, MVT::Glue};
|
||||||
SDValue New = CurDAG->getNode(ISD::INLINEASM, DL, VTs, Ops);
|
SDValue New = CurDAG->getNode(ISD::INLINEASM, DL, VTs, Ops);
|
||||||
New->setNodeId(-1);
|
New->setNodeId(-1);
|
||||||
return New.getNode();
|
ReplaceUses(N, New.getNode());
|
||||||
|
CurDAG->RemoveDeadNode(N);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNode
|
void SelectionDAGISel::Select_READ_REGISTER(SDNode *Op) {
|
||||||
*SelectionDAGISel::Select_READ_REGISTER(SDNode *Op) {
|
|
||||||
SDLoc dl(Op);
|
SDLoc dl(Op);
|
||||||
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
|
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
|
||||||
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
|
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
|
||||||
|
@ -2108,11 +2108,11 @@ SDNode
|
||||||
SDValue New = CurDAG->getCopyFromReg(
|
SDValue New = CurDAG->getCopyFromReg(
|
||||||
Op->getOperand(0), dl, Reg, Op->getValueType(0));
|
Op->getOperand(0), dl, Reg, Op->getValueType(0));
|
||||||
New->setNodeId(-1);
|
New->setNodeId(-1);
|
||||||
return New.getNode();
|
ReplaceUses(Op, New.getNode());
|
||||||
|
CurDAG->RemoveDeadNode(Op);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNode
|
void SelectionDAGISel::Select_WRITE_REGISTER(SDNode *Op) {
|
||||||
*SelectionDAGISel::Select_WRITE_REGISTER(SDNode *Op) {
|
|
||||||
SDLoc dl(Op);
|
SDLoc dl(Op);
|
||||||
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
|
MDNodeSDNode *MD = dyn_cast<MDNodeSDNode>(Op->getOperand(1));
|
||||||
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
|
const MDString *RegStr = dyn_cast<MDString>(MD->getMD()->getOperand(0));
|
||||||
|
@ -2122,11 +2122,17 @@ SDNode
|
||||||
SDValue New = CurDAG->getCopyToReg(
|
SDValue New = CurDAG->getCopyToReg(
|
||||||
Op->getOperand(0), dl, Reg, Op->getOperand(2));
|
Op->getOperand(0), dl, Reg, Op->getOperand(2));
|
||||||
New->setNodeId(-1);
|
New->setNodeId(-1);
|
||||||
return New.getNode();
|
ReplaceUses(Op, New.getNode());
|
||||||
|
CurDAG->RemoveDeadNode(Op);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDNode *SelectionDAGISel::Select_UNDEF(SDNode *N) {
|
void SelectionDAGISel::Select_UNDEF(SDNode *N) {
|
||||||
return CurDAG->SelectNodeTo(N, TargetOpcode::IMPLICIT_DEF,N->getValueType(0));
|
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.
|
/// GetVBR - decode a vbr encoding whose top bit is set.
|
||||||
|
@ -2706,9 +2712,9 @@ public:
|
||||||
};
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
SDNode *SelectionDAGISel::
|
void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
|
||||||
SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
const unsigned char *MatcherTable,
|
||||||
unsigned TableSize) {
|
unsigned TableSize) {
|
||||||
// FIXME: Should these even be selected? Handle these cases in the caller?
|
// FIXME: Should these even be selected? Handle these cases in the caller?
|
||||||
switch (NodeToMatch->getOpcode()) {
|
switch (NodeToMatch->getOpcode()) {
|
||||||
default:
|
default:
|
||||||
|
@ -2736,17 +2742,25 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
case ISD::LIFETIME_START:
|
case ISD::LIFETIME_START:
|
||||||
case ISD::LIFETIME_END:
|
case ISD::LIFETIME_END:
|
||||||
NodeToMatch->setNodeId(-1); // Mark selected.
|
NodeToMatch->setNodeId(-1); // Mark selected.
|
||||||
return nullptr;
|
return;
|
||||||
case ISD::AssertSext:
|
case ISD::AssertSext:
|
||||||
case ISD::AssertZext:
|
case ISD::AssertZext:
|
||||||
CurDAG->ReplaceAllUsesOfValueWith(SDValue(NodeToMatch, 0),
|
CurDAG->ReplaceAllUsesOfValueWith(SDValue(NodeToMatch, 0),
|
||||||
NodeToMatch->getOperand(0));
|
NodeToMatch->getOperand(0));
|
||||||
CurDAG->RemoveDeadNode(NodeToMatch);
|
CurDAG->RemoveDeadNode(NodeToMatch);
|
||||||
return nullptr;
|
return;
|
||||||
case ISD::INLINEASM: return Select_INLINEASM(NodeToMatch);
|
case ISD::INLINEASM:
|
||||||
case ISD::READ_REGISTER: return Select_READ_REGISTER(NodeToMatch);
|
Select_INLINEASM(NodeToMatch);
|
||||||
case ISD::WRITE_REGISTER: return Select_WRITE_REGISTER(NodeToMatch);
|
return;
|
||||||
case ISD::UNDEF: return Select_UNDEF(NodeToMatch);
|
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!");
|
assert(!NodeToMatch->isMachineOpcode() && "Node already selected!");
|
||||||
|
@ -3360,7 +3374,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
// NodeToMatch was eliminated by CSE when the target changed the DAG.
|
// NodeToMatch was eliminated by CSE when the target changed the DAG.
|
||||||
// We will visit the equivalent node later.
|
// We will visit the equivalent node later.
|
||||||
DEBUG(dbgs() << "Node was eliminated by CSE\n");
|
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 the node had chain/glue results, update our notion of the current
|
||||||
|
@ -3428,7 +3442,11 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
if (IsMorphNodeTo) {
|
if (IsMorphNodeTo) {
|
||||||
// Update chain uses.
|
// Update chain uses.
|
||||||
UpdateChains(NodeToMatch, InputChain, ChainNodesMatched, true);
|
UpdateChains(NodeToMatch, InputChain, ChainNodesMatched, true);
|
||||||
return Res;
|
if (Res != NodeToMatch) {
|
||||||
|
ReplaceUses(NodeToMatch, Res);
|
||||||
|
CurDAG->RemoveDeadNode(NodeToMatch);
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3477,9 +3495,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
"Didn't replace all uses of the node?");
|
"Didn't replace all uses of the node?");
|
||||||
CurDAG->RemoveDeadNode(NodeToMatch);
|
CurDAG->RemoveDeadNode(NodeToMatch);
|
||||||
|
|
||||||
// FIXME: We just return here, which interacts correctly with SelectRoot
|
return;
|
||||||
// above. We should fix this to not return an SDNode* anymore.
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3491,7 +3507,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable,
|
||||||
while (1) {
|
while (1) {
|
||||||
if (MatchScopes.empty()) {
|
if (MatchScopes.empty()) {
|
||||||
CannotYetSelect(NodeToMatch);
|
CannotYetSelect(NodeToMatch);
|
||||||
return nullptr;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore the interpreter state back to the point where the scope was
|
// Restore the interpreter state back to the point where the scope was
|
||||||
|
|
|
@ -841,8 +841,9 @@ void llvm::EmitMatcherTable(const Matcher *TheMatcher,
|
||||||
MatcherEmitter.EmitHistogram(TheMatcher, OS);
|
MatcherEmitter.EmitHistogram(TheMatcher, OS);
|
||||||
|
|
||||||
OS << " #undef TARGET_VAL\n";
|
OS << " #undef TARGET_VAL\n";
|
||||||
OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";
|
OS << " SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n";
|
||||||
OS << '\n';
|
OS << " return nullptr;\n";
|
||||||
|
OS << "}\n";
|
||||||
|
|
||||||
// Next up, emit the function for node and pattern predicates:
|
// Next up, emit the function for node and pattern predicates:
|
||||||
MatcherEmitter.EmitPredicateFunctions(OS);
|
MatcherEmitter.EmitPredicateFunctions(OS);
|
||||||
|
|
Loading…
Reference in New Issue