Ejemplo n.º 1
0
void QpTree::makeQpTree(InstVector &insts) {
    
    IPF_ASSERT(qpMap.size() == 1);
    
    slot = 1;                                                  // init slot (position in mask)
    for (InstVector::iterator it=insts.begin(); it!=insts.end(); it++) {
        Inst *inst = *it;                                      // iterate insts

        if (isDefOnePred(inst)) {                              // if inst defs one predicate opnd
            OpndVector &opnds = inst->getOpnds();              // get opnds of the inst
            QpNode     *qpNode = findQpNode(opnds[0]);         // inst qp is predecessor for predicates defined in the inst
            makeQpNode(qpNode, opnds[2]);                      // make qpNode for the predicate opnd (it is always second one)
            continue;
        }

        if (isDefTwoPreds(inst)) {                             // if inst defs two predicate opnds
            OpndVector &opnds = inst->getOpnds();              // get opnds of the inst
            QpNode     *qpNode = findQpNode(opnds[0]);         // inst qp is predecessor for predicates defined in the inst
            QpNode     *p1Node = makeQpNode(qpNode, opnds[1]); // make qpNode for first predicate opnd
            QpNode     *p2Node = makeQpNode(qpNode, opnds[2]); // make qpNode for second predicate opnd
            
            if (isDefComps(inst) == false) continue;           // inst does not define mutually complemen predicates - continue
            if (p1Node != NULL) p1Node->setCompNode(p2Node);   // p2Node complements p1Node
            if (p2Node != NULL) p2Node->setCompNode(p1Node);   // p1Node complements p2Node
        }
    }    

    for (QpMap::iterator it=qpMap.begin(); it!=qpMap.end(); it++) {
        QpNode *qpNode = it->second;                           // iterate all qpNodes in the tree
        qpNode->initCompMask();                                // set comp mask (to speed up getCompMask)
    }

    for (QpMap::iterator it=qpMap.begin(); it!=qpMap.end(); it++) {
        QpNode *qpNode = it->second;                           // iterate all qpNodes in the tree
        qpNode->initLiveMask();                                // set live masks (predicate spaces which do not complement)
    }
}