Mercurial > hg > CbC > old > device
diff mc-codegen.c @ 577:7e0076617c76
env switch continue..
author | kono |
---|---|
date | Sun, 15 Jan 2006 18:28:39 +0900 |
parents | 00e5ce0e341a |
children | dbde3b869a0f |
line wrap: on
line diff
--- a/mc-codegen.c Sun Jan 15 12:03:37 2006 +0900 +++ b/mc-codegen.c Sun Jan 15 18:28:39 2006 +0900 @@ -710,7 +710,7 @@ case RLVAR: code_cmp_rlvar(e2,USE_CREG,l1,cond); return l1; -#if FLOATC_DOE +#if 0 && FLOAT_CODE case DRLVAR: code_cmp_drlvar(e2,USE_CREG,1,l1,cond); return l1; @@ -733,22 +733,22 @@ case FCONST: if(control&&((dcadr(e2)!=0.0)^cond)) { gen_jmp(l1); return l1; - else return 0; + } else return 0; #endif -#if LONGLONG_DOE +#if 0 && LONGLONG_CODE case LRLVAR: - code_cmp_lrlvar(e2,1,l1,cond); + code_cmp_lrlvar(e2,USE_CREG,l1,cond); return l1; case LRGVAR: - code_cmp_lrgvar(e2,1,l1,cond); + code_cmp_lrgvar(e2,USE_CREG,l1,cond); return l1; case LREGISTER: - code_cmp_lregister(e2,1,l1,cond); + code_cmp_lregister(e2,l1,cond); return l1; case LCONST: if(control&&((lcadr(e2)!=0)^cond)) { gen_jmp(l1); return l1; - else return 0; + } else return 0; #endif case REGISTER: code_cmp_register(e2,l1,cond); @@ -1361,9 +1361,15 @@ int target = 0; int processing = 0; int use = 0; + int envreg = 0; /* e1 = list4(FUNCTION,code_segment,arglist,ftype); */ + if (env) { + envreg = get_register_var(0); + g_expr_u(assign_expr0(envreg,env,INT,INT)); + } + /* まず、サイズを計算しながら、target を決まった形に落す。 */ /* list5(target,next,ty,source,source_dependency) */ @@ -1379,6 +1385,13 @@ target=list5(r, target,ty,e2,0); fregs++; } else if ((ty==LONGLONG||ty==ULONGLONG) && (r = get_input_lregister_var(fregs,0,1))) { target=list5(r, target,ty,e2,0); regs+=2; + } else if (env) { + while(car(e2)==RSTRUCT) e2=cadr(e2); + g_expr_u(assign_expr0( + list2(INDIRECT, + list3(ADD,rvalue_t(envreg,INT),list2(CONST,-arg_size-sz)) + ), + e2,ty,ty)); } else { while(car(e2)==RSTRUCT) e2=cadr(e2); target=list5(list3(LVAR,0,0), target,ty,e2,0); @@ -1389,6 +1402,11 @@ printf("## target %d ty %d+%d sz %d\n",car(car(target)),ty,cadr(car(target)),sz); #endif } + if (env) { + /* change the frame pointer during parallel assignment */ + target=list5(code_frame_pointer_register(), target,INT,rvalue_t(envreg,INT),0); + } + /* disp を飛び先似合わせて修正 */ if (is_code(fnptr)) { @@ -1406,6 +1424,7 @@ sz=size(ty=caddr(e2)); if(car(t0)==LVAR) { /* ここで、書込先アドレスを決める */ + if (envreg) error(-1); cadr(t0)=-arg_size; } arg_size-=sz; @@ -1484,10 +1503,6 @@ g_expr(e2); emit_push(); } - if (env) { - g_expr(env); - emit_push(); - } /* 並列代入を実行 */ parallel_assign(&target,&processing,&use); @@ -1500,27 +1515,20 @@ use=cadr(use); } if(target) error(-1); - - if (env) { - /* change the frame pointer */ - e3 = emit_pop(0); - code_frame_pointer(e3); - emit_pop_free(e3); - } else if (is_function(fnptr)) { - if (car(e2) != FNAME) { - e2 = emit_pop(0); - code_fix_frame_pointer(disp_offset); - code_indirect_jmp(e2); - emit_pop_free(e2); - return; - } - code_fix_frame_pointer(disp_offset); - } + if(env) { + if (car(envreg)==REGISTER) + free_register(cadr(envreg)); + else free_lvar(cadr(envreg)); + } if (car(e2) == FNAME) { + if (is_function(fnptr)) + code_fix_frame_pointer(disp_offset); code_jmp(code0->nm); } else { e2 = emit_pop(0); + if (is_function(fnptr)) + code_fix_frame_pointer(disp_offset); code_indirect_jmp(e2); emit_pop_free(e2); }