Mercurial > hg > CbC > old > device
changeset 498:574856cee9da
printf double/int mix
cond operator fix
author | kono |
---|---|
date | Thu, 22 Dec 2005 11:50:32 +0900 |
parents | dbbc07bca089 |
children | d2570c00ca54 |
files | Changes mc-code-ia32.c mc-code-powerpc.c mc-codegen.c test/code-gen.c |
diffstat | 5 files changed, 96 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Dec 22 00:21:01 2005 +0900 +++ b/Changes Thu Dec 22 11:50:32 2005 +0900 @@ -7452,3 +7452,13 @@ dots & freg の扱いが間違ってるな。 ia32 の cond の float も間違ってる。 + +Thu Dec 22 11:48:39 JST 2005 + +cond のテストルーチンを入れたので、まぁ、いろいろバグが取れました。 + +ia32 の方では dreg が不必要にuseされている場合があるらしい。 + +printf もなんとか。assign_expr でのtype checkが変だった。 + +
--- a/mc-code-ia32.c Thu Dec 22 00:21:01 2005 +0900 +++ b/mc-code-ia32.c Thu Dec 22 11:50:32 2005 +0900 @@ -3060,9 +3060,12 @@ void code_i2ll(int reg) { int reg0 = USE_CREG; - use_register(creg,REG_EAX,1); - regv[creg]=0; + int creg0 = creg; + use_longlong(reg0); + use_register(creg0,REG_EAX,1); + regv[creg0]=0; + printf("\tcltd\n"); check_lreg(reg); lreg = creg = reg0; @@ -3076,8 +3079,12 @@ void code_u2ll(int reg) { int reg0 = USE_CREG; - use_register(creg,REG_EAX,1); - regv[creg]=0; + int creg0 = creg; + + use_longlong(reg0); + use_register(creg0,REG_EAX,1); + regv[creg0]=0; + use_longlong(reg0); printf("\txorl %%edx,%%edx\n"); check_lreg(reg);
--- a/mc-code-powerpc.c Thu Dec 22 00:21:01 2005 +0900 +++ b/mc-code-powerpc.c Thu Dec 22 11:50:32 2005 +0900 @@ -2121,7 +2121,7 @@ INT,INT), arg_assign); } } - if (dots && freg_arg>=3 && freg_arg<MAX_INPUT_DREGISTER_VAR) { + if (dots && (freg_arg*8+reg_arg*4)>=32 && freg_arg<MAX_INPUT_DREGISTER_VAR) { /* it requires integer register and floating register and stack value.
--- a/mc-codegen.c Thu Dec 22 00:21:01 2005 +0900 +++ b/mc-codegen.c Thu Dec 22 11:50:32 2005 +0900 @@ -2017,6 +2017,33 @@ assign_expr(int e1,int e2,int t) { /* we should check const / assign violation here */ t = type_value(t); + if (t>0) { + switch(car(type_value(t))) { + case BIT_FIELD: + // type = list4(BIT_FIELD,type, + // list3(type /*store type*/,0 /*bit offset*/,bitsize)); + e2 = correct_type(e2,cadr(t)); /* value type */ + return(list4(BASS,e1,e2,list2(BASS,t))); + case STRUCT:case UNION: + if (size(t)!=size(type)) error(TYERR); + type=t; // dispose attr + if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) { + replace_return_struct(cadr(e2),e1); + return cadr(e2); + } else { + return (list4(STASS,e1,e2,size(t))); + } + default: + if(scalar(t)) { + if (car(t)!=POINTER) { + e2=(type_value(t)==UNSIGNED)? + unsigned_value(e2):int_value(e2); + } + return(list3(ASS,e1,e2)); + } + error(TYERR); return list3(ASS,e1,e2); + } + } switch(t) { case VOID: break; @@ -2026,6 +2053,9 @@ case SHORT:case USHORT: e2=(t==USHORT)?unsigned_value(e2):int_value(e2); return(list3(SASS,e1,e2)); + case INT:case UNSIGNED: case ENUM: + e2=(t==UNSIGNED)?unsigned_value(e2):int_value(e2); + return(list3(ASS,e1,e2)); #if FLOAT_CODE case DOUBLE: e2=double_value(e2); @@ -2042,27 +2072,6 @@ e2=ulonglong_value(e2); return(list3(LASS,e1,e2)); #endif - default: - if(scalar(t)) { - e2=(type_value(t)==UNSIGNED)?unsigned_value(e2):int_value(e2); - return(list3(ASS,e1,e2)); - } - switch(car(type_value(t))) { - case BIT_FIELD: - // type = list4(BIT_FIELD,type, - // list3(type /*store type*/,0 /*bit offset*/,bitsize)); - e2 = correct_type(e2,cadr(t)); /* value type */ - return(list4(BASS,e1,e2,list2(BASS,t))); - case STRUCT:case UNION: - if (size(t)!=size(type)) error(TYERR); - type=t; // dispose attr - if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) { - replace_return_struct(cadr(e2),e1); - return cadr(e2); - } else { - return (list4(STASS,e1,e2,size(t))); - } - } } error(TYERR); return list3(ASS,e1,e2); } @@ -3256,7 +3265,7 @@ case VOID: break; case CHAR: op=COP; type=set_type_with_attr(INT,type); break; case UCHAR: op=COP+US; type=set_type_with_attr(UNSIGNED,type); break; - case SHORT: op=SOP; type=set_type_with_attr(SIGNED,type); break; + case SHORT: op=SOP; type=set_type_with_attr(SHORT,type); break; case USHORT: op=SOP+US; type=set_type_with_attr(UNSIGNED,type); break; case LONGLONG: op=LOP; break; case ULONGLONG: op=LOP+US; break;
--- a/test/code-gen.c Thu Dec 22 00:21:01 2005 +0900 +++ b/test/code-gen.c Thu Dec 22 11:50:32 2005 +0900 @@ -3331,8 +3331,10 @@ for(i=0;i<2;i++) { k = i==0? -4:4; printf("#3332: cond_iii %d\n",k); + printf("#3333: cond_iii %d\n",i==0? -8:8); k = i==0? i:j; - printf("#3334: cond_iii %d\n",k); + printf("#3335: cond_iii %d\n",k); + printf("#3336: cond_iii %d\n",i==0? i:j); } } @@ -3345,9 +3347,11 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3347: cond_ii0 %d\n",k); + printf("#3349: cond_ii0 %d\n",k); + printf("#3350: cond_ii0 %d\n",i==0? -8:8); k = i==0? i:j; - printf("#3349: cond_ii0 %d\n",k); + printf("#3352: cond_ii0 %d\n",k); + printf("#3353: cond_ii0 %d\n",i==0? i:j); } } @@ -3360,9 +3364,11 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3362: cond_uuu %u\n",k); + printf("#3366: cond_uuu %u\n",k); + printf("#3367: cond_uuu %u\n",i==0? -8:8); k = i==0? i:j; - printf("#3364: cond_uuu %u\n",k); + printf("#3369: cond_uuu %u\n",k); + printf("#3370: cond_uuu %u\n",i==0? i:j); } } @@ -3375,9 +3381,11 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3377: cond_uii %d\n",k); + printf("#3383: cond_uii %d\n",k); + printf("#3384: cond_uii %u\n",i==0? -8:8); k = i==0? i:j; - printf("#3379: cond_uii %d\n",k); + printf("#3386: cond_uii %d\n",k); + printf("#3387: cond_uii %u\n",i==0? i:j); } } @@ -3391,11 +3399,12 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3393: cond_fff %g\n",k); - printf("#3394: cond_fff %g\n",i==0? -4:4); + printf("#3401: cond_fff %g\n",k); + printf("#3402: cond_fff %g\n",i==0? -4.0:4.0); + printf("#3403: cond_fff %g\n",(float)(i==0? -4:4)); k = i==0? i:j; - printf("#3396: cond_fff %g\n",k); - printf("#3397: cond_fff %g\n",i==0? i:j); + printf("#3405: cond_fff %g\n",k); + printf("#3406: cond_fff %g\n",i==0? i:j); } } @@ -3408,11 +3417,12 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3410: cond_ddd %g\n",k); - printf("#3411: cond_ddd %g\n",i==0? -4:4); + printf("#3419: cond_ddd %g\n",k); + printf("#3420: cond_ddd %g\n",i==0? -4.0:4.0); + printf("#3421: cond_ddd %g\n",(double)(i==0? -4:4)); k = i==0? i:j; - printf("#3413: cond_ddd %g\n",k); - printf("#3414: cond_ddd %g\n",i==0? i:j); + printf("#3423: cond_ddd %g\n",k); + printf("#3424: cond_ddd %g\n",i==0? i:j); } } @@ -3421,13 +3431,13 @@ { int i=9; float f=(i>10) ? 4 : -4; - printf("#3423:%f\n",f); + printf("#3433:%f\n",f); i=10; f=(i>10) ? 4 : -4; - printf("#3426:%f\n",f); + printf("#3436:%f\n",f); i=11; f=(i>10) ? 4 : -4; - printf("#3429:%f\n",f); + printf("#3439:%f\n",f); } #endif @@ -3442,9 +3452,12 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3444: cond_lll %lld\n",k); + printf("#3454: cond_lll %lld\n",k); + printf("#3455: cond_lll %lld\n",i==0? -4LL:4LL); + printf("#3456: cond_lll %lld\n",(long long)(i==0? -4:4)); k = i==0? i:j; - printf("#3446: cond_lll %lld\n",k); + printf("#3458: cond_lll %lld\n",k); + printf("#3459: cond_lll %llu\n",i==0? i:j); } } @@ -3456,9 +3469,12 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3458: cond_ulll %llu\n",k); + printf("#3471: cond_ulll %llu\n",k); + printf("#3472: cond_ulll %llu\n",i==0? -4LL:4LL); + printf("#3473: cond_ulll %llu\n",(unsigned long long)(i==0? -4:4)); k = i==0? i:j; - printf("#3460: cond_ulll %llu\n",k); + printf("#3475: cond_ulll %llu\n",k); + printf("#3476: cond_ulll %llu\n",i==0? i:j); } } @@ -3470,9 +3486,12 @@ for(i=0;i<2;i++) { k = i==0? -4:4; - printf("#3472: cond_luu %lld\n",k); + printf("#3488: cond_luu %lld\n",k); + printf("#3489: cond_luu %lld\n",i==0? -4LL:4LL); + printf("#3490: cond_luu %lld\n",(unsigned long long)(i==0? -4:4)); k = i==0? i:j; - printf("#3474: cond_luu %lld\n",k); + printf("#3492: cond_luu %lld\n",k); + printf("#3493: cond_luu %lld\n",i==0? i:j); } }