Fixed a few typos in the german translation.
[mesa.git] / src / mesa / sparc / clip.S
1 /*
2 * Clip testing in SPARC assembly
3 */
4
5 #if defined(__sparc_v9__) && !defined(__linux__)
6 #define LDPTR ldx
7 #define V4F_DATA 0x00
8 #define V4F_START 0x08
9 #define V4F_COUNT 0x10
10 #define V4F_STRIDE 0x14
11 #define V4F_SIZE 0x18
12 #define V4F_FLAGS 0x1c
13 #else
14 #define LDPTR ld
15 #define V4F_DATA 0x00
16 #define V4F_START 0x04
17 #define V4F_COUNT 0x08
18 #define V4F_STRIDE 0x0c
19 #define V4F_SIZE 0x10
20 #define V4F_FLAGS 0x14
21 #endif
22
23 #define VEC_SIZE_1 1
24 #define VEC_SIZE_2 3
25 #define VEC_SIZE_3 7
26 #define VEC_SIZE_4 15
27
28 .text
29 .align 64
30
31 one_dot_zero:
32 .word 0x3f800000 /* 1.0f */
33
34 /* This trick is shamelessly stolen from the x86
35 * Mesa asm. Very clever, and we can do it too
36 * since we have the necessary add with carry
37 * instructions on Sparc.
38 */
39 clip_table:
40 .byte 0, 1, 0, 2, 4, 5, 4, 6
41 .byte 0, 1, 0, 2, 8, 9, 8, 10
42 .byte 32, 33, 32, 34, 36, 37, 36, 38
43 .byte 32, 33, 32, 34, 40, 41, 40, 42
44 .byte 0, 1, 0, 2, 4, 5, 4, 6
45 .byte 0, 1, 0, 2, 8, 9, 8, 10
46 .byte 16, 17, 16, 18, 20, 21, 20, 22
47 .byte 16, 17, 16, 18, 24, 25, 24, 26
48 .byte 63, 61, 63, 62, 55, 53, 55, 54
49 .byte 63, 61, 63, 62, 59, 57, 59, 58
50 .byte 47, 45, 47, 46, 39, 37, 39, 38
51 .byte 47, 45, 47, 46, 43, 41, 43, 42
52 .byte 63, 61, 63, 62, 55, 53, 55, 54
53 .byte 63, 61, 63, 62, 59, 57, 59, 58
54 .byte 31, 29, 31, 30, 23, 21, 23, 22
55 .byte 31, 29, 31, 30, 27, 25, 27, 26
56
57 /* GLvector4f *clip_vec, GLvector4f *proj_vec,
58 GLubyte clipMask[], GLubyte *orMask, GLubyte *andMask */
59
60 .align 64
61 __pc_tramp:
62 retl
63 nop
64
65 .globl _mesa_sparc_cliptest_points4
66 _mesa_sparc_cliptest_points4:
67 save %sp, -64, %sp
68 call __pc_tramp
69 sub %o7, (. - one_dot_zero - 4), %g1
70 ld [%g1 + 0x0], %f4
71 add %g1, 0x4, %g1
72
73 ld [%i0 + V4F_STRIDE], %l1
74 ld [%i0 + V4F_COUNT], %g7
75 LDPTR [%i0 + V4F_START], %i0
76 LDPTR [%i1 + V4F_START], %i5
77 ldub [%i3], %g2
78 ldub [%i4], %g3
79 sll %g3, 8, %g3
80 or %g2, %g3, %g2
81
82 ld [%i1 + V4F_FLAGS], %g3
83 or %g3, VEC_SIZE_4, %g3
84 st %g3, [%i1 + V4F_FLAGS]
85 mov 3, %g3
86 st %g3, [%i1 + V4F_SIZE]
87 st %g7, [%i1 + V4F_COUNT]
88 clr %l2
89 clr %l0
90
91 /* l0: i
92 * g7: count
93 * l1: stride
94 * l2: c
95 * g2: (tmpAndMask << 8) | tmpOrMask
96 * g1: clip_table
97 * i0: from[stride][i]
98 * i2: clipMask
99 * i5: vProj[4][i]
100 */
101
102 1: ld [%i0 + 0x0c], %f3 ! LSU Group
103 ld [%i0 + 0x0c], %g5 ! LSU Group
104 ld [%i0 + 0x08], %g4 ! LSU Group
105 fdivs %f4, %f3, %f8 ! FGM
106 addcc %g5, %g5, %g5 ! IEU1 Group
107 addx %g0, 0x0, %g3 ! IEU1 Group
108 addcc %g4, %g4, %g4 ! IEU1 Group
109 addx %g3, %g3, %g3 ! IEU1 Group
110 subcc %g5, %g4, %g0 ! IEU1 Group
111 ld [%i0 + 0x04], %g4 ! LSU Group
112 addx %g3, %g3, %g3 ! IEU1 Group
113 addcc %g4, %g4, %g4 ! IEU1 Group
114 addx %g3, %g3, %g3 ! IEU1 Group
115 subcc %g5, %g4, %g0 ! IEU1 Group
116 ld [%i0 + 0x00], %g4 ! LSU Group
117 addx %g3, %g3, %g3 ! IEU1 Group
118 addcc %g4, %g4, %g4 ! IEU1 Group
119 addx %g3, %g3, %g3 ! IEU1 Group
120 subcc %g5, %g4, %g0 ! IEU1 Group
121 addx %g3, %g3, %g3 ! IEU1 Group
122 ldub [%g1 + %g3], %g3 ! LSU Group
123 cmp %g3, 0 ! IEU1 Group, stall
124 be 2f ! CTI
125 stb %g3, [%i2] ! LSU
126 sll %g3, 8, %g4 ! IEU1 Group
127 add %l2, 1, %l2 ! IEU0
128 st %g0, [%i5 + 0x00] ! LSU
129 or %g4, 0xff, %g4 ! IEU0 Group
130 or %g2, %g3, %g2 ! IEU1
131 st %g0, [%i5 + 0x04] ! LSU
132 and %g2, %g4, %g2 ! IEU0 Group
133 st %g0, [%i5 + 0x08] ! LSU
134 b 3f ! CTI
135 st %f4, [%i5 + 0x0c] ! LSU Group
136 2: ld [%i0 + 0x00], %f0 ! LSU Group
137 ld [%i0 + 0x04], %f1 ! LSU Group
138 ld [%i0 + 0x08], %f2 ! LSU Group
139 fmuls %f0, %f8, %f0 ! FGM
140 st %f0, [%i5 + 0x00] ! LSU Group
141 fmuls %f1, %f8, %f1 ! FGM
142 st %f1, [%i5 + 0x04] ! LSU Group
143 fmuls %f2, %f8, %f2 ! FGM
144 st %f2, [%i5 + 0x08] ! LSU Group
145 st %f8, [%i5 + 0x0c] ! LSU Group
146 3: add %i5, 0x10, %i5 ! IEU1
147 add %l0, 1, %l0 ! IEU0 Group
148 add %i2, 1, %i2 ! IEU0 Group
149 cmp %l0, %g7 ! IEU1 Group
150 bne 1b ! CTI
151 add %i0, %l1, %i0 ! IEU0 Group
152 stb %g2, [%i3] ! LSU
153 srl %g2, 8, %g3 ! IEU0 Group
154 cmp %l2, %g7 ! IEU1 Group
155 bl,a 1f ! CTI
156 clr %g3 ! IEU0
157 1: stb %g3, [%i4] ! LSU Group
158 ret ! CTI Group
159 restore %i1, 0x0, %o0
160
161 .globl _mesa_sparc_cliptest_points4_np
162 _mesa_sparc_cliptest_points4_np:
163 save %sp, -64, %sp
164
165 call __pc_tramp
166 sub %o7, (. - one_dot_zero - 4), %g1
167 add %g1, 0x4, %g1
168
169 ld [%i0 + V4F_STRIDE], %l1
170 ld [%i0 + V4F_COUNT], %g7
171 LDPTR [%i0 + V4F_START], %i0
172 LDPTR [%i1 + V4F_START], %i5
173 ldub [%i3], %g2
174 ldub [%i4], %g3
175 sll %g3, 8, %g3
176 or %g2, %g3, %g2
177
178 ld [%i1 + V4F_FLAGS], %g3
179 or %g3, VEC_SIZE_4, %g3
180 st %g3, [%i1 + V4F_FLAGS]
181 mov 3, %g3
182 st %g3, [%i1 + V4F_SIZE]
183 st %g7, [%i1 + V4F_COUNT]
184 clr %l2
185 clr %l0
186
187 /* l0: i
188 * g7: count
189 * l1: stride
190 * l2: c
191 * g2: (tmpAndMask << 8) | tmpOrMask
192 * g1: clip_table
193 * i0: from[stride][i]
194 * i2: clipMask
195 */
196
197 1: ld [%i0 + 0x0c], %g5 ! LSU Group
198 ld [%i0 + 0x08], %g4 ! LSU Group
199 addcc %g5, %g5, %g5 ! IEU1 Group
200 addx %g0, 0x0, %g3 ! IEU1 Group
201 addcc %g4, %g4, %g4 ! IEU1 Group
202 addx %g3, %g3, %g3 ! IEU1 Group
203 subcc %g5, %g4, %g0 ! IEU1 Group
204 ld [%i0 + 0x04], %g4 ! LSU Group
205 addx %g3, %g3, %g3 ! IEU1 Group
206 addcc %g4, %g4, %g4 ! IEU1 Group
207 addx %g3, %g3, %g3 ! IEU1 Group
208 subcc %g5, %g4, %g0 ! IEU1 Group
209 ld [%i0 + 0x00], %g4 ! LSU Group
210 addx %g3, %g3, %g3 ! IEU1 Group
211 addcc %g4, %g4, %g4 ! IEU1 Group
212 addx %g3, %g3, %g3 ! IEU1 Group
213 subcc %g5, %g4, %g0 ! IEU1 Group
214 addx %g3, %g3, %g3 ! IEU1 Group
215 ldub [%g1 + %g3], %g3 ! LSU Group
216 cmp %g3, 0 ! IEU1 Group, stall
217 be 2f ! CTI
218 stb %g3, [%i2] ! LSU
219 sll %g3, 8, %g4 ! IEU1 Group
220 add %l2, 1, %l2 ! IEU0
221 or %g4, 0xff, %g4 ! IEU0 Group
222 or %g2, %g3, %g2 ! IEU1
223 and %g2, %g4, %g2 ! IEU0 Group
224 2: add %l0, 1, %l0 ! IEU0 Group
225 add %i2, 1, %i2 ! IEU0 Group
226 cmp %l0, %g7 ! IEU1 Group
227 bne 1b ! CTI
228 add %i0, %l1, %i0 ! IEU0 Group
229 stb %g2, [%i3] ! LSU
230 srl %g2, 8, %g3 ! IEU0 Group
231 cmp %l2, %g7 ! IEU1 Group
232 bl,a 1f ! CTI
233 clr %g3 ! IEU0
234 1: stb %g3, [%i4] ! LSU Group
235 ret ! CTI Group
236 restore %i1, 0x0, %o0