Esempio n. 1
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);
        }
    }
}
Esempio n. 2
0
//
//START VMD
//
void VMD::dump(Region * rg, UseDefMgr * mgr)
{
    if (g_tfile == NULL) { return; }
    ASSERT0(is_md() && rg);
    fprintf(g_tfile, "(MD%dV%d", mdid(), version());

    //Dump Def
    if (getDef() != NULL) {
        ASSERT0(!getDef()->is_phi());

        if (getDef()->getPrev() != NULL) {
            fprintf(g_tfile, ",PrevDEF:MD%dV%d",
                getDef()->getPrev()->getResult()->mdid(),
                getDef()->getPrev()->getResult()->version());
        } else {
            fprintf(g_tfile, ",-");
        }

        if (getDef()->getNextSet() != NULL) {
            SEGIter * nit = NULL;
            bool first = true;
            for (INT w = getDef()->getNextSet()->get_first(&nit);
                w >= 0; w = getDef()->getNextSet()->get_next(w, &nit)) {
                if (first) {
                    first = false;
                } else {
                    fprintf(g_tfile, ",");
                }

                MDDef const* use = mgr->getMDDef(w);
                ASSERT(use, ("not such MDDef"));
                ASSERT0(use->getResult());
                ASSERT(use->getPrev() == getDef(), ("insanity relation"));
                fprintf(g_tfile, ",NextDEF:MD%dV%d",
                    use->getResult()->mdid(), use->getResult()->version());
                }
        }
    } else {
        fprintf(g_tfile, ",-");
    }
    fprintf(g_tfile, ")");

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

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

    fflush(g_tfile);
}