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


C++ BitVector::IsSet方法代码示例

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


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

示例1: GetOldestAvailable

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AggregateCopyPropagation::GetOldestAvailable(Operand* candidateOp,
                                                  TOperandToIdDict& availableCopies,
                                                  BitVector& killSet, 
                                                  CopySetInfo& info) {
    // Check if an original source is available.
    int id;

    if(availableCopies.TryGetValue(candidateOp, &id)) {
        if(killSet.IsSet(id)) {
            // The original is dirty.
            return false;
        }

        info = infoList_[id];
        auto originalOp = info.Source;

        // Check if an older source is available. This is useful
        // for a chain of copies, when the copies are not modified.
        while(availableCopies.TryGetValue(originalOp, &id)) {
            if(killSet.IsSet(id)) {
                return originalOp;
            }

            info = infoList_[id];
            originalOp = info.Source;
        }

        return true;
    }

    return false;
}
开发者ID:lgratian,项目名称:compiler,代码行数:33,代码来源:AggregateCopyPropagation.cpp

示例2: ComputeBlockExposedAndKillSets

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void VariableAnalysis::ComputeBlockExposedAndKillSets(Block* block, 
													  BitVector& exposedSet,
													  BitVector& killSet) {
	// Scan all the instructions in the block and look for 'load' and 'store'.
	for(auto instr = block->FirstInstruction(); instr; 
        instr = instr->NextInstruction()) {
		if(auto storeInstr = instr->As<StoreInstr>()) {
			// A variable can be killed only if it's stored into.
			// Note that we don't care about the effects of function calls,
			// because in that case the variable is marked as "address taken"
			// and it isn't considered for SSA conversion anyway.
			if(auto variableRef = storeInstr->DestinationOp()->As<VariableReference>()) {
				auto localVar = variableRef->GetVariable();
				
                if(localVar == nullptr) {
                    continue;
                }

				killSet.SetBit(localVar->Id());
			}
		}
		else if(auto loadInstr = instr->As<LoadInstr>()) {
			// The only way a variable can be "used" is through a 'load' instruction.
			// All other kinds of uses will render the variable as being "address taken".
			if(auto variableRef = loadInstr->SourceOp()->As<VariableReference>()) {
				auto localVar = variableRef->GetVariable();
				
                if(localVar == nullptr) {
                    continue;
                }

				// Mark the variable as 'exposed' only if it's not in the 'kill' set.
				if(killSet.IsSet(localVar->Id()) == false) {
					exposedSet.SetBit(localVar->Id());
				}
			}
		}
	}
}
开发者ID:lgratian,项目名称:compiler,代码行数:40,代码来源:VariableAnalysis.cpp


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