Mercurial > hg > CbC > old > device
changeset 828:d0f48d1ea798
rvalue_t separation
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 27 Nov 2010 14:14:17 +0900 |
parents | d7b3dc41972f |
children | d5dfc30826ba |
files | mc-codegen.c mc-inline.c |
diffstat | 2 files changed, 54 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-codegen.c Sat Nov 27 13:05:25 2010 +0900 +++ b/mc-codegen.c Sat Nov 27 14:14:17 2010 +0900 @@ -4439,13 +4439,59 @@ right value with preserving type global variable */ extern int -rvalue_t(int e,int t) +rvalue_t(int e,int type0) { - int stype = type; - type = t; - e = rvalue(e); - type = stype; - return e; + int op,c; + NMTBL *n; + + if (e==0) error(-1); + op = 0; + switch(type0) { + case INT: + break; + case UNSIGNED: op=US; break; + case VOID: break; + case CHAR: op=COP; break; + case UCHAR: op=COP+US; break; + case SHORT: op=SOP; break; + case USHORT: op=SOP+US; break; + case LONGLONG: op=LOP; break; + case ULONGLONG: op=LOP+US; break; + case FLOAT: op=FOP; break; + case DOUBLE: op=DOP; break; + case CODE: return e; + case 0: error(-1); return e; + default: + if (type0>0) { + if (car(type0)==POINTER) { + if (lp64) op=LOP; + } else error(-1); + } else error(-1); + } + switch(OP(car(e))) { + case GVAR: + n = ncaddr(e); + if (cadr(e)==0 && (c=attr_value(n,KONST))) { + if (!has_attr(n,VOLATILE)) + return c; + } + return(list3n(RGVAR+op,cadr(e),ncaddr(e))); + case LVAR: + n = ncaddr(e); + if (cadr(e)==0 && n && (c=attr_value(n,KONST))) { + if (!has_attr(n,VOLATILE)) + return c; + } + return(list3n(RLVAR+op,cadr(e),ncaddr(e))); + case INDIRECT: + return(indirect(RINDIRECT+op,cadr(e),type0)); // cadr(e)? + case IVAR: case ARRAY: case PERIOD: case ARROW: + return(indirect(RINDIRECT+op,e,type0)); // RIVAR? + case CAST: + op = rvalue_t(cadr(e),cadddr(e)); + e = list4(CAST,op,caddr(e),cadddr(e)); // should be RCAST? + default:return(e); /* idempotent case? */ + } } /*
--- a/mc-inline.c Sat Nov 27 13:05:25 2010 +0900 +++ b/mc-inline.c Sat Nov 27 14:14:17 2010 +0900 @@ -530,7 +530,8 @@ lvar=p_lvar(cadr(e)); // can be anything.... switch(car(lvar)) { case LVAR: - return rvalue_t(lvar,cadddr(e)); + type = cadddr(e); + return rvalue(lvar); case REGISTER: case DREGISTER: case FREGISTER: case LREGISTER: case CONST: case FCONST: case DCONST: case LCONST: