Annotation of researchv10no/cmd/ccom/common/prepass.c, revision 1.1.1.1

1.1       root        1: /* prepass tries to turn the trees into basic blocks */
                      2: /* eventually this is where p2compile will be */
                      3: #include "mfile2.h"
                      4: NODE *dup(), *chng1(), *seq(), *buildtree(), *dlabel();
                      5: 
                      6: NODE *
                      7: prepass(p)
                      8: NODE *p;
                      9: {      int o;
                     10:        NODE *r, *l;
                     11:        if(!p)
                     12:                return(p);
                     13:        o = p->in.op;
                     14:        if(o == ASSIGN && (r = p->in.right)->in.op == QUEST) {
                     15:                if((l = p->in.left)->in.op == SNODE || l->in.op == RNODE)
                     16:                        return(p);
                     17:                p = chng1(p);
                     18:        }
                     19:        return(p);              
                     20: }
                     21: /* =(x ?(t :(a b))) -> (cbranch t l0), l0(jbr l1 =(x a)), l1(=(x b) */
                     22: NODE *
                     23: chng1(p)
                     24: NODE *p;
                     25: {      NODE *t, *a, *b, *x, *c1, *c2, *u, *v;
                     26:        int l0, l1;
                     27:        t = p->in.right->in.left;
                     28:        a = p->in.right->in.right->in.left;
                     29:        b = p->in.right->in.right->in.right;
                     30:        x = p->in.left;
                     31:        l0 = getlab();
                     32:        l1 = getlab();
                     33:        u = dup(p);
                     34:        u->in.left = dup(x);
                     35:        u->in.right = b;
                     36:        v = dup(p);
                     37:        v->in.left = dup(x);
                     38:        v->in.right = a;
                     39:        c2 = seq(dlabel(genbr(0, l1, v), l0), dlabel(u, l1));
                     40:        c1 = seq(buildtree(CBRANCH, t, bcon(l0)), c2);
                     41:        p->in.op = x->in.op = FREE;
                     42:        p->in.right->in.op = p->in.right->in.right->in.op = FREE;
                     43:        return(c1);
                     44: }
                     45: 
                     46: NODE *
                     47: dup(p)
                     48: NODE *p;
                     49: {      NODE *t;
                     50:        t = talloc();
                     51:        *t = *p;
                     52:        return(t);
                     53: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.