# HG changeset patch # User Shinji KONO # Date 1290750091 -32400 # Node ID c59753132812444761d5075e730370dbab351257 # Parent 44c276fa9ec6432782d3236d08af09dad46926d7 remove rvalue_t from CONV diff -r 44c276fa9ec6 -r c59753132812 .gdbinit --- a/.gdbinit Wed Nov 24 15:14:05 2010 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -tb main -r -s test/basic.c -define regs -printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4 -printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15 -end -define fregs -printf "f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f1,$f2,$f3,$f4,$f5,$f6 -printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15 -end -define allreg -printf "pc =%08x lr =%08x r0 =%08x r1 =%08x r3= %08x r4= %08x\n",$pc,$lr,$r0,$r1,$r3,$r4 -printf "r5=%08x r6=%08x r7=%08x r8=%08x r9=%08x\n",$r5,$r6,$r7,$r8,$r9 -printf "r10=%08x r11=%08x r12=%08x r13=%08x r14=%08x r15=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15 -printf "r16=%08x r17=%08x r18=%08x r19=%08x r20=%08x r21=%08x\n",$r10,$r11,$r12,$r13,$r14,$r15 -printf "f1=%g f2=%g f3=%g f4=%g f5=%g f6=%g\n",$f1,$f2,$f3,$f4,$f5,$f6 -printf "f10=%g f11=%g f12=%g f13=%g f14=%g f15=%g\n",$f10,$f11,$f12,$f13,$f14,$f15 -printf "f20=%g f21=%g f22=%g f23=%g f24=%g f25=%g\n",$f20,$f21,$f22,$f23,$f24,$f25 -end -define sh -regs -x/20i $pc-36 -end -define si -stepi -regs -x/1i $pc -end -define ni -nexti -regs -x/1i $pc -end -b errmsg diff -r 44c276fa9ec6 -r c59753132812 Changes --- a/Changes Wed Nov 24 15:14:05 2010 +0900 +++ b/Changes Fri Nov 26 14:41:31 2010 +0900 @@ -9938,3 +9938,15 @@ asm の引数のチェックが甘いみたいだな。 non parse mode が動かなくなっている。 + +Fri Nov 26 12:23:47 JST 2010 + +rvalue が RLVAR とかに idemopoent なので、pindirect がおかしい。 + +indirect に rvalue を使うのはまずいの? + + ASS と CONST (FUNCTION)、REGISTER が特別な場合らしい + + + + diff -r 44c276fa9ec6 -r c59753132812 Makefile --- a/Makefile Wed Nov 24 15:14:05 2010 +0900 +++ b/Makefile Fri Nov 26 14:41:31 2010 +0900 @@ -162,7 +162,7 @@ check: mc $(MC) $(TARGET).c -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -./b.out > $(TARGET).gcc.out - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).gcc.out $(TARGET).$(MC).out @@ -170,23 +170,23 @@ check-inline: mc $(MC) $(TARGET).c -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -./b.out > $(TARGET).gcc.out - -./$(MC) -s -DINLINE=inline $(TARGET).c + -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).gcc.out $(TARGET).$(MC).out check-code: mc $(MC) - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).code-out $(TARGET).$(MC).out check-code-inline: mc $(MC) - -./$(MC) -s -DINLINE=inline $(TARGET).c + -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).code-out $(TARGET).$(MC).out check-code-make: mc $(MC) - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).code-out diff -r 44c276fa9ec6 -r c59753132812 Makefile.i64 --- a/Makefile.i64 Wed Nov 24 15:14:05 2010 +0900 +++ b/Makefile.i64 Fri Nov 26 14:41:31 2010 +0900 @@ -12,7 +12,7 @@ STAGE=1 MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE) ARCH=i64 -MC=mc-$(ARCH) +MC=mc-$(ARCH) MLIB = -lm PRINTF= # printf.c CONVERTER=conv/c.o conv/null.o conv/c2cbc.o conv/cbc2c.o @@ -162,7 +162,7 @@ check: mc $(MC) $(TARGET).c -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -./b.out > $(TARGET).gcc.out - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).gcc.out $(TARGET).$(MC).out @@ -170,23 +170,23 @@ check-inline: mc $(MC) $(TARGET).c -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB) -./b.out > $(TARGET).gcc.out - -./$(MC) -s -DINLINE=inline $(TARGET).c + -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).gcc.out $(TARGET).$(MC).out check-code: mc $(MC) - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).code-out $(TARGET).$(MC).out check-code-inline: mc $(MC) - -./$(MC) -s -DINLINE=inline $(TARGET).c + -./$(MC) $(MCFLAG) -s -DINLINE=inline $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).$(MC).out -diff $(TARGET).code-out $(TARGET).$(MC).out check-code-make: mc $(MC) - -./$(MC) -s $(TARGET).c + -./$(MC) $(MCFLAG) -s $(TARGET).c -$(CC) $(TARGET).s $(MLIB) -./a.out > $(TARGET).code-out diff -r 44c276fa9ec6 -r c59753132812 mc-code-i64.c --- a/mc-code-i64.c Wed Nov 24 15:14:05 2010 +0900 +++ b/mc-code-i64.c Fri Nov 26 14:41:31 2010 +0900 @@ -824,29 +824,17 @@ } #if FLOAT_CODE -#define use_float(d,reg) if (reg==USE_CREG) reg=d?use_double0():use_float0() +#define use_float(d,reg) if (reg==USE_CREG) reg=use_double0(d) static -int use_float0() { +int use_double0(int d) { int i = creg; if (!is_float_reg(i)) { - if (!freg) freg = get_dregister(0); - else if (freg!=i) if (regs[i]!=REG_VAR) free_register(i); + if (!freg) freg = get_dregister(d); + if (regs[i]!=REG_VAR) free_register(i); i = freg; } if (!regs[i]) regs[i]=USING_REG; - creg = i; - return i; -} -static -int use_double0() { - int i = creg; - if (!is_float_reg(i)) { - if (!freg) freg = get_dregister(1); - else if (freg!=i) if (regs[i]!=REG_VAR) free_register(i); - i = freg; - } - if (!regs[i]) regs[i]=USING_REG; - creg = i; + creg = freg = i; return i; } #endif diff -r 44c276fa9ec6 -r c59753132812 mc-codegen.c --- a/mc-codegen.c Wed Nov 24 15:14:05 2010 +0900 +++ b/mc-codegen.c Fri Nov 26 14:41:31 2010 +0900 @@ -2208,12 +2208,12 @@ default: switch(type_value(type)) { case DOUBLE: break; - case FLOAT: e2 = list3(CONV,rvalue(e2),F2D); break; - case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2D); break; - case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2D); break; - case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2D); break; + case FLOAT: e2 = list3(CONV,e2,F2D); break; + case UNSIGNED: e2 = list3(CONV,e2,U2D); break; + case LONGLONG: e2 = list3(CONV,e2,LL2D); break; + case ULONGLONG: e2 = list3(CONV,e2,ULL2D); break; default: - if(integral(type)) e2 = list3(CONV,rvalue(e2),I2D); + if(integral(type)) e2 = list3(CONV,e2,I2D); else { error(TYERR); e2 = dlist2(DCONST,1.0); } } } @@ -2232,13 +2232,13 @@ else if (car(e2)==DCONST) e2 = dlist2(FCONST,dcadr(e2)); else { switch(type_value(type)) { - case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2F); break; - case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2F); break; + case LONGLONG: e2 = list3(CONV,e2,LL2F); break; + case ULONGLONG: e2 = list3(CONV,e2,ULL2F); break; case FLOAT: break; - case DOUBLE: e2 = list3(CONV,rvalue(e2),D2F); break; - case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2F); break; + case DOUBLE: e2 = list3(CONV,e2,D2F); break; + case UNSIGNED: e2 = list3(CONV,e2,U2F); break; default: - if(integral(type)) e2 = list3(CONV,rvalue(e2),I2F); + if(integral(type)) e2 = list3(CONV,e2,I2F); else { error(TYERR); e2 = dlist2(DCONST,1.0); } } } @@ -2260,13 +2260,13 @@ #endif else { switch(type_value(type)) { - case FLOAT: e2 = list3(CONV,rvalue(e2),F2LL); break; - case DOUBLE: e2 = list3(CONV,rvalue(e2),D2LL); break; - case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2LL); break; + case FLOAT: e2 = list3(CONV,e2,F2LL); break; + case DOUBLE: e2 = list3(CONV,e2,D2LL); break; + case UNSIGNED: e2 = list3(CONV,e2,U2LL); break; case LONGLONG: break; case ULONGLONG: break; default: - if(integral(type)) e2 = list3(CONV,rvalue(e2),I2LL); + if(integral(type)) e2 = list3(CONV,e2,I2LL); else if(lp64); else { error(TYERR); e2 = llist2(LCONST,0LL); } } @@ -2292,13 +2292,13 @@ #endif else { switch(type_value(type)) { - case FLOAT: e2 = list3(CONV,rvalue(e2),F2ULL); break; - case DOUBLE: e2 = list3(CONV,rvalue(e2),D2ULL); break; - case UNSIGNED: e2 = list3(CONV,rvalue(e2),U2ULL); break; + case FLOAT: e2 = list3(CONV,e2,F2ULL); break; + case DOUBLE: e2 = list3(CONV,e2,D2ULL); break; + case UNSIGNED: e2 = list3(CONV,e2,U2ULL); break; case LONGLONG: break; case ULONGLONG: break; default: - if(integral(type)) e2 = list3(CONV,rvalue(e2),I2ULL); + if(integral(type)) e2 = list3(CONV,e2,I2ULL); else if(lp64); else { error(TYERR); e2 = llist2(LCONST,0LL); } } @@ -2323,10 +2323,10 @@ #endif else { switch(t) { - case FLOAT: e2 = list3(CONV,rvalue(e2),F2I); break; - case DOUBLE: e2 = list3(CONV,rvalue(e2),D2I); break; - case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2I); break; - case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2I); break; + case FLOAT: e2 = list3(CONV,e2,F2I); break; + case DOUBLE: e2 = list3(CONV,e2,D2I); break; + case LONGLONG: e2 = list3(CONV,e2,LL2I); break; + case ULONGLONG: e2 = list3(CONV,e2,ULL2I); break; default: error(TYERR); e2 = list2(CONST,1); } @@ -2340,7 +2340,7 @@ { int t = type_value(type); if (t!=CHAR&&t!=INT) { - e2 = list3(CONV,int_value(rvalue(e2)),I2C); + e2 = list3(CONV,int_value(e2),I2C); type = set_type_with_attr(INT,type); } return e2; @@ -2351,7 +2351,7 @@ { int t = type_value(type); if (t!=SHORT&&t!=INT) { - e2 = list3(CONV,int_value(rvalue(e2)),I2S); + e2 = list3(CONV,int_value(e2),I2S); type = set_type_with_attr(INT,type); } return e2; @@ -2380,10 +2380,10 @@ #endif else { switch(t) { - case LONGLONG: e2 = list3(CONV,rvalue(e2),LL2U); break; - case ULONGLONG: e2 = list3(CONV,rvalue(e2),ULL2U); break; - case FLOAT: e2 = list3(CONV,rvalue(e2),F2U); break; - case DOUBLE: e2 = list3(CONV,rvalue(e2),D2U); break; + case LONGLONG: e2 = list3(CONV,e2,LL2U); break; + case ULONGLONG: e2 = list3(CONV,e2,ULL2U); break; + case FLOAT: e2 = list3(CONV,e2,F2U); break; + case DOUBLE: e2 = list3(CONV,e2,D2U); break; default: error(TYERR); } @@ -2397,7 +2397,7 @@ { int t = type_value(type); if (t!=UCHAR&&t!=UNSIGNED) { - e2 = list3(CONV,unsigned_value(rvalue(e2)),U2UC); + e2 = list3(CONV,unsigned_value(e2),U2UC); type = set_type_with_attr(UNSIGNED,type); } return e2; @@ -2408,7 +2408,7 @@ { int t = type_value(type); if (t!=USHORT&&t!=UNSIGNED) { - e2 = list3(CONV,unsigned_value(rvalue(e2)),U2US); + e2 = list3(CONV,unsigned_value(e2),U2US); type = set_type_with_attr(UNSIGNED,type); } return e2; @@ -4335,6 +4335,10 @@ offset=cadr(e4); e1=e3; } + } else if (car(e2)==LADD) { + e4=caddr(e2); + if (car(e4)==CONST) { offset=cadr(e4); e1=e3; } + else if (car(e4)==LCONST) { offset=lcadr(e4); e1=e3; } } return list4(t,e1,offset,type); } @@ -4399,7 +4403,7 @@ error(TYERR); } } - switch(car(e)) { + switch(OP(car(e))) { case GVAR: n = ncaddr(e); if (cadr(e)==0 && (c=attr_value(n,KONST))) { @@ -4415,7 +4419,7 @@ } return(list3n(RLVAR+op,cadr(e),ncaddr(e))); case INDIRECT: - return(indirect(RINDIRECT+op,cadr(e),type0)); + 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: diff -r 44c276fa9ec6 -r c59753132812 mc-inline.c --- a/mc-inline.c Wed Nov 24 15:14:05 2010 +0900 +++ b/mc-inline.c Fri Nov 26 14:41:31 2010 +0900 @@ -509,6 +509,14 @@ static int prindirect(int e) { +#if 0 + int offset = caddr(e); + int e1 = pexpr(cadr(e)); + e1 = binop(ADD,e1,list2(CONST,offset),list2(POINTER,type),INT); + type = cadddr(e); + e1 = rvalue(e1); + return indop(e1); +#else int lvar; int offset = caddr(e); int type0; @@ -517,22 +525,23 @@ if (type0>0 && car(type0)==POINTER) type=set_type_with_attr(cadr(type),type); if (car(lvar=cadr(e))==IVAR) { - lvar=p_lvar(cadr(e)); // can be anything.... - switch(car(lvar)) { - case LVAR: - if(offset) { - return list3(car(e),lvar,offset); - } - return rvalue_t(lvar,cadddr(e)); - case REGISTER: case DREGISTER: - case FREGISTER: case LREGISTER: - case CONST: case FCONST: case DCONST: case LCONST: - // should do type check - if (offset) error(-1); - return lvar; - } + lvar=p_lvar(cadr(e)); // can be anything.... + switch(car(lvar)) { + case LVAR: + if(offset) { + return list3(car(e),lvar,offset); + } + return rvalue_t(lvar,cadddr(e)); + case REGISTER: case DREGISTER: + case FREGISTER: case LREGISTER: + case CONST: case FCONST: case DCONST: case LCONST: + // should do type check + if (offset) error(-1); + return lvar; + } } return list3(car(e),pexpr(cadr(e)),offset); +#endif } static int