Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 1 | //===- DAGISelMatcherGen.cpp - Matcher generator --------------------------===// |
| 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" |
Jim Grosbach | 4a6d735 | 2011-03-11 02:19:02 +0000 | [diff] [blame] | 12 | #include "CodeGenRegisters.h" |
Jim Grosbach | 4a6d735 | 2011-03-11 02:19:02 +0000 | [diff] [blame] | 13 | #include "llvm/ADT/DenseMap.h" |
Chris Lattner | 785d16f | 2010-02-17 02:16:19 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/SmallVector.h" |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/StringMap.h" |
Chandler Carruth | 4ffd89f | 2012-12-04 10:37:14 +0000 | [diff] [blame] | 16 | #include "llvm/TableGen/Error.h" |
| 17 | #include "llvm/TableGen/Record.h" |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 18 | #include <utility> |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 19 | using namespace llvm; |
| 20 | |
Chris Lattner | c94fa4c | 2010-02-19 00:27:40 +0000 | [diff] [blame] | 21 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 22 | /// getRegisterValueType - Look up and return the ValueType of the specified |
| 23 | /// register. If the register is a member of multiple register classes which |
| 24 | /// have different associated types, return MVT::Other. |
| 25 | static MVT::SimpleValueType getRegisterValueType(Record *R, |
| 26 | const CodeGenTarget &T) { |
| 27 | bool FoundRC = false; |
| 28 | MVT::SimpleValueType VT = MVT::Other; |
Jakob Stoklund Olesen | ae1920b | 2011-06-15 04:50:36 +0000 | [diff] [blame] | 29 | const CodeGenRegister *Reg = T.getRegBank().getReg(R); |
Jakob Stoklund Olesen | 29f018c | 2011-09-29 22:28:37 +0000 | [diff] [blame] | 30 | ArrayRef<CodeGenRegisterClass*> RCs = T.getRegBank().getRegClasses(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 31 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 32 | for (unsigned rc = 0, e = RCs.size(); rc != e; ++rc) { |
Jakob Stoklund Olesen | 29f018c | 2011-09-29 22:28:37 +0000 | [diff] [blame] | 33 | const CodeGenRegisterClass &RC = *RCs[rc]; |
Jakob Stoklund Olesen | ae1920b | 2011-06-15 04:50:36 +0000 | [diff] [blame] | 34 | if (!RC.contains(Reg)) |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 35 | continue; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 36 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 37 | if (!FoundRC) { |
| 38 | FoundRC = true; |
| 39 | VT = RC.getValueTypeNum(0); |
| 40 | continue; |
Chris Lattner | c94fa4c | 2010-02-19 00:27:40 +0000 | [diff] [blame] | 41 | } |
Chris Lattner | 67ea6a7 | 2010-03-01 22:49:06 +0000 | [diff] [blame] | 42 | |
| 43 | // If this occurs in multiple register classes, they all have to agree. |
| 44 | assert(VT == RC.getValueTypeNum(0)); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 45 | } |
| 46 | return VT; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | namespace { |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 51 | class MatcherGen { |
| 52 | const PatternToMatch &Pattern; |
| 53 | const CodeGenDAGPatterns &CGP; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 54 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 55 | /// PatWithNoTypes - This is a clone of Pattern.getSrcPattern() that starts |
| 56 | /// out with all of the types removed. This allows us to insert type checks |
| 57 | /// as we scan the tree. |
| 58 | TreePatternNode *PatWithNoTypes; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 59 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 60 | /// VariableMap - A map from variable names ('$dst') to the recorded operand |
| 61 | /// number that they were captured as. These are biased by 1 to make |
| 62 | /// insertion easier. |
| 63 | StringMap<unsigned> VariableMap; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 64 | |
Chris Lattner | c94fa4c | 2010-02-19 00:27:40 +0000 | [diff] [blame] | 65 | /// NextRecordedOperandNo - As we emit opcodes to record matched values in |
| 66 | /// the RecordedNodes array, this keeps track of which slot will be next to |
| 67 | /// record into. |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 68 | unsigned NextRecordedOperandNo; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 69 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 70 | /// MatchedChainNodes - This maintains the position in the recorded nodes |
| 71 | /// array of all of the recorded input nodes that have chains. |
| 72 | SmallVector<unsigned, 2> MatchedChainNodes; |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 73 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 74 | /// MatchedGlueResultNodes - This maintains the position in the recorded |
| 75 | /// nodes array of all of the recorded input nodes that have glue results. |
| 76 | SmallVector<unsigned, 2> MatchedGlueResultNodes; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 77 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 78 | /// MatchedComplexPatterns - This maintains a list of all of the |
| 79 | /// ComplexPatterns that we need to check. The patterns are known to have |
| 80 | /// names which were recorded. The second element of each pair is the first |
| 81 | /// slot number that the OPC_CheckComplexPat opcode drops the matched |
| 82 | /// results into. |
| 83 | SmallVector<std::pair<const TreePatternNode*, |
| 84 | unsigned>, 2> MatchedComplexPatterns; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 85 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 86 | /// PhysRegInputs - List list has an entry for each explicitly specified |
| 87 | /// physreg input to the pattern. The first elt is the Register node, the |
| 88 | /// second is the recorded slot number the input pattern match saved it in. |
| 89 | SmallVector<std::pair<Record*, unsigned>, 2> PhysRegInputs; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 90 | |
Chris Lattner | 785d16f | 2010-02-17 02:16:19 +0000 | [diff] [blame] | 91 | /// Matcher - This is the top level of the generated matcher, the result. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 92 | Matcher *TheMatcher; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 93 | |
Chris Lattner | 785d16f | 2010-02-17 02:16:19 +0000 | [diff] [blame] | 94 | /// CurPredicate - As we emit matcher nodes, this points to the latest check |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 95 | /// which should have future checks stuck into its Next position. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 96 | Matcher *CurPredicate; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 97 | public: |
| 98 | MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 99 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 100 | ~MatcherGen() { |
| 101 | delete PatWithNoTypes; |
| 102 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 103 | |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 104 | bool EmitMatcherCode(unsigned Variant); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 105 | void EmitResultCode(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 106 | |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 107 | Matcher *GetMatcher() const { return TheMatcher; } |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 108 | private: |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 109 | void AddMatcher(Matcher *NewNode); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 110 | void InferPossibleTypes(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 111 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 112 | // Matcher Generation. |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 113 | void EmitMatchCode(const TreePatternNode *N, TreePatternNode *NodeNoTypes); |
| 114 | void EmitLeafMatchCode(const TreePatternNode *N); |
| 115 | void EmitOperatorMatchCode(const TreePatternNode *N, |
| 116 | TreePatternNode *NodeNoTypes); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 117 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 118 | // Result Code Generation. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 119 | unsigned getNamedArgumentSlot(StringRef Name) { |
| 120 | unsigned VarMapEntry = VariableMap[Name]; |
| 121 | assert(VarMapEntry != 0 && |
| 122 | "Variable referenced but not defined and not caught earlier!"); |
| 123 | return VarMapEntry-1; |
| 124 | } |
| 125 | |
| 126 | /// GetInstPatternNode - Get the pattern for an instruction. |
| 127 | const TreePatternNode *GetInstPatternNode(const DAGInstruction &Ins, |
| 128 | const TreePatternNode *N); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 129 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 130 | void EmitResultOperand(const TreePatternNode *N, |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 131 | SmallVectorImpl<unsigned> &ResultOps); |
| 132 | void EmitResultOfNamedOperand(const TreePatternNode *N, |
| 133 | SmallVectorImpl<unsigned> &ResultOps); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 134 | void EmitResultLeafAsOperand(const TreePatternNode *N, |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 135 | SmallVectorImpl<unsigned> &ResultOps); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 136 | void EmitResultInstructionAsOperand(const TreePatternNode *N, |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 137 | SmallVectorImpl<unsigned> &ResultOps); |
| 138 | void EmitResultSDNodeXFormAsOperand(const TreePatternNode *N, |
| 139 | SmallVectorImpl<unsigned> &ResultOps); |
| 140 | }; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 141 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 142 | } // end anon namespace. |
| 143 | |
| 144 | MatcherGen::MatcherGen(const PatternToMatch &pattern, |
| 145 | const CodeGenDAGPatterns &cgp) |
Chris Lattner | 853b919 | 2010-02-19 00:33:13 +0000 | [diff] [blame] | 146 | : Pattern(pattern), CGP(cgp), NextRecordedOperandNo(0), |
Chris Lattner | 01bcd94 | 2010-03-01 22:46:42 +0000 | [diff] [blame] | 147 | TheMatcher(0), CurPredicate(0) { |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 148 | // We need to produce the matcher tree for the patterns source pattern. To do |
| 149 | // this we need to match the structure as well as the types. To do the type |
| 150 | // matching, we want to figure out the fewest number of type checks we need to |
| 151 | // emit. For example, if there is only one integer type supported by a |
| 152 | // target, there should be no type comparisons at all for integer patterns! |
| 153 | // |
| 154 | // To figure out the fewest number of type checks needed, clone the pattern, |
| 155 | // remove the types, then perform type inference on the pattern as a whole. |
| 156 | // If there are unresolved types, emit an explicit check for those types, |
| 157 | // apply the type to the tree, then rerun type inference. Iterate until all |
| 158 | // types are resolved. |
| 159 | // |
| 160 | PatWithNoTypes = Pattern.getSrcPattern()->clone(); |
| 161 | PatWithNoTypes->RemoveAllTypes(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 162 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 163 | // If there are types that are manifestly known, infer them. |
| 164 | InferPossibleTypes(); |
| 165 | } |
| 166 | |
| 167 | /// InferPossibleTypes - As we emit the pattern, we end up generating type |
| 168 | /// checks and applying them to the 'PatWithNoTypes' tree. As we do this, we |
| 169 | /// want to propagate implied types as far throughout the tree as possible so |
| 170 | /// that we avoid doing redundant type checks. This does the type propagation. |
| 171 | void MatcherGen::InferPossibleTypes() { |
| 172 | // TP - Get *SOME* tree pattern, we don't care which. It is only used for |
| 173 | // diagnostics, which we know are impossible at this point. |
| 174 | TreePattern &TP = *CGP.pf_begin()->second; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 175 | |
Joerg Sonnenberger | 61131ab | 2012-10-25 20:33:17 +0000 | [diff] [blame] | 176 | bool MadeChange = true; |
| 177 | while (MadeChange) |
| 178 | MadeChange = PatWithNoTypes->ApplyTypeConstraints(TP, |
| 179 | true/*Ignore reg constraints*/); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 183 | /// AddMatcher - Add a matcher node to the current graph we're building. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 184 | void MatcherGen::AddMatcher(Matcher *NewNode) { |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 185 | if (CurPredicate != 0) |
Chris Lattner | bd8227f | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 186 | CurPredicate->setNext(NewNode); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 187 | else |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 188 | TheMatcher = NewNode; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 189 | CurPredicate = NewNode; |
| 190 | } |
| 191 | |
| 192 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 193 | //===----------------------------------------------------------------------===// |
| 194 | // Pattern Match Generation |
| 195 | //===----------------------------------------------------------------------===// |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 196 | |
| 197 | /// EmitLeafMatchCode - Generate matching code for leaf nodes. |
| 198 | void MatcherGen::EmitLeafMatchCode(const TreePatternNode *N) { |
| 199 | assert(N->isLeaf() && "Not a leaf?"); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 200 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 201 | // Direct match against an integer constant. |
Sean Silva | 6cfc806 | 2012-10-10 20:24:43 +0000 | [diff] [blame] | 202 | if (IntInit *II = dyn_cast<IntInit>(N->getLeafValue())) { |
Chris Lattner | bd8965a | 2010-03-01 07:27:07 +0000 | [diff] [blame] | 203 | // If this is the root of the dag we're matching, we emit a redundant opcode |
| 204 | // check to ensure that this gets folded into the normal top-level |
| 205 | // OpcodeSwitch. |
| 206 | if (N == Pattern.getSrcPattern()) { |
| 207 | const SDNodeInfo &NI = CGP.getSDNodeInfo(CGP.getSDNodeNamed("imm")); |
| 208 | AddMatcher(new CheckOpcodeMatcher(NI)); |
| 209 | } |
| 210 | |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 211 | return AddMatcher(new CheckIntegerMatcher(II->getValue())); |
Chris Lattner | bd8965a | 2010-03-01 07:27:07 +0000 | [diff] [blame] | 212 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 213 | |
Jakob Stoklund Olesen | 8e3cb3e | 2013-03-24 19:37:00 +0000 | [diff] [blame] | 214 | // An UnsetInit represents a named node without any constraints. |
| 215 | if (N->getLeafValue() == UnsetInit::get()) { |
| 216 | assert(N->hasName() && "Unnamed ? leaf"); |
| 217 | return; |
| 218 | } |
| 219 | |
Sean Silva | 6cfc806 | 2012-10-10 20:24:43 +0000 | [diff] [blame] | 220 | DefInit *DI = dyn_cast<DefInit>(N->getLeafValue()); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 221 | if (DI == 0) { |
Chris Lattner | ef18cd3 | 2012-03-26 19:11:51 +0000 | [diff] [blame] | 222 | errs() << "Unknown leaf kind: " << *N << "\n"; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 223 | abort(); |
| 224 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 225 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 226 | Record *LeafRec = DI->getDef(); |
Jakob Stoklund Olesen | f0a804d | 2013-03-23 20:35:01 +0000 | [diff] [blame] | 227 | |
| 228 | // A ValueType leaf node can represent a register when named, or itself when |
| 229 | // unnamed. |
| 230 | if (LeafRec->isSubClassOf("ValueType")) { |
| 231 | // A named ValueType leaf always matches: (add i32:$a, i32:$b). |
| 232 | if (N->hasName()) |
| 233 | return; |
| 234 | // An unnamed ValueType as in (sext_inreg GPR:$foo, i8). |
| 235 | return AddMatcher(new CheckValueTypeMatcher(LeafRec->getName())); |
| 236 | } |
| 237 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 238 | if (// Handle register references. Nothing to do here, they always match. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 239 | LeafRec->isSubClassOf("RegisterClass") || |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 240 | LeafRec->isSubClassOf("RegisterOperand") || |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 241 | LeafRec->isSubClassOf("PointerLikeRegClass") || |
Jakob Stoklund Olesen | 73ea7bf | 2010-05-24 14:48:12 +0000 | [diff] [blame] | 242 | LeafRec->isSubClassOf("SubRegIndex") || |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 243 | // Place holder for SRCVALUE nodes. Nothing to do here. |
| 244 | LeafRec->getName() == "srcvalue") |
| 245 | return; |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 246 | |
| 247 | // If we have a physreg reference like (mul gpr:$src, EAX) then we need to |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 248 | // record the register |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 249 | if (LeafRec->isSubClassOf("Register")) { |
Chris Lattner | 0cebe61 | 2010-03-01 02:24:17 +0000 | [diff] [blame] | 250 | AddMatcher(new RecordMatcher("physreg input "+LeafRec->getName(), |
| 251 | NextRecordedOperandNo)); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 252 | PhysRegInputs.push_back(std::make_pair(LeafRec, NextRecordedOperandNo++)); |
| 253 | return; |
| 254 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 255 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 256 | if (LeafRec->isSubClassOf("CondCode")) |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 257 | return AddMatcher(new CheckCondCodeMatcher(LeafRec->getName())); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 258 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 259 | if (LeafRec->isSubClassOf("ComplexPattern")) { |
Chris Lattner | c2676b2 | 2010-02-17 00:11:30 +0000 | [diff] [blame] | 260 | // We can't model ComplexPattern uses that don't have their name taken yet. |
| 261 | // The OPC_CheckComplexPattern operation implicitly records the results. |
| 262 | if (N->getName().empty()) { |
Chris Lattner | 53a2f60 | 2010-02-16 23:16:25 +0000 | [diff] [blame] | 263 | errs() << "We expect complex pattern uses to have names: " << *N << "\n"; |
| 264 | exit(1); |
| 265 | } |
Chris Lattner | 1f2ed5f | 2010-02-22 22:18:05 +0000 | [diff] [blame] | 266 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 267 | // Remember this ComplexPattern so that we can emit it after all the other |
| 268 | // structural matches are done. |
| 269 | MatchedComplexPatterns.push_back(std::make_pair(N, 0)); |
Chris Lattner | 8dc4f2b | 2010-02-17 06:08:25 +0000 | [diff] [blame] | 270 | return; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 271 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 272 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 273 | errs() << "Unknown leaf kind: " << *N << "\n"; |
| 274 | abort(); |
| 275 | } |
| 276 | |
| 277 | void MatcherGen::EmitOperatorMatchCode(const TreePatternNode *N, |
| 278 | TreePatternNode *NodeNoTypes) { |
| 279 | assert(!N->isLeaf() && "Not an operator?"); |
| 280 | const SDNodeInfo &CInfo = CGP.getSDNodeInfo(N->getOperator()); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 281 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 282 | // If this is an 'and R, 1234' where the operation is AND/OR and the RHS is |
| 283 | // a constant without a predicate fn that has more that one bit set, handle |
| 284 | // this as a special case. This is usually for targets that have special |
| 285 | // handling of certain large constants (e.g. alpha with it's 8/16/32-bit |
| 286 | // handling stuff). Using these instructions is often far more efficient |
| 287 | // than materializing the constant. Unfortunately, both the instcombiner |
| 288 | // and the dag combiner can often infer that bits are dead, and thus drop |
| 289 | // them from the mask in the dag. For example, it might turn 'AND X, 255' |
| 290 | // into 'AND X, 254' if it knows the low bit is set. Emit code that checks |
| 291 | // to handle this. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 292 | if ((N->getOperator()->getName() == "and" || |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 293 | N->getOperator()->getName() == "or") && |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 294 | N->getChild(1)->isLeaf() && N->getChild(1)->getPredicateFns().empty() && |
| 295 | N->getPredicateFns().empty()) { |
Sean Silva | 6cfc806 | 2012-10-10 20:24:43 +0000 | [diff] [blame] | 296 | if (IntInit *II = dyn_cast<IntInit>(N->getChild(1)->getLeafValue())) { |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 297 | if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. |
Chris Lattner | e9eeda8 | 2010-03-01 02:15:34 +0000 | [diff] [blame] | 298 | // If this is at the root of the pattern, we emit a redundant |
| 299 | // CheckOpcode so that the following checks get factored properly under |
| 300 | // a single opcode check. |
| 301 | if (N == Pattern.getSrcPattern()) |
| 302 | AddMatcher(new CheckOpcodeMatcher(CInfo)); |
| 303 | |
| 304 | // Emit the CheckAndImm/CheckOrImm node. |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 305 | if (N->getOperator()->getName() == "and") |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 306 | AddMatcher(new CheckAndImmMatcher(II->getValue())); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 307 | else |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 308 | AddMatcher(new CheckOrImmMatcher(II->getValue())); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 309 | |
| 310 | // Match the LHS of the AND as appropriate. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 311 | AddMatcher(new MoveChildMatcher(0)); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 312 | EmitMatchCode(N->getChild(0), NodeNoTypes->getChild(0)); |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 313 | AddMatcher(new MoveParentMatcher()); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 314 | return; |
| 315 | } |
| 316 | } |
| 317 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 318 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 319 | // Check that the current opcode lines up. |
Chris Lattner | a230f96 | 2010-02-27 21:48:43 +0000 | [diff] [blame] | 320 | AddMatcher(new CheckOpcodeMatcher(CInfo)); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 321 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 322 | // If this node has memory references (i.e. is a load or store), tell the |
| 323 | // interpreter to capture them in the memref array. |
| 324 | if (N->NodeHasProperty(SDNPMemOperand, CGP)) |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 325 | AddMatcher(new RecordMemRefMatcher()); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 326 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 327 | // If this node has a chain, then the chain is operand #0 is the SDNode, and |
| 328 | // the child numbers of the node are all offset by one. |
| 329 | unsigned OpNo = 0; |
Chris Lattner | 6bc1b51 | 2010-02-16 19:19:58 +0000 | [diff] [blame] | 330 | if (N->NodeHasProperty(SDNPHasChain, CGP)) { |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 331 | // Record the node and remember it in our chained nodes list. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 332 | AddMatcher(new RecordMatcher("'" + N->getOperator()->getName() + |
Chris Lattner | 0cebe61 | 2010-03-01 02:24:17 +0000 | [diff] [blame] | 333 | "' chained node", |
| 334 | NextRecordedOperandNo)); |
Chris Lattner | 785d16f | 2010-02-17 02:16:19 +0000 | [diff] [blame] | 335 | // Remember all of the input chains our pattern will match. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 336 | MatchedChainNodes.push_back(NextRecordedOperandNo++); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 337 | |
Chris Lattner | 2f7ecde | 2010-02-17 01:34:15 +0000 | [diff] [blame] | 338 | // Don't look at the input chain when matching the tree pattern to the |
| 339 | // SDNode. |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 340 | OpNo = 1; |
| 341 | |
Chris Lattner | 6bc1b51 | 2010-02-16 19:19:58 +0000 | [diff] [blame] | 342 | // If this node is not the root and the subtree underneath it produces a |
| 343 | // chain, then the result of matching the node is also produce a chain. |
| 344 | // Beyond that, this means that we're also folding (at least) the root node |
| 345 | // into the node that produce the chain (for example, matching |
| 346 | // "(add reg, (load ptr))" as a add_with_memory on X86). This is |
| 347 | // problematic, if the 'reg' node also uses the load (say, its chain). |
| 348 | // Graphically: |
| 349 | // |
| 350 | // [LD] |
| 351 | // ^ ^ |
| 352 | // | \ DAG's like cheese. |
| 353 | // / | |
| 354 | // / [YY] |
| 355 | // | ^ |
| 356 | // [XX]--/ |
| 357 | // |
| 358 | // It would be invalid to fold XX and LD. In this case, folding the two |
| 359 | // nodes together would induce a cycle in the DAG, making it a 'cyclic DAG' |
| 360 | // To prevent this, we emit a dynamic check for legality before allowing |
| 361 | // this to be folded. |
| 362 | // |
| 363 | const TreePatternNode *Root = Pattern.getSrcPattern(); |
| 364 | if (N != Root) { // Not the root of the pattern. |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 365 | // If there is a node between the root and this node, then we definitely |
| 366 | // need to emit the check. |
| 367 | bool NeedCheck = !Root->hasChild(N); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 368 | |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 369 | // If it *is* an immediate child of the root, we can still need a check if |
| 370 | // the root SDNode has multiple inputs. For us, this means that it is an |
| 371 | // intrinsic, has multiple operands, or has other inputs like chain or |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 372 | // glue). |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 373 | if (!NeedCheck) { |
| 374 | const SDNodeInfo &PInfo = CGP.getSDNodeInfo(Root->getOperator()); |
| 375 | NeedCheck = |
| 376 | Root->getOperator() == CGP.get_intrinsic_void_sdnode() || |
| 377 | Root->getOperator() == CGP.get_intrinsic_w_chain_sdnode() || |
| 378 | Root->getOperator() == CGP.get_intrinsic_wo_chain_sdnode() || |
| 379 | PInfo.getNumOperands() > 1 || |
| 380 | PInfo.hasProperty(SDNPHasChain) || |
Chris Lattner | 036609b | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 381 | PInfo.hasProperty(SDNPInGlue) || |
| 382 | PInfo.hasProperty(SDNPOptInGlue); |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 383 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 384 | |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 385 | if (NeedCheck) |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 386 | AddMatcher(new CheckFoldableChainNodeMatcher()); |
Chris Lattner | e39650a | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 387 | } |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 388 | } |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 389 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 390 | // If this node has an output glue and isn't the root, remember it. |
Chris Lattner | 036609b | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 391 | if (N->NodeHasProperty(SDNPOutGlue, CGP) && |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 392 | N != Pattern.getSrcPattern()) { |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 393 | // TODO: This redundantly records nodes with both glues and chains. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 394 | |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 395 | // Record the node and remember it in our chained nodes list. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 396 | AddMatcher(new RecordMatcher("'" + N->getOperator()->getName() + |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 397 | "' glue output node", |
Chris Lattner | 0cebe61 | 2010-03-01 02:24:17 +0000 | [diff] [blame] | 398 | NextRecordedOperandNo)); |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 399 | // Remember all of the nodes with output glue our pattern will match. |
| 400 | MatchedGlueResultNodes.push_back(NextRecordedOperandNo++); |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 401 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 402 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 403 | // If this node is known to have an input glue or if it *might* have an input |
| 404 | // glue, capture it as the glue input of the pattern. |
Chris Lattner | 036609b | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 405 | if (N->NodeHasProperty(SDNPOptInGlue, CGP) || |
| 406 | N->NodeHasProperty(SDNPInGlue, CGP)) |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 407 | AddMatcher(new CaptureGlueInputMatcher()); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 408 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 409 | for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) { |
| 410 | // Get the code suitable for matching this child. Move to the child, check |
| 411 | // it then move back to the parent. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 412 | AddMatcher(new MoveChildMatcher(OpNo)); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 413 | EmitMatchCode(N->getChild(i), NodeNoTypes->getChild(i)); |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 414 | AddMatcher(new MoveParentMatcher()); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 415 | } |
| 416 | } |
| 417 | |
| 418 | |
| 419 | void MatcherGen::EmitMatchCode(const TreePatternNode *N, |
| 420 | TreePatternNode *NodeNoTypes) { |
| 421 | // If N and NodeNoTypes don't agree on a type, then this is a case where we |
| 422 | // need to do a type check. Emit the check, apply the tyep to NodeNoTypes and |
| 423 | // reinfer any correlated types. |
Chris Lattner | 084df62 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 424 | SmallVector<unsigned, 2> ResultsToTypeCheck; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 425 | |
Chris Lattner | 084df62 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 426 | for (unsigned i = 0, e = NodeNoTypes->getNumTypes(); i != e; ++i) { |
| 427 | if (NodeNoTypes->getExtType(i) == N->getExtType(i)) continue; |
| 428 | NodeNoTypes->setType(i, N->getExtType(i)); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 429 | InferPossibleTypes(); |
Chris Lattner | 084df62 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 430 | ResultsToTypeCheck.push_back(i); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 431 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 432 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 433 | // If this node has a name associated with it, capture it in VariableMap. If |
| 434 | // we already saw this in the pattern, emit code to verify dagness. |
| 435 | if (!N->getName().empty()) { |
| 436 | unsigned &VarMapEntry = VariableMap[N->getName()]; |
| 437 | if (VarMapEntry == 0) { |
Chris Lattner | 20df242 | 2010-02-22 23:33:44 +0000 | [diff] [blame] | 438 | // If it is a named node, we must emit a 'Record' opcode. |
Chris Lattner | 0cebe61 | 2010-03-01 02:24:17 +0000 | [diff] [blame] | 439 | AddMatcher(new RecordMatcher("$" + N->getName(), NextRecordedOperandNo)); |
Chris Lattner | 20df242 | 2010-02-22 23:33:44 +0000 | [diff] [blame] | 440 | VarMapEntry = ++NextRecordedOperandNo; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 441 | } else { |
| 442 | // If we get here, this is a second reference to a specific name. Since |
| 443 | // we already have checked that the first reference is valid, we don't |
| 444 | // have to recursively match it, just check that it's the same as the |
| 445 | // previously named thing. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 446 | AddMatcher(new CheckSameMatcher(VarMapEntry-1)); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 447 | return; |
| 448 | } |
| 449 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 450 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 451 | if (N->isLeaf()) |
| 452 | EmitLeafMatchCode(N); |
| 453 | else |
| 454 | EmitOperatorMatchCode(N, NodeNoTypes); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 455 | |
Chris Lattner | 6fd326b | 2010-03-07 07:20:49 +0000 | [diff] [blame] | 456 | // If there are node predicates for this node, generate their checks. |
| 457 | for (unsigned i = 0, e = N->getPredicateFns().size(); i != e; ++i) |
| 458 | AddMatcher(new CheckPredicateMatcher(N->getPredicateFns()[i])); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 459 | |
Chris Lattner | 084df62 | 2010-03-24 00:41:19 +0000 | [diff] [blame] | 460 | for (unsigned i = 0, e = ResultsToTypeCheck.size(); i != e; ++i) |
| 461 | AddMatcher(new CheckTypeMatcher(N->getType(ResultsToTypeCheck[i]), |
| 462 | ResultsToTypeCheck[i])); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 463 | } |
| 464 | |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 465 | /// EmitMatcherCode - Generate the code that matches the predicate of this |
| 466 | /// pattern for the specified Variant. If the variant is invalid this returns |
| 467 | /// true and does not generate code, if it is valid, it returns false. |
| 468 | bool MatcherGen::EmitMatcherCode(unsigned Variant) { |
| 469 | // If the root of the pattern is a ComplexPattern and if it is specified to |
| 470 | // match some number of root opcodes, these are considered to be our variants. |
| 471 | // Depending on which variant we're generating code for, emit the root opcode |
| 472 | // check. |
| 473 | if (const ComplexPattern *CP = |
| 474 | Pattern.getSrcPattern()->getComplexPatternInfo(CGP)) { |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 475 | const std::vector<Record*> &OpNodes = CP->getRootNodes(); |
Chris Lattner | 405f125 | 2010-03-01 22:29:19 +0000 | [diff] [blame] | 476 | assert(!OpNodes.empty() &&"Complex Pattern must specify what it can match"); |
| 477 | if (Variant >= OpNodes.size()) return true; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 478 | |
Chris Lattner | 405f125 | 2010-03-01 22:29:19 +0000 | [diff] [blame] | 479 | AddMatcher(new CheckOpcodeMatcher(CGP.getSDNodeInfo(OpNodes[Variant]))); |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 480 | } else { |
| 481 | if (Variant != 0) return true; |
| 482 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 483 | |
Chris Lattner | 9752fb1 | 2010-03-04 01:25:36 +0000 | [diff] [blame] | 484 | // Emit the matcher for the pattern structure and types. |
| 485 | EmitMatchCode(Pattern.getSrcPattern(), PatWithNoTypes); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 486 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 487 | // If the pattern has a predicate on it (e.g. only enabled when a subtarget |
| 488 | // feature is around, do the check). |
| 489 | if (!Pattern.getPredicateCheck().empty()) |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 490 | AddMatcher(new CheckPatternPredicateMatcher(Pattern.getPredicateCheck())); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 491 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 492 | // Now that we've completed the structural type match, emit any ComplexPattern |
| 493 | // checks (e.g. addrmode matches). We emit this after the structural match |
| 494 | // because they are generally more expensive to evaluate and more difficult to |
| 495 | // factor. |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 496 | for (unsigned i = 0, e = MatchedComplexPatterns.size(); i != e; ++i) { |
| 497 | const TreePatternNode *N = MatchedComplexPatterns[i].first; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 498 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 499 | // Remember where the results of this match get stuck. |
| 500 | MatchedComplexPatterns[i].second = NextRecordedOperandNo; |
| 501 | |
| 502 | // Get the slot we recorded the value in from the name on the node. |
| 503 | unsigned RecNodeEntry = VariableMap[N->getName()]; |
| 504 | assert(!N->getName().empty() && RecNodeEntry && |
| 505 | "Complex pattern should have a name and slot"); |
| 506 | --RecNodeEntry; // Entries in VariableMap are biased. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 507 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 508 | const ComplexPattern &CP = |
David Greene | 05bce0b | 2011-07-29 22:43:06 +0000 | [diff] [blame] | 509 | CGP.getComplexPattern(((DefInit*)N->getLeafValue())->getDef()); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 510 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 511 | // Emit a CheckComplexPat operation, which does the match (aborting if it |
| 512 | // fails) and pushes the matched operands onto the recorded nodes list. |
| 513 | AddMatcher(new CheckComplexPatMatcher(CP, RecNodeEntry, |
| 514 | N->getName(), NextRecordedOperandNo)); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 515 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 516 | // Record the right number of operands. |
| 517 | NextRecordedOperandNo += CP.getNumOperands(); |
| 518 | if (CP.hasProperty(SDNPHasChain)) { |
| 519 | // If the complex pattern has a chain, then we need to keep track of the |
| 520 | // fact that we just recorded a chain input. The chain input will be |
| 521 | // matched as the last operand of the predicate if it was successful. |
| 522 | ++NextRecordedOperandNo; // Chained node operand. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 523 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 524 | // It is the last operand recorded. |
| 525 | assert(NextRecordedOperandNo > 1 && |
| 526 | "Should have recorded input/result chains at least!"); |
| 527 | MatchedChainNodes.push_back(NextRecordedOperandNo-1); |
| 528 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 529 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 530 | // TODO: Complex patterns can't have output glues, if they did, we'd want |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 531 | // to record them. |
| 532 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 533 | |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 534 | return false; |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 538 | //===----------------------------------------------------------------------===// |
| 539 | // Node Result Generation |
| 540 | //===----------------------------------------------------------------------===// |
| 541 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 542 | void MatcherGen::EmitResultOfNamedOperand(const TreePatternNode *N, |
| 543 | SmallVectorImpl<unsigned> &ResultOps){ |
| 544 | assert(!N->getName().empty() && "Operand not named!"); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 545 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 546 | // A reference to a complex pattern gets all of the results of the complex |
| 547 | // pattern's match. |
| 548 | if (const ComplexPattern *CP = N->getComplexPatternInfo(CGP)) { |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 549 | unsigned SlotNo = 0; |
| 550 | for (unsigned i = 0, e = MatchedComplexPatterns.size(); i != e; ++i) |
| 551 | if (MatchedComplexPatterns[i].first->getName() == N->getName()) { |
| 552 | SlotNo = MatchedComplexPatterns[i].second; |
| 553 | break; |
| 554 | } |
| 555 | assert(SlotNo != 0 && "Didn't get a slot number assigned?"); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 556 | |
Chris Lattner | 20df242 | 2010-02-22 23:33:44 +0000 | [diff] [blame] | 557 | // The first slot entry is the node itself, the subsequent entries are the |
| 558 | // matched values. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 559 | for (unsigned i = 0, e = CP->getNumOperands(); i != e; ++i) |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 560 | ResultOps.push_back(SlotNo+i); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 561 | return; |
| 562 | } |
| 563 | |
Chris Lattner | 57bf8a4 | 2010-03-04 01:23:08 +0000 | [diff] [blame] | 564 | unsigned SlotNo = getNamedArgumentSlot(N->getName()); |
| 565 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 566 | // If this is an 'imm' or 'fpimm' node, make sure to convert it to the target |
| 567 | // version of the immediate so that it doesn't get selected due to some other |
| 568 | // node use. |
| 569 | if (!N->isLeaf()) { |
| 570 | StringRef OperatorName = N->getOperator()->getName(); |
| 571 | if (OperatorName == "imm" || OperatorName == "fpimm") { |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 572 | AddMatcher(new EmitConvertToTargetMatcher(SlotNo)); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 573 | ResultOps.push_back(NextRecordedOperandNo++); |
| 574 | return; |
| 575 | } |
| 576 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 577 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 578 | ResultOps.push_back(SlotNo); |
| 579 | } |
| 580 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 581 | void MatcherGen::EmitResultLeafAsOperand(const TreePatternNode *N, |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 582 | SmallVectorImpl<unsigned> &ResultOps) { |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 583 | assert(N->isLeaf() && "Must be a leaf"); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 584 | |
Sean Silva | 6cfc806 | 2012-10-10 20:24:43 +0000 | [diff] [blame] | 585 | if (IntInit *II = dyn_cast<IntInit>(N->getLeafValue())) { |
Chris Lattner | d734919 | 2010-03-19 21:37:09 +0000 | [diff] [blame] | 586 | AddMatcher(new EmitIntegerMatcher(II->getValue(), N->getType(0))); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 587 | ResultOps.push_back(NextRecordedOperandNo++); |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 588 | return; |
| 589 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 590 | |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 591 | // If this is an explicit register reference, handle it. |
Sean Silva | 6cfc806 | 2012-10-10 20:24:43 +0000 | [diff] [blame] | 592 | if (DefInit *DI = dyn_cast<DefInit>(N->getLeafValue())) { |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 593 | Record *Def = DI->getDef(); |
| 594 | if (Def->isSubClassOf("Register")) { |
Jakob Stoklund Olesen | abdbc84 | 2011-06-18 04:26:06 +0000 | [diff] [blame] | 595 | const CodeGenRegister *Reg = |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 596 | CGP.getTargetInfo().getRegBank().getReg(Def); |
Jakob Stoklund Olesen | abdbc84 | 2011-06-18 04:26:06 +0000 | [diff] [blame] | 597 | AddMatcher(new EmitRegisterMatcher(Reg, N->getType(0))); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 598 | ResultOps.push_back(NextRecordedOperandNo++); |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 599 | return; |
| 600 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 601 | |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 602 | if (Def->getName() == "zero_reg") { |
Chris Lattner | d734919 | 2010-03-19 21:37:09 +0000 | [diff] [blame] | 603 | AddMatcher(new EmitRegisterMatcher(0, N->getType(0))); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 604 | ResultOps.push_back(NextRecordedOperandNo++); |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 605 | return; |
| 606 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 607 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 608 | // Handle a reference to a register class. This is used |
| 609 | // in COPY_TO_SUBREG instructions. |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 610 | if (Def->isSubClassOf("RegisterOperand")) |
| 611 | Def = Def->getValueAsDef("RegClass"); |
| 612 | if (Def->isSubClassOf("RegisterClass")) { |
| 613 | std::string Value = getQualifiedName(Def) + "RegClassID"; |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 614 | AddMatcher(new EmitStringIntegerMatcher(Value, MVT::i32)); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 615 | ResultOps.push_back(NextRecordedOperandNo++); |
| 616 | return; |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 617 | } |
Jakob Stoklund Olesen | 73ea7bf | 2010-05-24 14:48:12 +0000 | [diff] [blame] | 618 | |
| 619 | // Handle a subregister index. This is used for INSERT_SUBREG etc. |
Owen Anderson | bea6f61 | 2011-06-27 21:06:21 +0000 | [diff] [blame] | 620 | if (Def->isSubClassOf("SubRegIndex")) { |
| 621 | std::string Value = getQualifiedName(Def); |
Jakob Stoklund Olesen | 73ea7bf | 2010-05-24 14:48:12 +0000 | [diff] [blame] | 622 | AddMatcher(new EmitStringIntegerMatcher(Value, MVT::i32)); |
| 623 | ResultOps.push_back(NextRecordedOperandNo++); |
| 624 | return; |
| 625 | } |
Chris Lattner | 845c042 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 626 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 627 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 628 | errs() << "unhandled leaf node: \n"; |
| 629 | N->dump(); |
| 630 | } |
| 631 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 632 | /// GetInstPatternNode - Get the pattern for an instruction. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 633 | /// |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 634 | const TreePatternNode *MatcherGen:: |
| 635 | GetInstPatternNode(const DAGInstruction &Inst, const TreePatternNode *N) { |
| 636 | const TreePattern *InstPat = Inst.getPattern(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 637 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 638 | // FIXME2?: Assume actual pattern comes before "implicit". |
| 639 | TreePatternNode *InstPatNode; |
| 640 | if (InstPat) |
| 641 | InstPatNode = InstPat->getTree(0); |
| 642 | else if (/*isRoot*/ N == Pattern.getDstPattern()) |
| 643 | InstPatNode = Pattern.getSrcPattern(); |
| 644 | else |
| 645 | return 0; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 646 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 647 | if (InstPatNode && !InstPatNode->isLeaf() && |
| 648 | InstPatNode->getOperator()->getName() == "set") |
| 649 | InstPatNode = InstPatNode->getChild(InstPatNode->getNumChildren()-1); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 650 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 651 | return InstPatNode; |
| 652 | } |
| 653 | |
Cameron Zwarich | 3a2d255 | 2011-05-19 21:13:30 +0000 | [diff] [blame] | 654 | static bool |
| 655 | mayInstNodeLoadOrStore(const TreePatternNode *N, |
| 656 | const CodeGenDAGPatterns &CGP) { |
| 657 | Record *Op = N->getOperator(); |
| 658 | const CodeGenTarget &CGT = CGP.getTargetInfo(); |
| 659 | CodeGenInstruction &II = CGT.getInstruction(Op); |
| 660 | return II.mayLoad || II.mayStore; |
| 661 | } |
| 662 | |
| 663 | static unsigned |
| 664 | numNodesThatMayLoadOrStore(const TreePatternNode *N, |
| 665 | const CodeGenDAGPatterns &CGP) { |
| 666 | if (N->isLeaf()) |
| 667 | return 0; |
| 668 | |
| 669 | Record *OpRec = N->getOperator(); |
| 670 | if (!OpRec->isSubClassOf("Instruction")) |
| 671 | return 0; |
| 672 | |
| 673 | unsigned Count = 0; |
| 674 | if (mayInstNodeLoadOrStore(N, CGP)) |
| 675 | ++Count; |
| 676 | |
| 677 | for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) |
| 678 | Count += numNodesThatMayLoadOrStore(N->getChild(i), CGP); |
| 679 | |
| 680 | return Count; |
| 681 | } |
| 682 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 683 | void MatcherGen:: |
| 684 | EmitResultInstructionAsOperand(const TreePatternNode *N, |
| 685 | SmallVectorImpl<unsigned> &OutputOps) { |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 686 | Record *Op = N->getOperator(); |
| 687 | const CodeGenTarget &CGT = CGP.getTargetInfo(); |
Chris Lattner | f30187a | 2010-03-19 00:07:20 +0000 | [diff] [blame] | 688 | CodeGenInstruction &II = CGT.getInstruction(Op); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 689 | const DAGInstruction &Inst = CGP.getInstruction(Op); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 690 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 691 | // If we can, get the pattern for the instruction we're generating. We derive |
| 692 | // a variety of information from this pattern, such as whether it has a chain. |
| 693 | // |
| 694 | // FIXME2: This is extremely dubious for several reasons, not the least of |
| 695 | // which it gives special status to instructions with patterns that Pat<> |
| 696 | // nodes can't duplicate. |
| 697 | const TreePatternNode *InstPatNode = GetInstPatternNode(Inst, N); |
| 698 | |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 699 | // NodeHasChain - Whether the instruction node we're creating takes chains. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 700 | bool NodeHasChain = InstPatNode && |
| 701 | InstPatNode->TreeHasProperty(SDNPHasChain, CGP); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 702 | |
Tim Northover | ca578e7 | 2012-06-26 18:46:28 +0000 | [diff] [blame] | 703 | // Instructions which load and store from memory should have a chain, |
| 704 | // regardless of whether they happen to have an internal pattern saying so. |
| 705 | if (Pattern.getSrcPattern()->TreeHasProperty(SDNPHasChain, CGP) |
| 706 | && (II.hasCtrlDep || II.mayLoad || II.mayStore || II.canFoldAsLoad || |
| 707 | II.hasSideEffects)) |
| 708 | NodeHasChain = true; |
| 709 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 710 | bool isRoot = N == Pattern.getDstPattern(); |
| 711 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 712 | // TreeHasOutGlue - True if this tree has glue. |
| 713 | bool TreeHasInGlue = false, TreeHasOutGlue = false; |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 714 | if (isRoot) { |
| 715 | const TreePatternNode *SrcPat = Pattern.getSrcPattern(); |
Chris Lattner | 036609b | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 716 | TreeHasInGlue = SrcPat->TreeHasProperty(SDNPOptInGlue, CGP) || |
| 717 | SrcPat->TreeHasProperty(SDNPInGlue, CGP); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 718 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 719 | // FIXME2: this is checking the entire pattern, not just the node in |
| 720 | // question, doing this just for the root seems like a total hack. |
Chris Lattner | 036609b | 2010-12-23 18:28:41 +0000 | [diff] [blame] | 721 | TreeHasOutGlue = SrcPat->TreeHasProperty(SDNPOutGlue, CGP); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | // NumResults - This is the number of results produced by the instruction in |
| 725 | // the "outs" list. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 726 | unsigned NumResults = Inst.getNumResults(); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 727 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 728 | // Loop over all of the operands of the instruction pattern, emitting code |
| 729 | // to fill them all in. The node 'N' usually has number children equal to |
| 730 | // the number of input operands of the instruction. However, in cases |
| 731 | // where there are predicate operands for an instruction, we need to fill |
| 732 | // in the 'execute always' values. Match up the node operands to the |
| 733 | // instruction operands to do this. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 734 | SmallVector<unsigned, 8> InstOps; |
Chris Lattner | c240bb0 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 735 | for (unsigned ChildNo = 0, InstOpNo = NumResults, e = II.Operands.size(); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 736 | InstOpNo != e; ++InstOpNo) { |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 737 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 738 | // Determine what to emit for this operand. |
Chris Lattner | c240bb0 | 2010-11-01 04:03:32 +0000 | [diff] [blame] | 739 | Record *OperandNode = II.Operands[InstOpNo].Rec; |
Tom Stellard | 6d3d765 | 2012-09-06 14:15:52 +0000 | [diff] [blame] | 740 | if (OperandNode->isSubClassOf("OperandWithDefaultOps") && |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 741 | !CGP.getDefaultOperand(OperandNode).DefaultOps.empty()) { |
| 742 | // This is a predicate or optional def operand; emit the |
| 743 | // 'default ops' operands. |
Eric Christopher | ae321ed | 2010-08-10 23:46:20 +0000 | [diff] [blame] | 744 | const DAGDefaultOperand &DefaultOp |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 745 | = CGP.getDefaultOperand(OperandNode); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 746 | for (unsigned i = 0, e = DefaultOp.DefaultOps.size(); i != e; ++i) |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 747 | EmitResultOperand(DefaultOp.DefaultOps[i], InstOps); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 748 | continue; |
| 749 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 750 | |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 751 | // Otherwise this is a normal operand or a predicate operand without |
| 752 | // 'execute always'; emit it. |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 753 | |
Ulrich Weigand | ec8d1a5 | 2013-03-19 19:51:09 +0000 | [diff] [blame] | 754 | // For operands with multiple sub-operands we may need to emit |
| 755 | // multiple child patterns to cover them all. However, ComplexPattern |
| 756 | // children may themselves emit multiple MI operands. |
| 757 | unsigned NumSubOps = 1; |
| 758 | if (OperandNode->isSubClassOf("Operand")) { |
| 759 | DagInit *MIOpInfo = OperandNode->getValueAsDag("MIOperandInfo"); |
| 760 | if (unsigned NumArgs = MIOpInfo->getNumArgs()) |
| 761 | NumSubOps = NumArgs; |
| 762 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 763 | |
Ulrich Weigand | ec8d1a5 | 2013-03-19 19:51:09 +0000 | [diff] [blame] | 764 | unsigned FinalNumOps = InstOps.size() + NumSubOps; |
| 765 | while (InstOps.size() < FinalNumOps) { |
| 766 | const TreePatternNode *Child = N->getChild(ChildNo); |
| 767 | unsigned BeforeAddingNumOps = InstOps.size(); |
| 768 | EmitResultOperand(Child, InstOps); |
| 769 | assert(InstOps.size() > BeforeAddingNumOps && "Didn't add any operands"); |
| 770 | |
| 771 | // If the operand is an instruction and it produced multiple results, just |
| 772 | // take the first one. |
| 773 | if (!Child->isLeaf() && Child->getOperator()->isSubClassOf("Instruction")) |
| 774 | InstOps.resize(BeforeAddingNumOps+1); |
| 775 | |
| 776 | ++ChildNo; |
| 777 | } |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 778 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 779 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 780 | // If this node has input glue or explicitly specified input physregs, we |
| 781 | // need to add chained and glued copyfromreg nodes and materialize the glue |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 782 | // input. |
| 783 | if (isRoot && !PhysRegInputs.empty()) { |
| 784 | // Emit all of the CopyToReg nodes for the input physical registers. These |
| 785 | // occur in patterns like (mul:i8 AL:i8, GR8:i8:$src). |
| 786 | for (unsigned i = 0, e = PhysRegInputs.size(); i != e; ++i) |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 787 | AddMatcher(new EmitCopyToRegMatcher(PhysRegInputs[i].second, |
Chris Lattner | 9287953 | 2010-03-18 23:57:40 +0000 | [diff] [blame] | 788 | PhysRegInputs[i].first)); |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 789 | // Even if the node has no other glue inputs, the resultant node must be |
| 790 | // glued to the CopyFromReg nodes we just generated. |
| 791 | TreeHasInGlue = true; |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 792 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 793 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 794 | // Result order: node results, chain, glue |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 795 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 796 | // Determine the result types. |
| 797 | SmallVector<MVT::SimpleValueType, 4> ResultVTs; |
Chris Lattner | 0be6fe7 | 2010-03-27 19:15:02 +0000 | [diff] [blame] | 798 | for (unsigned i = 0, e = N->getNumTypes(); i != e; ++i) |
| 799 | ResultVTs.push_back(N->getType(i)); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 800 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 801 | // If this is the root instruction of a pattern that has physical registers in |
| 802 | // its result pattern, add output VTs for them. For example, X86 has: |
| 803 | // (set AL, (mul ...)) |
| 804 | // This also handles implicit results like: |
| 805 | // (implicit EFLAGS) |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 806 | if (isRoot && !Pattern.getDstRegs().empty()) { |
Chris Lattner | 9287953 | 2010-03-18 23:57:40 +0000 | [diff] [blame] | 807 | // If the root came from an implicit def in the instruction handling stuff, |
| 808 | // don't re-add it. |
| 809 | Record *HandledReg = 0; |
Chris Lattner | 9414ae5 | 2010-03-27 20:09:24 +0000 | [diff] [blame] | 810 | if (II.HasOneImplicitDefWithKnownVT(CGT) != MVT::Other) |
Chris Lattner | 9287953 | 2010-03-18 23:57:40 +0000 | [diff] [blame] | 811 | HandledReg = II.ImplicitDefs[0]; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 812 | |
Chris Lattner | 9287953 | 2010-03-18 23:57:40 +0000 | [diff] [blame] | 813 | for (unsigned i = 0; i != Pattern.getDstRegs().size(); ++i) { |
| 814 | Record *Reg = Pattern.getDstRegs()[i]; |
| 815 | if (!Reg->isSubClassOf("Register") || Reg == HandledReg) continue; |
| 816 | ResultVTs.push_back(getRegisterValueType(Reg, CGT)); |
| 817 | } |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 818 | } |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 819 | |
Chris Lattner | 1e50631 | 2010-03-19 05:34:15 +0000 | [diff] [blame] | 820 | // If this is the root of the pattern and the pattern we're matching includes |
| 821 | // a node that is variadic, mark the generated node as variadic so that it |
| 822 | // gets the excess operands from the input DAG. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 823 | int NumFixedArityOperands = -1; |
Chris Lattner | 1e50631 | 2010-03-19 05:34:15 +0000 | [diff] [blame] | 824 | if (isRoot && |
| 825 | (Pattern.getSrcPattern()->NodeHasProperty(SDNPVariadic, CGP))) |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 826 | NumFixedArityOperands = Pattern.getSrcPattern()->getNumChildren(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 827 | |
Cameron Zwarich | 3a2d255 | 2011-05-19 21:13:30 +0000 | [diff] [blame] | 828 | // If this is the root node and multiple matched nodes in the input pattern |
| 829 | // have MemRefs in them, have the interpreter collect them and plop them onto |
| 830 | // this node. If there is just one node with MemRefs, leave them on that node |
| 831 | // even if it is not the root. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 832 | // |
Cameron Zwarich | 3a2d255 | 2011-05-19 21:13:30 +0000 | [diff] [blame] | 833 | // FIXME3: This is actively incorrect for result patterns with multiple |
| 834 | // memory-referencing instructions. |
| 835 | bool PatternHasMemOperands = |
| 836 | Pattern.getSrcPattern()->TreeHasProperty(SDNPMemOperand, CGP); |
| 837 | |
| 838 | bool NodeHasMemRefs = false; |
| 839 | if (PatternHasMemOperands) { |
| 840 | unsigned NumNodesThatLoadOrStore = |
| 841 | numNodesThatMayLoadOrStore(Pattern.getDstPattern(), CGP); |
| 842 | bool NodeIsUniqueLoadOrStore = mayInstNodeLoadOrStore(N, CGP) && |
| 843 | NumNodesThatLoadOrStore == 1; |
| 844 | NodeHasMemRefs = |
| 845 | NodeIsUniqueLoadOrStore || (isRoot && (mayInstNodeLoadOrStore(N, CGP) || |
| 846 | NumNodesThatLoadOrStore != 1)); |
| 847 | } |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 848 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 849 | assert((!ResultVTs.empty() || TreeHasOutGlue || NodeHasChain) && |
Chris Lattner | 0be6fe7 | 2010-03-27 19:15:02 +0000 | [diff] [blame] | 850 | "Node has no result"); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 851 | |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 852 | AddMatcher(new EmitNodeMatcher(II.Namespace+"::"+II.TheDef->getName(), |
Chris Lattner | e86097a | 2010-02-28 02:31:26 +0000 | [diff] [blame] | 853 | ResultVTs.data(), ResultVTs.size(), |
| 854 | InstOps.data(), InstOps.size(), |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 855 | NodeHasChain, TreeHasInGlue, TreeHasOutGlue, |
Chris Lattner | 6281cda | 2010-02-28 02:41:25 +0000 | [diff] [blame] | 856 | NodeHasMemRefs, NumFixedArityOperands, |
| 857 | NextRecordedOperandNo)); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 858 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 859 | // The non-chain and non-glue results of the newly emitted node get recorded. |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 860 | for (unsigned i = 0, e = ResultVTs.size(); i != e; ++i) { |
Chris Lattner | f1b4eaf | 2010-12-21 02:38:05 +0000 | [diff] [blame] | 861 | if (ResultVTs[i] == MVT::Other || ResultVTs[i] == MVT::Glue) break; |
Chris Lattner | 77f2e27 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 862 | OutputOps.push_back(NextRecordedOperandNo++); |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 863 | } |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 864 | } |
| 865 | |
| 866 | void MatcherGen:: |
| 867 | EmitResultSDNodeXFormAsOperand(const TreePatternNode *N, |
| 868 | SmallVectorImpl<unsigned> &ResultOps) { |
| 869 | assert(N->getOperator()->isSubClassOf("SDNodeXForm") && "Not SDNodeXForm?"); |
| 870 | |
| 871 | // Emit the operand. |
| 872 | SmallVector<unsigned, 8> InputOps; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 873 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 874 | // FIXME2: Could easily generalize this to support multiple inputs and outputs |
| 875 | // to the SDNodeXForm. For now we just support one input and one output like |
| 876 | // the old instruction selector. |
| 877 | assert(N->getNumChildren() == 1); |
| 878 | EmitResultOperand(N->getChild(0), InputOps); |
| 879 | |
| 880 | // The input currently must have produced exactly one result. |
| 881 | assert(InputOps.size() == 1 && "Unexpected input to SDNodeXForm"); |
| 882 | |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 883 | AddMatcher(new EmitNodeXFormMatcher(InputOps[0], N->getOperator())); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 884 | ResultOps.push_back(NextRecordedOperandNo++); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 885 | } |
| 886 | |
| 887 | void MatcherGen::EmitResultOperand(const TreePatternNode *N, |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 888 | SmallVectorImpl<unsigned> &ResultOps) { |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 889 | // This is something selected from the pattern we matched. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 890 | if (!N->getName().empty()) |
| 891 | return EmitResultOfNamedOperand(N, ResultOps); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 892 | |
| 893 | if (N->isLeaf()) |
| 894 | return EmitResultLeafAsOperand(N, ResultOps); |
| 895 | |
| 896 | Record *OpRec = N->getOperator(); |
| 897 | if (OpRec->isSubClassOf("Instruction")) |
| 898 | return EmitResultInstructionAsOperand(N, ResultOps); |
| 899 | if (OpRec->isSubClassOf("SDNodeXForm")) |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 900 | return EmitResultSDNodeXFormAsOperand(N, ResultOps); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 901 | errs() << "Unknown result node to emit code for: " << *N << '\n'; |
Joerg Sonnenberger | 61131ab | 2012-10-25 20:33:17 +0000 | [diff] [blame] | 902 | PrintFatalError("Unknown node in result pattern!"); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | void MatcherGen::EmitResultCode() { |
Chris Lattner | 01bcd94 | 2010-03-01 22:46:42 +0000 | [diff] [blame] | 906 | // Patterns that match nodes with (potentially multiple) chain inputs have to |
| 907 | // merge them together into a token factor. This informs the generated code |
| 908 | // what all the chained nodes are. |
| 909 | if (!MatchedChainNodes.empty()) |
| 910 | AddMatcher(new EmitMergeInputChainsMatcher |
| 911 | (MatchedChainNodes.data(), MatchedChainNodes.size())); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 912 | |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 913 | // Codegen the root of the result pattern, capturing the resulting values. |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 914 | SmallVector<unsigned, 8> Ops; |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 915 | EmitResultOperand(Pattern.getDstPattern(), Ops); |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 916 | |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 917 | // At this point, we have however many values the result pattern produces. |
| 918 | // However, the input pattern might not need all of these. If there are |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 919 | // excess values at the end (such as implicit defs of condition codes etc) |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 920 | // just lop them off. This doesn't need to worry about glue or chains, just |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 921 | // explicit results. |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 922 | // |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 923 | unsigned NumSrcResults = Pattern.getSrcPattern()->getNumTypes(); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 924 | |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 925 | // If the pattern also has (implicit) results, count them as well. |
| 926 | if (!Pattern.getDstRegs().empty()) { |
| 927 | // If the root came from an implicit def in the instruction handling stuff, |
| 928 | // don't re-add it. |
| 929 | Record *HandledReg = 0; |
| 930 | const TreePatternNode *DstPat = Pattern.getDstPattern(); |
| 931 | if (!DstPat->isLeaf() &&DstPat->getOperator()->isSubClassOf("Instruction")){ |
| 932 | const CodeGenTarget &CGT = CGP.getTargetInfo(); |
| 933 | CodeGenInstruction &II = CGT.getInstruction(DstPat->getOperator()); |
| 934 | |
| 935 | if (II.HasOneImplicitDefWithKnownVT(CGT) != MVT::Other) |
| 936 | HandledReg = II.ImplicitDefs[0]; |
| 937 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 938 | |
Chris Lattner | b4a52b0 | 2010-03-27 20:45:15 +0000 | [diff] [blame] | 939 | for (unsigned i = 0; i != Pattern.getDstRegs().size(); ++i) { |
| 940 | Record *Reg = Pattern.getDstRegs()[i]; |
| 941 | if (!Reg->isSubClassOf("Register") || Reg == HandledReg) continue; |
| 942 | ++NumSrcResults; |
| 943 | } |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 944 | } |
| 945 | |
Chris Lattner | 565a6f9 | 2010-02-21 23:54:05 +0000 | [diff] [blame] | 946 | assert(Ops.size() >= NumSrcResults && "Didn't provide enough results"); |
| 947 | Ops.resize(NumSrcResults); |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 948 | |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 949 | // If the matched pattern covers nodes which define a glue result, emit a node |
Chris Lattner | 02f7358 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 950 | // that tells the matcher about them so that it can update their results. |
Chris Lattner | 8950bca | 2010-12-23 17:03:20 +0000 | [diff] [blame] | 951 | if (!MatchedGlueResultNodes.empty()) |
| 952 | AddMatcher(new MarkGlueResultsMatcher(MatchedGlueResultNodes.data(), |
| 953 | MatchedGlueResultNodes.size())); |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 954 | |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 955 | AddMatcher(new CompleteMatchMatcher(Ops.data(), Ops.size(), Pattern)); |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 956 | } |
| 957 | |
| 958 | |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 959 | /// ConvertPatternToMatcher - Create the matcher for the specified pattern with |
| 960 | /// the specified variant. If the variant number is invalid, this returns null. |
Chris Lattner | b21ba71 | 2010-02-25 02:04:40 +0000 | [diff] [blame] | 961 | Matcher *llvm::ConvertPatternToMatcher(const PatternToMatch &Pattern, |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 962 | unsigned Variant, |
Chris Lattner | c78f2a3 | 2010-02-28 20:49:53 +0000 | [diff] [blame] | 963 | const CodeGenDAGPatterns &CGP) { |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 964 | MatcherGen Gen(Pattern, CGP); |
| 965 | |
| 966 | // Generate the code for the matcher. |
Chris Lattner | fa342fa | 2010-03-01 07:17:40 +0000 | [diff] [blame] | 967 | if (Gen.EmitMatcherCode(Variant)) |
| 968 | return 0; |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 969 | |
Chris Lattner | 8e946be | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 970 | // FIXME2: Kill extra MoveParent commands at the end of the matcher sequence. |
| 971 | // FIXME2: Split result code out to another table, and make the matcher end |
| 972 | // with an "Emit <index>" command. This allows result generation stuff to be |
| 973 | // shared and factored? |
Jim Grosbach | fbadcd0 | 2010-12-21 16:16:00 +0000 | [diff] [blame] | 974 | |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 975 | // If the match succeeds, then we generate Pattern. |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 976 | Gen.EmitResultCode(); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 977 | |
| 978 | // Unconditional match. |
Chris Lattner | b49985a | 2010-02-18 06:47:49 +0000 | [diff] [blame] | 979 | return Gen.GetMatcher(); |
Chris Lattner | da272d1 | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 980 | } |