Diff for /gforth/engine/peephole.c between versions 1.5 and 1.9

version 1.5, 2001/06/15 16:09:15 version 1.9, 2003/11/02 18:18:35
Line 1 Line 1
 /* Peephole optimization routines and tables  /* Peephole optimization routines and tables
   
   Copyright (C) 2001 Free Software Foundation, Inc.    Copyright (C) 2001,2002,2003 Free Software Foundation, Inc.
   
   This file is part of Gforth.    This file is part of Gforth.
   
Line 33  typedef struct Combination { Line 33  typedef struct Combination {
 } Combination;  } Combination;
   
 Combination peephole_table[] = {  Combination peephole_table[] = {
 #include "peephole.i"  #include PEEPHOLE_I
 };  };
   
   #ifdef PRINT_SUPER_LENGTHS
   char *prim_names[] = {
   #include PRIM_NAMES_I
   };
   
   Combination *find_super(Cell prim)
   {
     Cell i;
   
     for (i=0; i<sizeof(peephole_table)/sizeof(peephole_table[0]); i++) {
       if (peephole_table[i].combination_prim == prim)
         return &peephole_table[i];
     }
     return NULL;
   }
   
   Cell sum_length(Cell prim)
   {
     Combination *super=find_super(prim);
   
     if (super)
       return sum_length(super->prefix)+prim_length(super->lastprim);
     else
       return prim_length(prim);
   }
   
   void print_prim(Cell prim)
   {
     fprintf(stderr, "%s", prim_names[prim]);
   }  
   
   void print_super(Cell prim)
   {
     Combination *super=find_super(prim);
     
     if (super) {
       print_super(super->prefix);
       fprintf(stderr, " ");
       print_prim(super->lastprim);
     } else {
       print_prim(prim);
     }
   }
   
   void print_super_lengths()
   {
     Cell i;
   
     for (i=0; i<sizeof(peephole_table)/sizeof(peephole_table[0]); i++) {
       Cell super_length = prim_length(peephole_table[i].combination_prim);
       Cell sum_super_length = sum_length(peephole_table[i].combination_prim);
   
       fprintf(stderr, "%6.4f %3d %3d ", ((double)super_length)/sum_super_length,
               super_length, sum_super_length);
       print_super(peephole_table[i].combination_prim);
       fprintf(stderr,"\n");
     }
   }
   #endif
   
 int use_super = 1;  int use_super = 1;
   
 typedef Xt Inst;  typedef Xt Inst;

Removed from v.1.5  
changed lines
  Added in v.1.9


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>