本文整理汇总了C++中Pattern::getRecord方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::getRecord方法的具体用法?C++ Pattern::getRecord怎么用?C++ Pattern::getRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::getRecord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void InstrSelectorEmitter::run(std::ostream &OS) {
// Type-check all of the node types to ensure we "understand" them.
ReadNodeTypes();
// Read in all of the nonterminals, instructions, and expanders...
ReadNonterminals();
ReadInstructionPatterns();
ReadExpanderPatterns();
// Instantiate any unresolved nonterminals with information from the context
// that they are used in.
InstantiateNonterminals();
// Clear InstantiatedNTs, we don't need it anymore...
InstantiatedNTs.clear();
DEBUG(std::cerr << "Patterns acquired:\n");
for (std::map<Record*, Pattern*>::iterator I = Patterns.begin(),
E = Patterns.end(); I != E; ++I)
if (I->second->isResolved())
DEBUG(std::cerr << " " << *I->second << "\n");
CalculateComputableValues();
OS << "#include \"llvm/CodeGen/MachineInstrBuilder.h\"\n";
EmitSourceFileHeader("Instruction Selector for the " + Target.getName() +
" target", OS);
// Output the slot number enums...
OS << "\nenum { // Slot numbers...\n"
<< " LastBuiltinSlot = ISD::NumBuiltinSlots-1, // Start numbering here\n";
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I)
OS << " " << I->first << "_Slot,\n";
OS << " NumSlots\n};\n\n// Reduction value typedefs...\n";
// Output the reduction value typedefs...
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I) {
OS << "typedef ReducedValue<unsigned, " << I->first
<< "_Slot> ReducedValue_" << I->first << ";\n";
}
// Output the pattern enums...
OS << "\n\n"
<< "enum { // Patterns...\n"
<< " NotComputed = 0,\n"
<< " NoMatchPattern, \n";
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I) {
OS << " // " << I->first << " patterns...\n";
for (PatternOrganizer::NodesForSlot::iterator J = I->second.begin(),
E = I->second.end(); J != E; ++J)
for (unsigned i = 0, e = J->second.size(); i != e; ++i)
OS << " " << J->second[i]->getRecord()->getName() << "_Pattern,\n";
}
OS << "};\n\n";
//===--------------------------------------------------------------------===//
// Emit the class definition...
//
OS << "namespace {\n"
<< " class " << Target.getName() << "ISel {\n"
<< " SelectionDAG &DAG;\n"
<< " public:\n"
<< " " << Target.getName () << "ISel(SelectionDAG &D) : DAG(D) {}\n"
<< " void generateCode();\n"
<< " private:\n"
<< " unsigned makeAnotherReg(const TargetRegisterClass *RC) {\n"
<< " return DAG.getMachineFunction().getSSARegMap()->createVirt"
"ualRegister(RC);\n"
<< " }\n\n"
<< " // DAG matching methods for classes... all of these methods"
" return the cost\n"
<< " // of producing a value of the specified class and type, which"
" also gets\n"
<< " // added to the DAG node.\n";
// Output all of the matching prototypes for slots...
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I)
OS << " unsigned Match_" << I->first << "(SelectionDAGNode *N);\n";
OS << "\n // DAG matching methods for DAG nodes...\n";
// Output all of the matching prototypes for slot/node pairs
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I)
for (PatternOrganizer::NodesForSlot::iterator J = I->second.begin(),
E = I->second.end(); J != E; ++J)
OS << " unsigned Match_" << I->first << "_" << getNodeName(J->first)
<< "(SelectionDAGNode *N);\n";
// Output all of the dag reduction methods prototypes...
OS << "\n // DAG reduction methods...\n";
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I)
OS << " ReducedValue_" << I->first << " *Reduce_" << I->first
<< "(SelectionDAGNode *N,\n" << std::string(27+2*I->first.size(), ' ')
//.........这里部分代码省略.........
示例2: EmitMatchCosters
// EmitMatchCosters - Given a list of patterns, which all have the same root
// pattern operator, emit an efficient decision tree to decide which one to
// pick. This is structured this way to avoid reevaluations of non-obvious
// subexpressions.
void InstrSelectorEmitter::EmitMatchCosters(std::ostream &OS,
const std::vector<std::pair<Pattern*, TreePatternNode*> > &Patterns,
const std::string &VarPrefix,
unsigned IndentAmt) {
assert(!Patterns.empty() && "No patterns to emit matchers for!");
std::string Indent(IndentAmt, ' ');
// Load all of the operands of the root node into scalars for fast access
const NodeType &ONT = getNodeType(Patterns[0].second->getOperator());
for (unsigned i = 0, e = ONT.ArgTypes.size(); i != e; ++i)
OS << Indent << "SelectionDAGNode *" << VarPrefix << "_Op" << i
<< " = N->getUse(" << i << ");\n";
// Compute the costs of computing the various nonterminals/registers, which
// are directly used at this level.
OS << "\n" << Indent << "// Operand matching costs...\n";
std::set<std::string> ComputedValues; // Avoid duplicate computations...
for (unsigned i = 0, e = Patterns.size(); i != e; ++i) {
TreePatternNode *NParent = Patterns[i].second;
for (unsigned c = 0, e = NParent->getNumChildren(); c != e; ++c) {
TreePatternNode *N = NParent->getChild(c);
if (N->isLeaf()) {
Record *VR = N->getValueRecord();
const std::string &LeafName = VR->getName();
std::string OpName = VarPrefix + "_Op" + utostr(c);
std::string ValName = OpName + "_" + LeafName + "_Cost";
if (!ComputedValues.count(ValName)) {
OS << Indent << "unsigned " << ValName << " = Match_"
<< Pattern::getSlotName(VR) << "(" << OpName << ");\n";
ComputedValues.insert(ValName);
}
}
}
}
OS << "\n";
std::string LocCostName = VarPrefix + "_Cost";
OS << Indent << "unsigned " << LocCostName << "Min = ~0U >> 1;\n"
<< Indent << "unsigned " << VarPrefix << "_PatternMin = NoMatchPattern;\n";
#if 0
// Separate out all of the patterns into groups based on what their top-level
// signature looks like...
std::vector<std::pair<Pattern*, TreePatternNode*> > PatternsLeft(Patterns);
while (!PatternsLeft.empty()) {
// Process all of the patterns that have the same signature as the last
// element...
std::vector<std::pair<Pattern*, TreePatternNode*> > Group;
MoveIdenticalPatterns(PatternsLeft.back().second, PatternsLeft, Group);
assert(!Group.empty() && "Didn't at least pick the source pattern?");
#if 0
OS << "PROCESSING GROUP:\n";
for (unsigned i = 0, e = Group.size(); i != e; ++i)
OS << " " << *Group[i].first << "\n";
OS << "\n\n";
#endif
OS << Indent << "{ // ";
if (Group.size() != 1) {
OS << Group.size() << " size group...\n";
OS << Indent << " unsigned " << VarPrefix << "_Pattern = NoMatch;\n";
} else {
OS << *Group[0].first << "\n";
OS << Indent << " unsigned " << VarPrefix << "_Pattern = "
<< Group[0].first->getRecord()->getName() << "_Pattern;\n";
}
OS << Indent << " unsigned " << LocCostName << " = ";
if (Group.size() == 1)
OS << "1;\n"; // Add inst cost if at individual rec
else
OS << "0;\n";
// Loop over all of the operands, adding in their costs...
TreePatternNode *N = Group[0].second;
const std::vector<TreePatternNode*> &Children = N->getChildren();
// If necessary, emit conditionals to check for the appropriate tree
// structure here...
for (unsigned i = 0, e = Children.size(); i != e; ++i) {
TreePatternNode *C = Children[i];
if (C->isLeaf()) {
// We already calculated the cost for this leaf, add it in now...
OS << Indent << " " << LocCostName << " += "
<< VarPrefix << "_Op" << utostr(i) << "_"
<< C->getValueRecord()->getName() << "_Cost;\n";
} else {
// If it's not a leaf, we have to check to make sure that the current
// node has the appropriate structure, then recurse into it...
OS << Indent << " if (" << VarPrefix << "_Op" << i
<< "->getNodeType() == ISD::" << getNodeName(C->getOperator())
<< ") {\n";
std::vector<std::pair<Pattern*, TreePatternNode*> > SubPatterns;
//.........这里部分代码省略.........