Mercurial > hg > CbC > old > device
changeset 829:d5dfc30826ba
fix duplicate assignment
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 02 Dec 2010 10:04:35 +0900 |
parents | d0f48d1ea798 |
children | ff5dfee80829 |
files | mc-code-spu.c mc-codegen.c |
diffstat | 2 files changed, 25 insertions(+), 108 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-code-spu.c Sat Nov 27 14:14:17 2010 +0900 +++ b/mc-code-spu.c Thu Dec 02 10:04:35 2010 +0900 @@ -70,6 +70,7 @@ // static void data_mode(char *name); // static void text_mode(int alignment); +static void cext(int sz, int sign, int from, int to); static void ld_indexx(int byte, int n, int xreg,int reg,int sign); static void local_table(void); static void shift(char *op, int creg,int reg); @@ -784,15 +785,9 @@ code_register_overlap(int s,int t) { switch(car(s)) { - case REGISTER: - case FREGISTER: - case DREGISTER: - case LREGISTER: + case REGISTER: case FREGISTER: case DREGISTER: case LREGISTER: switch(car(t)) { - case REGISTER: - case FREGISTER: - case DREGISTER: - case LREGISTER: + case REGISTER: case FREGISTER: case DREGISTER: case LREGISTER: return cadr(s)==cadr(t); } } @@ -832,10 +827,6 @@ void gexpr_init(void) { - while(reg_sp > 0) { - error(-1); - free_register(reg_stack[--reg_sp]); - } use_int0(); text_mode(2); gexpr_code_init(); @@ -926,63 +917,10 @@ static int prev_const_list; static int prev_const_list_label; -/* - constant table - glist3( tag, next, value ) - LVAR glist2(label,offset) - GVAR nptr - CONST value - LABEL value - nth element has offset n * SIZE_OF_INT - */ - -#define CONST_TBL_COUNT 100 -/* -static int -search_const(int tag,int value,int *label) -{ - int p,i,j,list,prev; - - for(j=0;j<2;j++) { - i = 0; - if(j==1) { - if (!const_list_label) const_list_label = fwdlabel(); - *label = const_list_label; - if (const_list==0) { - const_list = glist3(tag,0,value); - return 0; - } else { - prev = list = const_list; - } - } else { - prev = list = prev_const_list; *label = prev_const_list_label; - } - for(p = list; p ;prev=p,p=cadr(p),i+=SIZE_OF_INT) { - if (car(p)!=tag) continue; - switch(tag) { - case GVAR: case CONST: case LABEL: - if (caddr(p)!=value) continue; - return i; - case LVAR: - if (car(caddr(p))!=car(value)) continue; - if (cadr(caddr(p))!=cadr(value)) continue; - return i; - } - } - } - cadr(prev) = glist3(tag,0,value); - if (i>CONST_TBL_COUNT) { - const_list_table(); - } - return i; -} -*/ extern void code_ptr_cache_def(int r, NMTBL *nptr) { - char *rrn = register_name(r); - printf("\tlqd\t%s, %d($sp)\n",rrn,(nptr->sc)*16); } static int @@ -1041,11 +979,14 @@ // char *rn2 = register_name(r+1); char *drn; int dreg; - if (offset==0) { + if (-32768<offset&&offset<32768) + printf("\tai\t%s, %s, %d\n",crn,rrn,offset); + else if (offset==0) { if(r!=reg) printf("\tori\t%s, %s, 0\n",crn,rrn); } else { drn = register_name(dreg = get_register()); + code_const(offset, dreg); printf("\ta\t%s, %s, %s\n",crn,drn,rrn); free_register(dreg); } @@ -1053,7 +994,7 @@ static void -code_ld(char *ld,int reg,int offset,int r,char *cext) +code_ld(char *ld,int reg,int offset,int r) { char *crn = register_name(reg); char *rrn = register_name(r); @@ -1061,27 +1002,10 @@ printf("\t%s\t%s, %d(%s)\n",ld,crn,offset,rrn); } else { code_add(reg,offset,r); - printf("\t%s\t%s, 0(%s) %s\n",ld,crn,crn,cext); + printf("\t%s\t%s, 0(%s)\n",ld,crn,crn); } } -static void -code_ldf(char *ld,char *crn,int offset,int r,char *cext) -{ - char *rrn = register_name(r); - char *orn; - int reg; - if (-1024<offset&&offset<1024) { - printf("\t%s\t%s, %d(%s)\n",ld,crn,(offset*4),rrn); - } else { - orn = register_name(reg=get_register()); - code_add(reg,offset,r); - //printf("\t%s\t%s, [%s, 0]%s\n",ld,crn,orn,cext); - free_register(reg); - } -} - - /* store @@ -1100,32 +1024,31 @@ void code_label(int labelno) { - clear_ptr_cache(); printf(".LC%d:\n",labelno); } void code_gvar(int e1,int reg) { use_int(reg); - return; + printf("\tila\t%s,%s",register_name(reg),ncaddr(e1)->nm); } void code_rgvar(int e1,int reg) { - use_int(reg); + code_crvar(e1,reg,0,SIZE_OF_INT); } void code_crgvar(int e1,int reg,int sign,int sz){ use_int(reg); - cext(sign,sz,reg); + printf("\tlqr\t%s,%s",register_name(reg),ncaddr(e1)->nm); + cext(sz, sign, reg, reg); } void code_register(int e2,int reg) { use_int(reg); - // reg = e2 if (reg!=e2) { printf("\tori\t%s, %s, 0\n",register_name(reg),register_name(e2)); } @@ -1173,7 +1096,7 @@ } void -cext(int sz, int sign, int from, into to) +cext(int sz, int sign, int from, int to) { if (sz==1 && !sign) { // unsigned char @@ -1215,12 +1138,8 @@ void code_fname(NMTBL *n,int reg) { - int r; use_int(reg); - r = get_ptr_cache(n); - if(r!=reg) { - printf("\tori\t%s, %s, 0\n",register_name(reg),register_name(r)); - } + printf("\tila\t%s, %s\n",register_name(reg),n->nm); return; } @@ -1274,9 +1193,9 @@ } else { drn = register_name(reg); } - code_ld(cload(sz,sign),reg,0,xreg,cext_at(sz,sign)); + code_ld(cload(sz,sign),reg,0,xreg); code_add(reg,dir,reg); - code_ldf(cstore(sz),drn,0,xreg,sz==SIZE_OF_SHORT?" @ movhi":""); + code_ld(cstore(sz),drn,0,xreg); } @@ -1302,9 +1221,9 @@ } else { xrn = register_name(reg); } - code_ld(cload(sz,sign),reg,0,xreg,cext_at(sz,sign)); + code_ld(cload(sz,sign),reg,0,xreg); code_add(nreg,dir,reg); - code_ldf(cstore(sz),nrn,0,xreg,""); + code_ldf(cstore(sz),nrn,0,xreg); free_register(nreg); } @@ -1365,8 +1284,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(ncaddr(e1)), - cext_at(sz,0)); + code_ld(cload(sz,0),reg,cadr(e1),get_ptr_cache(ncaddr(e1))); cext(0,sz,r); printf("\tceqi\t%s, %s, 0\n",register_name(reg), register_name(reg)); jcond(label,cond); @@ -1389,7 +1307,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(ncaddr(e1)),""); + code_ld("lqd",reg,cadr(e1),get_ptr_cache(ncaddr(e1))); code_cmp_register(reg,label,cond); } @@ -2075,7 +1993,7 @@ if (!is_int_reg(creg)) error(-1); lreg = creg; use_int(reg); - code_ld(cload(sz,sign),reg,offset,lreg,cext_at(sz,sign)); + code_ld(cload(sz,sign),reg,offset,lreg); cext(sign,sz,reg); } @@ -2088,7 +2006,7 @@ if (!is_int_reg(creg)) error(-1); xreg = creg; use_float(d,reg); - code_ldf(d?"lqd":"lqd",register_name(reg),offset,xreg,""); + code_ld("lqd",reg,offset,xreg); return d?DOUBLE:FLOAT; } #endif @@ -2154,8 +2072,7 @@ void code_assign_gvar(int e2,int creg,int byte) { use_int(creg); - code_ldf(cstore(byte),register_name(creg),cadr(e2), - get_ptr_cache(ncaddr(e2)),byte==SIZE_OF_SHORT?" @ movhi":""); + printf("\tstqr\t%s,%s\n",regsister_name(creg),ncaddr(e2)->nm); } void
--- a/mc-codegen.c Sat Nov 27 14:14:17 2010 +0900 +++ b/mc-codegen.c Thu Dec 02 10:04:35 2010 +0900 @@ -216,7 +216,7 @@ return INT; case URLVAR: if (lp64) code_crlvar(e2,USE_CREG,0,size_of_int); - code_rlvar(e2,USE_CREG); + else code_rlvar(e2,USE_CREG); return UNSIGNED; case CRLVAR: code_crlvar(e2,USE_CREG,1,1);