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