glx: Don't try to swap a front buffer if we don't have one.
[mesa.git] / src / gallium / drivers / r600 / r600_compiler_tgsi.c
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23 #include <stdlib.h>
24 #include <string.h>
25 #include <stdint.h>
26 #include <stdio.h>
27 #include <errno.h>
28 #include <tgsi/tgsi_parse.h>
29 #include <tgsi/tgsi_scan.h>
30 #include "r600_shader.h"
31 #include "r600_context.h"
32
33 struct tgsi_shader {
34 struct c_vector **v[TGSI_FILE_COUNT];
35 struct tgsi_shader_info info;
36 struct tgsi_parse_context parser;
37 const struct tgsi_token *tokens;
38 struct c_shader *shader;
39 struct c_node *node;
40 };
41
42 static unsigned tgsi_file_to_c_file(unsigned file);
43 static unsigned tgsi_sname_to_c_sname(unsigned sname);
44 static int tgsi_opcode_to_c_opcode(unsigned opcode, unsigned *copcode);
45
46 static int tgsi_shader_init(struct tgsi_shader *ts,
47 const struct tgsi_token *tokens,
48 struct c_shader *shader)
49 {
50 int i;
51
52 ts->shader = shader;
53 ts->tokens = tokens;
54 tgsi_scan_shader(ts->tokens, &ts->info);
55 tgsi_parse_init(&ts->parser, ts->tokens);
56 /* initialize to NULL in case of error */
57 for (i = 0; i < C_FILE_COUNT; i++) {
58 ts->v[i] = NULL;
59 }
60 for (i = 0; i < TGSI_FILE_COUNT; i++) {
61 if (ts->info.file_count[i] > 0) {
62 ts->v[i] = calloc(ts->info.file_count[i], sizeof(void*));
63 if (ts->v[i] == NULL) {
64 fprintf(stderr, "%s:%d unsupported %d %d\n", __func__, __LINE__, i, ts->info.file_count[i]);
65 return -ENOMEM;
66 }
67 }
68 }
69 return 0;
70 }
71
72 static void tgsi_shader_destroy(struct tgsi_shader *ts)
73 {
74 int i;
75
76 for (i = 0; i < TGSI_FILE_COUNT; i++) {
77 free(ts->v[i]);
78 }
79 tgsi_parse_free(&ts->parser);
80 }
81
82 static int ntransform_declaration(struct tgsi_shader *ts)
83 {
84 struct tgsi_full_declaration *fd = &ts->parser.FullToken.FullDeclaration;
85 struct c_vector *v;
86 unsigned file;
87 unsigned name;
88 int sid;
89 int i;
90
91 if (fd->Declaration.Dimension) {
92 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
93 return -EINVAL;
94 }
95 for (i = fd->Range.First ; i <= fd->Range.Last; i++) {
96 sid = i;
97 name = C_SEMANTIC_GENERIC;
98 file = tgsi_file_to_c_file(fd->Declaration.File);
99 if (file == TGSI_FILE_NULL) {
100 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
101 return -EINVAL;
102 }
103 if (fd->Declaration.Semantic) {
104 name = tgsi_sname_to_c_sname(fd->Semantic.Name);
105 sid = fd->Semantic.Index;
106 }
107 v = c_shader_vector_new(ts->shader, file, name, sid);
108 if (v == NULL) {
109 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
110 return -ENOMEM;
111 }
112 ts->v[fd->Declaration.File][i] = v;
113 }
114 return 0;
115 }
116
117 static int ntransform_immediate(struct tgsi_shader *ts)
118 {
119 struct tgsi_full_immediate *fd = &ts->parser.FullToken.FullImmediate;
120 struct c_vector *v;
121 unsigned file;
122 unsigned name;
123
124 if (fd->Immediate.DataType != TGSI_IMM_FLOAT32) {
125 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
126 return -EINVAL;
127 }
128 name = C_SEMANTIC_GENERIC;
129 file = C_FILE_IMMEDIATE;
130 v = c_shader_vector_new(ts->shader, file, name, 0);
131 if (v == NULL) {
132 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
133 return -ENOMEM;
134 }
135 v->channel[0]->value = fd->u[0].Uint;
136 v->channel[1]->value = fd->u[1].Uint;
137 v->channel[2]->value = fd->u[2].Uint;
138 v->channel[3]->value = fd->u[3].Uint;
139 ts->v[TGSI_FILE_IMMEDIATE][0] = v;
140 return 0;
141 }
142
143 static int ntransform_instruction(struct tgsi_shader *ts)
144 {
145 struct tgsi_full_instruction *fi = &ts->parser.FullToken.FullInstruction;
146 struct c_shader *shader = ts->shader;
147 struct c_instruction instruction;
148 unsigned opcode;
149 int i, j, r;
150
151 if (fi->Instruction.NumDstRegs > 1) {
152 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
153 return -EINVAL;
154 }
155 if (fi->Instruction.Saturate) {
156 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
157 return -EINVAL;
158 }
159 if (fi->Instruction.Predicate) {
160 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
161 return -EINVAL;
162 }
163 if (fi->Instruction.Label) {
164 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
165 return -EINVAL;
166 }
167 if (fi->Instruction.Texture) {
168 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
169 return -EINVAL;
170 }
171 for (i = 0; i < fi->Instruction.NumSrcRegs; i++) {
172 if (fi->Src[i].Register.Indirect ||
173 fi->Src[i].Register.Dimension ||
174 fi->Src[i].Register.Absolute) {
175 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
176 return -EINVAL;
177 }
178 }
179 for (i = 0; i < fi->Instruction.NumDstRegs; i++) {
180 if (fi->Dst[i].Register.Indirect || fi->Dst[i].Register.Dimension) {
181 fprintf(stderr, "%s %d unsupported\n", __func__, __LINE__);
182 return -EINVAL;
183 }
184 }
185 r = tgsi_opcode_to_c_opcode(fi->Instruction.Opcode, &opcode);
186 if (r) {
187 fprintf(stderr, "%s:%d unsupported\n", __func__, __LINE__);
188 return r;
189 }
190 if (opcode == C_OPCODE_END) {
191 return c_node_cfg_link(ts->node, &shader->end);
192 }
193 /* FIXME add flow instruction handling */
194 memset(&instruction, 0, sizeof(struct c_instruction));
195 instruction.nop = 0;
196 for (j = 0; j < 4; j++) {
197 instruction.op[instruction.nop].opcode = opcode;
198 instruction.op[instruction.nop].ninput = fi->Instruction.NumSrcRegs;
199 for (i = 0; i < fi->Instruction.NumSrcRegs; i++) {
200 instruction.op[instruction.nop].input[i].vector = ts->v[fi->Src[i].Register.File][fi->Src[i].Register.Index];
201 switch (j) {
202 case 0:
203 instruction.op[instruction.nop].input[i].swizzle = fi->Src[i].Register.SwizzleX;
204 break;
205 case 1:
206 instruction.op[instruction.nop].input[i].swizzle = fi->Src[i].Register.SwizzleY;
207 break;
208 case 2:
209 instruction.op[instruction.nop].input[i].swizzle = fi->Src[i].Register.SwizzleZ;
210 break;
211 case 3:
212 instruction.op[instruction.nop].input[i].swizzle = fi->Src[i].Register.SwizzleW;
213 break;
214 default:
215 return -EINVAL;
216 }
217 }
218 instruction.op[instruction.nop].output.vector = ts->v[fi->Dst[0].Register.File][fi->Dst[0].Register.Index];
219 switch (j) {
220 case 0:
221 instruction.op[instruction.nop].output.swizzle = (fi->Dst[0].Register.WriteMask & 0x1) ? C_SWIZZLE_X : C_SWIZZLE_D;
222 break;
223 case 1:
224 instruction.op[instruction.nop].output.swizzle = (fi->Dst[0].Register.WriteMask & 0x1) ? C_SWIZZLE_Y : C_SWIZZLE_D;
225 break;
226 case 2:
227 instruction.op[instruction.nop].output.swizzle = (fi->Dst[0].Register.WriteMask & 0x1) ? C_SWIZZLE_Z : C_SWIZZLE_D;
228 break;
229 case 3:
230 instruction.op[instruction.nop].output.swizzle = (fi->Dst[0].Register.WriteMask & 0x1) ? C_SWIZZLE_W : C_SWIZZLE_D;
231 break;
232 default:
233 return -EINVAL;
234 }
235 instruction.nop++;
236 }
237 return c_node_add_new_instruction(ts->node, &instruction);
238 }
239
240 int c_shader_from_tgsi(struct c_shader *shader, unsigned type,
241 const struct tgsi_token *tokens)
242 {
243 struct tgsi_shader ts;
244 int r = 0;
245
246 c_shader_init(shader, type);
247 r = tgsi_shader_init(&ts, tokens, shader);
248 if (r)
249 goto out_err;
250 ts.shader = shader;
251 ts.node = &shader->entry;
252 while (!tgsi_parse_end_of_tokens(&ts.parser)) {
253 tgsi_parse_token(&ts.parser);
254 switch (ts.parser.FullToken.Token.Type) {
255 case TGSI_TOKEN_TYPE_IMMEDIATE:
256 r = ntransform_immediate(&ts);
257 if (r)
258 goto out_err;
259 break;
260 case TGSI_TOKEN_TYPE_DECLARATION:
261 r = ntransform_declaration(&ts);
262 if (r)
263 goto out_err;
264 break;
265 case TGSI_TOKEN_TYPE_INSTRUCTION:
266 r = ntransform_instruction(&ts);
267 if (r)
268 goto out_err;
269 break;
270 default:
271 r = -EINVAL;
272 goto out_err;
273 }
274 }
275 tgsi_shader_destroy(&ts);
276 return 0;
277 out_err:
278 c_shader_destroy(shader);
279 tgsi_shader_destroy(&ts);
280 return r;
281 }
282
283 static unsigned tgsi_file_to_c_file(unsigned file)
284 {
285 switch (file) {
286 case TGSI_FILE_CONSTANT:
287 return C_FILE_CONSTANT;
288 case TGSI_FILE_INPUT:
289 return C_FILE_INPUT;
290 case TGSI_FILE_OUTPUT:
291 return C_FILE_OUTPUT;
292 case TGSI_FILE_TEMPORARY:
293 return C_FILE_TEMPORARY;
294 case TGSI_FILE_SAMPLER:
295 return C_FILE_SAMPLER;
296 case TGSI_FILE_ADDRESS:
297 return C_FILE_ADDRESS;
298 case TGSI_FILE_IMMEDIATE:
299 return C_FILE_IMMEDIATE;
300 case TGSI_FILE_PREDICATE:
301 return C_FILE_PREDICATE;
302 case TGSI_FILE_SYSTEM_VALUE:
303 return C_FILE_SYSTEM_VALUE;
304 case TGSI_FILE_NULL:
305 return C_FILE_NULL;
306 default:
307 fprintf(stderr, "%s:%d unsupported file %d\n", __func__, __LINE__, file);
308 return C_FILE_NULL;
309 }
310 }
311
312 static unsigned tgsi_sname_to_c_sname(unsigned sname)
313 {
314 switch (sname) {
315 case TGSI_SEMANTIC_POSITION:
316 return C_SEMANTIC_POSITION;
317 case TGSI_SEMANTIC_COLOR:
318 return C_SEMANTIC_COLOR;
319 case TGSI_SEMANTIC_BCOLOR:
320 return C_SEMANTIC_BCOLOR;
321 case TGSI_SEMANTIC_FOG:
322 return C_SEMANTIC_FOG;
323 case TGSI_SEMANTIC_PSIZE:
324 return C_SEMANTIC_PSIZE;
325 case TGSI_SEMANTIC_GENERIC:
326 return C_SEMANTIC_GENERIC;
327 case TGSI_SEMANTIC_NORMAL:
328 return C_SEMANTIC_NORMAL;
329 case TGSI_SEMANTIC_FACE:
330 return C_SEMANTIC_FACE;
331 case TGSI_SEMANTIC_EDGEFLAG:
332 return C_SEMANTIC_EDGEFLAG;
333 case TGSI_SEMANTIC_PRIMID:
334 return C_SEMANTIC_PRIMID;
335 case TGSI_SEMANTIC_INSTANCEID:
336 return C_SEMANTIC_INSTANCEID;
337 default:
338 return C_SEMANTIC_GENERIC;
339 }
340 }
341
342 static int tgsi_opcode_to_c_opcode(unsigned opcode, unsigned *copcode)
343 {
344 switch (opcode) {
345 case TGSI_OPCODE_MOV:
346 *copcode = C_OPCODE_MOV;
347 return 0;
348 case TGSI_OPCODE_MUL:
349 *copcode = C_OPCODE_MUL;
350 return 0;
351 case TGSI_OPCODE_MAD:
352 *copcode = C_OPCODE_MAD;
353 return 0;
354 case TGSI_OPCODE_END:
355 *copcode = C_OPCODE_END;
356 return 0;
357 case TGSI_OPCODE_ARL:
358 *copcode = C_OPCODE_ARL;
359 return 0;
360 case TGSI_OPCODE_LIT:
361 *copcode = C_OPCODE_LIT;
362 return 0;
363 case TGSI_OPCODE_RCP:
364 *copcode = C_OPCODE_RCP;
365 return 0;
366 case TGSI_OPCODE_RSQ:
367 *copcode = C_OPCODE_RSQ;
368 return 0;
369 case TGSI_OPCODE_EXP:
370 *copcode = C_OPCODE_EXP;
371 return 0;
372 case TGSI_OPCODE_LOG:
373 *copcode = C_OPCODE_LOG;
374 return 0;
375 case TGSI_OPCODE_ADD:
376 *copcode = C_OPCODE_ADD;
377 return 0;
378 case TGSI_OPCODE_DP3:
379 *copcode = C_OPCODE_DP3;
380 return 0;
381 case TGSI_OPCODE_DP4:
382 *copcode = C_OPCODE_DP4;
383 return 0;
384 case TGSI_OPCODE_DST:
385 *copcode = C_OPCODE_DST;
386 return 0;
387 case TGSI_OPCODE_MIN:
388 *copcode = C_OPCODE_MIN;
389 return 0;
390 case TGSI_OPCODE_MAX:
391 *copcode = C_OPCODE_MAX;
392 return 0;
393 case TGSI_OPCODE_SLT:
394 *copcode = C_OPCODE_SLT;
395 return 0;
396 case TGSI_OPCODE_SGE:
397 *copcode = C_OPCODE_SGE;
398 return 0;
399 case TGSI_OPCODE_SUB:
400 *copcode = C_OPCODE_SUB;
401 return 0;
402 case TGSI_OPCODE_LRP:
403 *copcode = C_OPCODE_LRP;
404 return 0;
405 case TGSI_OPCODE_CND:
406 *copcode = C_OPCODE_CND;
407 return 0;
408 case TGSI_OPCODE_DP2A:
409 *copcode = C_OPCODE_DP2A;
410 return 0;
411 case TGSI_OPCODE_FRC:
412 *copcode = C_OPCODE_FRC;
413 return 0;
414 case TGSI_OPCODE_CLAMP:
415 *copcode = C_OPCODE_CLAMP;
416 return 0;
417 case TGSI_OPCODE_FLR:
418 *copcode = C_OPCODE_FLR;
419 return 0;
420 case TGSI_OPCODE_ROUND:
421 *copcode = C_OPCODE_ROUND;
422 return 0;
423 case TGSI_OPCODE_EX2:
424 *copcode = C_OPCODE_EX2;
425 return 0;
426 case TGSI_OPCODE_LG2:
427 *copcode = C_OPCODE_LG2;
428 return 0;
429 case TGSI_OPCODE_POW:
430 *copcode = C_OPCODE_POW;
431 return 0;
432 case TGSI_OPCODE_XPD:
433 *copcode = C_OPCODE_XPD;
434 return 0;
435 case TGSI_OPCODE_ABS:
436 *copcode = C_OPCODE_ABS;
437 return 0;
438 case TGSI_OPCODE_RCC:
439 *copcode = C_OPCODE_RCC;
440 return 0;
441 case TGSI_OPCODE_DPH:
442 *copcode = C_OPCODE_DPH;
443 return 0;
444 case TGSI_OPCODE_COS:
445 *copcode = C_OPCODE_COS;
446 return 0;
447 case TGSI_OPCODE_DDX:
448 *copcode = C_OPCODE_DDX;
449 return 0;
450 case TGSI_OPCODE_DDY:
451 *copcode = C_OPCODE_DDY;
452 return 0;
453 case TGSI_OPCODE_KILP:
454 *copcode = C_OPCODE_KILP;
455 return 0;
456 case TGSI_OPCODE_PK2H:
457 *copcode = C_OPCODE_PK2H;
458 return 0;
459 case TGSI_OPCODE_PK2US:
460 *copcode = C_OPCODE_PK2US;
461 return 0;
462 case TGSI_OPCODE_PK4B:
463 *copcode = C_OPCODE_PK4B;
464 return 0;
465 case TGSI_OPCODE_PK4UB:
466 *copcode = C_OPCODE_PK4UB;
467 return 0;
468 case TGSI_OPCODE_RFL:
469 *copcode = C_OPCODE_RFL;
470 return 0;
471 case TGSI_OPCODE_SEQ:
472 *copcode = C_OPCODE_SEQ;
473 return 0;
474 case TGSI_OPCODE_SFL:
475 *copcode = C_OPCODE_SFL;
476 return 0;
477 case TGSI_OPCODE_SGT:
478 *copcode = C_OPCODE_SGT;
479 return 0;
480 case TGSI_OPCODE_SIN:
481 *copcode = C_OPCODE_SIN;
482 return 0;
483 case TGSI_OPCODE_SLE:
484 *copcode = C_OPCODE_SLE;
485 return 0;
486 case TGSI_OPCODE_SNE:
487 *copcode = C_OPCODE_SNE;
488 return 0;
489 case TGSI_OPCODE_STR:
490 *copcode = C_OPCODE_STR;
491 return 0;
492 case TGSI_OPCODE_TEX:
493 *copcode = C_OPCODE_TEX;
494 return 0;
495 case TGSI_OPCODE_TXD:
496 *copcode = C_OPCODE_TXD;
497 return 0;
498 case TGSI_OPCODE_TXP:
499 *copcode = C_OPCODE_TXP;
500 return 0;
501 case TGSI_OPCODE_UP2H:
502 *copcode = C_OPCODE_UP2H;
503 return 0;
504 case TGSI_OPCODE_UP2US:
505 *copcode = C_OPCODE_UP2US;
506 return 0;
507 case TGSI_OPCODE_UP4B:
508 *copcode = C_OPCODE_UP4B;
509 return 0;
510 case TGSI_OPCODE_UP4UB:
511 *copcode = C_OPCODE_UP4UB;
512 return 0;
513 case TGSI_OPCODE_X2D:
514 *copcode = C_OPCODE_X2D;
515 return 0;
516 case TGSI_OPCODE_ARA:
517 *copcode = C_OPCODE_ARA;
518 return 0;
519 case TGSI_OPCODE_ARR:
520 *copcode = C_OPCODE_ARR;
521 return 0;
522 case TGSI_OPCODE_BRA:
523 *copcode = C_OPCODE_BRA;
524 return 0;
525 case TGSI_OPCODE_CAL:
526 *copcode = C_OPCODE_CAL;
527 return 0;
528 case TGSI_OPCODE_RET:
529 *copcode = C_OPCODE_RET;
530 return 0;
531 case TGSI_OPCODE_SSG:
532 *copcode = C_OPCODE_SSG;
533 return 0;
534 case TGSI_OPCODE_CMP:
535 *copcode = C_OPCODE_CMP;
536 return 0;
537 case TGSI_OPCODE_SCS:
538 *copcode = C_OPCODE_SCS;
539 return 0;
540 case TGSI_OPCODE_TXB:
541 *copcode = C_OPCODE_TXB;
542 return 0;
543 case TGSI_OPCODE_NRM:
544 *copcode = C_OPCODE_NRM;
545 return 0;
546 case TGSI_OPCODE_DIV:
547 *copcode = C_OPCODE_DIV;
548 return 0;
549 case TGSI_OPCODE_DP2:
550 *copcode = C_OPCODE_DP2;
551 return 0;
552 case TGSI_OPCODE_TXL:
553 *copcode = C_OPCODE_TXL;
554 return 0;
555 case TGSI_OPCODE_BRK:
556 *copcode = C_OPCODE_BRK;
557 return 0;
558 case TGSI_OPCODE_IF:
559 *copcode = C_OPCODE_IF;
560 return 0;
561 case TGSI_OPCODE_ELSE:
562 *copcode = C_OPCODE_ELSE;
563 return 0;
564 case TGSI_OPCODE_ENDIF:
565 *copcode = C_OPCODE_ENDIF;
566 return 0;
567 case TGSI_OPCODE_PUSHA:
568 *copcode = C_OPCODE_PUSHA;
569 return 0;
570 case TGSI_OPCODE_POPA:
571 *copcode = C_OPCODE_POPA;
572 return 0;
573 case TGSI_OPCODE_CEIL:
574 *copcode = C_OPCODE_CEIL;
575 return 0;
576 case TGSI_OPCODE_I2F:
577 *copcode = C_OPCODE_I2F;
578 return 0;
579 case TGSI_OPCODE_NOT:
580 *copcode = C_OPCODE_NOT;
581 return 0;
582 case TGSI_OPCODE_TRUNC:
583 *copcode = C_OPCODE_TRUNC;
584 return 0;
585 case TGSI_OPCODE_SHL:
586 *copcode = C_OPCODE_SHL;
587 return 0;
588 case TGSI_OPCODE_AND:
589 *copcode = C_OPCODE_AND;
590 return 0;
591 case TGSI_OPCODE_OR:
592 *copcode = C_OPCODE_OR;
593 return 0;
594 case TGSI_OPCODE_MOD:
595 *copcode = C_OPCODE_MOD;
596 return 0;
597 case TGSI_OPCODE_XOR:
598 *copcode = C_OPCODE_XOR;
599 return 0;
600 case TGSI_OPCODE_SAD:
601 *copcode = C_OPCODE_SAD;
602 return 0;
603 case TGSI_OPCODE_TXF:
604 *copcode = C_OPCODE_TXF;
605 return 0;
606 case TGSI_OPCODE_TXQ:
607 *copcode = C_OPCODE_TXQ;
608 return 0;
609 case TGSI_OPCODE_CONT:
610 *copcode = C_OPCODE_CONT;
611 return 0;
612 case TGSI_OPCODE_EMIT:
613 *copcode = C_OPCODE_EMIT;
614 return 0;
615 case TGSI_OPCODE_ENDPRIM:
616 *copcode = C_OPCODE_ENDPRIM;
617 return 0;
618 case TGSI_OPCODE_BGNLOOP:
619 *copcode = C_OPCODE_BGNLOOP;
620 return 0;
621 case TGSI_OPCODE_BGNSUB:
622 *copcode = C_OPCODE_BGNSUB;
623 return 0;
624 case TGSI_OPCODE_ENDLOOP:
625 *copcode = C_OPCODE_ENDLOOP;
626 return 0;
627 case TGSI_OPCODE_ENDSUB:
628 *copcode = C_OPCODE_ENDSUB;
629 return 0;
630 case TGSI_OPCODE_NOP:
631 *copcode = C_OPCODE_NOP;
632 return 0;
633 case TGSI_OPCODE_NRM4:
634 *copcode = C_OPCODE_NRM4;
635 return 0;
636 case TGSI_OPCODE_CALLNZ:
637 *copcode = C_OPCODE_CALLNZ;
638 return 0;
639 case TGSI_OPCODE_IFC:
640 *copcode = C_OPCODE_IFC;
641 return 0;
642 case TGSI_OPCODE_BREAKC:
643 *copcode = C_OPCODE_BREAKC;
644 return 0;
645 case TGSI_OPCODE_KIL:
646 *copcode = C_OPCODE_KIL;
647 return 0;
648 case TGSI_OPCODE_F2I:
649 *copcode = C_OPCODE_F2I;
650 return 0;
651 case TGSI_OPCODE_IDIV:
652 *copcode = C_OPCODE_IDIV;
653 return 0;
654 case TGSI_OPCODE_IMAX:
655 *copcode = C_OPCODE_IMAX;
656 return 0;
657 case TGSI_OPCODE_IMIN:
658 *copcode = C_OPCODE_IMIN;
659 return 0;
660 case TGSI_OPCODE_INEG:
661 *copcode = C_OPCODE_INEG;
662 return 0;
663 case TGSI_OPCODE_ISGE:
664 *copcode = C_OPCODE_ISGE;
665 return 0;
666 case TGSI_OPCODE_ISHR:
667 *copcode = C_OPCODE_ISHR;
668 return 0;
669 case TGSI_OPCODE_ISLT:
670 *copcode = C_OPCODE_ISLT;
671 return 0;
672 case TGSI_OPCODE_F2U:
673 *copcode = C_OPCODE_F2U;
674 return 0;
675 case TGSI_OPCODE_U2F:
676 *copcode = C_OPCODE_U2F;
677 return 0;
678 case TGSI_OPCODE_UADD:
679 *copcode = C_OPCODE_UADD;
680 return 0;
681 case TGSI_OPCODE_UDIV:
682 *copcode = C_OPCODE_UDIV;
683 return 0;
684 case TGSI_OPCODE_UMAD:
685 *copcode = C_OPCODE_UMAD;
686 return 0;
687 case TGSI_OPCODE_UMAX:
688 *copcode = C_OPCODE_UMAX;
689 return 0;
690 case TGSI_OPCODE_UMIN:
691 *copcode = C_OPCODE_UMIN;
692 return 0;
693 case TGSI_OPCODE_UMOD:
694 *copcode = C_OPCODE_UMOD;
695 return 0;
696 case TGSI_OPCODE_UMUL:
697 *copcode = C_OPCODE_UMUL;
698 return 0;
699 case TGSI_OPCODE_USEQ:
700 *copcode = C_OPCODE_USEQ;
701 return 0;
702 case TGSI_OPCODE_USGE:
703 *copcode = C_OPCODE_USGE;
704 return 0;
705 case TGSI_OPCODE_USHR:
706 *copcode = C_OPCODE_USHR;
707 return 0;
708 case TGSI_OPCODE_USLT:
709 *copcode = C_OPCODE_USLT;
710 return 0;
711 case TGSI_OPCODE_USNE:
712 *copcode = C_OPCODE_USNE;
713 return 0;
714 case TGSI_OPCODE_SWITCH:
715 *copcode = C_OPCODE_SWITCH;
716 return 0;
717 case TGSI_OPCODE_CASE:
718 *copcode = C_OPCODE_CASE;
719 return 0;
720 case TGSI_OPCODE_DEFAULT:
721 *copcode = C_OPCODE_DEFAULT;
722 return 0;
723 case TGSI_OPCODE_ENDSWITCH:
724 *copcode = C_OPCODE_ENDSWITCH;
725 return 0;
726 default:
727 fprintf(stderr, "%s:%d unsupported opcode %d\n", __func__, __LINE__, opcode);
728 return -EINVAL;
729 }
730 }