Beispiel #1
0
static void Infer(IMODE *ans, IMODE *reg, ALIASLIST *pointsto)
{
    if (pointsto)
    {
        ALIASLIST *result = NULL;
        int c = InferOffset(reg);
        int l = InferStride(reg);
        BOOL xchanged = changed;
        while (pointsto)
        {
            ALIASADDRESS *addr = LookupAddress(pointsto->address->name, pointsto->address->offset + c);
            ALIASLIST *al = aAlloc(sizeof(ALIASLIST));
            al->address = addr;
            AliasUnion(&result, al);
            SetStride(pointsto->address, l);
            pointsto = pointsto->next;
        }
        changed = xchanged;
        AliasUnion(&tempInfo[ans->offset->v.sp->value.i]->pointsto, result);
    }
}
Beispiel #2
0
static int InferStride(IMODE *im)
{
    QUAD * q = tempInfo[im->offset->v.sp->value.i]->instructionDefines;
    if (q)
    {
        if (q->dc.opcode == i_lsl)
        {
            if ((q->temps & TEMP_LEFT) && q->dc.left->mode == i_direct)
            {
                if (q->dc.right->mode == i_immed && isintconst(q->dc.right->offset))
                    return 1 << q->dc.right->offset->v.i;
            }
        }
        else if (q->dc.opcode == i_mul || q->dc.opcode == i_add || q->dc.opcode == i_sub)
        {
            IMODE *one = q->dc.left;
            IMODE *two = q->dc.right;
            if (one->mode == i_immed && isintconst(one->offset))
            {
                IMODE *three = one;
                one = two;
                two = three;
            }
            if (one->mode == i_direct && one->offset->type == en_tempref)
            {
                if (two->mode == i_immed && isintconst(two->offset))
                {
                    if ( q->dc.opcode == i_add || q->dc.opcode == i_sub)
                        return InferStride(one);
                    return two->offset->v.i;
                }
            }
        }
    }
    return 1;
}