3f75558e3dc21787818f4ddb39f903b9de33bffd
[oota-llvm.git] / utils / TableGen / DAGISelMatcher.cpp
1 //===- 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"
13 #include "llvm/Support/raw_ostream.h"
14 using namespace llvm;
15
16 void MatcherNode::dump() const {
17   print(errs());
18 }
19
20 void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
21   OS.indent(indent) << "EmitNode: Src = " << *Pattern.getSrcPattern() << "\n";
22   OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n";
23 }
24
25 void MatcherNodeWithChild::printChild(raw_ostream &OS, unsigned indent) const {
26   if (Child)
27     return Child->print(OS, indent);
28   OS.indent(indent) << "<null child>\n";
29 }
30
31
32 void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const {
33   OS.indent(indent) << "Push\n";
34   printChild(OS, indent+2);
35   Failure->print(OS, indent);
36 }
37
38 void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
39   OS.indent(indent) << "Record\n";
40   printChild(OS, indent);
41 }
42
43 void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
44   OS.indent(indent) << "MoveChild " << ChildNo << '\n';
45   printChild(OS, indent);
46 }
47
48 void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const {
49   OS.indent(indent) << "MoveParent\n";
50   printChild(OS, indent);
51 }
52
53 void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const {
54   OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
55   printChild(OS, indent);
56 }
57
58 void CheckPatternPredicateMatcherNode::
59 print(raw_ostream &OS, unsigned indent) const {
60   OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
61   printChild(OS, indent);
62 }
63
64 void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const {
65   OS.indent(indent) << "CheckPredicate " << PredName << '\n';
66   printChild(OS, indent);
67 }
68
69 void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
70   OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
71   printChild(OS, indent);
72 }
73
74 void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
75   OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
76   printChild(OS, indent);
77 }
78
79 void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
80   OS.indent(indent) << "CheckInteger " << Value << '\n';
81   printChild(OS, indent);
82 }
83
84 void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
85   OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
86   printChild(OS, indent);
87 }
88
89 void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
90   OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
91   printChild(OS, indent);
92 }
93
94 void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const {
95   OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
96   printChild(OS, indent);
97 }
98
99 void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
100   OS.indent(indent) << "CheckAndImm " << Value << '\n';
101   printChild(OS, indent);
102 }
103
104 void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
105   OS.indent(indent) << "CheckOrImm " << Value << '\n';
106   printChild(OS, indent);
107 }
108
109 void CheckProfitableToFoldMatcherNode::print(raw_ostream &OS,
110                                              unsigned indent) const {
111   OS.indent(indent) << "CheckProfitableToFold\n";
112   printChild(OS, indent);
113 }
114
115 void CheckLegalToFoldMatcherNode::print(raw_ostream &OS, unsigned indent) const{
116   OS.indent(indent) << "CheckLegalToFold\n";
117   printChild(OS, indent);
118 }