本文整理汇总了C++中BlockList::Count方法的典型用法代码示例。如果您正苦于以下问题:C++ BlockList::Count方法的具体用法?C++ BlockList::Count怎么用?C++ BlockList::Count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BlockList
的用法示例。
在下文中一共展示了BlockList::Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeReturnedValues
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void IndirectCallPromotion::MergeReturnedValues(BlockList& callBlocks,
Block* continuationBlock,
CallInstr* instr) {
// If the call returns 'void' or the result is not used
// there are no values to merge.
if(instr->IsVoid() || (instr->HasDestinationOp() == false)) {
return;
}
auto unit = callBlocks[0]->ParentFunction()->ParentUnit();
auto& references = unit->References();
// Create the 'phi' that merges the returned values.
auto phiResultOp = Temporary::GetTemporary(instr->ResultOp()->GetType());
auto phiInstr = PhiInstr::GetPhi(phiResultOp, callBlocks.Count());
continuationBlock->InsertInstructionFirst(phiInstr);
// Now add the incoming operands.
for(int i = 0; i < callBlocks.Count(); i++) {
auto beforeGoto = callBlocks[i]->LastInstruction()->PreviousInstruction();
auto callInstr = beforeGoto->As<CallInstr>();
DebugValidator::IsNotNull(callInstr);
DebugValidator::IsNotNull(callInstr->ResultOp());
auto blockRef = references.GetBlockRef(callBlocks[i]);
phiInstr->AddOperand(callInstr->ResultOp(), blockRef);
}
// The original returned value is replaced by the 'phi' result.
instr->ResultOp()->ReplaceWith(phiResultOp);
}
示例2: ConnectGeneratedBlocks
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void IndirectCallPromotion::ConnectGeneratedBlocks(BlockList& testBlocks,
BlockList& callBlocks) {
// Connect the blocks based on the following pattern:
// TEST_BLOCK0:
// t0 = ucmp targetOp, FUNCT_REF0
// if t0, CALL_BLOCK0, TEST_BLOCK1
// CALL_BLOCK0:
// call FUNCT_REF0
// goto CONTINUATION_BLOCK
// TEST_BLOCK1:
// t1 = ucmp targetOp, FUNCT_REF1
// if t1, CALL_BLOCK1, TEST_BLOCK2
// ...
// CALL_BLOCK_N: // only if unpromoted targets
// call targetOp
// goto CONTINUATION_BLOCK
// CONTINUATION_BLOCK:
auto unit = callBlocks[0]->ParentFunction()->ParentUnit();
auto& references = unit->References();
for(int i = 0; i < testBlocks.Count(); i++) {
auto testBlock = testBlocks[i];
auto ucmpResultOp = testBlocks[i]->LastInstruction()->GetDestinationOp();
auto trueBlockRef = references.GetBlockRef(callBlocks[i]);
Block* falseBlock;
if((i + 1) < testBlocks.Count()) {
// There is a next target test.
falseBlock = testBlocks[i + 1];
}
else {
// Unpromoted targets exist, always do the call.
falseBlock = callBlocks[i + 1];
}
auto falseBlockRef = references.GetBlockRef(falseBlock);
auto ifInstr = IfInstr::GetIf(ucmpResultOp, trueBlockRef, falseBlockRef);
testBlock->InsertInstruction(ifInstr);
}
}