本文整理汇总了C++中MInstruction::setLoopInvariant方法的典型用法代码示例。如果您正苦于以下问题:C++ MInstruction::setLoopInvariant方法的具体用法?C++ MInstruction::setLoopInvariant怎么用?C++ MInstruction::setLoopInvariant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MInstruction
的用法示例。
在下文中一共展示了MInstruction::setLoopInvariant方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IonSpew
bool
Loop::optimize()
{
InstructionQueue invariantInstructions;
InstructionQueue boundsChecks;
IonSpew(IonSpew_LICM, "These instructions are in the loop: ");
while (!worklist_.empty()) {
if (mir->shouldCancel("LICM (worklist)"))
return false;
MInstruction *ins = popFromWorklist();
IonSpewHeader(IonSpew_LICM);
if (IonSpewEnabled(IonSpew_LICM)) {
ins->printName(IonSpewFile);
fprintf(IonSpewFile, " <- ");
ins->printOpcode(IonSpewFile);
fprintf(IonSpewFile, ": ");
}
if (isLoopInvariant(ins)) {
// Flag this instruction as loop invariant.
ins->setLoopInvariant();
if (!invariantInstructions.append(ins))
return false;
// Loop through uses of invariant instruction and add back to work list.
for (MUseDefIterator iter(ins->toDefinition()); iter; iter++) {
MDefinition *consumer = iter.def();
if (consumer->isInWorklist())
continue;
// if the consumer of this invariant instruction is in the
// loop, and it is also worth hoisting, then process it.
if (isInLoop(consumer) && isHoistable(consumer)) {
if (!insertInWorklist(consumer->toInstruction()))
return false;
}
}
if (IonSpewEnabled(IonSpew_LICM))
fprintf(IonSpewFile, " Loop Invariant!\n");
} else if (ins->isBoundsCheck()) {
if (!boundsChecks.append(ins))
return false;
}
}
if (!hoistInstructions(invariantInstructions, boundsChecks))
return false;
return true;
}
示例2: IonSpew
bool
Loop::optimize()
{
InstructionQueue invariantInstructions;
IonSpew(IonSpew_LICM, "These instructions are in the loop: ");
while (!worklist_.empty()) {
if (mir->shouldCancel("LICM (worklist)"))
return false;
MInstruction *ins = popFromWorklist();
IonSpewHeader(IonSpew_LICM);
if (IonSpewEnabled(IonSpew_LICM)) {
ins->printName(IonSpewFile);
fprintf(IonSpewFile, " <- ");
ins->printOpcode(IonSpewFile);
fprintf(IonSpewFile, ": ");
}
if (isLoopInvariant(ins)) {
// Flag this instruction as loop invariant.
ins->setLoopInvariant();
if (!invariantInstructions.append(ins))
return false;
if (IonSpewEnabled(IonSpew_LICM))
fprintf(IonSpewFile, " Loop Invariant!\n");
}
}
if (!hoistInstructions(invariantInstructions))
return false;
return true;
}