diff options
| author | 2025-09-08 22:05:33 +0200 | |
|---|---|---|
| committer | 2025-09-08 22:05:33 +0200 | |
| commit | e043811980db560fc2507bb53b644e54c80527dc (patch) | |
| tree | 6ea563d81c9d3767f439e361fc2c884cf4f9b64d /ir.c | |
| parent | 36b5b19bf183cb01525201ccbddd6afa692f21bb (diff) | |
regalloc: start implementing linear scan
Diffstat (limited to 'ir.c')
| -rw-r--r-- | ir.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1,5 +1,4 @@ #include "ir.h" -#include "endian.h" #include "obj.h" uchar type2cls[NTYPETAG]; @@ -13,6 +12,13 @@ const char *opnames[] = { #undef _ }; +const uchar opnarg[] = { + 0, +#define _(o,n) n, +#include "op.def" +#undef _ +}; + struct instr instrtab[MAXINSTR]; struct use *instruse[MAXINSTR]; short instrnuse[MAXINSTR]; @@ -362,6 +368,17 @@ insertphi(struct block *blk, enum irclass cls) return mkref(RTMP, new); } +void +numberinstrs(struct function *fn) +{ + struct block *blk = fn->entry; + int start = 0; + do { + blk->inumstart = start; + start += blk->ins.n+2; + } while ((blk = blk->lnext) != fn->entry); +} + /* require use */ void replcuses(union ref from, union ref to) @@ -387,7 +404,6 @@ replcuses(union ref from, union ref to) if (u[j].bits == from.bits) { u[j].bits = to.bits; adduse(use.blk, use.u, to); - deluse(use.blk, use.u, from); --i; break; } @@ -411,7 +427,7 @@ delinstr(struct block *blk, int idx) memcpy(&instrtab[t], &instrfreelist, sizeof(int)); instrfreelist = t; deluses(t); - for (int i = idx; i < blk->ins.n; ++i) + for (int i = idx; i < blk->ins.n-1; ++i) blk->ins.p[i] = blk->ins.p[i + 1]; --blk->ins.n; } |