~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to cfb/stipsprc32.s

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Xorg: stipsprc32.s,v 1.4 2001/02/09 02:04:39 xorgcvs Exp $
 
3
 * $XdotOrg: xserver/xorg/cfb/stipsprc32.s,v 1.3 2004/04/26 02:39:58 alanc Exp $
 
4
 *
 
5
Copyright 1990, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
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
OPEN GROUP 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 Open Group 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 Open Group.
 
26
 *
 
27
 * Author:  Keith Packard, MIT X Consortium
 
28
 */
 
29
/* $XFree86: xc/programs/Xserver/cfb/stipsprc32.s,v 1.4 2001/01/17 22:36:38 dawes Exp $ */
 
30
 
 
31
/*
 
32
 * SPARC assembly code for optimized text rendering.
 
33
 *
 
34
 * Other stippling could be done in assembly, but the payoff is
 
35
 * not nearly as large.  Mostly because large areas are heavily
 
36
 * optimized already.
 
37
 */
 
38
 
 
39
/* not that I expect to ever see an LSB SPARC, but ... */
 
40
#ifdef LITTLE_ENDIAN
 
41
# define BitsR          sll
 
42
# define BitsL          srl
 
43
# define WO(o)          3-o
 
44
# define FourBits(dest,bits)    and     bits, 0xf, dest
 
45
#else
 
46
# define BitsR          srl
 
47
# define BitsL          sll
 
48
# define WO(o)          o
 
49
# define FourBits(dest,bits)    srl     bits, 28, dest
 
50
#endif
 
51
 
 
52
/*
 
53
 * cfb32StippleStack(addr, stipple, value, stride, Count, Shift)
 
54
 *               4       5       6      7     16(sp) 20(sp)
 
55
 *
 
56
 *  Apply successive 32-bit stipples starting at addr, addr+stride, ...
 
57
 *
 
58
 *  Used for text rendering, but only when no data could be lost
 
59
 *  when the stipple is shifted left by Shift bits
 
60
 */
 
61
/* arguments */
 
62
#define addr    %i0
 
63
#define stipple %i1
 
64
#define value   %i2
 
65
#define stride  %i3
 
66
#define count   %i4
 
67
#define shift   %i5
 
68
 
 
69
/* local variables */
 
70
#define atemp   %l0
 
71
#define bits    %l1
 
72
#define lshift  %l2
 
73
#define sbase   %l3
 
74
#define stemp   %l4
 
75
 
 
76
#define CASE_SIZE       5       /* case blocks are 2^5 bytes each */
 
77
#define CASE_MASK       0x1e0   /* first case mask */
 
78
 
 
79
#define ForEachLine     LY1
 
80
#define NextLine        LY2
 
81
#define CaseBegin       LY3
 
82
#define ForEachBits     LY4
 
83
#define NextBits        LY5
 
84
 
 
85
#if defined(SVR4) || defined(__ELF__)
 
86
#ifdef TETEXT
 
87
#define _cfb32StippleStack      cfb32StippleStackTE
 
88
#else
 
89
#define _cfb32StippleStack      cfb32StippleStack
 
90
#endif
 
91
#else
 
92
#ifdef TETEXT
 
93
#define _cfb32StippleStack      _cfb32StippleStackTE
 
94
#endif
 
95
#endif
 
96
 
 
97
        .seg    "text"
 
98
        .proc   16
 
99
        .globl  _cfb32StippleStack
 
100
_cfb32StippleStack:
 
101
        save    %sp,-64,%sp
 
102
#ifdef SHAREDCODE
 
103
1:
 
104
        call    2f
 
105
        nop
 
106
2:
 
107
        mov     %o7,sbase                       /* sbase = 1b(1:) */
 
108
        add     sbase, CaseBegin-1b, sbase
 
109
#else /* !SHAREDCODE */
 
110
        sethi   %hi(CaseBegin),sbase            /* load up switch table */
 
111
        or      sbase,%lo(CaseBegin),sbase
 
112
#endif /* !SHAREDCODE */
 
113
        mov     4,lshift                        /* compute offset within */
 
114
        sub     lshift, shift, lshift           /*  stipple of remaining bits */
 
115
#ifdef LITTLE_ENDIAN
 
116
        inc     CASE_SIZE, shift                /* first shift for LSB */
 
117
#else
 
118
        inc     28-CASE_SIZE, shift             /* first shift for MSB */
 
119
#endif
 
120
        /* do ... while (--count > 0); */
 
121
ForEachLine:
 
122
        ld      [stipple],bits                  /* get stipple bits */
 
123
        mov     addr,atemp                      /* set up for this line */
 
124
#ifdef TETEXT
 
125
        /* Terminal emulator fonts are expanded and have many 0 rows */
 
126
        tst     bits
 
127
        bz      NextLine                        /* skip out early on 0 */
 
128
#endif
 
129
        add     addr, stride, addr              /* step for the loop */
 
130
        BitsR   bits, shift, stemp              /* get first bits */
 
131
        and     stemp, CASE_MASK, stemp         /* compute first jump */
 
132
        BitsL   bits, lshift, bits              /* set remaining bits */
 
133
        jmp     sbase+stemp                     /*  ... */
 
134
        tst     bits
 
135
 
 
136
ForEachBits:
 
137
        inc     16, atemp
 
138
ForEachBits1:
 
139
        FourBits(stemp, bits)                   /* compute jump for */
 
140
        sll     stemp, CASE_SIZE, stemp         /*  these four bits */
 
141
        BitsL   bits, 4, bits                   /* step for remaining bits */
 
142
        jmp     sbase+stemp                     /* jump */
 
143
        tst     bits
 
144
CaseBegin:
 
145
        bnz,a   ForEachBits1                    /* 0 */
 
146
        inc     16, atemp
 
147
NextLine:
 
148
        deccc   1, count
 
149
NextLine1:
 
150
        bnz,a   ForEachLine
 
151
        inc     4, stipple
 
152
        ret
 
153
        restore
 
154
        nop
 
155
 
 
156
        bnz     ForEachBits                     /* 1 */
 
157
        st      value, [atemp+WO(12)]
 
158
        deccc   1, count
 
159
        bnz,a   ForEachLine
 
160
        inc     4, stipple
 
161
        ret
 
162
        restore
 
163
        nop
 
164
                                        
 
165
        bnz     ForEachBits                     /* 2 */
 
166
        st      value, [atemp+WO(8)]
 
167
        deccc   1, count
 
168
        bnz,a   ForEachLine
 
169
        inc     4, stipple
 
170
        ret
 
171
        restore
 
172
        nop
 
173
                                        
 
174
        st      value, [atemp+WO(8)]            /* 3 */
 
175
        bnz     ForEachBits
 
176
        st      value, [atemp+WO(12)]
 
177
        deccc   1, count
 
178
        bnz,a   ForEachLine
 
179
        inc     4, stipple
 
180
        ret
 
181
        restore
 
182
                                        
 
183
        bnz     ForEachBits                     /* 4 */
 
184
        st      value, [atemp+WO(4)]
 
185
        deccc   1, count
 
186
        bnz,a   ForEachLine
 
187
        inc     4, stipple
 
188
        ret
 
189
        restore
 
190
        nop
 
191
                                        
 
192
        st      value, [atemp+WO(4)]            /* 5 */
 
193
        bnz     ForEachBits
 
194
        st      value, [atemp+WO(12)]
 
195
        deccc   1, count
 
196
        bnz,a   ForEachLine
 
197
        inc     4, stipple
 
198
        ret
 
199
        restore
 
200
                                        
 
201
        st      value, [atemp+WO(4)]            /* 6 */
 
202
        bnz     ForEachBits
 
203
        st      value, [atemp+WO(8)]
 
204
        deccc   1, count
 
205
        bnz,a   ForEachLine
 
206
        inc     4, stipple
 
207
        ret
 
208
        restore
 
209
                                        
 
210
        st      value, [atemp+WO(4)]            /* 7 */
 
211
        st      value, [atemp+WO(8)]
 
212
        bnz     ForEachBits
 
213
        st      value, [atemp+WO(12)]
 
214
        b       NextLine1
 
215
        deccc   1, count
 
216
        nop
 
217
        nop
 
218
                                        
 
219
        bnz     ForEachBits                     /* 8 */
 
220
        st      value, [atemp+WO(0)]
 
221
        deccc   1, count
 
222
        bnz,a   ForEachLine
 
223
        inc     4, stipple
 
224
        ret
 
225
        restore
 
226
        nop
 
227
                                        
 
228
        st      value, [atemp+WO(0)]            /* 9 */
 
229
        bnz     ForEachBits
 
230
        st      value, [atemp+WO(12)]
 
231
        deccc   1, count
 
232
        bnz,a   ForEachLine
 
233
        inc     4, stipple
 
234
        ret
 
235
        restore
 
236
                                        
 
237
        st      value, [atemp+WO(0)]            /* a */
 
238
        bnz     ForEachBits
 
239
        st      value, [atemp+WO(8)]
 
240
        deccc   1, count
 
241
        bnz,a   ForEachLine
 
242
        inc     4, stipple
 
243
        ret
 
244
        restore
 
245
                                        
 
246
        st      value, [atemp+WO(0)]            /* b */
 
247
        st      value, [atemp+WO(8)]
 
248
        bnz     ForEachBits
 
249
        st      value, [atemp+WO(12)]
 
250
        b       NextLine1
 
251
        deccc   1, count
 
252
        nop
 
253
        nop
 
254
                                        
 
255
        st      value, [atemp+WO(0)]            /* c */
 
256
        bnz     ForEachBits
 
257
        st      value, [atemp+WO(4)]
 
258
        deccc   1, count
 
259
        bnz,a   ForEachLine
 
260
        inc     4, stipple
 
261
        ret
 
262
        restore
 
263
                                        
 
264
        st      value, [atemp+WO(0)]            /* d */
 
265
        st      value, [atemp+WO(4)]
 
266
        bnz     ForEachBits
 
267
        st      value, [atemp+WO(12)]
 
268
        b       NextLine1
 
269
        deccc   1, count
 
270
        nop
 
271
        nop
 
272
                                        
 
273
        st      value, [atemp+WO(0)]            /* e */
 
274
        st      value, [atemp+WO(4)]
 
275
        bnz     ForEachBits
 
276
        st      value, [atemp+WO(8)]
 
277
        b       NextLine1
 
278
        deccc   1, count
 
279
        nop
 
280
        nop
 
281
                                        
 
282
        st      value, [atemp+WO(0)]            /* f */
 
283
        st      value, [atemp+WO(4)]
 
284
        st      value, [atemp+WO(8)]
 
285
        bnz     ForEachBits
 
286
        st      value, [atemp+WO(12)]
 
287
        deccc   1, count
 
288
        bnz,a   ForEachLine
 
289
        inc     4, stipple
 
290
        ret
 
291
        restore