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_eu_defines.h"
35 #include "brw_shader.h"
36 #include "dev/gen_debug.h"
38 #include "util/ralloc.h"
40 /* Returns a conditional modifier that negates the condition. */
41 enum brw_conditional_mod
42 brw_negate_cmod(uint32_t cmod
)
45 case BRW_CONDITIONAL_Z
:
46 return BRW_CONDITIONAL_NZ
;
47 case BRW_CONDITIONAL_NZ
:
48 return BRW_CONDITIONAL_Z
;
49 case BRW_CONDITIONAL_G
:
50 return BRW_CONDITIONAL_LE
;
51 case BRW_CONDITIONAL_GE
:
52 return BRW_CONDITIONAL_L
;
53 case BRW_CONDITIONAL_L
:
54 return BRW_CONDITIONAL_GE
;
55 case BRW_CONDITIONAL_LE
:
56 return BRW_CONDITIONAL_G
;
62 /* Returns the corresponding conditional mod for swapping src0 and
65 enum brw_conditional_mod
66 brw_swap_cmod(uint32_t cmod
)
69 case BRW_CONDITIONAL_Z
:
70 case BRW_CONDITIONAL_NZ
:
72 case BRW_CONDITIONAL_G
:
73 return BRW_CONDITIONAL_L
;
74 case BRW_CONDITIONAL_GE
:
75 return BRW_CONDITIONAL_LE
;
76 case BRW_CONDITIONAL_L
:
77 return BRW_CONDITIONAL_G
;
78 case BRW_CONDITIONAL_LE
:
79 return BRW_CONDITIONAL_GE
;
81 return BRW_CONDITIONAL_NONE
;
86 * Get the least significant bit offset of the i+1-th component of immediate
87 * type \p type. For \p i equal to the two's complement of j, return the
88 * offset of the j-th component starting from the end of the vector. For
89 * scalar register types return zero.
92 imm_shift(enum brw_reg_type type
, unsigned i
)
94 assert(type
!= BRW_REGISTER_TYPE_UV
&& type
!= BRW_REGISTER_TYPE_V
&&
97 if (type
== BRW_REGISTER_TYPE_VF
)
104 * Swizzle an arbitrary immediate \p x of the given type according to the
105 * permutation specified as \p swz.
108 brw_swizzle_immediate(enum brw_reg_type type
, uint32_t x
, unsigned swz
)
110 if (imm_shift(type
, 1)) {
111 const unsigned n
= 32 / imm_shift(type
, 1);
114 for (unsigned i
= 0; i
< n
; i
++) {
115 /* Shift the specified component all the way to the right and left to
116 * discard any undesired L/MSBs, then shift it right into component i.
118 y
|= x
>> imm_shift(type
, (i
& ~3) + BRW_GET_SWZ(swz
, i
& 3))
119 << imm_shift(type
, ~0u)
120 >> imm_shift(type
, ~0u - i
);
130 brw_get_default_exec_size(struct brw_codegen
*p
)
132 return p
->current
->exec_size
;
136 brw_get_default_group(struct brw_codegen
*p
)
138 return p
->current
->group
;
142 brw_get_default_access_mode(struct brw_codegen
*p
)
144 return p
->current
->access_mode
;
148 brw_set_default_exec_size(struct brw_codegen
*p
, unsigned value
)
150 p
->current
->exec_size
= value
;
153 void brw_set_default_predicate_control( struct brw_codegen
*p
, unsigned pc
)
155 p
->current
->predicate
= pc
;
158 void brw_set_default_predicate_inverse(struct brw_codegen
*p
, bool predicate_inverse
)
160 p
->current
->pred_inv
= predicate_inverse
;
163 void brw_set_default_flag_reg(struct brw_codegen
*p
, int reg
, int subreg
)
166 p
->current
->flag_subreg
= reg
* 2 + subreg
;
169 void brw_set_default_access_mode( struct brw_codegen
*p
, unsigned access_mode
)
171 p
->current
->access_mode
= access_mode
;
175 brw_set_default_compression_control(struct brw_codegen
*p
,
176 enum brw_compression compression_control
)
178 switch (compression_control
) {
179 case BRW_COMPRESSION_NONE
:
180 /* This is the "use the first set of bits of dmask/vmask/arf
181 * according to execsize" option.
183 p
->current
->group
= 0;
185 case BRW_COMPRESSION_2NDHALF
:
186 /* For SIMD8, this is "use the second set of 8 bits." */
187 p
->current
->group
= 8;
189 case BRW_COMPRESSION_COMPRESSED
:
190 /* For SIMD16 instruction compression, use the first set of 16 bits
191 * since we don't do SIMD32 dispatch.
193 p
->current
->group
= 0;
196 unreachable("not reached");
199 if (p
->devinfo
->gen
<= 6) {
200 p
->current
->compressed
=
201 (compression_control
== BRW_COMPRESSION_COMPRESSED
);
206 * Enable or disable instruction compression on the given instruction leaving
207 * the currently selected channel enable group untouched.
210 brw_inst_set_compression(const struct gen_device_info
*devinfo
,
211 brw_inst
*inst
, bool on
)
213 if (devinfo
->gen
>= 6) {
214 /* No-op, the EU will figure out for us whether the instruction needs to
218 /* The channel group and compression controls are non-orthogonal, there
219 * are two possible representations for uncompressed instructions and we
220 * may need to preserve the current one to avoid changing the selected
221 * channel group inadvertently.
224 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_COMPRESSED
);
225 else if (brw_inst_qtr_control(devinfo
, inst
)
226 == BRW_COMPRESSION_COMPRESSED
)
227 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_NONE
);
232 brw_set_default_compression(struct brw_codegen
*p
, bool on
)
234 p
->current
->compressed
= on
;
238 * Apply the range of channel enable signals given by
239 * [group, group + exec_size) to the instruction passed as argument.
242 brw_inst_set_group(const struct gen_device_info
*devinfo
,
243 brw_inst
*inst
, unsigned group
)
245 if (devinfo
->gen
>= 7) {
246 assert(group
% 4 == 0 && group
< 32);
247 brw_inst_set_qtr_control(devinfo
, inst
, group
/ 8);
248 brw_inst_set_nib_control(devinfo
, inst
, (group
/ 4) % 2);
250 } else if (devinfo
->gen
== 6) {
251 assert(group
% 8 == 0 && group
< 32);
252 brw_inst_set_qtr_control(devinfo
, inst
, group
/ 8);
255 assert(group
% 8 == 0 && group
< 16);
256 /* The channel group and compression controls are non-orthogonal, there
257 * are two possible representations for group zero and we may need to
258 * preserve the current one to avoid changing the selected compression
259 * enable inadvertently.
262 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_2NDHALF
);
263 else if (brw_inst_qtr_control(devinfo
, inst
) == BRW_COMPRESSION_2NDHALF
)
264 brw_inst_set_qtr_control(devinfo
, inst
, BRW_COMPRESSION_NONE
);
269 brw_set_default_group(struct brw_codegen
*p
, unsigned group
)
271 p
->current
->group
= group
;
274 void brw_set_default_mask_control( struct brw_codegen
*p
, unsigned value
)
276 p
->current
->mask_control
= value
;
279 void brw_set_default_saturate( struct brw_codegen
*p
, bool enable
)
281 p
->current
->saturate
= enable
;
284 void brw_set_default_acc_write_control(struct brw_codegen
*p
, unsigned value
)
286 p
->current
->acc_wr_control
= value
;
289 void brw_push_insn_state( struct brw_codegen
*p
)
291 assert(p
->current
!= &p
->stack
[BRW_EU_MAX_INSN_STACK
-1]);
292 *(p
->current
+ 1) = *p
->current
;
296 void brw_pop_insn_state( struct brw_codegen
*p
)
298 assert(p
->current
!= p
->stack
);
303 /***********************************************************************
306 brw_init_codegen(const struct gen_device_info
*devinfo
,
307 struct brw_codegen
*p
, void *mem_ctx
)
309 memset(p
, 0, sizeof(*p
));
311 p
->devinfo
= devinfo
;
312 p
->automatic_exec_sizes
= true;
314 * Set the initial instruction store array size to 1024, if found that
315 * isn't enough, then it will double the store size at brw_next_insn()
316 * until out of memory.
318 p
->store_size
= 1024;
319 p
->store
= rzalloc_array(mem_ctx
, brw_inst
, p
->store_size
);
321 p
->current
= p
->stack
;
322 memset(p
->current
, 0, sizeof(p
->current
[0]));
324 p
->mem_ctx
= mem_ctx
;
328 brw_set_default_exec_size(p
, BRW_EXECUTE_8
);
329 brw_set_default_mask_control(p
, BRW_MASK_ENABLE
); /* what does this do? */
330 brw_set_default_saturate(p
, 0);
331 brw_set_default_compression_control(p
, BRW_COMPRESSION_NONE
);
333 /* Set up control flow stack */
334 p
->if_stack_depth
= 0;
335 p
->if_stack_array_size
= 16;
336 p
->if_stack
= rzalloc_array(mem_ctx
, int, p
->if_stack_array_size
);
338 p
->loop_stack_depth
= 0;
339 p
->loop_stack_array_size
= 16;
340 p
->loop_stack
= rzalloc_array(mem_ctx
, int, p
->loop_stack_array_size
);
341 p
->if_depth_in_loop
= rzalloc_array(mem_ctx
, int, p
->loop_stack_array_size
);
345 const unsigned *brw_get_program( struct brw_codegen
*p
,
348 *sz
= p
->next_insn_offset
;
349 return (const unsigned *)p
->store
;
353 brw_disassemble(const struct gen_device_info
*devinfo
,
354 const void *assembly
, int start
, int end
, FILE *out
)
356 bool dump_hex
= (INTEL_DEBUG
& DEBUG_HEX
) != 0;
358 for (int offset
= start
; offset
< end
;) {
359 const brw_inst
*insn
= assembly
+ offset
;
360 brw_inst uncompacted
;
361 bool compacted
= brw_inst_cmpt_control(devinfo
, insn
);
363 fprintf(out
, "0x%08x: ", offset
);
366 brw_compact_inst
*compacted
= (void *)insn
;
368 unsigned char * insn_ptr
= ((unsigned char *)&insn
[0]);
369 const unsigned int blank_spaces
= 24;
370 for (int i
= 0 ; i
< 8; i
= i
+ 4) {
371 fprintf(out
, "%02x %02x %02x %02x ",
377 /* Make compacted instructions hex value output vertically aligned
378 * with uncompacted instructions hex value
380 fprintf(out
, "%*c", blank_spaces
, ' ');
383 brw_uncompact_instruction(devinfo
, &uncompacted
, compacted
);
388 unsigned char * insn_ptr
= ((unsigned char *)&insn
[0]);
389 for (int i
= 0 ; i
< 16; i
= i
+ 4) {
390 fprintf(out
, "%02x %02x %02x %02x ",
400 brw_disassemble_inst(out
, devinfo
, insn
, compacted
);
418 #define GEN_LT(gen) ((gen) - 1)
419 #define GEN_GE(gen) (~GEN_LT(gen))
420 #define GEN_LE(gen) (GEN_LT(gen) | (gen))
422 static const struct opcode_desc opcode_10_descs
[] = {
423 { .name
= "dim", .nsrc
= 1, .ndst
= 1, .gens
= GEN75
},
424 { .name
= "smov", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN8
) },
427 static const struct opcode_desc opcode_35_descs
[] = {
428 { .name
= "iff", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
429 { .name
= "brc", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN7
) },
432 static const struct opcode_desc opcode_38_descs
[] = {
433 { .name
= "do", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
434 { .name
= "case", .nsrc
= 0, .ndst
= 0, .gens
= GEN6
},
437 static const struct opcode_desc opcode_44_descs
[] = {
438 { .name
= "msave", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
439 { .name
= "call", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN6
) },
442 static const struct opcode_desc opcode_45_descs
[] = {
443 { .name
= "mrest", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
444 { .name
= "ret", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN6
) },
447 static const struct opcode_desc opcode_46_descs
[] = {
448 { .name
= "push", .nsrc
= 0, .ndst
= 0, .gens
= GEN_LE(GEN5
) },
449 { .name
= "fork", .nsrc
= 0, .ndst
= 0, .gens
= GEN6
},
450 { .name
= "goto", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN8
) },
453 static const struct opcode_desc opcode_descs
[128] = {
454 [BRW_OPCODE_ILLEGAL
] = {
455 .name
= "illegal", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
458 .name
= "mov", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
461 .name
= "sel", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
463 [BRW_OPCODE_MOVI
] = {
464 .name
= "movi", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN45
),
467 .name
= "not", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
470 .name
= "and", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
473 .name
= "or", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
476 .name
= "xor", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
479 .name
= "shr", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
482 .name
= "shl", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
485 .table
= opcode_10_descs
, .size
= ARRAY_SIZE(opcode_10_descs
),
489 .name
= "asr", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
491 /* Reserved - 13-15 */
493 .name
= "cmp", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
495 [BRW_OPCODE_CMPN
] = {
496 .name
= "cmpn", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
498 [BRW_OPCODE_CSEL
] = {
499 .name
= "csel", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN8
),
501 [BRW_OPCODE_F32TO16
] = {
502 .name
= "f32to16", .nsrc
= 1, .ndst
= 1, .gens
= GEN7
| GEN75
,
504 [BRW_OPCODE_F16TO32
] = {
505 .name
= "f16to32", .nsrc
= 1, .ndst
= 1, .gens
= GEN7
| GEN75
,
507 /* Reserved - 21-22 */
508 [BRW_OPCODE_BFREV
] = {
509 .name
= "bfrev", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
512 .name
= "bfe", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN7
),
514 [BRW_OPCODE_BFI1
] = {
515 .name
= "bfi1", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
517 [BRW_OPCODE_BFI2
] = {
518 .name
= "bfi2", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN7
),
520 /* Reserved - 27-31 */
521 [BRW_OPCODE_JMPI
] = {
522 .name
= "jmpi", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
525 .name
= "brd", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN7
),
528 .name
= "if", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
531 .table
= opcode_35_descs
, .size
= ARRAY_SIZE(opcode_35_descs
),
533 [BRW_OPCODE_ELSE
] = {
534 .name
= "else", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
536 [BRW_OPCODE_ENDIF
] = {
537 .name
= "endif", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
540 .table
= opcode_38_descs
, .size
= ARRAY_SIZE(opcode_38_descs
),
542 [BRW_OPCODE_WHILE
] = {
543 .name
= "while", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
545 [BRW_OPCODE_BREAK
] = {
546 .name
= "break", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
548 [BRW_OPCODE_CONTINUE
] = {
549 .name
= "cont", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
551 [BRW_OPCODE_HALT
] = {
552 .name
= "halt", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
555 .name
= "calla", .nsrc
= 0, .ndst
= 0, .gens
= GEN_GE(GEN75
),
558 .table
= opcode_44_descs
, .size
= ARRAY_SIZE(opcode_44_descs
),
561 .table
= opcode_45_descs
, .size
= ARRAY_SIZE(opcode_45_descs
),
564 .table
= opcode_46_descs
, .size
= ARRAY_SIZE(opcode_46_descs
),
567 .name
= "pop", .nsrc
= 2, .ndst
= 0, .gens
= GEN_LE(GEN5
),
569 [BRW_OPCODE_WAIT
] = {
570 .name
= "wait", .nsrc
= 1, .ndst
= 0, .gens
= GEN_ALL
,
572 [BRW_OPCODE_SEND
] = {
573 .name
= "send", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
575 [BRW_OPCODE_SENDC
] = {
576 .name
= "sendc", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
578 [BRW_OPCODE_SENDS
] = {
579 .name
= "sends", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN9
),
581 [BRW_OPCODE_SENDSC
] = {
582 .name
= "sendsc", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN9
),
585 [BRW_OPCODE_MATH
] = {
586 .name
= "math", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN6
),
590 .name
= "add", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
593 .name
= "mul", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
596 .name
= "avg", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
599 .name
= "frc", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
601 [BRW_OPCODE_RNDU
] = {
602 .name
= "rndu", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
604 [BRW_OPCODE_RNDD
] = {
605 .name
= "rndd", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
607 [BRW_OPCODE_RNDE
] = {
608 .name
= "rnde", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
610 [BRW_OPCODE_RNDZ
] = {
611 .name
= "rndz", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
614 .name
= "mac", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
616 [BRW_OPCODE_MACH
] = {
617 .name
= "mach", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
620 .name
= "lzd", .nsrc
= 1, .ndst
= 1, .gens
= GEN_ALL
,
623 .name
= "fbh", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
626 .name
= "fbl", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
628 [BRW_OPCODE_CBIT
] = {
629 .name
= "cbit", .nsrc
= 1, .ndst
= 1, .gens
= GEN_GE(GEN7
),
631 [BRW_OPCODE_ADDC
] = {
632 .name
= "addc", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
634 [BRW_OPCODE_SUBB
] = {
635 .name
= "subb", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN7
),
637 [BRW_OPCODE_SAD2
] = {
638 .name
= "sad2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
640 [BRW_OPCODE_SADA2
] = {
641 .name
= "sada2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
645 .name
= "dp4", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
648 .name
= "dph", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
651 .name
= "dp3", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
654 .name
= "dp2", .nsrc
= 2, .ndst
= 1, .gens
= GEN_ALL
,
657 [BRW_OPCODE_LINE
] = {
658 .name
= "line", .nsrc
= 2, .ndst
= 1, .gens
= GEN_LE(GEN10
),
661 .name
= "pln", .nsrc
= 2, .ndst
= 1, .gens
= GEN_GE(GEN45
) & GEN_LE(GEN10
),
664 .name
= "mad", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN6
),
667 .name
= "lrp", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN6
) & GEN_LE(GEN10
),
670 .name
= "madm", .nsrc
= 3, .ndst
= 1, .gens
= GEN_GE(GEN8
),
672 /* Reserved 94-124 */
673 [BRW_OPCODE_NENOP
] = {
674 .name
= "nenop", .nsrc
= 0, .ndst
= 0, .gens
= GEN45
,
677 .name
= "nop", .nsrc
= 0, .ndst
= 0, .gens
= GEN_ALL
,
682 gen_from_devinfo(const struct gen_device_info
*devinfo
)
684 switch (devinfo
->gen
) {
685 case 4: return devinfo
->is_g4x
? GEN45
: GEN4
;
688 case 7: return devinfo
->is_haswell
? GEN75
: GEN7
;
691 case 10: return GEN10
;
692 case 11: return GEN11
;
694 unreachable("not reached");
698 /* Return the matching opcode_desc for the specified opcode number and
699 * hardware generation, or NULL if the opcode is not supported by the device.
701 const struct opcode_desc
*
702 brw_opcode_desc(const struct gen_device_info
*devinfo
, enum opcode opcode
)
704 if (opcode
>= ARRAY_SIZE(opcode_descs
))
707 enum gen gen
= gen_from_devinfo(devinfo
);
708 if (opcode_descs
[opcode
].gens
!= 0) {
709 if ((opcode_descs
[opcode
].gens
& gen
) != 0) {
710 return &opcode_descs
[opcode
];
712 } else if (opcode_descs
[opcode
].table
!= NULL
) {
713 const struct opcode_desc
*table
= opcode_descs
[opcode
].table
;
714 for (unsigned i
= 0; i
< opcode_descs
[opcode
].size
; i
++) {
715 if ((table
[i
].gens
& gen
) != 0) {