Mercurial > hg > CbC > old > device
changeset 577:7e0076617c76
env switch continue..
author | kono |
---|---|
date | Sun, 15 Jan 2006 18:28:39 +0900 |
parents | 00e5ce0e341a |
children | dbde3b869a0f |
files | .gdbinit Changes mc-code-mips.c mc-code-powerpc.c mc-code.h mc-codegen.c |
diffstat | 6 files changed, 84 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Sun Jan 15 12:03:37 2006 +0900 +++ b/.gdbinit Sun Jan 15 18:28:39 2006 +0900 @@ -54,4 +54,5 @@ # run -s test/putenemy.c # run -s test/func_conv_err.c # run -DINLINE=inline test/tmp7.c -run -DINLINE=inline test/code-gen-all.c +# run -DINLINE=inline test/code-gen-all.c +run -s throw.c
--- a/Changes Sun Jan 15 12:03:37 2006 +0900 +++ b/Changes Sun Jan 15 18:28:39 2006 +0900 @@ -8361,6 +8361,18 @@ PowerPC 版だけか。ということは、PowerPC 版の R1SAVE を解消することから始めないとだめなみたい。 - - - +基本的に、stack pointer は、save しておくか、frame +pointer から計算すれば良いらしい。どうして、R1SAVE +することにしたのかは不明。 + +Sun Jan 15 16:06:29 JST 2006 + +code_fix_frame_pointer って何をやっているのだろう? +arm/mips では、何もしてない。powerpc,ia32 でも、 +消去できるのでは? + +でさ、env をさっさと計算して get_register_var に入れてしまう +のが良いと思う。で、INDIRECT+offset にして代入すれば良い。 + + +
--- a/mc-code-mips.c Sun Jan 15 12:03:37 2006 +0900 +++ b/mc-code-mips.c Sun Jan 15 18:28:39 2006 +0900 @@ -2297,10 +2297,6 @@ void code_fix_frame_pointer(int offset) { -#if 0 - printf("\tla $fp,"); - printf("%d+$L_%d($sp)\n",FUNC_LVAR(0),lvar_offset_label); -#endif } // MIPS $25 (=$jp) contains calling function address.
--- a/mc-code-powerpc.c Sun Jan 15 12:03:37 2006 +0900 +++ b/mc-code-powerpc.c Sun Jan 15 18:28:39 2006 +0900 @@ -83,8 +83,8 @@ static int lreg_sp; /* longlong REGister Stack-Pointer */ static int lreg_stack[MAX_MAX]; /* 実際のレジスタの領域 */ -#define REG_fp 1 -#define REG_sp 30 +#define REG_sp 1 +#define REG_fp 30 #define REG_VAR_BASE 29 #define REG_VAR_MIN 18 #define MIN_TMP_REG 3 @@ -322,6 +322,8 @@ // int r1_offsetv = -disp+max_func_args*SIZE_OF_INT-reg_save+r1_offset; int r1_offsetv = lvar_offsetv-reg_save+12; printf(".set L_%d,%d\n",lvar_offset_label,r1_offsetv-lvar_offsetv); + if (r1_offsetv-lvar_offsetv > 65000) error(-1); + // too large function arguments? printf(".set L_%d,%d\n",r1_offset_label,r1_offsetv); if (max_func_arg_label) { printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24); @@ -1395,7 +1397,7 @@ printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,retcont,code_base,crn); } -#define R1SAVE 1 +#define R1SAVE 0 void code_environment(int creg) { @@ -1404,9 +1406,10 @@ #if R1SAVE printf("\tlwz %s,0(r1)\n",register_name(creg)); #else - int l = 0; - printf("\tla %s,",register_name(creg)); - printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label); + printf("\tmr %s,r30\n",register_name(creg)); +// int l = 0; +// printf("\tla %s,",register_name(creg)); +// printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label); #endif } @@ -2274,6 +2277,11 @@ #endif } +int +code_frame_pointer_register() +{ + return list2(REGISTER,REG_fp); +} void code_fix_frame_pointer(int disp_offset) { @@ -2888,7 +2896,11 @@ void leave(int control, char *name) { +#if R1SAVE int retcont1=0,sz; +#else + int sz; +#endif if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3; reg_save = reg_save_offset(); @@ -2898,13 +2910,16 @@ } if (retcont) { if (control) jmp(retlabel); +#if R1SAVE retcont1 = fwdlabel(); +#endif fwddef(retcont); if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) { printf("\tfmr f1,f31\n"); } else if (cadr(fnptr->ty)>0&&( car(cadr(fnptr->ty))==STRUCT || car(cadr(fnptr->ty))==UNION)) { + // test routine? sz = size(cadr(fnptr->ty)); printf("\tli r7,%d\n",sz); printf("\tsubl r6,r7,r30\n"); @@ -2913,17 +2928,23 @@ } else if (cadr(fnptr->ty)!=VOID) { printf("\tmr r3,r29\n"); } -#if !R1SAVE - printf("\tla r1,lo16(%d)(r30)\n", - -reg_save+my_func_args*SIZE_OF_INT); +#if R1SAVE + // printf("\tb L_%d\n",retcont1); + jmp(retcont1); +#else +// printf("\tla r1,lo16(%d)(r30)\n", +// -reg_save+my_func_args*SIZE_OF_INT); #endif - printf("\tb L_%d\n",retcont1); } fwddef(retlabel); +#if R1SAVE printf("\tlwz r1,0(r1)\n"); if (retcont) { fwddef(retcont1); } +#else + printf("\taddi r1,r30,lo16(L_%d)\n",lvar_offset_label); +#endif if (max_freg_var>=0) { printf("\tlmw r%d,%d(r1)\n", REG_VAR_BASE-max_reg_var,reg_save);
--- a/mc-code.h Sun Jan 15 12:03:37 2006 +0900 +++ b/mc-code.h Sun Jan 15 18:28:39 2006 +0900 @@ -99,6 +99,7 @@ extern void emit_copy(int from,int to,int length,int offset,int value,int det); extern int function(int e1); extern void code_frame_pointer(int e3); +extern int code_frame_pointer_register(); extern void code_fix_frame_pointer(int disp_offset); extern void code_jmp(char *s); extern void code_indirect_jmp(int e2);
--- 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); }