Mercurial > hg > CbC > old > device
diff mc-nop-386.c @ 53:64a4e3789fd2 parallel-assign
parallel assign works.
author | kono |
---|---|
date | Tue, 18 Feb 2003 20:14:19 +0900 |
parents | ddaa1aa5b49b |
children | 1a6b6a7bdca6 |
line wrap: on
line diff
--- a/mc-nop-386.c Mon Feb 17 13:06:18 2003 +0900 +++ b/mc-nop-386.c Tue Feb 18 20:14:19 2003 +0900 @@ -34,7 +34,6 @@ static int edx_setup() ; static int lvar(int l); -static int cvar(int l); static void jump(int e1, int env); static void data_mode(char *name); static void text_mode(void); @@ -86,26 +85,28 @@ static int func_disp_label; /* - -16 local2 - -12 local1 - -8 arg1 - -4 arg2 - 0 arg3 - 0 (%edi) - local1 <----14 local variable 0 (%esi) + -16 -8 local2 + -12 -4 local1 + -8 8 arg3 + -4 4 arg2 + 0 0 arg1 + local2 -20 4 0 (%edi) + local1 <-- -16 0 local variable 0 (%esi) %edi -12 <- disp_offset %ebp %esi -8 %ebx -4 %ebp = %esp 0 %eip 4 <- arg_offset - arg1 8 + arg1 8 0 + arg2 12 4 see enter/enter1/leave see code_enter */ int arg_offset = 8; -int code_arg_offset = -4; int disp_offset = -12; int func_disp_offset = -12; -int code_disp_offset = -4; +int code_disp_offset = 0; +int jump_offset = 0; + int size_of_int = 4; int endian = 0; int MAX_REGISTER=6; /* intel386のレジスタを4つまで使う*/ @@ -1106,7 +1107,7 @@ return list2(assign_expr0(t,e1,ty,ty),e1); } else { disp-=sz; - g_expr(assign_expr0((e1=list2(LVAR,cvar(disp))),s,ty,ty)); + g_expr(assign_expr0((e1=list2(LVAR,disp)),s,ty,ty)); return list2(assign_expr0(t,e1,ty,ty),-1); } } @@ -1214,16 +1215,15 @@ int processing = 0; /* まず、サイズを計算しながら、決まった形に落す。 */ - /* ここで、書込先アドレスを決める */ arg_size = 0; regs = 0; max_regs = MAX_REGISTER_VAR-1; for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) { e2 = car(e3); sz = size(ty=caddr(e3)); - if (regs <= max_regs&&integral(ty)) { + if (regs <= max_regs&&scalar(ty)) { target=list4(list2(REGISTER,virtual((regs++)+REG_ESI)), target,ty,e2); } else { - target=list4(list2(LVAR,cvar(arg_size)), + target=list4(list2(LVAR,0), target,ty,e2); arg_size += sz; } @@ -1235,8 +1235,10 @@ /* disp を飛び先似合わせて修正 */ if (fnptr->sc==CODE) { if (-arg_size<disp) disp = -arg_size; + jump_offset = 0; } else { if (disp_offset-arg_size<disp) disp = disp_offset-arg_size; + jump_offset = 0; } /* 複雑な式を前もって計算しておく */ @@ -1246,9 +1248,14 @@ for (e2 = target; e2; e2 = cadr(e2)) { t0=car(e2); s0=cadddr(e2); sz=size(ty=caddr(e2)); + if(car(t0)==LVAR) { + /* ここで、書込先アドレスを決める */ + cadr(t0)=-arg_size+jump_offset; + arg_size-=sz; + } if (!is_simple(car(s0))) { disp-=sz; - g_expr(assign_expr0((e4=list2(LVAR,cvar(disp))),s0,ty,ty)); + g_expr(assign_expr0((e4=list2(LVAR,disp)),s0,ty,ty)); cadddr(e2)=e4; s0=e4; } else if (is_same_type(t0,s0)) { @@ -1868,18 +1875,14 @@ { code_disp_label=fwdlabel(); printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label); - /* - if(disp0) { - printf("\tsubl $%d,%%esp\n",disp0); - } - */ + printf("## args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset); } void code_leave(char *name) { - printf("\t.set _%d,%d\n",code_disp_label,cvar(disp)); + printf("\t.set _%d,%d\n",code_disp_label,disp+code_disp_offset); printf("_%d:\n",labelno); printf("\t.size\t%s,_%d-%s\n",name,labelno,name); local_table(); @@ -2086,7 +2089,7 @@ lvar(int l) { if (fnptr->sc==CODE) { - return (l<0)? l+code_disp_offset: -l+code_arg_offset; + return l+code_disp_offset; } else if (l<0) { return l+disp_offset; } else { @@ -2094,10 +2097,5 @@ } } -int -cvar(int l) -{ - return (fnptr->sc==CODE)?l:l+disp_offset; -} /* end */