diff options
-rw-r--r-- | all.h | 176 | ||||
-rw-r--r-- | copy.c | 4 | ||||
-rw-r--r-- | emit.c | 160 | ||||
-rw-r--r-- | fold.c | 106 | ||||
-rw-r--r-- | isel.c | 166 | ||||
-rw-r--r-- | live.c | 2 | ||||
-rw-r--r-- | mem.c | 34 | ||||
-rw-r--r-- | parse.c | 228 | ||||
-rw-r--r-- | rega.c | 20 | ||||
-rw-r--r-- | spill.c | 10 | ||||
-rw-r--r-- | sysv.c | 112 |
11 files changed, 509 insertions, 509 deletions
diff --git a/all.h b/all.h index 19125b0..2eccb97 100644 --- a/all.h +++ b/all.h @@ -162,8 +162,8 @@ enum ICmp { #undef X NICmp, - ICXnp = NICmp, /* x64 specific */ - ICXp, + ICxnp = NICmp, /* x64 specific */ + ICxp, NXICmp }; @@ -201,103 +201,103 @@ enum Class { #define KBASE(k) ((k)>>1) enum Op { - OXXX, + Oxxx, /* public instructions */ - OAdd, - OSub, - ODiv, - ORem, - OUDiv, - OURem, - OMul, - OAnd, - OOr, - OXor, - OSar, - OShr, - OShl, - OCmpw, - OCmpw1 = OCmpw + NICmp-1, - OCmpl, - OCmpl1 = OCmpl + NICmp-1, - OCmps, - OCmps1 = OCmps + NFCmp-1, - OCmpd, - OCmpd1 = OCmpd + NFCmp-1, - - OStoreb, - OStoreh, - OStorew, - OStorel, - OStores, - OStored, -#define isstore(o) (OStoreb <= o && o <= OStored) - OLoadsb, /* needs to match OExt (mem.c) */ - OLoadub, - OLoadsh, - OLoaduh, - OLoadsw, - OLoaduw, - OLoad, -#define isload(o) (OLoadsb <= o && o <= OLoad) - OExtsb, - OExtub, - OExtsh, - OExtuh, - OExtsw, - OExtuw, -#define isext(o) (OExtsb <= o && o <= OExtuw) - - OExts, - OTruncd, - OFtosi, - OSitof, - OCast, - - OAlloc, - OAlloc1 = OAlloc + NAlign-1, - - OCopy, + Oadd, + Osub, + Odiv, + Orem, + Oudiv, + Ourem, + Omul, + Oand, + Oor, + Oxor, + Osar, + Oshr, + Oshl, + Ocmpw, + Ocmpw1 = Ocmpw + NICmp-1, + Ocmpl, + Ocmpl1 = Ocmpl + NICmp-1, + Ocmps, + Ocmps1 = Ocmps + NFCmp-1, + Ocmpd, + Ocmpd1 = Ocmpd + NFCmp-1, + + Ostoreb, + Ostoreh, + Ostorew, + Ostorel, + Ostores, + Ostored, +#define isstore(o) (Ostoreb <= o && o <= Ostored) + Oloadsb, /* needs to match OExt (mem.c) */ + Oloadub, + Oloadsh, + Oloaduh, + Oloadsw, + Oloaduw, + Oload, +#define isload(o) (Oloadsb <= o && o <= Oload) + Oextsb, + Oextub, + Oextsh, + Oextuh, + Oextsw, + Oextuw, +#define isext(o) (Oextsb <= o && o <= Oextuw) + + Oexts, + Otruncd, + Oftosi, + Ositof, + Ocast, + + Oalloc, + Oalloc1 = Oalloc + NAlign-1, + + Ocopy, NPubOp, /* function instructions */ - OPar = NPubOp, - OParc, - OArg, - OArgc, - OCall, + Opar = NPubOp, + Oparc, + Oarg, + Oargc, + Ocall, /* reserved instructions */ - ONop, - OAddr, - OSwap, - OSign, - OSAlloc, - OXIDiv, - OXDiv, - OXCmp, - OXSet, - OXSetnp = OXSet + ICXnp, - OXSetp = OXSet + ICXp, - OXTest, + Onop, + Oaddr, + Oswap, + Osign, + Osalloc, + Oxidiv, + Oxdiv, + Oxcmp, + Oxset, + Oxsetnp = Oxset + ICxnp, + Oxsetp = Oxset + ICxp, + Oxtest, NOp }; enum Jmp { - JXXX, - JRet0, - JRetw, - JRetl, - JRets, - JRetd, - JRetc, -#define isret(j) (JRet0 <= j && j <= JRetc) - JJmp, - JJnz, - JXJc, - JXJnp = JXJc + ICXnp, - JXJp = JXJc + ICXp, + Jxxx, + Jret0, + Jretw, + Jretl, + Jrets, + Jretd, + Jretc, +#define isret(j) (Jret0 <= j && j <= Jretc) + Jjmp, + Jjnz, + Jxjc, + Jxjnp = Jxjc + ICxnp, + Jxjp = Jxjc + ICxp, NJmp }; diff --git a/copy.c b/copy.c index 71720f9..06a0fb3 100644 --- a/copy.c +++ b/copy.c @@ -55,7 +55,7 @@ visitins(Ins *i, Ref *cp, RList **w) { Ref r; - if (i->op == OCopy) { + if (i->op == Ocopy) { r = copyof(i->arg[0], cp); update(i->to, r, cp, w); } else if (!req(i->to, R)) { @@ -125,7 +125,7 @@ copy(Fn *fn) for (i=b->ins; i-b->ins < b->nins; i++) { r = copyof(i->to, cp); if (!req(r, i->to)) { - *i = (Ins){.op = ONop}; + *i = (Ins){.op = Onop}; continue; } for (a=0; a<2; a++) diff --git a/emit.c b/emit.c index 6b624e0..77fc1d4 100644 --- a/emit.c +++ b/emit.c @@ -43,70 +43,70 @@ static struct { short cls; char *asm; } omap[] = { - { OAdd, Ka, "+add%k %1, %=" }, - { OSub, Ka, "-sub%k %1, %=" }, - { OAnd, Ki, "+and%k %1, %=" }, - { OOr, Ki, "+or%k %1, %=" }, - { OXor, Ki, "+xor%k %1, %=" }, - { OSar, Ki, "-sar%k %B1, %=" }, - { OShr, Ki, "-shr%k %B1, %=" }, - { OShl, Ki, "-shl%k %B1, %=" }, - { OMul, Ki, "+imul%k %1, %=" }, - { OMul, Ks, "+mulss %1, %=" }, /* fixme */ - { OMul, Kd, "+mulsd %1, %=" }, - { ODiv, Ka, "-div%k %1, %=" }, - { OStorel, Ka, "movq %L0, %M1" }, - { OStorew, Ka, "movl %W0, %M1" }, - { OStoreh, Ka, "movw %H0, %M1" }, - { OStoreb, Ka, "movb %B0, %M1" }, - { OStores, Ka, "movss %S0, %M1" }, - { OStored, Ka, "movsd %D0, %M1" }, - { OLoad, Ka, "mov%k %M0, %=" }, - { OLoadsw, Kl, "movslq %M0, %L=" }, - { OLoadsw, Kw, "movl %M0, %W=" }, - { OLoaduw, Ki, "movl %M0, %W=" }, - { OLoadsh, Ki, "movsw%k %M0, %=" }, - { OLoaduh, Ki, "movzw%k %M0, %=" }, - { OLoadsb, Ki, "movsb%k %M0, %=" }, - { OLoadub, Ki, "movzb%k %M0, %=" }, - { OExtsw, Kl, "movslq %W0, %L=" }, - { OExtuw, Kl, "movl %W0, %W=" }, - { OExtsh, Ki, "movsw%k %H0, %=" }, - { OExtuh, Ki, "movzw%k %H0, %=" }, - { OExtsb, Ki, "movsb%k %B0, %=" }, - { OExtub, Ki, "movzb%k %B0, %=" }, - - { OExts, Kd, "cvtss2sd %0, %=" }, /* see if factorization is possible */ - { OTruncd, Ks, "cvttsd2ss %0, %=" }, - { OFtosi, Kw, "cvttss2si %0, %=" }, - { OFtosi, Kl, "cvttsd2si %0, %=" }, - { OSitof, Ks, "cvtsi2ss %W0, %=" }, - { OSitof, Kd, "cvtsi2sd %L0, %=" }, - { OCast, Ki, "movq %D0, %L=" }, - { OCast, Ka, "movq %L0, %D=" }, - - { OAddr, Ki, "lea%k %M0, %=" }, - { OSwap, Ki, "xchg%k %0, %1" }, - { OSign, Kl, "cqto" }, - { OSign, Kw, "cltd" }, - { OXDiv, Ki, "div%k %0" }, - { OXIDiv, Ki, "idiv%k %0" }, - { OXCmp, Ks, "comiss %S0, %S1" }, /* fixme, Kf */ - { OXCmp, Kd, "comisd %D0, %D1" }, - { OXCmp, Ki, "cmp%k %0, %1" }, - { OXTest, Ki, "test%k %0, %1" }, - { OXSet+ICule, Ki, "setbe %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICult, Ki, "setb %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICsle, Ki, "setle %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICslt, Ki, "setl %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICsgt, Ki, "setg %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICsge, Ki, "setge %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICugt, Ki, "seta %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICuge, Ki, "setae %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICeq, Ki, "setz %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICne, Ki, "setnz %B=\n\tmovzb%k %B=, %=" }, - { OXSet+ICXnp, Ki, "setnp %B=\n\tmovsb%k %B=, %=" }, - { OXSet+ICXp, Ki, "setp %B=\n\tmovsb%k %B=, %=" }, + { Oadd, Ka, "+add%k %1, %=" }, + { Osub, Ka, "-sub%k %1, %=" }, + { Oand, Ki, "+and%k %1, %=" }, + { Oor, Ki, "+or%k %1, %=" }, + { Oxor, Ki, "+xor%k %1, %=" }, + { Osar, Ki, "-sar%k %B1, %=" }, + { Oshr, Ki, "-shr%k %B1, %=" }, + { Oshl, Ki, "-shl%k %B1, %=" }, + { Omul, Ki, "+imul%k %1, %=" }, + { Omul, Ks, "+mulss %1, %=" }, /* fixme */ + { Omul, Kd, "+mulsd %1, %=" }, + { Odiv, Ka, "-div%k %1, %=" }, + { Ostorel, Ka, "movq %L0, %M1" }, + { Ostorew, Ka, "movl %W0, %M1" }, + { Ostoreh, Ka, "movw %H0, %M1" }, + { Ostoreb, Ka, "movb %B0, %M1" }, + { Ostores, Ka, "movss %S0, %M1" }, + { Ostored, Ka, "movsd %D0, %M1" }, + { Oload, Ka, "mov%k %M0, %=" }, + { Oloadsw, Kl, "movslq %M0, %L=" }, + { Oloadsw, Kw, "movl %M0, %W=" }, + { Oloaduw, Ki, "movl %M0, %W=" }, + { Oloadsh, Ki, "movsw%k %M0, %=" }, + { Oloaduh, Ki, "movzw%k %M0, %=" }, + { Oloadsb, Ki, "movsb%k %M0, %=" }, + { Oloadub, Ki, "movzb%k %M0, %=" }, + { Oextsw, Kl, "movslq %W0, %L=" }, + { Oextuw, Kl, "movl %W0, %W=" }, + { Oextsh, Ki, "movsw%k %H0, %=" }, + { Oextuh, Ki, "movzw%k %H0, %=" }, + { Oextsb, Ki, "movsb%k %B0, %=" }, + { Oextub, Ki, "movzb%k %B0, %=" }, + + { Oexts, Kd, "cvtss2sd %0, %=" }, /* see if factorization is possible */ + { Otruncd, Ks, "cvttsd2ss %0, %=" }, + { Oftosi, Kw, "cvttss2si %0, %=" }, + { Oftosi, Kl, "cvttsd2si %0, %=" }, + { Ositof, Ks, "cvtsi2ss %W0, %=" }, + { Ositof, Kd, "cvtsi2sd %L0, %=" }, + { Ocast, Ki, "movq %D0, %L=" }, + { Ocast, Ka, "movq %L0, %D=" }, + + { Oaddr, Ki, "lea%k %M0, %=" }, + { Oswap, Ki, "xchg%k %0, %1" }, + { Osign, Kl, "cqto" }, + { Osign, Kw, "cltd" }, + { Oxdiv, Ki, "div%k %0" }, + { Oxidiv, Ki, "idiv%k %0" }, + { Oxcmp, Ks, "comiss %S0, %S1" }, /* fixme, Kf */ + { Oxcmp, Kd, "comisd %D0, %D1" }, + { Oxcmp, Ki, "cmp%k %0, %1" }, + { Oxtest, Ki, "test%k %0, %1" }, + { Oxset+ICule, Ki, "setbe %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICult, Ki, "setb %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICsle, Ki, "setle %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICslt, Ki, "setl %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICsgt, Ki, "setg %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICsge, Ki, "setge %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICugt, Ki, "seta %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICuge, Ki, "setae %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICeq, Ki, "setz %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICne, Ki, "setnz %B=\n\tmovzb%k %B=, %=" }, + { Oxset+ICxnp, Ki, "setnp %B=\n\tmovsb%k %B=, %=" }, + { Oxset+ICxp, Ki, "setp %B=\n\tmovsb%k %B=, %=" }, { NOp, 0, 0 } }; @@ -200,7 +200,7 @@ emitcopy(Ref r1, Ref r2, int k, Fn *fn, FILE *f) { Ins icp; - icp.op = OCopy; + icp.op = Ocopy; icp.arg[0] = r2; icp.to = r1; icp.cls = k; @@ -364,11 +364,11 @@ emitins(Ins i, Fn *fn, FILE *f) } emitf(omap[o].asm, &i, fn, f); break; - case ONop: + case Onop: /* just do nothing for nops, they are inserted * by some passes */ break; - case OMul: + case Omul: /* here, we try to use the 3-addresss form * of multiplication when possible */ if (rtype(i.arg[1]) == RCon) { @@ -383,7 +383,7 @@ emitins(Ins i, Fn *fn, FILE *f) break; } goto Table; - case OSub: + case Osub: /* we have to use the negation trick to handle * some 3-address substractions */ if (req(i.to, i.arg[1])) { @@ -392,7 +392,7 @@ emitins(Ins i, Fn *fn, FILE *f) break; } goto Table; - case OCopy: + case Ocopy: /* make sure we don't emit useless copies, * also, we can use a trick to load 64-bits * registers, it's detailed in my note below @@ -413,7 +413,7 @@ emitins(Ins i, Fn *fn, FILE *f) } else if (!req(i.arg[0], i.to)) emitf("mov%k %0, %=", &i, fn, f); break; - case OCall: + case Ocall: /* calls simply have a weird syntax in AT&T * assembly... */ switch (rtype(i.arg[0])) { @@ -429,16 +429,16 @@ emitins(Ins i, Fn *fn, FILE *f) die("invalid call argument"); } break; - case OSAlloc: + case Osalloc: /* there is no good reason why this is here - * maybe we should split OSAlloc in 2 different + * maybe we should split Osalloc in 2 different * instructions depending on the result */ emitf("subq %L0, %%rsp", &i, fn, f); if (!req(i.to, R)) emitcopy(i.to, TMP(RSP), Kl, fn, f); break; - case OSwap: + case Oswap: if (KBASE(i.cls) == 0) goto Table; /* for floats, there is no swap instruction @@ -466,8 +466,8 @@ cneg(int cmp) case ICuge: return ICult; case ICeq: return ICne; case ICne: return ICeq; - case ICXnp: return ICXp; - case ICXp: return ICXnp; + case ICxnp: return ICxp; + case ICxp: return ICxnp; } } @@ -498,8 +498,8 @@ emitfn(Fn *fn, FILE *f) [ICugt] = "a", [ICuge] = "ae", [ICne] = "nz", - [ICXnp] = "np", - [ICXp] = "p" + [ICxnp] = "np", + [ICxp] = "p" }; static int id0; Blk *b, *s; @@ -529,7 +529,7 @@ emitfn(Fn *fn, FILE *f) for (i=b->ins; i!=&b->ins[b->nins]; i++) emitins(*i, fn, f); switch (b->jmp.type) { - case JRet0: + case Jret0: for (r=&rclob[NRClob]; r>rclob;) if (fn->reg & BIT(*--r)) { itmp.arg[0] = TMP(*r); @@ -540,14 +540,14 @@ emitfn(Fn *fn, FILE *f) "\tret\n" ); break; - case JJmp: + case Jjmp: Jmp: if (b->s1 != b->link) fprintf(f, "\tjmp %sbb%d /* %s */\n", locprefix, id0+b->s1->id, b->s1->name); break; default: - c = b->jmp.type - JXJc; + c = b->jmp.type - Jxjc; if (0 <= c && c <= NXICmp) { if (b->link == b->s2) { s = b->s1; diff --git a/fold.c b/fold.c index 3adb56b..923029e 100644 --- a/fold.c +++ b/fold.c @@ -124,7 +124,7 @@ visitjmp(Blk *b, int n, Fn *fn) int l; switch (b->jmp.type) { - case JJnz: + case Jjnz: l = latval(b->jmp.arg); assert(l != Top && "ssa invariant broken"); if (l == Bot) { @@ -143,7 +143,7 @@ visitjmp(Blk *b, int n, Fn *fn) flowrk = &edge[n][0]; } break; - case JJmp: + case Jjmp: edge[n][0].work = flowrk; flowrk = &edge[n][0]; break; @@ -226,7 +226,7 @@ fold(Fn *fn) visitjmp(b, n, fn); } b->visit++; - assert(b->jmp.type != JJmp + assert(b->jmp.type != Jjmp || !edge[n][0].dead || flowrk == &edge[n][0]); } @@ -290,13 +290,13 @@ fold(Fn *fn) } for (i=b->ins; i-b->ins < b->nins; i++) if (renref(&i->to)) - *i = (Ins){.op = ONop}; + *i = (Ins){.op = Onop}; else for (n=0; n<2; n++) renref(&i->arg[n]); renref(&b->jmp.arg); - if (b->jmp.type == JJnz && rtype(b->jmp.arg) == RCon) { - b->jmp.type = JJmp; + if (b->jmp.type == Jjnz && rtype(b->jmp.arg) == RCon) { + b->jmp.type = Jjmp; if (czero(&fn->con[b->jmp.arg.val], 0)) b->s1 = b->s2; b->jmp.arg = R; @@ -333,7 +333,7 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) lab = 0; l.s = cl->bits.i; r.s = cr->bits.i; - if (op == OAdd) { + if (op == Oadd) { if (cl->type == CAddr) { if (cr->type == CAddr) err("undefined addition (addr + addr)"); @@ -342,7 +342,7 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) else if (cr->type == CAddr) lab = cr->label; } - else if (op == OSub) { + else if (op == Osub) { if (cl->type == CAddr) { if (cr->type != CAddr) lab = cl->label; @@ -355,44 +355,44 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) else if (cl->type == CAddr || cr->type == CAddr) err("invalid address operand for '%s'", opdesc[op].name); switch (op) { - case OAdd: x = l.u + r.u; break; - case OSub: x = l.u - r.u; break; - case ODiv: x = l.s / r.s; break; - case ORem: x = l.s % r.s; break; - case OUDiv: x = l.u / r.u; break; - case OURem: x = l.u % r.u; break; - case OMul: x = l.u * r.u; break; - case OAnd: x = l.u & r.u; break; - case OOr: x = l.u | r.u; break; - case OXor: x = l.u ^ r.u; break; - case OSar: x = l.s >> (r.u & 63); break; - case OShr: x = l.u >> (r.u & 63); break; - case OShl: x = l.u << (r.u & 63); break; - case OExtsb: x = (int8_t)l.u; break; - case OExtub: x = (uint8_t)l.u; break; - case OExtsh: x = (int16_t)l.u; break; - case OExtuh: x = (uint16_t)l.u; break; - case OExtsw: x = (int32_t)l.u; break; - case OExtuw: x = (uint32_t)l.u; break; - case OFtosi: + case Oadd: x = l.u + r.u; break; + case Osub: x = l.u - r.u; break; + case Odiv: x = l.s / r.s; break; + case Orem: x = l.s % r.s; break; + case Oudiv: x = l.u / r.u; break; + case Ourem: x = l.u % r.u; break; + case Omul: x = l.u * r.u; break; + case Oand: x = l.u & r.u; break; + case Oor: x = l.u | r.u; break; + case Oxor: x = l.u ^ r.u; break; + case Osar: x = l.s >> (r.u & 63); break; + case Oshr: x = l.u >> (r.u & 63); break; + case Oshl: x = l.u << (r.u & 63); break; + case Oextsb: x = (int8_t)l.u; break; + case Oextub: x = (uint8_t)l.u; break; + case Oextsh: x = (int16_t)l.u; break; + case Oextuh: x = (uint16_t)l.u; break; + case Oextsw: x = (int32_t)l.u; break; + case Oextuw: x = (uint32_t)l.u; break; + case Oftosi: if (w) x = (int64_t)cl->bits.d; else x = (int32_t)cl->bits.s; break; - case OCast: + case Ocast: x = l.u; if (cl->type == CAddr) lab = cl->label; break; default: - if (OCmpw <= op && op <= OCmpl1) { - if (op <= OCmpw1) { + if (Ocmpw <= op && op <= Ocmpl1) { + if (op <= Ocmpw1) { l.u = (uint32_t)l.u; r.u = (uint32_t)r.u; } else - op -= OCmpl - OCmpw; - switch (op - OCmpw) { + op -= Ocmpl - Ocmpw; + switch (op - Ocmpw) { case ICule: x = l.u <= r.u; break; case ICult: x = l.u < r.u; break; case ICsle: x = l.s <= r.s; break; @@ -406,8 +406,8 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) default: die("unreachable"); } } - else if (OCmps <= op && op <= OCmps1) { - switch (op - OCmps) { + else if (Ocmps <= op && op <= Ocmps1) { + switch (op - Ocmps) { case FCle: x = l.fs <= r.fs; break; case FClt: x = l.fs < r.fs; break; case FCgt: x = l.fs > r.fs; break; @@ -419,8 +419,8 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) default: die("unreachable"); } } - else if (OCmpd <= op && op <= OCmpd1) { - switch (op - OCmpd) { + else if (Ocmpd <= op && op <= Ocmpd1) { + switch (op - Ocmpd) { case FCle: x = l.fd <= r.fd; break; case FClt: x = l.fd < r.fd; break; case FCgt: x = l.fd > r.fd; break; @@ -453,13 +453,13 @@ foldflt(Con *res, int op, int w, Con *cl, Con *cr) ld = cl->bits.d; rd = cr->bits.d; switch (op) { - case OAdd: xd = ld + rd; break; - case OSub: xd = ld - rd; break; - case ODiv: xd = ld / rd; break; - case OMul: xd = ld * rd; break; - case OSitof: xd = cl->bits.i; break; - case OExts: xd = cl->bits.s; break; - case OCast: xd = ld; break; + case Oadd: xd = ld + rd; break; + case Osub: xd = ld - rd; break; + case Odiv: xd = ld / rd; break; + case Omul: xd = ld * rd; break; + case Ositof: xd = cl->bits.i; break; + case Oexts: xd = cl->bits.s; break; + case Ocast: xd = ld; break; default: die("unreachable"); } *res = (Con){CBits, .bits={.d=xd}, .flt=2}; @@ -467,13 +467,13 @@ foldflt(Con *res, int op, int w, Con *cl, Con *cr) ls = cl->bits.s; rs = cr->bits.s; switch (op) { - case OAdd: xs = ls + rs; break; - case OSub: xs = ls - rs; break; - case ODiv: xs = ls / rs; break; - case OMul: xs = ls * rs; break; - case OSitof: xs = cl->bits.i; break; - case OTruncd: xs = cl->bits.d; break; - case OCast: xs = ls; break; + case Oadd: xs = ls + rs; break; + case Osub: xs = ls - rs; break; + case Odiv: xs = ls / rs; break; + case Omul: xs = ls * rs; break; + case Ositof: xs = cl->bits.i; break; + case Otruncd: xs = cl->bits.d; break; + case Ocast: xs = ls; break; default: die("unreachable"); } *res = (Con){CBits, .bits={.s=xs}, .flt=1}; @@ -486,8 +486,8 @@ opfold(int op, int cls, Con *cl, Con *cr, Fn *fn) int nc; Con c; - if ((op == ODiv || op == OUDiv - || op == ORem || op == OURem) && czero(cr, KWIDE(cls))) + if ((op == Odiv || op == Oudiv + || op == Orem || op == Ourem) && czero(cr, KWIDE(cls))) err("null divisor in '%s'", opdesc[op].name); if (cls == Kw || cls == Kl) foldint(&c, op, cls == Kl, cl, cr); diff --git a/isel.c b/isel.c index 31ea4ea..bebc47e 100644 --- a/isel.c +++ b/isel.c @@ -40,8 +40,8 @@ fcmptoi(int fc) case FCge: return ICuge; case FCne: return ICne; case FCeq: return ICeq; - case FCo: return ICXnp; - case FCuo: return ICXp; + case FCo: return ICxnp; + case FCuo: return ICxp; } } @@ -50,20 +50,20 @@ iscmp(int op, int *pk, int *pc) { int k, c; - if (OCmpw <= op && op <= OCmpw1) { - c = op - OCmpw; + if (Ocmpw <= op && op <= Ocmpw1) { + c = op - Ocmpw; k = Kw; } - else if (OCmpl <= op && op <= OCmpl1) { - c = op - OCmpl; + else if (Ocmpl <= op && op <= Ocmpl1) { + c = op - Ocmpl; k = Kl; } - else if (OCmps <= op && op <= OCmps1) { - c = fcmptoi(op - OCmps); + else if (Ocmps <= op && op <= Ocmps1) { + c = fcmptoi(op - Ocmps); k = Ks; } - else if (OCmpd <= op && op <= OCmpd1) { - c = fcmptoi(op - OCmpd); + else if (Ocmpd <= op && op <= Ocmpd1) { + c = fcmptoi(op - Ocmpd); k = Kd; } else @@ -141,7 +141,7 @@ fixarg(Ref *r, int k, int phi, Fn *fn) * long temporary */ r1 = newtmp("isel", Kl, fn); - emit(OCopy, Kl, r1, r0, R); + emit(Ocopy, Kl, r1, r0, R); } else if (s != -1) { /* load fast locals' addresses into @@ -149,7 +149,7 @@ fixarg(Ref *r, int k, int phi, Fn *fn) * instruction */ r1 = newtmp("isel", Kl, fn); - emit(OAddr, Kl, r1, SLOT(s), R); + emit(Oaddr, Kl, r1, SLOT(s), R); } *r = r1; } @@ -190,7 +190,7 @@ selcmp(Ref arg[2], int k, Fn *fn) arg[0] = r; } assert(rtype(arg[0]) != RCon); - emit(OXCmp, k, R, arg[1], arg[0]); + emit(Oxcmp, k, R, arg[1], arg[0]); iarg = curi->arg; fixarg(&iarg[0], k, 0, fn); fixarg(&iarg[1], k, 0, fn); @@ -214,16 +214,16 @@ sel(Ins i, ANum *an, Fn *fn) i0 = curi; k = i.cls; switch (i.op) { - case ODiv: - case ORem: - case OUDiv: - case OURem: - if (i.op == ODiv || i.op == OUDiv) + case Odiv: + case Orem: + case Oudiv: + case Ourem: + if (i.op == Odiv || i.op == Oudiv) r0 = TMP(RAX), r1 = TMP(RDX); else r0 = TMP(RDX), r1 = TMP(RAX); - emit(OCopy, k, i.to, r0, R); - emit(OCopy, k, R, r1, R); + emit(Ocopy, k, i.to, r0, R); + emit(Ocopy, k, R, r1, R); if (rtype(i.arg[1]) == RCon) { /* immediates not allowed for * divisions in x86 @@ -234,63 +234,63 @@ sel(Ins i, ANum *an, Fn *fn) if (fn->tmp[r0.val].slot != -1) err("unlikely argument %%%s in %s", fn->tmp[r0.val].name, opdesc[i.op].name); - if (i.op == ODiv || i.op == ORem) { - emit(OXIDiv, k, R, r0, R); - emit(OSign, k, TMP(RDX), TMP(RAX), R); + if (i.op == Odiv || i.op == Orem) { + emit(Oxidiv, k, R, r0, R); + emit(Osign, k, TMP(RDX), TMP(RAX), R); } else { - emit(OXDiv, k, R, r0, R); - emit(OCopy, k, TMP(RDX), CON_Z, R); + emit(Oxdiv, k, R, r0, R); + emit(Ocopy, k, TMP(RDX), CON_Z, R); } - emit(OCopy, k, TMP(RAX), i.arg[0], R); + emit(Ocopy, k, TMP(RAX), i.arg[0], R); fixarg(&curi->arg[0], k, 0, fn); if (rtype(i.arg[1]) == RCon) - emit(OCopy, k, r0, i.arg[1], R); + emit(Ocopy, k, r0, i.arg[1], R); break; - case OSar: - case OShr: - case OShl: + case Osar: + case Oshr: + case Oshl: if (rtype(i.arg[1]) == RCon) goto Emit; r0 = i.arg[1]; i.arg[1] = TMP(RCX); - emit(OCopy, Kw, R, TMP(RCX), R); + emit(Ocopy, Kw, R, TMP(RCX), R); emiti(i); - emit(OCopy, Kw, TMP(RCX), r0, R); + emit(Ocopy, Kw, TMP(RCX), r0, R); break; - case ONop: + case Onop: break; - case OStored: - case OStores: - case OStorel: - case OStorew: - case OStoreh: - case OStoreb: + case Ostored: + case Ostores: + case Ostorel: + case Ostorew: + case Ostoreh: + case Ostoreb: if (rtype(i.arg[0]) == RCon) { - if (i.op == OStored) - i.op = OStorel; - if (i.op == OStores) - i.op = OStorew; + if (i.op == Ostored) + i.op = Ostorel; + if (i.op == Ostores) + i.op = Ostorew; } seladdr(&i.arg[1], an, fn); goto Emit; - case_OLoad: + case_Oload: seladdr(&i.arg[0], an, fn); goto Emit; - case OCall: - case OSAlloc: - case OCopy: - case OAdd: - case OSub: - case OMul: - case OAnd: - case OOr: - case OXor: - case OXTest: - case OFtosi: - case OSitof: - case OExts: - case OTruncd: - case OCast: + case Ocall: + case Osalloc: + case Ocopy: + case Oadd: + case Osub: + case Omul: + case Oand: + case Oor: + case Oxor: + case Oxtest: + case Oftosi: + case Ositof: + case Oexts: + case Otruncd: + case Ocast: case_OExt: Emit: emiti(i); @@ -298,9 +298,9 @@ Emit: fixarg(&iarg[0], argcls(&i, 0), 0, fn); fixarg(&iarg[1], argcls(&i, 1), 0, fn); break; - case OAlloc: - case OAlloc+1: - case OAlloc+2: /* == OAlloc1 */ + case Oalloc: + case Oalloc+1: + case Oalloc+2: /* == Oalloc1 */ /* we need to make sure * the stack remains aligned * (rsp = 0) mod 16 @@ -310,14 +310,14 @@ Emit: if (sz < 0 || sz >= INT_MAX-15) err("invalid alloc size %"PRId64, sz); sz = (sz + 15) & -16; - emit(OSAlloc, Kl, i.to, getcon(sz, fn), R); + emit(Osalloc, Kl, i.to, getcon(sz, fn), R); } else { /* r0 = (i.arg[0] + 15) & -16 */ r0 = newtmp("isel", Kl, fn); r1 = newtmp("isel", Kl, fn); - emit(OSAlloc, Kl, i.to, r0, R); - emit(OAnd, Kl, r0, r1, getcon(-16, fn)); - emit(OAdd, Kl, r1, i.arg[0], getcon(15, fn)); + emit(Osalloc, Kl, i.to, r0, R); + emit(Oand, Kl, r0, r1, getcon(-16, fn)); + emit(Oadd, Kl, r1, i.arg[0], getcon(15, fn)); if (fn->tmp[i.arg[0].val].slot != -1) err("unlikely argument %%%s in %s", fn->tmp[i.arg[0].val].name, opdesc[i.op].name); @@ -327,11 +327,11 @@ Emit: if (isext(i.op)) goto case_OExt; if (isload(i.op)) - goto case_OLoad; + goto case_Oload; if (iscmp(i.op, &kc, &x)) { if (rtype(i.arg[0]) == RCon) x = icmpop(x); - emit(OXSet+x, k, i.to, R, R); + emit(Oxset+x, k, i.to, R, R); selcmp(i.arg, kc, fn); break; } @@ -365,14 +365,14 @@ seljmp(Blk *b, Fn *fn) int c, k; Ins *fi; - if (b->jmp.type == JRet0 || b->jmp.type == JJmp) + if (b->jmp.type == Jret0 || b->jmp.type == Jjmp) return; - assert(b->jmp.type == JJnz); + assert(b->jmp.type == Jjnz); r = b->jmp.arg; b->jmp.arg = R; assert(!req(r, R) && rtype(r) != RCon); if (b->s1 == b->s2) { - b->jmp.type = JJmp; + b->jmp.type = Jjmp; b->s2 = 0; return; } @@ -381,20 +381,20 @@ seljmp(Blk *b, Fn *fn) if (iscmp(fi->op, &k, &c)) { if (rtype(fi->arg[0]) == RCon) c = icmpop(c); - b->jmp.type = JXJc + c; + b->jmp.type = Jxjc + c; if (fn->tmp[r.val].nuse == 1) { assert(fn->tmp[r.val].ndef == 1); selcmp(fi->arg, k, fn); - *fi = (Ins){.op = ONop}; + *fi = (Ins){.op = Onop}; } return; } - if (fi->op == OAnd && fn->tmp[r.val].nuse == 1 + if (fi->op == Oand && fn->tmp[r.val].nuse == 1 && (rtype(fi->arg[0]) == RTmp || rtype(fi->arg[1]) == RTmp)) { - fi->op = OXTest; + fi->op = Oxtest; fi->to = R; - b->jmp.type = JXJc + ICne; + b->jmp.type = Jxjc + ICne; if (rtype(fi->arg[1]) == RCon) { r = fi->arg[1]; fi->arg[1] = fi->arg[0]; @@ -407,12 +407,12 @@ seljmp(Blk *b, Fn *fn) * has to be marked as live */ if (fn->tmp[r.val].nuse == 1) - emit(OCopy, Kw, R, r, R); - b->jmp.type = JXJc + ICne; + emit(Ocopy, Kw, R, r, R); + b->jmp.type = Jxjc + ICne; return; } selcmp((Ref[2]){r, CON_Z}, Kw, fn); /* todo, add long branch if non-zero */ - b->jmp.type = JXJc + ICne; + b->jmp.type = Jxjc + ICne; } static int @@ -474,13 +474,13 @@ anumber(ANum *ai, Blk *b, Con *con) for (i=b->ins; i-b->ins < b->nins; i++) { if (rtype(i->to) == RTmp) ai[i->to.val].i = i; - if (i->op != OAdd && i->op != OMul) + if (i->op != Oadd && i->op != Omul) continue; a1 = aref(i->arg[0], ai); a2 = aref(i->arg[1], ai); t1 = a1 != 1 && a1 != 2; t2 = a2 != 1 && a2 != 2; - if (i->op == OAdd) { + if (i->op == Oadd) { a = add[n1 = a1][n2 = a2]; if (t1 && a < add[0][a2]) a = add[n1 = 0][n2 = a2]; @@ -586,7 +586,7 @@ isel(Fn *fn) /* assign slots to fast allocs */ b = fn->start; /* specific to NAlign == 3 */ /* or change n=4 and sz /= 4 below */ - for (al=OAlloc, n=4; al<=OAlloc1; al++, n*=2) + for (al=Oalloc, n=4; al<=Oalloc1; al++, n*=2) for (i=b->ins; i-b->ins < b->nins; i++) if (i->op == al) { if (rtype(i->arg[0]) != RCon) @@ -598,7 +598,7 @@ isel(Fn *fn) sz /= 4; fn->tmp[i->to.val].slot = fn->slot; fn->slot += sz; - *i = (Ins){.op = ONop}; + *i = (Ins){.op = Onop}; } /* process basic blocks */ diff --git a/live.c b/live.c index 785a535..09a4a25 100644 --- a/live.c +++ b/live.c @@ -115,7 +115,7 @@ Again: for (k=0; k<2; k++) b->nlive[k] = nlv[k]; for (i=&b->ins[b->nins]; i!=b->ins;) { - if ((--i)->op == OCall && rtype(i->arg[1]) == RCall) { + if ((--i)->op == Ocall && rtype(i->arg[1]) == RCall) { b->in->t[0] &= ~retregs(i->arg[1], m); for (k=0; k<2; k++) nlv[k] -= m[k]; diff --git a/mem.c b/mem.c index c59d7fe..ea0bef7 100644 --- a/mem.c +++ b/mem.c @@ -4,10 +4,10 @@ static int loadsz(Ins *l) { switch (l->op) { - case OLoadsb: case OLoadub: return 1; - case OLoadsh: case OLoaduh: return 2; - case OLoadsw: case OLoaduw: return 4; - case OLoad: return KWIDE(l->cls) ? 8 : 4; + case Oloadsb: case Oloadub: return 1; + case Oloadsh: case Oloaduh: return 2; + case Oloadsw: case Oloaduw: return 4; + case Oload: return KWIDE(l->cls) ? 8 : 4; } die("unreachable"); } @@ -16,10 +16,10 @@ static int storesz(Ins *s) { switch (s->op) { - case OStoreb: return 1; - case OStoreh: return 2; - case OStorew: case OStores: return 4; - case OStorel: case OStored: return 8; + case Ostoreb: return 1; + case Ostoreh: return 2; + case Ostorew: case Ostores: return 4; + case Ostorel: case Ostored: return 8; } die("unreachable"); } @@ -38,7 +38,7 @@ memopt(Fn *fn) /* promote uniform stack slots to temporaries */ b = fn->start; for (i=b->ins; i-b->ins < b->nins; i++) { - if (OAlloc > i->op || i->op > OAlloc1) + if (Oalloc > i->op || i->op > Oalloc1) continue; /* specific to NAlign == 3 */ assert(rtype(i->to) == RTmp); @@ -67,14 +67,14 @@ memopt(Fn *fn) goto Skip; } /* get rid of the alloc and replace uses */ - *i = (Ins){.op = ONop}; + *i = (Ins){.op = Onop}; t->ndef--; ue = &t->use[t->nuse]; for (u=t->use; u!=ue; u++) { l = u->u.ins; if (isstore(l->op)) { l->cls = k; - l->op = OCopy; + l->op = Ocopy; l->to = l->arg[1]; l->arg[1] = R; t->nuse--; @@ -86,16 +86,16 @@ memopt(Fn *fn) /* try to turn loads into copies so we * can eliminate them later */ switch(l->op) { - case OLoad: - case OLoadsw: - case OLoaduw: + case Oload: + case Oloadsw: + case Oloaduw: if (KBASE(k) != KBASE(l->cls)) - l->op = OCast; + l->op = Ocast; else - l->op = OCopy; + l->op = Ocopy; break; default: - l->op = OExtsb + (l->op - OLoadsb); + l->op = Oextsb + (l->op - Oloadsb); break; } } diff --git a/parse.c b/parse.c index 03a89f1..373414e 100644 --- a/parse.c +++ b/parse.c @@ -11,72 +11,72 @@ OpDesc opdesc[NOp] = { #define A(a,b,c,d) {[Kw]=K##a, [Kl]=K##b, [Ks]=K##c, [Kd]=K##d} /* NAME NM ARGCLS0 ARGCLS1 SF LF FLD*/ - [OAdd] = { "add", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 }, - [OSub] = { "sub", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 }, - [ODiv] = { "div", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 }, - [ORem] = { "rem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, - [OUDiv] = { "udiv", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, - [OURem] = { "urem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, - [OMul] = { "mul", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 }, - [OAnd] = { "and", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, - [OOr] = { "or", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, - [OXor] = { "xor", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, - [OSar] = { "sar", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, - [OShr] = { "shr", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, - [OShl] = { "shl", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, - [OStored] = { "stored", 0, {A(d,d,d,d), A(m,m,m,m)}, 0, 1, 0 }, - [OStores] = { "stores", 0, {A(s,s,s,s), A(m,m,m,m)}, 0, 1, 0 }, - [OStorel] = { "storel", 0, {A(l,l,l,l), A(m,m,m,m)}, 0, 1, 0 }, - [OStorew] = { "storew", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, - [OStoreh] = { "storeh", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, - [OStoreb] = { "storeb", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, - [OLoad] = { "load", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 1, 0 }, - [OLoadsw] = { "loadsw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OLoaduw] = { "loaduw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OLoadsh] = { "loadsh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OLoaduh] = { "loaduh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OLoadsb] = { "loadsb", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OLoadub] = { "loadub", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OExtsw] = { "extsw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 }, - [OExtuw] = { "extuw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 }, - [OExtsh] = { "extsh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, - [OExtuh] = { "extuh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, - [OExtsb] = { "extsb", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, - [OExtub] = { "extub", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, - [OExts] = { "exts", 0, {A(e,e,e,s), A(e,e,e,x)}, 0, 1, 1 }, - [OTruncd] = { "truncd", 0, {A(e,e,d,e), A(e,e,x,e)}, 0, 1, 1 }, - [OFtosi] = { "ftosi", 0, {A(s,d,e,e), A(x,x,e,e)}, 0, 1, 1 }, - [OSitof] = { "sitof", 0, {A(e,e,w,l), A(e,e,x,x)}, 0, 1, 1 }, - [OCast] = { "cast", 0, {A(s,d,w,l), A(x,x,x,x)}, 0, 1, 1 }, - [OCopy] = { "copy", 1, {A(w,l,s,d), A(x,x,x,x)}, 0, 1, 0 }, - [ONop] = { "nop", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 1, 0 }, - [OSwap] = { "swap", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 0 }, - [OSign] = { "sign", 0, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, - [OSAlloc] = { "salloc", 0, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, - [OXIDiv] = { "xidiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, - [OXDiv] = { "xdiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, - [OXCmp] = { "xcmp", 1, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 0 }, - [OXTest] = { "xtest", 1, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 0 }, - [OAddr] = { "addr", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, - [OPar] = { "parn", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 0, 0 }, - [OParc] = { "parc", 0, {A(e,x,e,e), A(e,x,e,e)}, 0, 0, 0 }, - [OArg] = { "arg", 0, {A(w,l,s,d), A(x,x,x,x)}, 0, 0, 0 }, - [OArgc] = { "argc", 0, {A(e,x,e,e), A(e,l,e,e)}, 0, 0, 0 }, - [OCall] = { "call", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 0, 0 }, - [OXSetnp] = { "xsetnp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 }, - [OXSetp] = { "xsetp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 }, - [OAlloc] = { "alloc4", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, - [OAlloc+1] = { "alloc8", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, - [OAlloc+2] = { "alloc16", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, + [Oadd] = { "add", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 }, + [Osub] = { "sub", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 }, + [Odiv] = { "div", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 }, + [Orem] = { "rem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, + [Oudiv] = { "udiv", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, + [Ourem] = { "urem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 }, + [Omul] = { "mul", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 }, + [Oand] = { "and", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, + [Oor] = { "or", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, + [Oxor] = { "xor", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 }, + [Osar] = { "sar", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, + [Oshr] = { "shr", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, + [Oshl] = { "shl", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 }, + [Ostored] = { "stored", 0, {A(d,d,d,d), A(m,m,m,m)}, 0, 1, 0 }, + [Ostores] = { "stores", 0, {A(s,s,s,s), A(m,m,m,m)}, 0, 1, 0 }, + [Ostorel] = { "storel", 0, {A(l,l,l,l), A(m,m,m,m)}, 0, 1, 0 }, + [Ostorew] = { "storew", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, + [Ostoreh] = { "storeh", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, + [Ostoreb] = { "storeb", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 }, + [Oload] = { "load", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 1, 0 }, + [Oloadsw] = { "loadsw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oloaduw] = { "loaduw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oloadsh] = { "loadsh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oloaduh] = { "loaduh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oloadsb] = { "loadsb", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oloadub] = { "loadub", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Oextsw] = { "extsw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 }, + [Oextuw] = { "extuw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 }, + [Oextsh] = { "extsh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, + [Oextuh] = { "extuh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, + [Oextsb] = { "extsb", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, + [Oextub] = { "extub", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 }, + [Oexts] = { "exts", 0, {A(e,e,e,s), A(e,e,e,x)}, 0, 1, 1 }, + [Otruncd] = { "truncd", 0, {A(e,e,d,e), A(e,e,x,e)}, 0, 1, 1 }, + [Oftosi] = { "ftosi", 0, {A(s,d,e,e), A(x,x,e,e)}, 0, 1, 1 }, + [Ositof] = { "sitof", 0, {A(e,e,w,l), A(e,e,x,x)}, 0, 1, 1 }, + [Ocast] = { "cast", 0, {A(s,d,w,l), A(x,x,x,x)}, 0, 1, 1 }, + [Ocopy] = { "copy", 1, {A(w,l,s,d), A(x,x,x,x)}, 0, 1, 0 }, + [Onop] = { "nop", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 1, 0 }, + [Oswap] = { "swap", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 0 }, + [Osign] = { "sign", 0, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, + [Osalloc] = { "salloc", 0, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, + [Oxidiv] = { "xidiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, + [Oxdiv] = { "xdiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 }, + [Oxcmp] = { "xcmp", 1, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 0 }, + [Oxtest] = { "xtest", 1, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 0 }, + [Oaddr] = { "addr", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Opar] = { "parn", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 0, 0 }, + [Oparc] = { "parc", 0, {A(e,x,e,e), A(e,x,e,e)}, 0, 0, 0 }, + [Oarg] = { "arg", 0, {A(w,l,s,d), A(x,x,x,x)}, 0, 0, 0 }, + [Oargc] = { "argc", 0, {A(e,x,e,e), A(e,l,e,e)}, 0, 0, 0 }, + [Ocall] = { "call", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 0, 0 }, + [Oxsetnp] = { "xsetnp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 }, + [Oxsetp] = { "xsetp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 }, + [Oalloc] = { "alloc4", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, + [Oalloc+1] = { "alloc8", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, + [Oalloc+2] = { "alloc16", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, #define X(c) \ - [OCmpw+IC##c] = { "c" #c "w", 0, {A(w,w,e,e), A(w,w,e,e)}, 1, 0, 1 }, \ - [OCmpl+IC##c] = { "c" #c "l", 0, {A(l,l,e,e), A(l,l,e,e)}, 1, 0, 1 }, \ - [OXSet+IC##c] = { "xset" #c, 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 1, 0 }, + [Ocmpw+IC##c] = { "c" #c "w", 0, {A(w,w,e,e), A(w,w,e,e)}, 1, 0, 1 }, \ + [Ocmpl+IC##c] = { "c" #c "l", 0, {A(l,l,e,e), A(l,l,e,e)}, 1, 0, 1 }, \ + [Oxset+IC##c] = { "xset" #c, 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 1, 0 }, ICMPS(X) #undef X #define X(c) \ - [OCmps+FC##c] = { "c" #c "s", 0, {A(s,s,e,e), A(s,s,e,e)}, 1, 0, 1 }, \ - [OCmpd+FC##c] = { "c" #c "d", 0, {A(d,d,e,e), A(d,d,e,e)}, 1, 0, 1 }, + [Ocmps+FC##c] = { "c" #c "s", 0, {A(s,s,e,e), A(s,s,e,e)}, 1, 0, 1 }, \ + [Ocmpd+FC##c] = { "c" #c "d", 0, {A(d,d,e,e), A(d,d,e,e)}, 1, 0, 1 }, FCMPS(X) #undef X @@ -191,12 +191,12 @@ lex() { "d", TD }, { "s", TS }, { "z", TZ }, - { "loadw", OLoad }, /* for convenience */ - { "loadl", OLoad }, - { "loads", OLoad }, - { "loadd", OLoad }, - { "alloc1", OAlloc }, - { "alloc2", OAlloc }, + { "loadw", Oload }, /* for convenience */ + { "loadl", Oload }, + { "loads", Oload }, + { "loadd", Oload }, + { "alloc1", Oalloc }, + { "alloc2", Oalloc }, { 0, TXXX } }; static char tok[NString]; @@ -453,14 +453,14 @@ parserefl(int arg) err("invalid function parameter"); if (k == 4) if (arg) - *curi = (Ins){OArgc, R, {TYPE(ty), r}, Kl}; + *curi = (Ins){Oargc, R, {TYPE(ty), r}, Kl}; else - *curi = (Ins){OParc, r, {TYPE(ty)}, Kl}; + *curi = (Ins){Oparc, r, {TYPE(ty)}, Kl}; else if (arg) - *curi = (Ins){OArg, R, {r}, k}; + *curi = (Ins){Oarg, R, {r}, k}; else - *curi = (Ins){OPar, r, {R}, k}; + *curi = (Ins){Opar, r, {R}, k}; curi++; if (peek() == TRParen) break; @@ -522,12 +522,12 @@ parseline(PState ps) break; case TLbl: b = findblk(tokval.str); - if (curb && curb->jmp.type == JXXX) { + if (curb && curb->jmp.type == Jxxx) { closeblk(); - curb->jmp.type = JJmp; + curb->jmp.type = Jjmp; curb->s1 = b; } - if (b->jmp.type != JXXX) + if (b->jmp.type != Jxxx) err("multiple definitions of block @%s", b->name); *blink = b; curb = b; @@ -536,9 +536,9 @@ parseline(PState ps) return PPhi; case TRet: curb->jmp.type = (int[]){ - JRetw, JRetl, - JRets, JRetd, - JRetc, JRet0 + Jretw, Jretl, + Jrets, Jretd, + Jretc, Jret0 }[rcls]; if (rcls < 5) { r = parseref(); @@ -548,10 +548,10 @@ parseline(PState ps) } goto Close; case TJmp: - curb->jmp.type = JJmp; + curb->jmp.type = Jjmp; goto Jump; case TJnz: - curb->jmp.type = JJnz; + curb->jmp.type = Jjnz; r = parseref(); if (req(r, R)) err("invalid argument for jnz jump"); @@ -560,7 +560,7 @@ parseline(PState ps) Jump: expect(TLbl); curb->s1 = findblk(tokval.str); - if (curb->jmp.type != JJmp) { + if (curb->jmp.type != Jjmp) { expect(TComma); expect(TLbl); curb->s2 = findblk(tokval.str); @@ -586,7 +586,7 @@ DoOp: arg[0] = parseref(); parserefl(1); expect(TNL); - op = OCall; + op = Ocall; if (k == 4) { k = Kl; arg[1] = TYPE(ty); @@ -721,19 +721,19 @@ typecheck(Fn *fn) } r = b->jmp.arg; if (isret(b->jmp.type)) { - if (b->jmp.type == JRetc) { + if (b->jmp.type == Jretc) { if (!usecheck(r, Kl, fn)) goto JErr; - } else if (!usecheck(r, b->jmp.type-JRetw, fn)) + } else if (!usecheck(r, b->jmp.type-Jretw, fn)) goto JErr; } - if (b->jmp.type == JJnz && !usecheck(r, Kw, fn)) + if (b->jmp.type == Jjnz && !usecheck(r, Kw, fn)) JErr: err("invalid type for jump argument %%%s in block @%s", fn->tmp[r.val].name, b->name); - if (b->s1 && b->s1->jmp.type == JXXX) + if (b->s1 && b->s1->jmp.type == Jxxx) err("block @%s is used undefined", b->s1->name); - if (b->s2 && b->s2->jmp.type == JXXX) + if (b->s2 && b->s2->jmp.type == Jxxx) err("block @%s is used undefined", b->s2->name); } } @@ -775,7 +775,7 @@ parsefn(int export) while (ps != PEnd); if (!curb) err("empty function"); - if (curb->jmp.type == JXXX) + if (curb->jmp.type == Jxxx) err("last block misses jump"); curf->mem = vnew(0, sizeof curf->mem[0]); curf->nmem = 0; @@ -1086,26 +1086,26 @@ void printfn(Fn *fn, FILE *f) { static char *jtoa[NJmp] = { - [JRet0] = "ret", - [JRetw] = "retw", - [JRetl] = "retl", - [JRetc] = "retc", - [JRets] = "rets", - [JRetd] = "retd", - [JJnz] = "jnz", - [JXJnp] = "xjnp", - [JXJp] = "xjp", - #define X(c) [JXJc+IC##c] = "xj" #c, + [Jret0] = "ret", + [Jretw] = "retw", + [Jretl] = "retl", + [Jretc] = "retc", + [Jrets] = "rets", + [Jretd] = "retd", + [Jjnz] = "jnz", + [Jxjnp] = "xjnp", + [Jxjp] = "xjp", + #define X(c) [Jxjc+IC##c] = "xj" #c, ICMPS(X) #undef X }; static char prcls[NOp] = { - [OArg] = 1, - [OSwap] = 1, - [OXCmp] = 1, - [OXTest] = 1, - [OXDiv] = 1, - [OXIDiv] = 1, + [Oarg] = 1, + [Oswap] = 1, + [Oxcmp] = 1, + [Oxtest] = 1, + [Oxdiv] = 1, + [Oxidiv] = 1, }; static char ktoc[] = "wlsd"; Blk *b; @@ -1154,28 +1154,28 @@ printfn(Fn *fn, FILE *f) fprintf(f, "\n"); } switch (b->jmp.type) { - case JRet0: - case JRetw: - case JRetl: - case JRets: - case JRetd: - case JRetc: + case Jret0: + case Jretw: + case Jretl: + case Jrets: + case Jretd: + case Jretc: fprintf(f, "\t%s", jtoa[b->jmp.type]); - if (b->jmp.type != JRet0 || !req(b->jmp.arg, R)) { + if (b->jmp.type != Jret0 || !req(b->jmp.arg, R)) { fprintf(f, " "); printref(b->jmp.arg, fn, f); } - if (b->jmp.type == JRetc) + if (b->jmp.type == Jretc) fprintf(f, ", :%s", typ[fn->retty].name); fprintf(f, "\n"); break; - case JJmp: + case Jjmp: if (b->s1 != b->link) fprintf(f, "\tjmp @%s\n", b->s1->name); break; default: fprintf(f, "\t%s ", jtoa[b->jmp.type]); - if (b->jmp.type == JJnz) { + if (b->jmp.type == Jjnz) { printref(b->jmp.arg, fn, f); fprintf(f, ", "); } diff --git a/rega.c b/rega.c index 2fac0d8..da4e9e5 100644 --- a/rega.c +++ b/rega.c @@ -224,10 +224,10 @@ pmrec(enum PMStat *status, int i, int *k) } status[i] = Moved; if (req(swp, R)) { - *curi++ = (Ins){OCopy, pm[i].dst, {pm[i].src}, pm[i].cls}; + *curi++ = (Ins){Ocopy, pm[i].dst, {pm[i].src}, pm[i].cls}; return R; } else if (!req(swp, pm[i].src)) { - *curi++ = (Ins){OSwap, R, {pm[i].src, pm[i].dst}, *k}; + *curi++ = (Ins){Oswap, R, {pm[i].src, pm[i].dst}, *k}; return swp; } else return R; @@ -273,7 +273,7 @@ move(int r, Ref to, RMap *m) static int regcpy(Ins *i) { - return i->op == OCopy && isreg(i->arg[0]); + return i->op == Ocopy && isreg(i->arg[0]); } static Ins * @@ -291,7 +291,7 @@ dopm(Blk *b, Ins *i, RMap *m) move(i->arg[0].val, i->to, m); } while (i != b->ins && regcpy(i-1)); assert(m0.n <= m->n); - if (i != b->ins && (i-1)->op == OCall) { + if (i != b->ins && (i-1)->op == Ocall) { def = retregs((i-1)->arg[1], 0); for (r=0; r<NRSave; r++) if (!(BIT(rsave[r]) & def)) @@ -371,13 +371,13 @@ doblk(Blk *b, RMap *cur) } for (i=&b->ins[b->nins]; i!=b->ins;) { switch ((--i)->op) { - case OCall: + case Ocall: rs = argregs(i->arg[1], 0); for (r=0; r<NRSave; r++) if (!(BIT(rsave[r]) & rs)) rfree(cur, rsave[r]); break; - case OCopy: + case Ocopy: if (isreg(i->arg[0])) { i = dopm(b, i, cur); continue; @@ -391,7 +391,7 @@ doblk(Blk *b, RMap *cur) assert(rtype(i->to) == RTmp); r = rfree(cur, i->to.val); if (r == -1 && !isreg(i->to)) { - *i = (Ins){.op = ONop}; + *i = (Ins){.op = Onop}; continue; } if (i->to.val >= Tmp0) @@ -447,7 +447,7 @@ rega(Fn *fn) for (t=Tmp0; t<fn->ntmp; t++) *hint(t) = -1; for (b=fn->start, i=b->ins; i-b->ins < b->nins; i++) - if (i->op != OCopy || !isreg(i->arg[0])) + if (i->op != Ocopy || !isreg(i->arg[0])) break; else { assert(rtype(i->to) == RTmp); @@ -507,7 +507,7 @@ rega(Fn *fn) rfree(&cur, t); radd(&cur, t, r); x = tmp[t].cls; - emit(OCopy, x, TMP(r1), TMP(r), R); + emit(Ocopy, x, TMP(r1), TMP(r), R); } } if ((j = &insb[NIns] - curi)) { @@ -569,7 +569,7 @@ rega(Fn *fn) sprintf(b1->name, "%s_%s", b->name, s->name); b1->nins = curi - insb; idup(&b1->ins, insb, b1->nins); - b1->jmp.type = JJmp; + b1->jmp.type = Jjmp; b1->s1 = s; **ps = b1; } diff --git a/spill.c b/spill.c index 77c4fbe..e4dae28 100644 --- a/spill.c +++ b/spill.c @@ -234,20 +234,20 @@ reloads(BSet *u, BSet *v) for (t=Tmp0; bsiter(u, &t); t++) if (!bshas(v, t)) - emit(OLoad, tmp[t].cls, TMP(t), slot(t), R); + emit(Oload, tmp[t].cls, TMP(t), slot(t), R); } static void store(Ref r, int s) { if (s != -1) - emit(OStorew + tmp[r.val].cls, 0, R, r, SLOT(s)); + emit(Ostorew + tmp[r.val].cls, 0, R, r, SLOT(s)); } static int regcpy(Ins *i) { - return i->op == OCopy && isreg(i->arg[0]); + return i->op == Ocopy && isreg(i->arg[0]); } static Ins * @@ -281,7 +281,7 @@ dopm(Blk *b, Ins *i, BSet *v) bsset(v, i->arg[0].val); } while (i != b->ins && regcpy(i-1)); bscopy(u, v); - if (i != b->ins && (i-1)->op == OCall) { + if (i != b->ins && (i-1)->op == Ocall) { v->t[0] &= ~retregs((i-1)->arg[1], 0); limit2(v, NISave, NFSave, 0); for (r=0, n=0; n<NRSave; n++) @@ -308,7 +308,7 @@ dopm(Blk *b, Ins *i, BSet *v) * borders * * Be careful with: - * - OCopy instructions to ensure register + * - Ocopy instructions to ensure register * constraints */ void diff --git a/sysv.c b/sysv.c index d15e556..2cb3c4f 100644 --- a/sysv.c +++ b/sysv.c @@ -76,11 +76,11 @@ blit(Ref rstk, uint soff, Ref rsrc, uint sz, Fn *fn) for (boff=0; sz>0; sz-=8, soff+=8, boff+=8) { r = newtmp("abi", Kl, fn); r1 = newtmp("abi", Kl, fn); - emit(OStorel, 0, R, r, r1); - emit(OAdd, Kl, r1, rstk, getcon(soff, fn)); + emit(Ostorel, 0, R, r, r1); + emit(Oadd, Kl, r1, rstk, getcon(soff, fn)); r1 = newtmp("abi", Kl, fn); - emit(OLoad, Kl, r, r1, R); - emit(OAdd, Kl, r1, rsrc, getcon(boff, fn)); + emit(Oload, Kl, r, r1, R); + emit(Oadd, Kl, r1, rsrc, getcon(boff, fn)); } } @@ -109,35 +109,35 @@ selret(Blk *b, Fn *fn) j = b->jmp.type; - if (!isret(j) || j == JRet0) + if (!isret(j) || j == Jret0) return; r0 = b->jmp.arg; - b->jmp.type = JRet0; + b->jmp.type = Jret0; - if (j == JRetc) { + if (j == Jretc) { aclass(&aret, &typ[fn->retty]); if (aret.inmem) { assert(rtype(fn->retr) == RTmp); - emit(OCopy, Kl, TMP(RAX), fn->retr, R); + emit(Ocopy, Kl, TMP(RAX), fn->retr, R); blit(fn->retr, 0, r0, aret.size, fn); ca = 1; } else { ca = retr(reg, &aret); if (aret.size > 8) { r = newtmp("abi", Kl, fn); - emit(OLoad, Kl, reg[1], r, R); - emit(OAdd, Kl, r, r0, getcon(8, fn)); + emit(Oload, Kl, reg[1], r, R); + emit(Oadd, Kl, r, r0, getcon(8, fn)); } - emit(OLoad, Kl, reg[0], r0, R); + emit(Oload, Kl, reg[0], r0, R); } } else { - k = j - JRetw; + k = j - Jretw; if (KBASE(k) == 0) { - emit(OCopy, k, TMP(RAX), r0, R); + emit(Ocopy, k, TMP(RAX), r0, R); ca = 1; } else { - emit(OCopy, k, TMP(XMM0), r0, R); + emit(Ocopy, k, TMP(XMM0), r0, R); ca = 1 << 2; } } @@ -272,9 +272,9 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) if (!req(i1->arg[1], R)) { assert(rtype(i1->arg[1]) == RType); aclass(&aret, &typ[i1->arg[1].val]); - ca = classify(i0, i1, ac, OArg, &aret); + ca = classify(i0, i1, ac, Oarg, &aret); } else - ca = classify(i0, i1, ac, OArg, 0); + ca = classify(i0, i1, ac, Oarg, 0); for (stk=0, a=&ac[i1-i0]; a>ac;) if ((--a)->inmem) { @@ -287,7 +287,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) stk += stk & 15; if (stk) { r = getcon(-(int64_t)stk, fn); - emit(OSAlloc, Kl, R, r, R); + emit(Osalloc, Kl, R, r, R); } if (!req(i1->arg[1], R)) { @@ -295,60 +295,60 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) /* get the return location from eax * it saves one callee-save reg */ r1 = newtmp("abi", Kl, fn); - emit(OCopy, Kl, i1->to, TMP(RAX), R); + emit(Ocopy, Kl, i1->to, TMP(RAX), R); ca += 1; } else { if (aret.size > 8) { r = newtmp("abi", Kl, fn); aret.ref[1] = newtmp("abi", aret.cls[1], fn); - emit(OStorel, 0, R, aret.ref[1], r); - emit(OAdd, Kl, r, i1->to, getcon(8, fn)); + emit(Ostorel, 0, R, aret.ref[1], r); + emit(Oadd, Kl, r, i1->to, getcon(8, fn)); } aret.ref[0] = newtmp("abi", aret.cls[0], fn); - emit(OStorel, 0, R, aret.ref[0], i1->to); + emit(Ostorel, 0, R, aret.ref[0], i1->to); ca += retr(reg, &aret); if (aret.size > 8) - emit(OCopy, aret.cls[1], aret.ref[1], reg[1], R); - emit(OCopy, aret.cls[0], aret.ref[0], reg[0], R); + emit(Ocopy, aret.cls[1], aret.ref[1], reg[1], R); + emit(Ocopy, aret.cls[0], aret.ref[0], reg[0], R); r1 = i1->to; } /* allocate return pad */ ra = alloc(sizeof *ra); /* specific to NAlign == 3 */ al = aret.align >= 2 ? aret.align - 2 : 0; - ra->i = (Ins){OAlloc+al, r1, {getcon(aret.size, fn)}, Kl}; + ra->i = (Ins){Oalloc+al, r1, {getcon(aret.size, fn)}, Kl}; ra->link = (*rap); *rap = ra; } else { ra = 0; if (KBASE(i1->cls) == 0) { - emit(OCopy, i1->cls, i1->to, TMP(RAX), R); + emit(Ocopy, i1->cls, i1->to, TMP(RAX), R); ca += 1; } else { - emit(OCopy, i1->cls, i1->to, TMP(XMM0), R); + emit(Ocopy, i1->cls, i1->to, TMP(XMM0), R); ca += 1 << 2; } } - emit(OCall, i1->cls, R, i1->arg[0], CALL(ca)); - emit(OCopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R); + emit(Ocall, i1->cls, R, i1->arg[0], CALL(ca)); + emit(Ocopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R); ni = ns = 0; if (ra && aret.inmem) - emit(OCopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */ + emit(Ocopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */ for (i=i0, a=ac; i<i1; i++, a++) { if (a->inmem) continue; r1 = rarg(a->cls[0], &ni, &ns); - if (i->op == OArgc) { + if (i->op == Oargc) { if (a->size > 8) { r2 = rarg(a->cls[1], &ni, &ns); r = newtmp("abi", Kl, fn); - emit(OLoad, a->cls[1], r2, r, R); - emit(OAdd, Kl, r, i->arg[1], getcon(8, fn)); + emit(Oload, a->cls[1], r2, r, R); + emit(Oadd, Kl, r, i->arg[1], getcon(8, fn)); } - emit(OLoad, a->cls[0], r1, i->arg[1], R); + emit(Oload, a->cls[0], r1, i->arg[1], R); } else - emit(OCopy, i->cls, r1, i->arg[0], R); + emit(Ocopy, i->cls, r1, i->arg[0], R); } if (!stk) @@ -358,18 +358,18 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) for (i=i0, a=ac, off=0; i<i1; i++, a++) { if (!a->inmem) continue; - if (i->op == OArgc) { + if (i->op == Oargc) { if (a->align == 4) off += off & 15; blit(r, off, i->arg[1], a->size, fn); } else { r1 = newtmp("abi", Kl, fn); - emit(OStorel, 0, R, i->arg[0], r1); - emit(OAdd, Kl, r1, r, getcon(off, fn)); + emit(Ostorel, 0, R, i->arg[0], r1); + emit(Oadd, Kl, r1, r, getcon(off, fn)); } off += a->size; } - emit(OSAlloc, Kl, r, getcon(stk, fn), R); + emit(Osalloc, Kl, r, getcon(stk, fn), R); } static void @@ -386,29 +386,29 @@ selpar(Fn *fn, Ins *i0, Ins *i1) if (fn->retty >= 0) { aclass(&aret, &typ[fn->retty]); - classify(i0, i1, ac, OPar, &aret); + classify(i0, i1, ac, Opar, &aret); } else - classify(i0, i1, ac, OPar, 0); + classify(i0, i1, ac, Opar, 0); for (i=i0, a=ac; i<i1; i++, a++) { - if (i->op != OParc || a->inmem) + if (i->op != Oparc || a->inmem) continue; if (a->size > 8) { r = newtmp("abi", Kl, fn); a->ref[1] = newtmp("abi", Kl, fn); - emit(OStorel, 0, R, a->ref[1], r); - emit(OAdd, Kl, r, i->to, getcon(8, fn)); + emit(Ostorel, 0, R, a->ref[1], r); + emit(Oadd, Kl, r, i->to, getcon(8, fn)); } a->ref[0] = newtmp("abi", Kl, fn); - emit(OStorel, 0, R, a->ref[0], i->to); + emit(Ostorel, 0, R, a->ref[0], i->to); /* specific to NAlign == 3 */ al = a->align >= 2 ? a->align - 2 : 0; - emit(OAlloc+al, Kl, i->to, getcon(a->size, fn), R); + emit(Oalloc+al, Kl, i->to, getcon(a->size, fn), R); } if (fn->retty >= 0 && aret.inmem) { r = newtmp("abi", Kl, fn); - emit(OCopy, Kl, r, rarg(Kl, &ni, &ns), R); + emit(Ocopy, Kl, r, rarg(Kl, &ni, &ns), R); fn->retr = r; } @@ -423,19 +423,19 @@ selpar(Fn *fn, Ins *i0, Ins *i1) s += a->size / 4; continue; case 2: - emit(OLoad, i->cls, i->to, SLOT(-s), R); + emit(Oload, i->cls, i->to, SLOT(-s), R); s += 2; continue; } r = rarg(a->cls[0], &ni, &ns); - if (i->op == OParc) { - emit(OCopy, Kl, a->ref[0], r, R); + if (i->op == Oparc) { + emit(Ocopy, Kl, a->ref[0], r, R); if (a->size > 8) { r = rarg(a->cls[1], &ni, &ns); - emit(OCopy, Kl, a->ref[1], r, R); + emit(Ocopy, Kl, a->ref[1], r, R); } } else - emit(OCopy, i->cls, i->to, r, R); + emit(Ocopy, i->cls, i->to, r, R); } } @@ -449,7 +449,7 @@ abi(Fn *fn) /* lower arguments */ for (b=fn->start, i=b->ins; i-b->ins < b->nins; i++) - if (i->op != OPar && i->op != OParc) + if (i->op != Opar && i->op != Oparc) break; selpar(fn, b->ins, i); n = b->nins - (i - b->ins) + (&insb[NIns] - curi); @@ -468,16 +468,16 @@ abi(Fn *fn) curi = &insb[NIns]; selret(b, fn); for (i=&b->ins[b->nins]; i!=b->ins;) { - if ((--i)->op == OCall) { + if ((--i)->op == Ocall) { for (i0=i; i0>b->ins; i0--) - if ((i0-1)->op != OArg) - if ((i0-1)->op != OArgc) + if ((i0-1)->op != Oarg) + if ((i0-1)->op != Oargc) break; selcall(fn, i0, i, &ral); i = i0; continue; } - assert(i->op != OArg && i->op != OArgc); + assert(i->op != Oarg && i->op != Oargc); emiti(*i); } if (b == fn->start) |