本文整理汇总了C++中Pattern::getResult方法的典型用法代码示例。如果您正苦于以下问题:C++ Pattern::getResult方法的具体用法?C++ Pattern::getResult怎么用?C++ Pattern::getResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pattern
的用法示例。
在下文中一共展示了Pattern::getResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CalculateComputableValues
// CalculateComputableValues - Fill in the ComputableValues map through
// analysis of the patterns we are playing with.
void InstrSelectorEmitter::CalculateComputableValues() {
// Loop over all of the patterns, adding them to the ComputableValues map
for (std::map<Record*, Pattern*>::iterator I = Patterns.begin(),
E = Patterns.end(); I != E; ++I)
if (I->second->isResolved()) {
// We don't want to add patterns like R32 = R32. This is a hack working
// around a special case of a general problem, but for now we explicitly
// forbid these patterns. They can never match anyway.
Pattern *P = I->second;
if (!P->getResult() || !P->getTree()->isLeaf() ||
P->getResult() != P->getTree()->getValueRecord())
ComputableValues.addPattern(P);
}
}
示例2: run
//.........这里部分代码省略.........
<< "//\n";
for (PatternOrganizer::iterator I = ComputableValues.begin(),
E = ComputableValues.end(); I != E; ++I) {
const std::string &SlotName = I->first;
OS << "ReducedValue_" << SlotName << " *" << Target.getName()
<< "ISel::Reduce_" << SlotName
<< "(SelectionDAGNode *N, MachineBasicBlock *MBB) {\n"
<< " ReducedValue_" << SlotName << " *Val = N->hasValue<ReducedValue_"
<< SlotName << ">(" << SlotName << "_Slot);\n"
<< " if (Val) return Val;\n"
<< " if (N->getBB()) MBB = N->getBB();\n\n"
<< " switch (N->getPatternFor(" << SlotName << "_Slot)) {\n";
// Loop over all of the patterns that can produce a value for this slot...
PatternOrganizer::NodesForSlot &NodesForSlot = I->second;
for (PatternOrganizer::NodesForSlot::iterator J = NodesForSlot.begin(),
E = NodesForSlot.end(); J != E; ++J)
for (unsigned i = 0, e = J->second.size(); i != e; ++i) {
Pattern *P = J->second[i];
OS << " case " << P->getRecord()->getName() << "_Pattern: {\n"
<< " // " << *P << "\n";
// Loop over the operands, reducing them...
std::vector<std::pair<TreePatternNode*, std::string> > Operands;
ReduceAllOperands(P->getTree(), "N", Operands, OS);
// Now that we have reduced all of our operands, and have the values
// that reduction produces, perform the reduction action for this
// pattern.
std::string Result;
// If the pattern produces a register result, generate a new register
// now.
if (Record *R = P->getResult()) {
assert(R->isSubClassOf("RegisterClass") &&
"Only handle register class results so far!");
OS << " unsigned NewReg = makeAnotherReg(" << Target.getName()
<< "::" << R->getName() << "RegisterClass);\n";
Result = "NewReg";
DEBUG(OS << " std::cerr << \"%reg\" << NewReg << \" =\t\";\n");
} else {
DEBUG(OS << " std::cerr << \"\t\t\";\n");
Result = "0";
}
// Print out the pattern that matched...
DEBUG(OS << " std::cerr << \" " << P->getRecord()->getName() <<'"');
DEBUG(for (unsigned i = 0, e = Operands.size(); i != e; ++i)
if (Operands[i].first->isLeaf()) {
Record *RV = Operands[i].first->getValueRecord();
assert(RV->isSubClassOf("RegisterClass") &&
"Only handles registers here so far!");
OS << " << \" %reg\" << " << Operands[i].second
<< "->Val";
} else {
OS << " << ' ' << " << Operands[i].second
<< "->Val";
});
DEBUG(OS << " << \"\\n\";\n");
// Generate the reduction code appropriate to the particular type of
// pattern that this is...
switch (P->getPatternType()) {
case Pattern::Instruction:
// Instruction patterns just emit a single MachineInstr, using BuildMI
OS << " BuildMI(MBB, " << Target.getName() << "::"