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 | fdbdc8c | 2010-02-16 07:21:10 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Casting.h" |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
| 19 | class CodeGenDAGPatterns; |
| 20 | class MatcherNode; |
| 21 | class PatternToMatch; |
| 22 | class raw_ostream; |
| 23 | class ComplexPattern; |
| 24 | |
| 25 | MatcherNode *ConvertPatternToMatcher(const PatternToMatch &Pattern, |
| 26 | const CodeGenDAGPatterns &CGP); |
| 27 | |
| 28 | void EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &OS); |
| 29 | |
| 30 | |
| 31 | /// MatcherNode - Base class for all the the DAG ISel Matcher representation |
| 32 | /// nodes. |
| 33 | class MatcherNode { |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 34 | OwningPtr<MatcherNode> Child; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 35 | public: |
| 36 | enum KindTy { |
| 37 | EmitNode, |
| 38 | Push, // [Push, Dest0, Dest1, Dest2, Dest3] |
| 39 | Record, // [Record] |
| 40 | MoveChild, // [MoveChild, Child#] |
| 41 | MoveParent, // [MoveParent] |
| 42 | |
| 43 | CheckSame, // [CheckSame, N] Fail if not same as prev match. |
| 44 | CheckPatternPredicate, |
| 45 | CheckPredicate, // [CheckPredicate, P] Fail if predicate fails. |
| 46 | CheckOpcode, // [CheckOpcode, Opcode] Fail if not opcode. |
| 47 | CheckType, // [CheckType, MVT] Fail if not correct type. |
| 48 | CheckInteger, // [CheckInteger, int0,int1,int2,...int7] Fail if wrong val. |
| 49 | CheckCondCode, // [CheckCondCode, CondCode] Fail if not condcode. |
| 50 | CheckValueType, |
| 51 | CheckComplexPat, |
| 52 | CheckAndImm, |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 53 | CheckOrImm, |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 54 | CheckFoldableChainNode, |
| 55 | CheckChainCompatible |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 56 | }; |
| 57 | const KindTy Kind; |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 58 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 59 | protected: |
| 60 | MatcherNode(KindTy K) : Kind(K) {} |
| 61 | public: |
| 62 | virtual ~MatcherNode() {} |
| 63 | |
| 64 | KindTy getKind() const { return Kind; } |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 65 | |
| 66 | MatcherNode *getChild() { return Child.get(); } |
| 67 | const MatcherNode *getChild() const { return Child.get(); } |
| 68 | void setChild(MatcherNode *C) { Child.reset(C); } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 69 | |
| 70 | static inline bool classof(const MatcherNode *) { return true; } |
| 71 | |
| 72 | virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0; |
| 73 | void dump() const; |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 74 | protected: |
| 75 | void printChild(raw_ostream &OS, unsigned indent) const; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 76 | }; |
| 77 | |
| 78 | /// EmitNodeMatcherNode - This signals a successful match and generates a node. |
| 79 | class EmitNodeMatcherNode : public MatcherNode { |
| 80 | const PatternToMatch &Pattern; |
| 81 | public: |
| 82 | EmitNodeMatcherNode(const PatternToMatch &pattern) |
| 83 | : MatcherNode(EmitNode), Pattern(pattern) {} |
| 84 | |
| 85 | const PatternToMatch &getPattern() const { return Pattern; } |
| 86 | |
| 87 | static inline bool classof(const MatcherNode *N) { |
| 88 | return N->getKind() == EmitNode; |
| 89 | } |
| 90 | |
| 91 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 92 | }; |
| 93 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 94 | |
| 95 | /// PushMatcherNode - This pushes a failure scope on the stack and evaluates |
| 96 | /// 'child'. If 'child' fails to match, it pops its scope and attempts to |
| 97 | /// match 'Failure'. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 98 | class PushMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 99 | OwningPtr<MatcherNode> Failure; |
| 100 | public: |
| 101 | PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 102 | : MatcherNode(Push), Failure(failure) { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 103 | setChild(child); |
| 104 | } |
| 105 | |
| 106 | MatcherNode *getFailure() { return Failure.get(); } |
| 107 | const MatcherNode *getFailure() const { return Failure.get(); } |
| 108 | void setFailure(MatcherNode *N) { Failure.reset(N); } |
| 109 | |
| 110 | static inline bool classof(const MatcherNode *N) { |
| 111 | return N->getKind() == Push; |
| 112 | } |
| 113 | |
| 114 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 115 | }; |
| 116 | |
| 117 | /// RecordMatcherNode - Save the current node in the operand list. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 118 | class RecordMatcherNode : public MatcherNode { |
Chris Lattner | 56cf88d | 2010-02-17 01:03:09 +0000 | [diff] [blame] | 119 | /// WhatFor - This is a string indicating why we're recording this. This |
| 120 | /// should only be used for comment generation not anything semantic. |
| 121 | std::string WhatFor; |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 122 | public: |
Chris Lattner | 086ca52 | 2010-02-17 01:27:29 +0000 | [diff] [blame] | 123 | RecordMatcherNode(const std::string &whatfor) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 124 | : MatcherNode(Record), WhatFor(whatfor) {} |
Chris Lattner | 56cf88d | 2010-02-17 01:03:09 +0000 | [diff] [blame] | 125 | |
Chris Lattner | 086ca52 | 2010-02-17 01:27:29 +0000 | [diff] [blame] | 126 | const std::string &getWhatFor() const { return WhatFor; } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 127 | |
| 128 | static inline bool classof(const MatcherNode *N) { |
| 129 | return N->getKind() == Record; |
| 130 | } |
| 131 | |
| 132 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 133 | }; |
| 134 | |
| 135 | /// MoveChildMatcherNode - This tells the interpreter to move into the |
| 136 | /// specified child node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 137 | class MoveChildMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 138 | unsigned ChildNo; |
| 139 | public: |
| 140 | MoveChildMatcherNode(unsigned childNo) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 141 | : MatcherNode(MoveChild), ChildNo(childNo) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 142 | |
| 143 | unsigned getChildNo() const { return ChildNo; } |
| 144 | |
| 145 | static inline bool classof(const MatcherNode *N) { |
| 146 | return N->getKind() == MoveChild; |
| 147 | } |
| 148 | |
| 149 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 150 | }; |
| 151 | |
| 152 | /// MoveParentMatcherNode - This tells the interpreter to move to the parent |
| 153 | /// of the current node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 154 | class MoveParentMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 155 | public: |
| 156 | MoveParentMatcherNode() |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 157 | : MatcherNode(MoveParent) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 158 | |
| 159 | static inline bool classof(const MatcherNode *N) { |
| 160 | return N->getKind() == MoveParent; |
| 161 | } |
| 162 | |
| 163 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 164 | }; |
| 165 | |
| 166 | /// CheckSameMatcherNode - This checks to see if this node is exactly the same |
| 167 | /// node as the specified match that was recorded with 'Record'. This is used |
| 168 | /// 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^] | 169 | class CheckSameMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 170 | unsigned MatchNumber; |
| 171 | public: |
| 172 | CheckSameMatcherNode(unsigned matchnumber) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 173 | : MatcherNode(CheckSame), MatchNumber(matchnumber) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 174 | |
| 175 | unsigned getMatchNumber() const { return MatchNumber; } |
| 176 | |
| 177 | static inline bool classof(const MatcherNode *N) { |
| 178 | return N->getKind() == CheckSame; |
| 179 | } |
| 180 | |
| 181 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 182 | }; |
| 183 | |
| 184 | /// CheckPatternPredicateMatcherNode - This checks the target-specific predicate |
| 185 | /// to see if the entire pattern is capable of matching. This predicate does |
| 186 | /// 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^] | 187 | class CheckPatternPredicateMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 188 | std::string Predicate; |
| 189 | public: |
| 190 | CheckPatternPredicateMatcherNode(StringRef predicate) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 191 | : MatcherNode(CheckPatternPredicate), Predicate(predicate) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 192 | |
| 193 | StringRef getPredicate() const { return Predicate; } |
| 194 | |
| 195 | static inline bool classof(const MatcherNode *N) { |
| 196 | return N->getKind() == CheckPatternPredicate; |
| 197 | } |
| 198 | |
| 199 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 200 | }; |
| 201 | |
| 202 | /// CheckPredicateMatcherNode - This checks the target-specific predicate to |
| 203 | /// see if the node is acceptable. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 204 | class CheckPredicateMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 205 | StringRef PredName; |
| 206 | public: |
| 207 | CheckPredicateMatcherNode(StringRef predname) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 208 | : MatcherNode(CheckPredicate), PredName(predname) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 209 | |
| 210 | StringRef getPredicateName() const { return PredName; } |
| 211 | |
| 212 | static inline bool classof(const MatcherNode *N) { |
| 213 | return N->getKind() == CheckPredicate; |
| 214 | } |
| 215 | |
| 216 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 217 | }; |
| 218 | |
| 219 | |
| 220 | /// CheckOpcodeMatcherNode - This checks to see if the current node has the |
| 221 | /// specified opcode, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 222 | class CheckOpcodeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 223 | StringRef OpcodeName; |
| 224 | public: |
| 225 | CheckOpcodeMatcherNode(StringRef opcodename) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 226 | : MatcherNode(CheckOpcode), OpcodeName(opcodename) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 227 | |
| 228 | StringRef getOpcodeName() const { return OpcodeName; } |
| 229 | |
| 230 | static inline bool classof(const MatcherNode *N) { |
| 231 | return N->getKind() == CheckOpcode; |
| 232 | } |
| 233 | |
| 234 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 235 | }; |
| 236 | |
| 237 | /// CheckTypeMatcherNode - This checks to see if the current node has the |
| 238 | /// specified type, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 239 | class CheckTypeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 240 | MVT::SimpleValueType Type; |
| 241 | public: |
| 242 | CheckTypeMatcherNode(MVT::SimpleValueType type) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 243 | : MatcherNode(CheckType), Type(type) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 244 | |
| 245 | MVT::SimpleValueType getType() const { return Type; } |
| 246 | |
| 247 | static inline bool classof(const MatcherNode *N) { |
| 248 | return N->getKind() == CheckType; |
| 249 | } |
| 250 | |
| 251 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 252 | }; |
| 253 | |
| 254 | /// CheckIntegerMatcherNode - This checks to see if the current node is a |
| 255 | /// ConstantSDNode with the specified integer value, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 256 | class CheckIntegerMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 257 | int64_t Value; |
| 258 | public: |
| 259 | CheckIntegerMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 260 | : MatcherNode(CheckInteger), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 261 | |
| 262 | int64_t getValue() const { return Value; } |
| 263 | |
| 264 | static inline bool classof(const MatcherNode *N) { |
| 265 | return N->getKind() == CheckInteger; |
| 266 | } |
| 267 | |
| 268 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 269 | }; |
| 270 | |
| 271 | /// CheckCondCodeMatcherNode - This checks to see if the current node is a |
| 272 | /// CondCodeSDNode with the specified condition, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 273 | class CheckCondCodeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 274 | StringRef CondCodeName; |
| 275 | public: |
| 276 | CheckCondCodeMatcherNode(StringRef condcodename) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 277 | : MatcherNode(CheckCondCode), CondCodeName(condcodename) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 278 | |
| 279 | StringRef getCondCodeName() const { return CondCodeName; } |
| 280 | |
| 281 | static inline bool classof(const MatcherNode *N) { |
| 282 | return N->getKind() == CheckCondCode; |
| 283 | } |
| 284 | |
| 285 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 286 | }; |
| 287 | |
| 288 | /// CheckValueTypeMatcherNode - This checks to see if the current node is a |
| 289 | /// VTSDNode with the specified type, if not it fails to match. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 290 | class CheckValueTypeMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 291 | StringRef TypeName; |
| 292 | public: |
| 293 | CheckValueTypeMatcherNode(StringRef type_name) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 294 | : MatcherNode(CheckValueType), TypeName(type_name) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 295 | |
| 296 | StringRef getTypeName() const { return TypeName; } |
| 297 | |
| 298 | static inline bool classof(const MatcherNode *N) { |
| 299 | return N->getKind() == CheckValueType; |
| 300 | } |
| 301 | |
| 302 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 303 | }; |
| 304 | |
| 305 | |
| 306 | |
| 307 | /// CheckComplexPatMatcherNode - This node runs the specified ComplexPattern on |
| 308 | /// the current node. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 309 | class CheckComplexPatMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 310 | const ComplexPattern &Pattern; |
| 311 | public: |
| 312 | CheckComplexPatMatcherNode(const ComplexPattern &pattern) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 313 | : MatcherNode(CheckComplexPat), Pattern(pattern) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 314 | |
Chris Lattner | dc429fd | 2010-02-17 00:31:50 +0000 | [diff] [blame] | 315 | const ComplexPattern &getPattern() const { return Pattern; } |
| 316 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 317 | static inline bool classof(const MatcherNode *N) { |
| 318 | return N->getKind() == CheckComplexPat; |
| 319 | } |
| 320 | |
| 321 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 322 | }; |
| 323 | |
| 324 | /// CheckAndImmMatcherNode - This checks to see if the current node is an 'and' |
| 325 | /// with something equivalent to the specified immediate. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 326 | class CheckAndImmMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 327 | int64_t Value; |
| 328 | public: |
| 329 | CheckAndImmMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 330 | : MatcherNode(CheckAndImm), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 331 | |
| 332 | int64_t getValue() const { return Value; } |
| 333 | |
| 334 | static inline bool classof(const MatcherNode *N) { |
| 335 | return N->getKind() == CheckAndImm; |
| 336 | } |
| 337 | |
| 338 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 339 | }; |
| 340 | |
| 341 | /// CheckOrImmMatcherNode - This checks to see if the current node is an 'and' |
| 342 | /// with something equivalent to the specified immediate. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 343 | class CheckOrImmMatcherNode : public MatcherNode { |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 344 | int64_t Value; |
| 345 | public: |
| 346 | CheckOrImmMatcherNode(int64_t value) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 347 | : MatcherNode(CheckOrImm), Value(value) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 348 | |
| 349 | int64_t getValue() const { return Value; } |
| 350 | |
| 351 | static inline bool classof(const MatcherNode *N) { |
| 352 | return N->getKind() == CheckOrImm; |
| 353 | } |
| 354 | |
| 355 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 356 | }; |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 357 | |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 358 | /// CheckFoldableChainNodeMatcherNode - This checks to see if the current node |
| 359 | /// (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^] | 360 | class CheckFoldableChainNodeMatcherNode : public MatcherNode { |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 361 | public: |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 362 | CheckFoldableChainNodeMatcherNode() |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 363 | : MatcherNode(CheckFoldableChainNode) {} |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 364 | |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 365 | static inline bool classof(const MatcherNode *N) { |
Chris Lattner | c6dc8f6 | 2010-02-16 19:15:55 +0000 | [diff] [blame] | 366 | return N->getKind() == CheckFoldableChainNode; |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 367 | } |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 368 | |
Chris Lattner | 9de3948 | 2010-02-16 06:10:58 +0000 | [diff] [blame] | 369 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 370 | }; |
| 371 | |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 372 | /// CheckChainCompatibleMatcherNode - Verify that the current node's chain |
| 373 | /// operand is 'compatible' with the specified recorded node's. |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 374 | class CheckChainCompatibleMatcherNode : public MatcherNode { |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 375 | unsigned PreviousOp; |
| 376 | public: |
| 377 | CheckChainCompatibleMatcherNode(unsigned previousop) |
Chris Lattner | 3b31c98 | 2010-02-18 02:49:24 +0000 | [diff] [blame^] | 378 | : MatcherNode(CheckChainCompatible), PreviousOp(previousop) {} |
Chris Lattner | 283adcb | 2010-02-17 06:23:39 +0000 | [diff] [blame] | 379 | |
| 380 | unsigned getPreviousOp() const { return PreviousOp; } |
| 381 | |
| 382 | static inline bool classof(const MatcherNode *N) { |
| 383 | return N->getKind() == CheckChainCompatible; |
| 384 | } |
| 385 | |
| 386 | virtual void print(raw_ostream &OS, unsigned indent = 0) const; |
| 387 | }; |
| 388 | |
| 389 | |
| 390 | |
Chris Lattner | e7d6e3c | 2010-02-15 08:04:42 +0000 | [diff] [blame] | 391 | } // end namespace llvm |
| 392 | |
| 393 | #endif |