Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.88
 
1.89
 
MAIN:ragge:20040507164935
 
reader.c
_>200200                 delay(p->n_left);
 201201 }
 202202 
<> 203+/*
  204+ * Check if a node has side effects.
  205+ */
  206+static int
  207+isuseless(NODE *n)
  208+{
  209+        switch (n->n_op) {
  210+        case FUNARG:
  211+        case UCALL:
  212+        case UFORTCALL:
  213+        case FORCE:
  214+        case INIT:
  215+        case ASSIGN:
  216+        case INCR:
  217+        case DECR:
  218+        case CALL:
  219+        case FORTCALL:
  220+        case CBRANCH:
  221+        case RETURN:
  222+        case GOTO:
  223+        case STCALL:
  224+        case USTCALL:
  225+        case STASG:
  226+        case STARG:
  227+                return 0;
  228+        default:
  229+                return 1;
  230+        }
  231+}
  232+
  233+static NODE *
  234+deluseless(NODE *p)
  235+{
  236+        struct interpass *ip;
  237+        NODE *l, *r;
  238+
  239+        if (optype(p->n_op) == LTYPE) {
  240+                nfree(p);
  241+                return NULL;
  242+        }
  243+        if (isuseless(p) == 0)
  244+                return p;
  245+
  246+        if (optype(p->n_op) == UTYPE) {
  247+                l = p->n_left;
  248+                nfree(p);
  249+                return deluseless(l);
  250+        }
  251+
  252+        /* Be sure that both leaves may be valid */
  253+        l = deluseless(p->n_left);
  254+        r = deluseless(p->n_right);
  255+        nfree(p);
  256+        if (l && r) {
  257+                /* Put left on queue first */
  258+                ip = tmpalloc(sizeof(*ip));
  259+                ip->type = IP_NODE;
  260+                ip->lineno = 0; /* XXX */
  261+                ip->ip_node = l;
  262+                pass2_compile(ip);
  263+                return r;
  264+        } else if (l)
  265+                return l;
  266+        else if (r)
  267+                return r;
  268+        return NULL;
  269+}
  270+
203271 static void newblock(int myreg, int aoff);
 204272 static void epilogue(int regs, int autos, int retlab);
 205273 
 206274 void
 207275 pass2_compile(struct interpass *ip)
 208276 {
<> 277+        if (ip->type == IP_NODE) {
  278+                ip->ip_node = deluseless(ip->ip_node);
  279+                if (ip->ip_node == NULL)
  280+                        return;
  281+        }
209282         if (Oflag) {
 210283                 if (ip->type == IP_PROLOG)
 211284                         saving++;
     
 !
11091182                         return;
 11101183                 if (ip->type != IP_NODE)
 11111184                         continue;
<> 1185+                n = ip->sqelem.sqe_next;
  1186+                /* Check for nodes without side effects */
11121187                 if (ip->ip_node->n_op != GOTO)
 11131188                         continue;
<>1114 -                n = ip->sqelem.sqe_next;
<_11151189                 switch (n->type) {
 11161190                 case IP_NODE:
 11171191                         tfree(n->ip_node);
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-08-31 02:15 +0200