Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 1 | //===- DAGISelMatcher.h - 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 | #ifndef TBLGEN_DAGISELMATCHER_H |
| 11 | #define TBLGEN_DAGISELMATCHER_H |
| 12 | |
Chris Lattner | fdbdc8c | 2010-02-16 07:21:10 +0000 | [diff] [blame] | 13 | #include "llvm/CodeGen/ValueTypes.h" |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 14 | #include "llvm/ADT/OwningPtr.h" |
| 15 | #include "llvm/ADT/StringRef.h" |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/SmallVector.h" |
Chris Lattner | fdbdc8c | 2010-02-16 07:21:10 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Casting.h" |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
| 20 | class CodeGenDAGPatterns; |
| 21 | class MatcherNode; |
| 22 | class PatternToMatch; |
| 23 | class raw_ostream; |
| 24 | class ComplexPattern; |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 25 | class Record; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 26 | |
| 27 | MatcherNode *ConvertPatternToMatcher(const PatternToMatch &Pattern, |
| 28 | const CodeGenDAGPatterns &CGP); |
Chris Lattner | 3ee1bc4 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 29 | MatcherNode *OptimizeMatcher(MatcherNode *Matcher); |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 30 | void EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &OS); |
| 31 | |
| 32 | |
| 33 | /// MatcherNode - Base class for all the the DAG ISel Matcher representation |
| 34 | /// nodes. |
| 35 | class MatcherNode { |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 36 | // The next matcher node that is executed after this one. Null if this is the |
| 37 | // last stage of a match. |
| 38 | OwningPtr<MatcherNode> Next; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 39 | public: |
| 40 | enum KindTy { |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 41 | // Matcher state manipulation. |
| 42 | Push, // Push a checking scope. |
| 43 | RecordNode, // Record the current node. |
Chris Lattner | 3ee1bc4 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 44 | RecordChild, // Record a child of the current node. |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 45 | RecordMemRef, // Record the memref in the current node. |
| 46 | CaptureFlagInput, // If the current node has an input flag, save it. |
| 47 | MoveChild, // Move current node to specified child. |
| 48 | MoveParent, // Move current node to parent. |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 49 | |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 50 | // Predicate checking. |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 51 | CheckSame, // Fail if not same as prev match. |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 52 | CheckPatternPredicate, |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 53 | CheckPredicate, // Fail if node predicate fails. |
| 54 | CheckOpcode, // Fail if not opcode. |
Chris Lattner | f58c08e | 2010-02-22 22:30:37 +0000 | [diff] [blame] | 55 | CheckMultiOpcode, // Fail if not in opcode list. |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 56 | CheckType, // Fail if not correct type. |
| 57 | CheckInteger, // Fail if wrong val. |
| 58 | CheckCondCode, // Fail if not condcode. |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 59 | CheckValueType, |
| 60 | CheckComplexPat, |
| 61 | CheckAndImm, |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 62 | CheckOrImm, |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 63 | CheckFoldableChainNode, |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 64 | CheckChainCompatible, |
| 65 | |
| 66 | // Node creation/emisssion. |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 67 | EmitInteger, // Create a TargetConstant |
| 68 | EmitStringInteger, // Create a TargetConstant from a string. |
| 69 | EmitRegister, // Create a register. |
| 70 | EmitConvertToTarget, // Convert a imm/fpimm to target imm/fpimm |
| 71 | EmitMergeInputChains, // Merge together a chains for an input. |
| 72 | EmitCopyToReg, // Emit a copytoreg into a physreg. |
| 73 | EmitNode, // Create a DAG node |
| 74 | EmitNodeXForm, // Run a SDNodeXForm |
Chris Lattner | 69f60c8 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 75 | MarkFlagResults, // Indicate which interior nodes have flag results. |
Chris Lattner | b085ea1 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 76 | CompleteMatch // Finish a match and update the results. |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 77 | }; |
| 78 | const KindTy Kind; |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 79 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 80 | protected: |
| 81 | MatcherNode(KindTy K) : Kind(K) {} |
| 82 | public: |
| 83 | virtual ~MatcherNode() {} |
| 84 | |
| 85 | KindTy getKind() const { return Kind; } |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 86 | |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 87 | MatcherNode *getNext() { return Next.get(); } |
| 88 | const MatcherNode *getNext() const { return Next.get(); } |
| 89 | void setNext(MatcherNode *C) { Next.reset(C); } |
Chris Lattner | 3ee1bc4 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 90 | MatcherNode *takeNext() { return Next.take(); } |
| 91 | |
| 92 | OwningPtr<MatcherNode> &getNextPtr() { return Next; } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 93 | |
| 94 | static inline bool classof(const MatcherNode *) { return true; } |
| 95 | |
| 96 | virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; |
| 97 | void dump() const; |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 98 | protected: |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 99 | void printNext(raw_ostream &OS, unsigned indent) const; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 100 | }; |
| 101 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 102 | /// PushMatcherNode - This pushes a failure scope on the stack and evaluates |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 103 | /// 'Next'. If 'Next' fails to match, it pops its scope and attempts to |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 104 | /// match 'Failure'. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 105 | class PushMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 106 | OwningPtr<MatcherNode> Failure; |
| 107 | public: |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 108 | PushMatcherNode(MatcherNode *next = 0, MatcherNode *failure = 0) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 109 | : MatcherNode(Push), Failure(failure) { |
Chris Lattner | 78039ec | 2010-02-18 02:53:41 +0000 | [diff] [blame] | 110 | setNext(next); |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | MatcherNode *getFailure() { return Failure.get(); } |
| 114 | const MatcherNode *getFailure() const { return Failure.get(); } |
| 115 | void setFailure(MatcherNode *N) { Failure.reset(N); } |
Chris Lattner | 3ee1bc4 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 116 | OwningPtr<MatcherNode> &getFailurePtr() { return Failure; } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 117 | |
| 118 | static inline bool classof(const MatcherNode *N) { |
| 119 | return N->getKind() == Push; |
| 120 | } |
| 121 | |
| 122 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 123 | }; |
| 124 | |
| 125 | /// RecordMatcherNode - Save the current node in the operand list. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 126 | class RecordMatcherNode : public MatcherNode { |
Chris Lattner | 56cf88d | 2010-02-17 01:03:09 +0000 | [diff] [blame] | 127 | /// WhatFor - This is a string indicating why we're recording this. This |
| 128 | /// should only be used for comment generation not anything semantic. |
| 129 | std::string WhatFor; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 130 | public: |
Chris Lattner | 086ca52 | 2010-02-17 01:27:29 +0000 | [diff] [blame] | 131 | RecordMatcherNode(const std::string &whatfor) |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 132 | : MatcherNode(RecordNode), WhatFor(whatfor) {} |
Chris Lattner | 56cf88d | 2010-02-17 01:03:09 +0000 | [diff] [blame] | 133 | |
Chris Lattner | 086ca52 | 2010-02-17 01:27:29 +0000 | [diff] [blame] | 134 | const std::string &getWhatFor() const { return WhatFor; } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 135 | |
| 136 | static inline bool classof(const MatcherNode *N) { |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 137 | return N->getKind() == RecordNode; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 141 | }; |
| 142 | |
Chris Lattner | 3ee1bc4 | 2010-02-24 07:31:45 +0000 | [diff] [blame] | 143 | /// RecordChildMatcherNode - Save a numbered child of the current node, or fail |
| 144 | /// the match if it doesn't exist. This is logically equivalent to: |
| 145 | /// MoveChild N + RecordNode + MoveParent. |
| 146 | class RecordChildMatcherNode : public MatcherNode { |
| 147 | unsigned ChildNo; |
| 148 | |
| 149 | /// WhatFor - This is a string indicating why we're recording this. This |
| 150 | /// should only be used for comment generation not anything semantic. |
| 151 | std::string WhatFor; |
| 152 | public: |
| 153 | RecordChildMatcherNode(unsigned childno, const std::string &whatfor) |
| 154 | : MatcherNode(RecordChild), ChildNo(childno), WhatFor(whatfor) {} |
| 155 | |
| 156 | unsigned getChildNo() const { return ChildNo; } |
| 157 | const std::string &getWhatFor() const { return WhatFor; } |
| 158 | |
| 159 | static inline bool classof(const MatcherNode *N) { |
| 160 | return N->getKind() == RecordChild; |
| 161 | } |
| 162 | |
| 163 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 164 | }; |
| 165 | |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 166 | /// RecordMemRefMatcherNode - Save the current node's memref. |
| 167 | class RecordMemRefMatcherNode : public MatcherNode { |
| 168 | public: |
| 169 | RecordMemRefMatcherNode() : MatcherNode(RecordMemRef) {} |
| 170 | |
| 171 | static inline bool classof(const MatcherNode *N) { |
| 172 | return N->getKind() == RecordMemRef; |
| 173 | } |
| 174 | |
| 175 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 176 | }; |
| 177 | |
| 178 | |
| 179 | /// CaptureFlagInputMatcherNode - If the current record has a flag input, record |
| 180 | /// it so that it is used as an input to the generated code. |
| 181 | class CaptureFlagInputMatcherNode : public MatcherNode { |
| 182 | public: |
| 183 | CaptureFlagInputMatcherNode() |
| 184 | : MatcherNode(CaptureFlagInput) {} |
| 185 | |
| 186 | static inline bool classof(const MatcherNode *N) { |
| 187 | return N->getKind() == CaptureFlagInput; |
| 188 | } |
| 189 | |
| 190 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 191 | }; |
| 192 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 193 | /// MoveChildMatcherNode - This tells the interpreter to move into the |
| 194 | /// specified child node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 195 | class MoveChildMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 196 | unsigned ChildNo; |
| 197 | public: |
| 198 | MoveChildMatcherNode(unsigned childNo) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 199 | : MatcherNode(MoveChild), ChildNo(childNo) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 200 | |
| 201 | unsigned getChildNo() const { return ChildNo; } |
| 202 | |
| 203 | static inline bool classof(const MatcherNode *N) { |
| 204 | return N->getKind() == MoveChild; |
| 205 | } |
| 206 | |
| 207 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 208 | }; |
| 209 | |
| 210 | /// MoveParentMatcherNode - This tells the interpreter to move to the parent |
| 211 | /// of the current node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 212 | class MoveParentMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 213 | public: |
| 214 | MoveParentMatcherNode() |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 215 | : MatcherNode(MoveParent) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 216 | |
| 217 | static inline bool classof(const MatcherNode *N) { |
| 218 | return N->getKind() == MoveParent; |
| 219 | } |
| 220 | |
| 221 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 222 | }; |
| 223 | |
| 224 | /// CheckSameMatcherNode - This checks to see if this node is exactly the same |
| 225 | /// node as the specified match that was recorded with 'Record'. This is used |
| 226 | /// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 227 | class CheckSameMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 228 | unsigned MatchNumber; |
| 229 | public: |
| 230 | CheckSameMatcherNode(unsigned matchnumber) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 231 | : MatcherNode(CheckSame), MatchNumber(matchnumber) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 232 | |
| 233 | unsigned getMatchNumber() const { return MatchNumber; } |
| 234 | |
| 235 | static inline bool classof(const MatcherNode *N) { |
| 236 | return N->getKind() == CheckSame; |
| 237 | } |
| 238 | |
| 239 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 240 | }; |
| 241 | |
| 242 | /// CheckPatternPredicateMatcherNode - This checks the target-specific predicate |
| 243 | /// to see if the entire pattern is capable of matching. This predicate does |
| 244 | /// not take a node as input. This is used for subtarget feature checks etc. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 245 | class CheckPatternPredicateMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 246 | std::string Predicate; |
| 247 | public: |
| 248 | CheckPatternPredicateMatcherNode(StringRef predicate) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 249 | : MatcherNode(CheckPatternPredicate), Predicate(predicate) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 250 | |
| 251 | StringRef getPredicate() const { return Predicate; } |
| 252 | |
| 253 | static inline bool classof(const MatcherNode *N) { |
| 254 | return N->getKind() == CheckPatternPredicate; |
| 255 | } |
| 256 | |
| 257 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 258 | }; |
| 259 | |
| 260 | /// CheckPredicateMatcherNode - This checks the target-specific predicate to |
| 261 | /// see if the node is acceptable. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 262 | class CheckPredicateMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 263 | StringRef PredName; |
| 264 | public: |
| 265 | CheckPredicateMatcherNode(StringRef predname) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 266 | : MatcherNode(CheckPredicate), PredName(predname) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 267 | |
| 268 | StringRef getPredicateName() const { return PredName; } |
| 269 | |
| 270 | static inline bool classof(const MatcherNode *N) { |
| 271 | return N->getKind() == CheckPredicate; |
| 272 | } |
| 273 | |
| 274 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 275 | }; |
| 276 | |
| 277 | |
| 278 | /// CheckOpcodeMatcherNode - This checks to see if the current node has the |
| 279 | /// specified opcode, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 280 | class CheckOpcodeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 281 | StringRef OpcodeName; |
| 282 | public: |
| 283 | CheckOpcodeMatcherNode(StringRef opcodename) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 284 | : MatcherNode(CheckOpcode), OpcodeName(opcodename) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 285 | |
| 286 | StringRef getOpcodeName() const { return OpcodeName; } |
| 287 | |
| 288 | static inline bool classof(const MatcherNode *N) { |
| 289 | return N->getKind() == CheckOpcode; |
| 290 | } |
| 291 | |
| 292 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 293 | }; |
| 294 | |
Chris Lattner | f58c08e | 2010-02-22 22:30:37 +0000 | [diff] [blame] | 295 | /// CheckMultiOpcodeMatcherNode - This checks to see if the current node has one |
| 296 | /// of the specified opcode, if not it fails to match. |
| 297 | class CheckMultiOpcodeMatcherNode : public MatcherNode { |
| 298 | SmallVector<StringRef, 4> OpcodeNames; |
| 299 | public: |
| 300 | CheckMultiOpcodeMatcherNode(const StringRef *opcodes, unsigned numops) |
| 301 | : MatcherNode(CheckMultiOpcode), OpcodeNames(opcodes, opcodes+numops) {} |
| 302 | |
| 303 | unsigned getNumOpcodeNames() const { return OpcodeNames.size(); } |
| 304 | StringRef getOpcodeName(unsigned i) const { return OpcodeNames[i]; } |
| 305 | |
| 306 | static inline bool classof(const MatcherNode *N) { |
| 307 | return N->getKind() == CheckMultiOpcode; |
| 308 | } |
| 309 | |
| 310 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 311 | }; |
| 312 | |
| 313 | |
| 314 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 315 | /// CheckTypeMatcherNode - This checks to see if the current node has the |
| 316 | /// specified type, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 317 | class CheckTypeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 318 | MVT::SimpleValueType Type; |
| 319 | public: |
| 320 | CheckTypeMatcherNode(MVT::SimpleValueType type) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 321 | : MatcherNode(CheckType), Type(type) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 322 | |
| 323 | MVT::SimpleValueType getType() const { return Type; } |
| 324 | |
| 325 | static inline bool classof(const MatcherNode *N) { |
| 326 | return N->getKind() == CheckType; |
| 327 | } |
| 328 | |
| 329 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 330 | }; |
| 331 | |
| 332 | /// CheckIntegerMatcherNode - This checks to see if the current node is a |
| 333 | /// ConstantSDNode with the specified integer value, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 334 | class CheckIntegerMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 335 | int64_t Value; |
| 336 | public: |
| 337 | CheckIntegerMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 338 | : MatcherNode(CheckInteger), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 339 | |
| 340 | int64_t getValue() const { return Value; } |
| 341 | |
| 342 | static inline bool classof(const MatcherNode *N) { |
| 343 | return N->getKind() == CheckInteger; |
| 344 | } |
| 345 | |
| 346 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 347 | }; |
| 348 | |
| 349 | /// CheckCondCodeMatcherNode - This checks to see if the current node is a |
| 350 | /// CondCodeSDNode with the specified condition, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 351 | class CheckCondCodeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 352 | StringRef CondCodeName; |
| 353 | public: |
| 354 | CheckCondCodeMatcherNode(StringRef condcodename) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 355 | : MatcherNode(CheckCondCode), CondCodeName(condcodename) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 356 | |
| 357 | StringRef getCondCodeName() const { return CondCodeName; } |
| 358 | |
| 359 | static inline bool classof(const MatcherNode *N) { |
| 360 | return N->getKind() == CheckCondCode; |
| 361 | } |
| 362 | |
| 363 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 364 | }; |
| 365 | |
| 366 | /// CheckValueTypeMatcherNode - This checks to see if the current node is a |
| 367 | /// VTSDNode with the specified type, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 368 | class CheckValueTypeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 369 | StringRef TypeName; |
| 370 | public: |
| 371 | CheckValueTypeMatcherNode(StringRef type_name) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 372 | : MatcherNode(CheckValueType), TypeName(type_name) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 373 | |
| 374 | StringRef getTypeName() const { return TypeName; } |
| 375 | |
| 376 | static inline bool classof(const MatcherNode *N) { |
| 377 | return N->getKind() == CheckValueType; |
| 378 | } |
| 379 | |
| 380 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 381 | }; |
| 382 | |
| 383 | |
| 384 | |
| 385 | /// CheckComplexPatMatcherNode - This node runs the specified ComplexPattern on |
| 386 | /// the current node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 387 | class CheckComplexPatMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 388 | const ComplexPattern &Pattern; |
| 389 | public: |
| 390 | CheckComplexPatMatcherNode(const ComplexPattern &pattern) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 391 | : MatcherNode(CheckComplexPat), Pattern(pattern) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 392 | |
Chris Lattner | dc429fd | 2010-02-17 00:31:50 +0000 | [diff] [blame] | 393 | const ComplexPattern &getPattern() const { return Pattern; } |
| 394 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 395 | static inline bool classof(const MatcherNode *N) { |
| 396 | return N->getKind() == CheckComplexPat; |
| 397 | } |
| 398 | |
| 399 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 400 | }; |
| 401 | |
| 402 | /// CheckAndImmMatcherNode - This checks to see if the current node is an 'and' |
| 403 | /// with something equivalent to the specified immediate. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 404 | class CheckAndImmMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 405 | int64_t Value; |
| 406 | public: |
| 407 | CheckAndImmMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 408 | : MatcherNode(CheckAndImm), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 409 | |
| 410 | int64_t getValue() const { return Value; } |
| 411 | |
| 412 | static inline bool classof(const MatcherNode *N) { |
| 413 | return N->getKind() == CheckAndImm; |
| 414 | } |
| 415 | |
| 416 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 417 | }; |
| 418 | |
| 419 | /// CheckOrImmMatcherNode - This checks to see if the current node is an 'and' |
| 420 | /// with something equivalent to the specified immediate. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 421 | class CheckOrImmMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 422 | int64_t Value; |
| 423 | public: |
| 424 | CheckOrImmMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 425 | : MatcherNode(CheckOrImm), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 426 | |
| 427 | int64_t getValue() const { return Value; } |
| 428 | |
| 429 | static inline bool classof(const MatcherNode *N) { |
| 430 | return N->getKind() == CheckOrImm; |
| 431 | } |
| 432 | |
| 433 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 434 | }; |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 435 | |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 436 | /// CheckFoldableChainNodeMatcherNode - This checks to see if the current node |
| 437 | /// (which defines a chain operand) is safe to fold into a larger pattern. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 438 | class CheckFoldableChainNodeMatcherNode : public MatcherNode { |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 439 | public: |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 440 | CheckFoldableChainNodeMatcherNode() |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 441 | : MatcherNode(CheckFoldableChainNode) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 442 | |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 443 | static inline bool classof(const MatcherNode *N) { |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 444 | return N->getKind() == CheckFoldableChainNode; |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 445 | } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 446 | |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 447 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 448 | }; |
| 449 | |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 450 | /// CheckChainCompatibleMatcherNode - Verify that the current node's chain |
| 451 | /// operand is 'compatible' with the specified recorded node's. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 452 | class CheckChainCompatibleMatcherNode : public MatcherNode { |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 453 | unsigned PreviousOp; |
| 454 | public: |
| 455 | CheckChainCompatibleMatcherNode(unsigned previousop) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame] | 456 | : MatcherNode(CheckChainCompatible), PreviousOp(previousop) {} |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 457 | |
| 458 | unsigned getPreviousOp() const { return PreviousOp; } |
| 459 | |
| 460 | static inline bool classof(const MatcherNode *N) { |
| 461 | return N->getKind() == CheckChainCompatible; |
| 462 | } |
| 463 | |
| 464 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 465 | }; |
| 466 | |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 467 | /// EmitIntegerMatcherNode - This creates a new TargetConstant. |
| 468 | class EmitIntegerMatcherNode : public MatcherNode { |
| 469 | int64_t Val; |
| 470 | MVT::SimpleValueType VT; |
| 471 | public: |
| 472 | EmitIntegerMatcherNode(int64_t val, MVT::SimpleValueType vt) |
| 473 | : MatcherNode(EmitInteger), Val(val), VT(vt) {} |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 474 | |
Chris Lattner | 7043e0a | 2010-02-19 07:49:56 +0000 | [diff] [blame] | 475 | int64_t getValue() const { return Val; } |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 476 | MVT::SimpleValueType getVT() const { return VT; } |
| 477 | |
| 478 | static inline bool classof(const MatcherNode *N) { |
| 479 | return N->getKind() == EmitInteger; |
| 480 | } |
| 481 | |
| 482 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 483 | }; |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 484 | |
| 485 | /// EmitStringIntegerMatcherNode - A target constant whose value is represented |
| 486 | /// by a string. |
| 487 | class EmitStringIntegerMatcherNode : public MatcherNode { |
| 488 | std::string Val; |
| 489 | MVT::SimpleValueType VT; |
| 490 | public: |
| 491 | EmitStringIntegerMatcherNode(const std::string &val, MVT::SimpleValueType vt) |
| 492 | : MatcherNode(EmitStringInteger), Val(val), VT(vt) {} |
| 493 | |
| 494 | const std::string &getValue() const { return Val; } |
| 495 | MVT::SimpleValueType getVT() const { return VT; } |
| 496 | |
| 497 | static inline bool classof(const MatcherNode *N) { |
| 498 | return N->getKind() == EmitStringInteger; |
| 499 | } |
| 500 | |
| 501 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 502 | }; |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 503 | |
| 504 | /// EmitRegisterMatcherNode - This creates a new TargetConstant. |
| 505 | class EmitRegisterMatcherNode : public MatcherNode { |
| 506 | /// Reg - The def for the register that we're emitting. If this is null, then |
| 507 | /// this is a reference to zero_reg. |
| 508 | Record *Reg; |
| 509 | MVT::SimpleValueType VT; |
| 510 | public: |
| 511 | EmitRegisterMatcherNode(Record *reg, MVT::SimpleValueType vt) |
| 512 | : MatcherNode(EmitRegister), Reg(reg), VT(vt) {} |
| 513 | |
| 514 | Record *getReg() const { return Reg; } |
| 515 | MVT::SimpleValueType getVT() const { return VT; } |
| 516 | |
| 517 | static inline bool classof(const MatcherNode *N) { |
| 518 | return N->getKind() == EmitRegister; |
| 519 | } |
| 520 | |
| 521 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 522 | }; |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 523 | |
| 524 | /// EmitConvertToTargetMatcherNode - Emit an operation that reads a specified |
| 525 | /// recorded node and converts it from being a ISD::Constant to |
| 526 | /// ISD::TargetConstant, likewise for ConstantFP. |
| 527 | class EmitConvertToTargetMatcherNode : public MatcherNode { |
| 528 | unsigned Slot; |
| 529 | public: |
| 530 | EmitConvertToTargetMatcherNode(unsigned slot) |
| 531 | : MatcherNode(EmitConvertToTarget), Slot(slot) {} |
| 532 | |
| 533 | unsigned getSlot() const { return Slot; } |
| 534 | |
| 535 | static inline bool classof(const MatcherNode *N) { |
| 536 | return N->getKind() == EmitConvertToTarget; |
| 537 | } |
| 538 | |
| 539 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 540 | }; |
| 541 | |
| 542 | /// EmitMergeInputChainsMatcherNode - Emit a node that merges a list of input |
| 543 | /// chains together with a token factor. The list of nodes are the nodes in the |
| 544 | /// matched pattern that have chain input/outputs. This node adds all input |
| 545 | /// chains of these nodes if they are not themselves a node in the pattern. |
| 546 | class EmitMergeInputChainsMatcherNode : public MatcherNode { |
| 547 | SmallVector<unsigned, 3> ChainNodes; |
| 548 | public: |
| 549 | EmitMergeInputChainsMatcherNode(const unsigned *nodes, unsigned NumNodes) |
| 550 | : MatcherNode(EmitMergeInputChains), ChainNodes(nodes, nodes+NumNodes) {} |
| 551 | |
| 552 | unsigned getNumNodes() const { return ChainNodes.size(); } |
| 553 | |
| 554 | unsigned getNode(unsigned i) const { |
| 555 | assert(i < ChainNodes.size()); |
| 556 | return ChainNodes[i]; |
| 557 | } |
| 558 | |
| 559 | static inline bool classof(const MatcherNode *N) { |
| 560 | return N->getKind() == EmitMergeInputChains; |
| 561 | } |
| 562 | |
| 563 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 564 | }; |
| 565 | |
| 566 | /// EmitCopyToRegMatcherNode - Emit a CopyToReg node from a value to a physreg, |
| 567 | /// pushing the chain and flag results. |
| 568 | /// |
| 569 | class EmitCopyToRegMatcherNode : public MatcherNode { |
| 570 | unsigned SrcSlot; // Value to copy into the physreg. |
| 571 | Record *DestPhysReg; |
| 572 | public: |
| 573 | EmitCopyToRegMatcherNode(unsigned srcSlot, Record *destPhysReg) |
| 574 | : MatcherNode(EmitCopyToReg), SrcSlot(srcSlot), DestPhysReg(destPhysReg) {} |
| 575 | |
| 576 | unsigned getSrcSlot() const { return SrcSlot; } |
| 577 | Record *getDestPhysReg() const { return DestPhysReg; } |
| 578 | |
| 579 | static inline bool classof(const MatcherNode *N) { |
| 580 | return N->getKind() == EmitCopyToReg; |
| 581 | } |
| 582 | |
| 583 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 584 | }; |
| 585 | |
| 586 | |
| 587 | |
| 588 | /// EmitNodeXFormMatcherNode - Emit an operation that runs an SDNodeXForm on a |
| 589 | /// recorded node and records the result. |
| 590 | class EmitNodeXFormMatcherNode : public MatcherNode { |
| 591 | unsigned Slot; |
| 592 | Record *NodeXForm; |
| 593 | public: |
| 594 | EmitNodeXFormMatcherNode(unsigned slot, Record *nodeXForm) |
| 595 | : MatcherNode(EmitNodeXForm), Slot(slot), NodeXForm(nodeXForm) {} |
| 596 | |
| 597 | unsigned getSlot() const { return Slot; } |
| 598 | Record *getNodeXForm() const { return NodeXForm; } |
| 599 | |
| 600 | static inline bool classof(const MatcherNode *N) { |
| 601 | return N->getKind() == EmitNodeXForm; |
| 602 | } |
| 603 | |
| 604 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 605 | }; |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 606 | |
| 607 | /// EmitNodeMatcherNode - This signals a successful match and generates a node. |
| 608 | class EmitNodeMatcherNode : public MatcherNode { |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 609 | std::string OpcodeName; |
| 610 | const SmallVector<MVT::SimpleValueType, 3> VTs; |
| 611 | const SmallVector<unsigned, 6> Operands; |
| 612 | bool HasChain, HasFlag, HasMemRefs; |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 613 | |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 614 | /// NumFixedArityOperands - If this is a fixed arity node, this is set to -1. |
| 615 | /// If this is a varidic node, this is set to the number of fixed arity |
| 616 | /// operands in the root of the pattern. The rest are appended to this node. |
| 617 | int NumFixedArityOperands; |
| 618 | public: |
| 619 | EmitNodeMatcherNode(const std::string &opcodeName, |
| 620 | const MVT::SimpleValueType *vts, unsigned numvts, |
| 621 | const unsigned *operands, unsigned numops, |
| 622 | bool hasChain, bool hasFlag, bool hasmemrefs, |
| 623 | int numfixedarityoperands) |
| 624 | : MatcherNode(EmitNode), OpcodeName(opcodeName), |
| 625 | VTs(vts, vts+numvts), Operands(operands, operands+numops), |
| 626 | HasChain(hasChain), HasFlag(hasFlag), HasMemRefs(hasmemrefs), |
| 627 | NumFixedArityOperands(numfixedarityoperands) {} |
| 628 | |
| 629 | const std::string &getOpcodeName() const { return OpcodeName; } |
| 630 | |
| 631 | unsigned getNumVTs() const { return VTs.size(); } |
| 632 | MVT::SimpleValueType getVT(unsigned i) const { |
| 633 | assert(i < VTs.size()); |
| 634 | return VTs[i]; |
| 635 | } |
| 636 | |
| 637 | unsigned getNumOperands() const { return Operands.size(); } |
| 638 | unsigned getOperand(unsigned i) const { |
| 639 | assert(i < Operands.size()); |
| 640 | return Operands[i]; |
| 641 | } |
| 642 | |
| 643 | bool hasChain() const { return HasChain; } |
| 644 | bool hasFlag() const { return HasFlag; } |
| 645 | bool hasMemRefs() const { return HasMemRefs; } |
| 646 | int getNumFixedArityOperands() const { return NumFixedArityOperands; } |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 647 | |
| 648 | static inline bool classof(const MatcherNode *N) { |
| 649 | return N->getKind() == EmitNode; |
| 650 | } |
| 651 | |
| 652 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 653 | }; |
Chris Lattner | b085ea1 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 654 | |
Chris Lattner | 69f60c8 | 2010-02-24 05:33:42 +0000 | [diff] [blame] | 655 | /// MarkFlagResultsMatcherNode - This node indicates which non-root nodes in the |
| 656 | /// pattern produce flags. This allows CompleteMatchMatcherNode to update them |
| 657 | /// with the output flag of the resultant code. |
| 658 | class MarkFlagResultsMatcherNode : public MatcherNode { |
| 659 | SmallVector<unsigned, 3> FlagResultNodes; |
| 660 | public: |
| 661 | MarkFlagResultsMatcherNode(const unsigned *nodes, unsigned NumNodes) |
| 662 | : MatcherNode(MarkFlagResults), FlagResultNodes(nodes, nodes+NumNodes) {} |
| 663 | |
| 664 | unsigned getNumNodes() const { return FlagResultNodes.size(); } |
| 665 | |
| 666 | unsigned getNode(unsigned i) const { |
| 667 | assert(i < FlagResultNodes.size()); |
| 668 | return FlagResultNodes[i]; |
| 669 | } |
| 670 | |
| 671 | static inline bool classof(const MatcherNode *N) { |
| 672 | return N->getKind() == MarkFlagResults; |
| 673 | } |
| 674 | |
| 675 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 676 | }; |
| 677 | |
Chris Lattner | b085ea1 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 678 | /// CompleteMatchMatcherNode - Complete a match by replacing the results of the |
| 679 | /// pattern with the newly generated nodes. This also prints a comment |
| 680 | /// indicating the source and dest patterns. |
| 681 | class CompleteMatchMatcherNode : public MatcherNode { |
| 682 | SmallVector<unsigned, 2> Results; |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 683 | const PatternToMatch &Pattern; |
| 684 | public: |
Chris Lattner | b085ea1 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 685 | CompleteMatchMatcherNode(const unsigned *results, unsigned numresults, |
| 686 | const PatternToMatch &pattern) |
| 687 | : MatcherNode(CompleteMatch), Results(results, results+numresults), |
| 688 | Pattern(pattern) {} |
| 689 | |
| 690 | unsigned getNumResults() const { return Results.size(); } |
| 691 | unsigned getResult(unsigned R) const { return Results[R]; } |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 692 | const PatternToMatch &getPattern() const { return Pattern; } |
| 693 | |
| 694 | static inline bool classof(const MatcherNode *N) { |
Chris Lattner | b085ea1 | 2010-02-21 06:03:07 +0000 | [diff] [blame] | 695 | return N->getKind() == CompleteMatch; |
Chris Lattner | 3163ca5 | 2010-02-21 03:22:59 +0000 | [diff] [blame] | 696 | } |
| 697 | |
| 698 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 699 | }; |
| 700 | |
Chris Lattner | ddfb522 | 2010-02-18 22:03:03 +0000 | [diff] [blame] | 701 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 702 | } // end namespace llvm |
| 703 | |
| 704 | #endif |