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

« back to all changes in this revision

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