Mercurial > hg > CbC > old > device
changeset 834:51b230253f27
rindirect offset peep hole
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 03 Dec 2010 20:12:52 +0900 |
parents | 15764443b058 |
children | 59ebc5cb2a99 |
files | mc-codegen.c mc-inline.c |
diffstat | 2 files changed, 17 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-codegen.c Fri Dec 03 18:43:18 2010 +0900 +++ b/mc-codegen.c Fri Dec 03 20:12:52 2010 +0900 @@ -1777,6 +1777,7 @@ return; } #endif +static int llvalue_opt(int e0); static int lvalue_opt(int e0) @@ -1784,6 +1785,7 @@ int e,e1; if (inmode) return e0; + if (car(e0)==LADD) return llvalue_opt(e0); if (car(e0)!=ADD) return e0; if (car(e=caddr(e0))!=CONST) return e0; e1 = cadr(e0); @@ -1808,8 +1810,6 @@ return(list3n(GVAR,cadr(e1)+cadr(e),ncaddr(e1))); } else if(car(e1)==LVAR) { return(list3n(LVAR,cadr(e1)+cadr(e),ncaddr(e1))); -// } else if(car(e1)==RLVAR) { this is not correct -// return(list3n(RLVAR,cadr(e1)+cadr(e),ncaddr(e1))); } } return e0; } @@ -1844,8 +1844,6 @@ return(list3n(GVAR,cadr(e1)+lcadr(e),ncaddr(e1))); } else if(car(e1)==LVAR) { return(list3n(LVAR,cadr(e1)+lcadr(e),ncaddr(e1))); -// } else if(car(e1)==RLVAR) { this is not correct -// return(list3n(RLVAR,cadr(e1)+cadr(e),ncaddr(e1))); } return e0; } @@ -4591,20 +4589,16 @@ if (inmode || chk) { // bitfield will be checked after parse return e1; - } else if(dsp) { - switch(car(e)) { - case GVAR: + } + if (car(e)==INDIRECT) e = cadr(e); + if(dsp) { + switch(OP(car(e))) { + case GVAR: // e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp))); - e=list3n(GVAR,cadr(e)+dsp,ncaddr(e)); + e=list3n(car(e),cadr(e)+dsp,ncaddr(e)); break; - case LVAR: - e=list3n(LVAR,cadr(e) + dsp,ncaddr(e)); /* may have attribute */ - break; - case INDIRECT: - if (lp64) - e=list2(INDIRECT,list3(LADD,cadr(e),llist2(LCONST,dsp))); - else - e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp))); + case LVAR: + e=list3n(car(e),cadr(e) + dsp,ncaddr(e)); /* may have attribute */ break; case IVAR: if (lp64) @@ -4614,16 +4608,9 @@ break; default: if (lp64) - e=list2(INDIRECT,list3(LADD,e,llist2(LCONST,dsp))); + e=list3(LADD,e,llist2(LCONST,dsp)); else - e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp))); - } - } else { - switch(car(e)) { - case GVAR: case LVAR: case INDIRECT: case IVAR: - break; - default: - e=list2(INDIRECT,e); + e=list3(ADD,e,list2(CONST,dsp)); } } type0 = type_value(type);
--- a/mc-inline.c Fri Dec 03 18:43:18 2010 +0900 +++ b/mc-inline.c Fri Dec 03 20:12:52 2010 +0900 @@ -543,6 +543,11 @@ } } int e2 = pexpr(cadr(e)); + if (OP(car(e2))==ADD) { + int c = caddr(e2); + if (car(c)==CONST) { e2 = cadr(e2); offset = cadr(c); } + else if (car(c)==LCONST) { e2 = cadr(e2); offset = lcadr(c); } + } return list3(car(e),e2,offset); #endif }