Mercurial > hg > CbC > old > device
changeset 592:259a53737e25
a little tosop optimization.
author | kono |
---|---|
date | Fri, 20 Jan 2006 14:05:48 +0900 |
parents | 0497fa2e2414 |
children | c139d4d9307c |
files | Changes mc-codegen.c mc-parse.c mc-switch.c stdio.h |
diffstat | 5 files changed, 51 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Thu Jan 19 19:38:41 2006 +0900 +++ b/Changes Fri Jan 20 14:05:48 2006 +0900 @@ -8535,11 +8535,15 @@ Thu Jan 19 16:49:23 JST 2006 hoge() -#if +#if 0 { とかで、type が、おかしくなるらしい。ありそうな話だ。 - - - +これといい、原因といい、くだらんバグだった。初期化してない +変数を使ってたのにwariningでないのは最適化をかけないからか。 + +register stack overflow ってなかなかでないのね。ローカル +変数をレジスタにマップしない限りレジスタって意味ないのか。 + +
--- a/mc-codegen.c Thu Jan 19 19:38:41 2006 +0900 +++ b/mc-codegen.c Fri Jan 20 14:05:48 2006 +0900 @@ -1541,6 +1541,8 @@ { int e2,e3,op; + // e3 op e2 + e2 = cadr(e1); op = car(e1); e3 = caddr(e1); @@ -1549,6 +1551,15 @@ oprtc(op,USE_CREG,e3); return; } + if ((op==CMP||op==UCMP) && car(e3)==REGISTER && car(e2)==REGISTER) { + tosop(op,cadr(e2),cadr(e3)); + return; + } + if (car(e3)==REGISTER) { + g_expr(e2); + tosop(op,USE_CREG,cadr(e3)); + return; + } g_expr(e3); emit_push(); g_expr(e2); @@ -1566,6 +1577,20 @@ e2 = cadr(e1); op = car(e1); e3 = caddr(e1); + switch (op) { + case DCMPGE: case DCMPEQ: case DCMPNEQ: case DCMP: + case FCMPGE: case FCMPEQ: case FCMPNEQ: case FCMP: + if ((car(e3)==DREGISTER||car(e3)==FREGISTER) && + ((car(e2)==DREGISTER||car(e2)==FREGISTER))) { + dtosop(op,cadr(e2),cadr(e3)); + return; + } + } + if (car(e3)==DREGISTER||car(e3)==FREGISTER) { + g_expr(e2); + dtosop(op,USE_CREG,cadr(e3)); + return; + } g_expr(e3); emit_dpush(d); g_expr(e2); @@ -1589,6 +1614,11 @@ loprtc(op,USE_CREG,e3); return; } + if (car(e3)==LREGISTER) { + g_expr(e2); + ltosop(op,USE_CREG,cadr(e3)); + return; + } g_expr(e3); emit_lpush(); g_expr(e2); @@ -2796,7 +2826,7 @@ // printf("## asm\n"); e = reverse0(e); for(i=out;i;i=cadr(i)) { - p = (char*)cadr(car(i)); + p = ((NMTBL*)cadr(car(i)))->nm; e1 = car(e); e = cadr(e); repl = code_asm_operand(p,e1,ASM_OUTPUT,repl,0,0); if (car(car(repl))==REGISTER) { @@ -2806,7 +2836,7 @@ repl0 = repl; n = length(repl0); for(i=in;i;i=cadr(i)) { - p = (char*)cadr(car(i)); + p = ((NMTBL*)cadr(car(i)))->nm; e1 = car(e); e = cadr(e); repl = code_asm_operand(p,e1,ASM_INPUT,repl,n,repl0); if (car(car(repl))==REGISTER) { @@ -2814,7 +2844,8 @@ } } repl = reverse0(repl); - code_asm((char*)cadr(asm0),repl); + p = ((NMTBL*)cadr(asm0))->nm; + code_asm(p,repl); for(i=assign;i;i=cadr(i)) { g_expr_u(car(i)); }
--- a/mc-parse.c Thu Jan 19 19:38:41 2006 +0900 +++ b/mc-parse.c Fri Jan 20 14:05:48 2006 +0900 @@ -587,6 +587,7 @@ reserve("__label__",LABEL); reserve("__FILE__",C_FILE); reserve("__FUNCTION__",C_FUNCTION); + reserve("__func__",C_FUNCTION); reserve("__LINE__",C_LINE); #if ASM_CODE reserve("asm",ASM); @@ -3748,13 +3749,8 @@ } else if (sym==LC) { // statement in expression (GNU extension) // a = {hoge(); 1;} - // if COMMA expr is not gexpred by !control, - // l2 is not defined and generates undefined error. - // cntl prevents this. - // // In docomp, last expression is kept in lastexp. // - int l,b,l2,cntl=control; if (inmode) { int sparse = parse; parse=0; docomp(1); @@ -3762,6 +3758,10 @@ parse = sparse; lastexp = 0; } else { + int l,b,l2,cntl=control; + // if COMMA expr is not gexpred by !control, + // l2 is not defined and generates undefined error. + // cntl prevents this. if (cntl) { gen_jmp(l=fwdlabel()); } else l = 0; @@ -3770,9 +3770,8 @@ if (cntl) { gen_jmp(l2=fwdlabel()); } else l2 = 0; - // we cannot handle complex statement in the middle - // of the expression, so make it a simple call (by jmp) - // mostly we have to do is register stack save. + // make it a simple call (by jmp) + // register stack save now e1 = list3(COMMA,list3(LCALL,b,l2),lastexp); lastexp = 0; if (l) fwddef(l);