diff mc-codegen.c @ 297:0f79c95df73a

switch index no compile error
author kono
date Sun, 06 Jun 2004 20:19:36 +0900
parents 284aa4eaab0d
children 117baacd1ed0
line wrap: on
line diff
--- a/mc-codegen.c	Sun Jun 06 02:40:32 2004 +0900
+++ b/mc-codegen.c	Sun Jun 06 20:19:36 2004 +0900
@@ -1770,209 +1770,4 @@
     return 0;
 }
 
-#if CASE_CODE
-
-/*
-      cslist = list3(value,next,label)  label==0 means skip
-      chunk  = list4(cslist,next,delta,list3(count,min,max))
- */
-
-/*
-   group continous case value
- */
-
-static int
-make_chunk(int cslist)
-{
-    int delta,delta1,list,p,count;
-    // cslist is already sorted
-    delta = 0;
-    list = list4(cslist,0,1,list3(0,car(cslist) /* min */,0)); 
-    count=1;
-    for(p=0;cadr(cslist);cslist = cadr(cslist),count++) {
-        // compute new delta
-	delta1 = car(cadr(cslist))-car(cslist);
-        // empty case
-	if (!caddr(cslist)) count--;
-	if (delta==0) {
-            // 2nd element
-	    caddr(list) = delta = delta1;
-	    if (p) cadr(p)=0;  // terminate previous chunk
-	} else if (delta1!=delta) {
-	    // not contiguous, start new list
-	    caddr(cadddr(list)) = car(cslist);      // max
-	    car(cadddr(list)) = count; count=0;
-            delta = 0;
-	    list = list4(cadr(cslist),list,1,list3(0,0,0));
-	    cadr(cadddr(list)) = car(cadr(cslist)); // min
-            // prepare terminate point for next turn
-	    p=cslist;
-	}
-    }
-    if (p) cadr(p)=0;  // terminate previous chunk
-    car(cadddr(list)) = count;
-    caddr(cadddr(list)) = car(cslist);   // max
-    return list;
-}
-
-#define CASE_MERGE_RATE 70
-
-static int gcd(int i,int j)
-{
-    int k;
-    if (i<j) { k=i; i=j; j=k;}
-    for(;;) {
-	if ((k=i%j)==0) return j;
-	i = j; j = k;
-    }
-}
-
-/*
-    check two chunks are mergeable or not.
- */
-
-int
-merge_chunk_p(int *delta,int max,int min,int *count,int delta1,int count1) 
-{
-    int range = max-min;
-    int g;
-    // compute possible merge delta
-    g = gcd(*delta,delta1);
-    g = gcd(g,range);
-    range /= g;
-    *count = count1 = count1+*count;
-    *delta = g;
-#if 1
-    if (count1*128>(range*128*CASE_MERGE_RATE/100)) {
-	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)
-	);
-    }
-#endif
-    //    count/((max-min)/delta) > 0.8
-    return count1*128>(range*128*CASE_MERGE_RATE/100);
-}
-
-/*
-     merge possible chunk
-      input:  list4(cslist,next,delta,list3(count,min,max))
-      output: list3(continuous number of chunk,next,delta,case_count);
- */
-
-static int
-merge_chunk(int cslist)
-{
-    int list = cslist;
-    int tail,last,max,min,i;
-    int count,c_count,p,widest,delta=1;
-    int chunks = 0;
-    while(cadr(list)) {
-	p = cadddr(list);
-	c_count = count = car(p); max=caddr(p);
-	widest = 1; last = list;
-	delta = caddr(list);
-        // check possible merge against the end of the chunks
-	for(i=1,tail=cadr(list);cadr(tail); tail=cadr(tail),i++) {
-	    p = cadddr(tail);
-	    min = cadr(p);
-	    if (merge_chunk_p(&delta,max,min,&count,caddr(tail),car(p))) {
-                // It is mergeable.
-		widest = i+1; last = tail; c_count=count;
-	    }
-	}
-	chunks = list4(widest,chunks,delta,c_count);
-        // skip merged chunks
-	list = cadr(last);
-    }
-    // last one can remain.
-    if (list) chunks = list4(1,chunks,caddr(list),car(cadddr(list)));
-    return chunks;
-}
-
-static int
-table_jump(int count,int delta,int cslist)
-{
-    int list;
-    for(;count-->0;cslist=cadr(cslist)) {
-	list = car(cslist);
-	printf("# table cases delta=%d count=%d min=%d max=%d\n",
-		caddr(cslist),car(cadddr(cslist)),
-				cadr(cadddr(cslist)),caddr(cadddr(cslist))
-		);
-	for(;list; list=cadr(list)) {
-	    if (caddr(list))
-		cmpdimm(car(list),csvalue1,caddr(list),0);
-	}
-    }
-    return cslist;
-}
-
-static int
-cascade_compare(int count,int cslist)
-{
-    int list;
-    for(;count-->0;cslist=cadr(cslist)) {
-	list = car(cslist);
-	printf("# cascade cases delta=%d count=%d min=%d max=%d\n",
-		caddr(cslist),car(cadddr(cslist)),
-				cadr(cadddr(cslist)),caddr(cadddr(cslist))
-		);
-	for(;list; list=cadr(list)) {
-	    if (caddr(list))
-		cmpdimm(car(list),csvalue1,caddr(list),0);
-	}
-    }
-    return cslist;
-}
-
-#define CASE_TABLE_COUNT 10
-
-void
-switch_table(int cslist,int cslabel,int dlabel)
-{
-    int chunks;
-    int i,j;
-#if 0
-    for(i=cslist;i;i=cadr(i)) {
-	printf("# case %d L_%d\n",car(i),caddr(i));
-    }
-#endif
-    cslist=make_chunk(cslist);
-#if 1
-    chunks = 0;
-    for(i=cslist;i;i=cadr(i)) {
-        chunks++;
-    }
-    j = chunks;
-#endif
-    chunks = merge_chunk(cslist);
-#if 0
-    //  chunks: list3(widest,next,delta);
-    printf("# chunks %d = sum ",j);
-    j = 0;
-    for(i=chunks;i;i=cadr(i)) {
-	printf(" %d/%d",car(i),caddr(i));
-	j+=car(i);
-    }
-    printf(" sum = %d\n",j);
-#endif
-    fwddef(cslabel);
-    cslist = reverse0(cslist);
-    for(;chunks;chunks=cadr(chunks)) {
-	printf("# chunk count %d delta %d c_count %d\n",
-		car(chunks),caddr(chunks),cadddr(chunks));
-	if (cadddr(chunks)>CASE_TABLE_COUNT)
-	    cslist = table_jump(car(chunks),caddr(chunks),cslist);
-	else
-	    cslist = cascade_compare(car(chunks),cslist);
-    }
-    if (dlabel) jmp(dlabel);
-}
-
-#endif
-
-
-
 /* end */