Showing the changes to parse.c (1 of 11 files). Show all
Unified · Split
| @@ -11,72 +11,72 @@ OpDesc opdesc[NOp] = { · 10 unmodified lines | |||
| 11 | #define A(a,b,c,d) {[Kw]=K##a, [Kl]=K##b, [Ks]=K##c, [Kd]=K##d} | 11 | #define A(a,b,c,d) {[Kw]=K##a, [Kl]=K##b, [Ks]=K##c, [Kd]=K##d} |
| 12 | 12 | ||
| 13 | /* NAME NM ARGCLS0 ARGCLS1 SF LF FLD*/ | 13 | /* NAME NM ARGCLS0 ARGCLS1 SF LF FLD*/ |
| 14 | [OAdd] = { "add", 2, {A(w,l,s,d), A(w,l,s,d)}, 1, 0, 1 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 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 }, | 70 | [Oalloc+2] = { "alloc16", 1, {A(e,l,e,e), A(e,x,e,e)}, 0, 0, 0 }, |
| 71 | #define X(c) \ | 71 | #define X(c) \ |
| 72 | [OCmpw+IC##c] = { "c" #c "w", 0, {A(w,w,e,e), A(w,w,e,e)}, 1, 0, 1 }, \ | 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 }, \ | 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 }, | 74 | [Oxset+IC##c] = { "xset" #c, 0, {A(x,x,e,e), A(x,x,e,e)}, 0, 1, 0 }, |
| 75 | ICMPS(X) | 75 | ICMPS(X) |
| 76 | #undef X | 76 | #undef X |
| 77 | #define X(c) \ | 77 | #define X(c) \ |
| 78 | [OCmps+FC##c] = { "c" #c "s", 0, {A(s,s,e,e), A(s,s,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 }, | 79 | [Ocmpd+FC##c] = { "c" #c "d", 0, {A(d,d,e,e), A(d,d,e,e)}, 1, 0, 1 }, |
| 80 | FCMPS(X) | 80 | FCMPS(X) |
| 81 | #undef X | 81 | #undef X |
| 82 | 82 | ||
| @@ -191,12 +191,12 @@ lex() · 108 unmodified lines | |||
| 191 | { "d", TD }, | 191 | { "d", TD }, |
| 192 | { "s", TS }, | 192 | { "s", TS }, |
| 193 | { "z", TZ }, | 193 | { "z", TZ }, |
| 194 | { "loadw", OLoad }, /* for convenience */ | 194 | { "loadw", Oload }, /* for convenience */ |
| 195 | { "loadl", OLoad }, | 195 | { "loadl", Oload }, |
| 196 | { "loads", OLoad }, | 196 | { "loads", Oload }, |
| 197 | { "loadd", OLoad }, | 197 | { "loadd", Oload }, |
| 198 | { "alloc1", OAlloc }, | 198 | { "alloc1", Oalloc }, |
| 199 | { "alloc2", OAlloc }, | 199 | { "alloc2", Oalloc }, |
| 200 | { 0, TXXX } | 200 | { 0, TXXX } |
| 201 | }; | 201 | }; |
| 202 | static char tok[NString]; | 202 | static char tok[NString]; |
| @@ -453,14 +453,14 @@ parserefl(int arg) · 250 unmodified lines | |||
| 453 | err("invalid function parameter"); | 453 | err("invalid function parameter"); |
| 454 | if (k == 4) | 454 | if (k == 4) |
| 455 | if (arg) | 455 | if (arg) |
| 456 | *curi = (Ins){OArgc, R, {TYPE(ty), r}, Kl}; | 456 | *curi = (Ins){Oargc, R, {TYPE(ty), r}, Kl}; |
| 457 | else | 457 | else |
| 458 | *curi = (Ins){OParc, r, {TYPE(ty)}, Kl}; | 458 | *curi = (Ins){Oparc, r, {TYPE(ty)}, Kl}; |
| 459 | else | 459 | else |
| 460 | if (arg) | 460 | if (arg) |
| 461 | *curi = (Ins){OArg, R, {r}, k}; | 461 | *curi = (Ins){Oarg, R, {r}, k}; |
| 462 | else | 462 | else |
| 463 | *curi = (Ins){OPar, r, {R}, k}; | 463 | *curi = (Ins){Opar, r, {R}, k}; |
| 464 | curi++; | 464 | curi++; |
| 465 | if (peek() == TRParen) | 465 | if (peek() == TRParen) |
| 466 | break; | 466 | break; |
| @@ -522,12 +522,12 @@ parseline(PState ps) · 55 unmodified lines | |||
| 522 | break; | 522 | break; |
| 523 | case TLbl: | 523 | case TLbl: |
| 524 | b = findblk(tokval.str); | 524 | b = findblk(tokval.str); |
| 525 | if (curb && curb->jmp.type == JXXX) { | 525 | if (curb && curb->jmp.type == Jxxx) { |
| 526 | closeblk(); | 526 | closeblk(); |
| 527 | curb->jmp.type = JJmp; | 527 | curb->jmp.type = Jjmp; |
| 528 | curb->s1 = b; | 528 | curb->s1 = b; |
| 529 | } | 529 | } |
| 530 | if (b->jmp.type != JXXX) | 530 | if (b->jmp.type != Jxxx) |
| 531 | err("multiple definitions of block @%s", b->name); | 531 | err("multiple definitions of block @%s", b->name); |
| 532 | *blink = b; | 532 | *blink = b; |
| 533 | curb = b; | 533 | curb = b; |
| @@ -536,9 +536,9 @@ parseline(PState ps) · 2 unmodified lines | |||
| 536 | return PPhi; | 536 | return PPhi; |
| 537 | case TRet: | 537 | case TRet: |
| 538 | curb->jmp.type = (int[]){ | 538 | curb->jmp.type = (int[]){ |
| 539 | JRetw, JRetl, | 539 | Jretw, Jretl, |
| 540 | JRets, JRetd, | 540 | Jrets, Jretd, |
| 541 | JRetc, JRet0 | 541 | Jretc, Jret0 |
| 542 | }[rcls]; | 542 | }[rcls]; |
| 543 | if (rcls < 5) { | 543 | if (rcls < 5) { |
| 544 | r = parseref(); | 544 | r = parseref(); |
| @@ -548,10 +548,10 @@ parseline(PState ps) · 3 unmodified lines | |||
| 548 | } | 548 | } |
| 549 | goto Close; | 549 | goto Close; |
| 550 | case TJmp: | 550 | case TJmp: |
| 551 | curb->jmp.type = JJmp; | 551 | curb->jmp.type = Jjmp; |
| 552 | goto Jump; | 552 | goto Jump; |
| 553 | case TJnz: | 553 | case TJnz: |
| 554 | curb->jmp.type = JJnz; | 554 | curb->jmp.type = Jjnz; |
| 555 | r = parseref(); | 555 | r = parseref(); |
| 556 | if (req(r, R)) | 556 | if (req(r, R)) |
| 557 | err("invalid argument for jnz jump"); | 557 | err("invalid argument for jnz jump"); |
| @@ -560,7 +560,7 @@ parseline(PState ps) · 2 unmodified lines | |||
| 560 | Jump: | 560 | Jump: |
| 561 | expect(TLbl); | 561 | expect(TLbl); |
| 562 | curb->s1 = findblk(tokval.str); | 562 | curb->s1 = findblk(tokval.str); |
| 563 | if (curb->jmp.type != JJmp) { | 563 | if (curb->jmp.type != Jjmp) { |
| 564 | expect(TComma); | 564 | expect(TComma); |
| 565 | expect(TLbl); | 565 | expect(TLbl); |
| 566 | curb->s2 = findblk(tokval.str); | 566 | curb->s2 = findblk(tokval.str); |
| @@ -586,7 +586,7 @@ DoOp: · 19 unmodified lines | |||
| 586 | arg[0] = parseref(); | 586 | arg[0] = parseref(); |
| 587 | parserefl(1); | 587 | parserefl(1); |
| 588 | expect(TNL); | 588 | expect(TNL); |
| 589 | op = OCall; | 589 | op = Ocall; |
| 590 | if (k == 4) { | 590 | if (k == 4) { |
| 591 | k = Kl; | 591 | k = Kl; |
| 592 | arg[1] = TYPE(ty); | 592 | arg[1] = TYPE(ty); |
| @@ -721,19 +721,19 @@ typecheck(Fn *fn) · 128 unmodified lines | |||
| 721 | } | 721 | } |
| 722 | r = b->jmp.arg; | 722 | r = b->jmp.arg; |
| 723 | if (isret(b->jmp.type)) { | 723 | if (isret(b->jmp.type)) { |
| 724 | if (b->jmp.type == JRetc) { | 724 | if (b->jmp.type == Jretc) { |
| 725 | if (!usecheck(r, Kl, fn)) | 725 | if (!usecheck(r, Kl, fn)) |
| 726 | goto JErr; | 726 | goto JErr; |
| 727 | } else if (!usecheck(r, b->jmp.type-JRetw, fn)) | 727 | } else if (!usecheck(r, b->jmp.type-Jretw, fn)) |
| 728 | goto JErr; | 728 | goto JErr; |
| 729 | } | 729 | } |
| 730 | if (b->jmp.type == JJnz && !usecheck(r, Kw, fn)) | 730 | if (b->jmp.type == Jjnz && !usecheck(r, Kw, fn)) |
| 731 | JErr: | 731 | JErr: |
| 732 | err("invalid type for jump argument %%%s in block @%s", | 732 | err("invalid type for jump argument %%%s in block @%s", |
| 733 | fn->tmp[r.val].name, b->name); | 733 | 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) |
| 735 | err("block @%s is used undefined", b->s1->name); | 735 | 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) |
| 737 | err("block @%s is used undefined", b->s2->name); | 737 | err("block @%s is used undefined", b->s2->name); |
| 738 | } | 738 | } |
| 739 | } | 739 | } |
| @@ -775,7 +775,7 @@ parsefn(int export) · 35 unmodified lines | |||
| 775 | while (ps != PEnd); | 775 | while (ps != PEnd); |
| 776 | if (!curb) | 776 | if (!curb) |
| 777 | err("empty function"); | 777 | err("empty function"); |
| 778 | if (curb->jmp.type == JXXX) | 778 | if (curb->jmp.type == Jxxx) |
| 779 | err("last block misses jump"); | 779 | err("last block misses jump"); |
| 780 | curf->mem = vnew(0, sizeof curf->mem[0]); | 780 | curf->mem = vnew(0, sizeof curf->mem[0]); |
| 781 | curf->nmem = 0; | 781 | curf->nmem = 0; |
| @@ -1086,26 +1086,26 @@ void · 304 unmodified lines | |||
| 1086 | printfn(Fn *fn, FILE *f) | 1086 | printfn(Fn *fn, FILE *f) |
| 1087 | { | 1087 | { |
| 1088 | static char *jtoa[NJmp] = { | 1088 | static char *jtoa[NJmp] = { |
| 1089 | [JRet0] = "ret", | 1089 | [Jret0] = "ret", |
| 1090 | [JRetw] = "retw", | 1090 | [Jretw] = "retw", |
| 1091 | [JRetl] = "retl", | 1091 | [Jretl] = "retl", |
| 1092 | [JRetc] = "retc", | 1092 | [Jretc] = "retc", |
| 1093 | [JRets] = "rets", | 1093 | [Jrets] = "rets", |
| 1094 | [JRetd] = "retd", | 1094 | [Jretd] = "retd", |
| 1095 | [JJnz] = "jnz", | 1095 | [Jjnz] = "jnz", |
| 1096 | [JXJnp] = "xjnp", | 1096 | [Jxjnp] = "xjnp", |
| 1097 | [JXJp] = "xjp", | 1097 | [Jxjp] = "xjp", |
| 1098 | #define X(c) [JXJc+IC##c] = "xj" #c, | 1098 | #define X(c) [Jxjc+IC##c] = "xj" #c, |
| 1099 | ICMPS(X) | 1099 | ICMPS(X) |
| 1100 | #undef X | 1100 | #undef X |
| 1101 | }; | 1101 | }; |
| 1102 | static char prcls[NOp] = { | 1102 | static char prcls[NOp] = { |
| 1103 | [OArg] = 1, | 1103 | [Oarg] = 1, |
| 1104 | [OSwap] = 1, | 1104 | [Oswap] = 1, |
| 1105 | [OXCmp] = 1, | 1105 | [Oxcmp] = 1, |
| 1106 | [OXTest] = 1, | 1106 | [Oxtest] = 1, |
| 1107 | [OXDiv] = 1, | 1107 | [Oxdiv] = 1, |
| 1108 | [OXIDiv] = 1, | 1108 | [Oxidiv] = 1, |
| 1109 | }; | 1109 | }; |
| 1110 | static char ktoc[] = "wlsd"; | 1110 | static char ktoc[] = "wlsd"; |
| 1111 | Blk *b; | 1111 | Blk *b; |
| @@ -1154,28 +1154,28 @@ printfn(Fn *fn, FILE *f) · 42 unmodified lines | |||
| 1154 | fprintf(f, "\n"); | 1154 | fprintf(f, "\n"); |
| 1155 | } | 1155 | } |
| 1156 | switch (b->jmp.type) { | 1156 | switch (b->jmp.type) { |
| 1157 | case JRet0: | 1157 | case Jret0: |
| 1158 | case JRetw: | 1158 | case Jretw: |
| 1159 | case JRetl: | 1159 | case Jretl: |
| 1160 | case JRets: | 1160 | case Jrets: |
| 1161 | case JRetd: | 1161 | case Jretd: |
| 1162 | case JRetc: | 1162 | case Jretc: |
| 1163 | fprintf(f, "\t%s", jtoa[b->jmp.type]); | 1163 | 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)) { |
| 1165 | fprintf(f, " "); | 1165 | fprintf(f, " "); |
| 1166 | printref(b->jmp.arg, fn, f); | 1166 | printref(b->jmp.arg, fn, f); |
| 1167 | } | 1167 | } |
| 1168 | if (b->jmp.type == JRetc) | 1168 | if (b->jmp.type == Jretc) |
| 1169 | fprintf(f, ", :%s", typ[fn->retty].name); | 1169 | fprintf(f, ", :%s", typ[fn->retty].name); |
| 1170 | fprintf(f, "\n"); | 1170 | fprintf(f, "\n"); |
| 1171 | break; | 1171 | break; |
| 1172 | case JJmp: | 1172 | case Jjmp: |
| 1173 | if (b->s1 != b->link) | 1173 | if (b->s1 != b->link) |
| 1174 | fprintf(f, "\tjmp @%s\n", b->s1->name); | 1174 | fprintf(f, "\tjmp @%s\n", b->s1->name); |
| 1175 | break; | 1175 | break; |
| 1176 | default: | 1176 | default: |
| 1177 | fprintf(f, "\t%s ", jtoa[b->jmp.type]); | 1177 | fprintf(f, "\t%s ", jtoa[b->jmp.type]); |
| 1178 | if (b->jmp.type == JJnz) { | 1178 | if (b->jmp.type == Jjnz) { |
| 1179 | printref(b->jmp.arg, fn, f); | 1179 | printref(b->jmp.arg, fn, f); |
| 1180 | fprintf(f, ", "); | 1180 | fprintf(f, ", "); |
| 1181 | } | 1181 | } |