Mercurial > hg > CbC > old > device
changeset 712:bf94c295d763 compiler-64bit
*** empty log message ***
author | kono |
---|---|
date | Sat, 27 Oct 2007 23:20:44 +0900 |
parents | 35e6841ba01a |
children | 88e364604533 |
files | Changes conv/c.c conv/c2cbc.c conv/cbc2c.c mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code-spu.c mc-codegen.c mc-inline.c mc-macro.c mc-parse.c mc-parse.h mc-tree.c mc.h |
diffstat | 16 files changed, 255 insertions(+), 166 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sat Oct 27 13:30:38 2007 +0900 +++ b/Changes Sat Oct 27 23:20:44 2007 +0900 @@ -9646,11 +9646,7 @@ mc-macro で、car にstring pointer を入れているのは、 どうする? - - - - - - - - +Sat Oct 27 13:30:55 JST 2007 + +けっこう、スムースだな... macro のと、ST_DECL あたりに、 +なんか残っているらしい。
--- a/conv/c.c Sat Oct 27 13:30:38 2007 +0900 +++ b/conv/c.c Sat Oct 27 23:20:44 2007 +0900 @@ -110,7 +110,7 @@ args=n->dsp; fprintf(vout,"code %s(",n->nm); while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); type_print(n->ty,n,vout); args=cadr(args); if(args) fprintf(vout,","); @@ -229,7 +229,7 @@ fprintf(vout,"%s(",n->nm); args=n->dsp; while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); if (n==&str_ret) { args=cadr(args); continue; } type_print(n->ty,n,vout); args=cadr(args);
--- a/conv/c2cbc.c Sat Oct 27 13:30:38 2007 +0900 +++ b/conv/c2cbc.c Sat Oct 27 23:20:44 2007 +0900 @@ -113,7 +113,7 @@ args=n->dsp; fprintf(vout,"code %s(",n->nm); while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); type_print(n->ty,n,vout); args=cadr(args); if(args) fprintf(vout,","); @@ -233,7 +233,7 @@ fprintf(vout,"%s(",n->nm); args=n->dsp; while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); if (n==&str_ret) { args=cadr(args); continue; }
--- a/conv/cbc2c.c Sat Oct 27 13:30:38 2007 +0900 +++ b/conv/cbc2c.c Sat Oct 27 23:20:44 2007 +0900 @@ -113,7 +113,7 @@ args=n->dsp; fprintf(vout,"code %s(",n->nm); while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); type_print(n->ty,n,vout); args=cadr(args); if(args) fprintf(vout,","); @@ -233,7 +233,7 @@ fprintf(vout,"%s(",n->nm); args=n->dsp; while(args) { - n=(NMTBL *)caddr(args); + n=ncadddr(args); if (n==&str_ret) { args=cadr(args); continue; }
--- a/mc-code-arm.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-code-arm.c Sat Oct 27 23:20:44 2007 +0900 @@ -619,7 +619,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = ncaddr(args); + n = ncadddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -627,7 +627,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - cadddr(args)=SIZE_OF_INT; + caddr(args)=SIZE_OF_INT; } } else if (type==FLOAT) { if (is_function(fnptr)) { @@ -636,7 +636,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - cadddr(args)=size(type); + caddr(args)=size(type); } } else { if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) { @@ -644,7 +644,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; freg_var++; - cadddr(args)=size(type); + caddr(args)=size(type); } } } else if (type==DOUBLE) { @@ -655,7 +655,7 @@ regs[regv_l(i)]= INPUT_REG; regs[regv_h(i)]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } else if (type==LONGLONG||type==ULONGLONG) { if ((reg = get_input_lregister_var(reg_var,n,is_code0))) { @@ -665,7 +665,7 @@ regs[regv_l(i)]= INPUT_REG; regs[regv_h(i)]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } args = cadr(args); @@ -2233,7 +2233,7 @@ arg_on_register = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = ncaddr(args); + n = ncadddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR);
--- a/mc-code-ia32.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-code-ia32.c Sat Oct 27 23:20:44 2007 +0900 @@ -991,7 +991,7 @@ while (args) { /* process in reverse order */ - n = ncaddr(args); + n = ncadddr(args); type = n->ty; // n->dsp = offset; // printf("### %s %d %d\n",n->nm,n->dsp,n->ty); @@ -1001,7 +1001,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - cadddr(args)=SIZE_OF_INT; /* why we need this? */ + caddr(args)=SIZE_OF_INT; /* why we need this? */ } offset+=SIZE_OF_INT; } else if (type==FLOAT||type==DOUBLE) { @@ -1010,7 +1010,7 @@ n->dsp = cadr(reg); fregs[n->dsp]= INPUT_REG; freg_var++; - cadddr(args)=size(type); /* why we need this? */ + caddr(args)=size(type); /* why we need this? */ } offset+=size(type); } else
--- a/mc-code-mips.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-code-mips.c Sat Oct 27 23:20:44 2007 +0900 @@ -576,7 +576,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = ncaddr(args); + n = ncadddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -585,7 +585,7 @@ regs[n->dsp]= INPUT_REG; reg_var++; freg_var++; - cadddr(args)=SIZE_OF_INT; + caddr(args)=SIZE_OF_INT; } } else if (type==FLOAT) { if ((reg = get_input_dregister_var0(freg_var,reg_var,n,is_code0,0))) { @@ -594,7 +594,7 @@ regs[n->dsp]= INPUT_REG; reg_var++; freg_var++; - cadddr(args)=size(type); + caddr(args)=size(type); } } else if (type==DOUBLE) { if ((reg = get_input_lregister_var(reg_var,n,is_code0))) { @@ -604,7 +604,7 @@ regs[regv_l(i)]= INPUT_REG; regs[regv_h(i)]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } else if (type==LONGLONG||type==ULONGLONG) { if ((reg = get_input_lregister_var(reg_var,n,is_code0))) { @@ -614,7 +614,7 @@ regs[regv_l(i)]= INPUT_REG; regs[regv_h(i)]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } args = cadr(args); @@ -1831,7 +1831,7 @@ int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = ncaddr(args); + n = ncadddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR);
--- a/mc-code-powerpc.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-code-powerpc.c Sat Oct 27 23:20:44 2007 +0900 @@ -793,7 +793,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = ncaddr(args); + n = ncadddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -801,7 +801,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - arg_offset_v += (cadddr(args)=SIZE_OF_INT); + arg_offset_v += (caddr(args)=SIZE_OF_INT); } } else if (type==FLOAT) { if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) { @@ -809,7 +809,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; freg_var++; - arg_offset_v += (cadddr(args)=size(type)); + arg_offset_v += (caddr(args)=size(type)); } } else if (type==DOUBLE) { if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) { @@ -817,7 +817,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; freg_var++; - arg_offset_v += (cadddr(args)=size(type)); + arg_offset_v += (caddr(args)=size(type)); } } else if (type==LONGLONG||type==ULONGLONG) { if ((reg = get_input_lregister_var(reg_var,n,is_code0))) { @@ -827,7 +827,7 @@ regs[regv_l(i)]= INPUT_REG; regs[regv_h(i)]= INPUT_REG; reg_var+=2; - arg_offset_v += (cadddr(args)=size(type)); + arg_offset_v += (caddr(args)=size(type)); } } args = cadr(args); @@ -1390,8 +1390,8 @@ regs[FREG_VAR_BASE-i+FREG_OFFSET]=REG_VAR; /*そのレジスタを使うことを宣言し*/ if (i>max_freg_var) max_freg_var=i; /* その場所を表す番号を返す */ - return list3(DREGISTER, - FREG_VAR_BASE-i+FREG_OFFSET,(int)n); + return list3n(DREGISTER, + FREG_VAR_BASE-i+FREG_OFFSET,n); } } return list3n(LVAR,new_lvar(SIZE_OF_DOUBLE),0); @@ -2176,7 +2176,7 @@ int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = ncaddr(args); + n = ncadddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR); @@ -2212,7 +2212,7 @@ } n->sc = LVAR; g_expr_u(assign_expr0( - list3n(LVAR,n->dsp,0),list3(tag,reg,(int)n),n->ty,t)); + list3n(LVAR,n->dsp,0),list3n(tag,reg,n),n->ty,t)); if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { free_register(reg); } @@ -6335,7 +6335,7 @@ e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii(ncadr(e1)->nm); + ascii(ncaddr(e1)->nm); e1=list2(LABEL,val); } else if (car(e1)==CONST) { } else error(-1);
--- a/mc-code-spu.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-code-spu.c Sat Oct 27 23:20:44 2007 +0900 @@ -594,7 +594,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = ncaddr(args); + n = ncadddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -602,7 +602,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - cadddr(args)=SIZE_OF_INT; + caddr(args)=SIZE_OF_INT; } } else if (type==FLOAT) { if (is_function(fnptr)) { @@ -611,7 +611,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; reg_var++; - cadddr(args)=size(type); + caddr(args)=size(type); } } else { if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) { @@ -619,7 +619,7 @@ n->dsp = cadr(reg); regs[n->dsp]= INPUT_REG; freg_var++; - cadddr(args)=size(type); + caddr(args)=size(type); } } } else if (type==DOUBLE) { @@ -630,7 +630,7 @@ regs[i]= INPUT_REG; //regs[i]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } else if (type==LONGLONG||type==ULONGLONG) { if ((reg = get_input_lregister_var(reg_var,n,is_code0))) { @@ -640,7 +640,7 @@ regs[i]= INPUT_REG; //regs[(i)]= INPUT_REG; reg_var+=2; - cadddr(args)=size(type); + caddr(args)=size(type); } } args = cadr(args); @@ -2106,7 +2106,7 @@ arg_on_register = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = ncaddr(args); + n = ncadddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR);
--- a/mc-codegen.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-codegen.c Sat Oct 27 23:20:44 2007 +0900 @@ -568,7 +568,7 @@ g_expr_u(e2); return g_expr0(caddr(e1)); case RETURN: - n = (NMTBL *)e2; + n = ncaddr(e1); if (retcont==0) retcont=fwdlabel(); code_return(USE_CREG); @@ -2808,7 +2808,7 @@ int e; NMTBL *n; for(e=inline_funcs;e;e=cadr(e)) { - n = (NMTBL*)car(e); + n = ncaddr(e); if (is_code(n)||is_function(n)) { if (n->sc!=STATIC || has_attr(n,FNAME)) { // global or used as pointer @@ -3173,7 +3173,7 @@ e = reverse0(e); for(i=out;i;i=cadr(i)) { - p = ((NMTBL*)cadr(car(i)))->nm; + p = (ncaddr(car(i)))->nm; e1 = car(e); e = cadr(e); repl = code_asm_operand(p,e1,ASM_OUTPUT,repl,0,0); if (!chk && repl && car(car(repl))==REGISTER) { @@ -3183,7 +3183,7 @@ repl0 = repl; n = length(repl0); for(i=in;i;i=cadr(i)) { - p = ((NMTBL*)cadr(car(i)))->nm; + p = (ncaddr(car(i)))->nm; e1 = car(e); e = cadr(e); repl = code_asm_operand(p,e1,ASM_INPUT,repl,n,repl0); if (!chk && repl && car(car(repl))==REGISTER) { @@ -3192,7 +3192,7 @@ } repl = reverse0(repl); - p = ((NMTBL*)cadr(asm0))->nm; + p = (ncaddr(asm0))->nm; code_asm(p,repl); for(i=assign;i;i=cadr(i)) { g_expr_u(car(i)); @@ -3286,7 +3286,7 @@ } } if (n!=&null_nptr) - fields = list4(type,fields,(int)(n->nm),disp); + fields = list4n(type,fields,disp,n); // don't set attribute to n } else if (mode==GUDECL||mode==LUDECL) { // union /* disp is pushded and reset in sdecl */ @@ -3295,7 +3295,7 @@ } else { sz = size(type0); } - fields = list4(type,fields,(int)(n->nm),0); + fields = list4n(type,fields,0,n); } else { if (n->sc!=EMPTY && !(n->sc==EXTRN||n->sc==EXTRN1||n->sc==STATIC)) { /* redefined case */ @@ -3351,7 +3351,7 @@ return n; case GTDECL: // typedef nsc = TYPE; - gtypedefed=glist2((int)gnptr,gtypedefed); + gtypedefed=glist3n(GTDECL,gtypedefed,gnptr); set_attributes(n,attr); break; case LTDECL: // local typedef @@ -3381,7 +3381,7 @@ type0=type; } } - fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); + fnptr->dsp=list4n(type,fnptr->dsp,0,n); n->sc = LVAR; if(inmode==INLINE) { n->dsp = args++; @@ -3412,7 +3412,7 @@ n->dsp = args; args += sz; } - cadddr(fnptr->dsp)=sz; + caddr(fnptr->dsp)=sz; if(type0==VOID) { } else { n->ty = type; @@ -3595,7 +3595,7 @@ int e; int t,sz,offset1=0; int init = decl_str_init; - NMTBL *n = (NMTBL*)caddr(v); + NMTBL *n = ncaddr(v); decl_str_init = 0; sz = size(n->ty); @@ -3767,7 +3767,7 @@ { int ass,sz,bfd; int v0 = car(v); - NMTBL *n = (NMTBL*)caddr(v); + NMTBL *n = ncaddr(v); if (inmode) error(-1); #if STRUCT_ALIGN @@ -3847,7 +3847,7 @@ int offset0=0; int e; int t,sz,offset1=0; - NMTBL *n = (NMTBL*)caddr(v); + NMTBL *n = ncaddr(v); sz = size(n->ty); /* @@ -3882,7 +3882,7 @@ int smode = mode; mode = STADECL; if (decl_str_init) flush_delayed_decl_data(e); mode = smode; - emit_data_closing((NMTBL*)caddr(e)); + emit_data_closing(ncaddr(e)); } } @@ -3908,15 +3908,15 @@ #if ARG_REORDER_DEBUG if (lsrc)fprintf(stderr,"arg_reorder old:\n"); for(j=new_arg;j;j=cadr(j)) { - n=(NMTBL *)caddr(j); + n=ncadddr(j); if (lsrc)fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j)); } if (lsrc)fprintf(stderr,"arg_reorder new:\n"); #endif for(j=arg;j;j=cadr(j)) { - n=(NMTBL *)caddr(j); + n=ncadddr(j); for(i=new_arg;i;i=cadr(i)) { - n1=(NMTBL *)caddr(i); + n1=ncadddr(i); if (!neqname(n1->nm,n->nm)) break; // if (n1==n) break; } @@ -3931,23 +3931,23 @@ if(n->sc==LVAR) { n->dsp = dsp; car(j)=car(i); - caddr(j)=caddr(i); + ncadddr(j)=ncadddr(i); n1->dsp = n->dsp; n->ty = n1->ty; n->sc = n1->sc; n->attr = n1->attr; - cadddr(j)=sz= cadddr(i); + caddr(j)=sz= caddr(i); if (sz==1||sz==size_of_short) sz = size_of_int; dsp += sz; } else if(n->sc==IVAR) { n->dsp = dsp; car(j)=car(i); - caddr(j)=caddr(i); + ncadddr(j)=ncadddr(i); n1->dsp = n->dsp; n->ty = n1->ty; n->sc = n1->sc; n->attr = n1->attr; - cadddr(j)=sz= cadddr(i); + caddr(j)=sz= caddr(i); dsp ++; } arg_types = glist2(n->ty, arg_types); @@ -3990,7 +3990,7 @@ /* fix all argument's offset */ sz = inmode?1:size(type); for(t=fnptr->dsp;t;t=cadr(t)) { - n=(NMTBL *)caddr(t); + n=ncadddr(t); n->dsp += inmode?1:sz; } fnptr->dsp = reverse0(fnptr->dsp); @@ -4220,14 +4220,14 @@ } switch(car(e)) { case GVAR: - n = (NMTBL*)caddr(e); + n = ncaddr(e); if (cadr(e)==0 && (c=attr_value(n,KONST))) { if (!has_attr(n,VOLATILE)) return c; } return(list3n(RGVAR+op,cadr(e),ncaddr(e))); case LVAR: - n = (NMTBL*)caddr(e); + n = ncaddr(e); if (cadr(e)==0 && n && (c=attr_value(n,KONST))) { if (!has_attr(n,VOLATILE)) return c; @@ -4311,13 +4311,13 @@ NMTBL *nptr0; t = caddr(type_value(type)); if (t==0) { - nptr0=(NMTBL*)cadddr(type); + nptr0=ncadddr(type); if (!nptr0->ty) { error(TYERR); return 0; } t = caddr(type) = caddr(nptr0->ty); } for(;t;t = cadr(t)) { - if (neqname((char *)caddr(t),name)==0) { - *dsp = cadddr(t); + if (neqname(ncadddr(t)->nm,name)==0) { + *dsp = caddr(t); return car(t); } } @@ -5283,7 +5283,7 @@ { int i; for(i=0;i<MAX_PTR_CACHE-1;i++) { - ptr_cache=glist3(0,ptr_cache,0); + ptr_cache=glist3n(0,ptr_cache,0); } ptr_cache_last=ptr_cache; } @@ -5294,8 +5294,8 @@ int ptcptr=ptr_cache; int prev = 0; while(ptcptr!=ptr_cache_last) { - if(car(ptcptr)&&caddr(ptcptr)==r) { - free_register(r); caddr(ptcptr)=-1; car(ptcptr)=0; + if(ncaddr(ptcptr)&&car(ptcptr)==r) { + free_register(r); car(ptcptr)=-1; ncaddr(ptcptr)=0; // remove me if (prev) cadr(prev) = cadr(ptcptr); else ptr_cache = cadr(ptcptr); @@ -5314,7 +5314,7 @@ int ptcptr=ptr_cache; int r = 0; while(ptcptr!=ptr_cache_last) { - r = caddr(ptcptr); + r = car(ptcptr); ptcptr=cadr(ptcptr); } return r; @@ -5326,7 +5326,7 @@ { int ptcptr=ptr_cache; while(ptcptr!=ptr_cache_last) { - free_register(caddr(ptcptr)); caddr(ptcptr)=-1; car(ptcptr)=0; + free_register(car(ptcptr)); car(ptcptr)=-1; ncaddr(ptcptr)=0; ptcptr=cadr(ptcptr); } ptr_cache_last = ptr_cache; @@ -5338,19 +5338,19 @@ { int r; int ptcptr=ptr_cache; - int g = (int)nptr; + NMTBL *g = nptr; int prev=0,p; // linear search cache while(ptcptr!=ptr_cache_last) { - if(car(ptcptr)==g) { + if(ncaddr(ptcptr)==g) { if (prev) { // make this top cadr(prev)=cadr(ptcptr); cadr(ptcptr) = ptr_cache; ptr_cache = ptcptr; } - return caddr(ptcptr); + return car(ptcptr); } ptcptr=cadr(prev=ptcptr); } @@ -5358,14 +5358,14 @@ // cache is full if (prev) { // remove oldest cache and it becomes the last - free_register(caddr(prev)); caddr(ptcptr)=-1; car(ptcptr)=0; + free_register(car(prev)); car(ptcptr)=-1; ncaddr(ptcptr)=0; ptr_cache_last = prev; } else error(-1); } r = get_register(0); // some ptr cache may remove by this - caddr(p = cadr(ptr_cache_last)) = r; - car(p) = g; + car(p = cadr(ptr_cache_last)) = r; + ncaddr(p) = g; use_ptr_cache(r); cadr(ptr_cache_last) = cadr(p);
--- a/mc-inline.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-inline.c Sat Oct 27 23:20:44 2007 +0900 @@ -899,14 +899,14 @@ p_decl(int e) { // list4(ST_DECL,parse,(int)n,list3(mode,stmode,ctmode),init); - int ctmode=cadddr(e); - NMTBL *n=(NMTBL*)caddr(e); + int ctmode=caddr(e); + NMTBL *n=ncaddddr(e); int dsp = n->dsp; int v=0; int sstmode = stmode; int smode = mode; int save_init_vars = init_vars; - int init = caddddr(e); // variable initialization + int init = cadddr(e); // variable initialization init_vars = 0; // in real partial evaluation, we have to check whether this variable @@ -963,7 +963,7 @@ if (n->sc!=FLABEL) inline_lvars = glist2(v,inline_lvars); if (heap[pdisp+dsp]) { - fprintf(stderr,"## double p_decl %s %s\n",((NMTBL*)(caddr(heap[pdisp+dsp])))->nm,n->nm); + fprintf(stderr,"## double p_decl %s %s\n",(ncaddr(heap[pdisp+dsp]))->nm,n->nm); error(-1); } heap[pdisp+dsp]=v; @@ -1545,7 +1545,7 @@ } for (e3 = e5 = reverse0(caddr(e)); e3; e3 = cadr(e3)) { - anptr = (NMTBL*)caddr(fargtype); + anptr = ncadddr(fargtype); if (!anptr) break; // should not happen? t=caddr(e3); // type e4 = car(e3); @@ -1575,7 +1575,7 @@ leave_inline(int e1,int toplevel) { NMTBL *n; - NMTBL *local_statics = (NMTBL*)cadddr(e1); // local static list + NMTBL *local_statics = ncadddr(e1); // local static list if (retcont && !toplevel) error(STERR); // inline can't handle return/environment except top level
--- a/mc-macro.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-macro.c Sat Oct 27 23:20:44 2007 +0900 @@ -44,6 +44,13 @@ static int macro_processing(); /* + nptr->dsp + list3s(MACRO,arg,char*) + + list3s(STRING,next,char*) + */ + +/* macro_expansion(NMTBL *nptrm) innput macro term (and chptr for arguments) @@ -54,7 +61,7 @@ In macro_function and macro_eavl, expand result is put into macrop local variable. - list2("replaced string",next) + list3s(STRING,next,char*) to generate result, mappend/reverse0 is necessary. */ @@ -76,7 +83,7 @@ if (nptrm->sc == FMACRO) { macrop=macro_function(macrop,&chptr,nptrm,0); } else { - macrop=macro_eval(macrop,(char *)car(nptrm->dsp),0); + macrop=macro_eval(macrop,scaddr(nptrm->dsp),0); } // copy output from resulted listed string @@ -138,7 +145,7 @@ } #endif // push previous chptr, and change it to the generate macro - chptrsave = glist2((int)chptr,chptrsave); // push old one into the stack + chptrsave = glist3s(STRING,chptrsave,chptr); // push old one into the stack chsave = glist2(ch,chsave); chptr = macropp; ch = *chptr++; @@ -675,7 +682,7 @@ /* macro define from chptr body will be copied and stored in nptr->dsp - list2( string, list of argments (if any)) + list3s( STRING, list of argments (if any), char *) We don't expand macro here, it just copied. */ @@ -705,8 +712,8 @@ // equal is allowed for -Dhoge=aho option // if (ch=='=') chptr++; while((c=*chptr)==' '||c=='\t') chptr++; - nptr->dsp = list2((int)cheap->ptr,args); /* macro body */ - body = (char **)&car(nptr->dsp); + nptr->dsp = list3s(MACRO,args,cheap->ptr); /* macro body */ + body = (char **)&scaddr(nptr->dsp); // now copy it to the body while ((*cheap->ptr = c = *chptr++) @@ -757,8 +764,8 @@ int plevel = 0; char **body; char *chptr = *pchptr; - int args = list2((int)cheap->ptr,0); - body = (char **)&car(args); + int args = glist3s(STRING,0,cheap->ptr); + body = (char **)&scaddr(args); for(;;) { *cheap->ptr = c = *chptr++; cheap = increment_cheap(cheap,body); @@ -808,8 +815,8 @@ } if (plevel==0) { if (c==',') { cheap->ptr[-1] = 0; - args = list2((int)cheap->ptr,args); - body = (char **)&car(args); + args = list3s(STRING,args,cheap->ptr); + body = (char **)&scaddr(args); } else if (c==')') { cheap->ptr[-1] = 0; break; @@ -863,7 +870,7 @@ // eval all argument list evalues = 0; while(values) { - evalues = list2(macro_eval(0,(char *)car(values),history),evalues); + evalues = list2(macro_eval(0,scaddr(values),history),evalues); values = cadr(values); } // define all arguments locally @@ -873,13 +880,13 @@ enter_scope(); while(args) { mappend0(reverse0(car(evalues)),¯o); - local_define((char *)car(args),macro); + local_define(scaddr(args),macro); args = cadr(args); evalues = cadr(evalues); } // process body replacement - macro = (char *)car(nptr->dsp); - macrop = macro_eval(macrop,macro,list2((int)macro,history)); + macro = scaddr(nptr->dsp); + macrop = macro_eval(macrop,macro,list3s(STRING,history,macro)); args = sargs; // unbind arguments leave_scope(); @@ -920,8 +927,8 @@ char *body = body0; char **expand; NMTBL *nptrm; - macrop = list2((int)cheap->ptr,macrop); - expand = (char **)&car(macrop); + macrop = list3s(STRING,macrop,cheap->ptr); + expand = (char **)&scaddr(macrop); for(; (c = *body++) ;) { if (in_quote) { if (c=='\\') { @@ -971,7 +978,7 @@ c = *body; nptrm = name_space_search(nptrm,MACRO); if (nptrm->dsp) - macro = (char *)car(nptrm->dsp); + macro = scaddr(nptrm->dsp); else macro=""; // if (check_recurse(macro,history)) goto skip; @@ -987,9 +994,9 @@ cheap = increment_cheap(cheap,expand); body++; macrop = macro_function(macrop,&body,nptrm, - list2((int)macro,history)); - macrop = list2((int)cheap->ptr,macrop); - expand = (char **)&(car(macrop)); + list3s(STRING,history,macro)); + macrop = list3s(STRING,macrop,cheap->ptr); + expand = (char **)&(scaddr(macrop)); break; case MACRO: if (neqname(nptrm->nm,macro)) { @@ -1003,9 +1010,9 @@ } *cheap->ptr = 0; cheap = increment_cheap(cheap,expand); - macrop=macro_eval(macrop,macro,list2((int)macro,history)); - macrop = list2((int)cheap->ptr,macrop); - expand = (char **)&(car(macrop)); + macrop=macro_eval(macrop,macro,list3s(STRING,history,macro)); + macrop = list3s(STRING,macrop,cheap->ptr); + expand = (char **)&(scaddr(macrop)); break; } default: @@ -1041,7 +1048,7 @@ char *p; *result = cheap->ptr; for(;lists;lists = cadr(lists)) { - p = (char *)car(lists); + p = scaddr(lists); for(;(*cheap->ptr = *p++);cheap = increment_cheap(cheap,result)) { // in_quote + \n case ? should be \n. if (p[-1]=='\n') cheap->ptr[0]=' '; @@ -1058,7 +1065,7 @@ char *p; *result = cheap->ptr; for(;lists;lists = cadr(lists)) { - p = (char *)car(lists); + p = scaddr(lists); for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,result)) { // in_quote + \n case ? should be \n. // if (p[-1]=='\n') cheap->ptr[0]=' ';
--- a/mc-parse.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-parse.c Sat Oct 27 23:20:44 2007 +0900 @@ -483,7 +483,7 @@ fprintf(stderr,"%s",linebuf); lim=chptr; while (chptrsave) { - lim = (char*)car(chptrsave); + lim = scaddr(chptrsave); chptrsave = cadr(chptrsave); } if (lim<linebuf||linebuf+BUFSIZ<lim) { @@ -800,13 +800,9 @@ { NMTBL *nptr; - - (nptr = name_space_search(get_name(s,0,DEF),d?0:MACRO))->sc = sc; - if (d==0) { - nptr->dsp = (int)""; nptr->ty=0; - } else { - nptr->dsp = d; - } + if (d==0) error(-1); + (nptr = name_space_search(get_name(s,0,DEF),0))->sc = sc; + nptr->dsp = d; } /* @@ -942,7 +938,7 @@ init = decl_data(type,v,0,0); data_closing(v); } if (inmode && (mode==LDECL||mode==LLDECL||mode==STADECL)) { - parse = list5(ST_DECL,parse,(int)n,list3(mode,stmode,ctmode),init); + parse = list5n(ST_DECL,parse,list3(mode,stmode,ctmode),init,n); } while(sym==COMMA) { init = 0; @@ -964,8 +960,8 @@ init = decl_data(type,v,0,0);data_closing(v); } if (inmode && mode==LDECL) { - parse = list5(ST_DECL,parse,(int)n, - list3(mode,stmode,ctmode),init); + parse = list5n(ST_DECL,parse, + list3(mode,stmode,ctmode),init,n); } } if(sym!=SM) error(DCERR); @@ -1162,7 +1158,7 @@ if(sym==IDENT) { if (nptr->sc==TYPE) { t=nptr->ty; - typedefed=glist2((int)nptr,typedefed); + typedefed=glist3n(TYPEDEF,typedefed,nptr); // have to be type attribute copy_attributes(nptr); getsym(0); @@ -2091,12 +2087,12 @@ conv->code_end_(); if (inmode) { set_attr(n,INLINE, - list4(reverse0(parse),arg_disp,disp,(int)local_static_list)); + list4n(reverse0(parse),arg_disp,disp,local_static_list)); if (parse_mode && ! sinmode) { set_attr(n,NOINLINE,-1); } parse = 0; - inline_funcs = list2((int)n,inline_funcs); + inline_funcs = list3n(INLINE,inline_funcs,n); } else { if(!chk) gen_code_leave(fnptr->nm); } @@ -2187,12 +2183,12 @@ conv->function_end_(); conv->rc_(); if (inmode) { set_attr(n,INLINE, - list4(reverse0(parse),arg_disp,disp,(int)local_static_list)); + list4n(reverse0(parse),arg_disp,disp,local_static_list)); if (parse_mode && ! sinmode) { set_attr(n,NOINLINE,-1); } parse = 0; - inline_funcs = list2((int)n,inline_funcs); + inline_funcs = list3n(INLINE,inline_funcs,n); inmode = 0; } else { #if 0 @@ -2231,7 +2227,7 @@ int sz ; n1 = get_nptr(); - a = ncaddr(arg); + a = ncadddr(arg); n1->ty = a->ty; n1->nm = a->nm; n1->sc = a->sc==IVAR?LVAR:a->sc; @@ -2246,7 +2242,7 @@ ((sz+(size_of_int-1))&~(size_of_int-1)): sz; - nargs=list4(car(arg),nargs,(int)n1,cadddr(arg)); + nargs=list4n(car(arg),nargs,caddr(arg),n1); } args = offset; return nargs; @@ -2302,7 +2298,7 @@ // make calling argments for(args=fnptr->dsp,cargs=0;args;args=cadr(args)) { - a = ncaddr(args); + a = ncadddr(args); // make call function argment for gen_inline e=list3n(a->sc==IVAR?LVAR:a->sc,a->dsp,a); cargs = list3(e,cargs,a->ty); @@ -2367,9 +2363,9 @@ /* reverse all argument offset (with size) */ arg = fnptr->dsp; for(t=arg;t;t=cadr(t)) { - n1=ncaddr(t); + n1=ncadddr(t); if(n1->sc==LVAR) - n1->dsp = -n1->dsp-cadddr(t); + n1->dsp = -n1->dsp-caddr(t); } retcont = 0; @@ -2380,7 +2376,7 @@ // make calling argments for(arg=fnptr->dsp,cargs=0;arg;arg=cadr(arg)) { - a = ncaddr(arg); + a = ncadddr(arg); // make call function argment for gen_inline e=list3n(a->sc==IVAR?LVAR:a->sc,a->dsp,a); cargs = list3(e,cargs,a->ty); @@ -4317,7 +4313,7 @@ tmp_struct = def(0,0); if (inmode) { set_attr(tmp_struct,HAS_ADDRESS,1); - parse = list5(ST_DECL,parse,(int)tmp_struct,list3(LDECL,0,0),0); + parse = list5n(ST_DECL,parse,list3(LDECL,0,0),0,tmp_struct); } } return tmp_struct; @@ -4421,7 +4417,7 @@ } if (car(e1)==FNAME) { // recursive inline is not allowed - if ((NMTBL *)(cadr(e1))!=fnptr && is_inline(ncaddr(e1))) { + if (ncaddr(e1)!=fnptr && is_inline(ncaddr(e1))) { return list4(INLINE,e1,arglist,ftype); } } @@ -4929,9 +4925,10 @@ return (symval=0); } } - if ((nptrm->sc==MACRO&&neqname((char *)car(nptrm->dsp),nptrm->nm)) || + if ((nptrm->sc==MACRO&&neqname(scaddr(nptrm->dsp),nptrm->nm)) || (nptrm->sc==FMACRO&&skipspc()=='(')) { - if (in_macro_if && *((char*)car(nptrm->dsp))==0) { + char *s; + if (in_macro_if && (s = scaddr(nptrm->dsp)) && *s==0) { symval = 0; return (sym=CONST); } @@ -5082,7 +5079,7 @@ extern void free_nptr(NMTBL *n) { - n->dsp = (int)free_nptr_list; + n->u.nptr = free_nptr_list; free_nptr_list = n; } @@ -5096,10 +5093,12 @@ NMTBL *ret; if (free_nptr_list) { ret = free_nptr_list; - free_nptr_list = (NMTBL *)free_nptr_list->dsp; + free_nptr_list = free_nptr_list->u.nptr; ret->sc = 0; ret->ty = 0; ret->dsp = 0; + ret->dsp = 0; + ret->u.nptr = 0; ret->attr = 0; ret->next = 0; return ret; @@ -5119,6 +5118,7 @@ ret->sc = 0; ret->ty = 0; ret->dsp = 0; + ret->u.nptr = 0; ret->attr = 0; ret->next = 0; return ret; @@ -5151,6 +5151,7 @@ } nptr->sc=EMPTY; nptr->dsp=0; + nptr->u.nptr=0; return nptr; } @@ -5178,6 +5179,7 @@ n->nm = hash->nm; n->sc = EMPTY; n->dsp = 0; + n->u.nptr = 0; n->attr = 0; return n; } @@ -5311,11 +5313,11 @@ if(*chptr) return ch = *chptr++; else if (chptrsave) { - chptr = (char *)car(chptrsave); + chptr = scaddr(chptrsave); ch = car(chsave); i = cadr(chptrsave); j = cadr(chsave); - free_glist2(chptrsave); + free_glist2s(chptrsave); free_glist2(chsave); chptrsave = i; chsave = j; @@ -5458,6 +5460,19 @@ return e; } +extern int +list3s(int e1, int e2, char *e3) +{ + int e; + + e=getfree(2+(sizeof(void*)/sizeof(int))); + heap[e]=e1; + heap[e+1]=e2; + scaddr(e) = e3; + + return e; +} + extern int list4(int e1, int e2, int e3, int e4) @@ -5486,6 +5501,19 @@ } extern int +list4s(int e1, int e2, int e3, char * e4) +{ + int e; + + e=getfree(3+(sizeof(void*)/sizeof(int))); + heap[e]=e1; + heap[e+1]=e2; + heap[e+2]=e3; + scadddr(e) = e4; + return e; +} + +extern int list5(int e1, int e2, int e3, int e4,int e5) { int e; @@ -5500,6 +5528,20 @@ } extern int +list5n(int e1, int e2, int e3, int e4,NMTBL * e5) +{ + int e; + + e=getfree(4+(sizeof(void*)/sizeof(int))); + heap[e]=e1; + heap[e+1]=e2; + heap[e+2]=e3; + heap[e+3]=e4; + ncaddddr(e) = e5; + return e; +} + +extern int getfree(int n) { int e; @@ -5542,6 +5584,31 @@ return ret; } +extern int +glist2s(int e1,char *e2) +{ + int ret; + ret = gfree; + gfree+=(1+sizeof(void*)/sizeof(int)) ; + heap[ret]=e1; + scaddr(ret) = e2; + if(lfree<gfree) error(HPERR); + return ret; +} + +extern int +glist3s(int e1,int e2, char *e3) +{ + int ret; + ret = gfree; + gfree+=(2+sizeof(void*)/sizeof(int)) ; + heap[ret]=e1; + heap[ret+1]=e2; + scaddr(ret) = e3; + if(lfree<gfree) error(HPERR); + return ret; +} + extern void free_glist2(int e1) { @@ -5632,6 +5699,12 @@ } extern void +free_glist2s(int e1) +{ + // fix me +} + +extern void free_glist3(int e1) { /* list3n is larger than length 3, but it's Ok */ @@ -5920,16 +5993,7 @@ extern int c3(int d) { fprintf(stderr,"heap[%d]=",d);return cadddr(d); } extern int c4(int d) { fprintf(stderr,"heap[%d]=",d);return caddddr(d); } -extern char *cc0(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)car(d); } -extern char *cc1(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadr(d); } -extern char *cc2(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)caddr(d); } -extern char *cc3(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadddr(d); } -extern char *cc4(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)caddddr(d); } - -extern NMTBL *nc0(int d) { fprintf(stderr,"heap[%d]=",d);return (NMTBL *)car(d); } -extern NMTBL *nc1(int d) { fprintf(stderr,"heap[%d]=",d);return (NMTBL *)cadr(d); } -extern NMTBL *nc2(int d) { fprintf(stderr,"heap[%d]=",d);return (NMTBL *)caddr(d); } -extern NMTBL *nc3(int d) { fprintf(stderr,"heap[%d]=",d);return (NMTBL *)cadddr(d); } -extern NMTBL *nc4(int d) { fprintf(stderr,"heap[%d]=",d);return (NMTBL *)caddddr(d); } +extern char *cc2(int d) { fprintf(stderr,"heap[%d]=",d);return scaddr(d); } +extern NMTBL *nc2(int d) { fprintf(stderr,"heap[%d]=",d);return ncaddr(d); } /* end */
--- a/mc-parse.h Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-parse.h Sat Oct 27 23:20:44 2007 +0900 @@ -104,6 +104,7 @@ extern void free_glist3(int e1); extern void free_glist3_a(int e1); +extern void free_glist2s(int e1); extern int csvalue1; /* current switch variable */ extern int blabel; /* break label in switch */ extern int dlabel; /* default label in switch */ @@ -128,6 +129,8 @@ #endif extern void error(int n); extern int glist2(int e1,int e2); +extern int glist2s(int e1,char * e2); +extern int glist3s(int e1,int e2, char * e3); extern int glist3(int e1,int e2,int e3); extern int glist4(int e1,int e2,int e3,int e4); extern int glist5(int e1,int e2,int e3,int e4,int e5); @@ -136,6 +139,7 @@ extern int length(int list); extern int list2(int e1, int e2); extern int list3(int e1, int e2, int e3); +extern int list3s(int e1, int e2, char * e3); extern int list4(int e1, int e2, int e3, int e4); extern NMTBL * extern_define(char *s,int d,int type,int use); extern void set_lfree(int save);
--- a/mc-tree.c Sat Oct 27 13:30:38 2007 +0900 +++ b/mc-tree.c Sat Oct 27 23:20:44 2007 +0900 @@ -260,7 +260,8 @@ { tree_node_type node_type,*t; int i,j; - char *s; + char *s, **p; + NMTBL **n; t = &node_type; t->tree_type=e; @@ -284,9 +285,11 @@ case 'v': printf(",%d",heap[e+i]); break; case 'n': - printf(",%s",((NMTBL *)heap[e+i])->nm); break; + n = (NMTBL**)&(heap[e+i]); + printf(",%s",(*n)->nm); break; case 's': - printf(",%s",(char *)heap[e+i]); break; + p = (char**)&(heap[e+i]); + printf(",%s",*p); break; case 'i': printf(",%d",heap[e+i]); break; } @@ -301,7 +304,7 @@ { NMTBL *n; int tags; - if((n=(NMTBL*)cadddr(type))) { + if((n=ncadddr(type))) { fprintf(out,"%s ",n->nm); return; } @@ -349,8 +352,8 @@ typedef_search(int t,int type) { while(t) { - if (((NMTBL*)car(t))->ty==type) - return (NMTBL*)car(t); + if ((ncaddr(t))->ty==type) + return ncaddr(t); t=cadr(t); } return 0; @@ -525,7 +528,7 @@ } break; case IDENT: - nptr = (NMTBL*)cadr(e); + nptr = ncaddr(e); fprintf(vout,"%s",nptr->nm); break; case CONST: switch(car(e)) { @@ -720,7 +723,7 @@ print_expr(list3(cadr(e),car(e1),cadr(e1)),vout); break; case ST_COMMENT: - fprintf(vout,"\n# %s\n",vcaddr(e)); + fprintf(vout,"\n# %s\n",scaddr(e)); break; default: fprintf(stderr,"Unknown Statement ID %d\n",car(e));
--- a/mc.h Sat Oct 27 13:30:38 2007 +0900 +++ b/mc.h Sat Oct 27 23:20:44 2007 +0900 @@ -547,7 +547,12 @@ char *nm; struct nametable *next; int sc,attr; - int ty,dsp; } NMTBL; + int ty,dsp; + union { + struct nametable *nptr; + char *nm; + } u; +} NMTBL; extern int *heap; /* heap area (in cheap ) */ extern NMTBL *global_list; /* list of all global NMTBL */ @@ -565,8 +570,10 @@ extern int glist3n(int e1, int e2, NMTBL *e3); extern int list4(int e1, int e2, int e3,int e4); extern int list4n(int e1, int e2, int e3,NMTBL *e4); +extern int list4s(int e1, int e2, int e3,char *e4); extern int glist4n(int e1, int e2, int e3,NMTBL *e4); extern int list5(int e1, int e2, int e3,int e4,int e5); +extern int list5n(int e1, int e2, int e3,int e4,NMTBL * e5); extern int length(int e1); extern int getfree(int size); extern int nth(int n,int e1); @@ -603,6 +610,8 @@ #define ncadddr(e) (*(NMTBL**)&heap[((int)(e))+3]) +#define ncaddddr(e) (*(NMTBL**)&heap[((int)(e))+4]) + #define vcaddr(e) (*(void**)&heap[((int)(e))+2]) #define vcadddr(e) (*(void**)&heap[((int)(e))+3]) @@ -611,6 +620,12 @@ #define pcadddr(e) (*(int**)&heap[((int)(e))+3]) +#define scaddr(e) (*(char**)&heap[((int)(e))+2]) +#ifdef NOTHREAD + my_spe_run_thread(t_args); +#endif +#define scadddr(e) (*(char**)&heap[((int)(e))+3]) + #if FLOAT_CODE #define dcadr(e) (*(double*)&heap[((int)(e))+1]) #define dcaddr(e) (*(double*)&heap[((int)(e))+2])