Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.62
 
1.63
 
MAIN:pantzer:20090105231822
 
optim2.c
_>6969 void removephi(struct p2env *p2e, struct labelinfo *,struct bblockinfo *bbinfo);
 7070 void remunreach(struct p2env *);
 7171 
<> 72+#ifdef PCC_DEBUG
  73+void printflowdiagram(struct p2env *,struct labelinfo *labinfo,struct bblockinfo *bbinfo,char *);
  74+#endif
  75+
7276 void
 7377 optimize(struct p2env *p2e)
 7478 {
     
 !
9599                 bblocks_build(p2e, &labinfo, &bbinfo);
 96100                 BDEBUG(("Calling cfg_build\n"));
 97101                 cfg_build(p2e, &labinfo);
<> 102+        
  103+#ifdef PCC_DEBUG
  104+                printflowdiagram(p2e, &labinfo, &bbinfo,"first");
  105+#endif
98106         }
 99107         if (xssaflag) {
 100108                 BDEBUG(("Calling dominators\n"));
     
 !
116124 
 117125                 BDEBUG(("Calling removephi\n"));
 118126 
<> 127+#ifdef PCC_DEBUG
  128+                printflowdiagram(p2e, &labinfo, &bbinfo,"ssa");
  129+#endif
  130+
119131                 removephi(p2e,&labinfo,&bbinfo);
 120132 
 121133                 BDEBUG(("Calling remunreach\n"));
     
 !
132144                 cfg_build(p2e, &labinfo);
 133145 
 134146 #ifdef PCC_DEBUG
<> 147+                printflowdiagram(p2e, &labinfo, &bbinfo,"no_phi");
  148+
135149                 if (b2debug) {
 136150                         printf("new tree\n");
 137151                         printip(ipole);
     
 !
11971211                 }
 11981212         }
 11991213 }
<_ 1214+
  1215+#ifdef PCC_DEBUG
  1216+void flownodeprint(NODE *p,FILE *flowdiagramfile);
  1217+
  1218+void
  1219+flownodeprint(NODE *p,FILE *flowdiagramfile)
  1220+{       
  1221+        int opty;
  1222+        char *o;
  1223+
  1224+        fprintf(flowdiagramfile,"{");
  1225+
  1226+        o=opst[p->n_op];
  1227+        
  1228+        while (*o != 0) {
  1229+                if (*o=='<' || *o=='>')
  1230+                        fputc('\\',flowdiagramfile);
  1231+                
  1232+                fputc(*o,flowdiagramfile);
  1233+                o++;
  1234+        }
  1235+        
  1236+        
  1237+        switch( p->n_op ) {                     
  1238+                case REG:
  1239+                        fprintf(flowdiagramfile, " %s", rnames[p->n_rval] );
  1240+                        break;
  1241+                        
  1242+                case TEMP:
  1243+                        fprintf(flowdiagramfile, " %d", regno(p));
  1244+                        break;
  1245+                        
  1246+                case XASM:
  1247+                case XARG:
  1248+                        fprintf(flowdiagramfile, " '%s'", p->n_name);
  1249+                        break;
  1250+                        
  1251+                case ICON:
  1252+                case NAME:
  1253+                case OREG:
  1254+                        fprintf(flowdiagramfile, " " );
  1255+                        adrput(flowdiagramfile, p );
  1256+                        break;
  1257+                        
  1258+                case STCALL:
  1259+                case USTCALL:
  1260+                case STARG:
  1261+                case STASG:
  1262+                        fprintf(flowdiagramfile, " size=%d", p->n_stsize );
  1263+                        fprintf(flowdiagramfile, " align=%d", p->n_stalign );
  1264+                        break;
  1265+        }
  1266+        
  1267+        opty = optype(p->n_op);
  1268+        
  1269+        if (opty != LTYPE) {
  1270+                fprintf(flowdiagramfile,"| {");
  1271+        
  1272+                flownodeprint(p->n_left,flowdiagramfile);
  1273+        
  1274+                if (opty == BITYPE) {
  1275+                        fprintf(flowdiagramfile,"|");
  1276+                        flownodeprint(p->n_right,flowdiagramfile);
  1277+                }
  1278+                fprintf(flowdiagramfile,"}");
  1279+        }
  1280+        
  1281+        fprintf(flowdiagramfile,"}");
  1282+}
  1283+
  1284+void printflowdiagram(struct p2env *p2e,struct labelinfo *labinfo,struct bblockinfo *bbinfo,char *type) {
  1285+        struct basicblock *bbb;
  1286+        struct cfgnode *ccnode;
  1287+        struct interpass *ip;
  1288+        struct interpass_prolog *plg;
  1289+        struct phiinfo *phi;
  1290+        char *name;
  1291+        char *filename;
  1292+        int filenamesize;
  1293+        char *ext=".dot";
  1294+        FILE *flowdiagramfile;
  1295+        
  1296+        if (!g2debug)
  1297+                return;
  1298+        
  1299+        bbb=DLIST_NEXT(&p2e->bblocks, bbelem);
  1300+        ip=bbb->first;
  1301+
  1302+        if (ip->type != IP_PROLOG)
  1303+                return;
  1304+        plg = (struct interpass_prolog *)ip;
  1305+
  1306+        name=plg->ipp_name;
  1307+        
  1308+        filenamesize=strlen(name)+1+strlen(type)+strlen(ext)+1;
  1309+        filename=tmpalloc(filenamesize);
  1310+        snprintf(filename,filenamesize,"%s-%s%s",name,type,ext);
  1311+        
  1312+        flowdiagramfile=fopen(filename,"w");
  1313+        
  1314+        fprintf(flowdiagramfile,"digraph {\n");
  1315+        fprintf(flowdiagramfile,"rankdir=LR\n");
  1316+        
  1317+        DLIST_FOREACH(bbb, &p2e->bblocks, bbelem) {
  1318+                ip=bbb->first;
  1319+                
  1320+                fprintf(flowdiagramfile,"bb%p [shape=record ",bbb);
  1321+                
  1322+                if (ip->type==IP_PROLOG)
  1323+                        fprintf(flowdiagramfile,"root ");
  1324+
  1325+                fprintf(flowdiagramfile,"label=\"");
  1326+                
  1327+                SLIST_FOREACH(phi,&bbb->phi,phielem) {
  1328+                        fprintf(flowdiagramfile,"Phi %d|",phi->tmpregno);
  1329+                }               
  1330+                
  1331+                
  1332+                while (1) {
  1333+                        switch (ip->type) {
  1334+                                case IP_NODE:
  1335+                                        flownodeprint(ip->ip_node,flowdiagramfile);
  1336+                                        break;
  1337+                                        
  1338+                                case IP_DEFLAB:
  1339+                                        fprintf(flowdiagramfile,"Label: %d", ip->ip_lbl);
  1340+                                        break;
  1341+                                        
  1342+                                case IP_PROLOG:
  1343+                                        plg = (struct interpass_prolog *)ip;
  1344+        
  1345+                                        fprintf(flowdiagramfile,"%s %s",plg->ipp_name,type);
  1346+                                        break;
  1347+                        }
  1348+                        
  1349+                        fprintf(flowdiagramfile,"|");
  1350+                        fprintf(flowdiagramfile,"|");
  1351+                        
  1352+                        if (ip==bbb->last)
  1353+                                break;
  1354+                        
  1355+                        ip = DLIST_NEXT(ip, qelem);
  1356+                }
  1357+                fprintf(flowdiagramfile,"\"]\n");
  1358+                
  1359+                SLIST_FOREACH(ccnode, &bbb->children, cfgelem) {
  1360+                        char *color="black";
  1361+                        struct interpass *pip=bbb->last;
  1362+
  1363+                        if (pip->type == IP_NODE && pip->ip_node->n_op == CBRANCH) {
  1364+                                int label=pip->ip_node->n_right->n_lval;
  1365+                                
  1366+                                if (ccnode->bblock==labinfo->arr[label - p2e->ipp->ip_lblnum])
  1367+                                        color="red";
  1368+                        }
  1369+                        
  1370+                        fprintf(flowdiagramfile,"bb%p -> bb%p [color=%s]\n", bbb,ccnode->bblock,color);
  1371+                }
  1372+        }
  1373+        
  1374+        fprintf(flowdiagramfile,"}\n");
  1375+        fclose(flowdiagramfile);
  1376+}
  1377+#endif
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-09-21 10:10 +0200