aboutsummaryrefslogtreecommitdiffhomepage
path: root/regalloc.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-20 09:45:26 +0200
committerlemon <lsof@mailbox.org>2023-06-20 09:45:26 +0200
commit945d17aff2aa92dd1fbb0304d4ee7ab5ea6ce496 (patch)
treebb63bc06b372058d0931ef4a2ad915836b64ce96 /regalloc.c
parent981906a54e6c8dd727b7b6be2a428c547877ef78 (diff)
fix cls logic for comparison instrs
previously instr.cls always represented the output dataclass. this doesn't work for comparisons because we know the output is always a boolean integer and we care about the actual comparison dataclass. so now .cls represents the operation dataclass, which matches the result class except for comparisons where the result is always KI4V
Diffstat (limited to 'regalloc.c')
-rw-r--r--regalloc.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/regalloc.c b/regalloc.c
index ed5af2c..1b3b765 100644
--- a/regalloc.c
+++ b/regalloc.c
@@ -61,8 +61,8 @@ def(struct rega *ra, struct instr *ins, struct block *blk, int curi)
assert(ra->regs[reg].bits == mkref(RTMP, var).bits);
} else if (alloc->t == ASTACK) {
/* unspill, insert 'store [slot], reg' */
- int reg = allocreg(ra, ins->cls, mkref(RTMP, var), -1);
- struct instr store = mkinstr(Ostore1 + ilog2(cls2siz[ins->cls]), 0,
+ int reg = allocreg(ra, insrescls(*ins), mkref(RTMP, var), -1);
+ struct instr store = mkinstr(Ostore1 + ilog2(cls2siz[insrescls(*ins)]), 0,
mkref(RICON, alloc->a*8), mkref(RREG, reg));
DBG("-- unspill %%%d s%d -> %s\n", var, alloc->a, mctarg->rnames[ins->reg+1]);
addstkslotref(insertinstr(blk, ++curi, store));
@@ -151,7 +151,7 @@ spill(struct rega *ra, int reg, struct block *blk, int curi) {
DBG("-- spill %%%d %s -> s%d\n", var, mctarg->rnames[reg], s);
instrtab[var].reg = 0;
/* insert 'reg = load [slot]' */
- load = mkinstr(Oloads1 + 2*ilog2(cls2siz[instrtab[var].cls]), instrtab[var].cls, mkref(RICON, s*8));
+ load = mkinstr(Oloads1 + 2*ilog2(cls2siz[insrescls(instrtab[var])]), insrescls(instrtab[var]), mkref(RICON, s*8));
load.reg = reg+1;
addstkslotref(insertinstr(blk, ++curi, load));
freereg(ra, reg);
@@ -184,7 +184,7 @@ forcetake(struct rega *ra, int reg, union ref ref, struct block *blk, int curi)
int rename = allocreg(ra, isgpr(reg) ? KI4 : KF4, ra->regs[reg], excl);
if (ccopt.dbg.r)DBG("-- rename %%%d %s -> %s\n", var, mctarg->rnames[reg], mctarg->rnames[rename]);
/* introduce move from rename -> original (since we allocate backwards) */
- insertinstr(blk, ++curi, mkmove(instrtab[var].cls, reg, rename));
+ insertinstr(blk, ++curi, mkmove(insrescls(instrtab[var]), reg, rename));
instrtab[var].reg = rename+1;
ra->regs[rename] = mkref(RTMP, var);
bsset(globusage, rename);
@@ -230,12 +230,12 @@ use(struct rega *ra, struct block *blk, int curi, enum op op, int hint, union re
take(ra, hint, *ref);
ins->reg = hint + 1;
} else {
- ins->reg = allocreg(ra, ins->cls, *ref, excl) + 1;
+ ins->reg = allocreg(ra, insrescls(*ins), *ref, excl) + 1;
}
if (s >= 0) {
/* unspill, insert 'store [slot], reg' */
DBG("-- unspill %%%d s%d -> %s\n", ref->i, s, mctarg->rnames[ins->reg-1]);
- struct instr store = mkinstr(Ostore1 + ilog2(cls2siz[ins->cls]), 0,
+ struct instr store = mkinstr(Ostore1 + ilog2(cls2siz[insrescls(*ins)]), 0,
mkref(RICON, s*8),
mkref(RREG, ins->reg-1));
addstkslotref(insertinstr(blk, ++curi, store));
@@ -335,7 +335,7 @@ regalloc(struct function *fn)
if (ins->reg-1 != ins->l.i) {
/* an in-place operation where the destination does not
* match the first operand, so we need to add a move */
- insertinstr(blk, i, mkmove(ins->cls, ins->reg-1, ins->l.i));
+ insertinstr(blk, i, mkmove(insrescls(*ins), ins->reg-1, ins->l.i));
ins->l.i = ins->reg-1;
}
}
@@ -349,7 +349,7 @@ regalloc(struct function *fn)
/* introduce necessary moves in each pred,
* XXX this doesn't work for backwards branches */
for (int i = 0; i < phi->n; ++i) {
- struct instr mov = mkinstr(Omove, ins->cls, mkref(RREG, ins->reg-1), phi->ref[i]);
+ struct instr mov = mkinstr(Omove, insrescls(*ins), mkref(RREG, ins->reg-1), phi->ref[i]);
insertinstr(phi->blk[i], phi->blk[i]->ins.n, mov);
}
}