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