Mercurial > hg > CbC > old > device
changeset 209:7bfc1435cdc6 regv-fix
regv fix done
author | kono |
---|---|
date | Wed, 21 Apr 2004 17:40:29 +0900 |
parents | 70b1da1864f6 |
children | f21651f85344 |
files | Changes mc-code-powerpc.c mc-parse.c test/int.c |
diffstat | 4 files changed, 43 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Wed Apr 21 16:39:15 2004 +0900 +++ b/Changes Wed Apr 21 17:40:29 2004 +0900 @@ -3937,3 +3937,7 @@ lreg_hとlreg_lみたいな感じにする。 うーん、register full かぁ。何おかしくしちゃったかなぁ。 + +Wed Apr 21 17:32:40 JST 2004 + +unsigned のcosnt計算がおかしいんじゃない?
--- a/mc-code-powerpc.c Wed Apr 21 16:39:15 2004 +0900 +++ b/mc-code-powerpc.c Wed Apr 21 17:40:29 2004 +0900 @@ -1790,9 +1790,9 @@ char *crn; g_expr(e1); crn=register_name(creg); + creg = d?use_double(creg):use_float(creg); printf("\t%s %s,%d(%s)\n",fload(d), fregister_name(freg),offset,crn); - creg = freg; return d?DOUBLE:FLOAT; } #endif @@ -2924,11 +2924,12 @@ void code_dassop(int op,int d) { /* we have lvalue in creg, applied floating value is in freg */ - char *frn=fregister_name(freg); int xreg=emit_dpop(d); char *crn=register_name(creg); - - if (!is_float_reg(freg)) error(-1); + char *frn; + creg = d?use_double(creg):use_float(creg); + frn =fregister_name(freg); + printf("\t%s %s,0(%s)\n",fload(d),frn,crn); dtosop(op,xreg); printf("\t%s %s,0(%s)\n",fstore(d),frn,crn); @@ -2943,17 +2944,20 @@ int g; char *grn,*drn; int r; - r = get_ptr_cache(&float_one); - float_one_lib_used=1; if (car(e2)==DREGISTER||car(e2)==FREGISTER) { error(-1); /* unspported now */ } g_expr(e2); + float_one_lib_used=1; + r = get_ptr_cache(&float_one); + drn=register_name(r); + crn=register_name(creg); + + creg = d?use_double(creg):use_float(creg); frn=fregister_name(freg); - drn=register_name(r); grn=fregister_name(g=get_dregister(d)); printf("\t%s %s,0(%s)\n",fload(d),frn,crn); @@ -2975,8 +2979,6 @@ int g; char *grn,*drn; int r; - r = get_ptr_cache(&float_one); - float_one_lib_used=1; if (car(e2)==DREGISTER||car(e2)==FREGISTER) { error(-1); /* unspported now */ @@ -2984,8 +2986,13 @@ g_expr(e2); crn=register_name(creg); + + float_one_lib_used=1; + r = get_ptr_cache(&float_one); + drn=register_name(r); + + creg = d?use_double(creg):use_float(creg); frn=fregister_name(freg); - drn=register_name(r); grn=fregister_name(g=get_dregister(d)); printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
--- a/mc-parse.c Wed Apr 21 16:39:15 2004 +0900 +++ b/mc-parse.c Wed Apr 21 17:40:29 2004 +0900 @@ -2238,7 +2238,9 @@ #endif if(!integral(type)) error(TYERR); if((t==UNSIGNED||type==UNSIGNED)&& - (op==MUL||op==DIV||op==MOD||op==RSHIFT||op==LSHIFT)) + (op==MUL||op==DIV||op==MOD)) + op=op+US; + if(t==UNSIGNED&&(op==RSHIFT||op==LSHIFT)) op=op+US; if(t==CHAR) { type= INT; @@ -3251,6 +3253,7 @@ } if((op==MUL||op==DIV)&&car(e2)==LCONST&&lcadr(e2)==1) return e1; if(op==BOR||op==EOR||op==BAND) return(list3(op+LOP,e1,e2)); + if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==ULONGLONG?US:0)+LOP,e1,e2)); return(list3(type==ULONGLONG?op+US+LOP:op,e1,e2)); } #endif @@ -3321,6 +3324,10 @@ e=e1>>e2;break; case LSHIFT: e=e1<<e2;break; + case URSHIFT: + e=((unsigned)e1)>>e2;break; + case ULSHIFT: + e=((unsigned)e1)<<e2;break; case EQ: e=(e1==e2);break; case NEQ: @@ -3406,9 +3413,10 @@ return e; } if(!integral(t1)||!integral(t2)) error(TYERR); - if(t1==INT) type=t2; else type=t1; + if(t1==INT) type=t2; else type=t1; /* ??? */ if((op==MUL||op==DIV)&&car(e2)==CONST&&cadr(e2)==1) return e1; if(op==BOR||op==EOR||op==BAND) return(list3(op,e1,e2)); + if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==UNSIGNED?US:0),e1,e2)); return(list3(type==UNSIGNED?op+US:op,e1,e2)); }
--- a/test/int.c Wed Apr 21 16:39:15 2004 +0900 +++ b/test/int.c Wed Apr 21 17:40:29 2004 +0900 @@ -172,25 +172,29 @@ g = 3.0; printf("%d:%d\t",n++,g); g1 = g<<2; + printf("<< %d:%d\t",n++,g1); g1 = g<<f; - printf("%d:%d\t",n++,g1); + printf("<< %d:%d\t",n++,g1); g1 = g>>2; + printf(">> %d:%d\t",n++,g1); g1 = g>>f; - printf("%d:%d\t",n++,g1); + printf(">> %d:%d\t",n++,g1); g = g%g1; - printf("%d:%d\t",n++,g); + printf("% %d:%d\t",n++,g); g = g|g1; - printf("%d:%d\t",n++,g); + printf("| %d:%d\t",n++,g); g = g&g1; - printf("%d:%d\t",n++,g); + printf("& %d:%d\t",n++,g); g = g^g1; - printf("%d:%d\t",n++,g); - printf("\n"); + printf("^ %d:%d\t",n++,g); g = -120; g1 = g>>2; + printf(">> %d:%d\t",n++,g1); g1 = g>>f; - printf("%d:%d\t",n++,g1); + printf(">> %d:%d\t",n++,g1); + + printf("\n"); printf("simple unsigned "); f = f+f;