Mercurial > hg > CbC > old > device
changeset 254:5aaca4f9d96b
*** empty log message ***
author | kono |
---|---|
date | Wed, 12 May 2004 21:44:45 +0900 |
parents | 7b2762739df6 |
children | 8cd8d72286ae |
files | Changes mc-code-ia32.c mc-code-mips.c mc-code.h mc.h |
diffstat | 5 files changed, 45 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Wed May 12 19:48:42 2004 +0900 +++ b/Changes Wed May 12 21:44:45 2004 +0900 @@ -4177,3 +4177,15 @@ だとすれば、code segement 側でstackを頻繁に移動するのはまずい? float/double のフローは mc-parse では、少し、齟齬があるみたい。 + +は、良いとして.... + + cprestore, mask の計算 + offset の合わせ + +が終れば動くの? それだけ? + +あぁ、 + int endian; + extern int endian; +も通す必要があるのね。まぁ、フラグの扱いだけだけど....
--- a/mc-code-ia32.c Wed May 12 19:48:42 2004 +0900 +++ b/mc-code-ia32.c Wed May 12 21:44:45 2004 +0900 @@ -24,12 +24,12 @@ #define SIZE_OF_LONGLONG 8 #define ENDIAN 0 -int size_of_int; -int size_of_short; -int size_of_float; -int size_of_double; -int size_of_longlong; -int endian; +int size_of_int = SIZE_OF_INT; +int size_of_short = SIZE_OF_SHORT; +int size_of_float = SIZE_OF_FLOAT; +int size_of_double = SIZE_OF_DOUBLE; +int size_of_longlong = SIZE_OF_LONGLONG; +int endian = ENDIAN; #define SAVE_STACKS 1 @@ -230,12 +230,6 @@ arg_offset = 8; // func_disp_offset = -12; disp_offset = -12; - size_of_int = SIZE_OF_INT; - size_of_short = SIZE_OF_SHORT; - size_of_float = SIZE_OF_FLOAT; - size_of_double = SIZE_OF_DOUBLE; - size_of_longlong = SIZE_OF_LONGLONG; - endian = ENDIAN; MAX_REGISTER=6; MAX_DATA_REG=4; MAX_POINTER=3;
--- a/mc-code-mips.c Wed May 12 19:48:42 2004 +0900 +++ b/mc-code-mips.c Wed May 12 21:44:45 2004 +0900 @@ -878,7 +878,7 @@ emit_init(void) { free_all_register(); - max_reg_var=-1; max_freg_var=-1; + max_reg_var=0; max_freg_var=0; reg_sp = 0; freg_sp = 0; text_mode(); @@ -2519,18 +2519,20 @@ } +#define round16(i) ((i+0xf)&~0xf) void leave(int control, char *name) { int retcont1=0,sz; int r1_offsetv; int lvar_offsetv; - - if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3; + int nireg,nfreg; + + // if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3; reg_save = - (REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*size_of_int; + (REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*SIZE_OF_INT; freg_save = - (REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*size_of_float; + (REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*SIZE_OF_FLOAT; if (control) { code_set_return_register(1); @@ -2552,7 +2554,7 @@ sz = size(cadr(fnptr->ty)); printf("\tli $4,%d\n",sz); printf("\tsubl $5,$4,$fp\n"); - printf("\tlw $3,(%d)($fp)\n",(my_func_args-1)*size_of_int); + printf("\tlw $3,(%d)($fp)\n",(my_func_args-1)*SIZE_OF_INT); emit_copy(6,3,sz,0,1,1); } else if (cadr(fnptr->ty)!=VOID) { if (creg!=RET_REGISTER) @@ -2577,7 +2579,7 @@ fprintf(asi,"$L_%d=%d\n",cprestore_label ,max_func_iargs); #endif - disp &= -size_of_int; + disp &= -SIZE_OF_INT; r1_offsetv = disp; printf(".set L_%d,%d\n",r1_offset_label,r1_offsetv); printf(".set L_%d,%d\n",lvar_offset_label,lvar_offsetv); @@ -2592,7 +2594,14 @@ printf("\t.align 2\n"); printf("%s:\n",name); - printf("\t.frame $fp,%d,$31\n",0); + printf("\t.frame $fp,%d,$31\t",0); +printf("# vars= %d, regs= %d/%d, args= %d, extra= %d\n", + round16(-disp), + max_reg_var+2, + max_freg_var, + round16(max_func_args*SIZE_OF_INT), + 0 +); printf("\t.mask 0x%x,%d\n",code_mask(),0); printf("\t.fmask 0x%x,%d\n",code_fmask(),0); @@ -2600,7 +2609,7 @@ printf("\t.cpload $25\n"); printf("\t.set reorder\n"); printf("\tsubu $sp,$sp,$L_%d\n",-r1_offsetv); - printf("\t.cprestore %d\n",max_func_iargs); + printf("\t.cprestore %d\n",max_func_args*SIZE_OF_INT); code_register_save(reg_save,freg_save,disp); printf("\tj $L_%d\n",code_top_label);
--- a/mc-code.h Wed May 12 19:48:42 2004 +0900 +++ b/mc-code.h Wed May 12 21:44:45 2004 +0900 @@ -15,6 +15,7 @@ extern int size_of_double; extern int size_of_longlong; extern int endian; + extern int MAX_REGISTER; extern int MAX_REGISTGER_VAR; extern int MAX_FREGISTER;
--- a/mc.h Wed May 12 19:48:42 2004 +0900 +++ b/mc.h Wed May 12 21:44:45 2004 +0900 @@ -13,8 +13,6 @@ #define FLOAT_CODE 1 #define LONGLONG_CODE 1 -#define SIZE_INT 4 - /* reserved word start */ #define INT (-1) @@ -421,12 +419,18 @@ EXTERN int chptrsave; EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr; EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void); -EXTERN int arg_offset,stat_no,size_of_int,size_of_short,disp_offset,endian,csvalue1; +EXTERN int arg_offset,stat_no,disp_offset,csvalue1; EXTERN int code_arg_offset; -EXTERN int size_of_double,size_of_float,size_of_longlong; EXTERN int retlabel,retpending,retcont; EXTERN int arglist; +extern int size_of_int; +extern int size_of_short; +extern int size_of_float; +extern int size_of_double; +extern int size_of_longlong; +extern int endian; + EXTERN FILE *obuf; #if 1