]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/mfb/fastblt.h
0ca295d6235aa1bff5e9f0b7887cd7ffe0e575b0
[rdpsrv] / Xserver / programs / Xserver / mfb / fastblt.h
1 /* $XConsortium: fastblt.h,v 1.7 94/04/17 20:28:07 dpw Exp $ */
2 /*
3
4 Copyright (c) 1989  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24
25 Except as contained in this notice, the name of the X Consortium shall
26 not be used in advertising or otherwise to promote the sale, use or
27 other dealings in this Software without prior written authorization
28 from the X Consortium.
29
30 */
31
32 /*
33  * Fast bitblt macros for certain hardware.  If your machine has an addressing
34  * mode of small constant + register, you'll probably want this magic specific
35  * code.  It's 25% faster for the R2000.  I haven't studied the Sparc
36  * instruction set, but I suspect it also has this addressing mode.  Also,
37  * unrolling the loop by 32 is possibly excessive for mfb. The number of times
38  * the loop is actually looped through is pretty small.
39  */
40
41 /*
42  * WARNING:  These macros make *a lot* of assumptions about
43  * the environment they are invoked in.  Plenty of implicit
44  * arguments, lots of side effects.  Don't use them casually.
45  */
46
47 #define SwitchOdd(n) case n: BodyOdd(n)
48 #define SwitchEven(n) case n: BodyEven(n)
49
50 /* to allow mfb and cfb to share code... */
51 #ifndef BitRight
52 #define BitRight(a,b) SCRRIGHT(a,b)
53 #define BitLeft(a,b) SCRLEFT(a,b)
54 #endif
55
56 #ifdef LARGE_INSTRUCTION_CACHE
57 #define UNROLL 8
58 #define PackedLoop \
59     switch (nl & (UNROLL-1)) { \
60     SwitchOdd( 7) SwitchEven( 6) SwitchOdd( 5) SwitchEven( 4) \
61     SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
62     } \
63     while ((nl -= UNROLL) >= 0) { \
64         LoopReset \
65         BodyEven( 8) \
66         BodyOdd( 7) BodyEven( 6) BodyOdd( 5) BodyEven( 4) \
67         BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
68     }
69 #else
70 #define UNROLL 4
71 #define PackedLoop \
72     switch (nl & (UNROLL-1)) { \
73     SwitchOdd( 3) SwitchEven( 2) SwitchOdd( 1) \
74     } \
75     while ((nl -= UNROLL) >= 0) { \
76         LoopReset \
77         BodyEven( 4) \
78         BodyOdd( 3) BodyEven( 2) BodyOdd( 1) \
79     }
80 #endif
81
82 #if PPW == 32
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; \
96     }
97 #else /* PPW == 64 */
98 #define DuffL(counter,label,body) \
99     switch (counter & 7) { \
100     label: \
101         body \
102     case 7: \
103         body \
104     case 6: \
105         body \
106     case 5: \
107         body \
108     case 4: \
109         body \
110     case 3: \
111         body \
112     case 2: \
113         body \
114     case 1: \
115         body \
116     case 0: \
117         if ((counter -= 8) >= 0) \
118             goto label; \
119     }
120 #endif /* PPW */