Mercurial > hg > CbC > old > device
diff mc-code-spu.c @ 719:4c5ac4025fbd
*** empty log message ***
author | kono |
---|---|
date | Wed, 28 Nov 2007 19:38:01 +0900 |
parents | d12029c499df |
children | 13e540e7d9bf |
line wrap: on
line diff
--- a/mc-code-spu.c Tue Nov 20 17:51:50 2007 +0900 +++ b/mc-code-spu.c Wed Nov 28 19:38:01 2007 +0900 @@ -386,13 +386,13 @@ lvar(int l,char *cext) { if (large_lvar) { - printf("0(%s)\n##lvar0\n",register_name(large_lvar)); + printf("0(%s)\n",register_name(large_lvar)); free_register(large_lvar); return; } if (is_code(fnptr)) { if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */ - printf("%d($sp)\n##lvar1\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET)); + printf("%d($sp)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET)); } else { printf("%d($sp)\n",CODE_LVAR(l)); } @@ -976,196 +976,18 @@ return i; } */ -#if FLOAT_CODE -static int -search_double_const(int tag,int value1,int value2,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,glist3(tag,0,value2),value1); - 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 DCONST: case LCONST: - if (caddr(p)!=value1) continue; - p = cadr(p); - if (!p||car(p)!=tag) error(-1); - if (caddr(p)!=value2) continue; - return i; - } - prev = p; - } - } - cadr(prev) = glist3(tag,glist3(tag,0,value2),value1); - if (i>CONST_TBL_COUNT) { - const_list_table(); - } - return i; -} -#endif - -static int inst_count; - -static void -const_list_table() -{ - int p,lb=0; - inst_count = 0; - - if (const_list) { - if (control) { - lb = fwdlabel(); - gen_jmp(lb); - // printf("\t.align\t2\n"); - } - fwddef(const_list_label); - control=0; - for(p = const_list; p ; p = cadr(p)) { - switch(car(p)) { - 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; - case LVAR: printf("\t.word\t.LC%d+%d\n", - car(caddr(p)),cadr(caddr(p))); break; - default: error(-1); - } - } - if (lb) { - fwddef(lb); // control==1 now - } - prev_const_list_label=const_list_label; - const_list_label = 0; - } - for(p = prev_const_list; p ; p = cadr(p)) { - if (car(p)==LVAR) { - free_glist2(caddr(p)); - } - } - free_glist3_a(prev_const_list); - prev_const_list=const_list; - const_list = 0; -} - 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); -} - -#define mask8(d,bit) (d & (255 << bit)) - -/* - mode CONST or other (CMP is Ok only in stage 1 result) - *p1 stage 1 const - *p2 stage 2 const - *p3 stage 3 const - return 0 ... require 4 stage - 1 ... positive result - -1 ... negative result - - */ -static int -make_const(int c,int *p1,int *p2,int *p3,int mode) -{ - int sign,im,jm,km; - int min_stage = 4; - int msign=0,mim=0,mjm,mkm; - int id,jd,kd; - int i,j,k; - int d; - if (c == (d = mask8(c,0))) { - min_stage=1; min_stage=1; msign = 1; - mim = d;mjm = 0;mkm = 0; - } else if (mode!=CONST) { - if (-c == (d = mask8(-c,0))) { - min_stage=1; min_stage=1; msign = -1; - mim = d;mjm = 0;mkm = 0; - } - } else { - if (~c== (d = mask8(~c,0))) { - min_stage=1; min_stage=1; msign = -1; - mim = d;mjm = 0;mkm = 0; - } - } - for(sign=1;sign>=-1;sign-=2) { - if (min_stage==1) break; - for(i=24;i>=0;i-=2) { - jm = km = 0; - if (sign>0) { - if (c == (d = mask8(c,i))) { - min_stage=1; min_stage=1; msign = 1; - mim = d;mjm = 0;mkm = 0; - break; - } - id = c - d; - } else if (mode!=CONST) { - if (-c == (d = mask8(-c,i))) { - min_stage=1; min_stage=1; msign = -1; - mim = d;mjm = 0;mkm = 0; - break; - } - id = -c - d; - } else { - if (~c== (d = mask8(~c,i))) { - min_stage=1; min_stage=1; msign = -1; - mim = d;mjm = 0;mkm = 0; - break; - } - id = ~c - d; - } - if (d==0) continue; - im = d; - if (min_stage<=2) continue; - for(j=i-8;j>=0;j-=2) { - km = 0; - if (!(jm=mask8(id,j))) continue; - jd = id - jm; - if (jd==0) { - min_stage=2; msign = sign; - mim = im;mjm = jm;mkm = km; - break; - } - if (min_stage<=3) continue; - for(k=j-8;k>=0;k-=2) { - if (!(km=mask8(jd,k))) continue; - kd = jd - km; - if (kd==0) { - min_stage=3; msign = sign; - mim = im;mjm = jm;mkm = km; - break; - } - } - } - } - } - if (min_stage<=3) { - *p1 = mim; *p2= mjm; *p3 = mkm; - return msign; - } else return 0; + char *rrn = register_name(r); + printf("\tlqd\t%s, %d($sp)\n",rrn,(nptr->sc)*16); } static int is_stage1_const(int c,int mode) { - int sign,p1=0,p2=0,p3=0; - sign = make_const(c,&p1,&p2,&p3,mode); - return (c==0||(p1&&!p2&&!p3))?sign:0; + return mode?(0<=c && c<262143): (-32768<=c && c<32767); } extern void @@ -1218,34 +1040,9 @@ char *rn2 = register_name(r+1); char *drn; int dreg; - int s,p1,p2,p3,h; - char *add; if (offset==0) { if(r!=reg) printf("\tori\t%s, %s, 0\n",crn,rrn); - } else if ((s=make_const(offset,&p1,&p2,&p3,0))) { - add = s>0?"a":"sf"; - //printf("\t%s\t%s, %s, %d\n",add,crn,rrn,p1); - if (-32768<(p1+p2+p3)&&(p1+p2+p3)<32768) - printf("\til\t%s,%d\n",rn2,(p1+p2+p3)); - else if( (p1+p2+p3) > 32767 && (p1+p2+p3) < 262144) - printf("\tila\t%s, %d\n",rn2,p1+p2+p3); - else if( (p1+p2+p3) > 262143) { - printf("\tilhu\t%s, %d\n",rn2,(p1+p2+p3)/65536); - printf("\tiohl\t%s, %d\n",rn2,(p1+p2+p3)%65536); - } else { - h = (~(p1+p2+p3) >> 16) & 0xffff; - h += 1; - h = -h; - printf("\tilhu\t%s,%d\n",crn,h); - if(((p1+p2)&0xffff) > -262143) - printf("\tiohl %s,%d\n",crn, ((p1+p2)&0xffff)); - else - printf("\tori %s,%s,%d\n",crn,crn,((p1+p2)&0xffff)); - - } - - printf("\t%s\t%s, %s, %s\n", add, crn, rrn ,rn2); } else { drn = register_name(dreg = get_register()); printf("\ta\t%s, %s, %s\n",crn,drn,rrn); @@ -1284,8 +1081,19 @@ } -#define cload(sz,sign) \ - (sz==1?(sign?"lqd":"lqd"):sz==SIZE_OF_SHORT?(sign?"lqd":"lqd"):"lqd") +/* + +store + lqd $2,176($sp) + cbd $3,0($sp) + shufb $2,$4,$2,$3 + stqd $2,176($sp) +unsigned load + rotqbyi $2,$2,13 + andi $4,$2,0x00ff + + */ + #define cext(sign,sz,reg) @@ -1306,21 +1114,17 @@ void code_gvar(int e1,int reg) { use_int(reg); - 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(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(ncaddr(e1)), - cext_at(sz,sign)); cext(sign,sz,reg); } @@ -1445,8 +1249,6 @@ } else { drn = register_name(reg); } -// ldrb r2, [ip, #-1]! @ zero_extendqisi2 -// ??????offset???????????12bit! code_ld(cload(sz,sign),reg,0,xreg,cext_at(sz,sign)); code_add(reg,dir,reg); code_ldf(cstore(sz),drn,0,xreg,sz==SIZE_OF_SHORT?" @ movhi":"");