2 * Copyright © 2014 Intel Corporation
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * 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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27 * A representation of i965 EU assembly instructions, with helper methods to
28 * get and set various fields. This is the actual hardware format.
36 #include "brw_context.h"
42 /* brw_context.h has a forward declaration of brw_inst, so name the struct. */
43 typedef struct brw_inst
{
47 static inline uint64_t brw_inst_bits(brw_inst
*inst
,
48 unsigned high
, unsigned low
);
49 static inline void brw_inst_set_bits(brw_inst
*inst
,
50 unsigned high
, unsigned low
,
53 #define FC(name, high, low, assertions) \
55 brw_inst_set_##name(const struct brw_context *brw, \
56 brw_inst *inst, uint64_t v) \
60 brw_inst_set_bits(inst, high, low, v); \
62 static inline uint64_t \
63 brw_inst_##name(const struct brw_context *brw, \
68 return brw_inst_bits(inst, high, low); \
71 /* A simple macro for fields which stay in the same place on all generations. */
72 #define F(name, high, low) FC(name, high, low, true)
74 #define BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \
76 if (brw->gen >= 8) { \
77 high = hi8; low = lo8; \
78 } else if (brw->gen >= 7) { \
79 high = hi7; low = lo7; \
80 } else if (brw->gen >= 6) { \
81 high = hi6; low = lo6; \
82 } else if (brw->gen >= 5) { \
83 high = hi5; low = lo5; \
84 } else if (brw->is_g4x) { \
85 high = hi45; low = lo45; \
87 high = hi4; low = lo4; \
89 assert(((int) high) != -1 && ((int) low) != -1); \
91 /* A general macro for cases where the field has moved to several different
92 * bit locations across generations. GCC appears to combine cases where the
93 * bits are identical, removing some of the inefficiency.
95 #define FF(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8)\
97 brw_inst_set_##name(const struct brw_context *brw, \
98 brw_inst *inst, uint64_t value) \
100 BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \
101 brw_inst_set_bits(inst, high, low, value); \
103 static inline uint64_t \
104 brw_inst_##name(const struct brw_context *brw, brw_inst *inst) \
106 BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \
107 return brw_inst_bits(inst, high, low); \
110 /* A macro for fields which moved as of Gen8+. */
111 #define F8(name, gen4_high, gen4_low, gen8_high, gen8_low) \
113 /* 4: */ gen4_high, gen4_low, \
114 /* 4.5: */ gen4_high, gen4_low, \
115 /* 5: */ gen4_high, gen4_low, \
116 /* 6: */ gen4_high, gen4_low, \
117 /* 7: */ gen4_high, gen4_low, \
118 /* 8: */ gen8_high, gen8_low);
120 F(src1_vstride
, 120, 117)
121 F(src1_width
, 116, 114)
122 F(src1_da16_swiz_w
, 115, 114)
123 F(src1_da16_swiz_z
, 113, 112)
124 F(src1_hstride
, 113, 112)
125 F(src1_address_mode
, 111, 111)
126 /** Src1.SrcMod @{ */
127 F(src1_negate
, 110, 110)
128 F(src1_abs
, 109, 109)
130 F8(src1_ia_subreg_nr
, /* 4+ */ 108, 106, /* 8+ */ 108, 105)
131 F(src1_da_reg_nr
, 108, 101)
132 F(src1_da16_subreg_nr
, 100, 100)
133 F(src1_da1_subreg_nr
, 100, 96)
134 F(src1_da16_swiz_y
, 99, 98)
135 F(src1_da16_swiz_x
, 97, 96)
136 F8(src1_reg_type
, /* 4+ */ 46, 44, /* 8+ */ 94, 91)
137 F8(src1_reg_file
, /* 4+ */ 43, 42, /* 8+ */ 90, 89)
138 F(src0_vstride
, 88, 85)
139 F(src0_width
, 84, 82)
140 F(src0_da16_swiz_w
, 83, 82)
141 F(src0_da16_swiz_z
, 81, 80)
142 F(src0_hstride
, 81, 80)
143 F(src0_address_mode
, 79, 79)
144 /** Src0.SrcMod @{ */
145 F(src0_negate
, 78, 78)
148 F8(src0_ia_subreg_nr
, /* 4+ */ 76, 74, /* 8+ */ 76, 73)
149 F(src0_da_reg_nr
, 76, 69)
150 F(src0_da16_subreg_nr
, 68, 68)
151 F(src0_da1_subreg_nr
, 68, 64)
152 F(src0_da16_swiz_y
, 67, 66)
153 F(src0_da16_swiz_x
, 65, 64)
154 F(dst_address_mode
, 63, 63)
155 F(dst_hstride
, 62, 61)
156 F8(dst_ia_subreg_nr
, /* 4+ */ 60, 58, /* 8+ */ 60, 57)
157 F(dst_da_reg_nr
, 60, 53)
158 F(dst_da16_subreg_nr
, 52, 52)
159 F(dst_da1_subreg_nr
, 52, 48)
160 F(da16_writemask
, 51, 48) /* Dst.ChanEn */
161 F8(src0_reg_type
, /* 4+ */ 41, 39, /* 8+ */ 46, 43)
162 F8(src0_reg_file
, /* 4+ */ 38, 37, /* 8+ */ 42, 41)
163 F8(dst_reg_type
, /* 4+ */ 36, 34, /* 8+ */ 40, 37)
164 F8(dst_reg_file
, /* 4+ */ 33, 32, /* 8+ */ 36, 35)
165 F8(mask_control
, /* 4+ */ 9, 9, /* 8+ */ 34, 34)
167 /* 4-6: doesn't exist */ -1, -1, -1, -1, -1, -1, -1, -1,
170 F8(flag_subreg_nr
, /* 4+ */ 89, 89, /* 8+ */ 32, 32)
172 FC(branch_control
, 30, 30, brw
->gen
>= 8)
173 F(debug_control
, 30, 30)
174 F(cmpt_control
, 29, 29)
175 F(acc_wr_control
, 28, 28)
176 F(cond_modifier
, 27, 24)
177 FC(math_function
, 27, 24, brw
->gen
>= 6)
180 F(pred_control
, 19, 16)
181 F(thread_control
, 15, 14)
182 F(qtr_control
, 13, 12)
184 /* 4-6: doesn't exist */ -1, -1, -1, -1, -1, -1, -1, -1,
187 F8(no_dd_check
, /* 4+ */ 11, 11, /* 8+ */ 10, 10)
188 F8(no_dd_clear
, /* 4+ */ 10, 10, /* 8+ */ 9, 9)
190 /* Bit 7 is Reserved (for future Opcode expansion) */
194 * Three-source instructions:
197 F(3src_src2_reg_nr
, 125, 118)
198 F(3src_src2_subreg_nr
, 117, 115) /* Extra discontiguous bit on CHV? */
199 F(3src_src2_swizzle
, 114, 107)
200 F(3src_src2_rep_ctrl
, 106, 106)
201 F(3src_src1_reg_nr
, 104, 97)
202 F(3src_src1_subreg_nr
, 96, 94) /* Extra discontiguous bit on CHV? */
203 F(3src_src1_swizzle
, 93, 86)
204 F(3src_src1_rep_ctrl
, 85, 85)
205 F(3src_src0_reg_nr
, 83, 76)
206 F(3src_src0_subreg_nr
, 75, 73) /* Extra discontiguous bit on CHV? */
207 F(3src_src0_swizzle
, 72, 65)
208 F(3src_src0_rep_ctrl
, 64, 64)
209 F(3src_dst_reg_nr
, 63, 56)
210 F(3src_dst_subreg_nr
, 55, 53)
211 F(3src_dst_writemask
, 52, 49)
212 F8(3src_nib_ctrl
, 47, 47, 11, 11) /* only exists on IVB+ */
213 F8(3src_dst_type
, 45, 44, 48, 46) /* only exists on IVB+ */
214 F8(3src_src_type
, 43, 42, 45, 43)
215 F8(3src_src2_negate
, 41, 41, 42, 42)
216 F8(3src_src2_abs
, 40, 40, 41, 41)
217 F8(3src_src1_negate
, 39, 39, 40, 40)
218 F8(3src_src1_abs
, 38, 38, 39, 39)
219 F8(3src_src0_negate
, 37, 37, 38, 38)
220 F8(3src_src0_abs
, 36, 36, 37, 37)
221 F8(3src_flag_reg_nr
, 34, 34, 33, 33)
222 F8(3src_flag_subreg_nr
, 33, 33, 32, 32)
223 FF(3src_dst_reg_file
,
224 /* 4-5: doesn't exist - no 3-source instructions */ -1, -1, -1, -1, -1, -1,
226 /* 7-8: doesn't exist - no MRFs */ -1, -1, -1, -1)
227 F(3src_saturate
, 31, 31)
228 F(3src_debug_control
, 30, 30)
229 F(3src_cmpt_control
, 29, 29)
230 F(3src_acc_wr_control
, 28, 28)
231 F(3src_cond_modifier
, 27, 24)
232 F(3src_exec_size
, 23, 21)
233 F(3src_pred_inv
, 20, 20)
234 F(3src_pred_control
, 19, 16)
235 F(3src_thread_control
, 15, 14)
236 F(3src_qtr_control
, 13, 12)
237 F8(3src_no_dd_check
, 11, 11, 10, 10)
238 F8(3src_no_dd_clear
, 10, 10, 9, 9)
239 F8(3src_mask_control
, 9, 9, 34, 34)
240 F(3src_access_mode
, 8, 8)
241 /* Bit 7 is Reserved (for future Opcode expansion) */
246 * Flow control instruction bits:
250 brw_inst_set_uip(const struct brw_context
*brw
,
251 brw_inst
*inst
, int32_t value
)
253 assert(brw
->gen
>= 6);
256 brw_inst_set_bits(inst
, 95, 64, (uint32_t)value
);
258 assert(value
<= (1 << 16) - 1);
259 assert(value
> -(1 << 16));
260 brw_inst_set_bits(inst
, 127, 112, (uint16_t)value
);
264 static inline int32_t
265 brw_inst_uip(const struct brw_context
*brw
, brw_inst
*inst
)
267 assert(brw
->gen
>= 6);
270 return brw_inst_bits(inst
, 95, 64);
272 return (int16_t)brw_inst_bits(inst
, 127, 112);
277 brw_inst_set_jip(const struct brw_context
*brw
,
278 brw_inst
*inst
, int32_t value
)
280 assert(brw
->gen
>= 6);
283 brw_inst_set_bits(inst
, 127, 96, (uint32_t)value
);
285 assert(value
<= (1 << 16) - 1);
286 assert(value
> -(1 << 16));
287 brw_inst_set_bits(inst
, 111, 96, (uint16_t)value
);
291 static inline int32_t
292 brw_inst_jip(const struct brw_context
*brw
, brw_inst
*inst
)
294 assert(brw
->gen
>= 6);
297 return brw_inst_bits(inst
, 127, 96);
299 return (int16_t)brw_inst_bits(inst
, 111, 96);
303 /** Like FC, but using int16_t to handle negative jump targets. */
304 #define FJ(name, high, low, assertions) \
306 brw_inst_set_##name(const struct brw_context *brw, brw_inst *inst, int16_t v) \
308 assert(assertions); \
310 brw_inst_set_bits(inst, high, low, (uint16_t) v); \
312 static inline int16_t \
313 brw_inst_##name(const struct brw_context *brw, brw_inst *inst) \
315 assert(assertions); \
317 return brw_inst_bits(inst, high, low); \
320 FJ(gen6_jump_count
, 63, 48, brw
->gen
== 6)
321 FJ(gen4_jump_count
, 111, 96, brw
->gen
< 6)
322 FC(gen4_pop_count
, 115, 112, brw
->gen
< 6)
326 * Fields for SEND messages:
345 /* 4: doesn't exist */ -1, -1, -1, -1,
358 /* 4: */ 123, 120, /* called msg_target */
364 FC(base_mrf
, 27, 24, brw
->gen
< 6);
367 /* Message descriptor bits */
368 #define MD(x) (x + 96)
371 * URB message function control bits:
374 FF(urb_per_slot_offset
,
375 /* 4-6: */ -1, -1, -1, -1, -1, -1, -1, -1,
376 /* 7: */ MD(16), MD(16),
377 /* 8: */ MD(17), MD(17))
378 FC(urb_complete
, MD(15), MD(15), brw
->gen
< 8)
379 FC(urb_used
, MD(14), MD(14), brw
->gen
< 7)
380 FC(urb_allocate
, MD(13), MD(13), brw
->gen
< 7)
381 FF(urb_swizzle_control
,
382 /* 4: */ MD(11), MD(10),
383 /* 4.5: */ MD(11), MD(10),
384 /* 5: */ MD(11), MD(10),
385 /* 6: */ MD(11), MD(10),
386 /* 7: */ MD(14), MD(14),
387 /* 8: */ MD(15), MD(15))
388 FF(urb_global_offset
,
389 /* 4: */ MD( 9), MD(4),
390 /* 4.5: */ MD( 9), MD(4),
391 /* 5: */ MD( 9), MD(4),
392 /* 6: */ MD( 9), MD(4),
393 /* 7: */ MD(13), MD(3),
394 /* 8: */ MD(14), MD(4))
396 /* 4: */ MD( 3), MD(0),
397 /* 4.5: */ MD( 3), MD(0),
398 /* 5: */ MD( 3), MD(0),
399 /* 6: */ MD( 3), MD(0),
400 /* 7: */ MD( 2), MD(0),
401 /* 8: */ MD( 3), MD(0))
405 * Gen4-5 math messages:
408 FC(math_msg_data_type
, MD(7), MD(7), brw
->gen
< 6)
409 FC(math_msg_saturate
, MD(6), MD(6), brw
->gen
< 6)
410 FC(math_msg_precision
, MD(5), MD(5), brw
->gen
< 6)
411 FC(math_msg_signed_int
, MD(4), MD(4), brw
->gen
< 6)
412 FC(math_msg_function
, MD(3), MD(0), brw
->gen
< 6)
416 * Sampler message function control bits:
419 FF(sampler_simd_mode
,
420 /* 4: doesn't exist */ -1, -1, -1, -1,
421 /* 5: */ MD(17), MD(16),
422 /* 6: */ MD(17), MD(16),
423 /* 7: */ MD(18), MD(17),
424 /* 8: */ MD(18), MD(17))
426 /* 4: */ MD(15), MD(14),
427 /* 4.5: */ MD(15), MD(12),
428 /* 5: */ MD(15), MD(12),
429 /* 6: */ MD(15), MD(12),
430 /* 7: */ MD(16), MD(12),
431 /* 8: */ MD(16), MD(12))
432 FC(sampler_return_format
, MD(13), MD(12), brw
->gen
== 4 && !brw
->is_g4x
)
433 F(sampler
, MD(11), MD(8))
434 F(binding_table_index
, MD( 7), MD(0)) /* also used by other messages */
438 * Data port message function control bits:
441 FC(dp_category
, MD(18), MD(18), brw
->gen
>= 7)
443 /* Gen4-5 store fields in different bits for read/write messages. */
445 /* 4: */ MD(13), MD(12),
446 /* 4.5: */ MD(13), MD(11),
447 /* 5: */ MD(13), MD(11),
448 /* 6: */ MD(16), MD(13),
449 /* 7: */ MD(17), MD(14),
450 /* 8: */ MD(17), MD(14))
451 FF(dp_write_msg_type
,
452 /* 4: */ MD(14), MD(12),
453 /* 4.5: */ MD(14), MD(12),
454 /* 5: */ MD(14), MD(12),
455 /* 6: */ MD(16), MD(13),
456 /* 7: */ MD(17), MD(14),
457 /* 8: */ MD(17), MD(14))
458 FF(dp_read_msg_control
,
459 /* 4: */ MD(11), MD( 8),
460 /* 4.5: */ MD(10), MD( 8),
461 /* 5: */ MD(10), MD( 8),
462 /* 6: */ MD(12), MD( 8),
463 /* 7: */ MD(13), MD( 8),
464 /* 8: */ MD(13), MD( 8))
465 FF(dp_write_msg_control
,
466 /* 4: */ MD(11), MD( 8),
467 /* 4.5: */ MD(11), MD( 8),
468 /* 5: */ MD(11), MD( 8),
469 /* 6: */ MD(12), MD( 8),
470 /* 7: */ MD(13), MD( 8),
471 /* 8: */ MD(13), MD( 8))
472 FC(dp_read_target_cache
, MD(15), MD(14), brw
->gen
< 6);
475 /* 4: */ MD(15), MD(15),
476 /* 4.5: */ MD(15), MD(15),
477 /* 5: */ MD(15), MD(15),
478 /* 6: */ MD(17), MD(17),
479 /* 7+: does not exist */ -1, -1, -1, -1)
481 /* Gen6+ use the same bit locations for everything. */
483 /* 4-5: use dp_read_msg_type or dp_write_msg_type instead */
484 -1, -1, -1, -1, -1, -1,
485 /* 6: */ MD(16), MD(13),
486 /* 7: */ MD(17), MD(14),
487 /* 8: */ MD(17), MD(14))
489 /* 4: */ MD(11), MD( 8),
490 /* 4.5-5: use dp_read_msg_control or dp_write_msg_control */ -1, -1, -1, -1,
491 /* 6: */ MD(12), MD( 8),
492 /* 7: */ MD(13), MD( 8),
493 /* 8: */ MD(13), MD( 8))
497 * Scratch message bits (Gen7+):
500 FC(scratch_read_write
, MD(17), MD(17), brw
->gen
>= 7) /* 0 = read, 1 = write */
501 FC(scratch_type
, MD(16), MD(16), brw
->gen
>= 7) /* 0 = OWord, 1 = DWord */
502 FC(scratch_invalidate_after_read
, MD(15), MD(15), brw
->gen
>= 7)
503 FC(scratch_block_size
, MD(13), MD(12), brw
->gen
>= 7)
504 FC(scratch_addr_offset
, MD(11), MD( 0), brw
->gen
>= 7)
508 * Render Target message function control bits:
512 /* 4: */ MD(11), MD(11),
513 /* 4.5: */ MD(11), MD(11),
514 /* 5: */ MD(11), MD(11),
515 /* 6: */ MD(12), MD(12),
516 /* 7: */ MD(12), MD(12),
517 /* 8: */ MD(12), MD(12))
518 FC(rt_slot_group
, MD(11), MD(11), brw
->gen
>= 6)
519 F(rt_message_type
, MD(10), MD( 8))
523 * Thread Spawn message function control bits:
526 F(ts_resource_select
, MD( 4), MD( 4))
527 F(ts_request_type
, MD( 1), MD( 1))
528 F(ts_opcode
, MD( 0), MD( 0))
532 * Pixel Interpolator message function control bits:
535 F(pi_simd_mode
, MD(16), MD(16))
536 F(pi_nopersp
, MD(14), MD(14))
537 F(pi_message_type
, MD(13), MD(12))
538 F(pi_slot_group
, MD(11), MD(11))
539 F(pi_message_data
, MD(7), MD(0))
547 brw_inst_imm_d(const struct brw_context
*brw
, brw_inst
*insn
)
550 return brw_inst_bits(insn
, 127, 96);
553 static inline unsigned
554 brw_inst_imm_ud(const struct brw_context
*brw
, brw_inst
*insn
)
557 return brw_inst_bits(insn
, 127, 96);
561 brw_inst_imm_f(const struct brw_context
*brw
, brw_inst
*insn
)
565 ft
.u
= brw_inst_bits(insn
, 127, 96);
570 brw_inst_set_imm_d(const struct brw_context
*brw
,
571 brw_inst
*insn
, int value
)
574 return brw_inst_set_bits(insn
, 127, 96, value
);
578 brw_inst_set_imm_ud(const struct brw_context
*brw
,
579 brw_inst
*insn
, unsigned value
)
582 return brw_inst_set_bits(insn
, 127, 96, value
);
586 brw_inst_set_imm_f(const struct brw_context
*brw
,
587 brw_inst
*insn
, float value
)
592 brw_inst_set_bits(insn
, 127, 96, ft
.u
);
597 /* The AddrImm fields are split into two discontiguous sections on Gen8+ */
598 #define BRW_IA1_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low) \
600 brw_inst_set_##reg##_ia1_addr_imm(const struct brw_context *brw, \
604 assert((value & ~0x3ff) == 0); \
605 if (brw->gen >= 8) { \
606 brw_inst_set_bits(inst, g8_high, g8_low, value & 0x1ff); \
607 brw_inst_set_bits(inst, g8_nine, g8_nine, value >> 9); \
609 brw_inst_set_bits(inst, g4_high, g4_low, value); \
612 static inline unsigned \
613 brw_inst_##reg##_ia1_addr_imm(const struct brw_context *brw, \
616 if (brw->gen >= 8) { \
617 return brw_inst_bits(inst, g8_high, g8_low) | \
618 (brw_inst_bits(inst, g8_nine, g8_nine) << 9); \
620 return brw_inst_bits(inst, g4_high, g4_low); \
624 /* AddrImm[9:0] for Align1 Indirect Addressing */
625 /* -Gen 4- ----Gen8---- */
626 BRW_IA1_ADDR_IMM(src1
, 105, 96, 121, 104, 96)
627 BRW_IA1_ADDR_IMM(src0
, 73, 64, 95, 72, 64)
628 BRW_IA1_ADDR_IMM(dst
, 57, 48, 47, 56, 48)
630 #define BRW_IA16_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low) \
632 brw_inst_set_##reg##_ia16_addr_imm(const struct brw_context *brw, \
633 brw_inst *inst, unsigned value) \
635 assert((value & ~0x3ff) == 0); \
636 if (brw->gen >= 8) { \
637 brw_inst_set_bits(inst, g8_high, g8_low, value & 0x1ff); \
638 brw_inst_set_bits(inst, g8_nine, g8_nine, value >> 9); \
640 brw_inst_set_bits(inst, g4_high, g4_low, value >> 9); \
643 static inline unsigned \
644 brw_inst_##reg##_ia16_addr_imm(const struct brw_context *brw, \
647 if (brw->gen >= 8) { \
648 return brw_inst_bits(inst, g8_high, g8_low) | \
649 (brw_inst_bits(inst, g8_nine, g8_nine) << 9); \
651 return brw_inst_bits(inst, g4_high, g4_low); \
655 /* AddrImm[9:0] for Align16 Indirect Addressing:
656 * Compared to Align1, these are missing the low 4 bits.
657 * -Gen 4- ----Gen8----
659 BRW_IA16_ADDR_IMM(src1
, 105, 96, 121, 104, 100)
660 BRW_IA16_ADDR_IMM(src0
, 73, 64, 95, 72, 68)
661 BRW_IA16_ADDR_IMM(dst
, 57, 52, 47, 56, 52)
664 * Fetch a set of contiguous bits from the instruction.
666 * Bits indices range from 0..127; fields may not cross 64-bit boundaries.
668 static inline uint64_t
669 brw_inst_bits(brw_inst
*inst
, unsigned high
, unsigned low
)
671 /* We assume the field doesn't cross 64-bit boundaries. */
672 const unsigned word
= high
/ 64;
673 assert(word
== low
/ 64);
678 const uint64_t mask
= (((1ull << (high
- low
+ 1)) - 1) << low
);
680 return (inst
->data
[word
] & mask
) >> low
;
684 * Set bits in the instruction, with proper shifting and masking.
686 * Bits indices range from 0..127; fields may not cross 64-bit boundaries.
689 brw_inst_set_bits(brw_inst
*inst
, unsigned high
, unsigned low
, uint64_t value
)
691 const unsigned word
= high
/ 64;
692 assert(word
== low
/ 64);
697 const uint64_t mask
= (((1ull << (high
- low
+ 1)) - 1) << low
);
699 /* Make sure the supplied value actually fits in the given bitfield. */
700 assert((value
& (mask
>> low
)) == value
);
702 inst
->data
[word
] = (inst
->data
[word
] & ~mask
) | ((value
<< low
) & mask
);
705 #undef BRW_IA16_ADDR_IMM
706 #undef BRW_IA1_ADDR_IMM
719 * Fetch a set of contiguous bits from the compacted instruction.
721 * Bits indices range from 0..63.
723 static inline unsigned
724 brw_compact_inst_bits(brw_compact_inst
*inst
, unsigned high
, unsigned low
)
726 const uint64_t mask
= (((1ull << (high
- low
+ 1)) - 1) << low
);
728 return (inst
->data
& mask
) >> low
;
732 * Set bits in the compacted instruction.
734 * Bits indices range from 0..63.
737 brw_compact_inst_set_bits(brw_compact_inst
*inst
, unsigned high
, unsigned low
,
740 const uint64_t mask
= (((1ull << (high
- low
+ 1)) - 1) << low
);
742 /* Make sure the supplied value actually fits in the given bitfield. */
743 assert((value
& (mask
>> low
)) == value
);
745 inst
->data
= (inst
->data
& ~mask
) | ((value
<< low
) & mask
);
748 #define F(name, high, low) \
750 brw_compact_inst_set_##name(brw_compact_inst *inst, unsigned v) \
752 brw_compact_inst_set_bits(inst, high, low, v); \
755 static inline unsigned \
756 brw_compact_inst_##name(brw_compact_inst *inst) \
758 return brw_compact_inst_bits(inst, high, low); \
761 F(src1_reg_nr
, 63, 56)
762 F(src0_reg_nr
, 55, 48)
763 F(dst_reg_nr
, 47, 40)
764 F(src1_index
, 39, 35)
765 F(src0_index
, 34, 30)
766 F(cmpt_control
, 29, 29) /* Same location as brw_inst */
767 F(flag_subreg_nr
, 28, 28) /* <= Gen6 only */
768 F(cond_modifier
, 27, 24) /* Same location as brw_inst */
769 F(acc_wr_control
, 23, 23)
770 F(subreg_index
, 22, 18)
771 F(datatype_index
, 17, 13)
772 F(control_index
, 12, 8)
773 F(debug_control
, 7, 7)
774 F(opcode
, 6, 0) /* Same location as brw_inst */
777 * (Gen8+) Compacted three-source instructions:
780 F(3src_src2_reg_nr
, 63, 57)
781 F(3src_src1_reg_nr
, 56, 50)
782 F(3src_src0_reg_nr
, 49, 43)
783 F(3src_src2_subreg_nr
, 42, 40)
784 F(3src_src1_subreg_nr
, 39, 37)
785 F(3src_src0_subreg_nr
, 36, 34)
786 F(3src_src2_rep_ctrl
, 33, 33)
787 F(3src_src1_rep_ctrl
, 32, 32)
788 F(3src_saturate
, 31, 31)
789 F(3src_debug_control
, 30, 30)
790 F(3src_cmpt_control
, 29, 29)
791 F(3src_src0_rep_ctrl
, 28, 28)
793 F(3src_dst_reg_nr
, 18, 12)
794 F(3src_source_index
, 11, 10)
795 F(3src_control_index
, 9, 8)
796 /* Bit 7 is Reserved (for future Opcode expansion) */