Mercurial > hg > CbC > old > device
changeset 513:4c2607e72ab5
inline continue... fix function call
cstring
author | kono |
---|---|
date | Mon, 26 Dec 2005 00:45:46 +0900 |
parents | 53ec17a8af7d |
children | a2047e4555be |
files | Changes mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-inline.c |
diffstat | 7 files changed, 78 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sun Dec 25 19:46:20 2005 +0900 +++ b/Changes Mon Dec 26 00:45:46 2005 +0900 @@ -7540,10 +7540,24 @@ ## 41: else return i; const でreplaceする時がまずいな。RIVARみたいなのを作ると、 -ちょっとcaseが増えすぎるが... - - - - - - +ちょっとcaseが増えすぎるが... pindirect でいんちきするか。 + +const で置換したIVARのアドレスを取られると気まずいなぁ。 + +このあたりはマルチパスでないとできない。まぁ、parse tree を +持っているので可能ではあるけど。 + +Sun Dec 25 20:24:02 JST 2005 + +さて、return を作らないとだめか。 + +なに、結局、 + + return value がないときは jump + return value がある時には、g_expr でjump + +にする? とりあえず。 + +pfdecl で struct_return は、なんとかしてるの? + +
--- a/mc-code-arm.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-code-arm.c Mon Dec 26 00:45:46 2005 +0900 @@ -3590,7 +3590,7 @@ void emit_global(char *name,int t) { - data_mode(name); + // data_mode(name); printf("\t.globl\t%s\n",name); align(t); printf("%s:\n",name);
--- a/mc-code-ia32.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-code-ia32.c Mon Dec 26 00:45:46 2005 +0900 @@ -2034,7 +2034,7 @@ extern void emit_global(char *name,int t) { - data_mode(name); + // data_mode(name); printf(".globl\t%s\n",name); align(t); printf("%s:\n",name);
--- a/mc-code-mips.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-code-mips.c Mon Dec 26 00:45:46 2005 +0900 @@ -3270,7 +3270,7 @@ extern void emit_global(char *name,int t) { - data_mode(name); + // data_mode(name); printf(".globl\t%s\n",name); align(t); printf("%s:\n",name);
--- a/mc-code-powerpc.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-code-powerpc.c Mon Dec 26 00:45:46 2005 +0900 @@ -2973,7 +2973,7 @@ extern void emit_global(char *name,int t) { - data_mode(name); + // data_mode(name); printf(".globl\t_%s\n",name); align(t); printf("_%s:\n",name);
--- a/mc-codegen.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-codegen.c Mon Dec 26 00:45:46 2005 +0900 @@ -34,6 +34,7 @@ static int register_to_lvar(int e); static void remove0(int *parent,int e) ; static void sassign(int e1); +static void checkjmp(int l); #if FLOAT_CODE @@ -2396,20 +2397,6 @@ return labelno++; } -static void -checkjmp(int l) -{ - int p = pending_jmp; - pending_jmp = 0; - if (p) { - if (p!=l) { - control=0; - if (!chk) - jmp(p); - } - } -} - extern void fwddef(int l) { @@ -2925,7 +2912,7 @@ error(-1); return; } if (chk) return; - if (n->dsp != -1) { + if ((car(e)!=STRING && n->dsp != -1)) { n->dsp = -1; /* initialized flag */ emit_global(name,t); } @@ -2983,12 +2970,21 @@ emit_address(((NMTBL *)caddr(e))->nm,0); return; case STRING: - if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) { + if (car(type_value(n->ty))!=ARRAY || cadr(type_value(n->ty))!=CHAR) { l = emit_string_label(); + if (n->dsp != -1) { + n->dsp = -1; /* initialized flag */ + emit_global(name,t); + } ascii((char *)cadr(e)); emit_label(l); - } else + } else { + if (n->dsp != -1) { + n->dsp = -1; /* initialized flag */ + emit_global(name,t); + } ascii((char *)cadr(e)); + } return; } // fprintf(stderr,"## type= %d\n",t); @@ -3211,6 +3207,20 @@ t==UCHAR||t==SHORT||t==USHORT||t==ENUM); } +static void +checkjmp(int l) +{ + int p = pending_jmp; + pending_jmp = 0; + if (p) { + if (p!=l) { + control=0; + if (!chk) + jmp(p); + } + } +} + extern void checkret(void) {
--- a/mc-inline.c Sun Dec 25 19:46:20 2005 +0900 +++ b/mc-inline.c Mon Dec 26 00:45:46 2005 +0900 @@ -271,10 +271,8 @@ if (!cslabel) gen_jmp(cslabel = fwdlabel()); if(!(e=caddr(e1))) { - // conv->return_(); - // conv->return_end_(); + // no return value retpending = 1; - g_expr_u(cadr(e1)); return; } // conv->return_(); @@ -285,8 +283,6 @@ /* pass the return pointer to the called function */ replace_return_struct(cadr(e), rvalue_t(car(struct_return),caddr(struct_return))); - replace_return_struct(cadr(e), - rvalue_t(car(struct_return),caddr(struct_return))); g_expr_u(cadr(e)); } else { type = caddr(struct_return); @@ -428,7 +424,7 @@ newargs = list3( pexpr(car(e3)), cadr(e3), caddr(e3)); } newargs = reverse0(newargs); - return list4(INLINE,e1,newargs,ftype); + return list4(car(e),e1,newargs,ftype); } static int @@ -975,8 +971,12 @@ gen_inline(int e) { int svartable = pvartable; + int sretlabel = retlabel; + int sretcont = retcont; + int scslabel = cslabel; NMTBL *sfnptr = fnptr; int sdisp = pdisp; + int narg,arg; NMTBL *n = (NMTBL*)cadr(cadr(e)); int e1 = attr_value(n,INLINE); @@ -985,7 +985,14 @@ int e2,e3,t,e4,dots; int ret_type = function_type(cadddr(e),&dots); + retcont = 0; + cslabel = -1; + retpending = 0; + + checkret(); + enter_scope(); // to make label scope happy + retlabel = fwdlabel(); fnptr = n; // st_return see this pvartable = p_vartable(e,arg_disp,caddr(e1)); @@ -1007,11 +1014,21 @@ e2 = pexpr(parse); pdisp = sdisp; pvartable = svartable; - // how to handle return value? - g_expr_u(e2); - fnptr = sfnptr; + + if (ret_type!=VOID) + g_expr0(e2); + else + g_expr_u(e2); + fwddef(retlabel); + + if (retcont) error(STERR); // inline can't handle return/environment leave_scope(); + fnptr = sfnptr; + retlabel = sretlabel; + retcont = sretcont; + cslabel = scslabel; + return ret_type; }