Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 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" |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame^] | 13 | #include "Record.h" |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 14 | #include "llvm/Support/raw_ostream.h" |
| 15 | using namespace llvm; |
| 16 | |
| 17 | void MatcherNode::dump() const { |
| 18 | print(errs()); |
| 19 | } |
| 20 | |
| 21 | void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 22 | OS.indent(indent) << "EmitNode: Src = " << *Pattern.getSrcPattern() << "\n"; |
| 23 | OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n"; |
| 24 | } |
| 25 | |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 26 | void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const { |
| 27 | if (Next) |
| 28 | return Next->print(OS, indent); |
| 29 | OS.indent(indent) << "<null next field>\n"; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | |
| 33 | void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 34 | OS.indent(indent) << "Push\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 35 | printNext(OS, indent+2); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 36 | Failure->print(OS, indent); |
| 37 | } |
| 38 | |
| 39 | void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 40 | OS.indent(indent) << "Record\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 41 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 45 | OS.indent(indent) << "MoveChild " << ChildNo << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 46 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 50 | OS.indent(indent) << "MoveParent\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 51 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 55 | OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 56 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | void CheckPatternPredicateMatcherNode:: |
| 60 | print(raw_ostream &OS, unsigned indent) const { |
| 61 | OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 62 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 66 | OS.indent(indent) << "CheckPredicate " << PredName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 67 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 71 | OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 72 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 76 | OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 77 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 81 | OS.indent(indent) << "CheckInteger " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 82 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 86 | OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 87 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 91 | OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 92 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 96 | OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 97 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 101 | OS.indent(indent) << "CheckAndImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 102 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 106 | OS.indent(indent) << "CheckOrImm " << Value << '\n'; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 107 | printNext(OS, indent); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Chris Lattner | 21390d7 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 110 | void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, |
| 111 | unsigned indent) const { |
| 112 | OS.indent(indent) << "CheckFoldableChainNode\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 113 | printNext(OS, indent); |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 114 | } |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 115 | |
| 116 | void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, |
| 117 | unsigned indent) const { |
| 118 | OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 119 | printNext(OS, indent); |
Chris Lattner | 9a747f1 | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 120 | } |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame^] | 121 | |
| 122 | void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 123 | OS.indent(indent) << "EmitIntegerMatcherNode " << Val << " VT=" << VT << '\n'; |
| 124 | printNext(OS, indent); |
| 125 | } |
| 126 | |
| 127 | void EmitRegisterMatcherNode::print(raw_ostream &OS, unsigned indent) const { |
| 128 | OS.indent(indent) << "EmitRegisterMatcherNode "; |
| 129 | if (Reg) |
| 130 | OS << Reg->getName(); |
| 131 | else |
| 132 | OS << "zero_reg"; |
| 133 | OS << " VT=" << VT << '\n'; |
| 134 | printNext(OS, indent); |
| 135 | } |
| 136 | |