/src/ghostpdl/base/gsroprun8.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 Artifex Software, Inc. |
2 | | All Rights Reserved. |
3 | | |
4 | | This software is provided AS-IS with no warranty, either express or |
5 | | implied. |
6 | | |
7 | | This software is distributed under license and may not be copied, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* This file is repeatedly included by gsroprun.c to 'autogenerate' many |
18 | | * different versions of roprun code. DO NOT USE THIS FILE EXCEPT FROM |
19 | | * gsroprun.c. |
20 | | */ |
21 | | |
22 | | /* Set the following defines as appropriate on entry: |
23 | | * TEMPLATE_NAME (Compulsory) The name of the function to generate |
24 | | * SPECIFIC_ROP (Optional) If set, the function will base its decision |
25 | | * about whether to provide S and T upon |
26 | | * this value. |
27 | | * SPECIFIC_CODE (Optional) If set, this should expand out to code to |
28 | | * perform the rop. Will be invoked as: |
29 | | * SPECIFIC_CODE(OUT,D,S,T) |
30 | | * S_CONST (Optional) If set, S will be taken to be constant, else |
31 | | * S will be read from a pointer. |
32 | | * T_CONST (Optional) If set, T will be taken to be constant, else |
33 | | * T will be read from a pointer. |
34 | | * S_1BIT (Optional) If set, the code will cope with S maybe |
35 | | * being a pointer to a 1 bit bitmap to choose |
36 | | * between scolors[0] and [1]. If set to 1, the |
37 | | * code will assume that this is the case. |
38 | | * T_1BIT (Optional) If set, the code will cope with T maybe |
39 | | * being a pointer to a 1 bit bitmap to choose |
40 | | * between scolors[0] and [1]. If set to 1, the |
41 | | * code will assume that this is the case. |
42 | | * |
43 | | * To make use of SSE here, you must also define: |
44 | | * |
45 | | * MM_SPECIFIC_CODE If set, SSE can be used. Will be invoked as |
46 | | * MM_SPECIFIC_CODE(OUT_PTR,D_PTR,S,T). Note: |
47 | | * SPECIFIC_ROP must be set! |
48 | | */ |
49 | | |
50 | | #if defined(TEMPLATE_NAME) |
51 | | /* Can't do MM_SPECIFIC_CODE if we don't HAVE_SSE2 */ |
52 | | #ifndef HAVE_SSE2 |
53 | | #undef MM_SPECIFIC_CODE |
54 | | #endif |
55 | | |
56 | | #ifdef SPECIFIC_ROP |
57 | | #if rop3_uses_S(SPECIFIC_ROP) |
58 | | #define S_USED |
59 | | #endif |
60 | | #if rop3_uses_T(SPECIFIC_ROP) |
61 | | #define T_USED |
62 | | #endif |
63 | | #else /* !SPECIFIC_ROP */ |
64 | | #define S_USED |
65 | | #define T_USED |
66 | | #endif /* SPECIFIC_ROP */ |
67 | | |
68 | | #ifndef S_USED |
69 | | #undef S_1BIT |
70 | | #endif /* defined(S_USED) */ |
71 | | #ifndef T_USED |
72 | | #undef T_1BIT |
73 | | #endif /* defined(T_USED) */ |
74 | | |
75 | | #if defined(S_USED) && !defined(S_CONST) |
76 | 0 | #define FETCH_S do { S = *s++; } while (0==1) |
77 | | #define MM_FETCH_S do { S = _mm_loadu_si128((__m128i const *)s); s += 16; } while (0==1) |
78 | | #else /* !defined(S_USED) || defined(S_CONST) */ |
79 | | #define FETCH_S |
80 | | #define MM_FETCH_S |
81 | | #endif /* !defined(S_USED) || defined(S_CONST) */ |
82 | | |
83 | | #if defined(T_USED) && !defined(T_CONST) |
84 | 0 | #define FETCH_T do { T = *t++; } while (0 == 1) |
85 | | #define MM_FETCH_T do { T = _mm_loadu_su128((_m128i const *)t); t += 16; } while (0 == 1) |
86 | | #else /* !defined(T_USED) || defined(T_CONST) */ |
87 | | #define FETCH_T |
88 | | #define MM_FETCH_T |
89 | | #endif /* !defined(T_USED) || defined(T_CONST) */ |
90 | | |
91 | | #ifndef MM_SETUP |
92 | 0 | #define MM_SETUP() do { } while (0 == 1) |
93 | | #endif |
94 | | |
95 | | static void TEMPLATE_NAME(rop_run_op *op, byte *d, int len) |
96 | 0 | { |
97 | | #ifndef SPECIFIC_CODE |
98 | 0 | rop_proc proc = rop_proc_table[lop_rop(op->rop)]; |
99 | 0 | #define SPECIFIC_CODE(OUT_, D_,S_,T_) OUT_ = proc(D_,S_,T_) |
100 | | #endif /* !defined(SPECIFIC_CODE) */ |
101 | | #ifdef S_USED |
102 | | #ifdef S_CONST |
103 | | byte S = op->s.c; |
104 | | #ifdef MM_SPECIFIC_CODE |
105 | | __m128i MM_S = _mm_set1_epi8(S); |
106 | | #endif |
107 | | #else /* !defined(S_CONST) */ |
108 | | const byte *s = op->s.b.ptr; |
109 | | #endif /* !defined(S_CONST) */ |
110 | | #ifdef S_1BIT |
111 | | int sroll; |
112 | | const gx_color_index *scolors = op->scolors; |
113 | | #endif /* S_1BIT */ |
114 | | #else /* !defined(S_USED) */ |
115 | | #define S 0 |
116 | | #undef S_CONST |
117 | | #endif /* !defined(S_USED) */ |
118 | | #ifdef T_USED |
119 | | #ifdef T_CONST |
120 | | byte T = op->t.c; |
121 | | #ifdef MM_SPECIFIC_CODE |
122 | | __m128i MM_T = _mm_set1_epi8(T); |
123 | | #endif |
124 | | #else /* !defined(T_CONST) */ |
125 | | const byte *t = op->t.b.ptr; |
126 | | #endif /* !defined(T_CONST) */ |
127 | | #ifdef T_1BIT |
128 | | int troll; |
129 | | const gx_color_index *tcolors = op->tcolors; |
130 | | #endif /* T_1BIT */ |
131 | | #else /* !defined(T_USED) */ |
132 | | #define T 0 |
133 | | #undef T_CONST |
134 | | #endif /* !defined(T_USED) */ |
135 | |
|
136 | 0 | len *= op->mul; |
137 | |
|
138 | | #ifdef S_1BIT |
139 | | #if S_1BIT == MAYBE |
140 | 0 | if (op->flags & rop_s_1bit) { |
141 | 0 | #endif /* S_1BIT == MAYBE */ |
142 | 0 | s += op->s.b.pos>>3; |
143 | 0 | sroll = 8-(op->s.b.pos & 7); |
144 | | #if S_1BIT == MAYBE |
145 | | } else |
146 | 0 | sroll = 0; |
147 | | #endif /* S_1BIT == MAYBE */ |
148 | | #endif /* defined(S_1BIT) */ |
149 | | #ifdef T_1BIT |
150 | | #if T_1BIT == MAYBE |
151 | 0 | if (op->flags & rop_t_1bit) { |
152 | 0 | #endif /* T_1BIT == MAYBE */ |
153 | 0 | t += op->t.b.pos>>3; |
154 | 0 | troll = 8-(op->t.b.pos & 7); |
155 | 0 | #if T_1BIT == MAYBE |
156 | 0 | } else |
157 | 0 | troll = 0; |
158 | | #endif /* T_1BIT == MAYBE */ |
159 | | #endif /* defined(T_1BIT) */ |
160 | | |
161 | | /* Setup all done, now go for the loops */ |
162 | | |
163 | | /* SSE version - doesn't do 1 bit (for now at least) */ |
164 | | #if defined(MM_SPECIFIC_CODE) |
165 | | #if defined(S_1_BIT) |
166 | | if (sroll == 0) |
167 | | #endif |
168 | | #if defined(T_1_BIT) |
169 | | if (troll == 0) |
170 | | #endif |
171 | | { |
172 | | #ifdef MM_SETUP |
173 | 0 | MM_SETUP(); |
174 | | #endif |
175 | 0 | while (len > 16) |
176 | 0 | { |
177 | | #if defined(S_USED) && !defined(S_CONST) |
178 | | __mm128i MM_S; |
179 | | #endif /* defined(S_USED) && !defined(S_CONST) */ |
180 | | #if defined(T_USED) && !defined(T_CONST) |
181 | | __mm128i MM_T; |
182 | | #endif /* defined(T_USED) && !defined(T_CONST) */ |
183 | | #if defined(S_1BIT) && S_1BIT == MAYBE |
184 | | if (sroll == 0) { |
185 | | #endif /* defined(S_1BIT) && S_1BIT == MAYBE */ |
186 | 0 | #if !defined(S_1BIT) || S_1BIT == MAYBE |
187 | 0 | MM_FETCH_S; |
188 | 0 | #endif /* !defined(S_1BIT) || S_1BIT == MAYBE */ |
189 | | #if defined(S_1BIT) && S_1BIT == MAYBE |
190 | | } else |
191 | | #endif /* defined(S_1BIT) && S_1BIT == MAYBE */ |
192 | 0 | { |
193 | | #ifdef S_1BIT |
194 | | --sroll; |
195 | | S = scolors[(*s >> sroll) & 1]; |
196 | | if (sroll == 0) { |
197 | | sroll = 8; |
198 | | s++; |
199 | | } |
200 | | #endif /* S_1BIT */ |
201 | 0 | } |
202 | | #if defined(T_1BIT) && T_1BIT == MAYBE |
203 | | if (troll == 0) { |
204 | | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
205 | 0 | #if !defined(T_1BIT) || T_1BIT == MAYBE |
206 | 0 | MM_FETCH_T; |
207 | 0 | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
208 | | #if defined(T_1BIT) && T_1BIT == MAYBE |
209 | | } else |
210 | | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
211 | 0 | { |
212 | | #ifdef T_1BIT |
213 | | --troll; |
214 | | T = tcolors[(*t >> troll) & 1]; |
215 | | if (troll == 0) { |
216 | | troll = 8; |
217 | | t++; |
218 | | } |
219 | | #endif /* T_1BIT */ |
220 | 0 | } |
221 | 0 | MM_SPECIFIC_CODE(((__m128i *)d), ((const __m128i *)d), MM_S, MM_T); |
222 | 0 | d += 16; |
223 | 0 | len -= 16; |
224 | 0 | } |
225 | | } |
226 | | #endif |
227 | | |
228 | | /* Non SSE loop */ |
229 | 0 | do { |
230 | | #if defined(S_USED) && !defined(S_CONST) |
231 | | rop_operand S; |
232 | | #endif /* defined(S_USED) && !defined(S_CONST) */ |
233 | | #if defined(T_USED) && !defined(T_CONST) |
234 | | rop_operand T; |
235 | | #endif /* defined(T_USED) && !defined(T_CONST) */ |
236 | | #if defined(S_1BIT) && S_1BIT == MAYBE |
237 | 0 | if (sroll == 0) { |
238 | 0 | #endif /* defined(S_1BIT) && S_1BIT == MAYBE */ |
239 | | #if !defined(S_1BIT) || S_1BIT == MAYBE |
240 | 0 | FETCH_S; |
241 | | #endif /* !defined(S_1BIT) || S_1BIT == MAYBE */ |
242 | | #if defined(S_1BIT) && S_1BIT == MAYBE |
243 | | } else |
244 | 0 | #endif /* defined(S_1BIT) && S_1BIT == MAYBE */ |
245 | 0 | { |
246 | | #ifdef S_1BIT |
247 | | --sroll; |
248 | | S = scolors[(*s >> sroll) & 1]; |
249 | 0 | if (sroll == 0) { |
250 | 0 | sroll = 8; |
251 | 0 | s++; |
252 | 0 | } |
253 | | #endif /* S_1BIT */ |
254 | 0 | } |
255 | | #if defined(T_1BIT) && T_1BIT == MAYBE |
256 | 0 | if (troll == 0) { |
257 | 0 | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
258 | 0 | #if !defined(T_1BIT) || T_1BIT == MAYBE |
259 | 0 | FETCH_T; |
260 | 0 | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
261 | | #if defined(T_1BIT) && T_1BIT == MAYBE |
262 | | } else |
263 | 0 | #endif /* defined(T_1BIT) && T_1BIT == MAYBE */ |
264 | 0 | { |
265 | | #ifdef T_1BIT |
266 | | --troll; |
267 | | T = tcolors[(*t >> troll) & 1]; |
268 | 0 | if (troll == 0) { |
269 | 0 | troll = 8; |
270 | 0 | t++; |
271 | 0 | } |
272 | | #endif /* T_1BIT */ |
273 | 0 | } |
274 | 0 | SPECIFIC_CODE(*d, *d, S, T); |
275 | 0 | d++; |
276 | 0 | } |
277 | 0 | while (--len); |
278 | 0 | } Unexecuted instantiation: gsroprun.c:invert_rop_run8 Unexecuted instantiation: gsroprun.c:xor_rop_run8_const_st Unexecuted instantiation: gsroprun.c:sets_rop_run8 Unexecuted instantiation: gsroprun.c:generic_rop_run8 Unexecuted instantiation: gsroprun.c:generic_rop_run8_1bit Unexecuted instantiation: gsroprun.c:generic_rop_run8_const_t Unexecuted instantiation: gsroprun.c:generic_rop_run8_1bit_const_t Unexecuted instantiation: gsroprun.c:generic_rop_run8_const_st |
279 | | |
280 | | #undef FETCH_S |
281 | | #undef FETCH_T |
282 | | #undef S |
283 | | #undef S_1BIT |
284 | | #undef S_USED |
285 | | #undef S_CONST |
286 | | #undef SPECIFIC_CODE |
287 | | #undef SPECIFIC_ROP |
288 | | #undef T |
289 | | #undef T_1BIT |
290 | | #undef T_USED |
291 | | #undef T_CONST |
292 | | #undef TEMPLATE_NAME |
293 | | #undef MM_SETUP |
294 | | #undef MM_SPECIFIC_CODE |
295 | | #undef MM_FETCH_S |
296 | | #undef MM_FETCH_T |
297 | | |
298 | | #else |
299 | | int dummy; |
300 | | #endif |