Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.57
 
1.58
 
MAIN:ragge:20081116211741
 
optim2.c
_>6666 void placePhiFunctions(struct p2env *, struct bblockinfo *bbinfo);
 6767 void remunreach(struct p2env *);
 6868 
<>69 -#if 0
 70 -struct basicblock bblocks;
 71 -int nbblocks;
 72 -#endif
 73 -static struct interpass *cvpole;
 74 -
 75 -struct addrof {
 76 -        struct addrof *next;
 77 -        int tempnum;
 78 -        int oregoff;
 79 -} *otlink;
 80 -
 81 -static int
 82 -getoff(int num)
 83 -{
 84 -        struct addrof *w;
 85 -
 86 -        for (w = otlink; w; w = w->next)
 87 -                if (w->tempnum == num)
 88 -                        return w->oregoff;
 89 -        return 0;
 90 -}
 91 -
 92 -/*
 93 - * Use stack argument addresses instead of copying if & is used on a var.
 94 - */
 95 -static int
 96 -setargs(int tval, struct addrof *w)
 97 -{
 98 -        struct interpass *ip;
 99 -        NODE *p;
 100 -
 101 -        ip = DLIST_NEXT(cvpole, qelem); /* PROLOG */
 102 -        ip = DLIST_NEXT(ip, qelem); /* first DEFLAB */
 103 -        ip = DLIST_NEXT(ip, qelem); /* first NODE */
 104 -        for (; ip->type != IP_DEFLAB; ip = DLIST_NEXT(ip, qelem)) {
 105 -                p = ip->ip_node;
 106 -#ifdef PCC_DEBUG
 107 -                if (p->n_op != ASSIGN || p->n_left->n_op != TEMP)
 108 -                        comperr("temparg");
 109 -#endif
 110 -                if (p->n_right->n_op != OREG)
 111 -                        continue; /* arg in register */
 112 -                if (tval != regno(p->n_left))
 113 -                        continue; /* wrong assign */
 114 -                w->oregoff = p->n_right->n_lval;
 115 -                tfree(p);
 116 -                DLIST_REMOVE(ip, qelem);
 117 -                return 1;
 118 -        }
 119 -        return 0;
 120 -}
 121 -
 122 -/*
 123 - * Search for ADDROF elements and, if found, record them.
 124 - */
 125 -static void
 126 -findaddrof(NODE *p, void *arg)
 127 -{
 128 -        struct addrof *w;
 129 -        int tnr;
 130 -
 131 -        if (p->n_op != ADDROF)
 132 -                return;
 133 -        tnr = regno(p->n_left);
 134 -        if (getoff(tnr))
 135 -                return;
 136 -        w = tmpalloc(sizeof(struct addrof));
 137 -        w->tempnum = tnr;
 138 -        if (setargs(tnr, w) == 0)
 139 -                w->oregoff = BITOOR(freetemp(szty(p->n_left->n_type)));
 140 -        w->next = otlink;
 141 -        otlink = w;
 142 -}
 143 -
 144 -
 145 -/*
 146 - * Convert address-taken temps to OREGs.
 147 - */
 148 -static void
 149 -cvtaddrof(NODE *p, void *arg)
 150 -{
 151 -        NODE *l;
 152 -        int n;
 153 -
 154 -        if (p->n_op != ADDROF && p->n_op != TEMP)
 155 -                return;
 156 -        if (p->n_op == TEMP) {
 157 -                n = getoff(regno(p));
 158 -                if (n == 0)
 159 -                        return;
 160 -                p->n_op = OREG;
 161 -                p->n_lval = n;
 162 -                regno(p) = FPREG;
 163 -        } else {
 164 -                l = p->n_left;
 165 -                l->n_type = p->n_type;
 166 -                p->n_right = mklnode(ICON, l->n_lval, 0, l->n_type);
 167 -                p->n_op = PLUS;
 168 -                l->n_op = REG;
 169 -                l->n_lval = 0;
 170 -                l->n_rval = FPREG;
 171 -        }
 172 -}
 173 -
17469 void
 17570 optimize(struct p2env *p2e)
 17671 {
 17772         struct interpass *ipole = &p2e->ipole;
<>178 -        struct interpass *ip;
17973         struct labelinfo labinfo;
 18074         struct bblockinfo bbinfo;
 18175 
     
 !
18478                 printip(ipole);
 18579         }
 18680 
<>187 -        /*
 188 -         * Convert ADDROF TEMP to OREGs.
 189 -         */
 190 -        if (xtemps) {
 191 -                otlink = NULL;
 192 -                cvpole = ipole;
 193 -                DLIST_FOREACH(ip, ipole, qelem) {
 194 -                        if (ip->type != IP_NODE)
 195 -                                continue;
 196 -                        walkf(ip->ip_node, findaddrof, 0);
 197 -                }
 198 -                if (otlink) {
 199 -                        DLIST_FOREACH(ip, ipole, qelem) {
 200 -                                if (ip->type != IP_NODE)
 201 -                                        continue;
 202 -                                walkf(ip->ip_node, cvtaddrof, 0);
 203 -                        }
 204 -                }
 205 -        }
 206 -                
<_20781         if (xdeljumps)
 20882                 deljumps(p2e); /* Delete redundant jumps and dead code */
 20983 
FishEye: Open Source License registered to PCC.
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-12-21 17:34 +0100