blob: 4a918d15691b1123c2fc462c3154c5b9c481afb5 [file] [log] [blame]
Chris Lattnerb02cdaa2010-02-15 08:04:42 +00001//===- DAGISelMatcher.cpp - Representation of DAG pattern matcher ---------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "DAGISelMatcher.h"
11#include "CodeGenDAGPatterns.h"
12#include "CodeGenTarget.h"
Chandler Carruth91d19d82012-12-04 10:37:14 +000013#include "llvm/Support/raw_ostream.h"
14#include "llvm/TableGen/Record.h"
Chris Lattnerb02cdaa2010-02-15 08:04:42 +000015using namespace llvm;
16
David Blaikiea379b1812011-12-20 02:50:00 +000017void Matcher::anchor() { }
18
Chris Lattner2c3f6492010-02-25 02:04:40 +000019void Matcher::dump() const {
Chris Lattner1f2adb62010-02-25 06:53:39 +000020 print(errs(), 0);
Chris Lattnerb02cdaa2010-02-15 08:04:42 +000021}
22
Chris Lattner1f2adb62010-02-25 06:53:39 +000023void Matcher::print(raw_ostream &OS, unsigned indent) const {
24 printImpl(OS, indent);
Chris Lattner186ad802010-02-18 02:53:41 +000025 if (Next)
26 return Next->print(OS, indent);
Chris Lattnerb02cdaa2010-02-15 08:04:42 +000027}
28
Chris Lattnerc577b812010-02-27 07:49:13 +000029void Matcher::printOne(raw_ostream &OS) const {
30 printImpl(OS, 0);
31}
32
Chris Lattner9c791d82010-03-07 06:29:26 +000033/// unlinkNode - Unlink the specified node from this chain. If Other == this,
34/// we unlink the next pointer and return it. Otherwise we unlink Other from
35/// the list and return this.
36Matcher *Matcher::unlinkNode(Matcher *Other) {
37 if (this == Other)
38 return takeNext();
Jim Grosbach65586fe2010-12-21 16:16:00 +000039
Chris Lattner9c791d82010-03-07 06:29:26 +000040 // Scan until we find the predecessor of Other.
41 Matcher *Cur = this;
42 for (; Cur && Cur->getNext() != Other; Cur = Cur->getNext())
43 /*empty*/;
44
Craig Topper24064772014-04-15 07:20:03 +000045 if (!Cur) return nullptr;
Chris Lattner9c791d82010-03-07 06:29:26 +000046 Cur->takeNext();
47 Cur->setNext(Other->takeNext());
48 return this;
49}
50
51/// canMoveBefore - Return true if this matcher is the same as Other, or if
52/// we can move this matcher past all of the nodes in-between Other and this
53/// node. Other must be equal to or before this.
54bool Matcher::canMoveBefore(const Matcher *Other) const {
55 for (;; Other = Other->getNext()) {
56 assert(Other && "Other didn't come before 'this'?");
57 if (this == Other) return true;
58
59 // We have to be able to move this node across the Other node.
60 if (!canMoveBeforeNode(Other))
61 return false;
62 }
63}
64
Craig Topper0ac6f9f2013-09-25 06:40:22 +000065/// canMoveBeforeNode - Return true if it is safe to move the current matcher
Chris Lattner9c791d82010-03-07 06:29:26 +000066/// across the specified one.
67bool Matcher::canMoveBeforeNode(const Matcher *Other) const {
68 // We can move simple predicates before record nodes.
69 if (isSimplePredicateNode())
70 return Other->isSimplePredicateOrRecordNode();
Jim Grosbach65586fe2010-12-21 16:16:00 +000071
Chris Lattner9c791d82010-03-07 06:29:26 +000072 // We can move record nodes across simple predicates.
73 if (isSimplePredicateOrRecordNode())
74 return isSimplePredicateNode();
Jim Grosbach65586fe2010-12-21 16:16:00 +000075
Chris Lattner9c791d82010-03-07 06:29:26 +000076 // We can't move record nodes across each other etc.
77 return false;
78}
79
80
Chris Lattnerf7fc2d82010-02-25 19:00:39 +000081ScopeMatcher::~ScopeMatcher() {
Javed Absar776bf1d2017-10-16 06:43:54 +000082 for (Matcher *C : Children)
83 delete C;
Chris Lattnerf7fc2d82010-02-25 19:00:39 +000084}
85
Craig Topper0d16d2d2014-01-29 07:06:07 +000086SwitchOpcodeMatcher::~SwitchOpcodeMatcher() {
Javed Absar776bf1d2017-10-16 06:43:54 +000087 for (auto &C : Cases)
88 delete C.second;
Craig Topper0d16d2d2014-01-29 07:06:07 +000089}
90
91SwitchTypeMatcher::~SwitchTypeMatcher() {
Javed Absar776bf1d2017-10-16 06:43:54 +000092 for (auto &C : Cases)
93 delete C.second;
Craig Topper0d16d2d2014-01-29 07:06:07 +000094}
Chris Lattnerf7fc2d82010-02-25 19:00:39 +000095
Chris Lattner514e2922011-04-17 21:38:24 +000096CheckPredicateMatcher::CheckPredicateMatcher(const TreePredicateFn &pred)
97 : Matcher(CheckPredicate), Pred(pred.getOrigPatFragRecord()) {}
98
99TreePredicateFn CheckPredicateMatcher::getPredicate() const {
100 return TreePredicateFn(Pred);
101}
102
103
104
Chris Lattnerf7fc2d82010-02-25 19:00:39 +0000105// printImpl methods.
106
Chris Lattner1f2adb62010-02-25 06:53:39 +0000107void ScopeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerac55f9d2010-02-25 01:56:48 +0000108 OS.indent(indent) << "Scope\n";
Javed Absar776bf1d2017-10-16 06:43:54 +0000109 for (const Matcher *C : Children) {
110 if (!C)
Chris Lattner102a8a02010-02-28 20:49:53 +0000111 OS.indent(indent+1) << "NULL POINTER\n";
112 else
Javed Absar776bf1d2017-10-16 06:43:54 +0000113 C->print(OS, indent+2);
Chris Lattner102a8a02010-02-28 20:49:53 +0000114 }
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000115}
116
Chris Lattner1f2adb62010-02-25 06:53:39 +0000117void RecordMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000118 OS.indent(indent) << "Record\n";
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000119}
120
Chris Lattner1f2adb62010-02-25 06:53:39 +0000121void RecordChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerab417562010-02-24 07:31:45 +0000122 OS.indent(indent) << "RecordChild: " << ChildNo << '\n';
Chris Lattnerab417562010-02-24 07:31:45 +0000123}
124
Chris Lattner1f2adb62010-02-25 06:53:39 +0000125void RecordMemRefMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000126 OS.indent(indent) << "RecordMemRef\n";
Chris Lattner132df652010-02-21 03:22:59 +0000127}
128
Chris Lattnerf7f9e8c2010-12-23 17:03:20 +0000129void CaptureGlueInputMatcher::printImpl(raw_ostream &OS, unsigned indent) const{
130 OS.indent(indent) << "CaptureGlueInput\n";
Chris Lattner132df652010-02-21 03:22:59 +0000131}
132
Chris Lattner1f2adb62010-02-25 06:53:39 +0000133void MoveChildMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000134 OS.indent(indent) << "MoveChild " << ChildNo << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000135}
136
Chris Lattner1f2adb62010-02-25 06:53:39 +0000137void MoveParentMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000138 OS.indent(indent) << "MoveParent\n";
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000139}
140
Chris Lattner1f2adb62010-02-25 06:53:39 +0000141void CheckSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000142 OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000143}
144
Craig Toppera1bbc322013-10-05 05:38:16 +0000145void CheckChildSameMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
146 OS.indent(indent) << "CheckChild" << ChildNo << "Same\n";
147}
148
Chris Lattner2c3f6492010-02-25 02:04:40 +0000149void CheckPatternPredicateMatcher::
Chris Lattner1f2adb62010-02-25 06:53:39 +0000150printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000151 OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000152}
153
Chris Lattner1f2adb62010-02-25 06:53:39 +0000154void CheckPredicateMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner514e2922011-04-17 21:38:24 +0000155 OS.indent(indent) << "CheckPredicate " << getPredicate().getFnName() << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000156}
157
Chris Lattner1f2adb62010-02-25 06:53:39 +0000158void CheckOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner278606b2010-02-27 21:48:43 +0000159 OS.indent(indent) << "CheckOpcode " << Opcode.getEnumName() << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000160}
161
Chris Lattnerf4d17752010-03-01 06:59:22 +0000162void SwitchOpcodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
163 OS.indent(indent) << "SwitchOpcode: {\n";
Javed Absar776bf1d2017-10-16 06:43:54 +0000164 for (const auto &C : Cases) {
165 OS.indent(indent) << "case " << C.first->getEnumName() << ":\n";
166 C.second->print(OS, indent+2);
Chris Lattnerf4d17752010-03-01 06:59:22 +0000167 }
168 OS.indent(indent) << "}\n";
169}
170
171
Chris Lattner1f2adb62010-02-25 06:53:39 +0000172void CheckTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner6c2d1782010-03-24 00:41:19 +0000173 OS.indent(indent) << "CheckType " << getEnumName(Type) << ", ResNo="
174 << ResNo << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000175}
176
Chris Lattner3e1ffd02010-03-03 06:28:15 +0000177void SwitchTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
178 OS.indent(indent) << "SwitchType: {\n";
Javed Absar776bf1d2017-10-16 06:43:54 +0000179 for (const auto &C : Cases) {
180 OS.indent(indent) << "case " << getEnumName(C.first) << ":\n";
181 C.second->print(OS, indent+2);
Chris Lattner3e1ffd02010-03-03 06:28:15 +0000182 }
183 OS.indent(indent) << "}\n";
184}
185
Chris Lattner1f2adb62010-02-25 06:53:39 +0000186void CheckChildTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner0c95baa2010-02-24 20:15:25 +0000187 OS.indent(indent) << "CheckChildType " << ChildNo << " "
188 << getEnumName(Type) << '\n';
Chris Lattner0c95baa2010-02-24 20:15:25 +0000189}
190
191
Chris Lattner1f2adb62010-02-25 06:53:39 +0000192void CheckIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000193 OS.indent(indent) << "CheckInteger " << Value << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000194}
195
Craig Topper7ca1d182014-02-05 05:44:28 +0000196void CheckChildIntegerMatcher::printImpl(raw_ostream &OS,
197 unsigned indent) const {
198 OS.indent(indent) << "CheckChildInteger " << ChildNo << " " << Value << '\n';
199}
200
Chris Lattner1f2adb62010-02-25 06:53:39 +0000201void CheckCondCodeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000202 OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000203}
204
Chris Lattner1f2adb62010-02-25 06:53:39 +0000205void CheckValueTypeMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000206 OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000207}
208
Chris Lattner1f2adb62010-02-25 06:53:39 +0000209void CheckComplexPatMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000210 OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000211}
212
Chris Lattner1f2adb62010-02-25 06:53:39 +0000213void CheckAndImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000214 OS.indent(indent) << "CheckAndImm " << Value << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000215}
216
Chris Lattner1f2adb62010-02-25 06:53:39 +0000217void CheckOrImmMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000218 OS.indent(indent) << "CheckOrImm " << Value << '\n';
Chris Lattnerb02cdaa2010-02-15 08:04:42 +0000219}
220
Chris Lattner1f2adb62010-02-25 06:53:39 +0000221void CheckFoldableChainNodeMatcher::printImpl(raw_ostream &OS,
Chris Lattnerf8695c12010-02-16 19:15:55 +0000222 unsigned indent) const {
223 OS.indent(indent) << "CheckFoldableChainNode\n";
Chris Lattneraa7d3e02010-02-16 06:10:58 +0000224}
Chris Lattnerf8a5bb02010-02-17 06:23:39 +0000225
Chris Lattner1f2adb62010-02-25 06:53:39 +0000226void EmitIntegerMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Craig Topper6ff46262016-04-17 17:37:33 +0000227 OS.indent(indent) << "EmitInteger " << Val << " VT=" << getEnumName(VT)
228 << '\n';
Chris Lattner132df652010-02-21 03:22:59 +0000229}
230
Chris Lattner2c3f6492010-02-25 02:04:40 +0000231void EmitStringIntegerMatcher::
Chris Lattner1f2adb62010-02-25 06:53:39 +0000232printImpl(raw_ostream &OS, unsigned indent) const {
Craig Topper6ff46262016-04-17 17:37:33 +0000233 OS.indent(indent) << "EmitStringInteger " << Val << " VT=" << getEnumName(VT)
234 << '\n';
Chris Lattner42a7ba72010-02-18 22:03:03 +0000235}
236
Chris Lattner1f2adb62010-02-25 06:53:39 +0000237void EmitRegisterMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000238 OS.indent(indent) << "EmitRegister ";
Chris Lattner42a7ba72010-02-18 22:03:03 +0000239 if (Reg)
240 OS << Reg->getName();
241 else
242 OS << "zero_reg";
Craig Topper6ff46262016-04-17 17:37:33 +0000243 OS << " VT=" << getEnumName(VT) << '\n';
Chris Lattner42a7ba72010-02-18 22:03:03 +0000244}
245
Chris Lattner2c3f6492010-02-25 02:04:40 +0000246void EmitConvertToTargetMatcher::
Chris Lattner1f2adb62010-02-25 06:53:39 +0000247printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000248 OS.indent(indent) << "EmitConvertToTarget " << Slot << '\n';
Chris Lattner132df652010-02-21 03:22:59 +0000249}
250
Chris Lattner2c3f6492010-02-25 02:04:40 +0000251void EmitMergeInputChainsMatcher::
Chris Lattner1f2adb62010-02-25 06:53:39 +0000252printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000253 OS.indent(indent) << "EmitMergeInputChains <todo: args>\n";
Chris Lattner132df652010-02-21 03:22:59 +0000254}
255
Chris Lattner1f2adb62010-02-25 06:53:39 +0000256void EmitCopyToRegMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000257 OS.indent(indent) << "EmitCopyToReg <todo: args>\n";
Chris Lattner132df652010-02-21 03:22:59 +0000258}
259
Chris Lattner1f2adb62010-02-25 06:53:39 +0000260void EmitNodeXFormMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner132df652010-02-21 03:22:59 +0000261 OS.indent(indent) << "EmitNodeXForm " << NodeXForm->getName()
262 << " Slot=" << Slot << '\n';
Chris Lattner132df652010-02-21 03:22:59 +0000263}
264
265
Chris Lattnerc3f80e02010-02-28 02:31:26 +0000266void EmitNodeMatcherCommon::printImpl(raw_ostream &OS, unsigned indent) const {
267 OS.indent(indent);
Chris Lattner9d67dca2010-02-28 20:55:18 +0000268 OS << (isa<MorphNodeToMatcher>(this) ? "MorphNodeTo: " : "EmitNode: ")
Chris Lattnerc3f80e02010-02-28 02:31:26 +0000269 << OpcodeName << ": <todo flags> ";
Chris Lattner132df652010-02-21 03:22:59 +0000270
271 for (unsigned i = 0, e = VTs.size(); i != e; ++i)
272 OS << ' ' << getEnumName(VTs[i]);
273 OS << '(';
274 for (unsigned i = 0, e = Operands.size(); i != e; ++i)
275 OS << Operands[i] << ' ';
276 OS << ")\n";
Chris Lattner132df652010-02-21 03:22:59 +0000277}
278
Chris Lattner1f2adb62010-02-25 06:53:39 +0000279void CompleteMatchMatcher::printImpl(raw_ostream &OS, unsigned indent) const {
Chris Lattner79eaeb42010-02-21 06:03:07 +0000280 OS.indent(indent) << "CompleteMatch <todo args>\n";
Chris Lattner132df652010-02-21 03:22:59 +0000281 OS.indent(indent) << "Src = " << *Pattern.getSrcPattern() << "\n";
282 OS.indent(indent) << "Dst = " << *Pattern.getDstPattern() << "\n";
Chris Lattner132df652010-02-21 03:22:59 +0000283}
284
Chris Lattnerf4d17752010-03-01 06:59:22 +0000285bool CheckOpcodeMatcher::isEqualImpl(const Matcher *M) const {
286 // Note: pointer equality isn't enough here, we have to check the enum names
Jim Grosbach65586fe2010-12-21 16:16:00 +0000287 // to ensure that the nodes are for the same opcode.
Chris Lattnerf4d17752010-03-01 06:59:22 +0000288 return cast<CheckOpcodeMatcher>(M)->Opcode.getEnumName() ==
289 Opcode.getEnumName();
290}
291
Chris Lattnerc3f80e02010-02-28 02:31:26 +0000292bool EmitNodeMatcherCommon::isEqualImpl(const Matcher *m) const {
293 const EmitNodeMatcherCommon *M = cast<EmitNodeMatcherCommon>(m);
Chris Lattner212e8c82010-02-25 06:49:58 +0000294 return M->OpcodeName == OpcodeName && M->VTs == VTs &&
295 M->Operands == Operands && M->HasChain == HasChain &&
Chris Lattner2a0a3b42010-12-23 18:28:41 +0000296 M->HasInGlue == HasInGlue && M->HasOutGlue == HasOutGlue &&
Chris Lattnera8382642010-02-28 21:53:42 +0000297 M->HasMemRefs == HasMemRefs &&
Chris Lattner212e8c82010-02-25 06:49:58 +0000298 M->NumFixedArityOperands == NumFixedArityOperands;
299}
300
David Blaikiea379b1812011-12-20 02:50:00 +0000301void EmitNodeMatcher::anchor() { }
302
303void MorphNodeToMatcher::anchor() { }
304
Chris Lattnerc577b812010-02-27 07:49:13 +0000305// isContradictoryImpl Implementations.
306
Chris Lattnerc577b812010-02-27 07:49:13 +0000307static bool TypesAreContradictory(MVT::SimpleValueType T1,
308 MVT::SimpleValueType T2) {
309 // If the two types are the same, then they are the same, so they don't
310 // contradict.
311 if (T1 == T2) return false;
Jim Grosbach65586fe2010-12-21 16:16:00 +0000312
Chris Lattnerc577b812010-02-27 07:49:13 +0000313 // If either type is about iPtr, then they don't conflict unless the other
314 // one is not a scalar integer type.
315 if (T1 == MVT::iPTR)
316 return !MVT(T2).isInteger() || MVT(T2).isVector();
Jim Grosbach65586fe2010-12-21 16:16:00 +0000317
Chris Lattnerc577b812010-02-27 07:49:13 +0000318 if (T2 == MVT::iPTR)
319 return !MVT(T1).isInteger() || MVT(T1).isVector();
Jim Grosbach65586fe2010-12-21 16:16:00 +0000320
Chris Lattnerc577b812010-02-27 07:49:13 +0000321 // Otherwise, they are two different non-iPTR types, they conflict.
322 return true;
323}
324
Chris Lattner99e53b32010-02-28 00:22:30 +0000325bool CheckOpcodeMatcher::isContradictoryImpl(const Matcher *M) const {
326 if (const CheckOpcodeMatcher *COM = dyn_cast<CheckOpcodeMatcher>(M)) {
327 // One node can't have two different opcodes!
Chris Lattnerf4d17752010-03-01 06:59:22 +0000328 // Note: pointer equality isn't enough here, we have to check the enum names
Jim Grosbach65586fe2010-12-21 16:16:00 +0000329 // to ensure that the nodes are for the same opcode.
Chris Lattnerf4d17752010-03-01 06:59:22 +0000330 return COM->getOpcode().getEnumName() != getOpcode().getEnumName();
Chris Lattner99e53b32010-02-28 00:22:30 +0000331 }
Jim Grosbach65586fe2010-12-21 16:16:00 +0000332
Chris Lattner99e53b32010-02-28 00:22:30 +0000333 // If the node has a known type, and if the type we're checking for is
334 // different, then we know they contradict. For example, a check for
335 // ISD::STORE will never be true at the same time a check for Type i32 is.
336 if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M)) {
Chris Lattner6c2d1782010-03-24 00:41:19 +0000337 // If checking for a result the opcode doesn't have, it can't match.
338 if (CT->getResNo() >= getOpcode().getNumResults())
339 return true;
Jim Grosbach65586fe2010-12-21 16:16:00 +0000340
Chris Lattner6c2d1782010-03-24 00:41:19 +0000341 MVT::SimpleValueType NodeType = getOpcode().getKnownType(CT->getResNo());
Chris Lattnerda5b4ad2010-03-19 01:14:27 +0000342 if (NodeType != MVT::Other)
343 return TypesAreContradictory(NodeType, CT->getType());
Chris Lattner99e53b32010-02-28 00:22:30 +0000344 }
Jim Grosbach65586fe2010-12-21 16:16:00 +0000345
Chris Lattner99e53b32010-02-28 00:22:30 +0000346 return false;
347}
348
Chris Lattnerc577b812010-02-27 07:49:13 +0000349bool CheckTypeMatcher::isContradictoryImpl(const Matcher *M) const {
350 if (const CheckTypeMatcher *CT = dyn_cast<CheckTypeMatcher>(M))
351 return TypesAreContradictory(getType(), CT->getType());
352 return false;
353}
354
355bool CheckChildTypeMatcher::isContradictoryImpl(const Matcher *M) const {
356 if (const CheckChildTypeMatcher *CC = dyn_cast<CheckChildTypeMatcher>(M)) {
357 // If the two checks are about different nodes, we don't know if they
358 // conflict!
359 if (CC->getChildNo() != getChildNo())
360 return false;
Jim Grosbach65586fe2010-12-21 16:16:00 +0000361
Chris Lattnerc577b812010-02-27 07:49:13 +0000362 return TypesAreContradictory(getType(), CC->getType());
363 }
364 return false;
365}
Jim Grosbach65586fe2010-12-21 16:16:00 +0000366
Chris Lattner2586c862010-02-27 08:11:15 +0000367bool CheckIntegerMatcher::isContradictoryImpl(const Matcher *M) const {
368 if (const CheckIntegerMatcher *CIM = dyn_cast<CheckIntegerMatcher>(M))
369 return CIM->getValue() != getValue();
370 return false;
371}
Chris Lattner9c791d82010-03-07 06:29:26 +0000372
Craig Topper7ca1d182014-02-05 05:44:28 +0000373bool CheckChildIntegerMatcher::isContradictoryImpl(const Matcher *M) const {
374 if (const CheckChildIntegerMatcher *CCIM = dyn_cast<CheckChildIntegerMatcher>(M)) {
375 // If the two checks are about different nodes, we don't know if they
376 // conflict!
377 if (CCIM->getChildNo() != getChildNo())
378 return false;
379
380 return CCIM->getValue() != getValue();
381 }
382 return false;
383}
384
Chris Lattner9c791d82010-03-07 06:29:26 +0000385bool CheckValueTypeMatcher::isContradictoryImpl(const Matcher *M) const {
386 if (const CheckValueTypeMatcher *CVT = dyn_cast<CheckValueTypeMatcher>(M))
387 return CVT->getTypeName() != getTypeName();
388 return false;
389}
390