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


C++ Dictionary::ContainsKey方法代码示例

本文整理汇总了C++中Dictionary::ContainsKey方法的典型用法代码示例。如果您正苦于以下问题:C++ Dictionary::ContainsKey方法的具体用法?C++ Dictionary::ContainsKey怎么用?C++ Dictionary::ContainsKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dictionary的用法示例。


在下文中一共展示了Dictionary::ContainsKey方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReplaceParameters

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void RecursionElimination::ReplaceParameters() {
    // As it is now, the function still uses the parameters
    // in SSA form directly, but now it should use
    // the 'phi' instructions from the old entry block.
    // We use a dictionary to map from parameter to 'phi' result.
    Dictionary<Parameter*, Operand*> paramToPhi;
    DebugValidator::AreEqual(funct_->ParameterCount(),
                             parameterPhis_.Count());

    for(int i = 0; i < funct_->ParameterCount(); i++) {
        paramToPhi.Add(funct_->GetParameter(i),
                       parameterPhis_[i]->ResultOp());
    }

    // Scan all instructions and do the replacements.
    auto oldEntryBlock = oldEntryBlock_;

    funct_->ForEachInstruction([&paramToPhi, oldEntryBlock]
                               (Instruction* instr) -> bool {
        if(instr->IsPhi() && (instr->ParentBlock() == oldEntryBlock)) {
            // The 'phi's int the old entry block
            // shouldn't have their operands changed.
            return true;
        }

        for(int i = 0; i < instr->SourceOpCount(); i++) {
            if(auto parameter = instr->GetSourceOp(i)->As<Parameter>()) {
                DebugValidator::IsTrue(paramToPhi.ContainsKey(parameter));
                instr->ReplaceSourceOp(i, paramToPhi[parameter]);
            }
        }

        return true;
    });
}
开发者ID:lgratian,项目名称:compiler,代码行数:36,代码来源:RecursionElimination.cpp

示例2: Execute

void SimpleDeadCodeElimination::Execute(Function* function) {
    StaticList<Instruction*, 512> worklist;
    Dictionary<Instruction*, bool> inWorklist; // If an instruction is in the worklist.

    // Try to remove 'store' instructions that have no effect.
    // The algorithm is really simple, but should catch cases like
    // arrays initialized with constants that were propagated already.
    RemoveDeadStores(function);

    // Try to remove copy/set operations that are unused,
    // because the aggregates they target are never referenced.
    RemoveDeadCopyOperations(function);

	// We process the blocks from last to first, and the instructions in the block
	// from last to first too; this allows removing more instructions on each
	// iteration that the usual first-last order.
	for(auto block = function->LastBlock(); block; block = block->PreviousBlock()) {
        // If the block is unreachable we remove all instructions from it,
        // but don't remove the block; this will be handled by the CFG Simplifier,
        // which knows how to repair the Dominator Tree.
        if(block->IsUnreachable() && (block->IsEmpty() == false)) {
            CleanUnreachableBlock(block);
            continue;
        }

        for(auto instr = block->LastInstruction(); instr; 
            instr = instr->PreviousInstruction()) {
            if(GetSafetyInfo()->IsDefinitelyDead(instr)) {
                worklist.Add(instr);
                inWorklist.Add(instr, true);
            }
        }
    }

	// Process while we have instructions in the worklist.
    while(worklist.IsNotEmpty()) {
        auto instr = worklist.RemoveLast();
        inWorklist.Remove(instr);

        // Remove the instruction if it's dead.
        if(GetSafetyInfo()->IsDefinitelyDead(instr)) {
            // All the instructions that where used by this one
            // may be dead now, add them to the worklist.
            for(int i = 0; i < instr->SourceOpCount(); i++) {
                auto sourceOp = instr->GetSourceOp(i);

                // Make sure we don't add an instruction in the worklist twice.
                if(auto definingInstr = sourceOp->DefiningInstruction()) {
                    if(inWorklist.ContainsKey(definingInstr) == false) {
                        worklist.Add(definingInstr);
                        inWorklist.Add(definingInstr, true);
                   }
                }
            }

            InstructionRemoved(instr);
            instr->RemoveFromBlock(true /* free */);
        }
    }

    // If there were removed stored we may now have variables
    // that are not used by any instruction.
    RemoveDeadVariables(function);
}
开发者ID:lgratian,项目名称:compiler,代码行数:64,代码来源:SimpleDeadCodeElimination.cpp

示例3: WasInstructionProcessed

 bool WasInstructionProcessed(Instruction* instr) {
     return processedInstrs_.ContainsKey(instr);
 }
开发者ID:lgratian,项目名称:compiler,代码行数:3,代码来源:TreeBalancing.hpp

示例4: SetVolatileCount

	// Sets the number of volatile operations for the specified function.
	void SetVolatileCount(Function* function, int value) {
		if(volatileCount_.ContainsKey(function)) {
			volatileCount_[function] = value;
		}
		else volatileCount_.Add(function, value);
	}
开发者ID:lgratian,项目名称:compiler,代码行数:7,代码来源:VolatileVerifier.hpp

示例5: GetVolatileCount

	// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	// Returns the number of volatile operations from the specified function.
	int GetVolatileCount(Function* function) {
		if(volatileCount_.ContainsKey(function)) {
			return volatileCount_[function];
		}
		else return 0;
	}
开发者ID:lgratian,项目名称:compiler,代码行数:8,代码来源:VolatileVerifier.hpp


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