+/// Pattern - Represent a pattern of one form or another. Currently, three
+/// types of patterns are possible: Instruction's, Nonterminals, and Expanders.
+///
+struct Pattern {
+ enum PatternType {
+ Nonterminal, Instruction, Expander
+ };
+private:
+ /// PTy - The type of pattern this is.
+ ///
+ PatternType PTy;
+
+ /// Tree - The tree pattern which corresponds to this pattern. Note that if
+ /// there was a (set) node on the outside level that it has been stripped off.
+ ///
+ TreePatternNode *Tree;
+
+ /// Result - If this is an instruction or expander pattern, this is the
+ /// register result, specified with a (set) in the pattern.
+ ///
+ Record *Result;
+
+ /// TheRecord - The actual TableGen record corresponding to this pattern.
+ ///
+ Record *TheRecord;
+
+ /// Resolved - This is true of the pattern is useful in practice. In
+ /// particular, some non-terminals will have non-resolvable types. When a
+ /// user of the non-terminal is later found, they will have inferred a type
+ /// for the result of the non-terminal, which cause a clone of an unresolved
+ /// nonterminal to be made which is "resolved".
+ ///
+ bool Resolved;
+
+ /// ISE - the instruction selector emitter coordinating this madness.
+ ///
+ InstrSelectorEmitter &ISE;
+public:
+
+ /// Pattern constructor - Parse the specified DagInitializer into the current
+ /// record.
+ Pattern(PatternType pty, DagInit *RawPat, Record *TheRec,
+ InstrSelectorEmitter &ise);
+
+ /// getPatternType - Return what flavor of Record this pattern originated from
+ ///
+ PatternType getPatternType() const { return PTy; }
+
+ /// getTree - Return the tree pattern which corresponds to this pattern.
+ ///
+ TreePatternNode *getTree() const { return Tree; }
+
+ Record *getResult() const { return Result; }
+
+ /// getRecord - Return the actual TableGen record corresponding to this
+ /// pattern.
+ ///
+ Record *getRecord() const { return TheRecord; }
+
+ bool isResolved() const { return Resolved; }
+
+private:
+ TreePatternNode *ParseTreePattern(DagInit *DI);
+ bool InferTypes(TreePatternNode *N, bool &MadeChange);
+ void error(const std::string &Msg);
+};
+
+std::ostream &operator<<(std::ostream &OS, const Pattern &P);
+
+
+
+/// InstrSelectorEmitter - The top-level class which coordinates construction
+/// and emission of the instruction selector.
+///