Mercurial > hg > CbC > old > device
changeset 711:35e6841ba01a
pointer fixes (partial)
author | kono |
---|---|
date | Sat, 27 Oct 2007 13:30:38 +0900 |
parents | 4348f61a5e54 |
children | bf94c295d763 |
files | Changes 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-tree.c mc.h |
diffstat | 12 files changed, 461 insertions(+), 368 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Oct 25 13:58:42 2007 +0900 +++ b/Changes Sat Oct 27 13:30:38 2007 +0900 @@ -9640,3 +9640,17 @@ long を64にするのは、難しくないが、int がshort と同じ扱いになるの? extend するのもあれだが... +Fri Oct 26 12:41:38 JST 2007 + +pointer の書き換えはいいんだけど、bug を取りにくい。 +mc-macro で、car にstring pointer を入れているのは、 +どうする? + + + + + + + + +
--- a/mc-code-arm.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-code-arm.c Sat Oct 27 13:30:38 2007 +0900 @@ -619,7 +619,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = (NMTBL*)caddr(args); + n = ncaddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -858,7 +858,7 @@ regs[ll]=USING_REG; regv_l(ll) = REG_VAR_BASE+j; regv_h(ll) = REG_VAR_BASE+i; - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } } /* ひとつしかなかった */ @@ -869,7 +869,7 @@ } } not_found: - return list3(LVAR,new_lvar(SIZE_OF_LONGLONG),0); + return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0); } void @@ -908,7 +908,7 @@ if(i>MAX_CODE_INPUT_DREGISTER_VAR) return 0; i = FREG_VAR_BASE+i+FREG_OFFSET; use_input_reg(i,1); - return list3(FREGISTER,i,(int)n); + return list3n(FREGISTER,i,n); } else { return get_input_lregister_var(i,n,is_code); } @@ -917,10 +917,10 @@ j = get_input_lregister_var(i,n,is_code); return j; } else { - if (i==0) return list3(REGISTER,1,(int)n); - else if (i==1) return list3(REGISTER,2,(int)n); - else if (i==2) return list3(REGISTER,3,(int)n); - else if (i==3) return list3(REGISTER,4,(int)n); + if (i==0) return list3n(REGISTER,1,n); + else if (i==1) return list3n(REGISTER,2,n); + else if (i==2) return list3n(REGISTER,3,n); + else if (i==3) return list3n(REGISTER,4,n); else return 0; } } @@ -947,7 +947,7 @@ regv_l(ll)=i+1; #endif } else { error(-1); ll=LREG_OFFSET+2; } - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } int @@ -961,7 +961,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0; i = i+1; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } @@ -1175,10 +1175,10 @@ regs[j]=USING_REG; if (i+1>=max_reg_var) max_reg_var=i+1; /* その場所を表す番号を返す */ - return list3(REGISTER,j,(int)n); + return list3n(REGISTER,j,n); } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),0); } #define freg_var_num(i) (FREG_VAR_BASE+i+FREG_OFFSET) @@ -1194,11 +1194,11 @@ regs[j]=USING_REG; /*そのレジスタを使うことを宣言し*/ if (i+1>max_freg_var) max_freg_var=i+1; /* その場所を表す番号を返す */ - return list3(FREGISTER,j,(int)n); + return list3n(FREGISTER,j,n); } } } - return list3(LVAR,new_lvar(d?SIZE_OF_DOUBLE:SIZE_OF_FLOAT),0); + return list3n(LVAR,new_lvar(d?SIZE_OF_DOUBLE:SIZE_OF_FLOAT),0); } int @@ -1344,7 +1344,7 @@ control=0; for(p = const_list; p ; p = cadr(p)) { switch(car(p)) { - case GVAR: printf("\t.word\t%s\n",((NMTBL *)caddr(p))->nm); break; + case GVAR: printf("\t.word\t%s\n",(ncaddr(p))->nm); break; case DCONST: case LCONST: case CONST: printf("\t.word\t%d\n",caddr(p)); break; case LABEL: printf("\t.word\t.L%d\n",caddr(p)); break; @@ -1600,20 +1600,20 @@ void code_gvar(int e1,int reg) { use_int(reg); - code_add(reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_add(reg,cadr(e1),get_ptr_cache(ncaddr(e1))); return; } void code_rgvar(int e1,int reg) { use_int(reg); - code_ld("ldr",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),""); + code_ld("ldr",reg,cadr(e1),get_ptr_cache(ncaddr(e1)),""); } void code_crgvar(int e1,int reg,int sign,int sz){ use_int(reg); - code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)), + code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache(ncaddr(e1)), cext_at(sz,sign)); cext(sign,sz,reg); } @@ -1847,7 +1847,7 @@ void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { use_int(reg); - code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)), + code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache(ncaddr(e1)), cext_at(sz,0)); cext(0,sz,r); inc_inst(1); @@ -1873,7 +1873,7 @@ void code_cmp_rgvar(int e1,int reg,int label,int cond) { use_int(reg); - code_ld("ldr",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),""); + code_ld("ldr",reg,cadr(e1),get_ptr_cache(ncaddr(e1)),""); code_cmp_register(reg,label,cond); } @@ -1905,7 +1905,7 @@ { char *s,*crn; int lb,disp,label; - NMTBL *n = (NMTBL *)cadr(e1); + NMTBL *n = ncaddr(e1); if ((lb=attr_value(n,LABEL))) { // already defined return code_label_value(lb,creg) ; @@ -2233,7 +2233,7 @@ arg_on_register = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = (NMTBL *)caddr(args); + n = ncaddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR); @@ -2243,7 +2243,7 @@ len = size(n->ty); len = round4(len); for(;len>0 && reg_var<MAX_INPUT_REGISTER_VAR;len-=SIZE_OF_INT) { reg_var++; - g_expr_u(assign_expr0(list3(LVAR,offset,0), + g_expr_u(assign_expr0(list3n(LVAR,offset,0), list3(REGISTER,reg_var,0),INT,INT)); arg_on_register += SIZE_OF_INT; free_register(reg); @@ -2254,7 +2254,7 @@ if (dots) { while ((reg = get_input_register_var(reg_var,0,0))) { g_expr_u(assign_expr0( - list3(LVAR,offset,0),reg,INT,INT)); + list3n(LVAR,offset,0),reg,INT,INT)); offset+=SIZE_OF_INT; reg_var++; arg_on_register += SIZE_OF_INT; @@ -2461,35 +2461,35 @@ if (mode==AS_SAVE) { return get_register_var(0); } else if (reg_arg+1>MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_register_var(reg_arg,0,0); } else if (t==LONGLONG||t==ULONGLONG) { if (mode==AS_SAVE) { return get_lregister_var(0); } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_lregister_var(reg_arg,0,0); } else if (t==FLOAT) { if (mode==AS_SAVE) { return get_dregister_var(0,0); } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(freg_arg,0,0,0); } else if (t==DOUBLE) { if (mode==AS_SAVE) { return get_dregister_var(0,1); } else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(reg_arg,0,0,1); } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) { if (mode==AS_SAVE) { return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else { error(-1); return get_register_var(0); @@ -2530,7 +2530,7 @@ arg_assign = 0; e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case // jmp = get_register_var(0); @@ -2644,7 +2644,7 @@ // half register case writes *(sp-1) but it will be Ok. if (max_func_args<4) max_func_args=4; g_expr_u(assign_expr0(list3(REGISTER,4,0), - list3(LVAR,caller_arg_offset_v(3),0),INT,INT)); + list3n(LVAR,caller_arg_offset_v(3),0),INT,INT)); use_input_reg(4,1); } nargs = reg_arg = freg_arg = 0; @@ -2926,7 +2926,7 @@ code_assign_gvar(int e2,int creg,int byte) { use_int(creg); code_ldf(cstore(byte),register_name(creg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2)),byte==SIZE_OF_SHORT?" @ movhi":""); + get_ptr_cache(ncaddr(e2)),byte==SIZE_OF_SHORT?" @ movhi":""); } void @@ -3976,7 +3976,7 @@ } else { use_float(d,freg); code_ldf(fstore(d),fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))," @ float"); + get_ptr_cache(ncaddr(e2))," @ float"); } } @@ -4388,7 +4388,7 @@ } else { use_float(d,freg); code_ldf(fload(d),fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2)),""); + get_ptr_cache(ncaddr(e2)),""); } } @@ -5136,7 +5136,7 @@ { int r; use_longlong(creg); - r = get_ptr_cache((NMTBL*)caddr(e2)); + r = get_ptr_cache(ncaddr(e2)); #if ENDIAN_L==0 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r,""); code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r,""); @@ -5202,7 +5202,7 @@ use_longlong(creg); crn_h = lregister_name_high(creg); crn_l = lregister_name_low(creg); - r = get_ptr_cache((NMTBL*)caddr(e1)); + r = get_ptr_cache(ncaddr(e1)); #if ENDIAN_L==0 code_ldf("ldr",crn_l,cadr(e1),r,""); code_ldf("ldr",crn_h,cadr(e1)+SIZE_OF_INT,r,""); @@ -5935,8 +5935,8 @@ } else if (car(rstr)==CONST) { printf("%d",cadr(rstr)); } else if (car(rstr)==FNAME) { - printf("%s",(char*)cadr(rstr)); - } else if (car(rstr)==STRING) { + printf("%s",ncaddr(rstr)->nm); + } else if (car(rstr)==LABEL) { printf(".L%d",cadr(rstr)); } else { error(-1); @@ -5996,13 +5996,13 @@ repl = list3(list2(0,0),repl,clobber); } else if (c=='i') { if (car(e1)==GVAR) { - e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==FNAME) { - e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii((char*)cadr(e1)); - e1=list3(STRING,val,0); + ascii(ncaddr(e1)->nm); + e1=list2(LABEL,val); } else if (car(e1)==CONST) { } else error(-1); repl = list3(e1,repl,clobber);
--- a/mc-code-ia32.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-code-ia32.c Sat Oct 27 13:30:38 2007 +0900 @@ -854,7 +854,7 @@ if (i>=MAX_CODE_INPUT_REGISTER_VAR) return 0; i += REG_ESI; regs[i]=INPUT_REG; - return list3(REGISTER,i,(int)nptr); + return list3n(REGISTER,i,nptr); } else { return 0; } @@ -897,7 +897,7 @@ reg_var=2; return list2(LREGISTER,REG_L); } - return list3(LVAR,new_lvar(SIZE_OF_LONGLONG),0); + return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0); } int @@ -991,7 +991,7 @@ while (args) { /* process in reverse order */ - n = (NMTBL*)caddr(args); + n = ncaddr(args); type = n->ty; // n->dsp = offset; // printf("### %s %d %d\n",n->nm,n->dsp,n->ty); @@ -1066,16 +1066,16 @@ for(i=REG_ESI;i<REG_EBP;i++) { if (! regs[i]) { /* 使われていないなら */ regs[i]=REG_VAR; /* そのレジスタを使うことを宣言し */ - return list3(REGISTER,i,(int)nptr); /* その場所を表す番号を返す */ + return list3n(REGISTER,i,nptr); /* その場所を表す番号を返す */ } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),0); } int get_dregister_var(NMTBL *nptr,int d) { - return list3(LVAR,new_lvar(d?SIZE_OF_DOUBLE:SIZE_OF_FLOAT),0); + return list3n(LVAR,new_lvar(d?SIZE_OF_DOUBLE:SIZE_OF_FLOAT),0); } @@ -1120,7 +1120,7 @@ code_gvar(int e1,int creg) { use_int(creg); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) { printf("\tleal %d(%s),%s\n", cadr(e1),register_name(r,0), register_name(creg,0)); @@ -1129,10 +1129,10 @@ } #else if (cadr(e1)) { - printf("\tmovl $%s+%d,%s\n",((NMTBL*)caddr(e1))->nm,cadr(e1), + printf("\tmovl $%s+%d,%s\n",(ncaddr(e1))->nm,cadr(e1), register_name(creg,0)); } else { - printf("\tmovl $%s,%s\n",((NMTBL*)caddr(e1))->nm,register_name(creg,0)); + printf("\tmovl $%s,%s\n",(ncaddr(e1))->nm,register_name(creg,0)); } #endif @@ -1142,7 +1142,7 @@ code_rgvar(int e1,int creg) { use_int(creg); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) { printf("\tmovl %d(%s),%s\n", cadr(e1),register_name(r,0), register_name(creg,0)); @@ -1151,10 +1151,10 @@ } #else if (cadr(e1)) { - printf("\tmovl %s+%d,%s\n",((NMTBL*)caddr(e1))->nm,cadr(e1), + printf("\tmovl %s+%d,%s\n",(ncaddr(e1))->nm,cadr(e1), register_name(creg,0)); } else - printf("\tmovl %s,%s\n",((NMTBL*)caddr(e1))->nm,register_name(creg,0)); + printf("\tmovl %s,%s\n",(ncaddr(e1))->nm,register_name(creg,0)); #endif } @@ -1169,7 +1169,7 @@ code_crgvar(int e1,int creg,int sign,int sz){ use_int(creg); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) { printf("\t%s %d(%s),%s\n", cload(sign,sz),cadr(e1),register_name(r,0), register_name(creg,0)); @@ -1180,10 +1180,10 @@ #else if (cadr(e1)) { printf("\t%s %s+%d,%s\n",cload(sign,sz), - ((NMTBL*)caddr(e1))->nm,cadr(e1),register_name(creg,0)); + (ncaddr(e1))->nm,cadr(e1),register_name(creg,0)); } else printf("\t%s %s,%s\n",cload(sign,sz), - ((NMTBL*)caddr(e1))->nm,register_name(creg,0)); + (ncaddr(e1))->nm,register_name(creg,0)); #endif } @@ -1422,7 +1422,7 @@ code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { use_int(reg); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) { if (sz==1) printf("\tcmpb $0,%d(%s)\n",cadr(e1),register_name(r,0)); @@ -1437,14 +1437,14 @@ #else if (cadr(e1)) { if (sz==1) - printf("\tcmpb $0,%s+%d\n",((NMTBL*)caddr(e1))->nm,cadr(e1)); + printf("\tcmpb $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1)); else if (sz==SIZE_OF_SHORT) - printf("\tcmpw $0,%s+%d\n",((NMTBL*)caddr(e1))->nm,cadr(e1)); + printf("\tcmpw $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1)); } else { if (sz==1) - printf("\tcmpb $0,%s\n",((NMTBL*)caddr(e1))->nm); + printf("\tcmpb $0,%s\n",(ncaddr(e1))->nm); else if (sz==SIZE_OF_SHORT) - printf("\tcmpw $0,%s\n",((NMTBL*)caddr(e1))->nm); + printf("\tcmpw $0,%s\n",(ncaddr(e1))->nm); } #endif jcond(label,cond); @@ -1467,16 +1467,16 @@ code_cmp_rgvar(int e1,int reg,int label,int cond) { use_int(reg); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); if (cadr(e1)) printf("\tcmpl $0,%d(%s)\n",cadr(e1),register_name(r,0)); else printf("\tcmpl $0,(%s)\n",register_name(r,0)); #else if (cadr(e1)) - printf("\tcmpl $0,%s+%d\n",((NMTBL*)caddr(e1))->nm,cadr(e1)); + printf("\tcmpl $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1)); else - printf("\tcmpl $0,%s\n",((NMTBL*)caddr(e1))->nm); + printf("\tcmpl $0,%s\n",(ncaddr(e1))->nm); #endif jcond(label,cond); } @@ -1503,7 +1503,7 @@ { char *s; int lb; - NMTBL *n = (NMTBL *)cadr(e1); + NMTBL *n = ncaddr(e1); if ((lb=attr_value(n,LABEL))) { // already defined return code_label_value(lb,creg) ; @@ -1729,37 +1729,37 @@ { if(scalar(t)) { if (mode==AS_SAVE) { - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else if (t==LONGLONG||t==ULONGLONG) { if (mode==AS_SAVE) { - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_lregister_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else if (t==FLOAT) { if (mode==AS_SAVE) { - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_dregister_var(0,0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else if (t==DOUBLE) { if (mode==AS_SAVE) { - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_dregister_var(0,1); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) { if (mode==AS_SAVE) { - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else { error(-1); - return list3(LVAR,new_lvar(size(t)),0); + return list3n(LVAR,new_lvar(size(t)),0); // return get_register_var(0); } } @@ -1807,7 +1807,7 @@ arg_assign = 0; e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case jmp = list3(REGISTER,REG_EAX,0); @@ -2086,7 +2086,7 @@ if (byte) { use_data_reg(creg,1); } else { use_int(creg); } #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e2)); + int r = get_ptr_cache(ncaddr(e2)); if (cadr(e2)) printf("\t%s %s,%d(%s)\n",move(byte),register_name(creg,byte), cadr(e2),register_name(r,0)); @@ -2095,9 +2095,9 @@ register_name(r,0)); #else if (cadr(e2)) - printf("\t%s %s,%s+%d\n",move(byte),register_name(creg,byte),((NMTBL*)caddr(e2))->nm,cadr(e2)); + printf("\t%s %s,%s+%d\n",move(byte),register_name(creg,byte),(ncaddr(e2))->nm,cadr(e2)); else - printf("\t%s %s,%s\n",move(byte),register_name(creg,byte),((NMTBL*)caddr(e2))->nm); + printf("\t%s %s,%s\n",move(byte),register_name(creg,byte),(ncaddr(e2))->nm); #endif } @@ -3044,16 +3044,16 @@ void code_dassign_gvar(int e2,int freg,int d) { #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e2)); + int r = get_ptr_cache(ncaddr(e2)); if (cadr(e2)) printf("\t%s %d(%s)\n",fstore(d),cadr(e2),register_name(r,0)); else printf("\t%s (%s)\n",fstore(d),register_name(r,0)); #else if (cadr(e2)) - printf("\t%s %s+%d\n",fstore(d),((NMTBL*)caddr(e2))->nm,cadr(e2)); + printf("\t%s %s+%d\n",fstore(d),(ncaddr(e2))->nm,cadr(e2)); else - printf("\t%s %s\n",fstore(d),((NMTBL*)caddr(e2))->nm); + printf("\t%s %s\n",fstore(d),(ncaddr(e2))->nm); #endif } @@ -3199,16 +3199,16 @@ void code_drgvar(int e2,int d,int freg) { #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e2)); + int r = get_ptr_cache(ncaddr(e2)); if (cadr(e2)) printf("\t%s %d(%s)\n",fload(d),cadr(e2),register_name(r,0)); else printf("\t%s (%s)\n",fload(d),register_name(r,0)); #else if (cadr(e2)) - printf("\t%s %s+%d\n",fload(d),((NMTBL*)caddr(e2))->nm,cadr(e2)); + printf("\t%s %s+%d\n",fload(d),(ncaddr(e2))->nm,cadr(e2)); else - printf("\t%s %s\n",fload(d),((NMTBL*)caddr(e2))->nm); + printf("\t%s %s\n",fload(d),(ncaddr(e2))->nm); #endif } @@ -3221,16 +3221,16 @@ void code_cmp_drgvar(int e2,int reg,int d,int label,int cond) { #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e2)); + int r = get_ptr_cache(ncaddr(e2)); if (cadr(e2)) printf("\tfcomp %d(%s)\n",cadr(e2),register_name(r,0)); else printf("\tfcomp (%s)\n",register_name(r,0)); #else if (cadr(e2)) - printf("\tfcomp %s+%d\n",((NMTBL*)caddr(e2))->nm,cadr(e2)); + printf("\tfcomp %s+%d\n",(ncaddr(e2))->nm,cadr(e2)); else - printf("\tfcomp %s\n",((NMTBL*)caddr(e2))->nm); + printf("\tfcomp %s\n",(ncaddr(e2))->nm); #endif jcond(label,cond); } @@ -3596,7 +3596,7 @@ use_int(e2); crn = register_name(e2,0); #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); n = register_name(r,0); if (cadr(e1)) { printf("\tmovl %d(%s),%s\n",cadr(e1),n,crn); @@ -3606,7 +3606,7 @@ printf("\torl 4(%s),%s\n",n,crn); } #else - n = ((NMTBL*)caddr(e1))->nm; + n = (ncaddr(e1))->nm; if (cadr(e1)) { printf("\tmovl %s+%d,%s\n",n,cadr(e1),crn); printf("\torl %s+%d,%s\n",n,cadr(e1)+4,crn); @@ -3648,7 +3648,7 @@ use_longlong(e2); #if ENDIAN_L==0 #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); n = register_name(r,0); if (cadr(e1)) { printf("\tmovl %s,%d(%s)\n",l_eax(e2),cadr(e1),n); @@ -3658,7 +3658,7 @@ printf("\tmovl %s,4(%s)\n",l_edx(e2),n); } #else - n = ((NMTBL*)caddr(e1))->nm; + n = (ncaddr(e1))->nm; if (cadr(e1)) { printf("\tmovl %s,%s+%d\n",l_eax(e2),n,cadr(e1)); printf("\tmovl %s,%s+%d\n",l_edx(e2),n,cadr(e1)+4); @@ -3713,7 +3713,7 @@ use_longlong(e2); #if ENDIAN_L==0 #ifdef __APPLE__ - int r = get_ptr_cache((NMTBL*)caddr(e1)); + int r = get_ptr_cache(ncaddr(e1)); n = register_name(r,0); if (cadr(e1)) { printf("\tmovl %d(%s),%s\n",cadr(e1),n,l_eax(e2)); @@ -3723,7 +3723,7 @@ printf("\tmovl 4(%s),%s\n",n,l_edx(e2)); } #else - n = ((NMTBL*)caddr(e1))->nm; + n = (ncaddr(e1))->nm; if (cadr(e1)) { printf("\tmovl %s+%d,%s\n",n,cadr(e1),l_eax(e2)); printf("\tmovl %s+%d,%s\n",n,cadr(e1)+4,l_edx(e2)); @@ -4330,11 +4330,11 @@ printf("%d",cadr(rstr)); } else if (car(rstr)==FNAME) { #ifdef __APPLE__ - printf("_%s-_%d",(char*)cadr(rstr),goffset_label); + printf("_%s-_%d",ncaddr(rstr)->nm,goffset_label); #else - printf("%s",(char*)cadr(rstr)); + printf("%s",ncaddr(rstr)->nm); #endif - } else if (car(rstr)==STRING) { + } else if (car(rstr)==LABEL) { #ifdef __APPLE__ printf("_%d-_%d",cadr(rstr),goffset_label); #else @@ -4398,13 +4398,13 @@ repl = list3(list2(0,0),repl,clobber); } else if (c=='i') { if (car(e1)==GVAR) { - e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==FNAME) { - e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii((char*)cadr(e1)); - e1=list3(STRING,val,0); + ascii(ncaddr(e1)->nm); + e1=list2(LABEL,val); } else if (car(e1)==CONST) { } else error(-1); repl = list3(e1,repl,clobber);
--- a/mc-code-mips.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-code-mips.c Sat Oct 27 13:30:38 2007 +0900 @@ -576,7 +576,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = (NMTBL*)caddr(args); + n = ncaddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -796,7 +796,7 @@ regs[ll]=USING_REG; regv_l(ll) = REG_VAR_BASE-j; regv_h(ll) = REG_VAR_BASE-i; - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } } /* ひとつしかなかった */ @@ -807,7 +807,7 @@ } } not_found: - return list3(LVAR,new_lvar(SIZE_OF_LONGLONG),0); + return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0); } void @@ -859,12 +859,12 @@ */ if (i==0) i=12+FREG_OFFSET; else if (i==1 && reg_var==0) i=14+FREG_OFFSET; - else if (i==1) return list3(REGISTER,5,(int)n); - else if (i==2) return list3(REGISTER,6,(int)n); - else if (i==3) return list3(REGISTER,7,(int)n); + else if (i==1) return list3n(REGISTER,5,n); + else if (i==2) return list3n(REGISTER,6,n); + else if (i==3) return list3n(REGISTER,7,n); else return 0; } - return list3(FREGISTER,i,(int)n); + return list3n(FREGISTER,i,n); } int @@ -895,7 +895,7 @@ regv_l(ll)=i+1; #endif } else { error(-1); ll=LREG_OFFSET+2; } - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } int @@ -908,7 +908,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0; i = i+MIN_TMP_REG; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } /* double register case? */ @@ -923,7 +923,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR+1) return 0; i = i+MIN_TMP_REG; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } int @@ -1135,10 +1135,10 @@ regs[j]=USING_REG; if (i+1>=max_reg_var) max_reg_var=i+1; /* その場所を表す番号を返す */ - return list3(REGISTER,j,(int)n); + return list3n(REGISTER,j,n); } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),0); } #define freg_var_num(i) (FREG_VAR_BASE-i+FREG_OFFSET) @@ -1162,10 +1162,10 @@ regs[j]=USING_REG; /*そのレジスタを使うことを宣言し*/ if (i+1>max_freg_var) max_freg_var=i+1; /* その場所を表す番号を返す */ - return list3(FREGISTER,j,(int)n); + return list3n(FREGISTER,j,n); } } - return list3(LVAR,new_lvar(SIZE_OF_DOUBLE),0); + return list3n(LVAR,new_lvar(SIZE_OF_DOUBLE),0); } int @@ -1255,20 +1255,20 @@ void code_gvar(int e1,int reg) { use_int(reg); - code_add(reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_add(reg,cadr(e1),get_ptr_cache(ncaddr(e1))); return; } void code_rgvar(int e1,int reg) { use_int(reg); - code_ld("lw",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld("lw",reg,cadr(e1),get_ptr_cache(ncaddr(e1))); } void code_crgvar(int e1,int reg,int sign,int sz){ use_int(reg); - code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache(ncaddr(e1))); cext(sign,sz,reg); } @@ -1498,7 +1498,7 @@ void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { use_int(reg); - code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache(ncaddr(e1))); cext(0,sz,r); cmpreg = reg; // printf("\tcmpwi cr0,%s,0\n",crn); @@ -1522,7 +1522,7 @@ void code_cmp_rgvar(int e1,int reg,int label,int cond) { use_int(reg); - code_ld("lw",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld("lw",reg,cadr(e1),get_ptr_cache(ncaddr(e1))); code_cmp_register(reg,label,cond); } @@ -1552,7 +1552,7 @@ { char *s,*crn; int lb; - NMTBL *n = (NMTBL *)cadr(e1); + NMTBL *n = ncaddr(e1); if ((lb=attr_value(n,LABEL))) { // already defined return code_label_value(lb,creg) ; @@ -1831,7 +1831,7 @@ int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = (NMTBL *)caddr(args); + n = ncaddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR); @@ -1871,7 +1871,7 @@ continue; } n->sc = LVAR; - g_expr_u(assign_expr0(list3(LVAR,n->dsp,0),list3(tag,reg,(int)n),t,t)); + g_expr_u(assign_expr0(list3n(LVAR,n->dsp,0),list3n(tag,reg,n),t,t)); if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { free_register(reg); } @@ -1879,7 +1879,7 @@ if (dots) { while ((reg = get_input_register_var(reg_var,0,0))) { g_expr_u(assign_expr0( - list3(LVAR,offset,0),reg,INT,INT)); + list3n(LVAR,offset,0),reg,INT,INT)); offset+=SIZE_OF_INT; reg_var++; } @@ -1983,7 +1983,7 @@ printf("\tli.s %s,%12.12g\n",frn,value); break; case FRGVAR: - r = get_ptr_cache((NMTBL*)caddr(e2)); + r = get_ptr_cache(ncaddr(e2)); printf("\tlw %s,%d(%s)\n",frn,cadr(e2),register_name(r)); break; case FRLVAR: @@ -2051,7 +2051,7 @@ if (mode==AS_SAVE) { return get_register_var(0); } else if (reg_arg+1>MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_register_var(reg_arg,0,0); } else if (t==LONGLONG||t==ULONGLONG) { @@ -2060,14 +2060,14 @@ if (mode==AS_SAVE) { return get_lregister_var(0); } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_lregister_var(reg_arg,0,0); } else if (t==FLOAT) { if (mode==AS_SAVE) { return get_dregister_var(0,0); } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var0(freg_arg,reg_arg,0,0,0); } else if (t==DOUBLE) { @@ -2076,14 +2076,14 @@ if (mode==AS_SAVE) { return get_dregister_var(0,1); } else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(reg_arg,0,0,1); } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) { if (mode==AS_SAVE) { return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else { error(-1); return get_register_var(0); @@ -2134,7 +2134,7 @@ arg_assign = 0; e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case jmp = list2(REGISTER,25); @@ -2477,7 +2477,7 @@ code_assign_gvar(int e2,int creg,int byte) { use_int(creg); code_ldf(cstore(byte),register_name(creg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } void @@ -3606,7 +3606,7 @@ } use_float(d,freg); code_ldf("s.s",fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } void @@ -3918,7 +3918,7 @@ } use_float(d,freg); code_ldf("l.s",fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } @@ -4506,7 +4506,7 @@ { int r; use_longlong(creg); - r = get_ptr_cache((NMTBL*)caddr(e2)); + r = get_ptr_cache(ncaddr(e2)); #if ENDIAN_L==0 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r); code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r); @@ -4553,7 +4553,7 @@ use_longlong(creg); crn_h = lregister_name_high(creg); crn_l = lregister_name_low(creg); - r = get_ptr_cache((NMTBL*)caddr(e1)); + r = get_ptr_cache(ncaddr(e1)); #if ENDIAN_L==0 code_ldf("lw",crn_l,cadr(e1),r); code_ldf("lw",crn_h,cadr(e1)+SIZE_OF_INT,r); @@ -5457,8 +5457,8 @@ } else if (car(rstr)==CONST) { printf("%d",cadr(rstr)); } else if (car(rstr)==FNAME) { - printf("%s",(char*)cadr(rstr)); - } else if (car(rstr)==STRING) { + printf("%s",ncaddr(rstr)->nm); + } else if (car(rstr)==LABEL) { printf("$L_%d",cadr(rstr)); } else { error(-1); @@ -5518,13 +5518,13 @@ repl = list3(list2(0,0),repl,clobber); } else if (c=='i') { if (car(e1)==GVAR) { - e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==FNAME) { - e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0); + e1=list3(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii((char*)cadr(e1)); - e1=list3(STRING,val,0); + ascii(ncaddr(e1)->nm); + e1=list3(LABEL,val,0); } else if (car(e1)==CONST) { } else error(-1); repl = list3(e1,repl,clobber);
--- a/mc-code-powerpc.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-code-powerpc.c Sat Oct 27 13:30:38 2007 +0900 @@ -793,7 +793,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = (NMTBL*)caddr(args); + n = ncaddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -1052,7 +1052,7 @@ regs[ll]=REG_VAR; regv_l(ll) = REG_VAR_BASE-j; regv_h(ll) = REG_VAR_BASE-i; - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } } /* ひとつしかなかった */ @@ -1063,7 +1063,7 @@ } } not_found: - return list3(LVAR,new_lvar(SIZE_OF_LONGLONG),0); + return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0); } void @@ -1100,7 +1100,7 @@ if (i<0||i>=MAX_INPUT_DREGISTER_VAR) return 0; i = i+MIN_TMP_FREG+FREG_OFFSET; } - return list3(DREGISTER,i,(int)n); + return list3n(DREGISTER,i,n); } int @@ -1127,7 +1127,7 @@ regv_l(ll)=i+1; #endif } else { error(-1); ll=LREG_OFFSET+2; } - return list3(LREGISTER,ll,(int)n); + return list3n(LREGISTER,ll,n); } int @@ -1140,7 +1140,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0; i = i+MIN_TMP_REG; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } /* double register case? */ @@ -1155,7 +1155,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR+1) return 0; i = i+MIN_TMP_REG; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } int @@ -1375,10 +1375,10 @@ regs[REG_VAR_BASE-i]=REG_VAR; if (i>max_reg_var) max_reg_var=i; /* その場所を表す番号を返す */ - return list3(REGISTER,REG_VAR_BASE-i,(int)n); + return list3n(REGISTER,REG_VAR_BASE-i,n); } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),0); } int @@ -1394,7 +1394,7 @@ FREG_VAR_BASE-i+FREG_OFFSET,(int)n); } } - return list3(LVAR,new_lvar(SIZE_OF_DOUBLE),0); + return list3n(LVAR,new_lvar(SIZE_OF_DOUBLE),0); } int @@ -1541,20 +1541,20 @@ void code_gvar(int e1,int reg) { use_int(reg); - code_add(reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_add(reg,cadr(e1),get_ptr_cache(ncaddr(e1))); return; } void code_rgvar(int e1,int reg) { use_int(reg); - code_ld("lwz",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld("lwz",reg,cadr(e1),get_ptr_cache(ncaddr(e1))); } void code_crgvar(int e1,int reg,int sign,int sz){ use_int(reg); - code_ld(cload(sz),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld(cload(sz),reg,cadr(e1),get_ptr_cache(ncaddr(e1))); cext(sign,sz,reg); } @@ -1849,7 +1849,7 @@ void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { use_int(reg); - code_ld(cload(sz),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld(cload(sz),reg,cadr(e1),get_ptr_cache(ncaddr(e1))); cext(0,sz,reg); inc_cmpflag(); printf("\tcmpwi %s,%s,0\n",crname(cmpflag),register_name(reg)); @@ -1873,7 +1873,7 @@ void code_cmp_rgvar(int e1,int reg,int label,int cond) { use_int(reg); - code_ld("lwz",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_ld("lwz",reg,cadr(e1),get_ptr_cache(ncaddr(e1))); code_cmp_register(reg,label,cond); } @@ -1903,7 +1903,7 @@ code_string(int e1,int creg) { int lb; - NMTBL *n = (NMTBL *)cadr(e1); + NMTBL *n = ncaddr(e1); if ((lb=attr_value(n,LABEL))) { // already defined return code_label_value(lb,creg) ; @@ -2176,7 +2176,7 @@ int reg_var = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = (NMTBL *)caddr(args); + n = ncaddr(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( - list3(LVAR,n->dsp,0),list3(tag,reg,(int)n),n->ty,t)); + list3n(LVAR,n->dsp,0),list3(tag,reg,(int)n),n->ty,t)); if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { free_register(reg); } @@ -2220,7 +2220,7 @@ if (dots) { while ((reg = get_input_register_var(reg_var,0,0))) { g_expr_u(assign_expr0( - list3(LVAR,offset,0),reg,INT,INT)); + list3n(LVAR,offset,0),reg,INT,INT)); offset+=SIZE_OF_INT; reg_var++; } @@ -2230,7 +2230,7 @@ printf("\tbne 1,%s%d\n",lpfx,skip); while ((reg = get_input_dregister_var(freg_var,0,0,1))) { g_expr_u(assign_expr0( - list3(LVAR,offset,0),reg,DOUBLE,DOUBLE)); + list3n(LVAR,offset,0),reg,DOUBLE,DOUBLE)); offset+=SIZE_OF_DOUBLE; freg_var++; } @@ -2405,35 +2405,35 @@ if (mode==AS_SAVE) { return get_register_var(0); } else if (reg_arg>=MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_register_var(reg_arg,0,0); } else if (t==LONGLONG||t==ULONGLONG) { if (mode==AS_SAVE) { return get_lregister_var(0); } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_lregister_var(reg_arg,0,0); } else if (t==FLOAT) { if (mode==AS_SAVE) { return get_dregister_var(0,0); } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(freg_arg,0,0,0); } else if (t==DOUBLE) { if (mode==AS_SAVE) { return get_dregister_var(0,1); } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(freg_arg,0,0,1); } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) { if (mode==AS_SAVE) { return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else { error(-1); return get_register_var(0); @@ -2461,7 +2461,7 @@ arg_assign = 0; e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case jmp = get_register_var(0); @@ -2607,11 +2607,11 @@ int r1; if (car(e4)==DRLVAR) { special_lvar = cadr(e4); - e5 = list3(LVAR,special_lvar,0); + e5 = list3n(LVAR,special_lvar,0); } else { special_lvar = new_lvar(SIZE_OF_DOUBLE); g_expr(assign_expr0( - (e5=list3(LVAR,special_lvar,0)),e4,DOUBLE,t)); + (e5=list3n(LVAR,special_lvar,0)),e4,DOUBLE,t)); reg_arg_list = list2(e5,reg_arg_list); e4 = list2(DREGISTER,freg); /* freg should not change until XXX */ @@ -2628,7 +2628,7 @@ reg_arg_list = list2(r1,reg_arg_list); arg_assign = list2( assign_expr0(r0,e5,INT,INT), arg_assign); arg_assign = list2( assign_expr0(r1, - list3(LVAR,special_lvar+SIZE_OF_INT,0), + list3n(LVAR,special_lvar+SIZE_OF_INT,0), INT,INT), arg_assign); } } @@ -2638,7 +2638,7 @@ stack value. */ arg_assign = list2( - assign_expr0(list3(LVAR,caller_arg_offset_v(nargs),0), + assign_expr0(list3n(LVAR,caller_arg_offset_v(nargs),0), get_input_dregister_var(freg_arg,0,0,1),t,t), arg_assign); } @@ -2900,7 +2900,7 @@ code_assign_gvar(int e2,int creg,int byte) { use_int(creg); code_ldf(cstore(byte),register_name(creg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } void @@ -4155,7 +4155,7 @@ { use_float(d,freg); code_ldf(fstore(d),fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } void @@ -4584,7 +4584,7 @@ { use_float(d,freg); code_ldf(fload(d),fregister_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); } @@ -4607,7 +4607,7 @@ frn=fregister_name(reg); code_ldf(fload(1),grn,cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2))); + get_ptr_cache(ncaddr(e2))); inc_cmpflag(); printf("\tfcmpu %s,%s,%s\n",crname(cmpflag),frn,grn); free_register(g); @@ -5083,7 +5083,7 @@ { int r; use_longlong(creg); - r = get_ptr_cache((NMTBL*)caddr(e2)); + r = get_ptr_cache(ncaddr(e2)); #if ENDIAN_L==0 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r); code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r); @@ -5169,7 +5169,7 @@ use_longlong(creg); crn_h = lregister_name_high(creg); crn_l = lregister_name_low(creg); - r = get_ptr_cache((NMTBL*)caddr(e1)); + r = get_ptr_cache(ncaddr(e1)); #if ENDIAN_L==0 code_ldf(cload(0),crn_l,cadr(e1),r); code_ldf(cload(0),crn_h,cadr(e1)+SIZE_OF_INT,r); @@ -6259,9 +6259,9 @@ } else if (car(rstr)==CONST) { printf("%d",cadr(rstr)); } else if (car(rstr)==FNAME) { - printf("%s",(char*)cadr(rstr)); - } else if (car(rstr)==STRING) { - printf("%s",(char*)cadr(rstr)); + printf("%s",ncaddr(rstr)->nm); + } else if (car(rstr)==LABEL) { + printf("%s%d:\n",lpfx,cadr(rstr)); } else { error(-1); } @@ -6330,13 +6330,13 @@ break; case 'i': if (car(e1)==GVAR) { - e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==FNAME) { - e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii(((NMTBL*)cadr(e1))->nm); - e1=list3(STRING,val,0); + ascii(ncadr(e1)->nm); + e1=list2(LABEL,val); } else if (car(e1)==CONST) { } else error(-1); repl = list3(e1,repl,clobber);
--- a/mc-code-spu.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-code-spu.c Sat Oct 27 13:30:38 2007 +0900 @@ -594,7 +594,7 @@ function_type(fnptr->ty,&dots); while (args) { /* process in reverse order */ - n = (NMTBL*)caddr(args); + n = ncaddr(args); type = n->ty; if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { @@ -805,16 +805,16 @@ if(i>MAX_CODE_INPUT_DREGISTER_VAR) return 0; i = FREG_VAR_BASE+i+FREG_OFFSET; use_input_reg(i,1); - return list3(FREGISTER,i,(int)n); + return list3n(FREGISTER,i,n); } if (d) { j = get_input_lregister_var(i,n,is_code); return j; } else { - if (i==0) return list3(REGISTER,1,(int)n); - else if (i==1) return list3(REGISTER,2,(int)n); - else if (i==2) return list3(REGISTER,3,(int)n); - else if (i==3) return list3(REGISTER,4,(int)n); + if (i==0) return list3n(REGISTER,1,n); + else if (i==1) return list3n(REGISTER,2,n); + else if (i==2) return list3n(REGISTER,3,n); + else if (i==3) return list3n(REGISTER,4,n); else return 0; } } @@ -836,7 +836,7 @@ if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0; i = i+MIN_TMP_REG; } - return list3(REGISTER,i,(int)n); + return list3n(REGISTER,i,n); } @@ -1045,15 +1045,13 @@ int max = n?REG_VAR_USER_MAX-REG_VAR_BASE:REG_VAR_MAX-REG_VAR_BASE; for(i=0;i<max;i++) { j = reg_var_num(i); - if (! regs[j]) { /* ??諭??????法????蓮????蓮?? */ - /* ????曄???????????諭??????諭?????????? */ + if (! regs[j]) { regs[j]=USING_REG; if (i+1>=max_reg_var) max_reg_var=i+1; - /* ????曠???????離?????茱?????茵? */ - return list3(REGISTER,j,(int)n); + return list3n(REGISTER,j,n); } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),n); } #define freg_var_num(i) (FREG_VAR_BASE+i+FREG_OFFSET) @@ -1068,10 +1066,10 @@ regs[j]=USING_REG; /* 吾鴻帥篏帥絎h */ if (i+1>max_reg_var) max_reg_var=i+1; /* 贋茵垩菴 */ - return list3(FREGISTER,j,(int)n); + return list3n(FREGISTER,j,n); } } - return list3(LVAR,new_lvar(SIZE_OF_INT),0); + return list3n(LVAR,new_lvar(SIZE_OF_INT),n); } int @@ -1219,7 +1217,7 @@ control=0; for(p = const_list; p ; p = cadr(p)) { switch(car(p)) { - case GVAR: printf("\t.word\t%s\n",((NMTBL *)caddr(p))->nm); break; + case GVAR: printf("\t.word\t%s\n",(ncaddr(p))->nm); break; case DCONST: case LCONST: case CONST: printf("\t.word\t%d\n",caddr(p)); break; case LABEL: printf("\t.word\t.LC%d\n",caddr(p)); break; @@ -1522,20 +1520,20 @@ void code_gvar(int e1,int reg) { use_int(reg); - code_add(reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1))); + code_add(reg,cadr(e1),get_ptr_cache(ncaddr(e1))); return; } void code_rgvar(int e1,int reg) { use_int(reg); - code_ld("lqd",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),""); + code_ld("lqd",reg,cadr(e1),get_ptr_cache(ncaddr(e1)),""); } void code_crgvar(int e1,int reg,int sign,int sz){ use_int(reg); - code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)), + code_ld(cload(sz,sign),reg,cadr(e1),get_ptr_cache(ncaddr(e1)), cext_at(sz,sign)); cext(sign,sz,reg); } @@ -1769,7 +1767,7 @@ void code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) { use_int(reg); - code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)), + code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache(ncaddr(e1)), cext_at(sz,0)); cext(0,sz,r); printf("\tceqi\t%s, %s, 0\n",register_name(reg), register_name(reg)); @@ -1793,7 +1791,7 @@ void code_cmp_rgvar(int e1,int reg,int label,int cond) { use_int(reg); - code_ld("lqd",reg,cadr(e1),get_ptr_cache((NMTBL*)caddr(e1)),""); + code_ld("lqd",reg,cadr(e1),get_ptr_cache(ncaddr(e1)),""); code_cmp_register(reg,label,cond); } @@ -1825,8 +1823,7 @@ char *s,*crn; //int lb,label; int lb; - //printf("creg:%d\n",creg); - NMTBL *n = (NMTBL *)cadr(e1); + NMTBL *n = ncaddr(e1); if ((lb=attr_value(n,LABEL))) { // already defined return code_label_value(lb,creg) ; @@ -2109,7 +2106,7 @@ arg_on_register = 0; for(args = fnptr->dsp;args;args = cadr(args)) { - n = (NMTBL *)caddr(args); + n = ncaddr(args); tag = n->sc; reg = n->dsp; if (!n||n==&null_nptr) error(REG_ERR); @@ -2119,7 +2116,7 @@ len = size(n->ty); len = round4(len); for(;len>0 && reg_var<MAX_INPUT_REGISTER_VAR;len-=SIZE_OF_INT) { reg_var++; - g_expr_u(assign_expr0(list3(LVAR,offset,0), + g_expr_u(assign_expr0(list3n(LVAR,offset,0), list3(REGISTER,reg_var,0),INT,INT)); arg_on_register += SIZE_OF_INT; free_register(reg); @@ -2130,7 +2127,7 @@ if (dots) { while ((reg = get_input_register_var(reg_var,0,0))) { g_expr_u(assign_expr0( - list3(LVAR,offset,0),reg,INT,INT)); + list3n(LVAR,offset,0),reg,INT,INT)); offset+=SIZE_OF_INT; reg_var++; arg_on_register += SIZE_OF_INT; @@ -2367,35 +2364,35 @@ if (mode==AS_SAVE) { return get_register_var(0); } else if (reg_arg+1>MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_register_var(reg_arg,0,0); } else if (t==LONGLONG||t==ULONGLONG) { if (mode==AS_SAVE) { return get_lregister_var(0); } else if (reg_arg+1>=MAX_INPUT_REGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_lregister_var(reg_arg,0,0); } else if (t==FLOAT) { if (mode==AS_SAVE) { return get_dregister_var(0,0); } else if (freg_arg>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(freg_arg,0,0,0); } else if (t==DOUBLE) { if (mode==AS_SAVE) { return get_dregister_var(0,1); } else if (reg_arg+1>=MAX_INPUT_DREGISTER_VAR) { - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else return get_input_dregister_var(reg_arg,0,0,1); } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) { if (mode==AS_SAVE) { return get_register_var(0); } else - return list3(LVAR,caller_arg_offset_v(nargs),0); + return list3n(LVAR,caller_arg_offset_v(nargs),0); } else { error(-1); return get_register_var(0); @@ -2435,7 +2432,7 @@ arg_assign = 0; e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case // jmp = get_register_var(0); @@ -2549,7 +2546,7 @@ // half register case writes *(sp-1) but it will be Ok. if (max_func_args<4) max_func_args=4; g_expr_u(assign_expr0(list3(REGISTER,4,0), - list3(LVAR,caller_arg_offset_v(3),0),INT,INT)); + list3n(LVAR,caller_arg_offset_v(3),0),INT,INT)); use_input_reg(4,1); } nargs = reg_arg = freg_arg = 0; @@ -2821,7 +2818,7 @@ code_assign_gvar(int e2,int creg,int byte) { use_int(creg); code_ldf(cstore(byte),register_name(creg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2)),byte==SIZE_OF_SHORT?" @ movhi":""); + get_ptr_cache(ncaddr(e2)),byte==SIZE_OF_SHORT?" @ movhi":""); } void @@ -3828,7 +3825,7 @@ { use_float(d,freg); code_ldf(fstore(d),register_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2)),""); + get_ptr_cache(ncaddr(e2)),""); } void @@ -4081,7 +4078,7 @@ { use_float(d,freg); code_ldf(fload(d),register_name(freg),cadr(e2), - get_ptr_cache((NMTBL*)caddr(e2)),""); + get_ptr_cache(ncaddr(e2)),""); } @@ -4460,7 +4457,7 @@ { int r; use_longlong(creg); - r = get_ptr_cache((NMTBL*)caddr(e2)); + r = get_ptr_cache(ncaddr(e2)); #if ENDIAN_L==0 code_ldf(cstore(0),lregister_name_low(creg),cadr(e2),r,""); code_ldf(cstore(0),lregister_name_high(creg),cadr(e2)+SIZE_OF_INT,r,""); @@ -4525,7 +4522,7 @@ use_longlong(creg); crn_h = lregister_name_high(creg); crn_l = lregister_name_low(creg); - r = get_ptr_cache((NMTBL*)caddr(e1)); + r = get_ptr_cache(ncaddr(e1)); #if ENDIAN_L==0 code_ldf("lqd",crn_l,cadr(e1),r,""); //code_ldf("ldr",crn_h,cadr(e1)+SIZE_OF_INT,r,""); @@ -5231,8 +5228,8 @@ } else if (car(rstr)==CONST) { printf("%d",cadr(rstr)); } else if (car(rstr)==FNAME) { - printf("%s",(char*)cadr(rstr)); - } else if (car(rstr)==STRING) { + printf("%s",ncaddr(rstr)->nm); + } else if (car(rstr)==LABEL) { printf(".L%d",cadr(rstr)); } else { error(-1); @@ -5292,13 +5289,13 @@ repl = list3(list2(0,0),repl,clobber); } else if (c=='i') { if (car(e1)==GVAR) { - e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==FNAME) { - e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0); + e1=list3n(FNAME,0,ncaddr(e1)); } else if (car(e1)==STRING) { val = emit_string_label(); - ascii((char*)cadr(e1)); - e1=list3(STRING,val,0); + ascii(ncaddr(e1)->nm); + e1=list3(LABEL,val); } else if (car(e1)==CONST) { } else error(-1); repl = list3(e1,repl,clobber);
--- a/mc-codegen.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-codegen.c Sat Oct 27 13:30:38 2007 +0900 @@ -249,7 +249,7 @@ return ULONGLONG; #endif case FNAME: - code_fname((NMTBL *)(e2),USE_CREG); + code_fname(ncaddr(e1),USE_CREG); return ADDRESS; case LABEL: if (car(e2)!=LVAR) error(-1); @@ -275,7 +275,7 @@ code_string(e1,USE_CREG); return ADDRESS; case FUNCTION: - if (car(e2)==FNAME&&is_code((NMTBL*)cadr(e2))) { + if (car(e2)==FNAME&&is_code(ncaddr(e2))) { // error(FNERR); jump(e1,0); return VOID; @@ -283,7 +283,7 @@ t = function(e1); return t; case JUMP: - if (car(e2)==FNAME&&is_function((NMTBL*)cadr(e2))) { + if (car(e2)==FNAME&&is_function(ncaddr(e2))) { // error(GTERR); return function(e1); } @@ -303,15 +303,15 @@ g_expr0(e1); return t; case PERIOD: - nptr = (NMTBL*)caddr(e1); - type = cadddr(e1); + nptr = ncadddr(e1); + type = caddr(e1); e1 = strop(e2,0); t = type; if (chk) return t; g_expr0(e1); return t; case ARROW: - nptr = (NMTBL*)caddr(e1); - type = cadddr(e1); + nptr = ncadddr(e1); + type = caddr(e1); e1 = strop(e2,1); t = type; if (chk) return t; g_expr0(e1); @@ -958,8 +958,8 @@ error(-1); } n->sc = LVAR; - lvar = list3(LVAR,n->dsp,(int)n); - g_expr_u(assign_expr0(list3(LVAR,n->dsp,(int)n),list3(tag,reg,(int)n),t,t)); + lvar = list3n(LVAR,n->dsp,n); + g_expr_u(assign_expr0(list3n(LVAR,n->dsp,n),list3n(tag,reg,n),t,t)); if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) { free_register(reg); return g_expr0(lvar); @@ -1127,7 +1127,7 @@ if (lsrc) printf("## register overrap in save_target\n"); #endif } - g_expr_u(assign_expr0((e1=list3(LVAR,new_lvar(sz),0)),s,ty,ty)); + g_expr_u(assign_expr0((e1=list3n(LVAR,new_lvar(sz),0)),s,ty,ty)); *target = append5(*target,t,ty,e1,list3(e1,0,sz)); *use=list3(t,*use,e1); } @@ -1348,7 +1348,7 @@ case RGVAR: case SRGVAR : case SURGVAR: - return list3(GVAR,cadr(e1),caddr(e1)); + return list3n(GVAR,cadr(e1),ncaddr(e1)); case LVAR : case CRLVAR : case CURLVAR : @@ -1359,7 +1359,7 @@ case RLVAR: case SRLVAR : case SURLVAR : - return list3(LVAR,cadr(e1),caddr(e1)); + return list3n(LVAR,cadr(e1),ncaddr(e1)); case FREGISTER : case REGISTER: case LREGISTER: @@ -1496,7 +1496,7 @@ e2,ty,ty)); } else { while(car(e2)==RSTRUCT) e2=cadr(e2); - target=list5(list3(LVAR,0,0), target,ty,e2,0); + target=list5(list3n(LVAR,0,0), target,ty,e2,0); } /* keep arg space for register variables */ arg_size += sz; @@ -1536,7 +1536,7 @@ if (contains_p(s0,not_simple_p)) { /* } */ #endif /* complex case */ - g_expr_u(assign_expr0((e4=list3(LVAR,new_lvar(sz),0)),s0,ty,ty)); + g_expr_u(assign_expr0((e4=list3n(LVAR,new_lvar(sz),0)),s0,ty,ty)); use=list3(ty,use,e1); cadddr(e2)=e4; caddddr(e2)=list3(e4,0,sz); @@ -1560,7 +1560,7 @@ #endif caddr(e2) = UNSIGNED; caddddr(e2) = list3( - cadddr(e2)=list3(LVAR,cadr(s0),0), + cadddr(e2)=list3n(LVAR,cadr(s0),0), 0, size_of_int); #if DEBUG_PARALLEL_ASSIGN if (lsrc)printf("## div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),size_of_int); @@ -1575,9 +1575,9 @@ default: caddr(e2) = UNSIGNED; r = size_of_int; } if (e4==size_of_int) e3=cadr(e2); - car(e2) = list3(LVAR,cadr(t0)+e4,0); + car(e2) = list3n(LVAR,cadr(t0)+e4,0); caddddr(e2) = list3( - cadddr(e2) = list3(LVAR,cadr(s0)+e4,0),0, r); + cadddr(e2) = list3n(LVAR,cadr(s0)+e4,0),0, r); e4 += r; #if DEBUG_PARALLEL_ASSIGN if (lsrc)printf("## div 1 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),r); @@ -1599,7 +1599,7 @@ /* compute jump address */ e2 = cadr(e1); if (car(e2) == FNAME) { - code0=(NMTBL *)cadr(e2); + code0=ncaddr(e2); // if (!is_code(code0)) { error(TYERR); return; } } else { /* indirect */ g_expr(e2); @@ -1749,11 +1749,11 @@ switch (car(cadr(e1))) { case GVAR: return(list2(ADDRESS, - list3(GVAR,cadr(cadr(e1))+cadr(e),caddr(cadr(e1))))); + list3n(GVAR,cadr(cadr(e1))+cadr(e),ncaddr(cadr(e1))))); case LVAR: return(list2(ADDRESS, - list3(car(cadr(e1)),cadr(cadr(e1))+cadr(e), - caddr(cadr(e1))))); + list3n(LVAR,cadr(cadr(e1))+cadr(e), + ncaddr(cadr(e1))))); case INDIRECT: case PERIOD: case ARROW: @@ -1762,11 +1762,11 @@ error(-1); // ? } } else if(car(e1)==GVAR) { - return(list3(GVAR,cadr(e1)+cadr(e),caddr(e1))); + return(list3n(GVAR,cadr(e1)+cadr(e),ncaddr(e1))); } else if(car(e1)==LVAR) { - return(list3(LVAR,cadr(e1)+cadr(e),caddr(e1))); + return(list3n(LVAR,cadr(e1)+cadr(e),ncaddr(e1))); // } else if(car(e1)==RLVAR) { this is not correct -// return(list3(RLVAR,cadr(e1)+cadr(e),caddr(e1))); +// return(list3n(RLVAR,cadr(e1)+cadr(e),ncaddr(e1))); } return e0; } @@ -1859,7 +1859,7 @@ if (car(cadr(e4))==STRING) code_string(cadr(e4),reg); else code_gvar(cadr(e4),reg); return; - case FNAME: code_fname((NMTBL*)cadr(e4),reg); return; + case FNAME: code_fname(ncaddr(e4),reg); return; case STRING: code_string(e4,reg); return; default: error(-1); } @@ -2569,7 +2569,7 @@ // e2 が複雑な式でないと却ってだめなこともある // register が取れれば常に有効か? // たぶん、i386 の時には有効だったんだろうなぁ。 - int n = list3(LVAR,new_lvar(size_of_int),0); // get register var? + int n = list3n(LVAR,new_lvar(size_of_int),0); // get register var? g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT)); g_expr0(assign_expr0(rvalue_t(n,INT), list3(op,rvalue_t(list2(INDIRECT,rvalue_t(n,INT)),t),e3),t,t)); @@ -2674,7 +2674,7 @@ if (!code_lassop_p) { /* new = &e2 */ /* *new = *new op e3 */ - int n = list3(LVAR,new_lvar(size_of_int),0); + int n = list3n(LVAR,new_lvar(size_of_int),0); g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT)); g_expr0(assign_expr0(rvalue_t(n,INT), list3(op,rvalue_t(list2(INDIRECT,rvalue_t(n,INT)),t),e3),t,t)); @@ -3050,7 +3050,7 @@ case FCONST: case DCONST: e=dlist2(car(e),dcadr(e)); break; case LCONST: e=llist2(car(e),lcadr(e)); break; - case STRING: e=list3(car(e),cadr(e),caddr(e)); break; + case STRING: e=list3n(car(e),cadr(e),ncaddr(e)); break; case STRUCT: // for udpcl e=glist3(car(e),copy_expr(cadr(e)),copy_expr(caddr(e))); break; case ARRAY: @@ -3098,9 +3098,11 @@ case LVAR: case RLVAR: case URLVAR: case REGISTER: case FREGISTER: case DREGISTER: case LREGISTER: - case STRING: + case FNAME: case IVAR: case RIVAR: - e = glist3(car(e),cadr(e),caddr(e)); break; + e = glist3n(car(e),cadr(e),ncaddr(e)); break; + case STRING: + e = glist3n(car(e),cadr(e),ncaddr(e)); break; case CONST: switch(car(e)) { case CONST: @@ -3114,7 +3116,6 @@ } break; case LCALL: - case FNAME: case LABEL: e = glist2(car(e),cadr(e)); break; case DECL: @@ -3475,7 +3476,7 @@ if (n->attr) { if ((e=attr_value(n,ASM))) { if (car(e)!=STRING) error(-1); - str = (NMTBL*)caddr(e); + str = ncaddr(e); return str->nm; } } @@ -3568,17 +3569,17 @@ return; case ADDRESS: if (car(cadr(e))==GVAR) - emit_address(((NMTBL *)caddr(cadr(e)))->nm,cadr(cadr(e))); + emit_address((ncaddr(cadr(e)))->nm,cadr(cadr(e))); else error(INERR); return; case FNAME: - emit_address(((NMTBL *)cadr(e))->nm,0); + emit_address((ncaddr(e))->nm,0); return; case GVAR: - emit_address(((NMTBL *)caddr(e))->nm,0); + emit_address((ncaddr(e))->nm,0); return; case STRING: - emit_string(((NMTBL *)cadr(e))->nm,n->ty); + emit_string((ncaddr(e))->nm,n->ty); return; } // if (lsrc)fprintf(stderr,"## type= %d\n",t); @@ -3654,7 +3655,7 @@ if (car(init)!=DECL_DATA_FIELD) { error(-1); } - n = (NMTBL*)cadddr(init); + n = ncadddr(init); type1 = search_struct_type(type0,n->nm,&foffset); e = caddr(init); if (car(e)!=DECL_DATA) error(-1); @@ -3741,9 +3742,9 @@ nptr0->attr = 0; nptr0->ty = t; nptr0->dsp = new_lvar_align(sz,16); - e1 = list3(RSTRUCT,list3( - nptr0->sc,nptr0->dsp,(int)nptr0),sz); - v = list3(nptr0->sc,nptr0->dsp,(int)nptr0); + e1 = list3(RSTRUCT,list3n( + nptr0->sc,nptr0->dsp,nptr0),sz); + v = list3n(nptr0->sc,nptr0->dsp,nptr0); } else { e1 = 0; } @@ -3999,8 +4000,8 @@ def(&str_ret,0); args = sargs + (inmode?1:size_of_int); struct_return = inmode - ?list3(list3(IVAR,str_ret.dsp,0),sz,type) - :list3(list3(LVAR,str_ret.dsp,0),sz,type); + ?list3(list3n(IVAR,str_ret.dsp,0),sz,type) + :list3(list3n(LVAR,str_ret.dsp,0),sz,type); caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty)); } type = type_save; @@ -4224,14 +4225,14 @@ if (!has_attr(n,VOLATILE)) return c; } - return(list3(RGVAR+op,cadr(e),caddr(e))); + return(list3n(RGVAR+op,cadr(e),ncaddr(e))); case LVAR: n = (NMTBL*)caddr(e); if (cadr(e)==0 && n && (c=attr_value(n,KONST))) { if (!has_attr(n,VOLATILE)) return c; } - return(list3(RLVAR+op,cadr(e),caddr(e))); + return(list3n(RLVAR+op,cadr(e),ncaddr(e))); case INDIRECT: return(indirect(RINDIRECT+op,cadr(e),type0)); case IVAR: case ARRAY: case PERIOD: case ARROW: @@ -4336,7 +4337,7 @@ int e1 = 0; if (inmode || chk) { - e1 = list4(ind?ARROW:PERIOD,e,(int)nptr,type); + e1 = list4n(ind?ARROW:PERIOD,e,type,nptr); } if (ind) e = indop(rvalue(e)); type0 = type_value(type); @@ -4357,10 +4358,10 @@ switch(car(e)) { case GVAR: // e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp))); - e=list3(GVAR,cadr(e)+dsp,caddr(e)); + e=list3n(GVAR,cadr(e)+dsp,ncaddr(e)); break; case LVAR: - e=list3(LVAR,cadr(e) + dsp,0); /* may have attribute */ + e=list3n(LVAR,cadr(e) + dsp,ncaddr(e)); /* may have attribute */ break; case INDIRECT: e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp))); @@ -4913,7 +4914,7 @@ // compatible(cadr(t),cadr(type)); // ではあかんの? if (car(e)==FNAME) { - NMTBL *n = (NMTBL*)cadr(e); + NMTBL *n = ncaddr(e); int targ0 = caddr(cadr(t)); int targ1 = caddr(n->ty); if (is_function(n)) { @@ -5063,11 +5064,11 @@ if (lo) { #if LONGLONG_CODE if (post) { - n1 = list3(LVAR,new_lvar(size_of_longlong),0); + n1 = list3n(LVAR,new_lvar(size_of_longlong),0); code_lassign_lvar(cadr(n1),USE_CREG); } if (!code_lassop_p) { - n2 = list3(LVAR,new_lvar(size_of_longlong),0); + n2 = list3n(LVAR,new_lvar(size_of_longlong),0); code_lassign_lvar(cadr(n2),USE_CREG); lassign(list4(LASSOP,n2,e3,op+LOP)); } else { @@ -5080,7 +5081,7 @@ #endif } else { if (post) { - n1 = list3(LVAR,new_lvar(size_of_int),0); + n1 = list3n(LVAR,new_lvar(size_of_int),0); code_assign_lvar(cadr(n1),USE_CREG,0); } emit_push();
--- a/mc-inline.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-inline.c Sat Oct 27 13:30:38 2007 +0900 @@ -450,7 +450,7 @@ st_comment(int e1){ glineno++; printf("## %d ",glineno); - gen_comment(plinebuf=(char *)caddr(e1)); + gen_comment(plinebuf=(char *)ncaddr(e1)); } /* @@ -812,7 +812,7 @@ if (car(init)!=DECL_DATA_FIELD) { error(-1); } - n = (NMTBL*)cadddr(init); + n = ncadddr(init); type1 = search_struct_type(type0,n->nm,&foffset); e = caddr(init); if (car(e)!=DECL_DATA) error(-1); @@ -947,7 +947,7 @@ default: if (mode==STADECL) { if (init) { - v = list3(GVAR,0,(int)n); + v = list3n(GVAR,0,n); gen_decl_data(init,v); } stmode = sstmode; @@ -956,9 +956,9 @@ return pexpr(cadr(e)); } if (n->sc==FLABEL) - v = list3(LVAR,fwdlabel(),(int)n); + v = list3n(LVAR,fwdlabel(),n); else - v = list3(LVAR,new_lvar(size(n->ty)),(int)n); + v = list3n(LVAR,new_lvar(size(n->ty)),n); } if (n->sc!=FLABEL) inline_lvars = glist2(v,inline_lvars); @@ -1177,7 +1177,7 @@ p_comment(int e) { glineno++; - return list3(ST_COMMENT,pexpr(cadr(e)),caddr(e)); + return list3n(ST_COMMENT,pexpr(cadr(e)),ncaddr(e)); } static int @@ -1243,13 +1243,13 @@ return indop(e1); case PERIOD: e2 = pexpr(e2); - nptr = (NMTBL*)caddr(e1); - type = cadddr(e1); + nptr = ncadddr(e1); + type = caddr(e1); return strop(e2,0); case ARROW: e2 = pexpr(e2); - nptr = (NMTBL*)caddr(e1); - type = cadddr(e1); + nptr = ncadddr(e1); + type = caddr(e1); return strop(e2,1); case INLINE: return p_inline(e1); @@ -1464,8 +1464,9 @@ return list3(DECL_DATA,pexpr(e2),caddr(e1)); case DECL_DATA_LIST: case DECL_DATA_ARRAY: + return list4(car(e1),pexpr(e2),pexpr(caddr(e1)),cadddr(e1)); case DECL_DATA_FIELD: - return list4(car(e1),pexpr(e2),pexpr(caddr(e1)),cadddr(e1)); + return list4n(car(e1),pexpr(e2),pexpr(caddr(e1)),ncadddr(e1)); case ST_DECL: return p_decl(e1); case ST_IF: return p_if(e1); case ST_DO: return p_do(e1); @@ -1508,7 +1509,7 @@ } } // we need real local variable for this inline - arg = heap[pdisp+narg]=list3(LVAR,new_lvar(size(t)),(int)anptr); + arg = heap[pdisp+narg]=list3n(LVAR,new_lvar(size(t)),anptr); inline_lvars = glist2(arg,inline_lvars); evals=list2(assign_expr0(arg,e4,anptr->ty,t),evals); return evals; @@ -1619,7 +1620,7 @@ int slfree; // int slreg_count=lreg_count; - NMTBL *n = (NMTBL*)cadr(cadr(e)); + NMTBL *n = (NMTBL*)ncaddr(cadr(e)); int e1 = attr_value(n,INLINE); int parse = car(e1); // inline parse tree int dots;
--- a/mc-macro.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-macro.c Sat Oct 27 13:30:38 2007 +0900 @@ -403,7 +403,7 @@ p = st_cheap->ptr; sprintf(num,"%d: ",lineno); - parse = list3(ST_COMMENT,parse,(int)p); + parse = list3n(ST_COMMENT,parse,(NMTBL*)p); // should contain file name c = 0; while((*st_cheap->ptr = num[c++])) @@ -414,7 +414,7 @@ *st_cheap->ptr = 0; st_cheap = increment_cheap(st_cheap,&p); p = st_cheap->ptr; - // parse = list3(ST_COMMENT,parse,(int)p); + // parse = list3n(ST_COMMENT,parse,(NMTBL*)p); sprintf(num,"%d: ",lineno); c = 0; while((*cheap->ptr = num[c++]))
--- a/mc-parse.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-parse.c Sat Oct 27 13:30:38 2007 +0900 @@ -936,7 +936,7 @@ int v; conv->return_type_(type,n,sd); n = def(n,ctmode); - v = list3(n->sc,n->dsp,(int)n); + v = list3n(n->sc,n->dsp,n); if (sym==ASS && n!=&null_nptr) { conv->op_(sym); init = decl_data(type,v,0,0); data_closing(v); @@ -958,7 +958,7 @@ } conv->return_type_(type,n,1); def(n,ctmode); - v = list3(n->sc,n->dsp,(int)n); + v = list3n(n->sc,n->dsp,n); if (sym==ASS && n!=&null_nptr) { conv->op_(sym); init = decl_data(type,v,0,0);data_closing(v); @@ -986,7 +986,7 @@ // int r __asm("r0") getsym(ATTRIBUTE); if (sym==STRING) { - attribute = list3(ASM,attribute,(int)nptr); + attribute = list3n(ASM,attribute,nptr); } mode = smode; checksym(RPAR); @@ -996,10 +996,10 @@ if (sym==LPAR) { attributes(0); } else if (sym==IDENT) { - attribute = list3(IDENT,attribute,(int)nptr); + attribute = list3n(IDENT,attribute,nptr); getsym(ATTRIBUTE); } else if (sym==STRING) { - attribute = list3(STRING,attribute,(int)nptr); + attribute = list3n(STRING,attribute,nptr); getsym(ATTRIBUTE); } else { attribute = list3(sym,attribute,0); @@ -1582,7 +1582,7 @@ if (sym==ASS) { if (inmode) { int offset1 = decl_data(t2,v,0,0); - offset = list4(DECL_DATA_FIELD,offset,offset1,(int)nptr1); + offset = list4n(DECL_DATA_FIELD,offset,offset1,nptr1); } else { decl_data(t2,v,offset+foffset,0); } @@ -1621,7 +1621,7 @@ static void local_struct_static(int v) { - NMTBL *nptr0,*n = (NMTBL*)caddr(v); + NMTBL *nptr0,*n = ncaddr(v); int sz = size(type),offset=0; int smode = mode; int v0; @@ -1638,7 +1638,7 @@ nptr0=new_static_name("__lstruct",'_'); def(nptr0,0); mode=smode; - v0 = list3(GVAR,0,(int)nptr0); + v0 = list3n(GVAR,0,nptr0); //nptr0->next = local_static_list; local_static_list = nptr0; //nptr0->sc = STATIC; //nptr0->ty = t = type; @@ -1648,9 +1648,9 @@ list4(STASS, inmode?( offset? - list3(ADD,list3(IVAR,n->dsp,0),list2(CONST,offset)): - list3(IVAR,n->dsp,0)): - list3(LVAR,n->dsp+offset,0), + list3(ADD,list3n(IVAR,n->dsp,0),list2(CONST,offset)): + list3n(IVAR,n->dsp,0)): + list3n(LVAR,n->dsp+offset,0), list3(RSTRUCT,v0,sz),sz), init_vars); mode=STADECL; @@ -1671,7 +1671,7 @@ list item list4(DECL_DATA_LIST,next,value,type); // coarsed later list item with struct tag or array tag - list4(DECL_DATA_FIELD,next,decl_data,(int)nptr); + list4n(DECL_DATA_FIELD,next,decl_data,(NMTBL*)nptr); data initializer (array or struct) // data type for field list3(DECL_DATA,value,type); @@ -1683,7 +1683,7 @@ { int t0,t1=0,e,i,mode_save,lc=0; int offset0; - NMTBL *n = (NMTBL*)caddr(v); + NMTBL *n = ncaddr(v); emit_init_vars(); conv->decl_data_(); @@ -1919,7 +1919,7 @@ if (nptr0->sc == EMPTY) nptr0=gnptr0; if (nptr0->sc!=TAG && nptr0->sc != EMPTY) error(DCERR); nptr0->sc = TAG; - nptr0->ty = list4(s,-1,0,(int)nptr0); + nptr0->ty = list4n(s,-1,0,nptr0); sdecl_field(smode); caddr(nptr0->ty)=fields; cadr((type0 = nptr0->ty))=disp; @@ -1935,13 +1935,13 @@ disp = cadr(nptr0->ty); } conv->comment_(' '); - type0 = glist4(s,disp,fields,(int)nptr0); + type0 = glist4n(s,disp,fields,nptr0); } } else if(sym==LC) { /* no tag name */ if (sdecl_f) conv->lc_(); sdecl_field(smode); - type0 = glist4(s,disp,fields,0); // mode is now previous mode + type0 = glist4n(s,disp,fields,0); // mode is now previous mode } else error(DCERR); @@ -2067,7 +2067,7 @@ /* reverse all argument offset (with size) */ arglist = fnptr->dsp; for(t=arglist;t;t=cadr(t)) { - n=(NMTBL *)caddr(t); + n=ncaddr(t); if(n->sc==LVAR) n->dsp = -n->dsp-cadddr(t); } @@ -2231,7 +2231,7 @@ int sz ; n1 = get_nptr(); - a = (NMTBL*)caddr(arg); + a = ncaddr(arg); n1->ty = a->ty; n1->nm = a->nm; n1->sc = a->sc==IVAR?LVAR:a->sc; @@ -2302,13 +2302,13 @@ // make calling argments for(args=fnptr->dsp,cargs=0;args;args=cadr(args)) { - a = (NMTBL*)caddr(args); + a = ncaddr(args); // make call function argment for gen_inline - e=list3(a->sc==IVAR?LVAR:a->sc,a->dsp,(int)a); + e=list3n(a->sc==IVAR?LVAR:a->sc,a->dsp,a); cargs = list3(e,cargs,a->ty); } // build inline function call - e = list4(INLINE,list2(FNAME,(int)n),cargs, + e = list4(INLINE,list3n(FNAME,0,n),cargs, list3(car(fnptr->ty),cadr(fnptr->ty),caddr(fnptr->ty))); typedefed=0; @@ -2367,7 +2367,7 @@ /* reverse all argument offset (with size) */ arg = fnptr->dsp; for(t=arg;t;t=cadr(t)) { - n1=(NMTBL *)caddr(t); + n1=ncaddr(t); if(n1->sc==LVAR) n1->dsp = -n1->dsp-cadddr(t); } @@ -2380,13 +2380,13 @@ // make calling argments for(arg=fnptr->dsp,cargs=0;arg;arg=cadr(arg)) { - a = (NMTBL*)caddr(arg); + a = ncaddr(arg); // make call function argment for gen_inline - e=list3(a->sc==IVAR?LVAR:a->sc,a->dsp,(int)a); + e=list3n(a->sc==IVAR?LVAR:a->sc,a->dsp,a); cargs = list3(e,cargs,a->ty); } // build inline function call - e = list4(INLINE,list2(FNAME,(int)n),cargs, + e = list4(INLINE,list3n(FNAME,0,n),cargs, list3(car(fnptr->ty),cadr(fnptr->ty),caddr(fnptr->ty))); typedefed=0; @@ -3165,7 +3165,7 @@ NMTBL *nptr0; conv->jump_(env); if (car(e2) == FNAME) { - nptr0=(NMTBL *)cadr(e2); + nptr0=ncaddr(e2); if (nptr0->sc==EMPTY) nptr0->sc = EXTRN1; else if(nptr0->sc==FUNCTION) @@ -3213,7 +3213,7 @@ } if (t==FNAME) { /* classical goto */ - nptr0 = (NMTBL *)cadr(e1); + nptr0 = ncaddr(e1); t = nptr0->sc; if (t==EMPTY||t==EXTRN1||t==EXTRN) { // error check? @@ -3226,7 +3226,7 @@ error(STERR); } if (!inmode) gen_jmp(nptr0->dsp); - else parse = list3(ST_GOTO,parse,list3(IVAR,nptr0->dsp,(int)nptr0)); + else parse = list3(ST_GOTO,parse,list3n(IVAR,nptr0->dsp,nptr0)); control=0; conv->sm_(); checksym(SM); @@ -3260,7 +3260,7 @@ // already used by goto with fwdlabel // or this is a local label defined by __label__ if (!inmode) fwddef(nptr->dsp); - else parse = list3(ST_LABEL,parse,list3(IVAR,nptr->dsp,(int)nptr)); + else parse = list3(ST_LABEL,parse,list3n(IVAR,nptr->dsp,nptr)); } else if(nptr->sc != EMPTY && nptr->sc != EXTRN1) { error(TYERR); // duplicate label } else { @@ -3271,7 +3271,7 @@ if (!inmode) nptr1->dsp = backdef(); else { nptr1->dsp = --disp; - parse = list3(ST_LABEL,parse,list3(IVAR,nptr1->dsp,(int)nptr1)); + parse = list3(ST_LABEL,parse,list3n(IVAR,nptr1->dsp,nptr1)); } } conv->label_(); @@ -3296,7 +3296,7 @@ checksym(LPAR); // asm string if (sym!=STRING) error(DCERR); - asm0=list3(STRING,(int)nptr,nptr->dsp); + asm0=list3n(STRING,nptr->dsp,nptr); getsym(0); if (sym!=COLON) { #if 0 @@ -3312,7 +3312,7 @@ getsym(0); if (sym==COLON) break; if (sym!=STRING) error(DCERR); - out=list2(list3(STRING,(int)nptr,nptr->dsp),out); + out=list2(list3n(STRING,nptr->dsp,nptr),out); getsym(0); e1=list2(e=expr1(),e1); lcheck(e); @@ -3323,7 +3323,7 @@ getsym(0); if (sym==COLON) break; if (sym!=STRING) error(DCERR); - input=list2(list3(STRING,(int)nptr,nptr->dsp),input); + input=list2(list3n(STRING,nptr->dsp,nptr),input); getsym(0); e1=list2(expr1(),e1); } while(sym==COMMA); @@ -3333,7 +3333,7 @@ // option string getsym(0); if (sym!=STRING) error(DCERR); - opt=list2(list3(STRING,(int)nptr,nptr->dsp),opt); + opt=list2(list3n(STRING,nptr->dsp,nptr),opt); getsym(0); } while(sym==COMMA); } @@ -3686,7 +3686,7 @@ e=list2(ADDRESS,e); break; case IVAR: - if ((nptr1=(NMTBL*)caddr(e))) { + if ((nptr1=ncaddr(e))) { set_attr(nptr1,HAS_ADDRESS,1); } e=list2(ADDRESS,e); @@ -3882,7 +3882,7 @@ if (type!=FNAME) { error(TYERR); } - nptr1 = (NMTBL *)cadr(e); + nptr1 = ncaddr(e); #else nptr1 = nptr; getsym(0); @@ -3900,7 +3900,7 @@ type = list2(POINTER,VOID); // can be global?! return list2(LABEL, - list3(inmode==INLINE?IVAR:LVAR,nptr1->dsp,(int)nptr1)); + list3n(inmode==INLINE?IVAR:LVAR,nptr1->dsp,nptr1)); } e=expr14(); @@ -3963,7 +3963,7 @@ fname(NMTBL *nptr) { int e1; - e1=list2(FNAME,(int)nptr); + e1=list3n(FNAME,0,nptr); if (nptr->ty>0) { // should be function or code // type=list3(FUNCTION,type,arg); type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty)); @@ -3994,7 +3994,7 @@ return fname(nptr); } case GVAR: - e1=list3(GVAR,0,(int)nptr); + e1=list3n(GVAR,0,nptr); type=nptr->ty; getsym(0); extrn_use(nptr); @@ -4010,7 +4010,7 @@ case DREGISTER: case FREGISTER: case REGISTER: - e1=list3(nptr->sc,nptr->dsp,(int)nptr); + e1=list3n(nptr->sc,nptr->dsp,nptr); type=nptr->ty; getsym(0); break; @@ -4025,7 +4025,7 @@ nptr->sc = EXTRN1; nptr->ty= type; extrn_use(nptr); - e1=expr15(list2(FNAME,(int)nptr)); + e1=expr15(list3n(FNAME,0,nptr)); break; } else if (in_macro_if) { type = INT; @@ -4040,7 +4040,7 @@ def(nptr,0); nptr->sc = EXTRN1; mode = smode; - e1=list2(FNAME,(int)nptr); + e1=list3n(FNAME,0,nptr); // type=list3(nptr->sc,nptr->ty,nptr->dsp); break; } @@ -4049,7 +4049,7 @@ break; case STRING: conv-> string_(nptr->nm,nptr->dsp); - e1=list3(STRING,(int)nptr,nptr->dsp); + e1=list3n(STRING,nptr->dsp,nptr); type=list3(ARRAY,CHAR,nptr->dsp); getsym(0); break; @@ -4090,7 +4090,7 @@ // code (*)(return_type); type=list2(POINTER,list3(CODE,VOID,cadr(fnptr->ty))); // type arg - e1=list2(RETURN,(int)fnptr); + e1=list3n(RETURN,0,fnptr); getsym(0); break; case DEFINED: @@ -4116,14 +4116,14 @@ // return current file name nptr=get_name(filep->name0,0,0); type=list3(ARRAY,CHAR,nptr->dsp); - e1=list3(STRING,(int)nptr,nptr->dsp); + e1=list3n(STRING,nptr->dsp,nptr); getsym(0); break; case C_FUNCTION: // return current function name nptr=get_name(fnptr->nm,0,0); type=list3(ARRAY,CHAR,nptr->dsp); - e1=list3(STRING,(int)nptr,nptr->dsp); + e1=list3n(STRING,nptr->dsp,nptr); getsym(0); break; case C_LINE: @@ -4158,7 +4158,7 @@ def(nptr0,0); e1 = size(type); mode = smode; - e2 = list3(GVAR,0,(int)nptr0); + e2 = list3n(GVAR,0,nptr0); e3 = decl_data_field(type,e2,0); if (!inmode) { e1 = list3(RSTRUCT,e2,e1); @@ -4178,7 +4178,7 @@ type = nptr0->ty = t; e1 = size(type); def(nptr0,0); - e2 = list3(nptr0->sc,nptr0->dsp,(int)nptr0); + e2 = list3n(nptr0->sc,nptr0->dsp,nptr0); #if LOCAL_STRUCT_INIT_STATIC local_struct_static(e2); #else @@ -4282,7 +4282,7 @@ } else break; } if(car(e1)==FNAME) { - set_attr((NMTBL*)cadr(e1),FNAME,1); + set_attr(ncaddr(e1),FNAME,1); type=list2(POINTER,type); } return e1; @@ -4411,7 +4411,7 @@ NMTBL *tmp = make_tmp_struct(); - e = list3(inmode?IVAR:LVAR,tmp->dsp,(int)tmp); + e = list3n(inmode?IVAR:LVAR,tmp->dsp,tmp); /* pass the pointer as an argument */ /* this is recognized by called function declaration */ @@ -4421,7 +4421,7 @@ } if (car(e1)==FNAME) { // recursive inline is not allowed - if ((NMTBL *)(cadr(e1))!=fnptr && is_inline((NMTBL *)cadr(e1))) { + if ((NMTBL *)(cadr(e1))!=fnptr && is_inline(ncaddr(e1))) { return list4(INLINE,e1,arglist,ftype); } } @@ -5168,12 +5168,12 @@ for(ns=hash->dsp;ns;ns=cadr(ns)) { if (car(ns)==sc) { - return (NMTBL*)caddr(ns); + return ncaddr(ns); } } if (ns==0) { n = get_nptr(); - hash->dsp = glist3(sc,hash->dsp,(int)n); + hash->dsp = glist3n(sc,hash->dsp,n); } n->nm = hash->nm; n->sc = EMPTY; @@ -5207,8 +5207,8 @@ for(ns=nlist->dsp;ns;ns=cadr(ns)) { if (car(ns)==sc /* && nptr1->sc!=EMPTY */) { // memorize previous nptr for this name for leave_scope - car(current_scope) = glist3(ns,car(current_scope),(int)nptr1); - caddr(ns) = (int)(nptr1 = get_nptr()); + car(current_scope) = glist3n(ns,car(current_scope),nptr1); + ncaddr(ns) = nptr1 = get_nptr(); nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; } } @@ -5224,8 +5224,8 @@ for(ns=nlist->dsp;ns;ns=cadr(ns)) { // memorize previous nptr for this name for leave_scope if (car(ns)==sc /* && nptr1->sc!=EMPTY */) { - car(scope) = glist3(ns,car(scope),(int)nptr1); - caddr(ns) = (int)(nptr1 = get_nptr()); + car(scope) = glist3n(ns,car(scope),nptr1); + ncaddr(ns) = nptr1 = get_nptr(); nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0; } } @@ -5247,12 +5247,12 @@ // restore nptr of current scope name to the previous nptr scope = car(current_scope); while(scope) { - ns = (NMTBL *)caddr(car(scope)); + ns = ncaddr(car(scope)); switch(ns->sc) { case GVAR: case STATIC: case IVAR: break; default: if (!inmode) free_nptr(ns); } - caddr(car(scope)) = caddr(scope); + ncaddr(car(scope)) = ncaddr(scope); next = cadr(scope); free_glist2(scope); // will destroy cadr scope = next; @@ -5446,6 +5446,20 @@ } extern int +list3n(int e1, int e2, NMTBL *e3) +{ + int e; + + e=getfree(2+(sizeof(void*)/sizeof(int))); + heap[e]=e1; + heap[e+1]=e2; + vcaddr(e) = e3; + + return e; +} + + +extern int list4(int e1, int e2, int e3, int e4) { int e; @@ -5459,6 +5473,19 @@ } extern int +list4n(int e1, int e2, int e3, NMTBL * e4) +{ + int e; + + e=getfree(3+(sizeof(void*)/sizeof(int))); + heap[e]=e1; + heap[e+1]=e2; + heap[e+2]=e3; + ncadddr(e) = e4; + return e; +} + +extern int list5(int e1, int e2, int e3, int e4,int e5) { int e; @@ -5547,6 +5574,21 @@ } extern int +glist3n(int e1,int e2,NMTBL *e3) +{ + int ret; + ret = gfree; + gfree+=(2+sizeof(void*)/sizeof(int)) ; + heap[ret]=e1; + heap[ret+1]=e2; + ncaddr(ret) = e3; + // heap[ret+2]=e3; + if(lfree<gfree) error(HPERR); + return ret; +} + + +extern int glist4(int e1,int e2,int e3,int e4) { int ret; @@ -5561,6 +5603,20 @@ } extern int +glist4n(int e1,int e2,int e3,NMTBL * e4) +{ + int ret; + ret = gfree; + gfree+=(3+sizeof(void*)/sizeof(int)) ; + heap[ret]=e1; + heap[ret+1]=e2; + heap[ret+2]=e3; + ncadddr(ret) = e4; + if(lfree<gfree) error(HPERR); + return ret; +} + +extern int glist5(int e1,int e2,int e3,int e4,int e5) { int ret; @@ -5578,6 +5634,7 @@ extern void free_glist3(int e1) { + /* list3n is larger than length 3, but it's Ok */ if (e1>gfree) return; /* freeing local heap */ if (e1==gfree) { gfree-=3; @@ -5588,7 +5645,7 @@ } extern void -free_glist3_a(int e1) // free chain of glist3 +free_glist3_a(int e1) // free all chain of glist3 { int next; while(e1) { @@ -5862,10 +5919,17 @@ extern int c2(int d) { fprintf(stderr,"heap[%d]=",d);return caddr(d); } 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); } + /* end */
--- a/mc-tree.c Thu Oct 25 13:58:42 2007 +0900 +++ b/mc-tree.c Sat Oct 27 13:30:38 2007 +0900 @@ -308,7 +308,7 @@ if((tags=caddr(type))) { fprintf(out,"{"); while(tags) { - n=(NMTBL*)caddr(tags); + n=ncaddr(tags); type_print(car(tags),n,out); fprintf(out,";"); tags = cadr(tags); @@ -494,7 +494,7 @@ case LVAR: case RLVAR: case URLVAR: - if ((nptr = (NMTBL*)caddr(e))) { + if ((nptr = ncaddr(e))) { fprintf(vout,"%s",nptr->nm); } else { // anonymous variable @@ -504,7 +504,7 @@ case GVAR: case RGVAR: case URGVAR: - if ((nptr = (NMTBL*)caddr(e))) { + if ((nptr = ncaddr(e))) { fprintf(vout,"%s",nptr->nm); } else { // anonymous variable @@ -517,7 +517,7 @@ } break; case REGISTER: - if ((nptr = (NMTBL*)caddr(e))) { + if ((nptr = ncaddr(e))) { fprintf(vout,"%s",nptr->nm); } else { // anonymous register variable @@ -552,7 +552,7 @@ case STRING: { int c; char *s; int i; - nptr = (NMTBL*)cadr(e); s = nptr->nm;i=nptr->dsp; + nptr = ncaddr(e); s = nptr->nm;i=nptr->dsp; fprintf(vout,"\""); while(--i>0) { c=*s++; @@ -576,12 +576,12 @@ break; case PERIOD: print_expr(cadr(e),vout); - n = (NMTBL*)caddr(e); + n = ncaddr(e); fprintf(vout,".%s",n->nm); break; case ARROW: print_expr(cadr(e),vout); - n = (NMTBL*)caddr(e); + n = ncaddr(e); fprintf(vout,"->%s",n->nm); break; case INDIRECT: @@ -591,7 +591,7 @@ print_expr(cadr(e),vout); break; case FNAME: - n = (NMTBL*)cadr(e); + n = ncaddr(e); fprintf(vout,"%s",n->nm); break; case FUNCTION: @@ -638,7 +638,7 @@ static void print_decl(int e, FILE *vout) { - NMTBL *n = (NMTBL*)caddr(e); + NMTBL *n = ncaddr(e); int e1 = cadddr(e); // int mode = car(e1); int stmode = cadr(e1); @@ -713,14 +713,14 @@ case ST_ASM: fprintf(vout,"__asm__ "); break; case ST_LABEL: - n = (NMTBL*)(caddr(caddr(e))); + n = ncaddr(caddr(e)); fprintf(vout,"%s:", n->nm); break; case ST_OP: e1 = caddr(e); print_expr(list3(cadr(e),car(e1),cadr(e1)),vout); break; case ST_COMMENT: - fprintf(vout,"\n# %s\n",(char*)caddr(e)); + fprintf(vout,"\n# %s\n",vcaddr(e)); break; default: fprintf(stderr,"Unknown Statement ID %d\n",car(e)); @@ -736,7 +736,7 @@ e2 = cadr(e1); if (car(e2) == FNAME) { - fn=(NMTBL *)cadr(e2); + fn=ncaddr(e2); fprintf(vout,"%s",fn->nm); } else { if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case
--- a/mc.h Thu Oct 25 13:58:42 2007 +0900 +++ b/mc.h Sat Oct 27 13:30:38 2007 +0900 @@ -561,7 +561,11 @@ #endif extern int list2(int e1, int e2); extern int list3(int e1, int e2, int e3); +extern int list3n(int e1, int e2, NMTBL *e3); +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 glist4n(int e1, int e2, int e3,NMTBL *e4); extern int list5(int e1, int e2, int e3,int e4,int e5); extern int length(int e1); extern int getfree(int size); @@ -595,6 +599,18 @@ #define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4]) +#define ncaddr(e) (*(NMTBL**)&heap[((int)(e))+2]) + +#define ncadddr(e) (*(NMTBL**)&heap[((int)(e))+3]) + +#define vcaddr(e) (*(void**)&heap[((int)(e))+2]) + +#define vcadddr(e) (*(void**)&heap[((int)(e))+3]) + +#define pcaddr(e) (*(int**)&heap[((int)(e))+2]) + +#define pcadddr(e) (*(int**)&heap[((int)(e))+3]) + #if FLOAT_CODE #define dcadr(e) (*(double*)&heap[((int)(e))+1]) #define dcaddr(e) (*(double*)&heap[((int)(e))+2])