当前位置: 首页>>代码示例>>C++>>正文


C++ BlockList::Count方法代码示例

本文整理汇总了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);
}
开发者ID:lgratian,项目名称:compiler,代码行数:33,代码来源:IndirectCallPromotion.cpp

示例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);
    }
}
开发者ID:lgratian,项目名称:compiler,代码行数:41,代码来源:IndirectCallPromotion.cpp


注:本文中的BlockList::Count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。