Mercurial > hg > CbC > old > device
changeset 41:886ca1f2cf15
*** empty log message ***
author | kono |
---|---|
date | Wed, 12 Feb 2003 06:10:09 +0900 |
parents | 060d1e549fec |
children | a89cf0d6904f |
files | mc-nop-386.c |
diffstat | 1 files changed, 40 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-nop-386.c Wed Feb 12 04:45:53 2003 +0900 +++ b/mc-nop-386.c Wed Feb 12 06:10:09 2003 +0900 @@ -303,9 +303,15 @@ return; real_v = virtual(real); move_op = regs[real_v]?"\txchg %s,%s\n":"\tmovl %s,%s\n"; - if (move || regs[real_v]) { +#ifdef REGFLOW + if (move || (regv[real_v])) { printf(move_op,reg_name[rname[virt]],reg_name[real]); } +#else + if (move || (regs[real_v])) { + printf(move_op,reg_name[rname[virt]],reg_name[real]); + } +#endif rname[real_v] = rname[virt]; rname[virt] = real; } @@ -356,6 +362,7 @@ free_register(i); lreg = i; regs[i]=0; + regv[i]=1; return lreg; } } @@ -377,6 +384,7 @@ reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */ creg = new_reg; } + regv[creg]=0; } int @@ -393,6 +401,7 @@ } else { xreg = lreg; } + regv[xreg]=1; return xreg; } @@ -403,6 +412,7 @@ for(i=REG_ESI;i<REG_ESP;i++) { if (! regs[i]) { /* 使われていないなら */ regs[i]=1; /* そのレジスタを使うことを宣言し */ + regv[i]=0; return i; /* その場所を表す番号を返す */ } } @@ -523,9 +533,10 @@ g_expr(e2); emit_push(); /* in case of register full we should copy creg to dreg */ - xrn = register_name(emit_pop(0),0); + xrn = register_name((e2=emit_pop(0)),0); printf("\tmovl (%s),%s\n",xrn,register_name(creg,0)); printf("\taddl $%d,(%s)\n",caddr(e1),xrn); + regv[e2]=0; return; case CPOSTINC: /* char *p; *p++ */ @@ -536,9 +547,10 @@ } g_expr(e2); emit_push(); /* in case of register full we should copy creg to dreg */ - xrn = register_name(emit_pop(0),1); + xrn = register_name((e2=emit_pop(0)),1); printf("\tmovsbl (%s),%s\n",xrn,register_name(creg,0)); printf("\tincl (%s)\n",xrn); + regv[e2]=0; return; case CPREINC: if (car(e2)==REGISTER) { @@ -571,6 +583,7 @@ e2 = emit_pop(0); printf("\tdecl (%s)\n",register_name(e2,0)); printf("\tmovsbl (%s),%s\n",register_name(e2,0),register_name(creg,0)); + regv[e2]=0; return; case MUL: case UMUL: case DIV: case UDIV: @@ -813,6 +826,7 @@ if(creg!=to) { free_register(creg); creg=to; } + regv[from]=regv[to]=regv[dreg]=0; } int @@ -843,11 +857,13 @@ xreg = get_register(); } printf("\tmovl %%esp,%s\n",register_name(xreg,0)); + regv[xreg]=1; emit_copy(creg,xreg,length,0); if (save) { printf("\tpopl %s\n",register_name(lreg,0)); } else free_register(xreg); + regv[xreg]=0; return length/size_of_int; } @@ -865,6 +881,7 @@ save = get_register(); saved = 0; } + regv[save]=0; e2 = cadr(e1); nargs = 0; for (e3 = caddr(e1); e3; e3 = cadr(e3)) { @@ -900,13 +917,12 @@ } /* we don't have to save creg nor dreg */ - regs[creg]=0; - regs[dreg]=0; + regs[creg]=0; regs[dreg]=0; + regv[creg]= regv[dreg]= regv[save]= 0; use_register(creg,REG_EAX,0); use_register(dreg,REG_EDX,0); /* will be destroyed */ use_register(save,REG_ECX,0); /* will be destroyed */ - regs[creg]=1; - regs[dreg]=1; + regs[creg]=1; regs[dreg]=1; if (car(e2) == FNAME) { printf("\tcall\t%s\n",n->nm); @@ -919,6 +935,8 @@ } else { free_register(save); } + regv[save]=0; + regv[creg]=1; } int @@ -1161,6 +1179,7 @@ g_expr(e2); xreg = emit_pop(0); emit_copy(xreg,creg,sz,0); + regv[xreg]=0; return; } @@ -1199,6 +1218,7 @@ if (byte) use_data_reg(creg,1); e2 = emit_pop(0); printf("\t%s %s,(%s)\n",op,register_name(creg,byte),register_name(e2,0)); + regv[e2]=0; return; } @@ -1238,10 +1258,12 @@ } else { reg_stack[reg_sp++] = xreg; /* push するかわりにレジスタを使う */ } + regv[xreg]=0; tosop(op); if(new_reg>=0) free_register(new_reg); printf("\tpopl %s # assop \n",register_name(dreg,0)); printf("\t%s %s,(%s)\n",byte ? "movb" : "movl",register_name(creg,byte),register_name(dreg,0)); + regv[dreg]=0; return; } @@ -1269,30 +1291,31 @@ if(oreg==-1) { printf("\tpopl %s\n",register_name(dreg,0)); oreg = dreg; + regv[oreg]=1; } orn = register_name(oreg,0); crn = register_name(creg,0); switch(op) { case ADD: printf("\taddl %s,%s\n",orn,crn); - return; + break; case SUB: printf("\tsubl %s,%s\n",orn,crn); - return; + break; case BAND: printf("\tandl %s,%s\n",orn,crn); - return; + break; case EOR: printf("\txorl %s,%s\n",orn,crn); - return; + break; case BOR: printf("\torl %s,%s\n",orn,crn); - return; + break; case MUL: case UMUL: /* use_register(dreg,REG_EDX,0); */ printf("\t%s %s,%s\n","imull",orn,crn); - return; + break; case DIV: case UDIV: orn = div_setup(oreg); @@ -1301,7 +1324,7 @@ else printf("\txor %%edx,%%edx\n\tidivl %s\n",orn); div_cleanup(orn); - return; + break; case MOD: case UMOD: orn = div_setup(oreg); @@ -1312,8 +1335,10 @@ rname[creg]=REG_EDX; rname[dreg]=REG_EAX; div_cleanup(orn); - return; + break; } + if (oreg>=0) regv[oreg]=0; + regv[dreg]=0; } static char *dvi_push = "(%esp)";