Mercurial > hg > CbC > old > device
changeset 298:4ccacae1d2e6
switch index level=1 odd situation.
author | kono |
---|---|
date | Sun, 06 Jun 2004 23:07:53 +0900 |
parents | 0f79c95df73a |
children | 3d260008c449 |
files | .gdbinit Changes Makefile mc-switch.c |
diffstat | 4 files changed, 57 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/.gdbinit Sun Jun 06 20:19:36 2004 +0900 +++ b/.gdbinit Sun Jun 06 23:07:53 2004 +0900 @@ -1,7 +1,8 @@ tb main # run -s test/arg.c # run -s -ob00.s mc-parse.c -run -s test/code-gen-all.c +run -s -ob02.s mc-codegen.c +# run -s test/code-gen-all.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
--- a/Changes Sun Jun 06 20:19:36 2004 +0900 +++ b/Changes Sun Jun 06 23:07:53 2004 +0900 @@ -4791,3 +4791,6 @@ index がtableになることって... 偶然にはあるかも知れないし、 無理にすればできないことはないだろうけど... +Sun Jun 6 23:07:16 JST 2004 + +level 1 table がおかしい。そうだよなぁ。
--- a/Makefile Sun Jun 06 20:19:36 2004 +0900 +++ b/Makefile Sun Jun 06 23:07:53 2004 +0900 @@ -140,11 +140,11 @@ clean : -rm -f mc mc-ia32 mc-powerpc mc-mips *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i -mc1 : b00.s b01.s mc-codegen.o mc-tree.o $(CONVERTER) - $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o $(CONVERTER) +mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o $(CONVERTER) + $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o $(CONVERTER) -mc2 : b00.s b01.s b02.s b03.s mc-codegen.o mc-tree.o $(CONVERTER) - $(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s $(CONVERTER) +mc2 : b00.s b01.s b02.s b03.s $(CONVERTER) + $(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s b04.s $(CONVERTER) b00.s : mc-parse.c $(MC) ./$(MC) -s -ob00.s mc-parse.c @@ -154,6 +154,8 @@ ./$(MC) -s -ob02.s mc-codegen.c b03.s : mc-tree.c $(MC) ./$(MC) -s -ob03.s mc-tree.c +b04.s : mc-switch.c $(MC) + ./$(MC) -s -ob04.s mc-switch.c b10.s : mc-parse.c mc1 ./mc1 -s -ob10.s mc-parse.c @@ -163,6 +165,8 @@ ./mc1 -s -ob12.s mc-codegen.c b13.s : mc-tree.c mc1 ./mc1 -s -ob13.s mc-tree.c +b14.s : mc-switch.c mc1 + ./mc1 -s -ob14.s mc-switch.c b20.s : mc-parse.c mc2 ./mc2 -s -ob20.s mc-parse.c @@ -172,18 +176,22 @@ ./mc2 -s -ob22.s mc-codegen.c b23.s : mc-tree.c mc2 ./mc2 -s -ob23.s mc-tree.c +b24.s : mc-switch.c mc1 + ./mc2 -s -ob24.s mc-switch.c -diff : b00.s b01.s b02.s b03.s b10.s b11.s b12.s b13.s +diff : b00.s b01.s b02.s b03.s b04.s b10.s b11.s b12.s b13.s b14.s -diff b00.s b10.s -diff b01.s b11.s -diff b02.s b12.s -diff b03.s b13.s + -diff b04.s b14.s -diff2 : b00.s b01.s b02.s b03.s b20.s b21.s b22.s b23.s +diff2 : b00.s b01.s b02.s b03.s b04.s b20.s b21.s b22.s b23.s b24.s -diff b00.s b20.s -diff b01.s b21.s -diff b02.s b22.s -diff b03.s b23.s + -diff b04.s b24.s # DO NOT DELETE @@ -208,13 +216,20 @@ mc-parse.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h mc-parse.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc-parse.o: /usr/include/stdlib.h /usr/include/alloca.h conv/conv.h -mc-parse.o: mc-codegen.h +mc-parse.o: mc-codegen.h mc-switch.h mc-tree.o: mc.h /usr/include/stdio.h /usr/include/sys/types.h mc-tree.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h mc-tree.o: /usr/include/machine/types.h /usr/include/ppc/types.h mc-tree.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h mc-tree.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h mc-tree.o: /usr/include/stdlib.h /usr/include/alloca.h conv/conv.h +mc-switch.o: mc.h /usr/include/stdio.h /usr/include/sys/types.h +mc-switch.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h +mc-switch.o: /usr/include/machine/types.h /usr/include/ppc/types.h +mc-switch.o: /usr/include/machine/ansi.h /usr/include/ppc/ansi.h +mc-switch.o: /usr/include/machine/endian.h /usr/include/ppc/endian.h +mc-switch.o: /usr/include/stdlib.h /usr/include/alloca.h conv/conv.h +mc-switch.o: mc-code.h mc-codegen.h mc.o: /usr/include/stdio.h /usr/include/sys/types.h mc.o: /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h mc.o: /usr/include/machine/types.h /usr/include/ppc/types.h
--- a/mc-switch.c Sun Jun 06 20:19:36 2004 +0900 +++ b/mc-switch.c Sun Jun 06 23:07:53 2004 +0900 @@ -25,6 +25,11 @@ #define chunk_min(chunks) cadr(cadddr(chunks)) #define index_max(index) caddr(index) #define index_min(index) cadddr(index) +#define index_label(index) car(index) + +#define CASE_TABLE_COUNT 3 +#define CASE_INDEX_COUNT 3 + /* group continous case value @@ -172,9 +177,6 @@ return cslist; } -#define CASE_TABLE_COUNT 10 -#define CASE_INDEX_COUNT 10 - /* generate index jmp @@ -183,7 +185,7 @@ static void switch_index_jmp(int index,int label) { - int value = car(car(caddr(caddr(index)))); + int value = index_min(index); cmpdimm(value,csvalue1,label,LT); // value register label mode } @@ -193,19 +195,20 @@ */ static int -switch_make_index_leaf(int count,int index) +switch_make_index_leaf(int count,int index,int level) { + control=1; + printf("# index leaf count=%d level=%d\n",count,level); for(;count-- !=0 && cadr(index);index=cadr(index)) { - switch_index_jmp( - cadr(index), /* next max */ - car(caddr(index)) /*label*/ ); + switch_index_jmp( cadr(index), index_label(index) ); } if (!cadr(index)) { // don't check max boundary - jmp(car(caddr(index))); + jmp(index_label(index)); return 0; } - if (count!=0) error(-1); + if (count!= -1) error(-1); + if (control&&dlabel) jmp(dlabel); return index; } @@ -215,28 +218,28 @@ */ static void -switch_make_index(int index0,int count,int cslabel) +switch_make_index(int index0,int count,int cslabel,int level) { int index=0; int icount=0; int l,min,max; + control=1; while (index0 && count > CASE_INDEX_COUNT) { l = backdef(); min = index_min(index0); - index0=switch_make_index_leaf(CASE_INDEX_COUNT,index0); - max = index_min(index0); + index0=switch_make_index_leaf(CASE_INDEX_COUNT,index0,level); + max = index_min(index0)-1; index = list4(l,index,max,min); count-=CASE_INDEX_COUNT; icount++; } if (index) { - switch_make_index(reverse0(index),icount,cslabel); - if (dlabel) jmp(dlabel); + switch_make_index(reverse0(index),icount,cslabel,level+1); } else { fwddef(cslabel); - switch_make_index_leaf(-1,index0); - if (dlabel) jmp(dlabel); + switch_make_index_leaf(-1,index0,level); } + if (control&&dlabel) jmp(dlabel); } /* @@ -246,6 +249,7 @@ static int switch_leaf(int count,int merge,int cslist) { + control=1; for(;count-- !=0 && merge;merge=cadr(merge)) { printf("# merge count %d delta %d c_count %d\n", car(merge),caddr(merge),cadddr(merge)); @@ -254,6 +258,7 @@ else cslist = cascade_compare(car(merge),cslist); } + if (control&&dlabel) jmp(dlabel); return cslist; } @@ -271,6 +276,7 @@ int count = 0; int index = 0; for(m=merge;m;m=cadr(m)) { + if (!index && !cadr(m)) break; // no index for single chunk chnkcnt++; count += cadddr(m); if (count > CASE_INDEX_COUNT || (index && !cadr(m))) { @@ -281,20 +287,19 @@ max = chunks?car(car(chunks)):gmax; index = list4(l,index,max,min); merge = cadr(m); count = 0; chnkcnt = 0; - if (dlabel) jmp(dlabel); } } if (index) { index = reverse0(index); // check lower bound - switch_index_jmp(index,dlabel?dlabel:blabel); - switch_make_index(index,icount,cslabel); - if (dlabel) jmp(dlabel); + // switch_index_jmp(index,dlabel?dlabel:blabel); + // nonsense because no control here. + switch_make_index(index,icount,cslabel,0); } else { fwddef(cslabel); switch_leaf(-1,merge,chunks); - if (dlabel) jmp(dlabel); } + if (control&&dlabel) jmp(dlabel); } /* generate switch table, index, cascading branch */ @@ -305,6 +310,7 @@ { int chunks,merge,gmax; int i,j; + control=1; #if 0 for(i=cslist;i;i=cadr(i)) { printf("# case %d L_%d\n",car(i),caddr(i)); @@ -313,11 +319,10 @@ /* find stepwise chunks */ chunks=make_chunk(cslist); #if 1 - chunks = 0; + j = 0; for(i=cslist;i;i=cadr(i)) { - chunks++; + j++; } - j = chunks; #endif /* possible merge of loose stepwise chunks */ merge = merge_chunk(chunks);