本文整理汇总了C++中machinebasicblock::iterator::defs方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::defs方法的具体用法?C++ iterator::defs怎么用?C++ iterator::defs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machinebasicblock::iterator
的用法示例。
在下文中一共展示了iterator::defs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canMerge
///
/// This method determines whether the two coalescing candidates can be merged.
/// In order to be merged, all instructions must be able to
/// 1. Move to the beginning of the SourceRegion.BranchTargetBlock;
/// 2. Move to the end of the TargetRegion.BranchBlock.
/// Merging involves moving the instructions in the
/// TargetRegion.BranchTargetBlock (also SourceRegion.BranchBlock).
///
/// This function first try to move instructions from the
/// TargetRegion.BranchTargetBlock down, to the beginning of the
/// SourceRegion.BranchTargetBlock. This is not possible if any register defined
/// in TargetRegion.BranchTargetBlock is used in a PHI node in the
/// SourceRegion.BranchTargetBlock. In this case, check whether the statement
/// can be moved up, to the end of the TargetRegion.BranchBlock (immediately
/// before the branch statement). If it cannot move, then these blocks cannot
/// be merged.
///
/// Note that there is no analysis for moving instructions past the fall-through
/// blocks because they are confirmed to be empty. An assert is thrown if they
/// are not.
///
/// \param[in] SourceRegion The candidate to move statements from
/// \param[in] TargetRegion The candidate to move statements to
/// \return true if all instructions in SourceRegion.BranchBlock can be merged
/// into a block in TargetRegion, false otherwise.
///
bool PPCBranchCoalescing::canMerge(CoalescingCandidateInfo &SourceRegion,
CoalescingCandidateInfo &TargetRegion) const {
if (!validateCandidates(SourceRegion, TargetRegion))
return false;
// Walk through PHI nodes first and see if they force the merge into the
// SourceRegion.BranchTargetBlock.
for (MachineBasicBlock::iterator
I = SourceRegion.BranchBlock->instr_begin(),
E = SourceRegion.BranchBlock->getFirstNonPHI();
I != E; ++I) {
for (auto &Def : I->defs())
for (auto &Use : MRI->use_instructions(Def.getReg())) {
if (Use.isPHI() && Use.getParent() == SourceRegion.BranchTargetBlock) {
DEBUG(dbgs() << "PHI " << *I << " defines register used in another "
"PHI within branch target block -- can't merge\n");
NumPHINotMoved++;
return false;
}
if (Use.getParent() == SourceRegion.BranchBlock) {
DEBUG(dbgs() << "PHI " << *I
<< " defines register used in this "
"block -- all must move down\n");
SourceRegion.MustMoveDown = true;
}
}
}
// Walk through the MI to see if they should be merged into
// TargetRegion.BranchBlock (up) or SourceRegion.BranchTargetBlock (down)
for (MachineBasicBlock::iterator
I = SourceRegion.BranchBlock->getFirstNonPHI(),
E = SourceRegion.BranchBlock->end();
I != E; ++I) {
if (!canMoveToBeginning(*I, *SourceRegion.BranchTargetBlock)) {
DEBUG(dbgs() << "Instruction " << *I
<< " cannot move down - must move up!\n");
SourceRegion.MustMoveUp = true;
}
if (!canMoveToEnd(*I, *TargetRegion.BranchBlock)) {
DEBUG(dbgs() << "Instruction " << *I
<< " cannot move up - must move down!\n");
SourceRegion.MustMoveDown = true;
}
}
return (SourceRegion.MustMoveUp && SourceRegion.MustMoveDown) ? false : true;
}