Exemplo n.º 1
0
//Remove given USE from occurence set.
void MDSSAInfo::removeUse(IR const* exp, IN UseDefMgr * usedefmgr)
{
    ASSERT0(exp && exp->is_exp() && usedefmgr);
    SEGIter * iter = NULL;
    for (INT i = getVOpndSet()->get_first(&iter);
         i >= 0; i = getVOpndSet()->get_next(i, &iter)) {
        VMD * vopnd = (VMD*)usedefmgr->getVOpnd(i);
        ASSERT0(vopnd && vopnd->is_md());
        vopnd->getOccSet()->diff(exp->id());
    }
}
Exemplo n.º 2
0
//Collect all USE, where USE is IR expression.
void MDSSAInfo::collectUse(
        OUT DefSBitSetCore & set,
        IN UseDefMgr * usedefmgr,
        IN DefMiscBitSetMgr * bsmgr)
{
    ASSERT0(usedefmgr && bsmgr);
    SEGIter * iter = NULL;
    Region * rg = usedefmgr->getRegion();
    for (INT i = getVOpndSet()->get_first(&iter);
         i >= 0; i = getVOpndSet()->get_next(i, &iter)) {
        VMD * vopnd = (VMD*)usedefmgr->getVOpnd(i);
        ASSERT0(vopnd && vopnd->is_md());

        SEGIter * vit = NULL;
        for (INT i2 = vopnd->getOccSet()->get_first(&vit);
            i2 >= 0; i2 = vopnd->getOccSet()->get_next(i2, &vit)) {
            IR * use = rg->getIR(i2);
            ASSERT0(use && (use->isMemoryRef() || use->is_id()));
            set.bunion(use->id(), *bsmgr);
        }
    }
}
Exemplo n.º 3
0
//
//START MDSSAInfo
//
//Return true if all definition of vopnd can reach 'exp'.
bool MDSSAInfo::isUseReachable(IN UseDefMgr * usedefmgr, IR const* exp)
{
    ASSERT0(usedefmgr && exp && exp->is_exp());
    SEGIter * iter = NULL;
    for (INT i = getVOpndSet()->get_first(&iter);
         i >= 0; i = getVOpndSet()->get_next(i, &iter)) {
        VMD * vopnd = (VMD*)usedefmgr->getVOpnd(i);
        ASSERT0(vopnd && vopnd->is_md());
        if (!vopnd->getOccSet()->is_contain(exp->id())) {
            return false;
        }
    }
    return true;
}
Exemplo n.º 4
0
void MDPhi::dump(Region * rg, UseDefMgr * mgr)
{
    ASSERT0(rg);
    ASSERT0(is_phi());
    if (g_tfile == NULL) { return; }

    List<IRBB*> preds;
    IR_CFG * cfg = rg->getCFG();
    ASSERT0(cfg);
    cfg->get_preds(preds, getBB());
    IRBB * pred = preds.get_head();

    ASSERT0(getResult());
    fprintf(g_tfile, "Phi: MD%dV%d <- ",
        getResult()->mdid(), getResult()->version());
    for (IR const* opnd = getOpndList(); opnd != NULL; opnd = opnd->get_next()) {
        if (opnd != getOpndList()) {
            fprintf(g_tfile, ", ");
        }

        switch (opnd->get_code()) {
        case IR_CONST:
            fprintf(g_tfile, "Const");
            break;
        case IR_LDA:
            fprintf(g_tfile, "Lda");
            break;
        case IR_ID:
            {
                VMD * vopnd = getOpndVMD(opnd, mgr);
                fprintf(g_tfile, "MD%dV%d(id:%d)",
                    vopnd->mdid(), vopnd->version(), opnd->id());
            }
            break;
        default: UNREACH();
        }

        ASSERT0(pred);
        fprintf(g_tfile, "(BB%d)", pred->id());
        pred = preds.get_next();
    }

    VMD * res = getResult();
    ASSERT0(res);
    fprintf(g_tfile, "|UsedBy:");
    SEGIter * vit = NULL;
    bool first = true;
    for (INT i2 = res->getOccSet()->get_first(&vit);
        i2 >= 0; i2 = res->getOccSet()->get_next(i2, &vit)) {
        if (first) {
            first = false;
        } else {
            fprintf(g_tfile, ",");
        }

        IR const* use = rg->getIR(i2);
        ASSERT0(use && (use->isMemoryRef() || use->is_id()));
        fprintf(g_tfile, "%s(id:%d)", IRNAME(use), use->id());
    }

    fflush(g_tfile);
}