History

match jumps/ops with il text

Quentin Carbonneaux committed 10 years ago

Commit 657c3fa1 parent b7debc411 files · +509 −509Browse files

Unified · Split

11 files
  1. all.h +88 −88
  2. copy.c +2 −2
  3. emit.c +80 −80
  4. fold.c +53 −53
  5. isel.c +83 −83
  6. live.c +1 −1
  7. mem.c +17 −17
  8. parse.c +114 −114
  9. rega.c +10 −10
  10. spill.c +5 −5
  11. sysv.c +56 −56
all.h+88−88
@@ -162,8 +162,8 @@ enum ICmp { · 161 unmodified lines
162162 #undef X
163163 NICmp,
164164
165− ICXnp = NICmp, /* x64 specific */
166− ICXp,
165+ ICxnp = NICmp, /* x64 specific */
166+ ICxp,
167167 NXICmp
168168 };
169169
@@ -201,103 +201,103 @@ enum Class { · 31 unmodified lines
201201 #define KBASE(k) ((k)>>1)
202202
203203 enum Op {
204− OXXX,
204+ Oxxx,
205205
206206 /* public instructions */
207− OAdd,
208− OSub,
209− ODiv,
210− ORem,
211− OUDiv,
212− OURem,
213− OMul,
214− OAnd,
215− OOr,
216− OXor,
217− OSar,
218− OShr,
219− OShl,
220− OCmpw,
221− OCmpw1 = OCmpw + NICmp-1,
222− OCmpl,
223− OCmpl1 = OCmpl + NICmp-1,
224− OCmps,
225− OCmps1 = OCmps + NFCmp-1,
226− OCmpd,
227− OCmpd1 = OCmpd + NFCmp-1,
228−
229− OStoreb,
230− OStoreh,
231− OStorew,
232− OStorel,
233− OStores,
234− OStored,
235−#define isstore(o) (OStoreb <= o && o <= OStored)
236− OLoadsb, /* needs to match OExt (mem.c) */
237− OLoadub,
238− OLoadsh,
239− OLoaduh,
240− OLoadsw,
241− OLoaduw,
242− OLoad,
243−#define isload(o) (OLoadsb <= o && o <= OLoad)
244− OExtsb,
245− OExtub,
246− OExtsh,
247− OExtuh,
248− OExtsw,
249− OExtuw,
250−#define isext(o) (OExtsb <= o && o <= OExtuw)
251−
252− OExts,
253− OTruncd,
254− OFtosi,
255− OSitof,
256− OCast,
257−
258− OAlloc,
259− OAlloc1 = OAlloc + NAlign-1,
260−
261− OCopy,
207+ Oadd,
208+ Osub,
209+ Odiv,
210+ Orem,
211+ Oudiv,
212+ Ourem,
213+ Omul,
214+ Oand,
215+ Oor,
216+ Oxor,
217+ Osar,
218+ Oshr,
219+ Oshl,
220+ Ocmpw,
221+ Ocmpw1 = Ocmpw + NICmp-1,
222+ Ocmpl,
223+ Ocmpl1 = Ocmpl + NICmp-1,
224+ Ocmps,
225+ Ocmps1 = Ocmps + NFCmp-1,
226+ Ocmpd,
227+ Ocmpd1 = Ocmpd + NFCmp-1,
228+
229+ Ostoreb,
230+ Ostoreh,
231+ Ostorew,
232+ Ostorel,
233+ Ostores,
234+ Ostored,
235+#define isstore(o) (Ostoreb <= o && o <= Ostored)
236+ Oloadsb, /* needs to match OExt (mem.c) */
237+ Oloadub,
238+ Oloadsh,
239+ Oloaduh,
240+ Oloadsw,
241+ Oloaduw,
242+ Oload,
243+#define isload(o) (Oloadsb <= o && o <= Oload)
244+ Oextsb,
245+ Oextub,
246+ Oextsh,
247+ Oextuh,
248+ Oextsw,
249+ Oextuw,
250+#define isext(o) (Oextsb <= o && o <= Oextuw)
251+
252+ Oexts,
253+ Otruncd,
254+ Oftosi,
255+ Ositof,
256+ Ocast,
257+
258+ Oalloc,
259+ Oalloc1 = Oalloc + NAlign-1,
260+
261+ Ocopy,
262262 NPubOp,
263263
264264 /* function instructions */
265− OPar = NPubOp,
266− OParc,
267− OArg,
268− OArgc,
269− OCall,
265+ Opar = NPubOp,
266+ Oparc,
267+ Oarg,
268+ Oargc,
269+ Ocall,
270270
271271 /* reserved instructions */
272− ONop,
273− OAddr,
274− OSwap,
275− OSign,
276− OSAlloc,
277− OXIDiv,
278− OXDiv,
279− OXCmp,
280− OXSet,
281− OXSetnp = OXSet + ICXnp,
282− OXSetp = OXSet + ICXp,
283− OXTest,
272+ Onop,
273+ Oaddr,
274+ Oswap,
275+ Osign,
276+ Osalloc,
277+ Oxidiv,
278+ Oxdiv,
279+ Oxcmp,
280+ Oxset,
281+ Oxsetnp = Oxset + ICxnp,
282+ Oxsetp = Oxset + ICxp,
283+ Oxtest,
284284 NOp
285285 };
286286
287287 enum Jmp {
288− JXXX,
289− JRet0,
290− JRetw,
291− JRetl,
292− JRets,
293− JRetd,
294− JRetc,
295−#define isret(j) (JRet0 <= j && j <= JRetc)
296− JJmp,
297− JJnz,
298− JXJc,
299− JXJnp = JXJc + ICXnp,
300− JXJp = JXJc + ICXp,
288+ Jxxx,
289+ Jret0,
290+ Jretw,
291+ Jretl,
292+ Jrets,
293+ Jretd,
294+ Jretc,
295+#define isret(j) (Jret0 <= j && j <= Jretc)
296+ Jjmp,
297+ Jjnz,
298+ Jxjc,
299+ Jxjnp = Jxjc + ICxnp,
300+ Jxjp = Jxjc + ICxp,
301301 NJmp
302302 };
303303
copy.c+2−2
@@ -55,7 +55,7 @@ visitins(Ins *i, Ref *cp, RList **w) · 54 unmodified lines
5555 {
5656 Ref r;
5757
58− if (i->op == OCopy) {
58+ if (i->op == Ocopy) {
5959 r = copyof(i->arg[0], cp);
6060 update(i->to, r, cp, w);
6161 } else if (!req(i->to, R)) {
@@ -125,7 +125,7 @@ copy(Fn *fn) · 63 unmodified lines
125125 for (i=b->ins; i-b->ins < b->nins; i++) {
126126 r = copyof(i->to, cp);
127127 if (!req(r, i->to)) {
128− *i = (Ins){.op = ONop};
128+ *i = (Ins){.op = Onop};
129129 continue;
130130 }
131131 for (a=0; a<2; a++)
emit.c+80−80
@@ -43,70 +43,70 @@ static struct { · 42 unmodified lines
4343 short cls;
4444 char *asm;
4545 } omap[] = {
46− { OAdd, Ka, "+add%k %1, %=" },
47− { OSub, Ka, "-sub%k %1, %=" },
48− { OAnd, Ki, "+and%k %1, %=" },
49− { OOr, Ki, "+or%k %1, %=" },
50− { OXor, Ki, "+xor%k %1, %=" },
51− { OSar, Ki, "-sar%k %B1, %=" },
52− { OShr, Ki, "-shr%k %B1, %=" },
53− { OShl, Ki, "-shl%k %B1, %=" },
54− { OMul, Ki, "+imul%k %1, %=" },
55− { OMul, Ks, "+mulss %1, %=" }, /* fixme */
56− { OMul, Kd, "+mulsd %1, %=" },
57− { ODiv, Ka, "-div%k %1, %=" },
58− { OStorel, Ka, "movq %L0, %M1" },
59− { OStorew, Ka, "movl %W0, %M1" },
60− { OStoreh, Ka, "movw %H0, %M1" },
61− { OStoreb, Ka, "movb %B0, %M1" },
62− { OStores, Ka, "movss %S0, %M1" },
63− { OStored, Ka, "movsd %D0, %M1" },
64− { OLoad, Ka, "mov%k %M0, %=" },
65− { OLoadsw, Kl, "movslq %M0, %L=" },
66− { OLoadsw, Kw, "movl %M0, %W=" },
67− { OLoaduw, Ki, "movl %M0, %W=" },
68− { OLoadsh, Ki, "movsw%k %M0, %=" },
69− { OLoaduh, Ki, "movzw%k %M0, %=" },
70− { OLoadsb, Ki, "movsb%k %M0, %=" },
71− { OLoadub, Ki, "movzb%k %M0, %=" },
72− { OExtsw, Kl, "movslq %W0, %L=" },
73− { OExtuw, Kl, "movl %W0, %W=" },
74− { OExtsh, Ki, "movsw%k %H0, %=" },
75− { OExtuh, Ki, "movzw%k %H0, %=" },
76− { OExtsb, Ki, "movsb%k %B0, %=" },
77− { OExtub, Ki, "movzb%k %B0, %=" },
78−
79− { OExts, Kd, "cvtss2sd %0, %=" }, /* see if factorization is possible */
80− { OTruncd, Ks, "cvttsd2ss %0, %=" },
81− { OFtosi, Kw, "cvttss2si %0, %=" },
82− { OFtosi, Kl, "cvttsd2si %0, %=" },
83− { OSitof, Ks, "cvtsi2ss %W0, %=" },
84− { OSitof, Kd, "cvtsi2sd %L0, %=" },
85− { OCast, Ki, "movq %D0, %L=" },
86− { OCast, Ka, "movq %L0, %D=" },
87−
88− { OAddr, Ki, "lea%k %M0, %=" },
89− { OSwap, Ki, "xchg%k %0, %1" },
90− { OSign, Kl, "cqto" },
91− { OSign, Kw, "cltd" },
92− { OXDiv, Ki, "div%k %0" },
93− { OXIDiv, Ki, "idiv%k %0" },
94− { OXCmp, Ks, "comiss %S0, %S1" }, /* fixme, Kf */
95− { OXCmp, Kd, "comisd %D0, %D1" },
96− { OXCmp, Ki, "cmp%k %0, %1" },
97− { OXTest, Ki, "test%k %0, %1" },
98− { OXSet+ICule, Ki, "setbe %B=\n\tmovzb%k %B=, %=" },
99− { OXSet+ICult, Ki, "setb %B=\n\tmovzb%k %B=, %=" },
100− { OXSet+ICsle, Ki, "setle %B=\n\tmovzb%k %B=, %=" },
101− { OXSet+ICslt, Ki, "setl %B=\n\tmovzb%k %B=, %=" },
102− { OXSet+ICsgt, Ki, "setg %B=\n\tmovzb%k %B=, %=" },
103− { OXSet+ICsge, Ki, "setge %B=\n\tmovzb%k %B=, %=" },
104− { OXSet+ICugt, Ki, "seta %B=\n\tmovzb%k %B=, %=" },
105− { OXSet+ICuge, Ki, "setae %B=\n\tmovzb%k %B=, %=" },
106− { OXSet+ICeq, Ki, "setz %B=\n\tmovzb%k %B=, %=" },
107− { OXSet+ICne, Ki, "setnz %B=\n\tmovzb%k %B=, %=" },
108− { OXSet+ICXnp, Ki, "setnp %B=\n\tmovsb%k %B=, %=" },
109− { OXSet+ICXp, Ki, "setp %B=\n\tmovsb%k %B=, %=" },
46+ { Oadd, Ka, "+add%k %1, %=" },
47+ { Osub, Ka, "-sub%k %1, %=" },
48+ { Oand, Ki, "+and%k %1, %=" },
49+ { Oor, Ki, "+or%k %1, %=" },
50+ { Oxor, Ki, "+xor%k %1, %=" },
51+ { Osar, Ki, "-sar%k %B1, %=" },
52+ { Oshr, Ki, "-shr%k %B1, %=" },
53+ { Oshl, Ki, "-shl%k %B1, %=" },
54+ { Omul, Ki, "+imul%k %1, %=" },
55+ { Omul, Ks, "+mulss %1, %=" }, /* fixme */
56+ { Omul, Kd, "+mulsd %1, %=" },
57+ { Odiv, Ka, "-div%k %1, %=" },
58+ { Ostorel, Ka, "movq %L0, %M1" },
59+ { Ostorew, Ka, "movl %W0, %M1" },
60+ { Ostoreh, Ka, "movw %H0, %M1" },
61+ { Ostoreb, Ka, "movb %B0, %M1" },
62+ { Ostores, Ka, "movss %S0, %M1" },
63+ { Ostored, Ka, "movsd %D0, %M1" },
64+ { Oload, Ka, "mov%k %M0, %=" },
65+ { Oloadsw, Kl, "movslq %M0, %L=" },
66+ { Oloadsw, Kw, "movl %M0, %W=" },
67+ { Oloaduw, Ki, "movl %M0, %W=" },
68+ { Oloadsh, Ki, "movsw%k %M0, %=" },
69+ { Oloaduh, Ki, "movzw%k %M0, %=" },
70+ { Oloadsb, Ki, "movsb%k %M0, %=" },
71+ { Oloadub, Ki, "movzb%k %M0, %=" },
72+ { Oextsw, Kl, "movslq %W0, %L=" },
73+ { Oextuw, Kl, "movl %W0, %W=" },
74+ { Oextsh, Ki, "movsw%k %H0, %=" },
75+ { Oextuh, Ki, "movzw%k %H0, %=" },
76+ { Oextsb, Ki, "movsb%k %B0, %=" },
77+ { Oextub, Ki, "movzb%k %B0, %=" },
78+
79+ { Oexts, Kd, "cvtss2sd %0, %=" }, /* see if factorization is possible */
80+ { Otruncd, Ks, "cvttsd2ss %0, %=" },
81+ { Oftosi, Kw, "cvttss2si %0, %=" },
82+ { Oftosi, Kl, "cvttsd2si %0, %=" },
83+ { Ositof, Ks, "cvtsi2ss %W0, %=" },
84+ { Ositof, Kd, "cvtsi2sd %L0, %=" },
85+ { Ocast, Ki, "movq %D0, %L=" },
86+ { Ocast, Ka, "movq %L0, %D=" },
87+
88+ { Oaddr, Ki, "lea%k %M0, %=" },
89+ { Oswap, Ki, "xchg%k %0, %1" },
90+ { Osign, Kl, "cqto" },
91+ { Osign, Kw, "cltd" },
92+ { Oxdiv, Ki, "div%k %0" },
93+ { Oxidiv, Ki, "idiv%k %0" },
94+ { Oxcmp, Ks, "comiss %S0, %S1" }, /* fixme, Kf */
95+ { Oxcmp, Kd, "comisd %D0, %D1" },
96+ { Oxcmp, Ki, "cmp%k %0, %1" },
97+ { Oxtest, Ki, "test%k %0, %1" },
98+ { Oxset+ICule, Ki, "setbe %B=\n\tmovzb%k %B=, %=" },
99+ { Oxset+ICult, Ki, "setb %B=\n\tmovzb%k %B=, %=" },
100+ { Oxset+ICsle, Ki, "setle %B=\n\tmovzb%k %B=, %=" },
101+ { Oxset+ICslt, Ki, "setl %B=\n\tmovzb%k %B=, %=" },
102+ { Oxset+ICsgt, Ki, "setg %B=\n\tmovzb%k %B=, %=" },
103+ { Oxset+ICsge, Ki, "setge %B=\n\tmovzb%k %B=, %=" },
104+ { Oxset+ICugt, Ki, "seta %B=\n\tmovzb%k %B=, %=" },
105+ { Oxset+ICuge, Ki, "setae %B=\n\tmovzb%k %B=, %=" },
106+ { Oxset+ICeq, Ki, "setz %B=\n\tmovzb%k %B=, %=" },
107+ { Oxset+ICne, Ki, "setnz %B=\n\tmovzb%k %B=, %=" },
108+ { Oxset+ICxnp, Ki, "setnp %B=\n\tmovsb%k %B=, %=" },
109+ { Oxset+ICxp, Ki, "setp %B=\n\tmovsb%k %B=, %=" },
110110 { NOp, 0, 0 }
111111 };
112112
@@ -200,7 +200,7 @@ emitcopy(Ref r1, Ref r2, int k, Fn *fn, FILE *f) · 87 unmodified lines
200200 {
201201 Ins icp;
202202
203− icp.op = OCopy;
203+ icp.op = Ocopy;
204204 icp.arg[0] = r2;
205205 icp.to = r1;
206206 icp.cls = k;
@@ -364,11 +364,11 @@ emitins(Ins i, Fn *fn, FILE *f) · 157 unmodified lines
364364 }
365365 emitf(omap[o].asm, &i, fn, f);
366366 break;
367− case ONop:
367+ case Onop:
368368 /* just do nothing for nops, they are inserted
369369 * by some passes */
370370 break;
371− case OMul:
371+ case Omul:
372372 /* here, we try to use the 3-addresss form
373373 * of multiplication when possible */
374374 if (rtype(i.arg[1]) == RCon) {
@@ -383,7 +383,7 @@ emitins(Ins i, Fn *fn, FILE *f) · 8 unmodified lines
383383 break;
384384 }
385385 goto Table;
386− case OSub:
386+ case Osub:
387387 /* we have to use the negation trick to handle
388388 * some 3-address substractions */
389389 if (req(i.to, i.arg[1])) {
@@ -392,7 +392,7 @@ emitins(Ins i, Fn *fn, FILE *f) · 2 unmodified lines
392392 break;
393393 }
394394 goto Table;
395− case OCopy:
395+ case Ocopy:
396396 /* make sure we don't emit useless copies,
397397 * also, we can use a trick to load 64-bits
398398 * registers, it's detailed in my note below
@@ -413,7 +413,7 @@ emitins(Ins i, Fn *fn, FILE *f) · 14 unmodified lines
413413 } else if (!req(i.arg[0], i.to))
414414 emitf("mov%k %0, %=", &i, fn, f);
415415 break;
416− case OCall:
416+ case Ocall:
417417 /* calls simply have a weird syntax in AT&T
418418 * assembly... */
419419 switch (rtype(i.arg[0])) {
@@ -429,16 +429,16 @@ emitins(Ins i, Fn *fn, FILE *f) · 9 unmodified lines
429429 die("invalid call argument");
430430 }
431431 break;
432− case OSAlloc:
432+ case Osalloc:
433433 /* there is no good reason why this is here
434− * maybe we should split OSAlloc in 2 different
434+ * maybe we should split Osalloc in 2 different
435435 * instructions depending on the result
436436 */
437437 emitf("subq %L0, %%rsp", &i, fn, f);
438438 if (!req(i.to, R))
439439 emitcopy(i.to, TMP(RSP), Kl, fn, f);
440440 break;
441− case OSwap:
441+ case Oswap:
442442 if (KBASE(i.cls) == 0)
443443 goto Table;
444444 /* for floats, there is no swap instruction
@@ -466,8 +466,8 @@ cneg(int cmp) · 21 unmodified lines
466466 case ICuge: return ICult;
467467 case ICeq: return ICne;
468468 case ICne: return ICeq;
469− case ICXnp: return ICXp;
470− case ICXp: return ICXnp;
469+ case ICxnp: return ICxp;
470+ case ICxp: return ICxnp;
471471 }
472472 }
473473
@@ -498,8 +498,8 @@ emitfn(Fn *fn, FILE *f) · 24 unmodified lines
498498 [ICugt] = "a",
499499 [ICuge] = "ae",
500500 [ICne] = "nz",
501− [ICXnp] = "np",
502− [ICXp] = "p"
501+ [ICxnp] = "np",
502+ [ICxp] = "p"
503503 };
504504 static int id0;
505505 Blk *b, *s;
@@ -529,7 +529,7 @@ emitfn(Fn *fn, FILE *f) · 23 unmodified lines
529529 for (i=b->ins; i!=&b->ins[b->nins]; i++)
530530 emitins(*i, fn, f);
531531 switch (b->jmp.type) {
532− case JRet0:
532+ case Jret0:
533533 for (r=&rclob[NRClob]; r>rclob;)
534534 if (fn->reg & BIT(*--r)) {
535535 itmp.arg[0] = TMP(*r);
@@ -540,14 +540,14 @@ emitfn(Fn *fn, FILE *f) · 4 unmodified lines
540540 "\tret\n"
541541 );
542542 break;
543− case JJmp:
543+ case Jjmp:
544544 Jmp:
545545 if (b->s1 != b->link)
546546 fprintf(f, "\tjmp %sbb%d /* %s */\n",
547547 locprefix, id0+b->s1->id, b->s1->name);
548548 break;
549549 default:
550− c = b->jmp.type - JXJc;
550+ c = b->jmp.type - Jxjc;
551551 if (0 <= c && c <= NXICmp) {
552552 if (b->link == b->s2) {
553553 s = b->s1;
fold.c+53−53
@@ -124,7 +124,7 @@ visitjmp(Blk *b, int n, Fn *fn) · 123 unmodified lines
124124 int l;
125125
126126 switch (b->jmp.type) {
127− case JJnz:
127+ case Jjnz:
128128 l = latval(b->jmp.arg);
129129 assert(l != Top && "ssa invariant broken");
130130 if (l == Bot) {
@@ -143,7 +143,7 @@ visitjmp(Blk *b, int n, Fn *fn) · 12 unmodified lines
143143 flowrk = &edge[n][0];
144144 }
145145 break;
146− case JJmp:
146+ case Jjmp:
147147 edge[n][0].work = flowrk;
148148 flowrk = &edge[n][0];
149149 break;
@@ -226,7 +226,7 @@ fold(Fn *fn) · 76 unmodified lines
226226 visitjmp(b, n, fn);
227227 }
228228 b->visit++;
229− assert(b->jmp.type != JJmp
229+ assert(b->jmp.type != Jjmp
230230 || !edge[n][0].dead
231231 || flowrk == &edge[n][0]);
232232 }
@@ -290,13 +290,13 @@ fold(Fn *fn) · 57 unmodified lines
290290 }
291291 for (i=b->ins; i-b->ins < b->nins; i++)
292292 if (renref(&i->to))
293− *i = (Ins){.op = ONop};
293+ *i = (Ins){.op = Onop};
294294 else
295295 for (n=0; n<2; n++)
296296 renref(&i->arg[n]);
297297 renref(&b->jmp.arg);
298− if (b->jmp.type == JJnz && rtype(b->jmp.arg) == RCon) {
299− b->jmp.type = JJmp;
298+ if (b->jmp.type == Jjnz && rtype(b->jmp.arg) == RCon) {
299+ b->jmp.type = Jjmp;
300300 if (czero(&fn->con[b->jmp.arg.val], 0))
301301 b->s1 = b->s2;
302302 b->jmp.arg = R;
@@ -333,7 +333,7 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) · 30 unmodified lines
333333 lab = 0;
334334 l.s = cl->bits.i;
335335 r.s = cr->bits.i;
336− if (op == OAdd) {
336+ if (op == Oadd) {
337337 if (cl->type == CAddr) {
338338 if (cr->type == CAddr)
339339 err("undefined addition (addr + addr)");
@@ -342,7 +342,7 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) · 2 unmodified lines
342342 else if (cr->type == CAddr)
343343 lab = cr->label;
344344 }
345− else if (op == OSub) {
345+ else if (op == Osub) {
346346 if (cl->type == CAddr) {
347347 if (cr->type != CAddr)
348348 lab = cl->label;
@@ -355,44 +355,44 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) · 6 unmodified lines
355355 else if (cl->type == CAddr || cr->type == CAddr)
356356 err("invalid address operand for '%s'", opdesc[op].name);
357357 switch (op) {
358− case OAdd: x = l.u + r.u; break;
359− case OSub: x = l.u - r.u; break;
360− case ODiv: x = l.s / r.s; break;
361− case ORem: x = l.s % r.s; break;
362− case OUDiv: x = l.u / r.u; break;
363− case OURem: x = l.u % r.u; break;
364− case OMul: x = l.u * r.u; break;
365− case OAnd: x = l.u & r.u; break;
366− case OOr: x = l.u | r.u; break;
367− case OXor: x = l.u ^ r.u; break;
368− case OSar: x = l.s >> (r.u & 63); break;
369− case OShr: x = l.u >> (r.u & 63); break;
370− case OShl: x = l.u << (r.u & 63); break;
371− case OExtsb: x = (int8_t)l.u; break;
372− case OExtub: x = (uint8_t)l.u; break;
373− case OExtsh: x = (int16_t)l.u; break;
374− case OExtuh: x = (uint16_t)l.u; break;
375− case OExtsw: x = (int32_t)l.u; break;
376− case OExtuw: x = (uint32_t)l.u; break;
377− case OFtosi:
358+ case Oadd: x = l.u + r.u; break;
359+ case Osub: x = l.u - r.u; break;
360+ case Odiv: x = l.s / r.s; break;
361+ case Orem: x = l.s % r.s; break;
362+ case Oudiv: x = l.u / r.u; break;
363+ case Ourem: x = l.u % r.u; break;
364+ case Omul: x = l.u * r.u; break;
365+ case Oand: x = l.u & r.u; break;
366+ case Oor: x = l.u | r.u; break;
367+ case Oxor: x = l.u ^ r.u; break;
368+ case Osar: x = l.s >> (r.u & 63); break;
369+ case Oshr: x = l.u >> (r.u & 63); break;
370+ case Oshl: x = l.u << (r.u & 63); break;
371+ case Oextsb: x = (int8_t)l.u; break;
372+ case Oextub: x = (uint8_t)l.u; break;
373+ case Oextsh: x = (int16_t)l.u; break;
374+ case Oextuh: x = (uint16_t)l.u; break;
375+ case Oextsw: x = (int32_t)l.u; break;
376+ case Oextuw: x = (uint32_t)l.u; break;
377+ case Oftosi:
378378 if (w)
379379 x = (int64_t)cl->bits.d;
380380 else
381381 x = (int32_t)cl->bits.s;
382382 break;
383− case OCast:
383+ case Ocast:
384384 x = l.u;
385385 if (cl->type == CAddr)
386386 lab = cl->label;
387387 break;
388388 default:
389− if (OCmpw <= op && op <= OCmpl1) {
390− if (op <= OCmpw1) {
389+ if (Ocmpw <= op && op <= Ocmpl1) {
390+ if (op <= Ocmpw1) {
391391 l.u = (uint32_t)l.u;
392392 r.u = (uint32_t)r.u;
393393 } else
394− op -= OCmpl - OCmpw;
395− switch (op - OCmpw) {
394+ op -= Ocmpl - Ocmpw;
395+ switch (op - Ocmpw) {
396396 case ICule: x = l.u <= r.u; break;
397397 case ICult: x = l.u < r.u; break;
398398 case ICsle: x = l.s <= r.s; break;
@@ -406,8 +406,8 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) · 7 unmodified lines
406406 default: die("unreachable");
407407 }
408408 }
409− else if (OCmps <= op && op <= OCmps1) {
410− switch (op - OCmps) {
409+ else if (Ocmps <= op && op <= Ocmps1) {
410+ switch (op - Ocmps) {
411411 case FCle: x = l.fs <= r.fs; break;
412412 case FClt: x = l.fs < r.fs; break;
413413 case FCgt: x = l.fs > r.fs; break;
@@ -419,8 +419,8 @@ foldint(Con *res, int op, int w, Con *cl, Con *cr) · 5 unmodified lines
419419 default: die("unreachable");
420420 }
421421 }
422− else if (OCmpd <= op && op <= OCmpd1) {
423− switch (op - OCmpd) {
422+ else if (Ocmpd <= op && op <= Ocmpd1) {
423+ switch (op - Ocmpd) {
424424 case FCle: x = l.fd <= r.fd; break;
425425 case FClt: x = l.fd < r.fd; break;
426426 case FCgt: x = l.fd > r.fd; break;
@@ -453,13 +453,13 @@ foldflt(Con *res, int op, int w, Con *cl, Con *cr) · 26 unmodified lines
453453 ld = cl->bits.d;
454454 rd = cr->bits.d;
455455 switch (op) {
456− case OAdd: xd = ld + rd; break;
457− case OSub: xd = ld - rd; break;
458− case ODiv: xd = ld / rd; break;
459− case OMul: xd = ld * rd; break;
460− case OSitof: xd = cl->bits.i; break;
461− case OExts: xd = cl->bits.s; break;
462− case OCast: xd = ld; break;
456+ case Oadd: xd = ld + rd; break;
457+ case Osub: xd = ld - rd; break;
458+ case Odiv: xd = ld / rd; break;
459+ case Omul: xd = ld * rd; break;
460+ case Ositof: xd = cl->bits.i; break;
461+ case Oexts: xd = cl->bits.s; break;
462+ case Ocast: xd = ld; break;
463463 default: die("unreachable");
464464 }
465465 *res = (Con){CBits, .bits={.d=xd}, .flt=2};
@@ -467,13 +467,13 @@ foldflt(Con *res, int op, int w, Con *cl, Con *cr) · 1 unmodified line
467467 ls = cl->bits.s;
468468 rs = cr->bits.s;
469469 switch (op) {
470− case OAdd: xs = ls + rs; break;
471− case OSub: xs = ls - rs; break;
472− case ODiv: xs = ls / rs; break;
473− case OMul: xs = ls * rs; break;
474− case OSitof: xs = cl->bits.i; break;
475− case OTruncd: xs = cl->bits.d; break;
476− case OCast: xs = ls; break;
470+ case Oadd: xs = ls + rs; break;
471+ case Osub: xs = ls - rs; break;
472+ case Odiv: xs = ls / rs; break;
473+ case Omul: xs = ls * rs; break;
474+ case Ositof: xs = cl->bits.i; break;
475+ case Otruncd: xs = cl->bits.d; break;
476+ case Ocast: xs = ls; break;
477477 default: die("unreachable");
478478 }
479479 *res = (Con){CBits, .bits={.s=xs}, .flt=1};
@@ -486,8 +486,8 @@ opfold(int op, int cls, Con *cl, Con *cr, Fn *fn) · 6 unmodified lines
486486 int nc;
487487 Con c;
488488
489− if ((op == ODiv || op == OUDiv
490− || op == ORem || op == OURem) && czero(cr, KWIDE(cls)))
489+ if ((op == Odiv || op == Oudiv
490+ || op == Orem || op == Ourem) && czero(cr, KWIDE(cls)))
491491 err("null divisor in '%s'", opdesc[op].name);
492492 if (cls == Kw || cls == Kl)
493493 foldint(&c, op, cls == Kl, cl, cr);
isel.c+83−83
@@ -40,8 +40,8 @@ fcmptoi(int fc) · 39 unmodified lines
4040 case FCge: return ICuge;
4141 case FCne: return ICne;
4242 case FCeq: return ICeq;
43− case FCo: return ICXnp;
44− case FCuo: return ICXp;
43+ case FCo: return ICxnp;
44+ case FCuo: return ICxp;
4545 }
4646 }
4747
@@ -50,20 +50,20 @@ iscmp(int op, int *pk, int *pc) · 2 unmodified lines
5050 {
5151 int k, c;
5252
53− if (OCmpw <= op && op <= OCmpw1) {
54− c = op - OCmpw;
53+ if (Ocmpw <= op && op <= Ocmpw1) {
54+ c = op - Ocmpw;
5555 k = Kw;
5656 }
57− else if (OCmpl <= op && op <= OCmpl1) {
58− c = op - OCmpl;
57+ else if (Ocmpl <= op && op <= Ocmpl1) {
58+ c = op - Ocmpl;
5959 k = Kl;
6060 }
61− else if (OCmps <= op && op <= OCmps1) {
62− c = fcmptoi(op - OCmps);
61+ else if (Ocmps <= op && op <= Ocmps1) {
62+ c = fcmptoi(op - Ocmps);
6363 k = Ks;
6464 }
65− else if (OCmpd <= op && op <= OCmpd1) {
66− c = fcmptoi(op - OCmpd);
65+ else if (Ocmpd <= op && op <= Ocmpd1) {
66+ c = fcmptoi(op - Ocmpd);
6767 k = Kd;
6868 }
6969 else
@@ -141,7 +141,7 @@ fixarg(Ref *r, int k, int phi, Fn *fn) · 71 unmodified lines
141141 * long temporary
142142 */
143143 r1 = newtmp("isel", Kl, fn);
144− emit(OCopy, Kl, r1, r0, R);
144+ emit(Ocopy, Kl, r1, r0, R);
145145 }
146146 else if (s != -1) {
147147 /* load fast locals' addresses into
@@ -149,7 +149,7 @@ fixarg(Ref *r, int k, int phi, Fn *fn) · 1 unmodified line
149149 * instruction
150150 */
151151 r1 = newtmp("isel", Kl, fn);
152− emit(OAddr, Kl, r1, SLOT(s), R);
152+ emit(Oaddr, Kl, r1, SLOT(s), R);
153153 }
154154 *r = r1;
155155 }
@@ -190,7 +190,7 @@ selcmp(Ref arg[2], int k, Fn *fn) · 34 unmodified lines
190190 arg[0] = r;
191191 }
192192 assert(rtype(arg[0]) != RCon);
193− emit(OXCmp, k, R, arg[1], arg[0]);
193+ emit(Oxcmp, k, R, arg[1], arg[0]);
194194 iarg = curi->arg;
195195 fixarg(&iarg[0], k, 0, fn);
196196 fixarg(&iarg[1], k, 0, fn);
@@ -214,16 +214,16 @@ sel(Ins i, ANum *an, Fn *fn) · 17 unmodified lines
214214 i0 = curi;
215215 k = i.cls;
216216 switch (i.op) {
217− case ODiv:
218− case ORem:
219− case OUDiv:
220− case OURem:
221− if (i.op == ODiv || i.op == OUDiv)
217+ case Odiv:
218+ case Orem:
219+ case Oudiv:
220+ case Ourem:
221+ if (i.op == Odiv || i.op == Oudiv)
222222 r0 = TMP(RAX), r1 = TMP(RDX);
223223 else
224224 r0 = TMP(RDX), r1 = TMP(RAX);
225− emit(OCopy, k, i.to, r0, R);
226− emit(OCopy, k, R, r1, R);
225+ emit(Ocopy, k, i.to, r0, R);
226+ emit(Ocopy, k, R, r1, R);
227227 if (rtype(i.arg[1]) == RCon) {
228228 /* immediates not allowed for
229229 * divisions in x86
@@ -234,63 +234,63 @@ sel(Ins i, ANum *an, Fn *fn) · 4 unmodified lines
234234 if (fn->tmp[r0.val].slot != -1)
235235 err("unlikely argument %%%s in %s",
236236 fn->tmp[r0.val].name, opdesc[i.op].name);
237− if (i.op == ODiv || i.op == ORem) {
238− emit(OXIDiv, k, R, r0, R);
239− emit(OSign, k, TMP(RDX), TMP(RAX), R);
237+ if (i.op == Odiv || i.op == Orem) {
238+ emit(Oxidiv, k, R, r0, R);
239+ emit(Osign, k, TMP(RDX), TMP(RAX), R);
240240 } else {
241− emit(OXDiv, k, R, r0, R);
242− emit(OCopy, k, TMP(RDX), CON_Z, R);
241+ emit(Oxdiv, k, R, r0, R);
242+ emit(Ocopy, k, TMP(RDX), CON_Z, R);
243243 }
244− emit(OCopy, k, TMP(RAX), i.arg[0], R);
244+ emit(Ocopy, k, TMP(RAX), i.arg[0], R);
245245 fixarg(&curi->arg[0], k, 0, fn);
246246 if (rtype(i.arg[1]) == RCon)
247− emit(OCopy, k, r0, i.arg[1], R);
247+ emit(Ocopy, k, r0, i.arg[1], R);
248248 break;
249− case OSar:
250− case OShr:
251− case OShl:
249+ case Osar:
250+ case Oshr:
251+ case Oshl:
252252 if (rtype(i.arg[1]) == RCon)
253253 goto Emit;
254254 r0 = i.arg[1];
255255 i.arg[1] = TMP(RCX);
256− emit(OCopy, Kw, R, TMP(RCX), R);
256+ emit(Ocopy, Kw, R, TMP(RCX), R);
257257 emiti(i);
258− emit(OCopy, Kw, TMP(RCX), r0, R);
258+ emit(Ocopy, Kw, TMP(RCX), r0, R);
259259 break;
260− case ONop:
260+ case Onop:
261261 break;
262− case OStored:
263− case OStores:
264− case OStorel:
265− case OStorew:
266− case OStoreh:
267− case OStoreb:
262+ case Ostored:
263+ case Ostores:
264+ case Ostorel:
265+ case Ostorew:
266+ case Ostoreh:
267+ case Ostoreb:
268268 if (rtype(i.arg[0]) == RCon) {
269− if (i.op == OStored)
270− i.op = OStorel;
271− if (i.op == OStores)
272− i.op = OStorew;
269+ if (i.op == Ostored)
270+ i.op = Ostorel;
271+ if (i.op == Ostores)
272+ i.op = Ostorew;
273273 }
274274 seladdr(&i.arg[1], an, fn);
275275 goto Emit;
276− case_OLoad:
276+ case_Oload:
277277 seladdr(&i.arg[0], an, fn);
278278 goto Emit;
279− case OCall:
280− case OSAlloc:
281− case OCopy:
282− case OAdd:
283− case OSub:
284− case OMul:
285− case OAnd:
286− case OOr:
287− case OXor:
288− case OXTest:
289− case OFtosi:
290− case OSitof:
291− case OExts:
292− case OTruncd:
293− case OCast:
279+ case Ocall:
280+ case Osalloc:
281+ case Ocopy:
282+ case Oadd:
283+ case Osub:
284+ case Omul:
285+ case Oand:
286+ case Oor:
287+ case Oxor:
288+ case Oxtest:
289+ case Oftosi:
290+ case Ositof:
291+ case Oexts:
292+ case Otruncd:
293+ case Ocast:
294294 case_OExt:
295295 Emit:
296296 emiti(i);
@@ -298,9 +298,9 @@ Emit: · 1 unmodified line
298298 fixarg(&iarg[0], argcls(&i, 0), 0, fn);
299299 fixarg(&iarg[1], argcls(&i, 1), 0, fn);
300300 break;
301− case OAlloc:
302− case OAlloc+1:
303− case OAlloc+2: /* == OAlloc1 */
301+ case Oalloc:
302+ case Oalloc+1:
303+ case Oalloc+2: /* == Oalloc1 */
304304 /* we need to make sure
305305 * the stack remains aligned
306306 * (rsp = 0) mod 16
@@ -310,14 +310,14 @@ Emit: · 3 unmodified lines
310310 if (sz < 0 || sz >= INT_MAX-15)
311311 err("invalid alloc size %"PRId64, sz);
312312 sz = (sz + 15) & -16;
313− emit(OSAlloc, Kl, i.to, getcon(sz, fn), R);
313+ emit(Osalloc, Kl, i.to, getcon(sz, fn), R);
314314 } else {
315315 /* r0 = (i.arg[0] + 15) & -16 */
316316 r0 = newtmp("isel", Kl, fn);
317317 r1 = newtmp("isel", Kl, fn);
318− emit(OSAlloc, Kl, i.to, r0, R);
319− emit(OAnd, Kl, r0, r1, getcon(-16, fn));
320− emit(OAdd, Kl, r1, i.arg[0], getcon(15, fn));
318+ emit(Osalloc, Kl, i.to, r0, R);
319+ emit(Oand, Kl, r0, r1, getcon(-16, fn));
320+ emit(Oadd, Kl, r1, i.arg[0], getcon(15, fn));
321321 if (fn->tmp[i.arg[0].val].slot != -1)
322322 err("unlikely argument %%%s in %s",
323323 fn->tmp[i.arg[0].val].name, opdesc[i.op].name);
@@ -327,11 +327,11 @@ Emit: · 3 unmodified lines
327327 if (isext(i.op))
328328 goto case_OExt;
329329 if (isload(i.op))
330− goto case_OLoad;
330+ goto case_Oload;
331331 if (iscmp(i.op, &kc, &x)) {
332332 if (rtype(i.arg[0]) == RCon)
333333 x = icmpop(x);
334− emit(OXSet+x, k, i.to, R, R);
334+ emit(Oxset+x, k, i.to, R, R);
335335 selcmp(i.arg, kc, fn);
336336 break;
337337 }
@@ -365,14 +365,14 @@ seljmp(Blk *b, Fn *fn) · 27 unmodified lines
365365 int c, k;
366366 Ins *fi;
367367
368− if (b->jmp.type == JRet0 || b->jmp.type == JJmp)
368+ if (b->jmp.type == Jret0 || b->jmp.type == Jjmp)
369369 return;
370− assert(b->jmp.type == JJnz);
370+ assert(b->jmp.type == Jjnz);
371371 r = b->jmp.arg;
372372 b->jmp.arg = R;
373373 assert(!req(r, R) && rtype(r) != RCon);
374374 if (b->s1 == b->s2) {
375− b->jmp.type = JJmp;
375+ b->jmp.type = Jjmp;
376376 b->s2 = 0;
377377 return;
378378 }
@@ -381,20 +381,20 @@ seljmp(Blk *b, Fn *fn) · 2 unmodified lines
381381 if (iscmp(fi->op, &k, &c)) {
382382 if (rtype(fi->arg[0]) == RCon)
383383 c = icmpop(c);
384− b->jmp.type = JXJc + c;
384+ b->jmp.type = Jxjc + c;
385385 if (fn->tmp[r.val].nuse == 1) {
386386 assert(fn->tmp[r.val].ndef == 1);
387387 selcmp(fi->arg, k, fn);
388− *fi = (Ins){.op = ONop};
388+ *fi = (Ins){.op = Onop};
389389 }
390390 return;
391391 }
392− if (fi->op == OAnd && fn->tmp[r.val].nuse == 1
392+ if (fi->op == Oand && fn->tmp[r.val].nuse == 1
393393 && (rtype(fi->arg[0]) == RTmp ||
394394 rtype(fi->arg[1]) == RTmp)) {
395− fi->op = OXTest;
395+ fi->op = Oxtest;
396396 fi->to = R;
397− b->jmp.type = JXJc + ICne;
397+ b->jmp.type = Jxjc + ICne;
398398 if (rtype(fi->arg[1]) == RCon) {
399399 r = fi->arg[1];
400400 fi->arg[1] = fi->arg[0];
@@ -407,12 +407,12 @@ seljmp(Blk *b, Fn *fn) · 6 unmodified lines
407407 * has to be marked as live
408408 */
409409 if (fn->tmp[r.val].nuse == 1)
410− emit(OCopy, Kw, R, r, R);
411− b->jmp.type = JXJc + ICne;
410+ emit(Ocopy, Kw, R, r, R);
411+ b->jmp.type = Jxjc + ICne;
412412 return;
413413 }
414414 selcmp((Ref[2]){r, CON_Z}, Kw, fn); /* todo, add long branch if non-zero */
415− b->jmp.type = JXJc + ICne;
415+ b->jmp.type = Jxjc + ICne;
416416 }
417417
418418 static int
@@ -474,13 +474,13 @@ anumber(ANum *ai, Blk *b, Con *con) · 55 unmodified lines
474474 for (i=b->ins; i-b->ins < b->nins; i++) {
475475 if (rtype(i->to) == RTmp)
476476 ai[i->to.val].i = i;
477− if (i->op != OAdd && i->op != OMul)
477+ if (i->op != Oadd && i->op != Omul)
478478 continue;
479479 a1 = aref(i->arg[0], ai);
480480 a2 = aref(i->arg[1], ai);
481481 t1 = a1 != 1 && a1 != 2;
482482 t2 = a2 != 1 && a2 != 2;
483− if (i->op == OAdd) {
483+ if (i->op == Oadd) {
484484 a = add[n1 = a1][n2 = a2];
485485 if (t1 && a < add[0][a2])
486486 a = add[n1 = 0][n2 = a2];
@@ -586,7 +586,7 @@ isel(Fn *fn) · 99 unmodified lines
586586 /* assign slots to fast allocs */
587587 b = fn->start;
588588 /* specific to NAlign == 3 */ /* or change n=4 and sz /= 4 below */
589− for (al=OAlloc, n=4; al<=OAlloc1; al++, n*=2)
589+ for (al=Oalloc, n=4; al<=Oalloc1; al++, n*=2)
590590 for (i=b->ins; i-b->ins < b->nins; i++)
591591 if (i->op == al) {
592592 if (rtype(i->arg[0]) != RCon)
@@ -598,7 +598,7 @@ isel(Fn *fn) · 5 unmodified lines
598598 sz /= 4;
599599 fn->tmp[i->to.val].slot = fn->slot;
600600 fn->slot += sz;
601− *i = (Ins){.op = ONop};
601+ *i = (Ins){.op = Onop};
602602 }
603603
604604 /* process basic blocks */
live.c+1−1
@@ -115,7 +115,7 @@ Again: · 114 unmodified lines
115115 for (k=0; k<2; k++)
116116 b->nlive[k] = nlv[k];
117117 for (i=&b->ins[b->nins]; i!=b->ins;) {
118− if ((--i)->op == OCall && rtype(i->arg[1]) == RCall) {
118+ if ((--i)->op == Ocall && rtype(i->arg[1]) == RCall) {
119119 b->in->t[0] &= ~retregs(i->arg[1], m);
120120 for (k=0; k<2; k++)
121121 nlv[k] -= m[k];
mem.c+17−17
@@ -4,10 +4,10 @@ static int · 3 unmodified lines
44 loadsz(Ins *l)
55 {
66 switch (l->op) {
7− case OLoadsb: case OLoadub: return 1;
8− case OLoadsh: case OLoaduh: return 2;
9− case OLoadsw: case OLoaduw: return 4;
10− case OLoad: return KWIDE(l->cls) ? 8 : 4;
7+ case Oloadsb: case Oloadub: return 1;
8+ case Oloadsh: case Oloaduh: return 2;
9+ case Oloadsw: case Oloaduw: return 4;
10+ case Oload: return KWIDE(l->cls) ? 8 : 4;
1111 }
1212 die("unreachable");
1313 }
@@ -16,10 +16,10 @@ static int · 2 unmodified lines
1616 storesz(Ins *s)
1717 {
1818 switch (s->op) {
19− case OStoreb: return 1;
20− case OStoreh: return 2;
21− case OStorew: case OStores: return 4;
22− case OStorel: case OStored: return 8;
19+ case Ostoreb: return 1;
20+ case Ostoreh: return 2;
21+ case Ostorew: case Ostores: return 4;
22+ case Ostorel: case Ostored: return 8;
2323 }
2424 die("unreachable");
2525 }
@@ -38,7 +38,7 @@ memopt(Fn *fn) · 12 unmodified lines
3838 /* promote uniform stack slots to temporaries */
3939 b = fn->start;
4040 for (i=b->ins; i-b->ins < b->nins; i++) {
41− if (OAlloc > i->op || i->op > OAlloc1)
41+ if (Oalloc > i->op || i->op > Oalloc1)
4242 continue;
4343 /* specific to NAlign == 3 */
4444 assert(rtype(i->to) == RTmp);
@@ -67,14 +67,14 @@ memopt(Fn *fn) · 22 unmodified lines
6767 goto Skip;
6868 }
6969 /* get rid of the alloc and replace uses */
70− *i = (Ins){.op = ONop};
70+ *i = (Ins){.op = Onop};
7171 t->ndef--;
7272 ue = &t->use[t->nuse];
7373 for (u=t->use; u!=ue; u++) {
7474 l = u->u.ins;
7575 if (isstore(l->op)) {
7676 l->cls = k;
77− l->op = OCopy;
77+ l->op = Ocopy;
7878 l->to = l->arg[1];
7979 l->arg[1] = R;
8080 t->nuse--;
@@ -86,16 +86,16 @@ memopt(Fn *fn) · 5 unmodified lines
8686 /* try to turn loads into copies so we
8787 * can eliminate them later */
8888 switch(l->op) {
89− case OLoad:
90− case OLoadsw:
91− case OLoaduw:
89+ case Oload:
90+ case Oloadsw:
91+ case Oloaduw:
9292 if (KBASE(k) != KBASE(l->cls))
93− l->op = OCast;
93+ l->op = Ocast;
9494 else
95− l->op = OCopy;
95+ l->op = Ocopy;
9696 break;
9797 default:
98− l->op = OExtsb + (l->op - OLoadsb);
98+ l->op = Oextsb + (l->op - Oloadsb);
9999 break;
100100 }
101101 }
parse.c+114−114
@@ -11,72 +11,72 @@ OpDesc opdesc[NOp] = { · 10 unmodified lines
1111 #define A(a,b,c,d) {[Kw]=K##a, [Kl]=K##b, [Ks]=K##c, [Kd]=K##d}
1212
1313 /* NAME NM ARGCLS0 ARGCLS1 SF LF FLD*/
14− [OAdd] = { "add", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 },
15− [OSub] = { "sub", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 },
16− [ODiv] = { "div", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 },
17− [ORem] = { "rem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
18− [OUDiv] = { "udiv", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
19− [OURem] = { "urem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
20− [OMul] = { "mul", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 },
21− [OAnd] = { "and", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
22− [OOr] = { "or", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
23− [OXor] = { "xor", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
24− [OSar] = { "sar", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
25− [OShr] = { "shr", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
26− [OShl] = { "shl", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
27− [OStored] = { "stored", 0, {A(d,d,d,d), A(m,m,m,m)}, 0, 1, 0 },
28− [OStores] = { "stores", 0, {A(s,s,s,s), A(m,m,m,m)}, 0, 1, 0 },
29− [OStorel] = { "storel", 0, {A(l,l,l,l), A(m,m,m,m)}, 0, 1, 0 },
30− [OStorew] = { "storew", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
31− [OStoreh] = { "storeh", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
32− [OStoreb] = { "storeb", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
33− [OLoad] = { "load", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 1, 0 },
34− [OLoadsw] = { "loadsw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
35− [OLoaduw] = { "loaduw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
36− [OLoadsh] = { "loadsh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
37− [OLoaduh] = { "loaduh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
38− [OLoadsb] = { "loadsb", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
39− [OLoadub] = { "loadub", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
40− [OExtsw] = { "extsw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 },
41− [OExtuw] = { "extuw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 },
42− [OExtsh] = { "extsh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
43− [OExtuh] = { "extuh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
44− [OExtsb] = { "extsb", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
45− [OExtub] = { "extub", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
46− [OExts] = { "exts", 0, {A(e,e,e,s), A(e,e,e,x)}, 0, 1, 1 },
47− [OTruncd] = { "truncd", 0, {A(e,e,d,e), A(e,e,x,e)}, 0, 1, 1 },
48− [OFtosi] = { "ftosi", 0, {A(s,d,e,e), A(x,x,e,e)}, 0, 1, 1 },
49− [OSitof] = { "sitof", 0, {A(e,e,w,l), A(e,e,x,x)}, 0, 1, 1 },
50− [OCast] = { "cast", 0, {A(s,d,w,l), A(x,x,x,x)}, 0, 1, 1 },
51− [OCopy] = { "copy", 1, {A(w,l,s,d), A(x,x,x,x)}, 0, 1, 0 },
52− [ONop] = { "nop", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 1, 0 },
53− [OSwap] = { "swap", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 0 },
54− [OSign] = { "sign", 0, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
55− [OSAlloc] = { "salloc", 0, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
56− [OXIDiv] = { "xidiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
57− [OXDiv] = { "xdiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
58− [OXCmp] = { "xcmp", 1, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 0 },
59− [OXTest] = { "xtest", 1, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 0 },
60− [OAddr] = { "addr", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
61− [OPar] = { "parn", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 0, 0 },
62− [OParc] = { "parc", 0, {A(e,x,e,e), A(e,x,e,e)}, 0, 0, 0 },
63− [OArg] = { "arg", 0, {A(w,l,s,d), A(x,x,x,x)}, 0, 0, 0 },
64− [OArgc] = { "argc", 0, {A(e,x,e,e), A(e,l,e,e)}, 0, 0, 0 },
65− [OCall] = { "call", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 0, 0 },
66− [OXSetnp] = { "xsetnp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 },
67− [OXSetp] = { "xsetp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 },
68− [OAlloc] = { "alloc4", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
69− [OAlloc+1] = { "alloc8", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
70− [OAlloc+2] = { "alloc16", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
14+ [Oadd] = { "add", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 },
15+ [Osub] = { "sub", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 },
16+ [Odiv] = { "div", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 },
17+ [Orem] = { "rem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
18+ [Oudiv] = { "udiv", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
19+ [Ourem] = { "urem", 2, {A(w,l,e,e), A(w,l,e,e)}, 0, 0, 1 },
20+ [Omul] = { "mul", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 1 },
21+ [Oand] = { "and", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
22+ [Oor] = { "or", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
23+ [Oxor] = { "xor", 2, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 1 },
24+ [Osar] = { "sar", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
25+ [Oshr] = { "shr", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
26+ [Oshl] = { "shl", 1, {A(w,l,e,e), A(w,w,e,e)}, 1, 0, 1 },
27+ [Ostored] = { "stored", 0, {A(d,d,d,d), A(m,m,m,m)}, 0, 1, 0 },
28+ [Ostores] = { "stores", 0, {A(s,s,s,s), A(m,m,m,m)}, 0, 1, 0 },
29+ [Ostorel] = { "storel", 0, {A(l,l,l,l), A(m,m,m,m)}, 0, 1, 0 },
30+ [Ostorew] = { "storew", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
31+ [Ostoreh] = { "storeh", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
32+ [Ostoreb] = { "storeb", 0, {A(w,w,w,w), A(m,m,m,m)}, 0, 1, 0 },
33+ [Oload] = { "load", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 1, 0 },
34+ [Oloadsw] = { "loadsw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
35+ [Oloaduw] = { "loaduw", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
36+ [Oloadsh] = { "loadsh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
37+ [Oloaduh] = { "loaduh", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
38+ [Oloadsb] = { "loadsb", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
39+ [Oloadub] = { "loadub", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
40+ [Oextsw] = { "extsw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 },
41+ [Oextuw] = { "extuw", 0, {A(e,w,e,e), A(e,x,e,e)}, 0, 1, 1 },
42+ [Oextsh] = { "extsh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
43+ [Oextuh] = { "extuh", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
44+ [Oextsb] = { "extsb", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
45+ [Oextub] = { "extub", 0, {A(w,w,e,e), A(x,x,e,e)}, 0, 1, 1 },
46+ [Oexts] = { "exts", 0, {A(e,e,e,s), A(e,e,e,x)}, 0, 1, 1 },
47+ [Otruncd] = { "truncd", 0, {A(e,e,d,e), A(e,e,x,e)}, 0, 1, 1 },
48+ [Oftosi] = { "ftosi", 0, {A(s,d,e,e), A(x,x,e,e)}, 0, 1, 1 },
49+ [Ositof] = { "sitof", 0, {A(e,e,w,l), A(e,e,x,x)}, 0, 1, 1 },
50+ [Ocast] = { "cast", 0, {A(s,d,w,l), A(x,x,x,x)}, 0, 1, 1 },
51+ [Ocopy] = { "copy", 1, {A(w,l,s,d), A(x,x,x,x)}, 0, 1, 0 },
52+ [Onop] = { "nop", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 1, 0 },
53+ [Oswap] = { "swap", 2, {A(w,l,s,d), A(w,l,s,d)}, 0, 0, 0 },
54+ [Osign] = { "sign", 0, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
55+ [Osalloc] = { "salloc", 0, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
56+ [Oxidiv] = { "xidiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
57+ [Oxdiv] = { "xdiv", 1, {A(w,l,e,e), A(x,x,e,e)}, 0, 0, 0 },
58+ [Oxcmp] = { "xcmp", 1, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 0 },
59+ [Oxtest] = { "xtest", 1, {A(w,l,e,e), A(w,l,e,e)}, 1, 0, 0 },
60+ [Oaddr] = { "addr", 0, {A(m,m,e,e), A(x,x,e,e)}, 0, 1, 0 },
61+ [Opar] = { "parn", 0, {A(x,x,x,x), A(x,x,x,x)}, 0, 0, 0 },
62+ [Oparc] = { "parc", 0, {A(e,x,e,e), A(e,x,e,e)}, 0, 0, 0 },
63+ [Oarg] = { "arg", 0, {A(w,l,s,d), A(x,x,x,x)}, 0, 0, 0 },
64+ [Oargc] = { "argc", 0, {A(e,x,e,e), A(e,l,e,e)}, 0, 0, 0 },
65+ [Ocall] = { "call", 0, {A(m,m,m,m), A(x,x,x,x)}, 0, 0, 0 },
66+ [Oxsetnp] = { "xsetnp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 },
67+ [Oxsetp] = { "xsetp", 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 0, 0 },
68+ [Oalloc] = { "alloc4", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
69+ [Oalloc+1] = { "alloc8", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
70+ [Oalloc+2] = { "alloc16", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 },
7171 #define X(c) \
72− [OCmpw+IC##c] = { "c" #c "w", 0, {A(w,w,e,e), A(w,w,e,e)}, 1, 0, 1 }, \
73− [OCmpl+IC##c] = { "c" #c "l", 0, {A(l,l,e,e), A(l,l,e,e)}, 1, 0, 1 }, \
74− [OXSet+IC##c] = { "xset" #c, 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 1, 0 },
72+ [Ocmpw+IC##c] = { "c" #c "w", 0, {A(w,w,e,e), A(w,w,e,e)}, 1, 0, 1 }, \
73+ [Ocmpl+IC##c] = { "c" #c "l", 0, {A(l,l,e,e), A(l,l,e,e)}, 1, 0, 1 }, \
74+ [Oxset+IC##c] = { "xset" #c, 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 1, 0 },
7575 ICMPS(X)
7676 #undef X
7777 #define X(c) \
78− [OCmps+FC##c] = { "c" #c "s", 0, {A(s,s,e,e), A(s,s,e,e)}, 1, 0, 1 }, \
79− [OCmpd+FC##c] = { "c" #c "d", 0, {A(d,d,e,e), A(d,d,e,e)}, 1, 0, 1 },
78+ [Ocmps+FC##c] = { "c" #c "s", 0, {A(s,s,e,e), A(s,s,e,e)}, 1, 0, 1 }, \
79+ [Ocmpd+FC##c] = { "c" #c "d", 0, {A(d,d,e,e), A(d,d,e,e)}, 1, 0, 1 },
8080 FCMPS(X)
8181 #undef X
8282
@@ -191,12 +191,12 @@ lex() · 108 unmodified lines
191191 { "d", TD },
192192 { "s", TS },
193193 { "z", TZ },
194− { "loadw", OLoad }, /* for convenience */
195− { "loadl", OLoad },
196− { "loads", OLoad },
197− { "loadd", OLoad },
198− { "alloc1", OAlloc },
199− { "alloc2", OAlloc },
194+ { "loadw", Oload }, /* for convenience */
195+ { "loadl", Oload },
196+ { "loads", Oload },
197+ { "loadd", Oload },
198+ { "alloc1", Oalloc },
199+ { "alloc2", Oalloc },
200200 { 0, TXXX }
201201 };
202202 static char tok[NString];
@@ -453,14 +453,14 @@ parserefl(int arg) · 250 unmodified lines
453453 err("invalid function parameter");
454454 if (k == 4)
455455 if (arg)
456− *curi = (Ins){OArgc, R, {TYPE(ty), r}, Kl};
456+ *curi = (Ins){Oargc, R, {TYPE(ty), r}, Kl};
457457 else
458− *curi = (Ins){OParc, r, {TYPE(ty)}, Kl};
458+ *curi = (Ins){Oparc, r, {TYPE(ty)}, Kl};
459459 else
460460 if (arg)
461− *curi = (Ins){OArg, R, {r}, k};
461+ *curi = (Ins){Oarg, R, {r}, k};
462462 else
463− *curi = (Ins){OPar, r, {R}, k};
463+ *curi = (Ins){Opar, r, {R}, k};
464464 curi++;
465465 if (peek() == TRParen)
466466 break;
@@ -522,12 +522,12 @@ parseline(PState ps) · 55 unmodified lines
522522 break;
523523 case TLbl:
524524 b = findblk(tokval.str);
525− if (curb && curb->jmp.type == JXXX) {
525+ if (curb && curb->jmp.type == Jxxx) {
526526 closeblk();
527− curb->jmp.type = JJmp;
527+ curb->jmp.type = Jjmp;
528528 curb->s1 = b;
529529 }
530− if (b->jmp.type != JXXX)
530+ if (b->jmp.type != Jxxx)
531531 err("multiple definitions of block @%s", b->name);
532532 *blink = b;
533533 curb = b;
@@ -536,9 +536,9 @@ parseline(PState ps) · 2 unmodified lines
536536 return PPhi;
537537 case TRet:
538538 curb->jmp.type = (int[]){
539− JRetw, JRetl,
540− JRets, JRetd,
541− JRetc, JRet0
539+ Jretw, Jretl,
540+ Jrets, Jretd,
541+ Jretc, Jret0
542542 }[rcls];
543543 if (rcls < 5) {
544544 r = parseref();
@@ -548,10 +548,10 @@ parseline(PState ps) · 3 unmodified lines
548548 }
549549 goto Close;
550550 case TJmp:
551− curb->jmp.type = JJmp;
551+ curb->jmp.type = Jjmp;
552552 goto Jump;
553553 case TJnz:
554− curb->jmp.type = JJnz;
554+ curb->jmp.type = Jjnz;
555555 r = parseref();
556556 if (req(r, R))
557557 err("invalid argument for jnz jump");
@@ -560,7 +560,7 @@ parseline(PState ps) · 2 unmodified lines
560560 Jump:
561561 expect(TLbl);
562562 curb->s1 = findblk(tokval.str);
563− if (curb->jmp.type != JJmp) {
563+ if (curb->jmp.type != Jjmp) {
564564 expect(TComma);
565565 expect(TLbl);
566566 curb->s2 = findblk(tokval.str);
@@ -586,7 +586,7 @@ DoOp: · 19 unmodified lines
586586 arg[0] = parseref();
587587 parserefl(1);
588588 expect(TNL);
589− op = OCall;
589+ op = Ocall;
590590 if (k == 4) {
591591 k = Kl;
592592 arg[1] = TYPE(ty);
@@ -721,19 +721,19 @@ typecheck(Fn *fn) · 128 unmodified lines
721721 }
722722 r = b->jmp.arg;
723723 if (isret(b->jmp.type)) {
724− if (b->jmp.type == JRetc) {
724+ if (b->jmp.type == Jretc) {
725725 if (!usecheck(r, Kl, fn))
726726 goto JErr;
727− } else if (!usecheck(r, b->jmp.type-JRetw, fn))
727+ } else if (!usecheck(r, b->jmp.type-Jretw, fn))
728728 goto JErr;
729729 }
730− if (b->jmp.type == JJnz && !usecheck(r, Kw, fn))
730+ if (b->jmp.type == Jjnz && !usecheck(r, Kw, fn))
731731 JErr:
732732 err("invalid type for jump argument %%%s in block @%s",
733733 fn->tmp[r.val].name, b->name);
734− if (b->s1 && b->s1->jmp.type == JXXX)
734+ if (b->s1 && b->s1->jmp.type == Jxxx)
735735 err("block @%s is used undefined", b->s1->name);
736− if (b->s2 && b->s2->jmp.type == JXXX)
736+ if (b->s2 && b->s2->jmp.type == Jxxx)
737737 err("block @%s is used undefined", b->s2->name);
738738 }
739739 }
@@ -775,7 +775,7 @@ parsefn(int export) · 35 unmodified lines
775775 while (ps != PEnd);
776776 if (!curb)
777777 err("empty function");
778− if (curb->jmp.type == JXXX)
778+ if (curb->jmp.type == Jxxx)
779779 err("last block misses jump");
780780 curf->mem = vnew(0, sizeof curf->mem[0]);
781781 curf->nmem = 0;
@@ -1086,26 +1086,26 @@ void · 304 unmodified lines
10861086 printfn(Fn *fn, FILE *f)
10871087 {
10881088 static char *jtoa[NJmp] = {
1089− [JRet0] = "ret",
1090− [JRetw] = "retw",
1091− [JRetl] = "retl",
1092− [JRetc] = "retc",
1093− [JRets] = "rets",
1094− [JRetd] = "retd",
1095− [JJnz] = "jnz",
1096− [JXJnp] = "xjnp",
1097− [JXJp] = "xjp",
1098− #define X(c) [JXJc+IC##c] = "xj" #c,
1089+ [Jret0] = "ret",
1090+ [Jretw] = "retw",
1091+ [Jretl] = "retl",
1092+ [Jretc] = "retc",
1093+ [Jrets] = "rets",
1094+ [Jretd] = "retd",
1095+ [Jjnz] = "jnz",
1096+ [Jxjnp] = "xjnp",
1097+ [Jxjp] = "xjp",
1098+ #define X(c) [Jxjc+IC##c] = "xj" #c,
10991099 ICMPS(X)
11001100 #undef X
11011101 };
11021102 static char prcls[NOp] = {
1103− [OArg] = 1,
1104− [OSwap] = 1,
1105− [OXCmp] = 1,
1106− [OXTest] = 1,
1107− [OXDiv] = 1,
1108− [OXIDiv] = 1,
1103+ [Oarg] = 1,
1104+ [Oswap] = 1,
1105+ [Oxcmp] = 1,
1106+ [Oxtest] = 1,
1107+ [Oxdiv] = 1,
1108+ [Oxidiv] = 1,
11091109 };
11101110 static char ktoc[] = "wlsd";
11111111 Blk *b;
@@ -1154,28 +1154,28 @@ printfn(Fn *fn, FILE *f) · 42 unmodified lines
11541154 fprintf(f, "\n");
11551155 }
11561156 switch (b->jmp.type) {
1157− case JRet0:
1158− case JRetw:
1159− case JRetl:
1160− case JRets:
1161− case JRetd:
1162− case JRetc:
1157+ case Jret0:
1158+ case Jretw:
1159+ case Jretl:
1160+ case Jrets:
1161+ case Jretd:
1162+ case Jretc:
11631163 fprintf(f, "\t%s", jtoa[b->jmp.type]);
1164− if (b->jmp.type != JRet0 || !req(b->jmp.arg, R)) {
1164+ if (b->jmp.type != Jret0 || !req(b->jmp.arg, R)) {
11651165 fprintf(f, " ");
11661166 printref(b->jmp.arg, fn, f);
11671167 }
1168− if (b->jmp.type == JRetc)
1168+ if (b->jmp.type == Jretc)
11691169 fprintf(f, ", :%s", typ[fn->retty].name);
11701170 fprintf(f, "\n");
11711171 break;
1172− case JJmp:
1172+ case Jjmp:
11731173 if (b->s1 != b->link)
11741174 fprintf(f, "\tjmp @%s\n", b->s1->name);
11751175 break;
11761176 default:
11771177 fprintf(f, "\t%s ", jtoa[b->jmp.type]);
1178− if (b->jmp.type == JJnz) {
1178+ if (b->jmp.type == Jjnz) {
11791179 printref(b->jmp.arg, fn, f);
11801180 fprintf(f, ", ");
11811181 }
rega.c+10−10
@@ -224,10 +224,10 @@ pmrec(enum PMStat *status, int i, int *k) · 223 unmodified lines
224224 }
225225 status[i] = Moved;
226226 if (req(swp, R)) {
227− *curi++ = (Ins){OCopy, pm[i].dst, {pm[i].src}, pm[i].cls};
227+ *curi++ = (Ins){Ocopy, pm[i].dst, {pm[i].src}, pm[i].cls};
228228 return R;
229229 } else if (!req(swp, pm[i].src)) {
230− *curi++ = (Ins){OSwap, R, {pm[i].src, pm[i].dst}, *k};
230+ *curi++ = (Ins){Oswap, R, {pm[i].src, pm[i].dst}, *k};
231231 return swp;
232232 } else
233233 return R;
@@ -273,7 +273,7 @@ move(int r, Ref to, RMap *m) · 39 unmodified lines
273273 static int
274274 regcpy(Ins *i)
275275 {
276− return i->op == OCopy && isreg(i->arg[0]);
276+ return i->op == Ocopy && isreg(i->arg[0]);
277277 }
278278
279279 static Ins *
@@ -291,7 +291,7 @@ dopm(Blk *b, Ins *i, RMap *m) · 11 unmodified lines
291291 move(i->arg[0].val, i->to, m);
292292 } while (i != b->ins && regcpy(i-1));
293293 assert(m0.n <= m->n);
294− if (i != b->ins && (i-1)->op == OCall) {
294+ if (i != b->ins && (i-1)->op == Ocall) {
295295 def = retregs((i-1)->arg[1], 0);
296296 for (r=0; r<NRSave; r++)
297297 if (!(BIT(rsave[r]) & def))
@@ -371,13 +371,13 @@ doblk(Blk *b, RMap *cur) · 73 unmodified lines
371371 }
372372 for (i=&b->ins[b->nins]; i!=b->ins;) {
373373 switch ((--i)->op) {
374− case OCall:
374+ case Ocall:
375375 rs = argregs(i->arg[1], 0);
376376 for (r=0; r<NRSave; r++)
377377 if (!(BIT(rsave[r]) & rs))
378378 rfree(cur, rsave[r]);
379379 break;
380− case OCopy:
380+ case Ocopy:
381381 if (isreg(i->arg[0])) {
382382 i = dopm(b, i, cur);
383383 continue;
@@ -391,7 +391,7 @@ doblk(Blk *b, RMap *cur) · 7 unmodified lines
391391 assert(rtype(i->to) == RTmp);
392392 r = rfree(cur, i->to.val);
393393 if (r == -1 && !isreg(i->to)) {
394− *i = (Ins){.op = ONop};
394+ *i = (Ins){.op = Onop};
395395 continue;
396396 }
397397 if (i->to.val >= Tmp0)
@@ -447,7 +447,7 @@ rega(Fn *fn) · 49 unmodified lines
447447 for (t=Tmp0; t<fn->ntmp; t++)
448448 *hint(t) = -1;
449449 for (b=fn->start, i=b->ins; i-b->ins < b->nins; i++)
450− if (i->op != OCopy || !isreg(i->arg[0]))
450+ if (i->op != Ocopy || !isreg(i->arg[0]))
451451 break;
452452 else {
453453 assert(rtype(i->to) == RTmp);
@@ -507,7 +507,7 @@ rega(Fn *fn) · 53 unmodified lines
507507 rfree(&cur, t);
508508 radd(&cur, t, r);
509509 x = tmp[t].cls;
510− emit(OCopy, x, TMP(r1), TMP(r), R);
510+ emit(Ocopy, x, TMP(r1), TMP(r), R);
511511 }
512512 }
513513 if ((j = &insb[NIns] - curi)) {
@@ -569,7 +569,7 @@ rega(Fn *fn) · 55 unmodified lines
569569 sprintf(b1->name, "%s_%s", b->name, s->name);
570570 b1->nins = curi - insb;
571571 idup(&b1->ins, insb, b1->nins);
572− b1->jmp.type = JJmp;
572+ b1->jmp.type = Jjmp;
573573 b1->s1 = s;
574574 **ps = b1;
575575 }
spill.c+5−5
@@ -234,20 +234,20 @@ reloads(BSet *u, BSet *v) · 233 unmodified lines
234234
235235 for (t=Tmp0; bsiter(u, &t); t++)
236236 if (!bshas(v, t))
237− emit(OLoad, tmp[t].cls, TMP(t), slot(t), R);
237+ emit(Oload, tmp[t].cls, TMP(t), slot(t), R);
238238 }
239239
240240 static void
241241 store(Ref r, int s)
242242 {
243243 if (s != -1)
244− emit(OStorew + tmp[r.val].cls, 0, R, r, SLOT(s));
244+ emit(Ostorew + tmp[r.val].cls, 0, R, r, SLOT(s));
245245 }
246246
247247 static int
248248 regcpy(Ins *i)
249249 {
250− return i->op == OCopy && isreg(i->arg[0]);
250+ return i->op == Ocopy && isreg(i->arg[0]);
251251 }
252252
253253 static Ins *
@@ -281,7 +281,7 @@ dopm(Blk *b, Ins *i, BSet *v) · 27 unmodified lines
281281 bsset(v, i->arg[0].val);
282282 } while (i != b->ins && regcpy(i-1));
283283 bscopy(u, v);
284− if (i != b->ins && (i-1)->op == OCall) {
284+ if (i != b->ins && (i-1)->op == Ocall) {
285285 v->t[0] &= ~retregs((i-1)->arg[1], 0);
286286 limit2(v, NISave, NFSave, 0);
287287 for (r=0, n=0; n<NRSave; n++)
@@ -308,7 +308,7 @@ dopm(Blk *b, Ins *i, BSet *v) · 20 unmodified lines
308308 * borders
309309 *
310310 * Be careful with:
311− * - OCopy instructions to ensure register
311+ * - Ocopy instructions to ensure register
312312 * constraints
313313 */
314314 void
sysv.c+56−56
@@ -76,11 +76,11 @@ blit(Ref rstk, uint soff, Ref rsrc, uint sz, Fn *fn) · 75 unmodified lines
7676 for (boff=0; sz>0; sz-=8, soff+=8, boff+=8) {
7777 r = newtmp("abi", Kl, fn);
7878 r1 = newtmp("abi", Kl, fn);
79− emit(OStorel, 0, R, r, r1);
80− emit(OAdd, Kl, r1, rstk, getcon(soff, fn));
79+ emit(Ostorel, 0, R, r, r1);
80+ emit(Oadd, Kl, r1, rstk, getcon(soff, fn));
8181 r1 = newtmp("abi", Kl, fn);
82− emit(OLoad, Kl, r, r1, R);
83− emit(OAdd, Kl, r1, rsrc, getcon(boff, fn));
82+ emit(Oload, Kl, r, r1, R);
83+ emit(Oadd, Kl, r1, rsrc, getcon(boff, fn));
8484 }
8585 }
8686
@@ -109,35 +109,35 @@ selret(Blk *b, Fn *fn) · 22 unmodified lines
109109
110110 j = b->jmp.type;
111111
112− if (!isret(j) || j == JRet0)
112+ if (!isret(j) || j == Jret0)
113113 return;
114114
115115 r0 = b->jmp.arg;
116− b->jmp.type = JRet0;
116+ b->jmp.type = Jret0;
117117
118− if (j == JRetc) {
118+ if (j == Jretc) {
119119 aclass(&aret, &typ[fn->retty]);
120120 if (aret.inmem) {
121121 assert(rtype(fn->retr) == RTmp);
122− emit(OCopy, Kl, TMP(RAX), fn->retr, R);
122+ emit(Ocopy, Kl, TMP(RAX), fn->retr, R);
123123 blit(fn->retr, 0, r0, aret.size, fn);
124124 ca = 1;
125125 } else {
126126 ca = retr(reg, &aret);
127127 if (aret.size > 8) {
128128 r = newtmp("abi", Kl, fn);
129− emit(OLoad, Kl, reg[1], r, R);
130− emit(OAdd, Kl, r, r0, getcon(8, fn));
129+ emit(Oload, Kl, reg[1], r, R);
130+ emit(Oadd, Kl, r, r0, getcon(8, fn));
131131 }
132− emit(OLoad, Kl, reg[0], r0, R);
132+ emit(Oload, Kl, reg[0], r0, R);
133133 }
134134 } else {
135− k = j - JRetw;
135+ k = j - Jretw;
136136 if (KBASE(k) == 0) {
137− emit(OCopy, k, TMP(RAX), r0, R);
137+ emit(Ocopy, k, TMP(RAX), r0, R);
138138 ca = 1;
139139 } else {
140− emit(OCopy, k, TMP(XMM0), r0, R);
140+ emit(Ocopy, k, TMP(XMM0), r0, R);
141141 ca = 1 << 2;
142142 }
143143 }
@@ -272,9 +272,9 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 128 unmodified lines
272272 if (!req(i1->arg[1], R)) {
273273 assert(rtype(i1->arg[1]) == RType);
274274 aclass(&aret, &typ[i1->arg[1].val]);
275− ca = classify(i0, i1, ac, OArg, &aret);
275+ ca = classify(i0, i1, ac, Oarg, &aret);
276276 } else
277− ca = classify(i0, i1, ac, OArg, 0);
277+ ca = classify(i0, i1, ac, Oarg, 0);
278278
279279 for (stk=0, a=&ac[i1-i0]; a>ac;)
280280 if ((--a)->inmem) {
@@ -287,7 +287,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 6 unmodified lines
287287 stk += stk & 15;
288288 if (stk) {
289289 r = getcon(-(int64_t)stk, fn);
290− emit(OSAlloc, Kl, R, r, R);
290+ emit(Osalloc, Kl, R, r, R);
291291 }
292292
293293 if (!req(i1->arg[1], R)) {
@@ -295,60 +295,60 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 1 unmodified line
295295 /* get the return location from eax
296296 * it saves one callee-save reg */
297297 r1 = newtmp("abi", Kl, fn);
298− emit(OCopy, Kl, i1->to, TMP(RAX), R);
298+ emit(Ocopy, Kl, i1->to, TMP(RAX), R);
299299 ca += 1;
300300 } else {
301301 if (aret.size > 8) {
302302 r = newtmp("abi", Kl, fn);
303303 aret.ref[1] = newtmp("abi", aret.cls[1], fn);
304− emit(OStorel, 0, R, aret.ref[1], r);
305− emit(OAdd, Kl, r, i1->to, getcon(8, fn));
304+ emit(Ostorel, 0, R, aret.ref[1], r);
305+ emit(Oadd, Kl, r, i1->to, getcon(8, fn));
306306 }
307307 aret.ref[0] = newtmp("abi", aret.cls[0], fn);
308− emit(OStorel, 0, R, aret.ref[0], i1->to);
308+ emit(Ostorel, 0, R, aret.ref[0], i1->to);
309309 ca += retr(reg, &aret);
310310 if (aret.size > 8)
311− emit(OCopy, aret.cls[1], aret.ref[1], reg[1], R);
312− emit(OCopy, aret.cls[0], aret.ref[0], reg[0], R);
311+ emit(Ocopy, aret.cls[1], aret.ref[1], reg[1], R);
312+ emit(Ocopy, aret.cls[0], aret.ref[0], reg[0], R);
313313 r1 = i1->to;
314314 }
315315 /* allocate return pad */
316316 ra = alloc(sizeof *ra);
317317 /* specific to NAlign == 3 */
318318 al = aret.align >= 2 ? aret.align - 2 : 0;
319− ra->i = (Ins){OAlloc+al, r1, {getcon(aret.size, fn)}, Kl};
319+ ra->i = (Ins){Oalloc+al, r1, {getcon(aret.size, fn)}, Kl};
320320 ra->link = (*rap);
321321 *rap = ra;
322322 } else {
323323 ra = 0;
324324 if (KBASE(i1->cls) == 0) {
325− emit(OCopy, i1->cls, i1->to, TMP(RAX), R);
325+ emit(Ocopy, i1->cls, i1->to, TMP(RAX), R);
326326 ca += 1;
327327 } else {
328− emit(OCopy, i1->cls, i1->to, TMP(XMM0), R);
328+ emit(Ocopy, i1->cls, i1->to, TMP(XMM0), R);
329329 ca += 1 << 2;
330330 }
331331 }
332− emit(OCall, i1->cls, R, i1->arg[0], CALL(ca));
333− emit(OCopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R);
332+ emit(Ocall, i1->cls, R, i1->arg[0], CALL(ca));
333+ emit(Ocopy, Kw, TMP(RAX), getcon((ca >> 8) & 15, fn), R);
334334
335335 ni = ns = 0;
336336 if (ra && aret.inmem)
337− emit(OCopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */
337+ emit(Ocopy, Kl, rarg(Kl, &ni, &ns), ra->i.to, R); /* pass hidden argument */
338338 for (i=i0, a=ac; i<i1; i++, a++) {
339339 if (a->inmem)
340340 continue;
341341 r1 = rarg(a->cls[0], &ni, &ns);
342− if (i->op == OArgc) {
342+ if (i->op == Oargc) {
343343 if (a->size > 8) {
344344 r2 = rarg(a->cls[1], &ni, &ns);
345345 r = newtmp("abi", Kl, fn);
346− emit(OLoad, a->cls[1], r2, r, R);
347− emit(OAdd, Kl, r, i->arg[1], getcon(8, fn));
346+ emit(Oload, a->cls[1], r2, r, R);
347+ emit(Oadd, Kl, r, i->arg[1], getcon(8, fn));
348348 }
349− emit(OLoad, a->cls[0], r1, i->arg[1], R);
349+ emit(Oload, a->cls[0], r1, i->arg[1], R);
350350 } else
351− emit(OCopy, i->cls, r1, i->arg[0], R);
351+ emit(Ocopy, i->cls, r1, i->arg[0], R);
352352 }
353353
354354 if (!stk)
@@ -358,18 +358,18 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) · 3 unmodified lines
358358 for (i=i0, a=ac, off=0; i<i1; i++, a++) {
359359 if (!a->inmem)
360360 continue;
361− if (i->op == OArgc) {
361+ if (i->op == Oargc) {
362362 if (a->align == 4)
363363 off += off & 15;
364364 blit(r, off, i->arg[1], a->size, fn);
365365 } else {
366366 r1 = newtmp("abi", Kl, fn);
367− emit(OStorel, 0, R, i->arg[0], r1);
368− emit(OAdd, Kl, r1, r, getcon(off, fn));
367+ emit(Ostorel, 0, R, i->arg[0], r1);
368+ emit(Oadd, Kl, r1, r, getcon(off, fn));
369369 }
370370 off += a->size;
371371 }
372− emit(OSAlloc, Kl, r, getcon(stk, fn), R);
372+ emit(Osalloc, Kl, r, getcon(stk, fn), R);
373373 }
374374
375375 static void
@@ -386,29 +386,29 @@ selpar(Fn *fn, Ins *i0, Ins *i1) · 10 unmodified lines
386386
387387 if (fn->retty >= 0) {
388388 aclass(&aret, &typ[fn->retty]);
389− classify(i0, i1, ac, OPar, &aret);
389+ classify(i0, i1, ac, Opar, &aret);
390390 } else
391− classify(i0, i1, ac, OPar, 0);
391+ classify(i0, i1, ac, Opar, 0);
392392
393393 for (i=i0, a=ac; i<i1; i++, a++) {
394− if (i->op != OParc || a->inmem)
394+ if (i->op != Oparc || a->inmem)
395395 continue;
396396 if (a->size > 8) {
397397 r = newtmp("abi", Kl, fn);
398398 a->ref[1] = newtmp("abi", Kl, fn);
399− emit(OStorel, 0, R, a->ref[1], r);
400− emit(OAdd, Kl, r, i->to, getcon(8, fn));
399+ emit(Ostorel, 0, R, a->ref[1], r);
400+ emit(Oadd, Kl, r, i->to, getcon(8, fn));
401401 }
402402 a->ref[0] = newtmp("abi", Kl, fn);
403− emit(OStorel, 0, R, a->ref[0], i->to);
403+ emit(Ostorel, 0, R, a->ref[0], i->to);
404404 /* specific to NAlign == 3 */
405405 al = a->align >= 2 ? a->align - 2 : 0;
406− emit(OAlloc+al, Kl, i->to, getcon(a->size, fn), R);
406+ emit(Oalloc+al, Kl, i->to, getcon(a->size, fn), R);
407407 }
408408
409409 if (fn->retty >= 0 && aret.inmem) {
410410 r = newtmp("abi", Kl, fn);
411− emit(OCopy, Kl, r, rarg(Kl, &ni, &ns), R);
411+ emit(Ocopy, Kl, r, rarg(Kl, &ni, &ns), R);
412412 fn->retr = r;
413413 }
414414
@@ -423,19 +423,19 @@ selpar(Fn *fn, Ins *i0, Ins *i1) · 8 unmodified lines
423423 s += a->size / 4;
424424 continue;
425425 case 2:
426− emit(OLoad, i->cls, i->to, SLOT(-s), R);
426+ emit(Oload, i->cls, i->to, SLOT(-s), R);
427427 s += 2;
428428 continue;
429429 }
430430 r = rarg(a->cls[0], &ni, &ns);
431− if (i->op == OParc) {
432− emit(OCopy, Kl, a->ref[0], r, R);
431+ if (i->op == Oparc) {
432+ emit(Ocopy, Kl, a->ref[0], r, R);
433433 if (a->size > 8) {
434434 r = rarg(a->cls[1], &ni, &ns);
435− emit(OCopy, Kl, a->ref[1], r, R);
435+ emit(Ocopy, Kl, a->ref[1], r, R);
436436 }
437437 } else
438− emit(OCopy, i->cls, i->to, r, R);
438+ emit(Ocopy, i->cls, i->to, r, R);
439439 }
440440 }
441441
@@ -449,7 +449,7 @@ abi(Fn *fn) · 7 unmodified lines
449449
450450 /* lower arguments */
451451 for (b=fn->start, i=b->ins; i-b->ins < b->nins; i++)
452− if (i->op != OPar && i->op != OParc)
452+ if (i->op != Opar && i->op != Oparc)
453453 break;
454454 selpar(fn, b->ins, i);
455455 n = b->nins - (i - b->ins) + (&insb[NIns] - curi);
@@ -468,16 +468,16 @@ abi(Fn *fn) · 12 unmodified lines
468468 curi = &insb[NIns];
469469 selret(b, fn);
470470 for (i=&b->ins[b->nins]; i!=b->ins;) {
471− if ((--i)->op == OCall) {
471+ if ((--i)->op == Ocall) {
472472 for (i0=i; i0>b->ins; i0--)
473− if ((i0-1)->op != OArg)
474− if ((i0-1)->op != OArgc)
473+ if ((i0-1)->op != Oarg)
474+ if ((i0-1)->op != Oargc)
475475 break;
476476 selcall(fn, i0, i, &ral);
477477 i = i0;
478478 continue;
479479 }
480− assert(i->op != OArg && i->op != OArgc);
480+ assert(i->op != Oarg && i->op != Oargc);
481481 emiti(*i);
482482 }
483483 if (b == fn->start)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t