2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keithw@vmware.com>
33 #include "brw_context.h"
34 #include "brw_defines.h"
37 #include "util/ralloc.h"
40 * Converts a BRW_REGISTER_TYPE_* enum to a short string (F, UD, and so on).
42 * This is different than reg_encoding from brw_disasm.c in that it operates
43 * on the abstract enum values, rather than the generation-specific encoding.
46 brw_reg_type_letters(unsigned type
)
48 const char *names
[] = {
49 [BRW_REGISTER_TYPE_UD
] = "UD",
50 [BRW_REGISTER_TYPE_D
] = "D",
51 [BRW_REGISTER_TYPE_UW
] = "UW",
52 [BRW_REGISTER_TYPE_W
] = "W",
53 [BRW_REGISTER_TYPE_F
] = "F",
54 [BRW_REGISTER_TYPE_UB
] = "UB",
55 [BRW_REGISTER_TYPE_B
] = "B",
56 [BRW_REGISTER_TYPE_UV
] = "UV",
57 [BRW_REGISTER_TYPE_V
] = "V",
58 [BRW_REGISTER_TYPE_VF
] = "VF",
59 [BRW_REGISTER_TYPE_DF
] = "DF",
60 [BRW_REGISTER_TYPE_HF
] = "HF",
61 [BRW_REGISTER_TYPE_UQ
] = "UQ",
62 [BRW_REGISTER_TYPE_Q
] = "Q",
64 assert(type
<= BRW_REGISTER_TYPE_Q
);
68 /* Returns a conditional modifier that negates the condition. */
69 enum brw_conditional_mod
70 brw_negate_cmod(uint32_t cmod
)
73 case BRW_CONDITIONAL_Z
:
74 return BRW_CONDITIONAL_NZ
;
75 case BRW_CONDITIONAL_NZ
:
76 return BRW_CONDITIONAL_Z
;
77 case BRW_CONDITIONAL_G
:
78 return BRW_CONDITIONAL_LE
;
79 case BRW_CONDITIONAL_GE
:
80 return BRW_CONDITIONAL_L
;
81 case BRW_CONDITIONAL_L
:
82 return BRW_CONDITIONAL_GE
;
83 case BRW_CONDITIONAL_LE
:
84 return BRW_CONDITIONAL_G
;
90 /* Returns the corresponding conditional mod for swapping src0 and
93 enum brw_conditional_mod
94 brw_swap_cmod(uint32_t cmod
)
97 case BRW_CONDITIONAL_Z
:
98 case BRW_CONDITIONAL_NZ
:
100 case BRW_CONDITIONAL_G
:
101 return BRW_CONDITIONAL_L
;
102 case BRW_CONDITIONAL_GE
:
103 return BRW_CONDITIONAL_LE
;
104 case BRW_CONDITIONAL_L
:
105 return BRW_CONDITIONAL_G
;
106 case BRW_CONDITIONAL_LE
:
107 return BRW_CONDITIONAL_GE
;
109 return BRW_CONDITIONAL_NONE
;
114 * Get the least significant bit offset of the i+1-th component of immediate
115 * type \p type. For \p i equal to the two's complement of j, return the
116 * offset of the j-th component starting from the end of the vector. For
117 * scalar register types return zero.
120 imm_shift(enum brw_reg_type type
, unsigned i
)
122 assert(type
!= BRW_REGISTER_TYPE_UV
&& type
!= BRW_REGISTER_TYPE_V
&&
125 if (type
== BRW_REGISTER_TYPE_VF
)
132 * Swizzle an arbitrary immediate \p x of the given type according to the
133 * permutation specified as \p swz.
136 brw_swizzle_immediate(enum brw_reg_type type
, uint32_t x
, unsigned swz
)
138 if (imm_shift(type
, 1)) {
139 const unsigned n
= 32 / imm_shift(type
, 1);
142 for (unsigned i
= 0; i
< n
; i
++) {
143 /* Shift the specified component all the way to the right and left to
144 * discard any undesired L/MSBs, then shift it right into component i.
146 y
|= x
>> imm_shift(type
, (i
& ~3) + BRW_GET_SWZ(swz
, i
& 3))
147 << imm_shift(type
, ~0u)
148 >> imm_shift(type
, ~0u - i
);
158 brw_set_default_exec_size(struct brw_codegen
*p
, unsigned value
)
160 brw_inst_set_exec_size(p
->devinfo
, p
->current
, value
);
163 void brw_set_default_predicate_control( struct brw_codegen
*p
, unsigned pc
)
165 brw_inst_set_pred_control(p
->devinfo
, p
->current
, pc
);
168 void brw_set_default_predicate_inverse(struct brw_codegen
*p
, bool predicate_inverse
)
170 brw_inst_set_pred_inv(p
->devinfo
, p
->current
, predicate_inverse
);
173 void brw_set_default_flag_reg(struct brw_codegen
*p
, int reg
, int subreg
)
175 if (p
->devinfo
->gen
>= 7)
176 brw_inst_set_flag_reg_nr(p
->devinfo
, p
->current
, reg
);
178 brw_inst_set_flag_subreg_nr(p
->devinfo
, p
->current
, subreg
);
181 void brw_set_default_access_mode( struct brw_codegen
*p
, unsigned access_mode
)
183 brw_inst_set_access_mode(p
->devinfo
, p
->current
, access_mode
);
187 brw_set_default_compression_control(struct brw_codegen
*p
,
188 enum brw_compression compression_control
)
190 if (p
->devinfo
->gen
>= 6) {
191 /* Since we don't use the SIMD32 support in gen6, we translate
192 * the pre-gen6 compression control here.
194 switch (compression_control
) {
195 case BRW_COMPRESSION_NONE
:
196 /* This is the "use the first set of bits of dmask/vmask/arf
197 * according to execsize" option.
199 brw_inst_set_qtr_control(p
->devinfo
, p
->current
, GEN6_COMPRESSION_1Q
);
201 case BRW_COMPRESSION_2NDHALF
:
202 /* For SIMD8, this is "use the second set of 8 bits." */
203 brw_inst_set_qtr_control(p
->devinfo
, p
->current
, GEN6_COMPRESSION_2Q
);
205 case BRW_COMPRESSION_COMPRESSED
:
206 /* For SIMD16 instruction compression, use the first set of 16 bits
207 * since we don't do SIMD32 dispatch.
209 brw_inst_set_qtr_control(p
->devinfo
, p
->current
, GEN6_COMPRESSION_1H
);
212 unreachable("not reached");
215 brw_inst_set_qtr_control(p
->devinfo
, p
->current
, compression_control
);
220 * Enable or disable instruction compression on the given instruction leaving
221 * the currently selected channel enable group untouched.
224 brw_inst_set_compression(const struct gen_device_info
*devinfo
,
225 brw_inst
*inst
, bool on
)
227 if (devinfo
->gen
>= 6) {
228 /* No-op, the EU will figure out for us whether the instruction needs to
232 /* The channel group and compression controls are non-orthogonal, there
233 * are two possible representations for uncompressed instructions and we
234 * may need to preserve the current one to avoid changing the selected
235 * channel group inadvertently.
238 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_COMPRESSED
);
239 else if (brw_inst_qtr_control(devinfo
, inst
)
240 == BRW_COMPRESSION_COMPRESSED
)
241 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_NONE
);
246 brw_set_default_compression(struct brw_codegen
*p
, bool on
)
248 brw_inst_set_compression(p
->devinfo
, p
->current
, on
);
252 * Apply the range of channel enable signals given by
253 * [group, group + exec_size) to the instruction passed as argument.
256 brw_inst_set_group(const struct gen_device_info
*devinfo
,
257 brw_inst
*inst
, unsigned group
)
259 if (devinfo
->gen
>= 7) {
260 assert(group
% 4 == 0 && group
< 32);
261 brw_inst_set_qtr_control(devinfo
, inst
, group
/ 8);
262 brw_inst_set_nib_control(devinfo
, inst
, (group
/ 4) % 2);
264 } else if (devinfo
->gen
== 6) {
265 assert(group
% 8 == 0 && group
< 32);
266 brw_inst_set_qtr_control(devinfo
, inst
, group
/ 8);
269 assert(group
% 8 == 0 && group
< 16);
270 /* The channel group and compression controls are non-orthogonal, there
271 * are two possible representations for group zero and we may need to
272 * preserve the current one to avoid changing the selected compression
273 * enable inadvertently.
276 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_2NDHALF
);
277 else if (brw_inst_qtr_control(devinfo
, inst
) == BRW_COMPRESSION_2NDHALF
)
278 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_NONE
);
283 brw_set_default_group(struct brw_codegen
*p
, unsigned group
)
285 brw_inst_set_group(p
->devinfo
, p
->current
, group
);
288 void brw_set_default_mask_control( struct brw_codegen
*p
, unsigned value
)
290 brw_inst_set_mask_control(p
->devinfo
, p
->current
, value
);
293 void brw_set_default_saturate( struct brw_codegen
*p
, bool enable
)
295 brw_inst_set_saturate(p
->devinfo
, p
->current
, enable
);
298 void brw_set_default_acc_write_control(struct brw_codegen
*p
, unsigned value
)
300 if (p
->devinfo
->gen
>= 6)
301 brw_inst_set_acc_wr_control(p
->devinfo
, p
->current
, value
);
304 void brw_push_insn_state( struct brw_codegen
*p
)
306 assert(p
->current
!= &p
->stack
[BRW_EU_MAX_INSN_STACK
-1]);
307 memcpy(p
->current
+ 1, p
->current
, sizeof(brw_inst
));
311 void brw_pop_insn_state( struct brw_codegen
*p
)
313 assert(p
->current
!= p
->stack
);
318 /***********************************************************************
321 brw_init_codegen(const struct gen_device_info
*devinfo
,
322 struct brw_codegen
*p
, void *mem_ctx
)
324 memset(p
, 0, sizeof(*p
));
326 p
->devinfo
= devinfo
;
328 * Set the initial instruction store array size to 1024, if found that
329 * isn't enough, then it will double the store size at brw_next_insn()
330 * until out of memory.
332 p
->store_size
= 1024;
333 p
->store
= rzalloc_array(mem_ctx
, brw_inst
, p
->store_size
);
335 p
->current
= p
->stack
;
336 memset(p
->current
, 0, sizeof(p
->current
[0]));
338 p
->mem_ctx
= mem_ctx
;
342 brw_set_default_exec_size(p
, BRW_EXECUTE_8
);
343 brw_set_default_mask_control(p
, BRW_MASK_ENABLE
); /* what does this do? */
344 brw_set_default_saturate(p
, 0);
345 brw_set_default_compression_control(p
, BRW_COMPRESSION_NONE
);
347 /* Set up control flow stack */
348 p
->if_stack_depth
= 0;
349 p
->if_stack_array_size
= 16;
350 p
->if_stack
= rzalloc_array(mem_ctx
, int, p
->if_stack_array_size
);
352 p
->loop_stack_depth
= 0;
353 p
->loop_stack_array_size
= 16;
354 p
->loop_stack
= rzalloc_array(mem_ctx
, int, p
->loop_stack_array_size
);
355 p
->if_depth_in_loop
= rzalloc_array(mem_ctx
, int, p
->loop_stack_array_size
);
357 brw_init_compaction_tables(devinfo
);
361 const unsigned *brw_get_program( struct brw_codegen
*p
,
364 *sz
= p
->next_insn_offset
;
365 return (const unsigned *)p
->store
;
369 brw_disassemble(const struct gen_device_info
*devinfo
,
370 void *assembly
, int start
, int end
, FILE *out
)
372 bool dump_hex
= (INTEL_DEBUG
& DEBUG_HEX
) != 0;
374 for (int offset
= start
; offset
< end
;) {
375 brw_inst
*insn
= assembly
+ offset
;
376 brw_inst uncompacted
;
377 bool compacted
= brw_inst_cmpt_control(devinfo
, insn
);
379 fprintf(out
, "0x%08x: ", offset
);
382 brw_compact_inst
*compacted
= (void *)insn
;
384 fprintf(out
, "0x%08x 0x%08x ",
385 ((uint32_t *)insn
)[1],
386 ((uint32_t *)insn
)[0]);
389 brw_uncompact_instruction(devinfo
, &uncompacted
, compacted
);
394 fprintf(out
, "0x%08x 0x%08x 0x%08x 0x%08x ",
395 ((uint32_t *)insn
)[3],
396 ((uint32_t *)insn
)[2],
397 ((uint32_t *)insn
)[1],
398 ((uint32_t *)insn
)[0]);
403 brw_disassemble_inst(out
, devinfo
, insn
, compacted
);
419 #define GEN_LT(gen) ((gen) - 1)
420 #define GEN_GE(gen) (~GEN_LT(gen))
421 #define GEN_LE(gen) (GEN_LT(gen) | (gen))
423 static const struct opcode_desc opcode_10_descs
[] = {
424 { .name
= "dim", .nsrc
= 1, .ndst
= 1, .gens
= GEN75
},
425 { .name
= "smov", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN8
) },
428 static const struct opcode_desc opcode_35_descs
[] = {
429 { .name
= "iff", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
430 { .name
= "brc", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN7
) },
433 static const struct opcode_desc opcode_38_descs
[] = {
434 { .name
= "do", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
435 { .name
= "case", .nsrc
= 0, .ndst
= 0, .gens
= GEN6
},
438 static const struct opcode_desc opcode_44_descs
[] = {
439 { .name
= "msave", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
440 { .name
= "call", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN6
) },
443 static const struct opcode_desc opcode_45_descs
[] = {
444 { .name
= "mrest", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
445 { .name
= "ret", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN6
) },
448 static const struct opcode_desc opcode_46_descs
[] = {
449 { .name
= "push", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
450 { .name
= "fork", .nsrc
= 0, .ndst
= 0, .gens
= GEN6
},
451 { .name
= "goto", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN8
) },
454 static const struct opcode_desc opcode_descs
[128] = {
455 [BRW_OPCODE_ILLEGAL
] = {
456 .name
= "illegal", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
459 .name
= "mov", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
462 .name
= "sel", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
464 [BRW_OPCODE_MOVI
] = {
465 .name
= "movi", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN45
),
468 .name
= "not", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
471 .name
= "and", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
474 .name
= "or", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
477 .name
= "xor", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
480 .name
= "shr", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
483 .name
= "shl", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
486 .table
= opcode_10_descs
, .size
= ARRAY_SIZE(opcode_10_descs
),
490 .name
= "asr", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
492 /* Reserved - 13-15 */
494 .name
= "cmp", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
496 [BRW_OPCODE_CMPN
] = {
497 .name
= "cmpn", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
499 [BRW_OPCODE_CSEL
] = {
500 .name
= "csel", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN8
),
502 [BRW_OPCODE_F32TO16
] = {
503 .name
= "f32to16", .nsrc
= 1, .ndst
= 1, .gens
= GEN7
| GEN75
,
505 [BRW_OPCODE_F16TO32
] = {
506 .name
= "f16to32", .nsrc
= 1, .ndst
= 1, .gens
= GEN7
| GEN75
,
508 /* Reserved - 21-22 */
509 [BRW_OPCODE_BFREV
] = {
510 .name
= "bfrev", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
513 .name
= "bfe", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN7
),
515 [BRW_OPCODE_BFI1
] = {
516 .name
= "bfi1", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
518 [BRW_OPCODE_BFI2
] = {
519 .name
= "bfi2", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN7
),
521 /* Reserved - 27-31 */
522 [BRW_OPCODE_JMPI
] = {
523 .name
= "jmpi", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
526 .name
= "brd", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN7
),
529 .name
= "if", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
532 .table
= opcode_35_descs
, .size
= ARRAY_SIZE(opcode_35_descs
),
534 [BRW_OPCODE_ELSE
] = {
535 .name
= "else", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
537 [BRW_OPCODE_ENDIF
] = {
538 .name
= "endif", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
541 .table
= opcode_38_descs
, .size
= ARRAY_SIZE(opcode_38_descs
),
543 [BRW_OPCODE_WHILE
] = {
544 .name
= "while", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
546 [BRW_OPCODE_BREAK
] = {
547 .name
= "break", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
549 [BRW_OPCODE_CONTINUE
] = {
550 .name
= "cont", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
552 [BRW_OPCODE_HALT
] = {
553 .name
= "halt", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
556 .name
= "calla", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN75
),
559 .table
= opcode_44_descs
, .size
= ARRAY_SIZE(opcode_44_descs
),
562 .table
= opcode_45_descs
, .size
= ARRAY_SIZE(opcode_45_descs
),
565 .table
= opcode_46_descs
, .size
= ARRAY_SIZE(opcode_46_descs
),
568 .name
= "pop", .nsrc
= 2, .ndst
= 0, .gens
= GEN_LE(GEN5
),
570 [BRW_OPCODE_WAIT
] = {
571 .name
= "wait", .nsrc
= 1, .ndst
= 0, .gens
= GEN_ALL
,
573 [BRW_OPCODE_SEND
] = {
574 .name
= "send", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
576 [BRW_OPCODE_SENDC
] = {
577 .name
= "sendc", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
579 [BRW_OPCODE_SENDS
] = {
580 .name
= "sends", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN9
),
582 [BRW_OPCODE_SENDSC
] = {
583 .name
= "sendsc", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN9
),
586 [BRW_OPCODE_MATH
] = {
587 .name
= "math", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN6
),
591 .name
= "add", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
594 .name
= "mul", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
597 .name
= "avg", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
600 .name
= "frc", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
602 [BRW_OPCODE_RNDU
] = {
603 .name
= "rndu", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
605 [BRW_OPCODE_RNDD
] = {
606 .name
= "rndd", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
608 [BRW_OPCODE_RNDE
] = {
609 .name
= "rnde", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
611 [BRW_OPCODE_RNDZ
] = {
612 .name
= "rndz", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
615 .name
= "mac", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
617 [BRW_OPCODE_MACH
] = {
618 .name
= "mach", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
621 .name
= "lzd", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
624 .name
= "fbh", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
627 .name
= "fbl", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
629 [BRW_OPCODE_CBIT
] = {
630 .name
= "cbit", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
632 [BRW_OPCODE_ADDC
] = {
633 .name
= "addc", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
635 [BRW_OPCODE_SUBB
] = {
636 .name
= "subb", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
638 [BRW_OPCODE_SAD2
] = {
639 .name
= "sad2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
641 [BRW_OPCODE_SADA2
] = {
642 .name
= "sada2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
646 .name
= "dp4", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
649 .name
= "dph", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
652 .name
= "dp3", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
655 .name
= "dp2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
658 [BRW_OPCODE_LINE
] = {
659 .name
= "line", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
662 .name
= "pln", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN45
),
665 .name
= "mad", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN6
),
668 .name
= "lrp", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN6
),
671 .name
= "madm", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN8
),
673 /* Reserved 94-124 */
674 [BRW_OPCODE_NENOP
] = {
675 .name
= "nenop", .nsrc
= 0, .ndst
= 0, .gens
= GEN45
,
678 .name
= "nop", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
683 gen_from_devinfo(const struct gen_device_info
*devinfo
)
685 switch (devinfo
->gen
) {
686 case 4: return devinfo
->is_g4x
? GEN45
: GEN4
;
689 case 7: return devinfo
->is_haswell
? GEN75
: GEN7
;
693 unreachable("not reached");
697 /* Return the matching opcode_desc for the specified opcode number and
698 * hardware generation, or NULL if the opcode is not supported by the device.
700 const struct opcode_desc
*
701 brw_opcode_desc(const struct gen_device_info
*devinfo
, enum opcode opcode
)
703 if (opcode
>= ARRAY_SIZE(opcode_descs
))
706 enum gen gen
= gen_from_devinfo(devinfo
);
707 if (opcode_descs
[opcode
].gens
!= 0) {
708 if ((opcode_descs
[opcode
].gens
& gen
) != 0) {
709 return &opcode_descs
[opcode
];
711 } else if (opcode_descs
[opcode
].table
!= NULL
) {
712 const struct opcode_desc
*table
= opcode_descs
[opcode
].table
;
713 for (unsigned i
= 0; i
< opcode_descs
[opcode
].size
; i
++) {
714 if ((table
[i
].gens
& gen
) != 0) {