DAGISelMatcher.cpp revision 845c04273461b2a10754a1455b02916a19ea72aa
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 "Record.h" 14#include "llvm/Support/raw_ostream.h" 15using namespace llvm; 16 17void MatcherNode::dump() const { 18 print(errs()); 19} 20 21void 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 26void 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"; 30} 31 32 33void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const { 34 OS.indent(indent) << "Push\n"; 35 printNext(OS, indent+2); 36 Failure->print(OS, indent); 37} 38 39void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const { 40 OS.indent(indent) << "Record\n"; 41 printNext(OS, indent); 42} 43 44void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const { 45 OS.indent(indent) << "MoveChild " << ChildNo << '\n'; 46 printNext(OS, indent); 47} 48 49void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const { 50 OS.indent(indent) << "MoveParent\n"; 51 printNext(OS, indent); 52} 53 54void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const { 55 OS.indent(indent) << "CheckSame " << MatchNumber << '\n'; 56 printNext(OS, indent); 57} 58 59void CheckPatternPredicateMatcherNode:: 60print(raw_ostream &OS, unsigned indent) const { 61 OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n'; 62 printNext(OS, indent); 63} 64 65void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const { 66 OS.indent(indent) << "CheckPredicate " << PredName << '\n'; 67 printNext(OS, indent); 68} 69 70void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { 71 OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n'; 72 printNext(OS, indent); 73} 74 75void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { 76 OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n'; 77 printNext(OS, indent); 78} 79 80void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { 81 OS.indent(indent) << "CheckInteger " << Value << '\n'; 82 printNext(OS, indent); 83} 84 85void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const { 86 OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n'; 87 printNext(OS, indent); 88} 89 90void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const { 91 OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n'; 92 printNext(OS, indent); 93} 94 95void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const { 96 OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n'; 97 printNext(OS, indent); 98} 99 100void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { 101 OS.indent(indent) << "CheckAndImm " << Value << '\n'; 102 printNext(OS, indent); 103} 104 105void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const { 106 OS.indent(indent) << "CheckOrImm " << Value << '\n'; 107 printNext(OS, indent); 108} 109 110void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS, 111 unsigned indent) const { 112 OS.indent(indent) << "CheckFoldableChainNode\n"; 113 printNext(OS, indent); 114} 115 116void CheckChainCompatibleMatcherNode::print(raw_ostream &OS, 117 unsigned indent) const { 118 OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n"; 119 printNext(OS, indent); 120} 121 122void EmitIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const { 123 OS.indent(indent) << "EmitIntegerMatcherNode " << Val << " VT=" << VT << '\n'; 124 printNext(OS, indent); 125} 126 127void 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 137