# HG changeset patch # User kono # Date 1137566444 -32400 # Node ID c991b82e6849c2b4cc50092e9e91ca82192446c0 # Parent 3fb4081164bd1dece301d04d3d93cbbe5aa7afe6 *** empty log message *** diff -r 3fb4081164bd -r c991b82e6849 Changes --- a/Changes Wed Jan 18 13:36:50 2006 +0900 +++ b/Changes Wed Jan 18 15:40:44 2006 +0900 @@ -8527,4 +8527,7 @@ 他のも、これにする方が正しそう。 - +Wed Jan 18 14:47:39 JST 2006 + +register の順序を変えると動かなくなるってのは、コードの信頼性が +低いってことなんだよな.... diff -r 3fb4081164bd -r c991b82e6849 mc-code-ia32.c --- a/mc-code-ia32.c Wed Jan 18 13:36:50 2006 +0900 +++ b/mc-code-ia32.c Wed Jan 18 15:40:44 2006 +0900 @@ -270,13 +270,13 @@ #define REG_EAX 1 #define REG_EBX 2 -#define REG_ECX 3 +#define REG_ECX 3 // for strange reason (code_assop) #define REG_EDX 4 #define REG_ESI 5 #define REG_EDI 6 #define REG_EBP 7 #define REG_ESP 8 -#define is_int_reg(reg) (REG_EAX<=reg&®nm); } else { - printf("\tcall\t*%s\n",register_name(creg,0)); + printf("\tcall\t*%s\n",register_name(REG_EAX,0)); } if (nargs) printf("\taddl $%d,%%esp\n",SIZE_OF_INT*nargs); if (ret_type==DOUBLE||ret_type==FLOAT) { @@ -1401,7 +1408,10 @@ use_longlong0(USE_CREG); } else if (ret_type==VOID) { } else { - set_ireg(RET_REGISTER,0); + if (use) + set_ireg(RET_REGISTER,0); + else + set_ireg(CREG_REGISTER,0); } stack_depth = stack_depth_save; return ret_type; @@ -1559,7 +1569,8 @@ void code_assop(int op,int creg,int byte,int sign) { int xreg; - // (*creg) op = pop() + // (*pop()) op = creg + // creg should be ecx use_int(creg); xreg = emit_pop(0); /* pop e3 value */ @@ -1933,11 +1944,12 @@ car(cadr(fnptr->ty))==STRUCT || car(cadr(fnptr->ty))==UNION)) { sz = size(cadr(fnptr->ty)); + set_ireg(RET_REGISTER,0); printf("\tmovl %d(%%ebp),%s\n",disp-SIZE_OF_INT, register_name(creg,0)); // emit_copy(dreg,creg,sz,0,1,1); } else if (cadr(fnptr->ty)!=VOID) { - use_register(creg,REG_EAX,0); + set_ireg(RET_REGISTER,0); printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0)); } } @@ -3257,7 +3269,7 @@ use_longlong(reg); printf("\taddl $%d,%%esi\n",dir); printf("\tadcl $%d,%%edi\n",dir>0?0:-1); - if (reg!=REG_L) { + if (use && reg!=REG_L) { code_lregister(REG_L,reg); } return; @@ -3277,7 +3289,7 @@ char *crn; if (car(e2)==LREGISTER) { use_longlong(reg); - if (reg!=REG_L) { + if (use && reg!=REG_L) { code_lregister(REG_L,reg); } printf("\taddl $%d,%%esi\n",dir); @@ -3288,10 +3300,12 @@ crn = register_name(creg0=creg,0); printf("\taddl $%d,(%s)\n",dir,crn); printf("\tadcl $%d,4(%s)\n",dir>0?0:-1,crn); - use_longlong(reg); - lload(creg0,0,reg); - printf("\taddl $%d,%s\n",-dir,l_eax(reg)); - printf("\tadcl $%d,%s\n",-dir>0?0:-1,l_edx(reg)); + if (use) { + use_longlong(reg); + lload(creg0,0,reg); + printf("\taddl $%d,%s\n",-dir,l_eax(reg)); + printf("\tadcl $%d,%s\n",-dir>0?0:-1,l_edx(reg)); + } } void code_lassop(int op,int reg) diff -r 3fb4081164bd -r c991b82e6849 mc-code-mips.c --- a/mc-code-mips.c Wed Jan 18 13:36:50 2006 +0900 +++ b/mc-code-mips.c Wed Jan 18 15:40:44 2006 +0900 @@ -1363,7 +1363,7 @@ use_int(reg); printf("\taddu %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)), dir); - if (cadr(e2)!=reg) + if (use && cadr(e2)!=reg) printf("\tmove %s,%s\n",register_name(reg),register_name(cadr(e2))); return; } @@ -1390,7 +1390,8 @@ int nreg; if (car(e2)==REGISTER) { use_int(reg); - printf("\tmove %s,%s\n",register_name(reg),register_name(cadr(e2))); + if (use) + printf("\tmove %s,%s\n",register_name(reg),register_name(cadr(e2))); printf("\taddu %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)),dir); return; @@ -5171,7 +5172,7 @@ if (car(e2)==LREGISTER) { use_longlong(reg); ladd(cadr(e2),cadr(e2),dir); - if (reg!=cadr(e2)) { + if (use && reg!=cadr(e2)) { lmove(reg,cadr(e2)); } return; @@ -5200,7 +5201,7 @@ int dir=caddr(e1); if (car(e2)==LREGISTER) { use_longlong(reg); - lmove(reg,cadr(e2)); + if (use) lmove(reg,cadr(e2)); ladd(cadr(e2),cadr(e2),dir); return; } diff -r 3fb4081164bd -r c991b82e6849 mc-code-powerpc.c --- a/mc-code-powerpc.c Wed Jan 18 13:36:50 2006 +0900 +++ b/mc-code-powerpc.c Wed Jan 18 15:40:44 2006 +0900 @@ -1334,7 +1334,7 @@ use_int(reg); printf("\taddi %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)), dir); - if (cadr(e2)!=reg) + if (use && cadr(e2)!=reg) printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2))); return; } @@ -1361,7 +1361,8 @@ int nreg; if (car(e2)==REGISTER) { use_int(reg); - printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2))); + if (use) + printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2))); printf("\taddi %s,%s,%d\n", register_name(cadr(e2)),register_name(cadr(e2)),dir); return; @@ -4984,7 +4985,7 @@ int dir=caddr(e1); if (car(e2)==LREGISTER) { use_longlong(reg); - if (reg!=cadr(e2)) + if (use && reg!=cadr(e2)) lmove(reg,cadr(e2)); ladd(cadr(e2),cadr(e2),dir); return; diff -r 3fb4081164bd -r c991b82e6849 mc-codegen.c --- a/mc-codegen.c Wed Jan 18 13:36:50 2006 +0900 +++ b/mc-codegen.c Wed Jan 18 15:40:44 2006 +0900 @@ -104,7 +104,7 @@ int t; int suse = use; use=0; t=g_expr0(e1); - code_gexpr(e1); + //code_gexpr(e1); use=suse; return t; @@ -118,7 +118,7 @@ int t; int suse = use; use=1; t=g_expr0(e1); - code_gexpr(e1); + //code_gexpr(e1); use=suse; return t;