home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mfb / fastblt.h next >
Encoding:
C/C++ Source or Header  |  1989-11-21  |  1.7 KB  |  65 lines

  1. /*
  2.  * Fast bitblt macros for certain hardware.  If your machine has an addressing
  3.  * mode of small constant + register, you'll probably want this magic specific
  4.  * code.  It's 25% faster for the R2000.  I haven't studied the Sparc
  5.  * instruction set, but I suspect it also has this addressing mode.  Also,
  6.  * unrolling the loop by 32 is possibly excessive for mfb. The number of times
  7.  * the loop is actually looped through is pretty small.
  8.  */
  9.  
  10. /*
  11.  * WARNING:  These macros make *a lot* of assumptions about
  12.  * the environment they are invoked in.  Plenty of implicit
  13.  * arguments, lots of side effects.  Don't use them casually.
  14.  */
  15.  
  16. #define SwitchOdd(n) case n: BodyOdd(n)
  17. #define SwitchEven(n) case n: BodyEven(n)
  18.  
  19. /* to allow mfb and cfb to share code... */
  20. #ifndef BitRight
  21. #define BitRight(a,b) SCRRIGHT(a,b)
  22. #define BitLeft(a,b) SCRLEFT(a,b)
  23. #endif
  24.  
  25. #ifdef LARGE_INSTRUCTION_CACHE
  26. #define UNROLL 8
  27. #define PackedLoop \
  28.     switch (nl & (UNROLL-1)) { \
  29.     SwitchOdd( 7) SwitchEven( 6) SwitchOdd( 5) SwitchEven( 4) \
  30.     SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
  31.     } \
  32.     while ((nl -= UNROLL) >= 0) { \
  33.     LoopReset \
  34.     BodyEven( 8) \
  35.         BodyOdd( 7) BodyEven( 6) BodyOdd( 5) BodyEven( 4) \
  36.         BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
  37.     }
  38. #else
  39. #define UNROLL 4
  40. #define PackedLoop \
  41.     switch (nl & (UNROLL-1)) { \
  42.     SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
  43.     } \
  44.     while ((nl -= UNROLL) >= 0) { \
  45.     LoopReset \
  46.         BodyEven( 4) \
  47.         BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
  48.     }
  49. #endif
  50.  
  51. #define DuffL(counter,label,body) \
  52.     switch (counter & 3) { \
  53.     label: \
  54.         body \
  55.     case 3: \
  56.     body \
  57.     case 2: \
  58.     body \
  59.     case 1: \
  60.     body \
  61.     case 0: \
  62.     if ((counter -= 4) >= 0) \
  63.         goto label; \
  64.     }
  65.