Mercurial > hg > CbC > old > device
changeset 468:464e7480395c
*** empty log message ***
author | kono |
---|---|
date | Sat, 30 Jul 2005 16:22:00 +0900 |
parents | 32737bad7489 |
children | cf1c2c42b7c8 |
files | Changes conv/c.c mc-code-ia32.c mc-code-powerpc.c mc-codegen.c mc-switch.c mc-tree.c test/switch.c |
diffstat | 8 files changed, 86 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/Changes Sat Jul 30 16:01:45 2005 +0900 +++ b/Changes Sat Jul 30 16:22:00 2005 +0900 @@ -7166,7 +7166,21 @@ Sat Jul 30 14:41:54 JST 2005 あぁ、function の型のlist node にVOIDというprimitive型が入ってしまって -いるね。これは、なんか、やっちまった記憶があるが... +いるね。これは、なんか、やっちまった記憶があるが... どうも、もともと +あまりちゃんとしてなくて、type<0でも car(type)とかやってたみたいだね。 inline code ってのはありえるの? + ./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> + +ですかぁ?! + +
--- a/conv/c.c Sat Jul 30 16:01:45 2005 +0900 +++ b/conv/c.c Sat Jul 30 16:22:00 2005 +0900 @@ -147,7 +147,7 @@ } int -error_(n){ +error_(int n){ return 0; }
--- a/mc-code-ia32.c Sat Jul 30 16:01:45 2005 +0900 +++ b/mc-code-ia32.c Sat Jul 30 16:22:00 2005 +0900 @@ -477,7 +477,7 @@ register_usage(char *s) { int i; - printf("# %d: %s:",lineno,s); + printf("## %d: %s:",lineno,s); printf(" creg=%s dreg=%s ",register_name(creg,0),register_name(dreg,0)); for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); @@ -493,7 +493,7 @@ printf(" %s",register_name(reg_stack[i],0)); } #endif - printf(" f:%d",freg_sp); + printf("# f:%d",freg_sp); printf("\n"); } @@ -512,7 +512,7 @@ /* process in reverse order */ n = (NMTBL*)caddr(args); type = n->ty; -// printf("# %s %d %d\n",n->nm,n->dsp,n->ty); +// printf("## %s %d %d\n",n->nm,n->dsp,n->ty); if (scalar(type)) { if ((reg = get_input_register_var(reg_var,n,is_code0))) { n->sc = REGISTER; @@ -693,7 +693,7 @@ else if (type==DATA_REG) use_data_reg(dreg,0); if (regv[dreg]) { - printf("# emit_pop dreg conflict\n"); + printf("## emit_pop dreg conflict\n"); error(-1); } printf("\tpopl %s\n",register_name(dreg,0)); @@ -2553,7 +2553,7 @@ int pop_fregister() { if (freg_sp<0) { error(-1); return -1;} - // printf("# fpop: %d\n",freg_sp-1); + // printf("## fpop: %d\n",freg_sp-1); return freg_stack[--freg_sp]; } @@ -2582,7 +2582,7 @@ if (freg_sp>=MAX_FPU_STACK) code_save_fstacks(); if (freg_sp>MAX_MAX) error(-1); freg_stack[freg_sp++]=-1; - // printf("# fpush:%d\n",freg_sp); + // printf("## fpush:%d\n",freg_sp); } #endif @@ -3347,7 +3347,7 @@ int val; int clobber = 0; - printf("# constraint %s\n",p); + printf("## constraint %s\n",p); if (*p=='=') { // output register p++; @@ -3509,7 +3509,7 @@ i = l+bitsize; *bfd = (i==bitsz)?0:i; *sz = (i+7)/8; -// printf("# bitpos=%d bitsize=%d bitsz=%d offset=%d\n",l,bitsize,bitsz,*poffset); +// printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",l,bitsize,bitsz,*poffset); return l; } } @@ -3524,7 +3524,7 @@ *bfd = (bitsize==bitsz)?0:bitsize; *sz = (bitsize+7)/8; -// printf("# bitpos=%d bitsize=%d bitsz=%d offset=%d\n",bitpos,bitsize,bitsz,*poffset); +// printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",bitpos,bitsize,bitsz,*poffset); return bitpos; } @@ -3538,7 +3538,7 @@ int i,size; set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l); size=bitsz/8; -// printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); +// printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); /* this implementation returns -1 for int i:1; */ if (l==1) { #if LONGLONG_CODE @@ -3571,7 +3571,7 @@ static void make_mask_and_or(int mask,int reg,int lreg) { -printf("# mask 0x%08x ~0x%08x\n",mask,~mask); +printf("## mask 0x%08x ~0x%08x\n",mask,~mask); printf("\tpushl %s\n",register_name(reg,0)); /* make and-mask */ oprtc(BOR,reg,list2(CONST,~mask)); @@ -3606,7 +3606,7 @@ int size; set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l); size = bitsz/8; -// printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); +// printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); if (l) { #if LONGLONG_CODE int push=0; @@ -3664,7 +3664,7 @@ make_mask_and_or_const(int mask,int reg,int c) { int a; -// printf("# mask 0x%08x ~0x%08x\n",mask,~mask); +// printf("## mask 0x%08x ~0x%08x\n",mask,~mask); a = ~mask|c; if (a!=-1) { /* do conjunction */ @@ -3702,7 +3702,7 @@ #endif set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l); size = bitsz/8; -// printf("# %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); +// printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz); use_int(adr); if (l) { #if LONGLONG_CODE
--- a/mc-code-powerpc.c Sat Jul 30 16:01:45 2005 +0900 +++ b/mc-code-powerpc.c Sat Jul 30 16:22:00 2005 +0900 @@ -320,23 +320,23 @@ } #if 0 -printf("# reg_save %d\n",reg_save); -printf("# function %s\n",fnptr->nm); +printf("## reg_save %d\n",reg_save); +printf("## function %s\n",fnptr->nm); l = ARG_LVAR_OFFSET; -printf("# offset call0\t%d\n",CALLER_ARG); +printf("## offset call0\t%d\n",CALLER_ARG); l = ARG_LVAR_OFFSET+max_func_args*SIZE_OF_INT; -printf("# offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT); +printf("## offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT); l = disp; -printf("# offset lvarn\t%d %d\n",FUNC_LVAR+lvar_offsetv,disp); +printf("## offset lvarn\t%d %d\n",FUNC_LVAR+lvar_offsetv,disp); l = 0; -printf("# offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv); +printf("## offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv); l = -reg_save; -printf("# offset regs\t%d\n",FUNC_LVAR+lvar_offsetv); -printf("# offset r1off\t%d\n",r1_offsetv); +printf("## offset regs\t%d\n",FUNC_LVAR+lvar_offsetv); +printf("## offset r1off\t%d\n",r1_offsetv); l = 0; -printf("# offset carg0\t%d\n",CALLEE_ARG+r1_offsetv); +printf("## offset carg0\t%d\n",CALLEE_ARG+r1_offsetv); l = my_func_args; -printf("# offset cargn\t%d %d\n",CALLEE_ARG+r1_offsetv,my_func_args); +printf("## offset cargn\t%d %d\n",CALLEE_ARG+r1_offsetv,my_func_args); #endif } @@ -580,7 +580,7 @@ get_register(void) { int i = get_register0(); - printf("# get_register %d\n",i); + printf("## get_register %d\n",i); return i; } #endif @@ -627,7 +627,7 @@ get_dregister(int d) { int i = get_dregister0(d); -printf("# get_dregister %d\n",i); +printf("## get_dregister %d\n",i); return i; } #endif @@ -645,7 +645,7 @@ int i; for(i=LREG_OFFSET+1;i<REAL_MAX_LREGISTER+LREG_OFFSET;i++) { if (regs[i]==0) { -// printf("# get_lregister %d\n",i); +// printf("## get_lregister %d\n",i); return i; } } @@ -715,7 +715,7 @@ void free_register(int i) { /* いらなくなったレジスタを開放 */ -// printf("# free_register %d\n",i); +// printf("## free_register %d\n",i); regs[i]=0; if (is_longlong_reg(i)) { regs[regv_l(i)]=0; @@ -807,7 +807,7 @@ for(i=0;i<MAX_FREGISTER;i++) { if (! regs[i+FREG_OFFSET]) fcount++; } - printf("# free reg %d freg %d\n",count,fcount); + printf("## free reg %d freg %d\n",count,fcount); return d?fcount:count; } @@ -829,7 +829,7 @@ free_all_register(void) { int i; -// printf("# free_all register\n"); +// printf("## free_all register\n"); #if LONGLONG_CODE for(i=0;i<REAL_MAX_LREGISTER;i++) { regs[i+LREG_OFFSET]=0; @@ -910,7 +910,7 @@ #if 1 for(j=0,i=0;i<MAX_REGISTER;i++) if (regs[i]) j++; if (j>USAGE_MAX) { - printf("\n# regs:"); + printf("\n## regs:"); for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); } } if (reg_sp>0) { @@ -924,7 +924,7 @@ } for(j=0,i=0;i<MAX_FREGISTER;i++) if (regs[i+FREG_OFFSET]) j++; if (j>USAGE_MAX) { - printf("\n# freg:"); + printf("\n## freg:"); for(i=0;i<MAX_FREGISTER;i++) { printf("%d",regs[i+FREG_OFFSET]); } } if (freg_sp>0) { @@ -939,7 +939,7 @@ for(j=0,i=0;i<REAL_MAX_LREGISTER;i++) if (regs[i+LREG_OFFSET]) j++; if (j>USAGE_MAX) { - printf("\n# lreg:"); + printf("\n## lreg:"); for(i=0;i<REAL_MAX_LREGISTER;i++) { printf("%d",regs[i+LREG_OFFSET]); } } if (lreg_sp>0) { @@ -1694,7 +1694,7 @@ void use_reg(int arg) { -// printf("# use reg %d\n",arg); +// printf("## use reg %d\n",arg); if (arg<0||arg> REAL_MAX_REGISTER+REAL_MAX_FREGISTER+ REAL_MAX_LREGISTER) error(-1); clear_ptr_cache_reg(arg); @@ -2366,7 +2366,7 @@ free_register(creg); emit_pop_free(xreg); #else - printf("# assop\n\tmr %s,%s\n",register_name(edx),register_name(creg)); + printf("## assop\n\tmr %s,%s\n",register_name(edx),register_name(creg)); ld_indexx(byte,0,edx,creg,sign); tosop(op,creg,xreg); crn = register_name(creg); @@ -4887,7 +4887,7 @@ if (regv_l(lreg)==edx || regv_h(lreg)==edx) { // this can't happen edx0 = get_register(); if(!edx0) error(-1); - printf("# lassop\n\tmr %s,%s\n",register_name(edx0),register_name(edx)); + printf("## lassop\n\tmr %s,%s\n",register_name(edx0),register_name(edx)); edx = edx0; } lload(edx0=edx,reg,0);
--- a/mc-codegen.c Sat Jul 30 16:01:45 2005 +0900 +++ b/mc-codegen.c Sat Jul 30 16:22:00 2005 +0900 @@ -538,7 +538,7 @@ } static int -rop_dual(op) +rop_dual(int op) { // x op y => y dual(op) x switch(op) { @@ -931,9 +931,9 @@ if (is_same_type(s,t)) { s1=s0+caddr(source); #if DEBUG_PARALLEL_ASSIGN>1 -printf("# overlap source %d t0 %d t1 %d\n",car(car(t)),t0,t1); -printf("# overlap target %d s0 %d s1 %d\n",car(car(source)),s0,s1); -printf("# overlap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1))); +printf("## overlap source %d t0 %d t1 %d\n",car(car(t)),t0,t1); +printf("## overlap target %d s0 %d s1 %d\n",car(car(source)),s0,s1); +printf("## overlap equal = %d\n",((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1))); #endif if((t0<=s0&&s0<t1)||(t0<s1&&s1<=t1)) result = list2(target,result); @@ -1008,7 +1008,7 @@ for(h=history;h;h=cadr(h)) { if (t1==car(h)) { #if DEBUG_PARALLEL_ASSIGN -printf("# circular dependency %d ty %d\n",car(t1),cadr(t1)); +printf("## circular dependency %d ty %d\n",car(t1),cadr(t1)); #endif return t1; } @@ -1047,7 +1047,7 @@ if(car(t)==car(s) && cadr(t)==cadr(s)) { /*書き込み先が自分自身*/ #if DEBUG_PARALLEL_ASSIGN -printf("# remove same %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); +printf("## remove same %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); #endif remove_target(target,t,use); progress = 1; @@ -1056,9 +1056,9 @@ /* 重なってないので安心して書き込める */ #if DEBUG_PARALLEL_ASSIGN if (s1 && cadr(s1)==0) -printf("# singleton %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); +printf("## singleton %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); else -printf("# normal assign %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); +printf("## normal assign %d ty %d+%d sz %d\n",car(t),ty,cadr(t),sz); #endif g_expr_u(assign_expr0(t,s,ty,ty)); remove_target(target,t,use); @@ -1069,7 +1069,7 @@ save_target(car(t),cadddr(t),target,use,sz,ty); progress = 1; #if DEBUG_PARALLEL_ASSIGN - printf("# saving %d ty %d+%d sz %d\n",car(car(t)),ty,cadr(car(t)),sz); + printf("## saving %d ty %d+%d sz %d\n",car(car(t)),ty,cadr(car(t)),sz); #endif break; } @@ -1081,7 +1081,7 @@ t=car(target0); s=cadddr(target0); sz=size(ty=caddr(target0)); #if DEBUG_PARALLEL_ASSIGN -printf("# can't progress save any %d ty %d+%d sz %d\n",car(s),ty,cadr(t),sz); +printf("## can't progress save any %d ty %d+%d sz %d\n",car(s),ty,cadr(t),sz); #endif remove_target(target,t,use); save_target(t,s,target,use,sz,ty); @@ -1257,7 +1257,7 @@ /* keep arg space for register variables */ arg_size += sz; #if DEBUG_PARALLEL_ASSIGN -printf("# target %d ty %d+%d sz %d\n",car(car(target)),ty,cadr(car(target)),sz); +printf("## target %d ty %d+%d sz %d\n",car(car(target)),ty,cadr(car(target)),sz); #endif } @@ -1306,14 +1306,14 @@ /* large struct generate large save/restore */ /* divide it to avoid large copy */ #if DEBUG_PARALLEL_ASSIGN -printf("# division sz %d\n",sz); +printf("## division sz %d\n",sz); #endif caddr(e2) = UNSIGNED; caddddr(e2) = list3( cadddr(e2)=list3(LVAR,cadr(s0),0), 0, size_of_int); #if DEBUG_PARALLEL_ASSIGN -printf("# div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),size_of_int); +printf("## div 0 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),size_of_int); #endif for(e4=size_of_int;e4<sz;) { cadr(e2) = list5(car(e2),cadr(e2), @@ -1330,7 +1330,7 @@ cadddr(e2) = list3(LVAR,cadr(s0)+e4,0),0, r); e4 += r; #if DEBUG_PARALLEL_ASSIGN -printf("# div 1 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),r); +printf("## div 1 source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),r); #endif } e2 = e3; @@ -1338,7 +1338,7 @@ } caddddr(e2)=list3(s0,0,sz); #if DEBUG_PARALLEL_ASSIGN -printf("# source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),sz); +printf("## source %d ty %d+%d sz %d\n",car(s0),ty,cadr(s0),sz); #endif } else { /* check used sources in rather complex source */ @@ -2612,7 +2612,7 @@ int assign = 0; char *p; - printf("# asm\n"); + printf("## asm\n"); in = reverse0(in); out = reverse0(out); e = reverse0(e); @@ -2928,7 +2928,7 @@ ascii((char *)cadr(e)); return; } - // fprintf(stderr,"# type= %d\n",t); + // fprintf(stderr,"## type= %d\n",t); } error(INERR); } @@ -3845,7 +3845,7 @@ { int reg; if (car(e1)==BIT_FIELD) { - printf("# bit_field_bug\n"); + printf("## bit_field_bug\n"); e1 = cadr(e1); } g_expr(e1);
--- a/mc-switch.c Sat Jul 30 16:01:45 2005 +0900 +++ b/mc-switch.c Sat Jul 30 16:22:00 2005 +0900 @@ -108,7 +108,7 @@ *delta = g; #if 0 if (count1*128>(range*128*CASE_MERGE_RATE/100)) { - printf("# min %d, max %d, count %d, delta %d, rate %g t=%d\n", + printf("## min %d, max %d, count %d, delta %d, rate %g t=%d\n", min,max,count1,g, ((double)count1)*100.0/range, count1*128>(range*128*CASE_MERGE_RATE/100) @@ -120,7 +120,7 @@ } static void -free_chunks(chunks) +free_chunks(int chunks) { int p; while(chunks) { @@ -168,7 +168,7 @@ int list; for(;count-->0;cslist=cadr(cslist)) { list = car(cslist); - printf("# cascade cases delta=%d count=%d min=%d max=%d\n", + printf("## cascade cases delta=%d count=%d min=%d max=%d\n", caddr(cslist),car(cadddr(cslist)), cadr(cadddr(cslist)),caddr(cadddr(cslist)) ); @@ -196,7 +196,7 @@ max=caddr(cadddr(list)); } - printf("# table count %d delta %d max %d min %d\n", + printf("## table count %d delta %d max %d min %d\n", count,delta,max,min); l = fwdlabel(); @@ -242,7 +242,7 @@ switch_make_index_leaf(int count,int index,int level) { control=1; - printf("# index leaf count=%d level=%d\n",count,level); + printf("## index leaf count=%d level=%d\n",count,level); for(;count-- !=0 && cadr(index);index=cadr(index)) { switch_index_jmp( cadr(index), index_label(index) ); } @@ -300,7 +300,7 @@ { control=1; for(;count-- !=0 && merge;merge=cadr(merge)) { - printf("# merge count %d delta %d c_count %d\n", + printf("## merge count %d delta %d c_count %d\n", car(merge),caddr(merge),cadddr(merge)); if (cadddr(merge)>CASE_TABLE_COUNT) { chunks = table_jump(car(merge),caddr(merge),chunks); @@ -365,7 +365,7 @@ int i; int j; for(i=cslist;i;i=cadr(i)) { - printf("# case %d L_%d\n",car(i),caddr(i)); + printf("## case %d L_%d\n",car(i),caddr(i)); } #endif control=1; @@ -382,7 +382,7 @@ merge = merge_chunk(chunks); #if 0 // chunks: list3(widest,next,delta); - printf("# chunks %d = sum ",j); + printf("## chunks %d = sum ",j); j = 0; for(i=merge;i;i=cadr(i)) { printf(" %d/%d",car(i),caddr(i));
--- a/mc-tree.c Sat Jul 30 16:01:45 2005 +0900 +++ b/mc-tree.c Sat Jul 30 16:22:00 2005 +0900 @@ -292,7 +292,7 @@ } NMTBL * -typedef_search(t,type) +typedef_search(int t,int type) { while(t) { if (((NMTBL*)car(t))->ty==type)
--- a/test/switch.c Sat Jul 30 16:01:45 2005 +0900 +++ b/test/switch.c Sat Jul 30 16:22:00 2005 +0900 @@ -1,5 +1,11 @@ #include <stdio.h> +int main1(int i); +int main2(int i); +int main3(int i); +int main4(int i); +int main5(int i); + main(int ac,char *av[]) { int i; @@ -1227,7 +1233,7 @@ } } -main5() +main5(int r) { int i,j,k; i = 3;