Mercurial > hg > CbC > old > device
changeset 469:cf1c2c42b7c8
fix iassop
author | kono |
---|---|
date | Sat, 30 Jul 2005 20:54:40 +0900 |
parents | 464e7480395c |
children | cc5ea30efe0c |
files | Changes mc-code-powerpc.c mc-codegen.c mc-macro.c test/code-gen.c |
diffstat | 5 files changed, 197 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sat Jul 30 16:22:00 2005 +0900 +++ b/Changes Sat Jul 30 20:54:40 2005 +0900 @@ -7171,16 +7171,33 @@ inline code ってのはありえるの? +何か知らないが gcc が .s の#マクロの展開をするようになってるね。 + + #include_next <stdarg.h> + +ですかぁ?! + ./mc1 -s -ob10.s mc-parse.c /usr/include/sys/cdefs.h:335:Macro syntax # error Unknown architecture このエラーはなんかあったが... __ppc__ が定義されてないのがいけないのだよ。 - -何か知らないが gcc が .s の#マクロの展開をするようになってるね。 - - #include_next <stdarg.h> - -ですかぁ?! - - +ifdef を見るときには EMPTY になってるな。 + +## nptr_pool->ptr += sizeof(NMTBL); +## 4074: gexpr_init: creg=r3 freg=f14 + lwz r3,0(r11) nptr_pool を読み込んで来る + stw r3,lo16(-20)(r30) + la r3,lo16(-20)(r30) + la r10,lo16(-20)(r30) + addi r10,r10,lo16(24) + stw r10,0(r3) + +これだな。 + +iassop の hoge += const の処理が間違っていたみたい。他のは?! +そもそも、この定数演算の処理ってだめだめだよね? + +いつどこで、こうなったのか... って、そもそも、ここに落ちるのが +変だよね。 +
--- a/mc-code-powerpc.c Sat Jul 30 16:22:00 2005 +0900 +++ b/mc-code-powerpc.c Sat Jul 30 20:54:40 2005 +0900 @@ -9,6 +9,7 @@ char *l_include_path[] = { "/usr/include/", + "/usr/lib/gcc/i686-apple-darwin8/4.0.0/include/", 0 }; @@ -18,6 +19,7 @@ #define __ppc__ 1\n\ #define __BIG_ENDIAN__ 1\n\ #define __STDC__ 1\n\ +#define __GNUC__ 1\n\ #define __builtin_va_list int\n\ #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\ #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
--- a/mc-codegen.c Sat Jul 30 16:22:00 2005 +0900 +++ b/mc-codegen.c Sat Jul 30 20:54:40 2005 +0900 @@ -2200,7 +2200,8 @@ /* *new = *new op e3 */ n = list3(LVAR,new_lvar(size_of_int),0); g_expr_u(assign_expr0(n,list2(ADDRESS,e2),INT,INT)); - g_expr(assign_expr0(list2(INDIRECT,n),list3(op,n,e3),t,t)); + g_expr(assign_expr0(rvalue_t(n,INT), + list3(op,rvalue_t(list2(INDIRECT,rvalue_t(n,INT)),t),e3),t,t)); free_lvar(cadr(n)); return; }
--- a/mc-macro.c Sat Jul 30 16:22:00 2005 +0900 +++ b/mc-macro.c Sat Jul 30 20:54:40 2005 +0900 @@ -112,7 +112,7 @@ */ static FILE * -getfname(void) +getfname(int next) { int i,end='"',err=0; char *s,*p,**pp,*name; @@ -135,13 +135,20 @@ cheap = increment_cheap(cheap,&name); save_cheap(&scheap,cheap); fp = fopen(name,"r") ; + if (next && fp) { fclose(fp); fp=0; next=0; } if (fp) { p = name; } else { for(pp=(end=='>'||filep->inc=='>') ?l_include_path:include_path; *pp;pp++) { p = expand_file_name(*pp,name); - if ((fp = fopen(p,"r"))) break ; + if ((fp = fopen(p,"r"))) { + if (next) { + fclose(fp); fp=0; next=0; + continue; + } else + break ; + } } } if(!fp) { error(FILERR); return filep->fcb; } @@ -331,6 +338,7 @@ int i; int c; int mode_save; + int next; ++chptr; while (*chptr==' '||*chptr=='\t') ++chptr; @@ -426,9 +434,10 @@ } break; case 'i': - if (macroeq("include")) { + next = 1; + if (macroeq("include_next")|| (next=0, macroeq("include"))) { if(filep+1 >= filestack + FILES) error(FILERR); - if ( ((filep+1)->fcb=getfname()) == NULL) error(FILERR); + if ( ((filep+1)->fcb=getfname(next)) == NULL) error(FILERR); (filep+1)->ln=lineno; lineno=0; ++filep;
--- a/test/code-gen.c Sat Jul 30 16:22:00 2005 +0900 +++ b/test/code-gen.c Sat Jul 30 20:54:40 2005 +0900 @@ -968,6 +968,161 @@ printf("#0967:code_assop 9 %u\n",ui1); } +// iassop_l(int op,int byte,int sign) +void +code_iassop_l() +{ + struct hoge { int i1,i2; + unsigned int ui1,ui2; + } s, *p; + int a = 3; + p = &s; + + p->i1 = -555; p->i2= 555; + p->ui1 = 632423423; p->ui2= 32394234; + + p->i1 += a; + printf("#0981:iassop 1 %d\n",p->i1); + p->i1 -= a; + printf("#0983:iassop 2 %d\n",p->i1); + p->i1 /= a; + printf("#0985:iassop 3 %d\n",p->i1); + p->i1 *= a; + printf("#0987:iassop 4 %d\n",p->i1); + p->i1 |= a; + printf("#0989:iassop 5 %d\n",p->i1); + p->i1 &= a; + printf("#0991:iassop 6 %d\n",p->i1); + p->i1 ^= a; + printf("#0993:iassop 7 %d\n",p->i1); + p->i1 <<= a; + printf("#0995:iassop 8 %d\n",p->i1); + p->i1 >>= a; + printf("#0997:iassop 9 %d\n",p->i1); + + p->ui1 += a; + printf("#1000:iassop 1 %u\n",p->ui1); + p->ui1 -= a; + printf("#1002:iassop 2 %u\n",p->ui1); + p->ui1 /= a; + printf("#1004:iassop 3 %u\n",p->ui1); + p->ui1 *= a; + printf("#1006:iassop 4 %u\n",p->ui1); + p->ui1 |= a; + printf("#1008:iassop 5 %u\n",p->ui1); + p->ui1 &= a; + printf("#1010:iassop 6 %u\n",p->ui1); + p->ui1 ^= a; + printf("#1012:iassop 7 %u\n",p->ui1); + p->ui1 <<= a; + printf("#1014:iassop 8 %u\n",p->ui1); + p->ui1 >>= a; + printf("#1016:iassop 9 %u\n",p->ui1); +} + +// iassop_l(int op,int byte,int sign) + +struct ghoge { int i1,i2; + unsigned int ui1,ui2; +} gs, *gp; + +void +code_iassop_g() +{ + int a = 3; + gp = &gs; + + gp->i1 = -555; gp->i2= 555; + gp->ui1 = 632423423; gp->ui2= 32394234; + + gp->i1 += a; + printf("#0981:iassop 1 %d\n",gp->i1); + gp->i1 -= a; + printf("#0983:iassop 2 %d\n",gp->i1); + gp->i1 /= a; + printf("#0985:iassop 3 %d\n",gp->i1); + gp->i1 *= a; + printf("#0987:iassop 4 %d\n",gp->i1); + gp->i1 |= a; + printf("#0989:iassop 5 %d\n",gp->i1); + gp->i1 &= a; + printf("#0991:iassop 6 %d\n",gp->i1); + gp->i1 ^= a; + printf("#0993:iassop 7 %d\n",gp->i1); + gp->i1 <<= a; + printf("#0995:iassop 8 %d\n",gp->i1); + gp->i1 >>= a; + printf("#0997:iassop 9 %d\n",gp->i1); + + gp->ui1 += a; + printf("#1000:iassop 1 %u\n",gp->ui1); + gp->ui1 -= a; + printf("#1002:iassop 2 %u\n",gp->ui1); + gp->ui1 /= a; + printf("#1004:iassop 3 %u\n",gp->ui1); + gp->ui1 *= a; + printf("#1006:iassop 4 %u\n",gp->ui1); + gp->ui1 |= a; + printf("#1008:iassop 5 %u\n",gp->ui1); + gp->ui1 &= a; + printf("#1010:iassop 6 %u\n",gp->ui1); + gp->ui1 ^= a; + printf("#1012:iassop 7 %u\n",gp->ui1); + gp->ui1 <<= a; + printf("#1014:iassop 8 %u\n",gp->ui1); + gp->ui1 >>= a; + printf("#1016:iassop 9 %u\n",gp->ui1); +} + +void +code_iassop_g_c() +{ + const int a = 3; + gp = &gs; + + gp->i1 = -555; gp->i2= 555; + gp->ui1 = 632423423; gp->ui2= 32394234; + + gp->i1 += a; + printf("#0981:iassop 1 %d\n",gp->i1); + gp->i1 -= a; + printf("#0983:iassop 2 %d\n",gp->i1); + gp->i1 /= a; + printf("#0985:iassop 3 %d\n",gp->i1); + gp->i1 *= a; + printf("#0987:iassop 4 %d\n",gp->i1); + gp->i1 |= a; + printf("#0989:iassop 5 %d\n",gp->i1); + gp->i1 &= a; + printf("#0991:iassop 6 %d\n",gp->i1); + gp->i1 ^= a; + printf("#0993:iassop 7 %d\n",gp->i1); + gp->i1 <<= a; + printf("#0995:iassop 8 %d\n",gp->i1); + gp->i1 >>= a; + printf("#0997:iassop 9 %d\n",gp->i1); + + gp->ui1 += a; + printf("#1000:iassop 1 %u\n",gp->ui1); + gp->ui1 -= a; + printf("#1002:iassop 2 %u\n",gp->ui1); + gp->ui1 /= a; + printf("#1004:iassop 3 %u\n",gp->ui1); + gp->ui1 *= a; + printf("#1006:iassop 4 %u\n",gp->ui1); + gp->ui1 |= a; + printf("#1008:iassop 5 %u\n",gp->ui1); + gp->ui1 &= a; + printf("#1010:iassop 6 %u\n",gp->ui1); + gp->ui1 ^= a; + printf("#1012:iassop 7 %u\n",gp->ui1); + gp->ui1 <<= a; + printf("#1014:iassop 8 %u\n",gp->ui1); + gp->ui1 >>= a; + printf("#1016:iassop 9 %u\n",gp->ui1); +} + + // code_assop(int op,int byte,int sign) void code_assop()