2 * Clip testing in SPARC assembly
5 #if defined(__sparc_v9__) && !defined(__linux__)
10 #define V4F_STRIDE 0x14
12 #define V4F_FLAGS 0x1c
16 #define V4F_START 0x04
17 #define V4F_COUNT 0x08
18 #define V4F_STRIDE 0x0c
20 #define V4F_FLAGS 0x14
32 .word 0x3f800000 /* 1.0f */
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.
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
57 /* GLvector4f *clip_vec, GLvector4f *proj_vec,
58 GLubyte clipMask[], GLubyte *orMask, GLubyte *andMask */
65 .globl _mesa_sparc_cliptest_points4
66 _mesa_sparc_cliptest_points4:
69 sub %o7, (. - one_dot_zero - 4), %g1
73 ld [%i0 + V4F_STRIDE], %l1
74 ld [%i0 + V4F_COUNT], %g7
75 LDPTR [%i0 + V4F_START], %i0
76 LDPTR [%i1 + V4F_START], %i5
82 ld [%i1 + V4F_FLAGS], %g3
83 or %g3, VEC_SIZE_4, %g3
84 st %g3, [%i1 + V4F_FLAGS]
86 st %g3, [%i1 + V4F_SIZE]
87 st %g7, [%i1 + V4F_COUNT]
95 * g2: (tmpAndMask << 8) | tmpOrMask
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
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
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
151 add %i0, %l1, %i0 ! IEU0 Group
153 srl %g2, 8, %g3 ! IEU0 Group
154 cmp %l2, %g7 ! IEU1 Group
157 1: stb %g3, [%i4] ! LSU Group
159 restore %i1, 0x0, %o0
161 .globl _mesa_sparc_cliptest_points4_np
162 _mesa_sparc_cliptest_points4_np:
166 sub %o7, (. - one_dot_zero - 4), %g1
169 ld [%i0 + V4F_STRIDE], %l1
170 ld [%i0 + V4F_COUNT], %g7
171 LDPTR [%i0 + V4F_START], %i0
172 LDPTR [%i1 + V4F_START], %i5
178 ld [%i1 + V4F_FLAGS], %g3
179 or %g3, VEC_SIZE_4, %g3
180 st %g3, [%i1 + V4F_FLAGS]
182 st %g3, [%i1 + V4F_SIZE]
183 st %g7, [%i1 + V4F_COUNT]
191 * g2: (tmpAndMask << 8) | tmpOrMask
193 * i0: from[stride][i]
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
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
228 add %i0, %l1, %i0 ! IEU0 Group
230 srl %g2, 8, %g3 ! IEU0 Group
231 cmp %l2, %g7 ! IEU1 Group
234 1: stb %g3, [%i4] ! LSU Group
236 restore %i1, 0x0, %o0