diff options
-rw-r--r-- | lisc/lisc.h | 3 | ||||
-rw-r--r-- | lisc/parse.c | 23 | ||||
-rw-r--r-- | lisc/rega.c | 2 | ||||
-rw-r--r-- | lisc/util.c | 2 |
4 files changed, 11 insertions, 19 deletions
diff --git a/lisc/lisc.h b/lisc/lisc.h index 5702182..3b43d47 100644 --- a/lisc/lisc.h +++ b/lisc/lisc.h @@ -78,7 +78,6 @@ enum Reg { enum { NString = 32, NPred = 15, - NBlk = 128, NIns = 256, NAlign = 3, NSeg = 32, @@ -467,7 +466,7 @@ void diag(char *); void *emalloc(size_t); void *alloc(size_t); void freeall(void); -Blk *bnew(void); +Blk *blknew(void); void emit(int, int, Ref, Ref, Ref); void emiti(Ins); void idup(Ins **, Ins *, ulong); diff --git a/lisc/parse.c b/lisc/parse.c index 7798dcd..113ea9f 100644 --- a/lisc/parse.c +++ b/lisc/parse.c @@ -133,7 +133,7 @@ static Con *con; static int ntmp; static int ncon; static Phi **plink; -static Blk *bmap[NBlk+1]; +static Blk **bmap; static Blk *curb; static Blk **blink; static int nblk; @@ -466,17 +466,12 @@ findblk(char *name) { int i; - assert(name[0]); - for (i=0; i<NBlk; i++) - if (!bmap[i] || strcmp(bmap[i]->name, name) == 0) - break; - if (i == NBlk) - err("too many blocks"); - if (!bmap[i]) { - bmap[i] = bnew(); - nblk++; - strcpy(bmap[i]->name, name); - } + for (i=0; i<nblk; i++) + if (strcmp(bmap[i]->name, name) == 0) + return bmap[i]; + vgrow(&bmap, ++nblk); + bmap[i] = blknew(); + strcpy(bmap[i]->name, name); return bmap[i]; } @@ -640,7 +635,6 @@ DoOp: static Fn * parsefn() { - int i; PState ps; Fn *fn; @@ -651,11 +645,10 @@ parsefn() curi = insb; tmp = vnew(ntmp, sizeof tmp[0]); con = vnew(ncon, sizeof con[0]); + bmap = vnew(nblk, sizeof bmap[0]); con[0].type = CBits; fn = alloc(sizeof *fn); blink = &fn->start; - for (i=0; i<NBlk; i++) - bmap[i] = 0; if (peek() != TGlo) rcls = parsecls(&fn->retty); else diff --git a/lisc/rega.c b/lisc/rega.c index 5e10451..b50321c 100644 --- a/lisc/rega.c +++ b/lisc/rega.c @@ -564,7 +564,7 @@ rega(Fn *fn) pmgen(); if (curi == insb) continue; - b1 = bnew(); + b1 = blknew(); b1->loop = (b->loop+s->loop) / 2; b1->link = blist; blist = b1; diff --git a/lisc/util.c b/lisc/util.c index 58c9b7d..cccbcf6 100644 --- a/lisc/util.c +++ b/lisc/util.c @@ -81,7 +81,7 @@ freeall() } Blk * -bnew() +blknew() { static Blk z; Blk *b; |