Diff for /gforth/prims2x.fs between versions 1.114 and 1.115

version 1.114, 2002/09/22 09:00:04 version 1.115, 2002/09/22 09:54:19
Line 1105  stack inst-stream IP Cell Line 1105  stack inst-stream IP Cell
     cr ;      cr ;
   
   
 \ superinstruction data for a sophisticated combiner (e.g., shortest path)  \ cost and superinstruction data for a sophisticated combiner (e.g.,
   \ shortest path)
   
 \ This is intended as initializer for a structure like this  \ This is intended as initializer for a structure like this
   
 \  struct super {  \  struct super {
 \    int super;       /* index in vm_prims */  
 \    int loads;       /* number of stack loads */  \    int loads;       /* number of stack loads */
 \    int stores;      /* number of stack stores */  \    int stores;      /* number of stack stores */
 \    int updates;     /* number of stack pointer updates */  \    int updates;     /* number of stack pointer updates */
Line 1118  stack inst-stream IP Cell Line 1118  stack inst-stream IP Cell
 \    int *components; /* array of vm_prim indexes of components */  \    int *components; /* array of vm_prim indexes of components */
 \  };  \  };
   
   \ How do you know which primitive or combined instruction this
   \ structure refers to?  By the order of cost structures, as in most
   \ other cases.
   
   : compute-costs { p -- nloads nstores nupdates }
       \ compute the number of loads, stores, and stack pointer updates
       \ of a primitive or combined instruction; does not take TOS
       \ caching into account, nor that IP updates are combined with
       \ other stuff
       0 max-stacks 0 +do
           p prim-stacks-in i th @ +
       loop
       0 max-stacks 0 +do
           p prim-stacks-out i th @ +
       loop
       0 max-stacks 0 +do
           p prim-stacks-in i th @ p prim-stacks-out i th @ <> -
       loop ;
   
 : output-num-part ( p -- )  : output-num-part ( p -- )
     prim-num @ 4 .r ." ," ;      prim-num @ 4 .r ." ," ;
   
 : output-supers ( -- )  : output-costs ( -- )
     ." {" combined prim-num @ 4 .r      ." {" prim compute-costs
     ." ,0,0,0," \ counting this stuff is not yet implemented      rot 2 .r ." ," swap 2 .r ." ," 2 .r ." ,"
     num-combined @ 2 .r      combined if
     ." , ((int []){" ['] output-num-part map-combined ." })}"          num-combined @ 2 .r
           ." , ((int []){" ['] output-num-part map-combined ." })}, /* "
       else
           ."  1, ((int []){" prim prim-num @ 4 .r ." })}, /* "
       endif
       prim prim-name 2@ type ."  */"
     cr ;      cr ;
   
 \ the parser  \ the parser

Removed from v.1.114  
changed lines
  Added in v.1.115


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