File:  [gforth] / gforth / Attic / threading.h
Revision 1.1: download - view: text, annotated - select for diffs
Thu Oct 26 22:48:43 1995 UTC (28 years, 5 months ago) by pazsan
Branches: MAIN
CVS tags: HEAD
Changed threading ifdefs.
Requires debugging !!!!!!
Perhaps change concepts with LONG_LATENCY
on RISCs.
Added sokoban.fs as a nice little game.

    1: /* This file defines a number of threading schemes.
    2:    To organize the former ifdef chaos, each path is separated
    3:    This gives a quite impressive number of paths, but you clearly
    4:    find things that go together. */
    5: 
    6: #ifndef GETCFA
    7: #  define CFA_NEXT
    8: #endif
    9: 
   10: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
   11:     && defined(LONG_LATENCY) && defined(CFA_NEXT)
   12: #warning scheme 1
   13: #  define NEXT_P0	({cfa=*ip++;})
   14: #  define IP		(ip-1)
   15: #  define NEXT_INST	(cfa)
   16: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
   17: #  define DEF_CA
   18: #  define NEXT_P1
   19: #  define NEXT_P2	({goto *cfa;})
   20: #  define EXEC(XT)	({cfa=(XT); goto *cfa;})
   21: #endif
   22: 
   23: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
   24:     && defined(LONG_LATENCY) && !defined(CFA_NEXT)
   25: #warning scheme 2
   26: #  define NEXT_P0	(ip++)
   27: #  define IP		(ip-1)
   28: #  define NEXT_INST	(*(ip-1))
   29: #  define INC_IP(const_inc)	({ ip+=(const_inc);})
   30: #  define DEF_CA
   31: #  define NEXT_P1
   32: #  define NEXT_P2	({goto **(ip-1);})
   33: #  define EXEC(XT)	({goto *(XT);})
   34: #endif
   35: 
   36: 
   37: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
   38:     && !defined(LONG_LATENCY) && defined(CFA_NEXT)
   39: #warning scheme 3
   40: #  define NEXT_P0
   41: #  define IP		(ip)
   42: #  define NEXT_INST	(*ip)
   43: #  define INC_IP(const_inc)	({ip+=(const_inc);})
   44: #  define DEF_CA
   45: #  define NEXT_P1	({cfa=*ip++;})
   46: #  define NEXT_P2	({goto *cfa;})
   47: #  define EXEC(XT)	({cfa=(XT); goto *cfa;})
   48: #endif
   49: 
   50: #if defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
   51:     && !defined(LONG_LATENCY) && !defined(CFA_NEXT)
   52: #warning scheme 4
   53: #  define NEXT_P0
   54: #  define IP		(ip)
   55: #  define NEXT_INST	(*ip)
   56: #  define INC_IP(const_inc)	({ ip+=(const_inc);})
   57: #  define DEF_CA
   58: #  define NEXT_P1
   59: #  define NEXT_P2	({goto **(ip++);})
   60: #  define EXEC(XT)	({goto *(XT);})
   61: #endif
   62: 
   63: /* without autoincrement */
   64: 
   65: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
   66:     && defined(LONG_LATENCY) && defined(CFA_NEXT)
   67: #warning scheme 5
   68: #  define NEXT_P0	({cfa=*ip;})
   69: #  define IP		(ip)
   70: #  define NEXT_INST	(cfa)
   71: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
   72: #  define DEF_CA
   73: #  define NEXT_P1	(ip++)
   74: #  define NEXT_P2	({goto *cfa;})
   75: #  define EXEC(XT)	({cfa=(XT); goto *cfa;})
   76: #endif
   77: 
   78: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
   79:     && defined(LONG_LATENCY) && !defined(CFA_NEXT)
   80: #warning scheme 6
   81: #  define NEXT_P0
   82: #  define IP		(ip)
   83: #  define NEXT_INST	(*ip)
   84: #  define INC_IP(const_inc)	(ip+=(const_inc);})
   85: #  define DEF_CA
   86: #  define NEXT_P1	(ip++)
   87: #  define NEXT_P2	({goto **(ip-1);})
   88: #  define EXEC(XT)	({goto *(XT);})
   89: #endif
   90: 
   91: 
   92: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
   93:     && !defined(LONG_LATENCY) && defined(CFA_NEXT)
   94: #warning scheme 7
   95: #  define NEXT_P0
   96: #  define IP		(ip)
   97: #  define NEXT_INST	(*ip)
   98: #  define INC_IP(const_inc)	({ip+=(const_inc);})
   99: #  define DEF_CA
  100: #  define NEXT_P1	({cfa=*ip++;})
  101: #  define NEXT_P2	({goto *cfa;})
  102: #  define EXEC(XT)	({cfa=(XT); goto *cfa;})
  103: #endif
  104: 
  105: #if defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
  106:     && !defined(LONG_LATENCY) && !defined(CFA_NEXT)
  107: #warning scheme 8
  108: #  define NEXT_P0
  109: #  define IP		(ip)
  110: #  define NEXT_INST	(*IP)
  111: #  define INC_IP(const_inc)	({ ip+=(const_inc);})
  112: #  define DEF_CA
  113: #  define NEXT_P1	(ip++)
  114: #  define NEXT_P2	({goto **(ip-1);})
  115: #  define EXEC(XT)	({goto *(XT);})
  116: #endif
  117: 
  118: /* common settings for direct THREADED */
  119: 
  120: 
  121: /* indirect THREADED  */
  122: 
  123: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
  124:     && defined(LONG_LATENCY) && defined(CISC_NEXT)
  125: #  define NEXT_P0	({cfa=*ip++;})
  126: #  define IP		(ip-1)
  127: #  define NEXT_INST	(cfa)
  128: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  129: #  define DEF_CA
  130: #  define NEXT_P1
  131: #  define NEXT_P2	({goto **cfa;})
  132: #  define EXEC(XT)	({cfa=(XT); goto **cfa;})
  133: #endif
  134: 
  135: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
  136:     && defined(LONG_LATENCY) && !defined(CISC_NEXT)
  137: #  define NEXT_P0	({cfa=*ip++;})
  138: #  define IP		(ip-1)
  139: #  define NEXT_INST	(cfa)
  140: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  141: #  define DEF_CA	Label ca;
  142: #  define NEXT_P1	({ca=*cfa;})
  143: #  define NEXT_P2	({goto *ca;})
  144: #  define EXEC(XT)	({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
  145: #endif
  146: 
  147: 
  148: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
  149:     && !defined(LONG_LATENCY) && defined(CISC_NEXT)
  150: #  define NEXT_P0
  151: #  define IP		(ip)
  152: #  define NEXT_INST	(*ip)
  153: #  define INC_IP(const_inc)	({ip+=(const_inc);})
  154: #  define DEF_CA
  155: #  define NEXT_P1	({cfa=*ip++;})
  156: #  define NEXT_P2	({goto **cfa;})
  157: #  define EXEC(XT)	({cfa=(XT); goto **cfa;})
  158: #endif
  159: 
  160: #if !defined(DIRECT_THREADED) && defined(AUTO_INCREMENT)\
  161:     && !defined(LONG_LATENCY) && !defined(CISC_NEXT)
  162: #  define NEXT_P0	({cfa=*ip++;})
  163: #  define IP		(ip-1)
  164: #  define NEXT_INST	(cfa)
  165: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  166: #  define DEF_CA	Label ca;
  167: #  define NEXT_P1	({ca=*cfa;})
  168: #  define NEXT_P2	({goto *ca;})
  169: #  define EXEC(XT)	({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
  170: #endif
  171: 
  172: 
  173: /* without autoincrement */
  174: 
  175: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
  176:     && defined(LONG_LATENCY) && defined(CISC_NEXT)
  177: #  define NEXT_P0	({cfa=*ip;})
  178: #  define IP		(ip)
  179: #  define NEXT_INST	(cfa)
  180: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  181: #  define DEF_CA
  182: #  define NEXT_P1	(ip++)
  183: #  define NEXT_P2	({goto **cfa;})
  184: #  define EXEC(XT)	({cfa=(XT); goto **cfa;})
  185: #endif
  186: 
  187: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
  188:     && defined(LONG_LATENCY) && !defined(CISC_NEXT)
  189: #  define NEXT_P0	({cfa=*ip;})
  190: #  define IP		(ip)
  191: #  define NEXT_INST	(cfa)
  192: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  193: #  define DEF_CA	Label ca;
  194: #  define NEXT_P1	({ip++; ca=*cfa;})
  195: #  define NEXT_P2	({goto *ca;})
  196: #  define EXEC(XT)	({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
  197: #endif
  198: 
  199: 
  200: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
  201:     && !defined(LONG_LATENCY) && defined(CISC_NEXT)
  202: #  define NEXT_P0
  203: #  define IP		(ip)
  204: #  define NEXT_INST	(*ip)
  205: #  define INC_IP(const_inc)	({ip+=(const_inc);})
  206: #  define DEF_CA
  207: #  define NEXT_P1	({cfa=*ip;})
  208: #  define NEXT_P2	({ip++; goto **cfa;})
  209: #  define EXEC(XT)	({cfa=(XT); goto **cfa;})
  210: #endif
  211: 
  212: #if !defined(DIRECT_THREADED) && !defined(AUTO_INCREMENT)\
  213:     && !defined(LONG_LATENCY) && !defined(CISC_NEXT)
  214: #  define NEXT_P0	({cfa=*ip;})
  215: #  define IP		(ip)
  216: #  define NEXT_INST	(cfa)
  217: #  define INC_IP(const_inc)	({cfa=IP[const_inc]; ip+=(const_inc);})
  218: #  define DEF_CA	Label ca;
  219: #  define NEXT_P1	({ip++; ca=*cfa;})
  220: #  define NEXT_P2	({goto *ca;})
  221: #  define EXEC(XT)	({DEF_CA cfa=(XT); ca=*cfa; goto *ca;})
  222: #endif
  223: 
  224: #define NEXT ({DEF_CA NEXT_P1; NEXT_P2;})
  225: 
  226: #if defined(CISC_NEXT) && !defined(LONG_LATENCY)
  227: # define NEXT1_P1
  228: # ifdef DIRECT_THREADED
  229: #  define NEXT1_P2 ({goto *cfa;})
  230: # else
  231: #  define NEXT1_P2 ({goto **cfa;})
  232: # endif /* DIRECT_THREADED */
  233: #else /* defined(CISC_NEXT) && !defined(LONG_LATENCY) */
  234: # ifdef DIRECT_THREADED
  235: #  define NEXT1_P1
  236: #  define NEXT1_P2 ({goto *cfa;})
  237: # else /* DIRECT_THREADED */
  238: #  define NEXT1_P1 ({ca = *cfa;})
  239: #  define NEXT1_P2 ({goto *ca;})
  240: # endif /* DIRECT_THREADED */
  241: #endif

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