]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/cfb/stipsprc32.s
Import X server from vnc-3.3.7.
[rdpsrv] / Xserver / programs / Xserver / cfb / stipsprc32.s
1 /*
2  * $XConsortium: stipsprc32.s,v 1.3 94/04/17 20:29:10 rws Exp $
3  *
4 Copyright (c) 1990  X Consortium
5
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
26  *
27  * Author:  Keith Packard, MIT X Consortium
28  */
29
30 /*
31  * SPARC assembly code for optimized text rendering.
32  *
33  * Other stippling could be done in assembly, but the payoff is
34  * not nearly as large.  Mostly because large areas are heavily
35  * optimized already.
36  */
37
38 /* not that I expect to ever see an LSB SPARC, but ... */
39 #ifdef LITTLE_ENDIAN
40 # define BitsR          sll
41 # define BitsL          srl
42 # define WO(o)          3-o
43 # define FourBits(dest,bits)    and     bits, 0xf, dest
44 #else
45 # define BitsR          srl
46 # define BitsL          sll
47 # define WO(o)          o
48 # define FourBits(dest,bits)    srl     bits, 28, dest
49 #endif
50
51 /*
52  * cfb32StippleStack(addr, stipple, value, stride, Count, Shift)
53  *               4       5       6      7     16(sp) 20(sp)
54  *
55  *  Apply successive 32-bit stipples starting at addr, addr+stride, ...
56  *
57  *  Used for text rendering, but only when no data could be lost
58  *  when the stipple is shifted left by Shift bits
59  */
60 /* arguments */
61 #define addr    %i0
62 #define stipple %i1
63 #define value   %i2
64 #define stride  %i3
65 #define count   %i4
66 #define shift   %i5
67
68 /* local variables */
69 #define atemp   %l0
70 #define bits    %l1
71 #define lshift  %l2
72 #define sbase   %l3
73 #define stemp   %l4
74
75 #define CASE_SIZE       5       /* case blocks are 2^5 bytes each */
76 #define CASE_MASK       0x1e0   /* first case mask */
77
78 #define ForEachLine     LY1
79 #define NextLine        LY2
80 #define CaseBegin       LY3
81 #define ForEachBits     LY4
82 #define NextBits        LY5
83
84 #if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
85 #ifdef TETEXT
86 #define _cfb32StippleStack      cfb32StippleStackTE
87 #else
88 #define _cfb32StippleStack      cfb32StippleStack
89 #endif
90 #else
91 #ifdef TETEXT
92 #define _cfb32StippleStack      _cfb32StippleStackTE
93 #endif
94 #endif
95
96         .seg    "text"
97         .proc   16
98         .globl  _cfb32StippleStack
99 _cfb32StippleStack:
100         save    %sp,-64,%sp
101         sethi   %hi(CaseBegin),sbase            /* load up switch table */
102         or      sbase,%lo(CaseBegin),sbase
103
104         mov     4,lshift                        /* compute offset within */
105         sub     lshift, shift, lshift           /*  stipple of remaining bits */
106 #ifdef LITTLE_ENDIAN
107         inc     CASE_SIZE, shift                /* first shift for LSB */
108 #else
109         inc     28-CASE_SIZE, shift             /* first shift for MSB */
110 #endif
111         /* do ... while (--count > 0); */
112 ForEachLine:
113         ld      [stipple],bits                  /* get stipple bits */
114         mov     addr,atemp                      /* set up for this line */
115 #ifdef TETEXT
116         /* Terminal emulator fonts are expanded and have many 0 rows */
117         tst     bits
118         bz      NextLine                        /* skip out early on 0 */
119 #endif
120         add     addr, stride, addr              /* step for the loop */
121         BitsR   bits, shift, stemp              /* get first bits */
122         and     stemp, CASE_MASK, stemp         /* compute first jump */
123         BitsL   bits, lshift, bits              /* set remaining bits */
124         jmp     sbase+stemp                     /*  ... */
125         tst     bits
126
127 ForEachBits:
128         inc     16, atemp
129 ForEachBits1:
130         FourBits(stemp, bits)                   /* compute jump for */
131         sll     stemp, CASE_SIZE, stemp         /*  these four bits */
132         BitsL   bits, 4, bits                   /* step for remaining bits */
133         jmp     sbase+stemp                     /* jump */
134         tst     bits
135 CaseBegin:
136         bnz,a   ForEachBits1                    /* 0 */
137         inc     16, atemp
138 NextLine:
139         deccc   1, count
140 NextLine1:
141         bnz,a   ForEachLine
142         inc     4, stipple
143         ret
144         restore
145         nop
146
147         bnz     ForEachBits                     /* 1 */
148         st      value, [atemp+WO(12)]
149         deccc   1, count
150         bnz,a   ForEachLine
151         inc     4, stipple
152         ret
153         restore
154         nop
155                                         
156         bnz     ForEachBits                     /* 2 */
157         st      value, [atemp+WO(8)]
158         deccc   1, count
159         bnz,a   ForEachLine
160         inc     4, stipple
161         ret
162         restore
163         nop
164                                         
165         st      value, [atemp+WO(8)]            /* 3 */
166         bnz     ForEachBits
167         st      value, [atemp+WO(12)]
168         deccc   1, count
169         bnz,a   ForEachLine
170         inc     4, stipple
171         ret
172         restore
173                                         
174         bnz     ForEachBits                     /* 4 */
175         st      value, [atemp+WO(4)]
176         deccc   1, count
177         bnz,a   ForEachLine
178         inc     4, stipple
179         ret
180         restore
181         nop
182                                         
183         st      value, [atemp+WO(4)]            /* 5 */
184         bnz     ForEachBits
185         st      value, [atemp+WO(12)]
186         deccc   1, count
187         bnz,a   ForEachLine
188         inc     4, stipple
189         ret
190         restore
191                                         
192         st      value, [atemp+WO(4)]            /* 6 */
193         bnz     ForEachBits
194         st      value, [atemp+WO(8)]
195         deccc   1, count
196         bnz,a   ForEachLine
197         inc     4, stipple
198         ret
199         restore
200                                         
201         st      value, [atemp+WO(4)]            /* 7 */
202         st      value, [atemp+WO(8)]
203         bnz     ForEachBits
204         st      value, [atemp+WO(12)]
205         b       NextLine1
206         deccc   1, count
207         nop
208         nop
209                                         
210         bnz     ForEachBits                     /* 8 */
211         st      value, [atemp+WO(0)]
212         deccc   1, count
213         bnz,a   ForEachLine
214         inc     4, stipple
215         ret
216         restore
217         nop
218                                         
219         st      value, [atemp+WO(0)]            /* 9 */
220         bnz     ForEachBits
221         st      value, [atemp+WO(12)]
222         deccc   1, count
223         bnz,a   ForEachLine
224         inc     4, stipple
225         ret
226         restore
227                                         
228         st      value, [atemp+WO(0)]            /* a */
229         bnz     ForEachBits
230         st      value, [atemp+WO(8)]
231         deccc   1, count
232         bnz,a   ForEachLine
233         inc     4, stipple
234         ret
235         restore
236                                         
237         st      value, [atemp+WO(0)]            /* b */
238         st      value, [atemp+WO(8)]
239         bnz     ForEachBits
240         st      value, [atemp+WO(12)]
241         b       NextLine1
242         deccc   1, count
243         nop
244         nop
245                                         
246         st      value, [atemp+WO(0)]            /* c */
247         bnz     ForEachBits
248         st      value, [atemp+WO(4)]
249         deccc   1, count
250         bnz,a   ForEachLine
251         inc     4, stipple
252         ret
253         restore
254                                         
255         st      value, [atemp+WO(0)]            /* d */
256         st      value, [atemp+WO(4)]
257         bnz     ForEachBits
258         st      value, [atemp+WO(12)]
259         b       NextLine1
260         deccc   1, count
261         nop
262         nop
263                                         
264         st      value, [atemp+WO(0)]            /* e */
265         st      value, [atemp+WO(4)]
266         bnz     ForEachBits
267         st      value, [atemp+WO(8)]
268         b       NextLine1
269         deccc   1, count
270         nop
271         nop
272                                         
273         st      value, [atemp+WO(0)]            /* f */
274         st      value, [atemp+WO(4)]
275         st      value, [atemp+WO(8)]
276         bnz     ForEachBits
277         st      value, [atemp+WO(12)]
278         deccc   1, count
279         bnz,a   ForEachLine
280         inc     4, stipple
281         ret
282         restore