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


C++ Opnd::canBePlacedIn方法代码示例

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


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

示例1: handleInst

PeepHoleOpt::Changed PeepHoleOpt::handleInst(Inst* inst)
{
    PeepHoleOpt::Changed temp;

    // Local propagation
    Inst::Opnds opnds(inst, Inst::OpndRole_All);
    
    for (Inst::Opnds::iterator it=opnds.begin();it != opnds.end();it = opnds.next(it)) {
        Opnd * opnd=inst->getOpnd(it);
        U_32 roles=inst->getOpndRoles(it);
                
        if (roles & Inst::OpndRole_Use) {
            if ((roles & Inst::OpndRole_All & Inst::OpndRole_FromEncoder) 
                && (roles & Inst::OpndRole_All & Inst::OpndRole_ForIterator)
                && (roles & Inst::OpndRole_Changeable) && ((roles & Inst::OpndRole_Def) == 0)
                && copyMap->has(opnd)) {
                if (opnd->getType()->isUnmanagedPtr() && (*copyMap)[opnd]->getType()->isInteger())
                    (*copyMap)[opnd]->setType(opnd->getType());
                inst->setOpnd(it, (*copyMap)[opnd]);
            }
        }
    }

    for (Inst::Opnds::iterator it = opnds.begin();it != opnds.end();it = opnds.next(it)) {
        Opnd * opnd=inst->getOpnd(it);
        U_32 roles=inst->getOpndRoles(it);

        if (roles & Inst::OpndRole_Def) {
            if (copyMap->has(opnd)) {
            	if (Log::isEnabled()) Log::out()<<"copy relation DELETED: " << opnd->getFirstId() << "<=" << (*copyMap)[opnd]->getFirstId() <<std::endl;
                copyMap->erase(opnd);
            }

            tempSet->clear();
            for(StlHashMap<Opnd*, Opnd*>::iterator iter=copyMap->begin();
                iter!=copyMap->end();++iter)
                if (iter->second == opnd) {
                    if (Log::isEnabled()) Log::out()<<"copy relation DELETED: " << iter->first->getFirstId() << "<=" << iter->second->getFirstId() <<std::endl;
                    tempSet->insert(iter->first);
                }
            for(StlSet<Opnd*>::iterator iter=tempSet->begin();
                iter!=tempSet->end();++iter)
                copyMap->erase(*iter);
        }
    }

    if (inst->getMnemonic() == Mnemonic_MOV) {
        Inst::Opnds opnds(inst, Inst::OpndRole_All);
        Opnd * dst = NULL;
        Opnd * src = NULL;
        U_32 counterDef = 0;
        U_32 counterUse = 0;

        for (Inst::Opnds::iterator it=opnds.begin();it!=opnds.end();it=opnds.next(it)) {
            Opnd * opnd = inst->getOpnd(it);
            U_32 roles = inst->getOpndRoles(it);
                    
            if (roles & Inst::OpndRole_Def) {
                counterDef++;
                dst = opnd;
            } else if (roles & Inst::OpndRole_Use) {
                counterUse++;
                src = opnd;
            }
        }

        if ((counterDef == 1) && (counterUse == 1) && (!dst->hasAssignedPhysicalLocation())) {
            bool kindsAreOk = true;
            if(src->canBePlacedIn(OpndKind_FPReg) || dst->canBePlacedIn(OpndKind_FPReg)) {
                Constraint srcConstr = src->getConstraint(Opnd::ConstraintKind_Calculated);
                Constraint dstConstr = dst->getConstraint(Opnd::ConstraintKind_Calculated);
                kindsAreOk = ! (srcConstr&dstConstr).isNull();
            }
            bool typeConvOk = src->getSize() == dst->getSize() && isTypeConversionAllowed(src, dst);
            if (typeConvOk && kindsAreOk && ! src->isPlacedIn(OpndKind_Reg)) {
                if (copyMap->has(src)) {
                    (*copyMap)[dst] = (*copyMap)[src];
                    if (Log::isEnabled()) Log::out()<<"copy relation INSERTED: " << dst->getFirstId() << "<=" << (*copyMap)[src]->getFirstId() <<std::endl;
                } else {
                    (*copyMap)[dst] = src;
                    if (Log::isEnabled()) Log::out()<<"copy relation INSERTED: " << dst->getFirstId() << "<=" << src->getFirstId() <<std::endl;
                }
            }
        }
    }
            
    if (inst->hasKind(Inst::Kind_PseudoInst) && inst->getKind() != Inst::Kind_CopyPseudoInst) {
        return Changed_Nothing;
    }

    Mnemonic mnemonic = inst->getMnemonic();
    switch(mnemonic) {
    case Mnemonic_MOV:
        return handleInst_MOV(inst);
    case Mnemonic_CALL:
        return handleInst_Call(inst);
    case Mnemonic_ADD:
    case Mnemonic_ADC:
    case Mnemonic_SUB:
    case Mnemonic_SBB:
//.........这里部分代码省略.........
开发者ID:unitedroad,项目名称:harmony-for-haiku,代码行数:101,代码来源:Ia32PeepHole.cpp


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