From ad8067a1ab1871cf57936828fb1b40c15cd3349d Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 19 Feb 2026 20:29:16 +0100 Subject: IR: just use an array for extended constants The extra work of using a hashtable to intern them is probably unnecessary. --- aarch64/emit.c | 12 ++++++------ aarch64/isel.c | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) (limited to 'aarch64') diff --git a/aarch64/emit.c b/aarch64/emit.c index d49906e..6db1bd6 100644 --- a/aarch64/emit.c +++ b/aarch64/emit.c @@ -86,12 +86,12 @@ ref2oper(union ref r) case RREG: return reg2oper(r.i); case RICON: return mkoper(OIMM, .imm = r.i); case RXCON: - if (kisint(conht[r.i].cls)) - return mkoper(OIMM, .imm = conht[r.i].i); - else if (kisflt(conht[r.i].cls)) { - assert(conht[r.i].f == 0.0); + if (kisint(contab.p[r.i].cls)) + return mkoper(OIMM, .imm = contab.p[r.i].i); + else if (kisflt(contab.p[r.i].cls)) { + assert(contab.p[r.i].f == 0.0); return mkoper(OIMM, .imm = 0); - } else if (!conht[r.i].cls) { + } else if (!contab.p[r.i].cls) { return mkoper(OSYM, .con = r.i); } assert(0); @@ -553,7 +553,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope Xfmov(pcode, cls, dst, REGZR); else assert(0); } else if (isaddrcon(val,0) || (val.t == RADDR && isaddrcon(addrht[val.i].base,0))) { - if ((ccopt.pic || (conht[val.i].flag & SFUNC)) && !(conht[val.i].flag & SLOCAL)) { + if ((ccopt.pic || (contab.p[val.i].flag & SFUNC)) && !(contab.p[val.i].flag & SLOCAL)) { Xadrp(pcode, KPTR, dst, src); Xadd(pcode, KPTR, dst, dst, src); } else { diff --git a/aarch64/isel.c b/aarch64/isel.c index 390793b..bcabf2c 100644 --- a/aarch64/isel.c +++ b/aarch64/isel.c @@ -108,7 +108,7 @@ fixarg(union ref *r, struct instr *ins, struct block *blk, int *curi) goto Reg; } else if (isfltcon(*r)) { enum irclass k = concls(*r), ki = KI32 + k-KF32; - if (conht[r->i].f != 0.0) { + if (contab.p[r->i].f != 0.0) { union { vlong i64; int i32; @@ -117,10 +117,10 @@ fixarg(union ref *r, struct instr *ins, struct block *blk, int *curi) } pun; vlong i; if (k == KF32) { - pun.f32 = conht[r->i].f; + pun.f32 = contab.p[r->i].f; i = pun.i32; } else { - pun.f64 = conht[r->i].f; + pun.f64 = contab.p[r->i].f; i = pun.i64; } union ref gpr = insertinstr(blk, (*curi)++, mkinstr(Ocopy, ki, mkintcon(ki, i))); @@ -301,9 +301,9 @@ fuseaddr(union ref *r, struct block *blk, int *curi, uint siz/*1,2,4,8*/) if (!(addr.disp >= -256 && addr.disp < 256) /* for 9-bit signed unscaled offset */ && !(!(addr.disp & (siz-1)) && (uvlong)addr.disp < (1<<12)*siz)) /* 12-bit unsigned scaled offset */ return 0; - if (isaddrcon(addr.base,0) && (!(conht[addr.base.i].flag & SLOCAL) || addr.index.bits)) { + if (isaddrcon(addr.base,0) && (!(contab.p[addr.base.i].flag & SLOCAL) || addr.index.bits)) { /* first load symbol address into a temp register */ - if (addr.disp && (ccopt.pic || (conht[addr.base.i].flag & SFUNC)) && !addr.index.bits) { + if (addr.disp && (ccopt.pic || (contab.p[addr.base.i].flag & SFUNC)) && !addr.index.bits) { addr.base = insertinstr(blk, (*curi)++, mkinstr(Ocopy, KPTR, .l = addr.base)); } else { addr.base = insertinstr(blk, (*curi)++, mkinstr(Ocopy, KPTR, @@ -339,7 +339,7 @@ loadstoreaddr(struct block *blk, union ref *r, int *curi, enum op op) *r = mkaddr((struct addr){.base = *r}); } else if (isaddrcon(*r, 0)) { bool pcrelok = in_range(op, Oloads32, Oloadi64); /* LDR-LDRSW have PC-relative literal form */ - if (!pcrelok || !(conht[r->i].flag & SLOCAL)) + if (!pcrelok || !(contab.p[r->i].flag & SLOCAL)) regarg(r, KPTR, blk, curi); } else if (r->t == RTMP || r->t == RSTACK) { fuseaddr(r, blk, curi, siz); @@ -390,7 +390,7 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi) op = ins->op ^= 1; ins->r.i = -ins->r.i; } - if (!(isaddrcon(ins->l,0) && (conht[ins->l.i].flag & SLOCAL))) + if (!(isaddrcon(ins->l,0) && (contab.p[ins->l.i].flag & SLOCAL))) regarg(&ins->l, ins->cls, blk, curi); fixarg(&ins->r, ins, blk, curi); break; @@ -445,7 +445,7 @@ seljmp(struct function *fn, struct block *blk) fixarg(&blk->jmp.arg[0], NULL, blk, &curi); union ref c = blk->jmp.arg[0]; if (c.t != RTMP) { - enum irclass cls = c.t == RICON ? KI32 : c.t == RXCON && conht[c.i].cls ? conht[c.i].cls : KPTR; + enum irclass cls = c.t == RICON ? KI32 : c.t == RXCON && contab.p[c.i].cls ? contab.p[c.i].cls : KPTR; int curi = blk->ins.n; c = insertinstr(blk, blk->ins.n, mkinstr(Ocopy, cls, c)); -- cgit v1.2.3