aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen/DAGISelMatcherOpt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/TableGen/DAGISelMatcherOpt.cpp')
-rw-r--r--utils/TableGen/DAGISelMatcherOpt.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/utils/TableGen/DAGISelMatcherOpt.cpp b/utils/TableGen/DAGISelMatcherOpt.cpp
index 408bd63..796b815 100644
--- a/utils/TableGen/DAGISelMatcherOpt.cpp
+++ b/utils/TableGen/DAGISelMatcherOpt.cpp
@@ -26,12 +26,19 @@ static void ContractNodes(OwningPtr<MatcherNode> &Matcher) {
// If we found a movechild node with a node that comes in a 'foochild' form,
// transform it.
if (MoveChildMatcherNode *MC = dyn_cast<MoveChildMatcherNode>(N)) {
- if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext())) {
- MatcherNode *New
- = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
+ MatcherNode *New = 0;
+ if (RecordMatcherNode *RM = dyn_cast<RecordMatcherNode>(MC->getNext()))
+ New = new RecordChildMatcherNode(MC->getChildNo(), RM->getWhatFor());
+
+ if (CheckTypeMatcherNode *CT= dyn_cast<CheckTypeMatcherNode>(MC->getNext()))
+ New = new CheckChildTypeMatcherNode(MC->getChildNo(), CT->getType());
+
+ if (New) {
+ // Insert the new node.
New->setNext(Matcher.take());
Matcher.reset(New);
- MC->setNext(RM->takeNext());
+ // Remove the old one.
+ MC->setNext(MC->getNext()->takeNext());
return ContractNodes(Matcher);
}
}