2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
23 #include "pipe/p_shader_tokens.h"
24 #include "tgsi/tgsi_info.h"
25 #include "tgsi/tgsi_parse.h"
26 #include "tgsi/tgsi_scan.h"
27 #include "tgsi/tgsi_dump.h"
28 #include "util/u_format.h"
29 #include "r600_pipe.h"
32 #include "r600_formats.h"
33 #include "r600_opcodes.h"
40 Why CAYMAN got loops for lots of instructions is explained here.
42 -These 8xx t-slot only ops are implemented in all vector slots.
43 MUL_LIT, FLT_TO_UINT, INT_TO_FLT, UINT_TO_FLT
44 These 8xx t-slot only opcodes become vector ops, with all four
45 slots expecting the arguments on sources a and b. Result is
46 broadcast to all channels.
47 MULLO_INT, MULHI_INT, MULLO_UINT, MULHI_UINT
48 These 8xx t-slot only opcodes become vector ops in the z, y, and
50 EXP_IEEE, LOG_IEEE/CLAMPED, RECIP_IEEE/CLAMPED/FF/INT/UINT/_64/CLAMPED_64
51 RECIPSQRT_IEEE/CLAMPED/FF/_64/CLAMPED_64
54 The w slot may have an independent co-issued operation, or if the
55 result is required to be in the w slot, the opcode above may be
56 issued in the w slot as well.
57 The compiler must issue the source argument to slots z, y, and x
61 int r600_find_vs_semantic_index(struct r600_shader
*vs
,
62 struct r600_shader
*ps
, int id
)
64 struct r600_shader_io
*input
= &ps
->input
[id
];
66 for (int i
= 0; i
< vs
->noutput
; i
++) {
67 if (input
->name
== vs
->output
[i
].name
&&
68 input
->sid
== vs
->output
[i
].sid
) {
75 static int r600_pipe_shader(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
77 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
78 struct r600_shader
*rshader
= &shader
->shader
;
83 if (shader
->bo
== NULL
) {
84 /* use PIPE_BIND_VERTEX_BUFFER so we use the cache buffer manager */
85 shader
->bo
= r600_bo(rctx
->radeon
, rshader
->bc
.ndw
* 4, 4096, PIPE_BIND_VERTEX_BUFFER
, PIPE_USAGE_IMMUTABLE
);
86 if (shader
->bo
== NULL
) {
89 ptr
= (uint32_t*)r600_bo_map(rctx
->radeon
, shader
->bo
, 0, NULL
);
90 if (R600_BIG_ENDIAN
) {
91 for (i
= 0; i
< rshader
->bc
.ndw
; ++i
) {
92 ptr
[i
] = bswap_32(rshader
->bc
.bytecode
[i
]);
95 memcpy(ptr
, rshader
->bc
.bytecode
, rshader
->bc
.ndw
* sizeof(*ptr
));
97 r600_bo_unmap(rctx
->radeon
, shader
->bo
);
100 switch (rshader
->processor_type
) {
101 case TGSI_PROCESSOR_VERTEX
:
102 if (rctx
->chip_class
>= EVERGREEN
) {
103 evergreen_pipe_shader_vs(ctx
, shader
);
105 r600_pipe_shader_vs(ctx
, shader
);
108 case TGSI_PROCESSOR_FRAGMENT
:
109 if (rctx
->chip_class
>= EVERGREEN
) {
110 evergreen_pipe_shader_ps(ctx
, shader
);
112 r600_pipe_shader_ps(ctx
, shader
);
121 static int r600_shader_from_tgsi(struct r600_pipe_context
* rctx
, struct r600_pipe_shader
*pipeshader
);
123 int r600_pipe_shader_create(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
125 static int dump_shaders
= -1;
126 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
129 /* Would like some magic "get_bool_option_once" routine.
131 if (dump_shaders
== -1)
132 dump_shaders
= debug_get_bool_option("R600_DUMP_SHADERS", FALSE
);
135 fprintf(stderr
, "--------------------------------------------------------------\n");
136 tgsi_dump(shader
->tokens
, 0);
138 r
= r600_shader_from_tgsi(rctx
, shader
);
140 R600_ERR("translation from TGSI failed !\n");
143 r
= r600_bc_build(&shader
->shader
.bc
);
145 R600_ERR("building bytecode failed !\n");
149 r600_bc_dump(&shader
->shader
.bc
);
150 fprintf(stderr
, "______________________________________________________________\n");
152 return r600_pipe_shader(ctx
, shader
);
155 void r600_pipe_shader_destroy(struct pipe_context
*ctx
, struct r600_pipe_shader
*shader
)
157 struct r600_pipe_context
*rctx
= (struct r600_pipe_context
*)ctx
;
159 r600_bo_reference(rctx
->radeon
, &shader
->bo
, NULL
);
160 r600_bc_clear(&shader
->shader
.bc
);
162 memset(&shader
->shader
,0,sizeof(struct r600_shader
));
166 * tgsi -> r600 shader
168 struct r600_shader_tgsi_instruction
;
170 struct r600_shader_src
{
179 struct r600_shader_ctx
{
180 struct tgsi_shader_info info
;
181 struct tgsi_parse_context parse
;
182 const struct tgsi_token
*tokens
;
184 unsigned file_offset
[TGSI_FILE_COUNT
];
187 struct r600_shader_tgsi_instruction
*inst_info
;
189 struct r600_shader
*shader
;
190 struct r600_shader_src src
[4];
193 u32 max_driver_temp_used
;
194 /* needed for evergreen interpolation */
195 boolean input_centroid
;
196 boolean input_linear
;
197 boolean input_perspective
;
201 struct r600_shader_tgsi_instruction
{
202 unsigned tgsi_opcode
;
204 unsigned r600_opcode
;
205 int (*process
)(struct r600_shader_ctx
*ctx
);
208 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[], eg_shader_tgsi_instruction
[], cm_shader_tgsi_instruction
[];
209 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
);
211 static int tgsi_is_supported(struct r600_shader_ctx
*ctx
)
213 struct tgsi_full_instruction
*i
= &ctx
->parse
.FullToken
.FullInstruction
;
216 if (i
->Instruction
.NumDstRegs
> 1) {
217 R600_ERR("too many dst (%d)\n", i
->Instruction
.NumDstRegs
);
220 if (i
->Instruction
.Predicate
) {
221 R600_ERR("predicate unsupported\n");
225 if (i
->Instruction
.Label
) {
226 R600_ERR("label unsupported\n");
230 for (j
= 0; j
< i
->Instruction
.NumSrcRegs
; j
++) {
231 if (i
->Src
[j
].Register
.Dimension
) {
232 R600_ERR("unsupported src %d (dimension %d)\n", j
,
233 i
->Src
[j
].Register
.Dimension
);
237 for (j
= 0; j
< i
->Instruction
.NumDstRegs
; j
++) {
238 if (i
->Dst
[j
].Register
.Dimension
) {
239 R600_ERR("unsupported dst (dimension)\n");
246 static int evergreen_interp_alu(struct r600_shader_ctx
*ctx
, int input
)
249 struct r600_bc_alu alu
;
250 int gpr
= 0, base_chan
= 0;
253 if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_PERSPECTIVE
) {
255 if (ctx
->shader
->input
[input
].centroid
)
257 } else if (ctx
->shader
->input
[input
].interpolate
== TGSI_INTERPOLATE_LINEAR
) {
259 /* if we have perspective add one */
260 if (ctx
->input_perspective
) {
262 /* if we have perspective centroid */
263 if (ctx
->input_centroid
)
266 if (ctx
->shader
->input
[input
].centroid
)
270 /* work out gpr and base_chan from index */
272 base_chan
= (2 * (ij_index
% 2)) + 1;
274 for (i
= 0; i
< 8; i
++) {
275 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
278 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_ZW
;
280 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INTERP_XY
;
282 if ((i
> 1) && (i
< 6)) {
283 alu
.dst
.sel
= ctx
->shader
->input
[input
].gpr
;
287 alu
.dst
.chan
= i
% 4;
289 alu
.src
[0].sel
= gpr
;
290 alu
.src
[0].chan
= (base_chan
- (i
% 2));
292 alu
.src
[1].sel
= V_SQ_ALU_SRC_PARAM_BASE
+ ctx
->shader
->input
[input
].lds_pos
;
294 alu
.bank_swizzle_force
= SQ_ALU_VEC_210
;
297 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
305 static int tgsi_declaration(struct r600_shader_ctx
*ctx
)
307 struct tgsi_full_declaration
*d
= &ctx
->parse
.FullToken
.FullDeclaration
;
311 switch (d
->Declaration
.File
) {
312 case TGSI_FILE_INPUT
:
313 i
= ctx
->shader
->ninput
++;
314 ctx
->shader
->input
[i
].name
= d
->Semantic
.Name
;
315 ctx
->shader
->input
[i
].sid
= d
->Semantic
.Index
;
316 ctx
->shader
->input
[i
].interpolate
= d
->Declaration
.Interpolate
;
317 ctx
->shader
->input
[i
].centroid
= d
->Declaration
.Centroid
;
318 ctx
->shader
->input
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_INPUT
] + i
;
319 if (ctx
->type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
->bc
->chip_class
>= EVERGREEN
) {
320 /* turn input into interpolate on EG */
321 if (ctx
->shader
->input
[i
].name
!= TGSI_SEMANTIC_POSITION
) {
322 if (ctx
->shader
->input
[i
].interpolate
> 0) {
323 ctx
->shader
->input
[i
].lds_pos
= ctx
->shader
->nlds
++;
324 evergreen_interp_alu(ctx
, i
);
329 case TGSI_FILE_OUTPUT
:
330 i
= ctx
->shader
->noutput
++;
331 ctx
->shader
->output
[i
].name
= d
->Semantic
.Name
;
332 ctx
->shader
->output
[i
].sid
= d
->Semantic
.Index
;
333 ctx
->shader
->output
[i
].gpr
= ctx
->file_offset
[TGSI_FILE_OUTPUT
] + i
;
334 ctx
->shader
->output
[i
].interpolate
= d
->Declaration
.Interpolate
;
336 case TGSI_FILE_CONSTANT
:
337 case TGSI_FILE_TEMPORARY
:
338 case TGSI_FILE_SAMPLER
:
339 case TGSI_FILE_ADDRESS
:
342 case TGSI_FILE_SYSTEM_VALUE
:
343 if (d
->Semantic
.Name
== TGSI_SEMANTIC_INSTANCEID
) {
344 struct r600_bc_alu alu
;
345 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
347 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_INT_TO_FLT
);
356 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
362 R600_ERR("unsupported file %d declaration\n", d
->Declaration
.File
);
368 static int r600_get_temp(struct r600_shader_ctx
*ctx
)
370 return ctx
->temp_reg
+ ctx
->max_driver_temp_used
++;
374 * for evergreen we need to scan the shader to find the number of GPRs we need to
375 * reserve for interpolation.
377 * we need to know if we are going to emit
378 * any centroid inputs
379 * if perspective and linear are required
381 static int evergreen_gpr_count(struct r600_shader_ctx
*ctx
)
386 ctx
->input_linear
= FALSE
;
387 ctx
->input_perspective
= FALSE
;
388 ctx
->input_centroid
= FALSE
;
389 ctx
->num_interp_gpr
= 1;
391 /* any centroid inputs */
392 for (i
= 0; i
< ctx
->info
.num_inputs
; i
++) {
393 /* skip position/face */
394 if (ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_POSITION
||
395 ctx
->info
.input_semantic_name
[i
] == TGSI_SEMANTIC_FACE
)
397 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_LINEAR
)
398 ctx
->input_linear
= TRUE
;
399 if (ctx
->info
.input_interpolate
[i
] == TGSI_INTERPOLATE_PERSPECTIVE
)
400 ctx
->input_perspective
= TRUE
;
401 if (ctx
->info
.input_centroid
[i
])
402 ctx
->input_centroid
= TRUE
;
406 /* ignoring sample for now */
407 if (ctx
->input_perspective
)
409 if (ctx
->input_linear
)
411 if (ctx
->input_centroid
)
414 ctx
->num_interp_gpr
+= (num_baryc
+ 1) >> 1;
416 /* TODO PULL MODEL and LINE STIPPLE, FIXED PT POS */
417 return ctx
->num_interp_gpr
;
420 static void tgsi_src(struct r600_shader_ctx
*ctx
,
421 const struct tgsi_full_src_register
*tgsi_src
,
422 struct r600_shader_src
*r600_src
)
424 memset(r600_src
, 0, sizeof(*r600_src
));
425 r600_src
->swizzle
[0] = tgsi_src
->Register
.SwizzleX
;
426 r600_src
->swizzle
[1] = tgsi_src
->Register
.SwizzleY
;
427 r600_src
->swizzle
[2] = tgsi_src
->Register
.SwizzleZ
;
428 r600_src
->swizzle
[3] = tgsi_src
->Register
.SwizzleW
;
429 r600_src
->neg
= tgsi_src
->Register
.Negate
;
430 r600_src
->abs
= tgsi_src
->Register
.Absolute
;
432 if (tgsi_src
->Register
.File
== TGSI_FILE_IMMEDIATE
) {
434 if ((tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleY
) &&
435 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleZ
) &&
436 (tgsi_src
->Register
.SwizzleX
== tgsi_src
->Register
.SwizzleW
)) {
438 index
= tgsi_src
->Register
.Index
* 4 + tgsi_src
->Register
.SwizzleX
;
439 r600_bc_special_constants(ctx
->literals
[index
], &r600_src
->sel
, &r600_src
->neg
);
440 if (r600_src
->sel
!= V_SQ_ALU_SRC_LITERAL
)
443 index
= tgsi_src
->Register
.Index
;
444 r600_src
->sel
= V_SQ_ALU_SRC_LITERAL
;
445 memcpy(r600_src
->value
, ctx
->literals
+ index
* 4, sizeof(r600_src
->value
));
446 } else if (tgsi_src
->Register
.File
== TGSI_FILE_SYSTEM_VALUE
) {
447 /* assume we wan't TGSI_SEMANTIC_INSTANCEID here */
448 r600_src
->swizzle
[0] = 3;
449 r600_src
->swizzle
[1] = 3;
450 r600_src
->swizzle
[2] = 3;
451 r600_src
->swizzle
[3] = 3;
454 if (tgsi_src
->Register
.Indirect
)
455 r600_src
->rel
= V_SQ_REL_RELATIVE
;
456 r600_src
->sel
= tgsi_src
->Register
.Index
;
457 r600_src
->sel
+= ctx
->file_offset
[tgsi_src
->Register
.File
];
461 static int tgsi_fetch_rel_const(struct r600_shader_ctx
*ctx
, unsigned int offset
, unsigned int dst_reg
)
463 struct r600_bc_vtx vtx
;
468 struct r600_bc_alu alu
;
470 memset(&alu
, 0, sizeof(alu
));
472 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD_INT
);
473 alu
.src
[0].sel
= ctx
->ar_reg
;
475 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
476 alu
.src
[1].value
= offset
;
478 alu
.dst
.sel
= dst_reg
;
482 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
487 ar_reg
= ctx
->ar_reg
;
490 memset(&vtx
, 0, sizeof(vtx
));
491 vtx
.fetch_type
= 2; /* VTX_FETCH_NO_INDEX_OFFSET */
492 vtx
.src_gpr
= ar_reg
;
493 vtx
.mega_fetch_count
= 16;
494 vtx
.dst_gpr
= dst_reg
;
495 vtx
.dst_sel_x
= 0; /* SEL_X */
496 vtx
.dst_sel_y
= 1; /* SEL_Y */
497 vtx
.dst_sel_z
= 2; /* SEL_Z */
498 vtx
.dst_sel_w
= 3; /* SEL_W */
499 vtx
.data_format
= FMT_32_32_32_32_FLOAT
;
500 vtx
.num_format_all
= 2; /* NUM_FORMAT_SCALED */
501 vtx
.format_comp_all
= 1; /* FORMAT_COMP_SIGNED */
502 vtx
.srf_mode_all
= 1; /* SRF_MODE_NO_ZERO */
503 vtx
.endian
= r600_endian_swap(32);
505 if ((r
= r600_bc_add_vtx(ctx
->bc
, &vtx
)))
511 static int tgsi_split_constant(struct r600_shader_ctx
*ctx
)
513 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
514 struct r600_bc_alu alu
;
515 int i
, j
, k
, nconst
, r
;
517 for (i
= 0, nconst
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
518 if (inst
->Src
[i
].Register
.File
== TGSI_FILE_CONSTANT
) {
521 tgsi_src(ctx
, &inst
->Src
[i
], &ctx
->src
[i
]);
523 for (i
= 0, j
= nconst
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
524 if (inst
->Src
[i
].Register
.File
!= TGSI_FILE_CONSTANT
) {
528 if (ctx
->src
[i
].rel
) {
529 int treg
= r600_get_temp(ctx
);
530 if ((r
= tgsi_fetch_rel_const(ctx
, ctx
->src
[i
].sel
- 512, treg
)))
533 ctx
->src
[i
].sel
= treg
;
537 int treg
= r600_get_temp(ctx
);
538 for (k
= 0; k
< 4; k
++) {
539 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
540 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
541 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
543 alu
.src
[0].rel
= ctx
->src
[i
].rel
;
549 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
553 ctx
->src
[i
].sel
= treg
;
561 /* need to move any immediate into a temp - for trig functions which use literal for PI stuff */
562 static int tgsi_split_literal_constant(struct r600_shader_ctx
*ctx
)
564 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
565 struct r600_bc_alu alu
;
566 int i
, j
, k
, nliteral
, r
;
568 for (i
= 0, nliteral
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
569 if (ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
573 for (i
= 0, j
= nliteral
- 1; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
574 if (j
> 0 && ctx
->src
[i
].sel
== V_SQ_ALU_SRC_LITERAL
) {
575 int treg
= r600_get_temp(ctx
);
576 for (k
= 0; k
< 4; k
++) {
577 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
578 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
579 alu
.src
[0].sel
= ctx
->src
[i
].sel
;
581 alu
.src
[0].value
= ctx
->src
[i
].value
[k
];
587 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
591 ctx
->src
[i
].sel
= treg
;
598 static int r600_shader_from_tgsi(struct r600_pipe_context
* rctx
, struct r600_pipe_shader
*pipeshader
)
600 struct r600_shader
*shader
= &pipeshader
->shader
;
601 struct tgsi_token
*tokens
= pipeshader
->tokens
;
602 struct tgsi_full_immediate
*immediate
;
603 struct tgsi_full_property
*property
;
604 struct r600_shader_ctx ctx
;
605 struct r600_bc_output output
[32];
606 unsigned output_done
, noutput
;
608 int i
, j
, r
= 0, pos0
;
610 ctx
.bc
= &shader
->bc
;
612 r600_bc_init(ctx
.bc
, rctx
->chip_class
);
614 tgsi_scan_shader(tokens
, &ctx
.info
);
615 tgsi_parse_init(&ctx
.parse
, tokens
);
616 ctx
.type
= ctx
.parse
.FullHeader
.Processor
.Processor
;
617 shader
->processor_type
= ctx
.type
;
618 ctx
.bc
->type
= shader
->processor_type
;
620 shader
->clamp_color
= (((ctx
.type
== TGSI_PROCESSOR_FRAGMENT
) && rctx
->clamp_fragment_color
) ||
621 ((ctx
.type
== TGSI_PROCESSOR_VERTEX
) && rctx
->clamp_vertex_color
));
623 shader
->nr_cbufs
= rctx
->nr_cbufs
;
625 /* register allocations */
626 /* Values [0,127] correspond to GPR[0..127].
627 * Values [128,159] correspond to constant buffer bank 0
628 * Values [160,191] correspond to constant buffer bank 1
629 * Values [256,511] correspond to cfile constants c[0..255]. (Gone on EG)
630 * Values [256,287] correspond to constant buffer bank 2 (EG)
631 * Values [288,319] correspond to constant buffer bank 3 (EG)
632 * Other special values are shown in the list below.
633 * 244 ALU_SRC_1_DBL_L: special constant 1.0 double-float, LSW. (RV670+)
634 * 245 ALU_SRC_1_DBL_M: special constant 1.0 double-float, MSW. (RV670+)
635 * 246 ALU_SRC_0_5_DBL_L: special constant 0.5 double-float, LSW. (RV670+)
636 * 247 ALU_SRC_0_5_DBL_M: special constant 0.5 double-float, MSW. (RV670+)
637 * 248 SQ_ALU_SRC_0: special constant 0.0.
638 * 249 SQ_ALU_SRC_1: special constant 1.0 float.
639 * 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
640 * 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
641 * 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
642 * 253 SQ_ALU_SRC_LITERAL: literal constant.
643 * 254 SQ_ALU_SRC_PV: previous vector result.
644 * 255 SQ_ALU_SRC_PS: previous scalar result.
646 for (i
= 0; i
< TGSI_FILE_COUNT
; i
++) {
647 ctx
.file_offset
[i
] = 0;
649 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
650 ctx
.file_offset
[TGSI_FILE_INPUT
] = 1;
651 if (ctx
.bc
->chip_class
>= EVERGREEN
) {
652 r600_bc_add_cfinst(ctx
.bc
, EG_V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
654 r600_bc_add_cfinst(ctx
.bc
, V_SQ_CF_WORD1_SQ_CF_INST_CALL_FS
);
657 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& ctx
.bc
->chip_class
>= EVERGREEN
) {
658 ctx
.file_offset
[TGSI_FILE_INPUT
] = evergreen_gpr_count(&ctx
);
660 ctx
.file_offset
[TGSI_FILE_OUTPUT
] = ctx
.file_offset
[TGSI_FILE_INPUT
] +
661 ctx
.info
.file_count
[TGSI_FILE_INPUT
];
662 ctx
.file_offset
[TGSI_FILE_TEMPORARY
] = ctx
.file_offset
[TGSI_FILE_OUTPUT
] +
663 ctx
.info
.file_count
[TGSI_FILE_OUTPUT
];
665 /* Outside the GPR range. This will be translated to one of the
666 * kcache banks later. */
667 ctx
.file_offset
[TGSI_FILE_CONSTANT
] = 512;
669 ctx
.file_offset
[TGSI_FILE_IMMEDIATE
] = V_SQ_ALU_SRC_LITERAL
;
670 ctx
.ar_reg
= ctx
.file_offset
[TGSI_FILE_TEMPORARY
] +
671 ctx
.info
.file_count
[TGSI_FILE_TEMPORARY
];
672 ctx
.temp_reg
= ctx
.ar_reg
+ 1;
676 shader
->fs_write_all
= FALSE
;
677 while (!tgsi_parse_end_of_tokens(&ctx
.parse
)) {
678 tgsi_parse_token(&ctx
.parse
);
679 switch (ctx
.parse
.FullToken
.Token
.Type
) {
680 case TGSI_TOKEN_TYPE_IMMEDIATE
:
681 immediate
= &ctx
.parse
.FullToken
.FullImmediate
;
682 ctx
.literals
= realloc(ctx
.literals
, (ctx
.nliterals
+ 1) * 16);
683 if(ctx
.literals
== NULL
) {
687 ctx
.literals
[ctx
.nliterals
* 4 + 0] = immediate
->u
[0].Uint
;
688 ctx
.literals
[ctx
.nliterals
* 4 + 1] = immediate
->u
[1].Uint
;
689 ctx
.literals
[ctx
.nliterals
* 4 + 2] = immediate
->u
[2].Uint
;
690 ctx
.literals
[ctx
.nliterals
* 4 + 3] = immediate
->u
[3].Uint
;
693 case TGSI_TOKEN_TYPE_DECLARATION
:
694 r
= tgsi_declaration(&ctx
);
698 case TGSI_TOKEN_TYPE_INSTRUCTION
:
699 r
= tgsi_is_supported(&ctx
);
702 ctx
.max_driver_temp_used
= 0;
703 /* reserve first tmp for everyone */
706 opcode
= ctx
.parse
.FullToken
.FullInstruction
.Instruction
.Opcode
;
707 if ((r
= tgsi_split_constant(&ctx
)))
709 if ((r
= tgsi_split_literal_constant(&ctx
)))
711 if (ctx
.bc
->chip_class
== CAYMAN
)
712 ctx
.inst_info
= &cm_shader_tgsi_instruction
[opcode
];
713 else if (ctx
.bc
->chip_class
>= EVERGREEN
)
714 ctx
.inst_info
= &eg_shader_tgsi_instruction
[opcode
];
716 ctx
.inst_info
= &r600_shader_tgsi_instruction
[opcode
];
717 r
= ctx
.inst_info
->process(&ctx
);
721 case TGSI_TOKEN_TYPE_PROPERTY
:
722 property
= &ctx
.parse
.FullToken
.FullProperty
;
723 if (property
->Property
.PropertyName
== TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
) {
724 if (property
->u
[0].Data
== 1)
725 shader
->fs_write_all
= TRUE
;
729 R600_ERR("unsupported token type %d\n", ctx
.parse
.FullToken
.Token
.Type
);
735 noutput
= shader
->noutput
;
737 /* clamp color outputs */
738 if (shader
->clamp_color
) {
739 for (i
= 0; i
< noutput
; i
++) {
740 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
||
741 shader
->output
[i
].name
== TGSI_SEMANTIC_BCOLOR
) {
744 for (j
= 0; j
< 4; j
++) {
745 struct r600_bc_alu alu
;
746 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
749 alu
.inst
= BC_INST(ctx
.bc
, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
750 alu
.dst
.sel
= shader
->output
[i
].gpr
;
754 alu
.src
[0].sel
= alu
.dst
.sel
;
760 r
= r600_bc_add_alu(ctx
.bc
, &alu
);
770 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
771 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
772 output
[i
+ j
].gpr
= shader
->output
[i
].gpr
;
773 output
[i
+ j
].elem_size
= 3;
774 output
[i
+ j
].swizzle_x
= 0;
775 output
[i
+ j
].swizzle_y
= 1;
776 output
[i
+ j
].swizzle_z
= 2;
777 output
[i
+ j
].swizzle_w
= 3;
778 output
[i
+ j
].burst_count
= 1;
779 output
[i
+ j
].barrier
= 1;
780 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
781 output
[i
+ j
].array_base
= i
- pos0
;
782 output
[i
+ j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
784 case TGSI_PROCESSOR_VERTEX
:
785 if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
786 output
[i
+ j
].array_base
= 60;
787 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
788 /* position doesn't count in array_base */
791 if (shader
->output
[i
].name
== TGSI_SEMANTIC_PSIZE
) {
792 output
[i
+ j
].array_base
= 61;
793 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_POS
;
794 /* position doesn't count in array_base */
798 case TGSI_PROCESSOR_FRAGMENT
:
799 if (shader
->output
[i
].name
== TGSI_SEMANTIC_COLOR
) {
800 output
[i
+ j
].array_base
= shader
->output
[i
].sid
;
801 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
802 if (shader
->fs_write_all
&& (rctx
->chip_class
>= EVERGREEN
)) {
803 for (j
= 1; j
< shader
->nr_cbufs
; j
++) {
804 memset(&output
[i
+ j
], 0, sizeof(struct r600_bc_output
));
805 output
[i
+ j
].gpr
= shader
->output
[i
].gpr
;
806 output
[i
+ j
].elem_size
= 3;
807 output
[i
+ j
].swizzle_x
= 0;
808 output
[i
+ j
].swizzle_y
= 1;
809 output
[i
+ j
].swizzle_z
= 2;
810 output
[i
+ j
].swizzle_w
= 3;
811 output
[i
+ j
].burst_count
= 1;
812 output
[i
+ j
].barrier
= 1;
813 output
[i
+ j
].array_base
= shader
->output
[i
].sid
+ j
;
814 output
[i
+ j
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
815 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
819 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_POSITION
) {
820 output
[i
+ j
].array_base
= 61;
821 output
[i
+ j
].swizzle_x
= 2;
822 output
[i
+ j
].swizzle_y
= 7;
823 output
[i
+ j
].swizzle_z
= output
[i
+ j
].swizzle_w
= 7;
824 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
825 } else if (shader
->output
[i
].name
== TGSI_SEMANTIC_STENCIL
) {
826 output
[i
+ j
].array_base
= 61;
827 output
[i
+ j
].swizzle_x
= 7;
828 output
[i
+ j
].swizzle_y
= 1;
829 output
[i
+ j
].swizzle_z
= output
[i
+ j
].swizzle_w
= 7;
830 output
[i
+ j
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
832 R600_ERR("unsupported fragment output name %d\n", shader
->output
[i
].name
);
838 R600_ERR("unsupported processor type %d\n", ctx
.type
);
844 /* add fake param output for vertex shader if no param is exported */
845 if (ctx
.type
== TGSI_PROCESSOR_VERTEX
) {
846 for (i
= 0, pos0
= 0; i
< noutput
; i
++) {
847 if (output
[i
].type
== V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
) {
853 memset(&output
[i
], 0, sizeof(struct r600_bc_output
));
855 output
[i
].elem_size
= 3;
856 output
[i
].swizzle_x
= 0;
857 output
[i
].swizzle_y
= 1;
858 output
[i
].swizzle_z
= 2;
859 output
[i
].swizzle_w
= 3;
860 output
[i
].burst_count
= 1;
861 output
[i
].barrier
= 1;
862 output
[i
].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PARAM
;
863 output
[i
].array_base
= 0;
864 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
868 /* add fake pixel export */
869 if (ctx
.type
== TGSI_PROCESSOR_FRAGMENT
&& !noutput
) {
870 memset(&output
[0], 0, sizeof(struct r600_bc_output
));
872 output
[0].elem_size
= 3;
873 output
[0].swizzle_x
= 7;
874 output
[0].swizzle_y
= 7;
875 output
[0].swizzle_z
= 7;
876 output
[0].swizzle_w
= 7;
877 output
[0].burst_count
= 1;
878 output
[0].barrier
= 1;
879 output
[0].type
= V_SQ_CF_ALLOC_EXPORT_WORD0_SQ_EXPORT_PIXEL
;
880 output
[0].array_base
= 0;
881 output
[0].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT
);
884 /* set export done on last export of each type */
885 for (i
= noutput
- 1, output_done
= 0; i
>= 0; i
--) {
886 if (ctx
.bc
->chip_class
< CAYMAN
) {
887 if (i
== (noutput
- 1)) {
888 output
[i
].end_of_program
= 1;
891 if (!(output_done
& (1 << output
[i
].type
))) {
892 output_done
|= (1 << output
[i
].type
);
893 output
[i
].inst
= BC_INST(ctx
.bc
, V_SQ_CF_ALLOC_EXPORT_WORD1_SQ_CF_INST_EXPORT_DONE
);
896 /* add output to bytecode */
897 for (i
= 0; i
< noutput
; i
++) {
898 r
= r600_bc_add_output(ctx
.bc
, &output
[i
]);
902 /* add program end */
903 if (ctx
.bc
->chip_class
== CAYMAN
)
904 cm_bc_add_cf_end(ctx
.bc
);
907 tgsi_parse_free(&ctx
.parse
);
911 tgsi_parse_free(&ctx
.parse
);
915 static int tgsi_unsupported(struct r600_shader_ctx
*ctx
)
917 R600_ERR("%s tgsi opcode unsupported\n",
918 tgsi_get_opcode_name(ctx
->inst_info
->tgsi_opcode
));
922 static int tgsi_end(struct r600_shader_ctx
*ctx
)
927 static void r600_bc_src(struct r600_bc_alu_src
*bc_src
,
928 const struct r600_shader_src
*shader_src
,
931 bc_src
->sel
= shader_src
->sel
;
932 bc_src
->chan
= shader_src
->swizzle
[chan
];
933 bc_src
->neg
= shader_src
->neg
;
934 bc_src
->abs
= shader_src
->abs
;
935 bc_src
->rel
= shader_src
->rel
;
936 bc_src
->value
= shader_src
->value
[bc_src
->chan
];
939 static void r600_bc_src_set_abs(struct r600_bc_alu_src
*bc_src
)
945 static void r600_bc_src_toggle_neg(struct r600_bc_alu_src
*bc_src
)
947 bc_src
->neg
= !bc_src
->neg
;
950 static void tgsi_dst(struct r600_shader_ctx
*ctx
,
951 const struct tgsi_full_dst_register
*tgsi_dst
,
953 struct r600_bc_alu_dst
*r600_dst
)
955 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
957 r600_dst
->sel
= tgsi_dst
->Register
.Index
;
958 r600_dst
->sel
+= ctx
->file_offset
[tgsi_dst
->Register
.File
];
959 r600_dst
->chan
= swizzle
;
961 if (tgsi_dst
->Register
.Indirect
)
962 r600_dst
->rel
= V_SQ_REL_RELATIVE
;
963 if (inst
->Instruction
.Saturate
) {
968 static int tgsi_last_instruction(unsigned writemask
)
972 for (i
= 0; i
< 4; i
++) {
973 if (writemask
& (1 << i
)) {
980 static int tgsi_op2_s(struct r600_shader_ctx
*ctx
, int swap
)
982 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
983 struct r600_bc_alu alu
;
985 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
987 for (i
= 0; i
< lasti
+ 1; i
++) {
988 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
991 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
992 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
994 alu
.inst
= ctx
->inst_info
->r600_opcode
;
996 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
997 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1000 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
1001 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1003 /* handle some special cases */
1004 switch (ctx
->inst_info
->tgsi_opcode
) {
1005 case TGSI_OPCODE_SUB
:
1006 r600_bc_src_toggle_neg(&alu
.src
[1]);
1008 case TGSI_OPCODE_ABS
:
1009 r600_bc_src_set_abs(&alu
.src
[0]);
1017 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1024 static int tgsi_op2(struct r600_shader_ctx
*ctx
)
1026 return tgsi_op2_s(ctx
, 0);
1029 static int tgsi_op2_swap(struct r600_shader_ctx
*ctx
)
1031 return tgsi_op2_s(ctx
, 1);
1034 static int cayman_emit_float_instr(struct r600_shader_ctx
*ctx
)
1036 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1038 struct r600_bc_alu alu
;
1039 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1041 for (i
= 0 ; i
< last_slot
; i
++) {
1042 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1043 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1044 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1045 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], 0);
1047 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1048 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1050 if (i
== last_slot
- 1)
1052 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1060 * r600 - trunc to -PI..PI range
1061 * r700 - normalize by dividing by 2PI
1064 static int tgsi_setup_trig(struct r600_shader_ctx
*ctx
)
1066 static float half_inv_pi
= 1.0 /(3.1415926535 * 2);
1067 static float double_pi
= 3.1415926535 * 2;
1068 static float neg_pi
= -3.1415926535;
1071 struct r600_bc_alu alu
;
1073 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1074 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1078 alu
.dst
.sel
= ctx
->temp_reg
;
1081 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1083 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1084 alu
.src
[1].chan
= 0;
1085 alu
.src
[1].value
= *(uint32_t *)&half_inv_pi
;
1086 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1087 alu
.src
[2].chan
= 0;
1089 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1093 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1094 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
1097 alu
.dst
.sel
= ctx
->temp_reg
;
1100 alu
.src
[0].sel
= ctx
->temp_reg
;
1101 alu
.src
[0].chan
= 0;
1103 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1107 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1108 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
1112 alu
.dst
.sel
= ctx
->temp_reg
;
1115 alu
.src
[0].sel
= ctx
->temp_reg
;
1116 alu
.src
[0].chan
= 0;
1118 alu
.src
[1].sel
= V_SQ_ALU_SRC_LITERAL
;
1119 alu
.src
[1].chan
= 0;
1120 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
1121 alu
.src
[2].chan
= 0;
1123 if (ctx
->bc
->chip_class
== R600
) {
1124 alu
.src
[1].value
= *(uint32_t *)&double_pi
;
1125 alu
.src
[2].value
= *(uint32_t *)&neg_pi
;
1127 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1128 alu
.src
[2].sel
= V_SQ_ALU_SRC_0_5
;
1133 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1139 static int cayman_trig(struct r600_shader_ctx
*ctx
)
1141 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1142 struct r600_bc_alu alu
;
1143 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1146 r
= tgsi_setup_trig(ctx
);
1151 for (i
= 0; i
< last_slot
; i
++) {
1152 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1153 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1156 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1157 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1159 alu
.src
[0].sel
= ctx
->temp_reg
;
1160 alu
.src
[0].chan
= 0;
1161 if (i
== last_slot
- 1)
1163 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1170 static int tgsi_trig(struct r600_shader_ctx
*ctx
)
1172 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1173 struct r600_bc_alu alu
;
1175 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1177 r
= tgsi_setup_trig(ctx
);
1181 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1182 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1184 alu
.dst
.sel
= ctx
->temp_reg
;
1187 alu
.src
[0].sel
= ctx
->temp_reg
;
1188 alu
.src
[0].chan
= 0;
1190 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1194 /* replicate result */
1195 for (i
= 0; i
< lasti
+ 1; i
++) {
1196 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1199 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1200 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1202 alu
.src
[0].sel
= ctx
->temp_reg
;
1203 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1206 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1213 static int tgsi_scs(struct r600_shader_ctx
*ctx
)
1215 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1216 struct r600_bc_alu alu
;
1219 /* We'll only need the trig stuff if we are going to write to the
1220 * X or Y components of the destination vector.
1222 if (likely(inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_XY
)) {
1223 r
= tgsi_setup_trig(ctx
);
1229 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_X
) {
1230 if (ctx
->bc
->chip_class
== CAYMAN
) {
1231 for (i
= 0 ; i
< 3; i
++) {
1232 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1233 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1234 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1240 alu
.src
[0].sel
= ctx
->temp_reg
;
1241 alu
.src
[0].chan
= 0;
1244 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1249 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1250 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
);
1251 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1253 alu
.src
[0].sel
= ctx
->temp_reg
;
1254 alu
.src
[0].chan
= 0;
1256 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1263 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Y
) {
1264 if (ctx
->bc
->chip_class
== CAYMAN
) {
1265 for (i
= 0 ; i
< 3; i
++) {
1266 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1267 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1268 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1273 alu
.src
[0].sel
= ctx
->temp_reg
;
1274 alu
.src
[0].chan
= 0;
1277 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1282 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1283 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
);
1284 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1286 alu
.src
[0].sel
= ctx
->temp_reg
;
1287 alu
.src
[0].chan
= 0;
1289 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1296 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_Z
) {
1297 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1299 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1301 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1303 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1304 alu
.src
[0].chan
= 0;
1308 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1314 if (inst
->Dst
[0].Register
.WriteMask
& TGSI_WRITEMASK_W
) {
1315 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1317 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1319 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1321 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1322 alu
.src
[0].chan
= 0;
1326 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1334 static int tgsi_kill(struct r600_shader_ctx
*ctx
)
1336 struct r600_bc_alu alu
;
1339 for (i
= 0; i
< 4; i
++) {
1340 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1341 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1345 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
1347 if (ctx
->inst_info
->tgsi_opcode
== TGSI_OPCODE_KILP
) {
1348 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1351 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1356 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1361 /* kill must be last in ALU */
1362 ctx
->bc
->force_add_cf
= 1;
1363 ctx
->shader
->uses_kill
= TRUE
;
1367 static int tgsi_lit(struct r600_shader_ctx
*ctx
)
1369 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1370 struct r600_bc_alu alu
;
1373 /* tmp.x = max(src.y, 0.0) */
1374 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1375 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1376 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 1);
1377 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1378 alu
.src
[1].chan
= 1;
1380 alu
.dst
.sel
= ctx
->temp_reg
;
1385 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1389 if (inst
->Dst
[0].Register
.WriteMask
& (1 << 2))
1395 if (ctx
->bc
->chip_class
== CAYMAN
) {
1396 for (i
= 0; i
< 3; i
++) {
1397 /* tmp.z = log(tmp.x) */
1398 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1399 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1400 alu
.src
[0].sel
= ctx
->temp_reg
;
1401 alu
.src
[0].chan
= 0;
1402 alu
.dst
.sel
= ctx
->temp_reg
;
1410 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1415 /* tmp.z = log(tmp.x) */
1416 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1417 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_CLAMPED
);
1418 alu
.src
[0].sel
= ctx
->temp_reg
;
1419 alu
.src
[0].chan
= 0;
1420 alu
.dst
.sel
= ctx
->temp_reg
;
1424 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1429 chan
= alu
.dst
.chan
;
1432 /* tmp.x = amd MUL_LIT(tmp.z, src.w, src.x ) */
1433 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1434 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MUL_LIT
);
1435 alu
.src
[0].sel
= sel
;
1436 alu
.src
[0].chan
= chan
;
1437 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], 3);
1438 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], 0);
1439 alu
.dst
.sel
= ctx
->temp_reg
;
1444 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1448 if (ctx
->bc
->chip_class
== CAYMAN
) {
1449 for (i
= 0; i
< 3; i
++) {
1450 /* dst.z = exp(tmp.x) */
1451 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1452 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1453 alu
.src
[0].sel
= ctx
->temp_reg
;
1454 alu
.src
[0].chan
= 0;
1455 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1461 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1466 /* dst.z = exp(tmp.x) */
1467 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1468 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1469 alu
.src
[0].sel
= ctx
->temp_reg
;
1470 alu
.src
[0].chan
= 0;
1471 tgsi_dst(ctx
, &inst
->Dst
[0], 2, &alu
.dst
);
1473 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1480 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1481 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1482 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
; /*1.0*/
1483 alu
.src
[0].chan
= 0;
1484 tgsi_dst(ctx
, &inst
->Dst
[0], 0, &alu
.dst
);
1485 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 0) & 1;
1486 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1490 /* dst.y = max(src.x, 0.0) */
1491 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1492 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
);
1493 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1494 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
; /*0.0*/
1495 alu
.src
[1].chan
= 0;
1496 tgsi_dst(ctx
, &inst
->Dst
[0], 1, &alu
.dst
);
1497 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 1) & 1;
1498 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1503 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1504 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1505 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1506 alu
.src
[0].chan
= 0;
1507 tgsi_dst(ctx
, &inst
->Dst
[0], 3, &alu
.dst
);
1508 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> 3) & 1;
1510 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1517 static int tgsi_rsq(struct r600_shader_ctx
*ctx
)
1519 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1520 struct r600_bc_alu alu
;
1523 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1526 * For state trackers other than OpenGL, we'll want to use
1527 * _RECIPSQRT_IEEE instead.
1529 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_CLAMPED
);
1531 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1532 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1533 r600_bc_src_set_abs(&alu
.src
[i
]);
1535 alu
.dst
.sel
= ctx
->temp_reg
;
1538 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1541 /* replicate result */
1542 return tgsi_helper_tempx_replicate(ctx
);
1545 static int tgsi_helper_tempx_replicate(struct r600_shader_ctx
*ctx
)
1547 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1548 struct r600_bc_alu alu
;
1551 for (i
= 0; i
< 4; i
++) {
1552 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1553 alu
.src
[0].sel
= ctx
->temp_reg
;
1554 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1556 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1557 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1560 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1567 static int tgsi_trans_srcx_replicate(struct r600_shader_ctx
*ctx
)
1569 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1570 struct r600_bc_alu alu
;
1573 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1574 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1575 for (i
= 0; i
< inst
->Instruction
.NumSrcRegs
; i
++) {
1576 r600_bc_src(&alu
.src
[i
], &ctx
->src
[i
], 0);
1578 alu
.dst
.sel
= ctx
->temp_reg
;
1581 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1584 /* replicate result */
1585 return tgsi_helper_tempx_replicate(ctx
);
1588 static int cayman_pow(struct r600_shader_ctx
*ctx
)
1590 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1592 struct r600_bc_alu alu
;
1593 int last_slot
= (inst
->Dst
[0].Register
.WriteMask
& 0x8) ? 4 : 3;
1595 for (i
= 0; i
< 3; i
++) {
1596 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1597 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1598 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1599 alu
.dst
.sel
= ctx
->temp_reg
;
1604 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1610 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1611 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1612 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], 0);
1613 alu
.src
[1].sel
= ctx
->temp_reg
;
1614 alu
.dst
.sel
= ctx
->temp_reg
;
1617 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1621 for (i
= 0; i
< last_slot
; i
++) {
1622 /* POW(a,b) = EXP2(b * LOG2(a))*/
1623 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1624 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1625 alu
.src
[0].sel
= ctx
->temp_reg
;
1627 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1628 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1629 if (i
== last_slot
- 1)
1631 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1638 static int tgsi_pow(struct r600_shader_ctx
*ctx
)
1640 struct r600_bc_alu alu
;
1644 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1645 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
1646 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
1647 alu
.dst
.sel
= ctx
->temp_reg
;
1650 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1654 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1655 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1656 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], 0);
1657 alu
.src
[1].sel
= ctx
->temp_reg
;
1658 alu
.dst
.sel
= ctx
->temp_reg
;
1661 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1664 /* POW(a,b) = EXP2(b * LOG2(a))*/
1665 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1666 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
1667 alu
.src
[0].sel
= ctx
->temp_reg
;
1668 alu
.dst
.sel
= ctx
->temp_reg
;
1671 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1674 return tgsi_helper_tempx_replicate(ctx
);
1677 static int tgsi_ssg(struct r600_shader_ctx
*ctx
)
1679 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1680 struct r600_bc_alu alu
;
1683 /* tmp = (src > 0 ? 1 : src) */
1684 for (i
= 0; i
< 4; i
++) {
1685 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1686 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1689 alu
.dst
.sel
= ctx
->temp_reg
;
1692 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
1693 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1694 r600_bc_src(&alu
.src
[2], &ctx
->src
[0], i
);
1698 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1703 /* dst = (-tmp > 0 ? -1 : tmp) */
1704 for (i
= 0; i
< 4; i
++) {
1705 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1706 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGT
);
1708 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1710 alu
.src
[0].sel
= ctx
->temp_reg
;
1711 alu
.src
[0].chan
= i
;
1714 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
1717 alu
.src
[2].sel
= ctx
->temp_reg
;
1718 alu
.src
[2].chan
= i
;
1722 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1729 static int tgsi_helper_copy(struct r600_shader_ctx
*ctx
, struct tgsi_full_instruction
*inst
)
1731 struct r600_bc_alu alu
;
1734 for (i
= 0; i
< 4; i
++) {
1735 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1736 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
))) {
1737 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
);
1740 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1741 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1742 alu
.src
[0].sel
= ctx
->temp_reg
;
1743 alu
.src
[0].chan
= i
;
1748 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1755 static int tgsi_op3(struct r600_shader_ctx
*ctx
)
1757 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1758 struct r600_bc_alu alu
;
1760 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
1762 for (i
= 0; i
< lasti
+ 1; i
++) {
1763 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
1766 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1767 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1768 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1769 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1772 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1779 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1786 static int tgsi_dp(struct r600_shader_ctx
*ctx
)
1788 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1789 struct r600_bc_alu alu
;
1792 for (i
= 0; i
< 4; i
++) {
1793 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1794 alu
.inst
= ctx
->inst_info
->r600_opcode
;
1795 for (j
= 0; j
< inst
->Instruction
.NumSrcRegs
; j
++) {
1796 r600_bc_src(&alu
.src
[j
], &ctx
->src
[j
], i
);
1799 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
1801 alu
.dst
.write
= (inst
->Dst
[0].Register
.WriteMask
>> i
) & 1;
1802 /* handle some special cases */
1803 switch (ctx
->inst_info
->tgsi_opcode
) {
1804 case TGSI_OPCODE_DP2
:
1806 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1807 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1810 case TGSI_OPCODE_DP3
:
1812 alu
.src
[0].sel
= alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
1813 alu
.src
[0].chan
= alu
.src
[1].chan
= 0;
1816 case TGSI_OPCODE_DPH
:
1818 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1819 alu
.src
[0].chan
= 0;
1829 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1836 static inline boolean
tgsi_tex_src_requires_loading(struct r600_shader_ctx
*ctx
,
1839 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1840 return (inst
->Src
[index
].Register
.File
!= TGSI_FILE_TEMPORARY
&&
1841 inst
->Src
[index
].Register
.File
!= TGSI_FILE_INPUT
) ||
1842 ctx
->src
[index
].neg
|| ctx
->src
[index
].abs
;
1845 static inline unsigned tgsi_tex_get_src_gpr(struct r600_shader_ctx
*ctx
,
1848 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1849 return ctx
->file_offset
[inst
->Src
[index
].Register
.File
] + inst
->Src
[index
].Register
.Index
;
1852 static int tgsi_tex(struct r600_shader_ctx
*ctx
)
1854 static float one_point_five
= 1.5f
;
1855 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
1856 struct r600_bc_tex tex
;
1857 struct r600_bc_alu alu
;
1861 /* Texture fetch instructions can only use gprs as source.
1862 * Also they cannot negate the source or take the absolute value */
1863 const boolean src_requires_loading
= tgsi_tex_src_requires_loading(ctx
, 0);
1864 boolean src_loaded
= FALSE
;
1865 unsigned sampler_src_reg
= 1;
1867 src_gpr
= tgsi_tex_get_src_gpr(ctx
, 0);
1869 if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXD
) {
1870 /* TGSI moves the sampler to src reg 3 for TXD */
1871 sampler_src_reg
= 3;
1873 for (i
= 1; i
< 3; i
++) {
1874 /* set gradients h/v */
1875 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
1876 tex
.inst
= (i
== 1) ? SQ_TEX_INST_SET_GRADIENTS_H
:
1877 SQ_TEX_INST_SET_GRADIENTS_V
;
1878 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
1879 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
1881 if (tgsi_tex_src_requires_loading(ctx
, i
)) {
1882 tex
.src_gpr
= r600_get_temp(ctx
);
1888 for (j
= 0; j
< 4; j
++) {
1889 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1890 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1891 r600_bc_src(&alu
.src
[0], &ctx
->src
[i
], j
);
1892 alu
.dst
.sel
= tex
.src_gpr
;
1897 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1903 tex
.src_gpr
= tgsi_tex_get_src_gpr(ctx
, i
);
1904 tex
.src_sel_x
= ctx
->src
[i
].swizzle
[0];
1905 tex
.src_sel_y
= ctx
->src
[i
].swizzle
[1];
1906 tex
.src_sel_z
= ctx
->src
[i
].swizzle
[2];
1907 tex
.src_sel_w
= ctx
->src
[i
].swizzle
[3];
1908 tex
.src_rel
= ctx
->src
[i
].rel
;
1910 tex
.dst_gpr
= ctx
->temp_reg
; /* just to avoid confusing the asm scheduler */
1911 tex
.dst_sel_x
= tex
.dst_sel_y
= tex
.dst_sel_z
= tex
.dst_sel_w
= 7;
1912 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
1913 tex
.coord_type_x
= 1;
1914 tex
.coord_type_y
= 1;
1915 tex
.coord_type_z
= 1;
1916 tex
.coord_type_w
= 1;
1918 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
1922 } else if (inst
->Instruction
.Opcode
== TGSI_OPCODE_TXP
) {
1924 /* Add perspective divide */
1925 if (ctx
->bc
->chip_class
== CAYMAN
) {
1927 for (i
= 0; i
< 3; i
++) {
1928 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1929 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1930 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1932 alu
.dst
.sel
= ctx
->temp_reg
;
1938 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1945 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1946 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
1947 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 3);
1949 alu
.dst
.sel
= ctx
->temp_reg
;
1950 alu
.dst
.chan
= out_chan
;
1953 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1958 for (i
= 0; i
< 3; i
++) {
1959 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1960 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
1961 alu
.src
[0].sel
= ctx
->temp_reg
;
1962 alu
.src
[0].chan
= out_chan
;
1963 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
1964 alu
.dst
.sel
= ctx
->temp_reg
;
1967 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1971 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1972 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
1973 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
1974 alu
.src
[0].chan
= 0;
1975 alu
.dst
.sel
= ctx
->temp_reg
;
1979 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
1983 src_gpr
= ctx
->temp_reg
;
1986 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
1987 static const unsigned src0_swizzle
[] = {2, 2, 0, 1};
1988 static const unsigned src1_swizzle
[] = {1, 0, 2, 2};
1990 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
1991 for (i
= 0; i
< 4; i
++) {
1992 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
1993 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_CUBE
);
1994 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
1995 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], src1_swizzle
[i
]);
1996 alu
.dst
.sel
= ctx
->temp_reg
;
2001 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2006 /* tmp1.z = RCP_e(|tmp1.z|) */
2007 if (ctx
->bc
->chip_class
== CAYMAN
) {
2008 for (i
= 0; i
< 3; i
++) {
2009 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2010 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2011 alu
.src
[0].sel
= ctx
->temp_reg
;
2012 alu
.src
[0].chan
= 2;
2014 alu
.dst
.sel
= ctx
->temp_reg
;
2020 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2025 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2026 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2027 alu
.src
[0].sel
= ctx
->temp_reg
;
2028 alu
.src
[0].chan
= 2;
2030 alu
.dst
.sel
= ctx
->temp_reg
;
2034 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2039 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
2040 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
2041 * muladd has no writemask, have to use another temp
2043 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2044 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2047 alu
.src
[0].sel
= ctx
->temp_reg
;
2048 alu
.src
[0].chan
= 0;
2049 alu
.src
[1].sel
= ctx
->temp_reg
;
2050 alu
.src
[1].chan
= 2;
2052 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
2053 alu
.src
[2].chan
= 0;
2054 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
2056 alu
.dst
.sel
= ctx
->temp_reg
;
2060 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2064 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2065 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2068 alu
.src
[0].sel
= ctx
->temp_reg
;
2069 alu
.src
[0].chan
= 1;
2070 alu
.src
[1].sel
= ctx
->temp_reg
;
2071 alu
.src
[1].chan
= 2;
2073 alu
.src
[2].sel
= V_SQ_ALU_SRC_LITERAL
;
2074 alu
.src
[2].chan
= 0;
2075 alu
.src
[2].value
= *(uint32_t *)&one_point_five
;
2077 alu
.dst
.sel
= ctx
->temp_reg
;
2082 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2087 src_gpr
= ctx
->temp_reg
;
2090 if (src_requires_loading
&& !src_loaded
) {
2091 for (i
= 0; i
< 4; i
++) {
2092 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2093 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2094 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2095 alu
.dst
.sel
= ctx
->temp_reg
;
2100 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2105 src_gpr
= ctx
->temp_reg
;
2108 opcode
= ctx
->inst_info
->r600_opcode
;
2109 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
) {
2111 case SQ_TEX_INST_SAMPLE
:
2112 opcode
= SQ_TEX_INST_SAMPLE_C
;
2114 case SQ_TEX_INST_SAMPLE_L
:
2115 opcode
= SQ_TEX_INST_SAMPLE_C_L
;
2117 case SQ_TEX_INST_SAMPLE_G
:
2118 opcode
= SQ_TEX_INST_SAMPLE_C_G
;
2123 memset(&tex
, 0, sizeof(struct r600_bc_tex
));
2126 tex
.sampler_id
= tgsi_tex_get_src_gpr(ctx
, sampler_src_reg
);
2127 tex
.resource_id
= tex
.sampler_id
+ R600_MAX_CONST_BUFFERS
;
2128 tex
.src_gpr
= src_gpr
;
2129 tex
.dst_gpr
= ctx
->file_offset
[inst
->Dst
[0].Register
.File
] + inst
->Dst
[0].Register
.Index
;
2130 tex
.dst_sel_x
= (inst
->Dst
[0].Register
.WriteMask
& 1) ? 0 : 7;
2131 tex
.dst_sel_y
= (inst
->Dst
[0].Register
.WriteMask
& 2) ? 1 : 7;
2132 tex
.dst_sel_z
= (inst
->Dst
[0].Register
.WriteMask
& 4) ? 2 : 7;
2133 tex
.dst_sel_w
= (inst
->Dst
[0].Register
.WriteMask
& 8) ? 3 : 7;
2140 tex
.src_sel_x
= ctx
->src
[0].swizzle
[0];
2141 tex
.src_sel_y
= ctx
->src
[0].swizzle
[1];
2142 tex
.src_sel_z
= ctx
->src
[0].swizzle
[2];
2143 tex
.src_sel_w
= ctx
->src
[0].swizzle
[3];
2144 tex
.src_rel
= ctx
->src
[0].rel
;
2147 if (inst
->Texture
.Texture
== TGSI_TEXTURE_CUBE
) {
2154 if (inst
->Texture
.Texture
!= TGSI_TEXTURE_RECT
) {
2155 tex
.coord_type_x
= 1;
2156 tex
.coord_type_y
= 1;
2157 tex
.coord_type_z
= 1;
2158 tex
.coord_type_w
= 1;
2161 if (inst
->Texture
.Texture
== TGSI_TEXTURE_1D_ARRAY
) {
2162 tex
.coord_type_z
= 0;
2163 tex
.src_sel_z
= tex
.src_sel_y
;
2164 } else if (inst
->Texture
.Texture
== TGSI_TEXTURE_2D_ARRAY
)
2165 tex
.coord_type_z
= 0;
2167 if (inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW1D
|| inst
->Texture
.Texture
== TGSI_TEXTURE_SHADOW2D
)
2168 tex
.src_sel_w
= tex
.src_sel_z
;
2170 r
= r600_bc_add_tex(ctx
->bc
, &tex
);
2174 /* add shadow ambient support - gallium doesn't do it yet */
2178 static int tgsi_lrp(struct r600_shader_ctx
*ctx
)
2180 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2181 struct r600_bc_alu alu
;
2182 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2186 /* optimize if it's just an equal balance */
2187 if (ctx
->src
[0].sel
== V_SQ_ALU_SRC_0_5
) {
2188 for (i
= 0; i
< lasti
+ 1; i
++) {
2189 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2192 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2193 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2194 r600_bc_src(&alu
.src
[0], &ctx
->src
[1], i
);
2195 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
2197 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2202 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2210 for (i
= 0; i
< lasti
+ 1; i
++) {
2211 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2214 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2215 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
);
2216 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2217 alu
.src
[0].chan
= 0;
2218 r600_bc_src(&alu
.src
[1], &ctx
->src
[0], i
);
2219 r600_bc_src_toggle_neg(&alu
.src
[1]);
2220 alu
.dst
.sel
= ctx
->temp_reg
;
2226 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2231 /* (1 - src0) * src2 */
2232 for (i
= 0; i
< lasti
+ 1; i
++) {
2233 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2236 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2237 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2238 alu
.src
[0].sel
= ctx
->temp_reg
;
2239 alu
.src
[0].chan
= i
;
2240 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
2241 alu
.dst
.sel
= ctx
->temp_reg
;
2247 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2252 /* src0 * src1 + (1 - src0) * src2 */
2253 for (i
= 0; i
< lasti
+ 1; i
++) {
2254 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2257 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2258 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2260 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2261 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
2262 alu
.src
[2].sel
= ctx
->temp_reg
;
2263 alu
.src
[2].chan
= i
;
2265 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2270 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2277 static int tgsi_cmp(struct r600_shader_ctx
*ctx
)
2279 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2280 struct r600_bc_alu alu
;
2282 int lasti
= tgsi_last_instruction(inst
->Dst
[0].Register
.WriteMask
);
2284 for (i
= 0; i
< lasti
+ 1; i
++) {
2285 if (!(inst
->Dst
[0].Register
.WriteMask
& (1 << i
)))
2288 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2289 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_CNDGE
);
2290 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2291 r600_bc_src(&alu
.src
[1], &ctx
->src
[2], i
);
2292 r600_bc_src(&alu
.src
[2], &ctx
->src
[1], i
);
2293 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2299 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2306 static int tgsi_xpd(struct r600_shader_ctx
*ctx
)
2308 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2309 static const unsigned int src0_swizzle
[] = {2, 0, 1};
2310 static const unsigned int src1_swizzle
[] = {1, 2, 0};
2311 struct r600_bc_alu alu
;
2312 uint32_t use_temp
= 0;
2315 if (inst
->Dst
[0].Register
.WriteMask
!= 0xf)
2318 for (i
= 0; i
< 4; i
++) {
2319 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2320 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2322 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src0_swizzle
[i
]);
2323 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], src1_swizzle
[i
]);
2325 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2326 alu
.src
[0].chan
= i
;
2327 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2328 alu
.src
[1].chan
= i
;
2331 alu
.dst
.sel
= ctx
->temp_reg
;
2337 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2342 for (i
= 0; i
< 4; i
++) {
2343 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2344 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
);
2347 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], src1_swizzle
[i
]);
2348 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], src0_swizzle
[i
]);
2350 alu
.src
[0].sel
= V_SQ_ALU_SRC_0
;
2351 alu
.src
[0].chan
= i
;
2352 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2353 alu
.src
[1].chan
= i
;
2356 alu
.src
[2].sel
= ctx
->temp_reg
;
2358 alu
.src
[2].chan
= i
;
2361 alu
.dst
.sel
= ctx
->temp_reg
;
2363 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2369 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2374 return tgsi_helper_copy(ctx
, inst
);
2378 static int tgsi_exp(struct r600_shader_ctx
*ctx
)
2380 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2381 struct r600_bc_alu alu
;
2385 /* result.x = 2^floor(src); */
2386 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2387 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2389 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2390 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2392 alu
.dst
.sel
= ctx
->temp_reg
;
2396 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2400 if (ctx
->bc
->chip_class
== CAYMAN
) {
2401 for (i
= 0; i
< 3; i
++) {
2402 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2403 alu
.src
[0].sel
= ctx
->temp_reg
;
2404 alu
.src
[0].chan
= 0;
2406 alu
.dst
.sel
= ctx
->temp_reg
;
2412 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2417 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2418 alu
.src
[0].sel
= ctx
->temp_reg
;
2419 alu
.src
[0].chan
= 0;
2421 alu
.dst
.sel
= ctx
->temp_reg
;
2425 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2431 /* result.y = tmp - floor(tmp); */
2432 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2433 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2435 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
);
2436 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2438 alu
.dst
.sel
= ctx
->temp_reg
;
2440 r
= tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2449 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2454 /* result.z = RoughApprox2ToX(tmp);*/
2455 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 0x1) {
2456 if (ctx
->bc
->chip_class
== CAYMAN
) {
2457 for (i
= 0; i
< 3; i
++) {
2458 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2459 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2460 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2462 alu
.dst
.sel
= ctx
->temp_reg
;
2469 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2474 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2475 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2476 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2478 alu
.dst
.sel
= ctx
->temp_reg
;
2484 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2490 /* result.w = 1.0;*/
2491 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 0x1) {
2492 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2494 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2495 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2496 alu
.src
[0].chan
= 0;
2498 alu
.dst
.sel
= ctx
->temp_reg
;
2502 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2506 return tgsi_helper_copy(ctx
, inst
);
2509 static int tgsi_log(struct r600_shader_ctx
*ctx
)
2511 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2512 struct r600_bc_alu alu
;
2516 /* result.x = floor(log2(|src|)); */
2517 if (inst
->Dst
[0].Register
.WriteMask
& 1) {
2518 if (ctx
->bc
->chip_class
== CAYMAN
) {
2519 for (i
= 0; i
< 3; i
++) {
2520 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2522 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2523 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2524 r600_bc_src_set_abs(&alu
.src
[0]);
2526 alu
.dst
.sel
= ctx
->temp_reg
;
2532 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2538 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2540 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2541 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2542 r600_bc_src_set_abs(&alu
.src
[0]);
2544 alu
.dst
.sel
= ctx
->temp_reg
;
2548 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2553 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2554 alu
.src
[0].sel
= ctx
->temp_reg
;
2555 alu
.src
[0].chan
= 0;
2557 alu
.dst
.sel
= ctx
->temp_reg
;
2562 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2567 /* result.y = |src.x| / (2 ^ floor(log2(|src.x|))); */
2568 if ((inst
->Dst
[0].Register
.WriteMask
>> 1) & 1) {
2570 if (ctx
->bc
->chip_class
== CAYMAN
) {
2571 for (i
= 0; i
< 3; i
++) {
2572 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2574 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2575 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2576 r600_bc_src_set_abs(&alu
.src
[0]);
2578 alu
.dst
.sel
= ctx
->temp_reg
;
2585 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2590 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2592 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2593 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2594 r600_bc_src_set_abs(&alu
.src
[0]);
2596 alu
.dst
.sel
= ctx
->temp_reg
;
2601 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2606 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2608 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
);
2609 alu
.src
[0].sel
= ctx
->temp_reg
;
2610 alu
.src
[0].chan
= 1;
2612 alu
.dst
.sel
= ctx
->temp_reg
;
2617 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2621 if (ctx
->bc
->chip_class
== CAYMAN
) {
2622 for (i
= 0; i
< 3; i
++) {
2623 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2624 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2625 alu
.src
[0].sel
= ctx
->temp_reg
;
2626 alu
.src
[0].chan
= 1;
2628 alu
.dst
.sel
= ctx
->temp_reg
;
2635 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2640 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2641 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
);
2642 alu
.src
[0].sel
= ctx
->temp_reg
;
2643 alu
.src
[0].chan
= 1;
2645 alu
.dst
.sel
= ctx
->temp_reg
;
2650 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2655 if (ctx
->bc
->chip_class
== CAYMAN
) {
2656 for (i
= 0; i
< 3; i
++) {
2657 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2658 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2659 alu
.src
[0].sel
= ctx
->temp_reg
;
2660 alu
.src
[0].chan
= 1;
2662 alu
.dst
.sel
= ctx
->temp_reg
;
2669 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2674 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2675 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
);
2676 alu
.src
[0].sel
= ctx
->temp_reg
;
2677 alu
.src
[0].chan
= 1;
2679 alu
.dst
.sel
= ctx
->temp_reg
;
2684 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2689 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2691 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2693 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2694 r600_bc_src_set_abs(&alu
.src
[0]);
2696 alu
.src
[1].sel
= ctx
->temp_reg
;
2697 alu
.src
[1].chan
= 1;
2699 alu
.dst
.sel
= ctx
->temp_reg
;
2704 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2709 /* result.z = log2(|src|);*/
2710 if ((inst
->Dst
[0].Register
.WriteMask
>> 2) & 1) {
2711 if (ctx
->bc
->chip_class
== CAYMAN
) {
2712 for (i
= 0; i
< 3; i
++) {
2713 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2715 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2716 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2717 r600_bc_src_set_abs(&alu
.src
[0]);
2719 alu
.dst
.sel
= ctx
->temp_reg
;
2726 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2731 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2733 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
);
2734 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2735 r600_bc_src_set_abs(&alu
.src
[0]);
2737 alu
.dst
.sel
= ctx
->temp_reg
;
2742 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2748 /* result.w = 1.0; */
2749 if ((inst
->Dst
[0].Register
.WriteMask
>> 3) & 1) {
2750 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2752 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
);
2753 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2754 alu
.src
[0].chan
= 0;
2756 alu
.dst
.sel
= ctx
->temp_reg
;
2761 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2766 return tgsi_helper_copy(ctx
, inst
);
2769 static int tgsi_eg_arl(struct r600_shader_ctx
*ctx
)
2771 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2772 struct r600_bc_alu alu
;
2775 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2777 switch (inst
->Instruction
.Opcode
) {
2778 case TGSI_OPCODE_ARL
:
2779 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT_FLOOR
;
2781 case TGSI_OPCODE_ARR
:
2782 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2789 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2791 alu
.dst
.sel
= ctx
->ar_reg
;
2793 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2797 /* TODO: Note that the MOVA can be avoided if we never use AR for
2798 * indexing non-CB registers in the current ALU clause. Similarly, we
2799 * need to load AR from ar_reg again if we started a new clause
2800 * between ARL and AR usage. The easy way to do that is to remove
2801 * the MOVA here, and load it for the first AR access after ar_reg
2802 * has been modified in each clause. */
2803 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2804 alu
.inst
= EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2805 alu
.src
[0].sel
= ctx
->ar_reg
;
2806 alu
.src
[0].chan
= 0;
2808 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2813 static int tgsi_r600_arl(struct r600_shader_ctx
*ctx
)
2815 /* TODO from r600c, ar values don't persist between clauses */
2816 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2817 struct r600_bc_alu alu
;
2820 switch (inst
->Instruction
.Opcode
) {
2821 case TGSI_OPCODE_ARL
:
2822 memset(&alu
, 0, sizeof(alu
));
2823 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
;
2824 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2825 alu
.dst
.sel
= ctx
->ar_reg
;
2829 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2832 memset(&alu
, 0, sizeof(alu
));
2833 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2834 alu
.src
[0].sel
= ctx
->ar_reg
;
2835 alu
.dst
.sel
= ctx
->ar_reg
;
2839 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2842 case TGSI_OPCODE_ARR
:
2843 memset(&alu
, 0, sizeof(alu
));
2844 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLT_TO_INT
;
2845 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2846 alu
.dst
.sel
= ctx
->ar_reg
;
2850 if ((r
= r600_bc_add_alu(ctx
->bc
, &alu
)))
2858 memset(&alu
, 0, sizeof(alu
));
2859 alu
.inst
= V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOVA_INT
;
2860 alu
.src
[0].sel
= ctx
->ar_reg
;
2863 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2866 ctx
->bc
->cf_last
->r6xx_uses_waterfall
= 1;
2870 static int tgsi_opdst(struct r600_shader_ctx
*ctx
)
2872 struct tgsi_full_instruction
*inst
= &ctx
->parse
.FullToken
.FullInstruction
;
2873 struct r600_bc_alu alu
;
2876 for (i
= 0; i
< 4; i
++) {
2877 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2879 alu
.inst
= CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
);
2880 tgsi_dst(ctx
, &inst
->Dst
[0], i
, &alu
.dst
);
2882 if (i
== 0 || i
== 3) {
2883 alu
.src
[0].sel
= V_SQ_ALU_SRC_1
;
2885 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], i
);
2888 if (i
== 0 || i
== 2) {
2889 alu
.src
[1].sel
= V_SQ_ALU_SRC_1
;
2891 r600_bc_src(&alu
.src
[1], &ctx
->src
[1], i
);
2895 r
= r600_bc_add_alu(ctx
->bc
, &alu
);
2902 static int emit_logic_pred(struct r600_shader_ctx
*ctx
, int opcode
)
2904 struct r600_bc_alu alu
;
2907 memset(&alu
, 0, sizeof(struct r600_bc_alu
));
2911 alu
.dst
.sel
= ctx
->temp_reg
;
2915 r600_bc_src(&alu
.src
[0], &ctx
->src
[0], 0);
2916 alu
.src
[1].sel
= V_SQ_ALU_SRC_0
;
2917 alu
.src
[1].chan
= 0;
2921 r
= r600_bc_add_alu_type(ctx
->bc
, &alu
, CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_PUSH_BEFORE
));
2927 static int pops(struct r600_shader_ctx
*ctx
, int pops
)
2930 if (ctx
->bc
->cf_last
) {
2931 if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU
) << 3)
2933 else if (ctx
->bc
->cf_last
->inst
== CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3)
2938 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP_AFTER
) << 3;
2939 ctx
->bc
->force_add_cf
= 1;
2940 } else if (alu_pop
== 2) {
2941 ctx
->bc
->cf_last
->inst
= CTX_INST(V_SQ_CF_ALU_WORD1_SQ_CF_INST_ALU_POP2_AFTER
) << 3;
2942 ctx
->bc
->force_add_cf
= 1;
2944 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_POP
));
2945 ctx
->bc
->cf_last
->pop_count
= pops
;
2946 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
2951 static inline void callstack_decrease_current(struct r600_shader_ctx
*ctx
, unsigned reason
)
2955 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2959 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
-= 4;
2962 /* TOODO : for 16 vp asic should -= 2; */
2963 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
--;
2968 static inline void callstack_check_depth(struct r600_shader_ctx
*ctx
, unsigned reason
, unsigned check_max_only
)
2970 if (check_max_only
) {
2983 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
) >
2984 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
2985 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
2986 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+ diff
;
2992 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
2996 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
+= 4;
2999 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
++;
3003 if ((ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
) >
3004 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
) {
3005 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].max
=
3006 ctx
->bc
->callstack
[ctx
->bc
->call_sp
].current
;
3010 static void fc_set_mid(struct r600_shader_ctx
*ctx
, int fc_sp
)
3012 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[fc_sp
];
3014 sp
->mid
= (struct r600_bc_cf
**)realloc((void *)sp
->mid
,
3015 sizeof(struct r600_bc_cf
*) * (sp
->num_mid
+ 1));
3016 sp
->mid
[sp
->num_mid
] = ctx
->bc
->cf_last
;
3020 static void fc_pushlevel(struct r600_shader_ctx
*ctx
, int type
)
3023 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
= type
;
3024 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
= ctx
->bc
->cf_last
;
3027 static void fc_poplevel(struct r600_shader_ctx
*ctx
)
3029 struct r600_cf_stack_entry
*sp
= &ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
];
3041 static int emit_return(struct r600_shader_ctx
*ctx
)
3043 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_RETURN
);
3047 static int emit_jump_to_offset(struct r600_shader_ctx
*ctx
, int pops
, int offset
)
3050 r600_bc_add_cfinst(ctx
->bc
, V_SQ_CF_WORD1_SQ_CF_INST_JUMP
);
3051 ctx
->bc
->cf_last
->pop_count
= pops
;
3052 /* TODO work out offset */
3056 static int emit_setret_in_loop_flag(struct r600_shader_ctx
*ctx
, unsigned flag_value
)
3061 static void emit_testflag(struct r600_shader_ctx
*ctx
)
3066 static void emit_return_on_flag(struct r600_shader_ctx
*ctx
, unsigned ifidx
)
3069 emit_jump_to_offset(ctx
, 1, 4);
3070 emit_setret_in_loop_flag(ctx
, V_SQ_ALU_SRC_0
);
3071 pops(ctx
, ifidx
+ 1);
3075 static void break_loop_on_flag(struct r600_shader_ctx
*ctx
, unsigned fc_sp
)
3079 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3080 ctx
->bc
->cf_last
->pop_count
= 1;
3082 fc_set_mid(ctx
, fc_sp
);
3088 static int tgsi_if(struct r600_shader_ctx
*ctx
)
3090 emit_logic_pred(ctx
, CTX_INST(V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_PRED_SETNE
));
3092 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_JUMP
));
3094 fc_pushlevel(ctx
, FC_IF
);
3096 callstack_check_depth(ctx
, FC_PUSH_VPM
, 0);
3100 static int tgsi_else(struct r600_shader_ctx
*ctx
)
3102 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_ELSE
));
3103 ctx
->bc
->cf_last
->pop_count
= 1;
3105 fc_set_mid(ctx
, ctx
->bc
->fc_sp
);
3106 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
;
3110 static int tgsi_endif(struct r600_shader_ctx
*ctx
)
3113 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_IF
) {
3114 R600_ERR("if/endif unbalanced in shader\n");
3118 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
== NULL
) {
3119 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3120 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->pop_count
= 1;
3122 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[0]->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3126 callstack_decrease_current(ctx
, FC_PUSH_VPM
);
3130 static int tgsi_bgnloop(struct r600_shader_ctx
*ctx
)
3132 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_START_NO_AL
));
3134 fc_pushlevel(ctx
, FC_LOOP
);
3136 /* check stack depth */
3137 callstack_check_depth(ctx
, FC_LOOP
, 0);
3141 static int tgsi_endloop(struct r600_shader_ctx
*ctx
)
3145 r600_bc_add_cfinst(ctx
->bc
, CTX_INST(V_SQ_CF_WORD1_SQ_CF_INST_LOOP_END
));
3147 if (ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].type
!= FC_LOOP
) {
3148 R600_ERR("loop/endloop in shader code are not paired.\n");
3152 /* fixup loop pointers - from r600isa
3153 LOOP END points to CF after LOOP START,
3154 LOOP START point to CF after LOOP END
3155 BRK/CONT point to LOOP END CF
3157 ctx
->bc
->cf_last
->cf_addr
= ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->id
+ 2;
3159 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].start
->cf_addr
= ctx
->bc
->cf_last
->id
+ 2;
3161 for (i
= 0; i
< ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].num_mid
; i
++) {
3162 ctx
->bc
->fc_stack
[ctx
->bc
->fc_sp
].mid
[i
]->cf_addr
= ctx
->bc
->cf_last
->id
;
3164 /* TODO add LOOPRET support */
3166 callstack_decrease_current(ctx
, FC_LOOP
);
3170 static int tgsi_loop_brk_cont(struct r600_shader_ctx
*ctx
)
3174 for (fscp
= ctx
->bc
->fc_sp
; fscp
> 0; fscp
--)
3176 if (FC_LOOP
== ctx
->bc
->fc_stack
[fscp
].type
)
3181 R600_ERR("Break not inside loop/endloop pair\n");
3185 r600_bc_add_cfinst(ctx
->bc
, ctx
->inst_info
->r600_opcode
);
3186 ctx
->bc
->cf_last
->pop_count
= 1;
3188 fc_set_mid(ctx
, fscp
);
3191 callstack_check_depth(ctx
, FC_PUSH_VPM
, 1);
3195 static struct r600_shader_tgsi_instruction r600_shader_tgsi_instruction
[] = {
3196 {TGSI_OPCODE_ARL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3197 {TGSI_OPCODE_MOV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3198 {TGSI_OPCODE_LIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3201 * For state trackers other than OpenGL, we'll want to use
3202 * _RECIP_IEEE instead.
3204 {TGSI_OPCODE_RCP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_CLAMPED
, tgsi_trans_srcx_replicate
},
3206 {TGSI_OPCODE_RSQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_rsq
},
3207 {TGSI_OPCODE_EXP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3208 {TGSI_OPCODE_LOG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3209 {TGSI_OPCODE_MUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3210 {TGSI_OPCODE_ADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3211 {TGSI_OPCODE_DP3
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3212 {TGSI_OPCODE_DP4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3213 {TGSI_OPCODE_DST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3214 {TGSI_OPCODE_MIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3215 {TGSI_OPCODE_MAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3216 {TGSI_OPCODE_SLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3217 {TGSI_OPCODE_SGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3218 {TGSI_OPCODE_MAD
, 1, V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3219 {TGSI_OPCODE_SUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3220 {TGSI_OPCODE_LRP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3221 {TGSI_OPCODE_CND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3223 {20, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3224 {TGSI_OPCODE_DP2A
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3226 {22, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3227 {23, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3228 {TGSI_OPCODE_FRC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3229 {TGSI_OPCODE_CLAMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3230 {TGSI_OPCODE_FLR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3231 {TGSI_OPCODE_ROUND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3232 {TGSI_OPCODE_EX2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3233 {TGSI_OPCODE_LG2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3234 {TGSI_OPCODE_POW
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3235 {TGSI_OPCODE_XPD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3237 {32, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3238 {TGSI_OPCODE_ABS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3239 {TGSI_OPCODE_RCC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3240 {TGSI_OPCODE_DPH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3241 {TGSI_OPCODE_COS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3242 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3243 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3244 {TGSI_OPCODE_KILP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3245 {TGSI_OPCODE_PK2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3246 {TGSI_OPCODE_PK2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3247 {TGSI_OPCODE_PK4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3248 {TGSI_OPCODE_PK4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3249 {TGSI_OPCODE_RFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3250 {TGSI_OPCODE_SEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3251 {TGSI_OPCODE_SFL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3252 {TGSI_OPCODE_SGT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3253 {TGSI_OPCODE_SIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3254 {TGSI_OPCODE_SLE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3255 {TGSI_OPCODE_SNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3256 {TGSI_OPCODE_STR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3257 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3258 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
3259 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3260 {TGSI_OPCODE_UP2H
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3261 {TGSI_OPCODE_UP2US
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3262 {TGSI_OPCODE_UP4B
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3263 {TGSI_OPCODE_UP4UB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3264 {TGSI_OPCODE_X2D
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3265 {TGSI_OPCODE_ARA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3266 {TGSI_OPCODE_ARR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_r600_arl
},
3267 {TGSI_OPCODE_BRA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3268 {TGSI_OPCODE_CAL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3269 {TGSI_OPCODE_RET
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3270 {TGSI_OPCODE_SSG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3271 {TGSI_OPCODE_CMP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3272 {TGSI_OPCODE_SCS
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3273 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3274 {TGSI_OPCODE_NRM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3275 {TGSI_OPCODE_DIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3276 {TGSI_OPCODE_DP2
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3277 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3278 {TGSI_OPCODE_BRK
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3279 {TGSI_OPCODE_IF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3281 {75, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3282 {76, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3283 {TGSI_OPCODE_ELSE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3284 {TGSI_OPCODE_ENDIF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3286 {79, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3287 {80, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3288 {TGSI_OPCODE_PUSHA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3289 {TGSI_OPCODE_POPA
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3290 {TGSI_OPCODE_CEIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3291 {TGSI_OPCODE_I2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3292 {TGSI_OPCODE_NOT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3293 {TGSI_OPCODE_TRUNC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
3294 {TGSI_OPCODE_SHL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3296 {88, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3297 {TGSI_OPCODE_AND
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3298 {TGSI_OPCODE_OR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3299 {TGSI_OPCODE_MOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3300 {TGSI_OPCODE_XOR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3301 {TGSI_OPCODE_SAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3302 {TGSI_OPCODE_TXF
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3303 {TGSI_OPCODE_TXQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3304 {TGSI_OPCODE_CONT
, 0, V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3305 {TGSI_OPCODE_EMIT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3306 {TGSI_OPCODE_ENDPRIM
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3307 {TGSI_OPCODE_BGNLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3308 {TGSI_OPCODE_BGNSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3309 {TGSI_OPCODE_ENDLOOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3310 {TGSI_OPCODE_ENDSUB
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3312 {103, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3313 {104, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3314 {105, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3315 {106, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3316 {TGSI_OPCODE_NOP
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3318 {108, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3319 {109, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3320 {110, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3321 {111, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3322 {TGSI_OPCODE_NRM4
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3323 {TGSI_OPCODE_CALLNZ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3324 {TGSI_OPCODE_IFC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3325 {TGSI_OPCODE_BREAKC
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3326 {TGSI_OPCODE_KIL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3327 {TGSI_OPCODE_END
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3329 {118, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3330 {TGSI_OPCODE_F2I
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3331 {TGSI_OPCODE_IDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3332 {TGSI_OPCODE_IMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3333 {TGSI_OPCODE_IMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3334 {TGSI_OPCODE_INEG
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3335 {TGSI_OPCODE_ISGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3336 {TGSI_OPCODE_ISHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3337 {TGSI_OPCODE_ISLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3338 {TGSI_OPCODE_F2U
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3339 {TGSI_OPCODE_U2F
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3340 {TGSI_OPCODE_UADD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3341 {TGSI_OPCODE_UDIV
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3342 {TGSI_OPCODE_UMAD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3343 {TGSI_OPCODE_UMAX
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3344 {TGSI_OPCODE_UMIN
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3345 {TGSI_OPCODE_UMOD
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3346 {TGSI_OPCODE_UMUL
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3347 {TGSI_OPCODE_USEQ
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3348 {TGSI_OPCODE_USGE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3349 {TGSI_OPCODE_USHR
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3350 {TGSI_OPCODE_USLT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3351 {TGSI_OPCODE_USNE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3352 {TGSI_OPCODE_SWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3353 {TGSI_OPCODE_CASE
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3354 {TGSI_OPCODE_DEFAULT
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3355 {TGSI_OPCODE_ENDSWITCH
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3356 {TGSI_OPCODE_LAST
, 0, V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3359 static struct r600_shader_tgsi_instruction eg_shader_tgsi_instruction
[] = {
3360 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3361 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3362 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3363 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, tgsi_trans_srcx_replicate
},
3364 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, tgsi_rsq
},
3365 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3366 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3367 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3368 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3369 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3370 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3371 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3372 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3373 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3374 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3375 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3376 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3377 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3378 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3379 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3381 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3382 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3384 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3385 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3386 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3387 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3388 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3389 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3390 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, tgsi_trans_srcx_replicate
},
3391 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, tgsi_trans_srcx_replicate
},
3392 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_pow
},
3393 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3395 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3396 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3397 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3398 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3399 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, tgsi_trig
},
3400 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3401 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3402 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3403 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3404 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3405 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3406 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3407 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3408 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3409 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3410 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3411 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, tgsi_trig
},
3412 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3413 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3414 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3415 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3416 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
3417 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3418 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3419 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3420 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3421 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3422 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3423 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3424 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3425 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3426 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3427 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3428 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3429 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3430 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3431 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3432 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3433 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3434 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3435 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3436 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3437 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3439 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3440 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3441 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3442 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3444 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3445 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3446 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3447 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3448 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3449 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3450 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3451 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
3452 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3454 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3455 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3456 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3457 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3458 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3459 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3460 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3461 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3462 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3463 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3464 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3465 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3466 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3467 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3468 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3470 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3471 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3472 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3473 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3474 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3476 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3477 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3478 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3479 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3480 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3481 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3482 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3483 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3484 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3485 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3487 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3488 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3489 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3490 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3491 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3492 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3493 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3494 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3495 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3496 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3497 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3498 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3499 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3500 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3501 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3502 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3503 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3504 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3505 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3506 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3507 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3508 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3509 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3510 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3511 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3512 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3513 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3514 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3517 static struct r600_shader_tgsi_instruction cm_shader_tgsi_instruction
[] = {
3518 {TGSI_OPCODE_ARL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3519 {TGSI_OPCODE_MOV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3520 {TGSI_OPCODE_LIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lit
},
3521 {TGSI_OPCODE_RCP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIP_IEEE
, cayman_emit_float_instr
},
3522 {TGSI_OPCODE_RSQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_RECIPSQRT_IEEE
, cayman_emit_float_instr
},
3523 {TGSI_OPCODE_EXP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_exp
},
3524 {TGSI_OPCODE_LOG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_log
},
3525 {TGSI_OPCODE_MUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MUL
, tgsi_op2
},
3526 {TGSI_OPCODE_ADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3527 {TGSI_OPCODE_DP3
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3528 {TGSI_OPCODE_DP4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3529 {TGSI_OPCODE_DST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_opdst
},
3530 {TGSI_OPCODE_MIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MIN
, tgsi_op2
},
3531 {TGSI_OPCODE_MAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MAX
, tgsi_op2
},
3532 {TGSI_OPCODE_SLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2_swap
},
3533 {TGSI_OPCODE_SGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2
},
3534 {TGSI_OPCODE_MAD
, 1, EG_V_SQ_ALU_WORD1_OP3_SQ_OP3_INST_MULADD
, tgsi_op3
},
3535 {TGSI_OPCODE_SUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_ADD
, tgsi_op2
},
3536 {TGSI_OPCODE_LRP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_lrp
},
3537 {TGSI_OPCODE_CND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3539 {20, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3540 {TGSI_OPCODE_DP2A
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3542 {22, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3543 {23, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3544 {TGSI_OPCODE_FRC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FRACT
, tgsi_op2
},
3545 {TGSI_OPCODE_CLAMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3546 {TGSI_OPCODE_FLR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_FLOOR
, tgsi_op2
},
3547 {TGSI_OPCODE_ROUND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3548 {TGSI_OPCODE_EX2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_EXP_IEEE
, cayman_emit_float_instr
},
3549 {TGSI_OPCODE_LG2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_LOG_IEEE
, cayman_emit_float_instr
},
3550 {TGSI_OPCODE_POW
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, cayman_pow
},
3551 {TGSI_OPCODE_XPD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_xpd
},
3553 {32, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3554 {TGSI_OPCODE_ABS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_MOV
, tgsi_op2
},
3555 {TGSI_OPCODE_RCC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3556 {TGSI_OPCODE_DPH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3557 {TGSI_OPCODE_COS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_COS
, cayman_trig
},
3558 {TGSI_OPCODE_DDX
, 0, SQ_TEX_INST_GET_GRADIENTS_H
, tgsi_tex
},
3559 {TGSI_OPCODE_DDY
, 0, SQ_TEX_INST_GET_GRADIENTS_V
, tgsi_tex
},
3560 {TGSI_OPCODE_KILP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* predicated kill */
3561 {TGSI_OPCODE_PK2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3562 {TGSI_OPCODE_PK2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3563 {TGSI_OPCODE_PK4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3564 {TGSI_OPCODE_PK4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3565 {TGSI_OPCODE_RFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3566 {TGSI_OPCODE_SEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETE
, tgsi_op2
},
3567 {TGSI_OPCODE_SFL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3568 {TGSI_OPCODE_SGT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGT
, tgsi_op2
},
3569 {TGSI_OPCODE_SIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SIN
, cayman_trig
},
3570 {TGSI_OPCODE_SLE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETGE
, tgsi_op2_swap
},
3571 {TGSI_OPCODE_SNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_SETNE
, tgsi_op2
},
3572 {TGSI_OPCODE_STR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3573 {TGSI_OPCODE_TEX
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3574 {TGSI_OPCODE_TXD
, 0, SQ_TEX_INST_SAMPLE_G
, tgsi_tex
},
3575 {TGSI_OPCODE_TXP
, 0, SQ_TEX_INST_SAMPLE
, tgsi_tex
},
3576 {TGSI_OPCODE_UP2H
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3577 {TGSI_OPCODE_UP2US
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3578 {TGSI_OPCODE_UP4B
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3579 {TGSI_OPCODE_UP4UB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3580 {TGSI_OPCODE_X2D
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3581 {TGSI_OPCODE_ARA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3582 {TGSI_OPCODE_ARR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_eg_arl
},
3583 {TGSI_OPCODE_BRA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3584 {TGSI_OPCODE_CAL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3585 {TGSI_OPCODE_RET
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3586 {TGSI_OPCODE_SSG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_ssg
},
3587 {TGSI_OPCODE_CMP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_cmp
},
3588 {TGSI_OPCODE_SCS
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_scs
},
3589 {TGSI_OPCODE_TXB
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3590 {TGSI_OPCODE_NRM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3591 {TGSI_OPCODE_DIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3592 {TGSI_OPCODE_DP2
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_DOT4
, tgsi_dp
},
3593 {TGSI_OPCODE_TXL
, 0, SQ_TEX_INST_SAMPLE_L
, tgsi_tex
},
3594 {TGSI_OPCODE_BRK
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_BREAK
, tgsi_loop_brk_cont
},
3595 {TGSI_OPCODE_IF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_if
},
3597 {75, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3598 {76, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3599 {TGSI_OPCODE_ELSE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_else
},
3600 {TGSI_OPCODE_ENDIF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endif
},
3602 {79, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3603 {80, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3604 {TGSI_OPCODE_PUSHA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3605 {TGSI_OPCODE_POPA
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3606 {TGSI_OPCODE_CEIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3607 {TGSI_OPCODE_I2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3608 {TGSI_OPCODE_NOT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3609 {TGSI_OPCODE_TRUNC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_TRUNC
, tgsi_op2
},
3610 {TGSI_OPCODE_SHL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3612 {88, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3613 {TGSI_OPCODE_AND
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3614 {TGSI_OPCODE_OR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3615 {TGSI_OPCODE_MOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3616 {TGSI_OPCODE_XOR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3617 {TGSI_OPCODE_SAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3618 {TGSI_OPCODE_TXF
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3619 {TGSI_OPCODE_TXQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3620 {TGSI_OPCODE_CONT
, 0, EG_V_SQ_CF_WORD1_SQ_CF_INST_LOOP_CONTINUE
, tgsi_loop_brk_cont
},
3621 {TGSI_OPCODE_EMIT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3622 {TGSI_OPCODE_ENDPRIM
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3623 {TGSI_OPCODE_BGNLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_bgnloop
},
3624 {TGSI_OPCODE_BGNSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3625 {TGSI_OPCODE_ENDLOOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_endloop
},
3626 {TGSI_OPCODE_ENDSUB
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3628 {103, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3629 {104, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3630 {105, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3631 {106, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3632 {TGSI_OPCODE_NOP
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3634 {108, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3635 {109, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3636 {110, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3637 {111, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3638 {TGSI_OPCODE_NRM4
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3639 {TGSI_OPCODE_CALLNZ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3640 {TGSI_OPCODE_IFC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3641 {TGSI_OPCODE_BREAKC
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3642 {TGSI_OPCODE_KIL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_KILLGT
, tgsi_kill
}, /* conditional kill */
3643 {TGSI_OPCODE_END
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_end
}, /* aka HALT */
3645 {118, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3646 {TGSI_OPCODE_F2I
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3647 {TGSI_OPCODE_IDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3648 {TGSI_OPCODE_IMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3649 {TGSI_OPCODE_IMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3650 {TGSI_OPCODE_INEG
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3651 {TGSI_OPCODE_ISGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3652 {TGSI_OPCODE_ISHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3653 {TGSI_OPCODE_ISLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3654 {TGSI_OPCODE_F2U
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3655 {TGSI_OPCODE_U2F
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3656 {TGSI_OPCODE_UADD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3657 {TGSI_OPCODE_UDIV
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3658 {TGSI_OPCODE_UMAD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3659 {TGSI_OPCODE_UMAX
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3660 {TGSI_OPCODE_UMIN
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3661 {TGSI_OPCODE_UMOD
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3662 {TGSI_OPCODE_UMUL
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3663 {TGSI_OPCODE_USEQ
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3664 {TGSI_OPCODE_USGE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3665 {TGSI_OPCODE_USHR
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3666 {TGSI_OPCODE_USLT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3667 {TGSI_OPCODE_USNE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3668 {TGSI_OPCODE_SWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3669 {TGSI_OPCODE_CASE
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3670 {TGSI_OPCODE_DEFAULT
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3671 {TGSI_OPCODE_ENDSWITCH
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},
3672 {TGSI_OPCODE_LAST
, 0, EG_V_SQ_ALU_WORD1_OP2_SQ_OP2_INST_NOP
, tgsi_unsupported
},