-//===- CodegenDAGPatterns.h - Read DAG patterns from .td file ---*- C++ -*-===//
+//===- CodeGenDAGPatterns.h - Read DAG patterns from .td file ---*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
//
//===----------------------------------------------------------------------===//
//
-// This file declares the CodegenDAGPatterns class, which is used to read and
+// This file declares the CodeGenDAGPatterns class, which is used to read and
// represent the patterns present in a .td file for instructions.
//
//===----------------------------------------------------------------------===//
class SDNodeInfo;
class TreePattern;
class TreePatternNode;
- class CodegenDAGPatterns;
+ class CodeGenDAGPatterns;
class ComplexPattern;
/// MVT::DAGISelGenValueType - These are some extended forms of MVT::ValueType
void setChild(unsigned i, TreePatternNode *N) {
Children[i] = N;
}
-
-
+
const std::string &getPredicateFn() const { return PredicateFn; }
void setPredicateFn(const std::string &Fn) { PredicateFn = Fn; }
Record *getTransformFn() const { return TransformFn; }
void setTransformFn(Record *Fn) { TransformFn = Fn; }
+ /// getIntrinsicInfo - If this node corresponds to an intrinsic, return the
+ /// CodeGenIntrinsic information for it, otherwise return a null pointer.
+ const CodeGenIntrinsic *getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const;
+
void print(std::ostream &OS) const;
void dump() const;
/// canPatternMatch - If it is impossible for this pattern to match on this
/// target, fill in Reason and return false. Otherwise, return true.
- bool canPatternMatch(std::string &Reason, CodegenDAGPatterns &CDP);
+ bool canPatternMatch(std::string &Reason, CodeGenDAGPatterns &CDP);
};
/// CDP - the top-level object coordinating this madness.
///
- CodegenDAGPatterns &CDP;
+ CodeGenDAGPatterns &CDP;
/// isInputPattern - True if this is an input pattern, something to match.
/// False if this is an output pattern, something to emit.
/// TreePattern constructor - Parse the specified DagInits into the
/// current record.
TreePattern(Record *TheRec, ListInit *RawPat, bool isInput,
- CodegenDAGPatterns &ise);
+ CodeGenDAGPatterns &ise);
TreePattern(Record *TheRec, DagInit *Pat, bool isInput,
- CodegenDAGPatterns &ise);
+ CodeGenDAGPatterns &ise);
TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput,
- CodegenDAGPatterns &ise);
+ CodeGenDAGPatterns &ise);
/// getTrees - Return the tree patterns which corresponds to this pattern.
///
}
std::vector<std::string> &getArgList() { return Args; }
- CodegenDAGPatterns &getDAGPatterns() const { return CDP; }
+ CodeGenDAGPatterns &getDAGPatterns() const { return CDP; }
/// InlinePatternFragments - If this pattern refers to any pattern
/// fragments, inline them into place, giving us a pattern without any
ImpResults(impresults), ImpOperands(impoperands),
ResultPattern(0) {}
- TreePattern *getPattern() const { return Pattern; }
+ const TreePattern *getPattern() const { return Pattern; }
unsigned getNumResults() const { return Results.size(); }
unsigned getNumOperands() const { return Operands.size(); }
unsigned getNumImpResults() const { return ImpResults.size(); }
TreePatternNode *getResultPattern() const { return ResultPattern; }
};
-/// PatternToMatch - Used by CodegenDAGPatterns to keep tab of patterns
+/// PatternToMatch - Used by CodeGenDAGPatterns to keep tab of patterns
/// processed to produce isel.
struct PatternToMatch {
PatternToMatch(ListInit *preds,
};
-class CodegenDAGPatterns {
+class CodeGenDAGPatterns {
RecordKeeper &Records;
CodeGenTarget Target;
std::vector<CodeGenIntrinsic> Intrinsics;
/// emit.
std::vector<PatternToMatch> PatternsToMatch;
public:
- CodegenDAGPatterns(RecordKeeper &R, std::ostream &OS);
- ~CodegenDAGPatterns();
+ CodeGenDAGPatterns(RecordKeeper &R);
+ ~CodeGenDAGPatterns();
const CodeGenTarget &getTargetInfo() const { return Target; }
return SDNodes.find(R)->second;
}
- const std::pair<Record*, std::string> &getSDNodeTransform(Record *R) const {
+ // Node transformation lookups.
+ typedef std::pair<Record*, std::string> NodeXForm;
+ const NodeXForm &getSDNodeTransform(Record *R) const {
assert(SDNodeXForms.count(R) && "Invalid transform!");
return SDNodeXForms.find(R)->second;
}
+ typedef std::map<Record*, NodeXForm>::const_iterator nx_iterator;
+ nx_iterator nx_begin() const { return SDNodeXForms.begin(); }
+ nx_iterator nx_end() const { return SDNodeXForms.end(); }
+
+
const ComplexPattern &getComplexPattern(Record *R) const {
assert(ComplexPatterns.count(R) && "Unknown addressing mode!");
return ComplexPatterns.find(R)->second;
pf_iterator pf_end() const { return PatternFragments.end(); }
// Patterns to match information.
- // FIXME: make a const_iterator.
- typedef std::vector<PatternToMatch>::iterator ptm_iterator;
- ptm_iterator ptm_begin() { return PatternsToMatch.begin(); }
- ptm_iterator ptm_end() { return PatternsToMatch.end(); }
+ typedef std::vector<PatternToMatch>::const_iterator ptm_iterator;
+ ptm_iterator ptm_begin() const { return PatternsToMatch.begin(); }
+ ptm_iterator ptm_end() const { return PatternsToMatch.end(); }
private:
void ParseNodeInfo();
- void ParseNodeTransforms(std::ostream &OS);
+ void ParseNodeTransforms();
void ParseComplexPatterns();
- void ParsePatternFragments(std::ostream &OS);
+ void ParsePatternFragments();
void ParseDefaultOperands();
void ParseInstructions();
void ParsePatterns();