From: ceriel Date: Mon, 17 Dec 1990 10:02:52 +0000 (+0000) Subject: Fixed problem with cost computation, added some assertions and X-Git-Tag: release-5-5~1342 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=41dc11e497c5603033700206ddef6675244ab201;p=ack.git Fixed problem with cost computation, added some assertions and added some more precise debugging printing --- diff --git a/mach/proto/ncg/codegen.c b/mach/proto/ncg/codegen.c index cffb11a8b..0a0bc3189 100644 --- a/mach/proto/ncg/codegen.c +++ b/mach/proto/ncg/codegen.c @@ -71,6 +71,7 @@ unsigned codegen(codep,ply,toplevel,costlimit,forced) byte *codep; unsigned cost #endif #ifndef NDEBUG + assert(costlimit <= INFINITY); level++; DEBUG("Entering codegen"); if (Debug > 1) fprintf(stderr, "toplevel = %d\n", toplevel); @@ -195,6 +196,7 @@ if (Debug) */ SAVEST; mincost = costlimit-totalcost+1; + assert(mincost <= INFINITY); for(i=0;ip_rar[i]); + assert(totalcost <= costlimit); myfree((string)besttup); break; } @@ -455,7 +458,7 @@ normalfailed: if (stackpad!=tokpatlen) { int doremove = (codep[-1] & 037) == DO_REMOVE; extern int allsetno; - DEBUG("REMOVE"); + DEBUG(doremove ? "REMOVE" : "TOSTACK"); if (codep[-1]&32) { getint(texpno,codep); getint(nodeno,codep); @@ -477,10 +480,15 @@ normalfailed: if (stackpad!=tokpatlen) { CHKCOST(); break; } - if (doremove) for (rp=machregs;rpr_contents.t_token != 0 && - match(&rp->r_contents,&machsets[texpno],nodeno)) + match(&rp->r_contents,&machsets[texpno],nodeno)) { +#ifndef NDEBUG + if (Debug > 1) fprintf(stderr, "killing reg %ld (%s)\n", (long)(rp-machregs), rp->r_repr ? codestrings[rp->r_repr] : "cc"); +#endif rp->r_contents.t_token=0; + } + } break; } case DO_KILLREG: @@ -492,7 +500,7 @@ normalfailed: if (stackpad!=tokpatlen) { result_t result; int dokill = (codep[-1] & 037) == DO_KILLREG; - DEBUG("RREMOVE"); + DEBUG(dokill ? "KILLREG" : "RREMOVE"); getint(nodeno,codep); result=compute(&enodes[nodeno]); if (result.e_typ!=EV_REG) @@ -718,6 +726,7 @@ normalfailed: if (stackpad!=tokpatlen) { } if (toplevel) gennl(); + CHKCOST(); break; } case DO_MOVE: {