repcode() { outcont(0); yyval = genlab(); outcont(yyval); brkstk[++brkptr] = yyval+1; genlab(); genlab(); }
void cgcmp(char *inst) { int lab = label(); gen("xorl\t%edx,%edx"); if (empty == Q_type) { cgpop2(); gen("cmpl\t%eax,%ecx"); } else { cgsynth("cmpl"); } lgen("%s\t%c%d", inst, lab); gen("incl\t%edx"); genlab(lab); gen("movl\t%edx,%eax"); }
void cgbrcond(char *i, int n) { int lab = label(); if (empty == Q_type) { cgpop2(); gen("cmpl\t%eax,%ecx"); } else { cgsynth("cmpl"); } lgen("%s\t%c%d", i, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); }
void cgcmp(char *inst) { int lab = label(); gen("xor\tdx,dx"); if (empty == Q_type) { cgpop2(); gen("cmp\tcx,ax"); } else { cgsynth("cmp"); } lgen("%s\t%c%d", inst, lab); gen("inc\tdx"); genlab(lab); gen("mov\tax,dx"); }
void cgcmp(char *inst) { int lab; lab = label(); gen("xorl\t%edx,%edx"); cgpop2(); gen("cmpl\t%eax,%ecx"); lgen("%s\t%c%d", inst, lab); gen("incl\t%edx"); genlab(lab); gen("movl\t%edx,%eax"); }
repcode() { transfer = 0; outcont(0); putcom("repeat"); yyval = genlab(3); indent++; outcont(yyval); brkstk[++brkptr] = yyval+1; typestk[brkptr] = REPEAT; brkused[brkptr] = 0; }
void cgbr(char *how, int n) { int lab = label(); gen("orl\t%eax,%eax"); lgen("%s\t%c%d", how, lab); lgen("%s\t%c%d", "jmp", n); genlab(lab); }
static void do_stmt(void) { int ls, lb, lc; Token = scan(); ls = label(); pushbrk(lb = label()); pushcont(lc = label()); genlab(ls); stmt(); match(WHILE, "'while'"); lparen(); genlab(lc); rexpr(); genbrtrue(ls); genlab(lb); rparen(); semi(); Bsp--; Csp--; }
static void if_stmt(void) { int l1, l2; Token = scan(); lparen(); rexpr(); clear(); rparen(); l1 = label(); genbrfalse(l1); stmt(); if (ELSE == Token) { l2 = label(); genjump(l2); genlab(l1); l1 = l2; Token = scan(); stmt(); } genlab(l1); }
void genswitch(int *vals, int *labs, int nc, int dflt) { int i, ltbl; ltbl = label(); gentext(); cgldswtch(ltbl); cgcalswtch(); genlab(ltbl); cgdefw(nc); for (i = 0; i < nc; i++) cgcase(vals[i], labs[i]); cgdefl(dflt); }
static void for_stmt(void) { int ls, lbody, lb, lc; Token = scan(); ls = label(); lbody = label(); pushbrk(lb = label()); pushcont(lc = label()); lparen(); if (Token != SEMI) { rexpr(); clear(); } semi(); genlab(ls); if (Token != SEMI) { rexpr(); clear(); genbrfalse(lb); } genjump(lbody); semi(); genlab(lc); if (Token != RPAREN) { rexpr(); clear(); } genjump(ls); rparen(); genlab(lbody); stmt(); genjump(lc); genlab(lb); Bsp--; Csp--; }
static void switch_block(void) { int lb, ls, ldflt = 0; int cval[MAXCASE]; int clab[MAXCASE]; int nc = 0; Token = scan(); pushbrk(lb = label()); ls = label(); genjump(ls); while (RBRACE != Token) { if (eofcheck()) return; if ((CASE == Token || DEFAULT == Token) && nc >= MAXCASE) { error("too many 'case's in 'switch'", NULL); nc = 0; } if (CASE == Token) { Token = scan(); cval[nc] = constexpr(); genlab(clab[nc++] = label()); colon(); } else if (DEFAULT == Token) {
void cgcmp(char *inst) { int lab; lab = label(); gen("movi(r2, 0);"); cgpop2(); gen("cmp(r1, r0);"); lgen("%s(%c%d);", inst, lab); gen("addi(r2, 1);"); genlab(lab); gen("mov(r0, r2);"); }
void cgbr(char *how, int n) { int lab; lab = label(); gen("or(r0, r0);"); lgen("%s(%c%d);", how, lab); lgen("%s(%c%d);", "b", n); genlab(lab); }