# HG changeset patch # User kono # Date 1134999732 -32400 # Node ID 79fef53141b4cf8016182c9ab5f445e6de9c4c95 # Parent 62f3c801b6ac5b3285950a1875b55509189cd49d fix clear_ptr_cache in MIPS/ARM. diff -r 62f3c801b6ac -r 79fef53141b4 .gdbinit --- a/.gdbinit Sat Dec 17 10:32:34 2005 +0900 +++ b/.gdbinit Mon Dec 19 22:42:12 2005 +0900 @@ -32,7 +32,7 @@ b errmsg tb main # run -s test/inline.c -run -s mc-parse.c +# run -s mc-parse.c # run -s mc-codegen.c # run -s nkf203/nkf.c # run -s -ob01.s mc-switch.c @@ -41,4 +41,4 @@ # run -s test/basic.c # run -s test/code-gen-all.c # run -s test/tmp7.c -# run -s test/inline.c +run -s test/inline.c diff -r 62f3c801b6ac -r 79fef53141b4 Changes --- a/Changes Sat Dec 17 10:32:34 2005 +0900 +++ b/Changes Mon Dec 19 22:42:12 2005 +0900 @@ -7422,3 +7422,23 @@ correct_type のエラーかぁ。 +Sat Dec 17 13:45:17 JST 2005 + +function() が複雑すぎ。codegen の方に共通部分を収納した方が良くない? +可能だとは思うが、難しいね。IA32 の方が古すぎる。 + +さすがに4つも書いたので共通化できるはずだが。 + +そういえば、mc-tree も動かなくなってるんだよな。 + +gen_inline で vartable を使っているけど、enter_scope でいい +んじゃないの? 新しい変数を使うときは、new_lvar すれば良いし。 +同じ変数名で置き換えをするときがちょっと気まずいか。いや、macro_ +function と同じで、既に値は計算してあるんだろ? っていうか計 +算してからdef & assignするわけだよね。def しないといけない +ところがあれだが... def する方が整合性は高いが、その必要は +ないはず。ということは、enter_scope でいいのかな。getsym +しないから、だめか。 + + + diff -r 62f3c801b6ac -r 79fef53141b4 mc-code-arm.c --- a/mc-code-arm.c Sat Dec 17 10:32:34 2005 +0900 +++ b/mc-code-arm.c Mon Dec 19 22:42:12 2005 +0900 @@ -2403,14 +2403,6 @@ if(scalar(t)) { nargs ++ ; reg_arg++; } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) { -#if 0 - if (*preg_arg>3 && *preg_arg%2==1) reg_arg++; // alignment - if (*preg_arg>3 && *pnargs%2==1) nargs++; // alignment - if (*preg_arg==3) { - // half register, half stack case - nargs --; - } -#endif nargs ++ ; reg_arg++; nargs ++ ; reg_arg++; } else if (t==FLOAT) { @@ -2500,23 +2492,8 @@ int half_register = 0; special_lvar = -1; -#if 0 - ret_type = cadr(cadddr(e1)); - if (ret_type==CHAR) ret_type=INT; // ??? - - /* check argments type is DOTS? */ - t = caddr(cadddr(e1)); - if (t==0 || t==DOTS) dots = 1; - else { - dots = 0; - for(t = caddr(cadddr(e1));t;t = cadr(t)) { - if (car(t)==DOTS) dots = 1; - } - } -#else ret_type = function_type(cadddr(e1),&dots); if (caddr(cadddr(e1))==0) dots=1; -#endif arg_assign = 0; e2 = cadr(e1); @@ -3361,6 +3338,7 @@ printf("%s:\n",name); code_label_value(r1_offset_label,REG_ip); printf("\tadd\tsp, ip, fp\n"); + clear_ptr_cache(); } @@ -3399,6 +3377,7 @@ printf("\tmov\tip, sp\n"); gen_jmp(entry_label = fwdlabel()); register_save_return_label = backdef(); + clear_ptr_cache(); } void diff -r 62f3c801b6ac -r 79fef53141b4 mc-code-mips.c --- a/mc-code-mips.c Sat Dec 17 10:32:34 2005 +0900 +++ b/mc-code-mips.c Mon Dec 19 22:42:12 2005 +0900 @@ -2083,23 +2083,8 @@ int stargs; special_lvar = -1; -#if 0 - ret_type = cadr(cadddr(e1)); - if (ret_type==CHAR) ret_type=INT; // ??? - - /* check argments type is DOTS? */ - t = caddr(cadddr(e1)); - if (t==0 || t==DOTS) dots = 1; - else { - dots = 0; - for(t = caddr(cadddr(e1));t;t = cadr(t)) { - if (car(t)==DOTS) dots = 1; - } - } -#else ret_type = function_type(cadddr(e1),&dots); if (caddr(cadddr(e1))==0) dots=1; -#endif arg_assign = 0; e2 = cadr(e1); @@ -3011,6 +2996,7 @@ // printf("\tmove $fp,$sp\n"); lvar_offset_label = fwdlabel(); max_func_args = 0; + clear_ptr_cache(); } @@ -3062,6 +3048,7 @@ printf("\tj $L_%d\n",register_save_label=fwdlabel()); register_save_return_label = backdef(); printf("\tsubu $fp,$13,$L_%d\n",lvar_offset_label); + clear_ptr_cache(); } void diff -r 62f3c801b6ac -r 79fef53141b4 mc-code-powerpc.c --- a/mc-code-powerpc.c Sat Dec 17 10:32:34 2005 +0900 +++ b/mc-code-powerpc.c Mon Dec 19 22:42:12 2005 +0900 @@ -2719,6 +2719,7 @@ fwddef(code_base); printf("\tmflr r31\n"); max_func_args = 0; + clear_ptr_cache(); } @@ -2778,6 +2779,7 @@ #endif printf("\tmflr r31\n"); max_func_args = 0; + clear_ptr_cache(); } void diff -r 62f3c801b6ac -r 79fef53141b4 mc-codegen.c --- a/mc-codegen.c Sat Dec 17 10:32:34 2005 +0900 +++ b/mc-codegen.c Mon Dec 19 22:42:12 2005 +0900 @@ -3378,8 +3378,12 @@ if (ind) e = indop(rvalue(e)); type0 = type_value(type); - if (integral(type0)||(car(type0)!=STRUCT && car(type0)!=UNION)) - e=rvalue(e); + if (integral(type0)||(car(type0)!=STRUCT && car(type0)!=UNION)) { + e=rvalue(e); type0 = type_value(type); + } + if ((car(type0)!=STRUCT && car(type0)!=UNION)) { + error(TYERR); type=INT; return e; + } /* type = list4(s,disp,fields,tag_nptr); */ /* print_fields(caddr(type),"strop"); */ type = search_struct_type(type,nptr->nm,&dsp); diff -r 62f3c801b6ac -r 79fef53141b4 mc-parse.c --- a/mc-parse.c Sat Dec 17 10:32:34 2005 +0900 +++ b/mc-parse.c Mon Dec 19 22:42:12 2005 +0900 @@ -1293,9 +1293,10 @@ int mode_save=mode; NMTBL *nptr0; int sz= size(type); + int type0=type_value(type); decl_str_init = 0; - if(cadr(type)==-1) { + if(cadr(type0)==-1) { error(DCERR); return; } @@ -1317,7 +1318,7 @@ return; } mode=SFDINIT; - t1 = caddr(type); /* list of fields */ + t1 = caddr(type0); /* list of fields */ while(1) { getsym(0); if (sym==PERIOD) { /* struct/union field initializaer */ @@ -1406,7 +1407,7 @@ offset = assign_data(e,t,n,offset); type=t; return offset; - } else if ((t1 = car(t0)) && t1==ARRAY) { + } else if (t0>0 && (t1 = car(t0)) && t1==ARRAY) { if (sym==LC) { conv->decl_data_begin_(); mode = mode_save; @@ -1433,7 +1434,7 @@ } } /* NOT REACHED */ - } else if (cadr(t0)==CHAR) { + } else if (type_value(cadr(t0))==CHAR) { e=expr1(); mode = mode_save; if(car(e)!=STRING) diff -r 62f3c801b6ac -r 79fef53141b4 test/code-gen.c --- a/test/code-gen.c Sat Dec 17 10:32:34 2005 +0900 +++ b/test/code-gen.c Mon Dec 19 22:42:12 2005 +0900 @@ -124,6 +124,7 @@ printf("#0123:code_gvar c %d %d %u %u %u %u\n",s_i1,s_i2,s1,s_s2,s_us1,s_us2); s_c1 = -1; s_c2 = -3; s_uc1 = 200; s_uc2 = 202; printf("#0125:code_gvar d %d %d %u %u\n",s_c1,s_c2,s_uc1,s_uc2); + s_i1 = 1; s_i2 = -2; } // code_register(int e2,int creg) @@ -137,6 +138,8 @@ register short s1,s2; register unsigned short us1,us2; + s_i1 = 1; s_i2 = -2; // check ptr cache clear + i1 = 1; i2 = -2; s1 = -1; s2 = -3; us1 = 65535; us2 = 65535; printf("#0141:code_lvar r %d %d %u %u %u %u\n",i1,i2,s1,s2,us1,us2);