First import
[xorg_rtime.git] / xorg-server-1.4 / mfb / fastblt.h
blob35ba5a2a13649ac95251019bc33674be821e91b9
1 /*
3 Copyright 1989, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
25 from The Open Group.
30 * Fast bitblt macros for certain hardware. If your machine has an addressing
31 * mode of small constant + register, you'll probably want this magic specific
32 * code. It's 25% faster for the R2000. I haven't studied the Sparc
33 * instruction set, but I suspect it also has this addressing mode. Also,
34 * unrolling the loop by 32 is possibly excessive for mfb. The number of times
35 * the loop is actually looped through is pretty small.
39 * WARNING: These macros make *a lot* of assumptions about
40 * the environment they are invoked in. Plenty of implicit
41 * arguments, lots of side effects. Don't use them casually.
44 #define SwitchOdd(n) case n: BodyOdd(n)
45 #define SwitchEven(n) case n: BodyEven(n)
47 /* to allow mfb and cfb to share code... */
48 #ifdef HAVE_DIX_CONFIG_H
49 #include <dix-config.h>
50 #endif
52 #ifndef BitRight
53 #define BitRight(a,b) SCRRIGHT(a,b)
54 #define BitLeft(a,b) SCRLEFT(a,b)
55 #endif
57 #ifdef LARGE_INSTRUCTION_CACHE
58 #define UNROLL 8
59 #define PackedLoop \
60 switch (nl & (UNROLL-1)) { \
61 SwitchOdd( 7) SwitchEven( 6) SwitchOdd( 5) SwitchEven( 4) \
62 SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
63 } \
64 while ((nl -= UNROLL) >= 0) { \
65 LoopReset \
66 BodyEven( 8) \
67 BodyOdd( 7) BodyEven( 6) BodyOdd( 5) BodyEven( 4) \
68 BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
70 #else
71 #define UNROLL 4
72 #define PackedLoop \
73 switch (nl & (UNROLL-1)) { \
74 SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
75 } \
76 while ((nl -= UNROLL) >= 0) { \
77 LoopReset \
78 BodyEven( 4) \
79 BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
81 #endif
83 #define DuffL(counter,label,body) \
84 switch (counter & 3) { \
85 label: \
86 body \
87 case 3: \
88 body \
89 case 2: \
90 body \
91 case 1: \
92 body \
93 case 0: \
94 if ((counter -= 4) >= 0) \
95 goto label; \