diff options
author | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-08-22 20:15:47 -0400 |
---|---|---|
committer | Quentin Carbonneaux <quentin.carbonneaux@yale.edu> | 2015-09-15 23:01:32 -0400 |
commit | 2db68eed1297fdaabd1a5d513f03f17faf7b25b6 (patch) | |
tree | 96c356aeb278a7de04695448eef6cd2a036ce53d /lisc/rega.c | |
parent | 390c5addd6c59075066138547285c17a9d3f49d9 (diff) | |
download | roux-2db68eed1297fdaabd1a5d513f03f17faf7b25b6.tar.gz |
my assumptions in dopm() were wrong
revert commit d0e9e3ada106dfe8dcda7a0099b341000f00afb2.
Diffstat (limited to 'lisc/rega.c')
-rw-r--r-- | lisc/rega.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lisc/rega.c b/lisc/rega.c index 6d1d174..5d2b9f5 100644 --- a/lisc/rega.c +++ b/lisc/rega.c @@ -212,8 +212,8 @@ static Ins * dopm(Blk *b, Ins *i, RMap *m) { RMap m0; - int n, r, r1, t; - Ins *i1, *ip; + int n, r, r1, t, nins; + Ins *i1, *ib, *ip, *ir; m0 = *m; i1 = i+1; @@ -251,14 +251,22 @@ dopm(Blk *b, Ins *i, RMap *m) r = RBASE(ip->arg[0].val); if (rfind(m, r) == -1) radd(m, r, r); - *ip = (Ins){ONop, R, {R, R}}; } pmgen(); #ifdef TEST_PMOV return 0; #endif - assert(curi-insb <= i1-i); - return memcpy(i, insb, (curi-insb) * sizeof(Ins)); + nins = curi-insb; + ib = alloc((b->nins + nins - (i1-i)) * sizeof(Ins)); + memcpy(ip = ib, b->ins, (i - b->ins) * sizeof(Ins)); + ip += i - b->ins; + memcpy(ir = ip, insb, nins * sizeof(Ins)); + ip += nins; + memcpy(ip, i1, (&b->ins[b->nins] - i1) * sizeof(Ins)); + b->nins += nins - (i1-i); + free(b->ins); + b->ins = ib; + return ir; } /* register allocation |