def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT",
SDTypeProfile<1, 2, []>, []>;
def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT",
- SDTypeProfile<1, 3, []>, []>;
+ SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>]>, []>;
// Nodes for intrinsics, you should use the intrinsic itself and let tblgen use
// these internally. Don't reference these directly.
dag PatternToMatch = patternToMatch;
list<dag> ResultInstrs = resultInstrs;
list<Predicate> Predicates = []; // See class Instruction in Target.td.
+ int AddedCost = 0; // See class Instruction in Target.td.
}
// Pat - A simple (but common) form of a pattern, which produces a simple result
TreePatternNode *DstPattern = TheInst.getResultPattern();
PatternsToMatch.
push_back(PatternToMatch(Instr->getValueAsListInit("Predicates"),
- SrcPattern, DstPattern));
+ SrcPattern, DstPattern,
+ Instr->getValueAsInt("AddedCost")));
}
}
PatternsToMatch.
push_back(PatternToMatch(Patterns[i]->getValueAsListInit("Predicates"),
Pattern->getOnlyTree(),
- Temp.getOnlyTree()));
+ Temp.getOnlyTree(),
+ Patterns[i]->getValueAsInt("AddedCost")));
}
}
// Otherwise, add it to the list of patterns we have.
PatternsToMatch.
push_back(PatternToMatch(PatternsToMatch[i].getPredicates(),
- Variant, PatternsToMatch[i].getDstPattern()));
+ Variant, PatternsToMatch[i].getDstPattern(),
+ PatternsToMatch[i].getAddedCost()));
}
DEBUG(std::cerr << "\n");
PatternToMatch *RHS) {
unsigned LHSSize = getPatternSize(LHS->getSrcPattern(), ISE);
unsigned RHSSize = getPatternSize(RHS->getSrcPattern(), ISE);
+ LHSSize += LHS->getAddedCost();
+ RHSSize += RHS->getAddedCost();
if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost
if (LHSSize < RHSSize) return false;
// Predicates.
ListInit *Predicates;
+ // Pattern cost.
+ unsigned Cost;
// Instruction selector pattern.
TreePatternNode *Pattern;
// Matched instruction.
OS << "\n" << std::string(Indent, ' ') << "// Emits: ";
Pattern.getDstPattern()->print(OS);
OS << "\n";
+ unsigned AddedCost = Pattern.getAddedCost();
OS << std::string(Indent, ' ') << "// Pattern complexity = "
- << getPatternSize(Pattern.getSrcPattern(), *this) << " cost = "
+ << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost
+ << " cost = "
<< getResultPatternCost(Pattern.getDstPattern(), *this) << "\n";
}
if (!FirstCodeLine.first) {
OS << "\n" << std::string(Indent, ' ') << "// Emits: ";
Pattern.getDstPattern()->print(OS);
OS << "\n";
+ unsigned AddedCost = Pattern.getAddedCost();
OS << std::string(Indent, ' ') << "// Pattern complexity = "
- << getPatternSize(Pattern.getSrcPattern(), *this) << " cost = "
+ << getPatternSize(Pattern.getSrcPattern(), *this) + AddedCost
+ << " cost = "
<< getResultPatternCost(Pattern.getDstPattern(), *this) << "\n";
}
EmitPatterns(Other, Indent, OS);
/// PatternToMatch - Used by DAGISelEmitter to keep tab of patterns processed
/// to produce isel.
struct PatternToMatch {
- PatternToMatch(ListInit *preds, TreePatternNode *src, TreePatternNode *dst):
- Predicates(preds), SrcPattern(src), DstPattern(dst) {};
+ PatternToMatch(ListInit *preds,
+ TreePatternNode *src, TreePatternNode *dst, unsigned cost):
+ Predicates(preds), SrcPattern(src), DstPattern(dst), AddedCost(cost) {};
ListInit *Predicates; // Top level predicate conditions to match.
TreePatternNode *SrcPattern; // Source pattern to match.
TreePatternNode *DstPattern; // Resulting pattern.
+ unsigned AddedCost; // Add to matching pattern complexity.
ListInit *getPredicates() const { return Predicates; }
TreePatternNode *getSrcPattern() const { return SrcPattern; }
TreePatternNode *getDstPattern() const { return DstPattern; }
+ unsigned getAddedCost() const { return AddedCost; }
};
/// DAGISelEmitter - The top-level class which coordinates construction