diff options
| -rw-r--r-- | amd64/emit.c | 58 | ||||
| -rw-r--r-- | amd64/isel.c | 22 | ||||
| -rw-r--r-- | amd64/sysv.c | 14 | ||||
| -rw-r--r-- | c/c.c | 32 | ||||
| -rw-r--r-- | ir/abi0.c | 20 | ||||
| -rw-r--r-- | ir/dump.c | 10 | ||||
| -rw-r--r-- | ir/fold.c | 2 | ||||
| -rw-r--r-- | ir/intrin.c | 2 | ||||
| -rw-r--r-- | ir/ir.c | 18 | ||||
| -rw-r--r-- | ir/ir.h | 14 | ||||
| -rw-r--r-- | ir/optmem.c | 14 | ||||
| -rw-r--r-- | ir/regalloc.c | 10 | ||||
| -rw-r--r-- | ir/ssa.c | 2 |
13 files changed, 109 insertions, 109 deletions
diff --git a/amd64/emit.c b/amd64/emit.c index df735e1..6ef6df3 100644 --- a/amd64/emit.c +++ b/amd64/emit.c @@ -46,7 +46,7 @@ ref2oper(union ref r) case RREG: return reg2oper(r.i); case RICON: return mkoper(OIMM, .imm = r.i); case RXCON: - if (conht[r.i].cls == KI4) + if (conht[r.i].cls == KI32) return mkoper(OIMM, .imm = conht[r.i].i); else if (!conht[r.i].cls) return mkoper(OSYM, .con = r.i, .cindex = NOINDEX); @@ -85,7 +85,7 @@ mkregoper(union ref r) static inline struct oper mkimmoper(union ref r) { - assert(iscon(r) && concls(r) == KI4); + assert(iscon(r) && concls(r) == KI32); return mkoper(OIMM, .imm = intconval(r)); } @@ -95,7 +95,7 @@ mkimmoper(union ref r) static inline struct oper mkimmregoper(union ref r) { - assert(isregref(r) || (iscon(r) && concls(r) == KI4)); + assert(isregref(r) || (iscon(r) && concls(r) == KI32)); return ref2oper(r); } @@ -109,7 +109,7 @@ mkdatregoper(union ref r) static inline struct oper mkimmdatregoper(union ref r) { - assert(isregref(r) || r.t == RICON || (r.t == RXCON && (conht[r.i].cls == KI4 || conht[r.i].deref))); + assert(isregref(r) || r.t == RICON || (r.t == RXCON && (conht[r.i].cls == KI32 || conht[r.i].deref))); return ref2oper(r); } @@ -286,7 +286,7 @@ encode(uchar **pcode, const struct desc *tab, int ntab, enum irclass k, struct o /* mandatory prefixes go before REX */ if (*opc == 0x66 || *opc == 0xF2 || *opc == 0xF3) B(*opc++), --nopc; - rex = in_range(k, KI8, KPTR) << 3; /* REX.W */ + rex = in_range(k, KI64, KPTR) << 3; /* REX.W */ if (en->norexw) rex = 0; switch (en->operenc) { case EN_RR: /* mod = 11; reg = dst; rm = src */ @@ -489,10 +489,10 @@ static void Xmov(uchar **pcode, enum irclass k, struct oper dst, struct oper src {4|8, PGPR, PFPR, "\x66\x0F\x7E", EN_RRX}, /* MOVD/Q r64/32, xmm */ }; static const uchar k2off[] = { - [KI4] = 0, - [KI8] = 1, [KPTR] = 1, - [KF4] = 7, - [KF8] = 10, + [KI32] = 0, + [KI64] = 1, [KPTR] = 1, + [KF32] = 7, + [KF64] = 10, }; encode(pcode, all + k2off[k], arraylength(all) - k2off[k], k, dst, src); } @@ -865,7 +865,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope Xlea(pcode, cls, dst, ref2oper(val)); } else if (val.bits == ZEROREF.bits && dst.t == OREG && (kisflt(cls) || !flagslivep(blk, curi))) { /* dst = 0 -> xor dst, dst; but only if it is ok to clobber flags */ - Xxor(pcode, kisint(cls) ? KI4 : cls, dst, dst); + Xxor(pcode, kisint(cls) ? KI32 : cls, dst, dst); } else if (isaddrcon(val,0)) { if (ccopt.pic) GOTLoad: /* for mov reg, [rip(sym@GOTPCREL)] */ @@ -873,7 +873,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope else /* for lea reg, [rip(sym)] */ Xlea(pcode, cls, dst, mkoper(OSYM, .con = val.i, .cindex = NOINDEX)); - } else if (val.t == RXCON && in_range(concls(val), KI8, KPTR)) { + } else if (val.t == RXCON && in_range(concls(val), KI64, KPTR)) { /* movabs */ assert(dst.t == OREG && in_range(dst.reg, RAX, R15)); B(0x48 | (dst.reg >> 3)); /* REX.W (+ REX.B) */ @@ -883,7 +883,7 @@ gencopy(uchar **pcode, enum irclass cls, struct block *blk, int curi, struct ope } else { struct oper src = mkimmdatregoper(val); if (memcmp(&dst, &src, sizeof dst) != 0) - Xmov(pcode, cls == KF8 && src.t == OREG && src.reg < XMM0 ? KI8 : cls, dst, src); + Xmov(pcode, cls == KF64 && src.t == OREG && src.reg < XMM0 ? KI64 : cls, dst, src); } } @@ -903,7 +903,7 @@ Xvaprologue(uchar **pcode, struct function *fn, struct oper sav) for (int r = 0; r < 6; ++r) { static const char reg[] = {RDI,RSI,RDX,RCX,R8,R9}; if (r >= gpr0) - Xmov(pcode, KI8, sav, reg2oper(reg[r])); + Xmov(pcode, KI64, sav, reg2oper(reg[r])); sav.disp += 8; } @@ -915,7 +915,7 @@ Xvaprologue(uchar **pcode, struct function *fn, struct oper sav) } for (int r = 0; r < 8; ++r) { if (r >= fpr0) - Xmovaps(pcode, KF8, sav, reg2oper(XMM0 + r)); + Xmovaps(pcode, KF64, sav, reg2oper(XMM0 + r)); sav.disp += 16; } if (fpr0 < 8) {/* patch relative jump */ @@ -953,14 +953,14 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc default: fatal(NULL, "amd64: in %y; unimplemented instr '%s'", fn->name, opnames[ins->op]); case Onop: break; - case Ostore1: cls = KI4, X = Xmovb; goto Store; - case Ostore2: cls = KI4, X = Xmovw; goto Store; - case Ostore4: cls = KI4, X = Xmov; goto Store; - case Ostore8: cls = KI8, X = Xmov; + case Ostore1: cls = KI32, X = Xmovb; goto Store; + case Ostore2: cls = KI32, X = Xmovw; goto Store; + case Ostore4: cls = KI32, X = Xmov; goto Store; + case Ostore8: cls = KI64, X = Xmov; Store: src = mkimmregoper(ins->r); - if (cls == KI4 && src.t == OREG && src.reg >= XMM0) cls = KF4; - if (cls == KI8 && src.t == OREG && src.reg >= XMM0) cls = KF8; + if (cls == KI32 && src.t == OREG && src.reg >= XMM0) cls = KF32; + if (cls == KI64 && src.t == OREG && src.reg >= XMM0) cls = KF64; X(pcode, cls, mkmemoper(ins->l), src); break; case Oexts1: src = mkregoper(ins->l); goto Movsxb; @@ -974,15 +974,15 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc case Oloads2: src = mkmemoper(ins->l); Movsxw: Xmovsxw(pcode, cls, reg2oper(ins->reg-1), src); break; case Oloadu2: src = mkmemoper(ins->l); Movzxw: Xmovzxw(pcode, cls, reg2oper(ins->reg-1), src); break; case Oloads4: src = mkmemoper(ins->l); Movsxl: Xmovsxl(pcode, cls, reg2oper(ins->reg-1), src); break; - case Oloadu4: src = mkmemoper(ins->l); Movzxl: Xmov(pcode, KI4, reg2oper(ins->reg-1), src); break; + case Oloadu4: src = mkmemoper(ins->l); Movzxl: Xmov(pcode, KI32, reg2oper(ins->reg-1), src); break; case Oloadf4: case Oloadf8: Xmov(pcode, cls, reg2oper(ins->reg-1), mkmemoper(ins->l)); break; - case Oloadi8: Xmov(pcode, KI8, reg2oper(ins->reg-1), mkmemoper(ins->l)); break; + case Oloadi8: Xmov(pcode, KI64, reg2oper(ins->reg-1), mkmemoper(ins->l)); break; case Ocvtf4f8: X = Xcvtss2sd; goto FloatsCvt; case Ocvtf8f4: X = Xcvtsd2ss; goto FloatsCvt; case Ocvtf4s: X = Xcvttss2si; goto FloatsCvt; case Ocvtf8s: X = Xcvttsd2si; goto FloatsCvt; - case Ocvts4f: X = cls == KF4 ? Xcvtsi2ss : Xcvtsi2sd; cls = KI4; goto FloatsCvt; - case Ocvts8f: X = cls == KF4 ? Xcvtsi2ss : Xcvtsi2sd; cls = KI8; goto FloatsCvt; + case Ocvts4f: X = cls == KF32 ? Xcvtsi2ss : Xcvtsi2sd; cls = KI32; goto FloatsCvt; + case Ocvts8f: X = cls == KF32 ? Xcvtsi2ss : Xcvtsi2sd; cls = KI64; goto FloatsCvt; FloatsCvt: X(pcode, cls, reg2oper(ins->reg-1), mkdatregoper(ins->l)); break; @@ -1050,12 +1050,12 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc switch (cls) { default: assert(0); case KPTR: - case KI8: B(0x48); /* REX.W */ - case KI4: B(0x99); /* CDQ/CQO */ + case KI64: B(0x48); /* REX.W */ + case KI32: B(0x99); /* CDQ/CQO */ assert(mkregoper(ins->l).reg == RAX); Xidiv(pcode, cls, mkdatregoper(ins->r)); break; - case KF4: case KF8: + case KF32: case KF64: Xdivf(pcode, cls, reg2oper(ins->reg-1), mkdatregoper(ins->r)); break; } @@ -1075,7 +1075,7 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc /* can zero output reg before test instruction (differs from both inputs) */ /* XXX this doesn't check if a source operand is an addr containing the register */ struct oper dst = reg2oper(ins->reg-1); - Xxor(pcode, KI4, dst, dst); + Xxor(pcode, KI32, dst, dst); regzeroed = 1; } if (kisint(ins->cls) && ins->r.bits == ZEROREF.bits) @@ -1092,7 +1092,7 @@ emitinstr(uchar **pcode, struct function *fn, struct block *blk, int curi, struc } Xsetcc(pcode, cc, dst.reg); if (!regzeroed) - Xmovzxb(pcode, KI4, dst, dst); + Xmovzxb(pcode, KI32, dst, dst); } break; case Omove: diff --git a/amd64/isel.c b/amd64/isel.c index 649c393..904fdbd 100644 --- a/amd64/isel.c +++ b/amd64/isel.c @@ -68,23 +68,23 @@ fixarg(union ref *r, struct instr *ins, struct block *blk, int *curi) } else if (in_range(op, Oadd, Osub) && con->i == 2147483648 && r == &ins->r) { /* add X, INT32MAX+1 -> sub X, INT32MIN */ ins->op = Oadd + (op == Oadd); - *r = mkintcon(KI4, -2147483648); + *r = mkintcon(KI32, -2147483648); } else if (kisflt(con->cls) && con->f == 0) { /* copy of float zero -> regular zero, that emit() will turn into xor x,x */ if (in_range(op, Ocopy, Omove) || op == Ophi) *r = ZEROREF; else *r = insertinstr(blk, (*curi)++, mkinstr(Ocopy, con->cls, ZEROREF)); - } else if (con->cls >= KI8) { + } else if (con->cls >= KI64) { /* float immediates & 64bit immediates are loaded from memory */ uchar data[8]; uint ksiz = cls2siz[con->cls]; union type ctype; if (con->cls <= KPTR && in_range(ins->op, Ocopy, Omove)) /* in this case we can use movabs */ return; - if (con->cls != KF4) { + if (con->cls != KF32) { wr64le(data, con->i); - ctype = mktype(con->cls == KF8 ? TYDOUBLE : TYVLONG); + ctype = mktype(con->cls == KF64 ? TYDOUBLE : TYVLONG); } else { union { float f; int i; } pun = { con->f }; wr32le(data, pun.i); @@ -107,7 +107,7 @@ fixarg(union ref *r, struct instr *ins, struct block *blk, int *curi) ShiftImm: /* shift immediate is always 8bit */ *r = mkref(RICON, sh & 255); } else if (isstkslot(*r)) { - struct instr adr = mkinstr(Oadd, KPTR, mkref(RREG, RBP), mkintcon(KI4, -stkslots[r->i])); + struct instr adr = mkinstr(Oadd, KPTR, mkref(RREG, RBP), mkintcon(KI32, -stkslots[r->i])); if (in_range(op, Ocopy, Omove)) *ins = adr; else @@ -162,7 +162,7 @@ selcall(struct function *fn, struct instr *ins, struct block *blk, int *curi) } } -#define isimm32(r) (iscon(r) && concls(r) == KI4) +#define isimm32(r) (iscon(r) && concls(r) == KI32) static bool aimm(struct addr *addr, int disp) @@ -389,7 +389,7 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi) case Oshl: case Osar: case Oslr: if (!iscon(ins->r)) { /* shift amount register is always CL */ - insertinstr(blk, (*curi)++, mkinstr(Omove, KI4, mkref(RREG, RCX), ins->r)); + insertinstr(blk, (*curi)++, mkinstr(Omove, KI32, mkref(RREG, RCX), ins->r)); ins->r = mkref(RREG, RCX); } goto ALU; @@ -498,13 +498,13 @@ sel(struct function *fn, struct instr *ins, struct block *blk, int *curi) break; case Ocvtu4f: fixarg(&ins->l, ins, blk, curi); - ins->l = insertinstr(blk, (*curi)++, mkinstr(Oextu4, KI8, ins->l)); + ins->l = insertinstr(blk, (*curi)++, mkinstr(Oextu4, KI64, ins->l)); ins->op = Ocvts8f; break; case Ocvtf4u: case Ocvtf8u: fixarg(&ins->l, ins, blk, curi); - if (ins->cls == KI4) { - ins->l = insertinstr(blk, (*curi)++, mkinstr(ins->op == Ocvtf4u ? Ocvtf4s : Ocvtf8s, KI8, ins->l)); + if (ins->cls == KI32) { + ins->l = insertinstr(blk, (*curi)++, mkinstr(ins->op == Ocvtf4u ? Ocvtf4s : Ocvtf8s, KI64, ins->l)); ins->op = Oextu4; } else assert(!"nyi flt -> u64"); break; @@ -541,7 +541,7 @@ seljmp(struct function *fn, struct block *blk) if (blk->jmp.t == Jb && blk->jmp.arg[0].bits) { union ref c = blk->jmp.arg[0]; if (c.t != RTMP) { - enum irclass cls = c.t == RICON ? KI4 : c.t == RXCON && conht[c.i].cls ? conht[c.i].cls : KPTR; + enum irclass cls = c.t == RICON ? KI32 : c.t == RXCON && conht[c.i].cls ? conht[c.i].cls : KPTR; int curi = blk->ins.n; c = insertinstr(blk, blk->ins.n, mkinstr(Ocopy, cls, c)); diff --git a/amd64/sysv.c b/amd64/sysv.c index db88692..e69797b 100644 --- a/amd64/sysv.c +++ b/amd64/sysv.c @@ -8,7 +8,7 @@ clsscalar(uchar cls[2], uint off, union type ty) enum irclass k = type2cls[scalartypet(ty)]; uchar *fcls = &cls[off/8]; if (isflt(ty)) { /* SSE */ - if (!*fcls || (*fcls == KF4 && k > *fcls)) + if (!*fcls || (*fcls == KF32 && k > *fcls)) *fcls = k; } else { /* INTEGER */ assert(isint(ty) || ty.t == TYPTR); @@ -16,7 +16,7 @@ clsscalar(uchar cls[2], uint off, union type ty) *fcls = k; } if (off % 8 >= 4 && cls2siz[*fcls] < 8) - *fcls = kisint(*fcls) ? KI8 : KF8; + *fcls = kisint(*fcls) ? KI64 : KF64; } static int @@ -230,8 +230,8 @@ vaarg(struct function *fn, struct block *blk, int *curi) union ref phi, phiargs[2]; if (ni) { /* l->gp_offset < 48 - num_gp * 8 */ - tmp = insertinstr(blk, (*curi)++, mkinstr(Oloadu4, KI4, ap)); - tmp = insertinstr(blk, (*curi)++, mkinstr(Oulte, KI4, tmp, mkref(RICON, 48 - ni*8))); + tmp = insertinstr(blk, (*curi)++, mkinstr(Oloadu4, KI32, ap)); + tmp = insertinstr(blk, (*curi)++, mkinstr(Oulte, KI32, tmp, mkref(RICON, 48 - ni*8))); merge = blksplitafter(fn, blk, *curi); blk->jmp.t = 0; useblk(fn, blk); @@ -240,10 +240,10 @@ vaarg(struct function *fn, struct block *blk, int *curi) { /* phi0: &l->reg_save_area[l->gp_offset] */ union ref sav = addinstr(fn, mkinstr(Oloadi8, KPTR, irbinop(fn, Oadd, KPTR, ap, mkref(RICON, 16)))); - union ref gpoff = addinstr(fn, mkinstr(Oloadu4, KI4, ap)); + union ref gpoff = addinstr(fn, mkinstr(Oloadu4, KI32, ap)); phiargs[0] = irbinop(fn, Oadd, KPTR, sav, gpoff); /* l->gp_offset += num_gp * 8 */ - gpoff = irbinop(fn, Oadd, KI4, gpoff, mkref(RICON, ni * 8)); + gpoff = irbinop(fn, Oadd, KI32, gpoff, mkref(RICON, ni * 8)); addinstr(fn, mkinstr(Ostore4, 0, ap, gpoff)); assert(merge->npred == 1); blkpred(merge, 0) = blk->s1; @@ -269,7 +269,7 @@ vaarg(struct function *fn, struct block *blk, int *curi) merge->ins.p[0] = var; phi = insertphi(merge, KPTR); memcpy(phitab.p[instrtab[phi.i].l.i], phiargs, sizeof phiargs); - instrtab[var] = mkinstr(cls[0] == KI4 ? Oloads4 : Oloadi8, cls[0], phi); + instrtab[var] = mkinstr(cls[0] == KI32 ? Oloads4 : Oloadi8, cls[0], phi); } else { assert(0&&nf); } @@ -2664,7 +2664,7 @@ expraddr(struct function *fn, const struct expr *ex) case EGETF: r = expraddr(fn, ex->sub); assert(ex->fld.bitsiz == 0); - return irbinop(fn, Oadd, KPTR, r, mkintcon(KI4, ex->fld.off)); + return irbinop(fn, Oadd, KPTR, r, mkintcon(KI32, ex->fld.off)); case ESET: assert(isagg(ex->ty)); r = expraddr(fn, &ex->sub[1]); @@ -2768,7 +2768,7 @@ geninit(struct function *fn, union type t, union ref dst, const struct expr *src /* TODO make it into an intrinsic */ struct instr call = { Ocall, KPTR }; addinstr(fn, mkarginstr(cls2type(KPTR), dst)); - addinstr(fn, mkarginstr(cls2type(KI4), ZEROREF)); + addinstr(fn, mkarginstr(cls2type(KI32), ZEROREF)); addinstr(fn, mkarginstr(cls2type(type2cls[targ_sizetype]), mkintcon(type2cls[targ_sizetype], siz))); call.l = mksymref("memset"); call.r = mkcallarg(cls2type(KPTR), 3, -1); @@ -2799,7 +2799,7 @@ geninit(struct function *fn, union type t, union ref dst, const struct expr *src else if (csiz == 2) genstore(fn, ctyp, adr, mkref(RICON, src->s.w16[i])); else - genstore(fn, ctyp, adr, mkintcon(KI4, src->s.w32[i])); + genstore(fn, ctyp, adr, mkintcon(KI32, src->s.w32[i])); adr = irbinop(fn, Oadd, KPTR, dst, mkref(RICON, (i+1)*csiz)); } genstore(fn, ctyp, adr, ZEROREF); /* null term */ @@ -2856,26 +2856,26 @@ cvt(struct function *fn, union type to, union type from, union ref ref) if (kisflt(kto) || kisflt(kfrom)) { if (ref.t == RICON) { assert(kisflt(kto) && kisint(kfrom)); - return mkfltcon(kto, kto == KF4 ? (float)ref.i : (double)ref.i); + return mkfltcon(kto, kto == KF32 ? (float)ref.i : (double)ref.i); } - if (kisflt(kto) && kfrom == KI4) op = issigned(from) ? Ocvts4f : Ocvtu4f; + if (kisflt(kto) && kfrom == KI32) op = issigned(from) ? Ocvts4f : Ocvtu4f; else if (to.t == TYBOOL && kisflt(kfrom)) return irbinop(fn, Oneq, kfrom, ref, mkfltcon(kfrom, 0.0)); - else if (kisflt(kto) && kfrom == KI8) op = issigned(from) ? Ocvts8f : Ocvtu8f; - else if (kto == KF8 && kfrom == KF4) op = Ocvtf4f8; - else if (kto == KF4 && kfrom == KF8) op = Ocvtf8f4; - else if (kfrom == KF4) op = issigned(to) ? Ocvtf4s : Ocvtf4u; - else if (kfrom == KF8) op = issigned(to) ? Ocvtf8s : Ocvtf8u; + else if (kisflt(kto) && kfrom == KI64) op = issigned(from) ? Ocvts8f : Ocvtu8f; + else if (kto == KF64 && kfrom == KF32) op = Ocvtf4f8; + else if (kto == KF32 && kfrom == KF64) op = Ocvtf8f4; + else if (kfrom == KF32) op = issigned(to) ? Ocvtf4s : Ocvtf4u; + else if (kfrom == KF64) op = issigned(to) ? Ocvtf8s : Ocvtf8u; else assert(0); } else { if (to.t == TYBOOL) { if (from.t == TYBOOL) return ref; if (isboollike(fn, ref)) - return kfrom == KI4 ? ref : cvt(fn, mktype(TYINT), from, ref); + return kfrom == KI32 ? ref : cvt(fn, mktype(TYINT), from, ref); return irbinop(fn, Oneq, kfrom, ref, ZEROREF); } - else if (kfrom == KI4 && issigned(from)) op = Oexts4; - else if (kfrom == KI4) op = Oextu4; - else if (kto == KI4 && isintcon(ref)) + else if (kfrom == KI32 && issigned(from)) op = Oexts4; + else if (kfrom == KI32) op = Oextu4; + else if (kto == KI32 && isintcon(ref)) return issigned(to) ? mkintcon(kto, (int)intconval(ref)) : mkintcon(kto, (uint)intconval(ref)); else op = Ocopy; } @@ -2890,7 +2890,7 @@ narrow(struct function *fn, enum irclass to, union type t, union ref ref, uint b if (targ_primsizes[tt] < cls2siz[to]) { enum op op; if (isfltt(tt)) { - assert(to == KF4 && tt >= TYDOUBLE); + assert(to == KF32 && tt >= TYDOUBLE); op = Ocvtf8f4; } else { static const enum op ext[5][2] = { @@ -3128,7 +3128,7 @@ genbitfload(struct function *fn, union ref *tmpval, const union type ty, union r uvlong mask; assert(k); - *addr = irbinop(fn, Oadd, KPTR, *addr, mkintcon(KI4, off)); + *addr = irbinop(fn, Oadd, KPTR, *addr, mkintcon(KI32, off)); tmp = genload(fn, ty, *addr, volatyl); if (tmpval) *tmpval = tmp; if (!issigned(ty)) { @@ -69,10 +69,10 @@ copyparam(struct function *fn, int *curi, int param, struct abiarg abi) if (abi.ty.cls == KPTR) abi.ty.cls = siz2intcls[cls2siz[abi.ty.cls]]; switch (abi.ty.cls) { default: assert(0); - case KI4: ld = Oloadu4; break; - case KI8: ld = Oloadi8; break; - case KF4: ld = Oloadf4; break; - case KF8: ld = Oloadf8; break; + case KI32: ld = Oloadu4; break; + case KI64: ld = Oloadi8; break; + case KF32: ld = Oloadf4; break; + case KF64: ld = Oloadf8; break; } return mkinstr(ld, abi.ty.cls, insertinstr(fn->entry, (*curi)++, par)); } else { /* aggregate in stack */ @@ -156,10 +156,10 @@ load2regs(union ref out[2], union irtype typ, union ref src, int nabi, struct ab union ref temp; switch (ins.cls = abi[i].ty.cls) { default: assert(0); - case KI4: ins.op = Oloadu4; break; - case KI8: ins.op = Oloadi8; break; - case KF4: ins.op = Oloadf4; break; - case KF8: ins.op = Oloadf8; break; + case KI32: ins.op = Oloadu4; break; + case KI64: ins.op = Oloadi8; break; + case KF32: ins.op = Oloadf4; break; + case KF64: ins.op = Oloadf8; break; } if (i == 0) ins.l = src; @@ -304,8 +304,8 @@ abi0_call(struct function *fn, struct instr *ins, struct block *blk, int *curi) int iref, iuser; switch (call->abiret[i].ty.cls) { default: assert(0); - case KF4: case KI4: store.op = Ostore4; break; - case KI8: case KF8: store.op = Ostore8; break; + case KF32: case KI32: store.op = Ostore4; break; + case KI64: case KF64: store.op = Ostore8; break; } if (i == 0) { store.l = retmem; @@ -58,7 +58,7 @@ pridat(const struct irdat *dat) } static const char *clsname[] = { - "?", "i4", "i8", "ptr", "f4", "f8" + "?", "i32", "i64", "ptr", "f32", "f64" }; static void @@ -123,11 +123,11 @@ dumpref(enum op o, union ref ref) } } } else switch (con->cls) { - case KI4: bfmt(out, "%d", (int)con->i); break; - case KI8: bfmt(out, "%ld", con->i); break; + case KI32: bfmt(out, "%d", (int)con->i); break; + case KI64: bfmt(out, "%ld", con->i); break; case KPTR: bfmt(out, "%'lx", con->i); break; - case KF4: bfmt(out, "%fs", con->f); break; - case KF8: bfmt(out, "%fd", con->f); break; + case KF32: bfmt(out, "%fs", con->f); break; + case KF64: bfmt(out, "%fd", con->f); break; default: assert(0); } if (con->deref) bfmt(out, "]"); @@ -58,7 +58,7 @@ foldflt(enum op op, enum irclass k, union ref lr, union ref rr) { int xi; double x, l = fltconval(lr), r = fltconval(rr); - bool w = k == KF8; + bool w = k == KF64; if (in_range(op, Odiv, Ourem)) assert(r != 0.0); switch (op) { case Ocopy: x = l; break; diff --git a/ir/intrin.c b/ir/intrin.c index 9bb0bcb..3edf931 100644 --- a/ir/intrin.c +++ b/ir/intrin.c @@ -36,7 +36,7 @@ intrin(struct block *blk, int *curi, enum intrin in, struct arg *args, int narg, pdst = insertinstr(blk, ++*curi, mkinstr(Oadd, KPTR, *args[0].arg, mkref(RICON, off))); psrc = insertinstr(blk, ++*curi, mkinstr(Oadd, KPTR, *args[1].arg, mkref(RICON, off))); } - src = insertinstr(blk, ++*curi, mkinstr(Oloads1 + 2*ilog2(step), step < 8 ? KI4 : KI8, psrc)); + src = insertinstr(blk, ++*curi, mkinstr(Oloads1 + 2*ilog2(step), step < 8 ? KI32 : KI64, psrc)); insertinstr(blk, ++*curi, mkinstr(Ostore1 + ilog2(step), 0, pdst, src)); } return 1; @@ -2,8 +2,8 @@ #include "../obj/obj.h" uchar type2cls[NTYPETAG]; -uchar cls2siz[KF8+1]; -const uchar siz2intcls[] = { [1] = KI4, [2] = KI4, [4] = KI4, [8] = KI8 }; +uchar cls2siz[KF64+1]; +const uchar siz2intcls[] = { [1] = KI32, [2] = KI32, [4] = KI32, [8] = KI64 }; const char *opnames[] = { "?\??", @@ -54,15 +54,15 @@ irinit(struct function *fn) if (!type2cls[TYINT]) { for (int i = TYBOOL; i <= TYUVLONG; ++i) { int siz = targ_primsizes[i]; - type2cls[i] = siz < 8 ? KI4 : KI8; + type2cls[i] = siz < 8 ? KI32 : KI64; } - type2cls[TYFLOAT] = KF4; - type2cls[TYDOUBLE] = KF8; - type2cls[TYLDOUBLE] = KF8; + type2cls[TYFLOAT] = KF32; + type2cls[TYDOUBLE] = KF64; + type2cls[TYLDOUBLE] = KF64; type2cls[TYPTR] = KPTR; type2cls[TYARRAY] = KPTR; - cls2siz[KI4] = cls2siz[KF4] = 4; - cls2siz[KI8] = cls2siz[KF8] = 8; + cls2siz[KI32] = cls2siz[KF32] = 4; + cls2siz[KI64] = cls2siz[KF64] = 8; cls2siz[KPTR] = targ_primsizes[TYPTR]; } fn->entry = fn->curblk = allocz(fn->arena, sizeof(struct block), 0); @@ -132,7 +132,7 @@ mkintcon(enum irclass k, vlong i) union ref mkfltcon(enum irclass k, double f) { - struct xcon con = { .cls = k, .f = k == KF4 ? (float) f : f }; + struct xcon con = { .cls = k, .f = k == KF32 ? (float) f : f }; return mkref(RXCON, addcon(&con)); } @@ -3,12 +3,12 @@ enum irclass { KXXX, - KI4, KI8, KPTR, - KF4, KF8, + KI32, KI64, KPTR, + KF32, KF64, }; -#define kisint(k) in_range((k), KI4, KPTR) -#define kisflt(k) in_range((k), KF4, KF8) +#define kisint(k) in_range((k), KI32, KPTR) +#define kisflt(k) in_range((k), KF32, KF64) union irtype { struct { ushort _ : 1, cls : 15; }; @@ -73,7 +73,7 @@ struct addr { int shift, disp; }; -#define insrescls(ins) (oiscmp((ins).op) ? KI4 : (ins).cls) +#define insrescls(ins) (oiscmp((ins).op) ? KI32 : (ins).cls) #define NOREF ((union ref) {0}) #define UNDREF ((union ref) {{ 0, -1 }}) #define ZEROREF ((union ref) {{ RICON, 0 }}) @@ -107,7 +107,7 @@ enum intrin { struct instr { uchar op, - cls; /* operation data class; also result class except for cmp ops (always i4) */ + cls; /* operation data class; also result class except for cmp ops (always i32) */ uchar skip : 1, /* ignore during codegen: forms part of one machine instruction */ keep : 1; /* for codegen, keep instr even if result seems unused */ uchar inplace : 1; /* set (by isel) for instructions which modify its first arg in place */ @@ -233,7 +233,7 @@ union irtype mkirtype(union type); union ref mkintcon(enum irclass, vlong); union ref mkfltcon(enum irclass, double); #define iscon(r) in_range((r).t, RICON, RXCON) -#define concls(r) ((r).t == RICON ? KI4 : conht[(r).i].cls) +#define concls(r) ((r).t == RICON ? KI32 : conht[(r).i].cls) #define isintcon(r) (iscon(r) && kisint(concls(r))) #define isfltcon(r) ((r).t == RXCON && kisflt(conht[(r).i].cls)) #define isnumcon(r) ((r).t == RICON || ((r).t == RXCON && conht[(r).i].cls)) diff --git a/ir/optmem.c b/ir/optmem.c index d8783d5..41d123a 100644 --- a/ir/optmem.c +++ b/ir/optmem.c @@ -2,12 +2,12 @@ #include <stdlib.h> /* qsort */ static const uchar loadszcls[] = { - [Oloads1 - Oloads1] = 1|KI4<<4, [Oloadu1 - Oloads1] = 1|KI4<<4, - [Oloads2 - Oloads1] = 2|KI4<<4, [Oloadu2 - Oloads1] = 2|KI4<<4, - [Oloads4 - Oloads1] = 4|KI4<<4, [Oloadu4 - Oloads1] = 4|KI4<<4, - [Oloadi8 - Oloads1] = 8|KI8<<4, - [Oloadf4 - Oloads1] = 4|KF4<<4, - [Oloadf8 - Oloads1] = 8|KF8<<4, + [Oloads1 - Oloads1] = 1|KI32<<4, [Oloadu1 - Oloads1] = 1|KI32<<4, + [Oloads2 - Oloads1] = 2|KI32<<4, [Oloadu2 - Oloads1] = 2|KI32<<4, + [Oloads4 - Oloads1] = 4|KI32<<4, [Oloadu4 - Oloads1] = 4|KI32<<4, + [Oloadi8 - Oloads1] = 8|KI64<<4, + [Oloadf4 - Oloads1] = 4|KF32<<4, + [Oloadf8 - Oloads1] = 8|KF64<<4, }; static const uchar load2ext[] = { [Oloads1 - Oloads1] = Oexts1, [Oloadu1 - Oloads1] = Oextu1, @@ -291,7 +291,7 @@ mem2reg(struct function *fn) if (!val.bits) { /* var is used uninitialized */ /* TODO emit diagnostic */ /* load some garbage */ - *m = mkinstr(kisflt(k) ? Oloadf4 + (k==KF8) : Oloads1+ilog2(sz)*2, + *m = mkinstr(kisflt(k) ? Oloadf4 + (k==KF64) : Oloads1+ilog2(sz)*2, k, mkref(RREG, mctarg->bpr)); } else { adduse(use->blk, use->u, val); diff --git a/ir/regalloc.c b/ir/regalloc.c index 9857d61..df40ad4 100644 --- a/ir/regalloc.c +++ b/ir/regalloc.c @@ -251,11 +251,11 @@ emitmove(enum irclass k, struct alloc dst, struct alloc src, struct block *blk, if (src.t == ASTACK) { switch (mv.cls = k) { default: assert(0); - case KI4: mv.op = Oloads4; break; - case KI8: mv.op = Oloadi8; break; + case KI32: mv.op = Oloads4; break; + case KI64: mv.op = Oloadi8; break; case KPTR: mv.op = targ_64bit ? Oloadi8 : Oloads4; break; - case KF4: mv.op = Oloadf4; break; - case KF8: mv.op = Oloadf8; break; + case KF32: mv.op = Oloadf4; break; + case KF64: mv.op = Oloadf8; break; } if (dst.t == AREG) reg = dst.a; @@ -976,7 +976,7 @@ devirt(struct rega *ra, struct block *blk) for (int i = 0; i < nargref; ++i) { static uchar cls2load[] = { - [KI4] = Oloads4, [KI8] = Oloadi8, [KF4] = Oloadf4, [KF8] = Oloadf8, [KPTR] = 0 + [KI32] = Oloads4, [KI64] = Oloadi8, [KF32] = Oloadf4, [KF64] = Oloadf8, [KPTR] = 0 }; cls2load[KPTR] = targ_64bit ? Oloadi8 : Oloads4; union ref *r = argref[i]; @@ -15,7 +15,7 @@ copyopt(struct function *fn) if (ins->op == Ocopy) { union ref arg = ins->l; if (arg.t == RTMP) k = insrescls(instrtab[arg.i]); - else if (arg.t == RICON) k = cls2siz[ins->cls] == 4 ? KI4 : KI8; + else if (arg.t == RICON) k = cls2siz[ins->cls] == 4 ? KI32 : KI64; else if (arg.t == RXCON) k = isnumcon(arg) ? conht[arg.i].cls : KPTR; else continue; if (ins->cls != k) continue; |