Exemplo n.º 1
0
void reflowConditional(BLOCK *src, BLOCK *dst)
{
    BLOCKLIST *bl, *bl1 = src->succ;
    BLOCKLIST temp;
    BRIGGS_SET *bls = briggsAlloc(blockCount);
    int i;
    temp.block = dst;
    temp.next = NULL;
    src->succ = &temp;
    for (i=0; i < blockCount; i++)
        if (blockArray[i])
            blockArray[i]->temp = FALSE;
    removeMark(bls, blockArray[0]);
    for (i=1; i < blockCount; i++)
        if (blockArray[i] && blockArray[i]->alwayslive)
            removeMark(bls, blockArray[i]);
    src->succ = bl1;
    for (i=0; i < blockCount; i++)
        if (blockArray[i])
            blockArray[i]->temp = FALSE;
    bl = bl1;
    while (bl)
    {
        if (bl->block != dst)
            removeDeadBlocks(bls, src, bl->block);
        bl = bl->next;
    }
    if (dst->critical)
    {
        BLOCK *crit = dst;
        BLOCKLIST *bl = crit->succ->block->pred;
        while (bl)
        {
            if (bl->block == crit)
            {
                bl->block = src;
                break;
            }
            bl = bl->next;
        }
        dst = crit->succ->block;
        crit->succ = crit->pred = NULL;
        blockArray[crit->blocknum] = NULL;	
    }
    src->succ->block = dst;
    src->succ->next = NULL;
}
Exemplo n.º 2
0
static void removeDeadBlocks(BRIGGS_SET *brs, BLOCK *back, BLOCK *b)
{
    if (b->temp)
        return;
    b->temp = TRUE;
    if (!briggsTest(brs, b->blocknum) && b->blocknum != exitBlock)
    {
        BLOCKLIST *bl2 = b->succ;
        while (bl2)
        {
            removeDeadBlocks(brs, b, bl2->block);
            if (!bl2->block->dead)
            {
                BLOCKLIST **bl3 = &bl2->block->pred;
                int n = 0;
                while (*bl3)
                {
                    if ((*bl3)->block == b)
                    {
                        QUAD *head = bl2->block->head->fwd;
                        *bl3 = (*bl3)->next;
                        while (head != bl2->block->tail->fwd && (head->dc.opcode == i_label ||
                               head->ignoreMe))
                        {
                            head = head->fwd;
                        }
                        while (head->dc.opcode == i_phi && head != bl2->block->tail->fwd)
                        {
                            PHIDATA *pd = head->dc.v.phi;
                            struct _phiblock **pb = &pd->temps;
                            int i;
                            for (i=0; i < n; i++, pb = &(*pb)->next) ;
                            (*pb) = (*pb)->next;			
                            head = head->fwd;
                        }
                        break;
                    }
                    n++;
                    bl3 = &(*bl3)->next;
                }
            }
            bl2 = bl2->next;
        }
        b->head->fwd = b->tail->fwd;
        b->tail->fwd->back = b->head;
        b->tail = b->head;
        b->succ = b->pred = NULL;
        b->dead = TRUE;
        b->critical = FALSE;
        blockArray[b->blocknum] = NULL;
    }
    else
    {
        QUAD *head ;
        int n = 0;
        BLOCKLIST **bl = &b->pred;
        while (bl)
        {
            if ((*bl)->block == back)
            {
                *bl = (*bl)->next;
                break;
            }
            n++;
            bl = &(*bl)->next;
        }
        
        head = b->head->fwd;
        while (head != b->tail->fwd && (head->dc.opcode == i_label || 
               head->ignoreMe))
        {
            head = head->fwd;
        }
        while (head->dc.opcode == i_phi && head != b->tail->fwd)
        {
            PHIDATA *pd = head->dc.v.phi;
            struct _phiblock **pb = &pd->temps;
            int i;
            for (i=0; i < n; i++, pb = &(*pb)->next) ;
            (*pb) = (*pb)->next;			
            head = head->fwd;
        }
    }
}