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.
37
#include "brw_eu_defines.h"
38
#include "brw_reg_type.h"
39
#include "dev/intel_device_info.h"
45
/* brw_context.h has a forward declaration of brw_inst, so name the struct. */
46
typedef struct brw_inst {
50
static inline uint64_t brw_inst_bits(const brw_inst *inst,
51
unsigned high, unsigned low);
52
static inline void brw_inst_set_bits(brw_inst *inst,
53
unsigned high, unsigned low,
56
#define FC(name, hi4, lo4, hi12, lo12, assertions) \
58
brw_inst_set_##name(const struct intel_device_info *devinfo, \
59
brw_inst *inst, uint64_t v) \
62
if (devinfo->ver >= 12) \
63
brw_inst_set_bits(inst, hi12, lo12, v); \
65
brw_inst_set_bits(inst, hi4, lo4, v); \
67
static inline uint64_t \
68
brw_inst_##name(const struct intel_device_info *devinfo, \
69
const brw_inst *inst) \
72
if (devinfo->ver >= 12) \
73
return brw_inst_bits(inst, hi12, lo12); \
75
return brw_inst_bits(inst, hi4, lo4); \
78
/* A simple macro for fields which stay in the same place on all generations,
81
#define F(name, hi4, lo4, hi12, lo12) FC(name, hi4, lo4, hi12, lo12, true)
83
#define BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
84
hi7, lo7, hi8, lo8, hi12, lo12) \
86
if (devinfo->ver >= 12) { \
87
high = hi12; low = lo12; \
88
} else if (devinfo->ver >= 8) { \
89
high = hi8; low = lo8; \
90
} else if (devinfo->ver >= 7) { \
91
high = hi7; low = lo7; \
92
} else if (devinfo->ver >= 6) { \
93
high = hi6; low = lo6; \
94
} else if (devinfo->ver >= 5) { \
95
high = hi5; low = lo5; \
96
} else if (devinfo->verx10 >= 45) { \
97
high = hi45; low = lo45; \
99
high = hi4; low = lo4; \
101
assert(((int) high) != -1 && ((int) low) != -1);
103
/* A general macro for cases where the field has moved to several different
104
* bit locations across generations. GCC appears to combine cases where the
105
* bits are identical, removing some of the inefficiency.
107
#define FF(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
108
hi7, lo7, hi8, lo8, hi12, lo12) \
110
brw_inst_set_##name(const struct intel_device_info *devinfo, \
111
brw_inst *inst, uint64_t value) \
113
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
114
hi7, lo7, hi8, lo8, hi12, lo12) \
115
brw_inst_set_bits(inst, high, low, value); \
117
static inline uint64_t \
118
brw_inst_##name(const struct intel_device_info *devinfo, const brw_inst *inst)\
120
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
121
hi7, lo7, hi8, lo8, hi12, lo12) \
122
return brw_inst_bits(inst, high, low); \
125
/* A macro for fields which moved as of Gfx8+. */
126
#define F8(name, gfx4_high, gfx4_low, gfx8_high, gfx8_low, \
127
gfx12_high, gfx12_low) \
129
/* 4: */ gfx4_high, gfx4_low, \
130
/* 4.5: */ gfx4_high, gfx4_low, \
131
/* 5: */ gfx4_high, gfx4_low, \
132
/* 6: */ gfx4_high, gfx4_low, \
133
/* 7: */ gfx4_high, gfx4_low, \
134
/* 8: */ gfx8_high, gfx8_low, \
135
/* 12: */ gfx12_high, gfx12_low);
137
/* Macro for fields that gained extra discontiguous MSBs in Gfx12 (specified
140
#define FFDC(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
141
hi7, lo7, hi8, lo8, hi12ex, lo12ex, hi12, lo12, assertions) \
143
brw_inst_set_##name(const struct intel_device_info *devinfo, \
144
brw_inst *inst, uint64_t value) \
146
assert(assertions); \
147
if (devinfo->ver >= 12) { \
148
const unsigned k = hi12 - lo12 + 1; \
149
if (hi12ex != -1 && lo12ex != -1) \
150
brw_inst_set_bits(inst, hi12ex, lo12ex, value >> k); \
151
brw_inst_set_bits(inst, hi12, lo12, value & ((1ull << k) - 1)); \
153
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
154
hi7, lo7, hi8, lo8, -1, -1); \
155
brw_inst_set_bits(inst, high, low, value); \
158
static inline uint64_t \
159
brw_inst_##name(const struct intel_device_info *devinfo, const brw_inst *inst)\
161
assert(assertions); \
162
if (devinfo->ver >= 12) { \
163
const unsigned k = hi12 - lo12 + 1; \
164
return (hi12ex == -1 || lo12ex == -1 ? 0 : \
165
brw_inst_bits(inst, hi12ex, lo12ex) << k) | \
166
brw_inst_bits(inst, hi12, lo12); \
168
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
169
hi7, lo7, hi8, lo8, -1, -1); \
170
return brw_inst_bits(inst, high, low); \
174
#define FD(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
175
hi7, lo7, hi8, lo8, hi12ex, lo12ex, hi12, lo12) \
176
FFDC(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, \
177
hi7, lo7, hi8, lo8, hi12ex, lo12ex, hi12, lo12, true)
179
/* Macro for fields that didn't move across generations until Gfx12, and then
180
* gained extra discontiguous bits.
182
#define FDC(name, hi4, lo4, hi12ex, lo12ex, hi12, lo12, assertions) \
183
FFDC(name, hi4, lo4, hi4, lo4, hi4, lo4, hi4, lo4, \
184
hi4, lo4, hi4, lo4, hi12ex, lo12ex, hi12, lo12, assertions)
187
/* Macro for the 2-bit register file field, which on Gfx12+ is stored as the
188
* variable length combination of an IsImm (hi12) bit and an additional file
191
#define FI(name, hi4, lo4, hi8, lo8, hi12, lo12) \
193
brw_inst_set_##name(const struct intel_device_info *devinfo, \
194
brw_inst *inst, uint64_t value) \
196
if (devinfo->ver >= 12) { \
197
brw_inst_set_bits(inst, hi12, hi12, value >> 1); \
198
if ((value >> 1) == 0) \
199
brw_inst_set_bits(inst, lo12, lo12, value & 1); \
201
BOUNDS(hi4, lo4, hi4, lo4, hi4, lo4, hi4, lo4, \
202
hi4, lo4, hi8, lo8, -1, -1); \
203
brw_inst_set_bits(inst, high, low, value); \
206
static inline uint64_t \
207
brw_inst_##name(const struct intel_device_info *devinfo, const brw_inst *inst)\
209
if (devinfo->ver >= 12) { \
210
return (brw_inst_bits(inst, hi12, hi12) << 1) | \
211
(brw_inst_bits(inst, hi12, hi12) == 0 ? \
212
brw_inst_bits(inst, lo12, lo12) : 1); \
214
BOUNDS(hi4, lo4, hi4, lo4, hi4, lo4, hi4, lo4, \
215
hi4, lo4, hi8, lo8, -1, -1); \
216
return brw_inst_bits(inst, high, low); \
220
/* Macro for fields that become a constant in Gfx12+ not actually represented
221
* in the instruction.
223
#define FK(name, hi4, lo4, const12) \
225
brw_inst_set_##name(const struct intel_device_info *devinfo, \
226
brw_inst *inst, uint64_t v) \
228
if (devinfo->ver >= 12) \
229
assert(v == (const12)); \
231
brw_inst_set_bits(inst, hi4, lo4, v); \
233
static inline uint64_t \
234
brw_inst_##name(const struct intel_device_info *devinfo, \
235
const brw_inst *inst) \
237
if (devinfo->ver >= 12) \
240
return brw_inst_bits(inst, hi4, lo4); \
243
F(src1_vstride, /* 4+ */ 120, 117, /* 12+ */ 119, 116)
244
F(src1_width, /* 4+ */ 116, 114, /* 12+ */ 115, 113)
245
F(src1_da16_swiz_w, /* 4+ */ 115, 114, /* 12+ */ -1, -1)
246
F(src1_da16_swiz_z, /* 4+ */ 113, 112, /* 12+ */ -1, -1)
247
F(src1_hstride, /* 4+ */ 113, 112, /* 12+ */ 97, 96)
248
F(src1_address_mode, /* 4+ */ 111, 111, /* 12+ */ 112, 112)
249
/** Src1.SrcMod @{ */
250
F(src1_negate, /* 4+ */ 110, 110, /* 12+ */ 121, 121)
251
F(src1_abs, /* 4+ */ 109, 109, /* 12+ */ 120, 120)
253
F8(src1_ia_subreg_nr, /* 4+ */ 108, 106, /* 8+ */ 108, 105, /* 12+ */ 111, 108)
254
F(src1_da_reg_nr, /* 4+ */ 108, 101, /* 12+ */ 111, 104)
255
F(src1_da16_subreg_nr, /* 4+ */ 100, 100, /* 12+ */ -1, -1)
256
F(src1_da1_subreg_nr, /* 4+ */ 100, 96, /* 12+ */ 103, 99)
257
F(src1_da16_swiz_y, /* 4+ */ 99, 98, /* 12+ */ -1, -1)
258
F(src1_da16_swiz_x, /* 4+ */ 97, 96, /* 12+ */ -1, -1)
259
F8(src1_reg_hw_type, /* 4+ */ 46, 44, /* 8+ */ 94, 91, /* 12+ */ 91, 88)
260
FI(src1_reg_file, /* 4+ */ 43, 42, /* 8+ */ 90, 89, /* 12+ */ 47, 98)
261
F(src1_is_imm, /* 4+ */ -1, -1, /* 12+ */ 47, 47)
262
F(src0_vstride, /* 4+ */ 88, 85, /* 12+ */ 87, 84)
263
F(src0_width, /* 4+ */ 84, 82, /* 12+ */ 83, 81)
264
F(src0_da16_swiz_w, /* 4+ */ 83, 82, /* 12+ */ -1, -1)
265
F(src0_da16_swiz_z, /* 4+ */ 81, 80, /* 12+ */ -1, -1)
266
F(src0_hstride, /* 4+ */ 81, 80, /* 12+ */ 65, 64)
267
F(src0_address_mode, /* 4+ */ 79, 79, /* 12+ */ 80, 80)
268
/** Src0.SrcMod @{ */
269
F(src0_negate, /* 4+ */ 78, 78, /* 12+ */ 45, 45)
270
F(src0_abs, /* 4+ */ 77, 77, /* 12+ */ 44, 44)
272
F8(src0_ia_subreg_nr, /* 4+ */ 76, 74, /* 8+ */ 76, 73, /* 12+ */ 79, 76)
273
F(src0_da_reg_nr, /* 4+ */ 76, 69, /* 12+ */ 79, 72)
274
F(src0_da16_subreg_nr, /* 4+ */ 68, 68, /* 12+ */ -1, -1)
275
F(src0_da1_subreg_nr, /* 4+ */ 68, 64, /* 12+ */ 71, 67)
276
F(src0_da16_swiz_y, /* 4+ */ 67, 66, /* 12+ */ -1, -1)
277
F(src0_da16_swiz_x, /* 4+ */ 65, 64, /* 12+ */ -1, -1)
278
F(dst_address_mode, /* 4+ */ 63, 63, /* 12+ */ 35, 35)
279
F(dst_hstride, /* 4+ */ 62, 61, /* 12+ */ 49, 48)
280
F8(dst_ia_subreg_nr, /* 4+ */ 60, 58, /* 8+ */ 60, 57, /* 12+ */ 63, 60)
281
F(dst_da_reg_nr, /* 4+ */ 60, 53, /* 12+ */ 63, 56)
282
F(dst_da16_subreg_nr, /* 4+ */ 52, 52, /* 12+ */ -1, -1)
283
F(dst_da1_subreg_nr, /* 4+ */ 52, 48, /* 12+ */ 55, 51)
284
F(da16_writemask, /* 4+ */ 51, 48, /* 12+ */ -1, -1) /* Dst.ChanEn */
285
F8(src0_reg_hw_type, /* 4+ */ 41, 39, /* 8+ */ 46, 43, /* 12+ */ 43, 40)
286
FI(src0_reg_file, /* 4+ */ 38, 37, /* 8+ */ 42, 41, /* 12+ */ 46, 66)
287
F(src0_is_imm, /* 4+ */ -1, -1, /* 12+ */ 46, 46)
288
F8(dst_reg_hw_type, /* 4+ */ 36, 34, /* 8+ */ 40, 37, /* 12+ */ 39, 36)
289
F8(dst_reg_file, /* 4+ */ 33, 32, /* 8+ */ 36, 35, /* 12+ */ 50, 50)
290
F8(mask_control, /* 4+ */ 9, 9, /* 8+ */ 34, 34, /* 12+ */ 31, 31)
292
/* 4-6: doesn't exist */ -1, -1, -1, -1, -1, -1, -1, -1,
296
F8(flag_subreg_nr, /* 4+ */ 89, 89, /* 8+ */ 32, 32, /* 12+ */ 22, 22)
297
F(saturate, /* 4+ */ 31, 31, /* 12+ */ 34, 34)
298
F(debug_control, /* 4+ */ 30, 30, /* 12+ */ 30, 30)
299
F(cmpt_control, /* 4+ */ 29, 29, /* 12+ */ 29, 29)
300
FC(branch_control, /* 4+ */ 28, 28, /* 12+ */ 33, 33, devinfo->ver >= 8)
301
FC(acc_wr_control, /* 4+ */ 28, 28, /* 12+ */ 33, 33, devinfo->ver >= 6)
302
FC(mask_control_ex, /* 4+ */ 28, 28, /* 12+ */ -1, -1, devinfo->verx10 == 45 ||
304
F(cond_modifier, /* 4+ */ 27, 24, /* 12+ */ 95, 92)
305
FC(math_function, /* 4+ */ 27, 24, /* 12+ */ 95, 92, devinfo->ver >= 6)
306
F(exec_size, /* 4+ */ 23, 21, /* 12+ */ 18, 16)
307
F(pred_inv, /* 4+ */ 20, 20, /* 12+ */ 28, 28)
308
F(pred_control, /* 4+ */ 19, 16, /* 12+ */ 27, 24)
309
F(thread_control, /* 4+ */ 15, 14, /* 12+ */ -1, -1)
310
F(atomic_control, /* 4+ */ -1, -1, /* 12+ */ 32, 32)
311
F(qtr_control, /* 4+ */ 13, 12, /* 12+ */ 21, 20)
313
/* 4-6: doesn't exist */ -1, -1, -1, -1, -1, -1, -1, -1,
317
F8(no_dd_check, /* 4+ */ 11, 11, /* 8+ */ 10, 10, /* 12+ */ -1, -1)
318
F8(no_dd_clear, /* 4+ */ 10, 10, /* 8+ */ 9, 9, /* 12+ */ -1, -1)
319
F(swsb, /* 4+ */ -1, -1, /* 12+ */ 15, 8)
320
FK(access_mode, /* 4+ */ 8, 8, /* 12+ */ BRW_ALIGN_1)
321
/* Bit 7 is Reserved (for future Opcode expansion) */
322
F(hw_opcode, /* 4+ */ 6, 0, /* 12+ */ 6, 0)
325
* Three-source instructions:
328
F(3src_src2_reg_nr, /* 4+ */ 125, 118, /* 12+ */ 127, 120) /* same in align1 */
329
F(3src_a16_src2_subreg_nr, /* 4+ */ 117, 115, /* 12+ */ -1, -1) /* Extra discontiguous bit on CHV? */
330
F(3src_a16_src2_swizzle, /* 4+ */ 114, 107, /* 12+ */ -1, -1)
331
F(3src_a16_src2_rep_ctrl, /* 4+ */ 106, 106, /* 12+ */ -1, -1)
332
F(3src_src1_reg_nr, /* 4+ */ 104, 97, /* 12+ */ 111, 104) /* same in align1 */
333
F(3src_a16_src1_subreg_nr, /* 4+ */ 96, 94, /* 12+ */ -1, -1) /* Extra discontiguous bit on CHV? */
334
F(3src_a16_src1_swizzle, /* 4+ */ 93, 86, /* 12+ */ -1, -1)
335
F(3src_a16_src1_rep_ctrl, /* 4+ */ 85, 85, /* 12+ */ -1, -1)
336
F(3src_src0_reg_nr, /* 4+ */ 83, 76, /* 12+ */ 79, 72) /* same in align1 */
337
F(3src_a16_src0_subreg_nr, /* 4+ */ 75, 73, /* 12+ */ -1, -1) /* Extra discontiguous bit on CHV? */
338
F(3src_a16_src0_swizzle, /* 4+ */ 72, 65, /* 12+ */ -1, -1)
339
F(3src_a16_src0_rep_ctrl, /* 4+ */ 64, 64, /* 12+ */ -1, -1)
340
F(3src_dst_reg_nr, /* 4+ */ 63, 56, /* 12+ */ 63, 56) /* same in align1 */
341
F(3src_a16_dst_subreg_nr, /* 4+ */ 55, 53, /* 12+ */ -1, -1)
342
F(3src_a16_dst_writemask, /* 4+ */ 52, 49, /* 12+ */ -1, -1)
343
F8(3src_a16_nib_ctrl, /* 4+ */ 47, 47, /* 8+ */ 11, 11, /* 12+ */ -1, -1) /* only exists on IVB+ */
344
F8(3src_a16_dst_hw_type, /* 4+ */ 45, 44, /* 8+ */ 48, 46, /* 12+ */ -1, -1) /* only exists on IVB+ */
345
F8(3src_a16_src_hw_type, /* 4+ */ 43, 42, /* 8+ */ 45, 43, /* 12+ */ -1, -1)
346
F8(3src_src2_negate, /* 4+ */ 41, 41, /* 8+ */ 42, 42, /* 12+ */ 85, 85)
347
F8(3src_src2_abs, /* 4+ */ 40, 40, /* 8+ */ 41, 41, /* 12+ */ 84, 84)
348
F8(3src_src1_negate, /* 4+ */ 39, 39, /* 8+ */ 40, 40, /* 12+ */ 87, 87)
349
F8(3src_src1_abs, /* 4+ */ 38, 38, /* 8+ */ 39, 39, /* 12+ */ 86, 86)
350
F8(3src_src0_negate, /* 4+ */ 37, 37, /* 8+ */ 38, 38, /* 12+ */ 45, 45)
351
F8(3src_src0_abs, /* 4+ */ 36, 36, /* 8+ */ 37, 37, /* 12+ */ 44, 44)
352
F8(3src_a16_src1_type, /* 4+ */ -1, -1, /* 8+ */ 36, 36, /* 12+ */ -1, -1)
353
F8(3src_a16_src2_type, /* 4+ */ -1, -1, /* 8+ */ 35, 35, /* 12+ */ -1, -1)
354
F8(3src_a16_flag_reg_nr, /* 4+ */ 34, 34, /* 8+ */ 33, 33, /* 12+ */ -1, -1)
355
F8(3src_a16_flag_subreg_nr, /* 4+ */ 33, 33, /* 8+ */ 32, 32, /* 12+ */ -1, -1)
356
FF(3src_a16_dst_reg_file,
357
/* 4-5: doesn't exist - no 3-source instructions */ -1, -1, -1, -1, -1, -1,
359
/* 7-8: doesn't exist - no MRFs */ -1, -1, -1, -1,
361
F(3src_saturate, /* 4+ */ 31, 31, /* 12+ */ 34, 34)
362
F(3src_debug_control, /* 4+ */ 30, 30, /* 12+ */ 30, 30)
363
F(3src_cmpt_control, /* 4+ */ 29, 29, /* 12+ */ 29, 29)
364
F(3src_acc_wr_control, /* 4+ */ 28, 28, /* 12+ */ 33, 33)
365
F(3src_cond_modifier, /* 4+ */ 27, 24, /* 12+ */ 95, 92)
366
F(3src_exec_size, /* 4+ */ 23, 21, /* 12+ */ 18, 16)
367
F(3src_pred_inv, /* 4+ */ 20, 20, /* 12+ */ 28, 28)
368
F(3src_pred_control, /* 4+ */ 19, 16, /* 12+ */ 27, 24)
369
F(3src_thread_control, /* 4+ */ 15, 14, /* 12+ */ -1, -1)
370
F(3src_atomic_control, /* 4+ */ -1, -1, /* 12+ */ 32, 32)
371
F(3src_qtr_control, /* 4+ */ 13, 12, /* 12+ */ 21, 20)
372
F8(3src_no_dd_check, /* 4+ */ 11, 11, /* 8+ */ 10, 10, /* 12+ */ -1, -1)
373
F8(3src_no_dd_clear, /* 4+ */ 10, 10, /* 8+ */ 9, 9, /* 12+ */ -1, -1)
374
F8(3src_mask_control, /* 4+ */ 9, 9, /* 8+ */ 34, 34, /* 12+ */ 31, 31)
375
FK(3src_access_mode, /* 4+ */ 8, 8, /* 12+ */ BRW_ALIGN_1)
376
F(3src_swsb, /* 4+ */ -1, -1, /* 12+ */ 15, 8)
377
/* Bit 7 is Reserved (for future Opcode expansion) */
378
F(3src_hw_opcode, /* 4+ */ 6, 0, /* 12+ */ 6, 0)
381
#define REG_TYPE(reg) \
383
brw_inst_set_3src_a16_##reg##_type(const struct intel_device_info *devinfo, \
384
brw_inst *inst, enum brw_reg_type type) \
386
unsigned hw_type = brw_reg_type_to_a16_hw_3src_type(devinfo, type); \
387
brw_inst_set_3src_a16_##reg##_hw_type(devinfo, inst, hw_type); \
390
static inline enum brw_reg_type \
391
brw_inst_3src_a16_##reg##_type(const struct intel_device_info *devinfo, \
392
const brw_inst *inst) \
394
unsigned hw_type = brw_inst_3src_a16_##reg##_hw_type(devinfo, inst); \
395
return brw_a16_hw_3src_type_to_reg_type(devinfo, hw_type); \
403
* Three-source align1 instructions:
406
/* Reserved 127:126 */
407
/* src2_reg_nr same in align16 */
408
FC(3src_a1_src2_subreg_nr, /* 4+ */ 117, 113, /* 12+ */ 119, 115, devinfo->ver >= 10)
409
FC(3src_a1_src2_hstride, /* 4+ */ 112, 111, /* 12+ */ 113, 112, devinfo->ver >= 10)
410
/* Reserved 110:109. src2 vstride is an implied parameter */
411
FC(3src_a1_src2_hw_type, /* 4+ */ 108, 106, /* 12+ */ 82, 80, devinfo->ver >= 10)
413
/* src1_reg_nr same in align16 */
414
FC(3src_a1_src1_subreg_nr, /* 4+ */ 96, 92, /* 12+ */ 103, 99, devinfo->ver >= 10)
415
FC(3src_a1_src1_hstride, /* 4+ */ 91, 90, /* 12+ */ 97, 96, devinfo->ver >= 10)
416
FDC(3src_a1_src1_vstride, /* 4+ */ 89, 88, /* 12+ */ 91, 91, 83, 83, devinfo->ver >= 10)
417
FC(3src_a1_src1_hw_type, /* 4+ */ 87, 85, /* 12+ */ 90, 88, devinfo->ver >= 10)
419
/* src0_reg_nr same in align16 */
420
FC(3src_a1_src0_subreg_nr, /* 4+ */ 75, 71, /* 12+ */ 71, 67, devinfo->ver >= 10)
421
FC(3src_a1_src0_hstride, /* 4+ */ 70, 69, /* 12+ */ 65, 64, devinfo->ver >= 10)
422
FDC(3src_a1_src0_vstride, /* 4+ */ 68, 67, /* 12+ */ 43, 43, 35, 35, devinfo->ver >= 10)
423
FC(3src_a1_src0_hw_type, /* 4+ */ 66, 64, /* 12+ */ 42, 40, devinfo->ver >= 10)
424
/* dst_reg_nr same in align16 */
425
FC(3src_a1_dst_subreg_nr, /* 4+ */ 55, 54, /* 12+ */ 55, 54, devinfo->ver >= 10)
426
FC(3src_a1_special_acc, /* 4+ */ 55, 52, /* 12+ */ 54, 51, devinfo->ver >= 10) /* aliases dst_subreg_nr */
428
FC(3src_a1_dst_hstride, /* 4+ */ 49, 49, /* 12+ */ 48, 48, devinfo->ver >= 10)
429
FC(3src_a1_dst_hw_type, /* 4+ */ 48, 46, /* 12+ */ 38, 36, devinfo->ver >= 10)
430
FI(3src_a1_src2_reg_file, /* 4+ */ -1, -1, /* 8+ */ 45, 45, /* 12+ */ 47, 114)
431
FC(3src_a1_src1_reg_file, /* 4+ */ 44, 44, /* 12+ */ 98, 98, devinfo->ver >= 10)
432
FI(3src_a1_src0_reg_file, /* 4+ */ -1, -1, /* 8+ */ 43, 43, /* 12+ */ 46, 66)
434
F(3src_a1_src2_is_imm, /* 4+ */ -1, -1, /* 12+ */ 47, 47)
435
F(3src_a1_src0_is_imm, /* 4+ */ -1, -1, /* 12+ */ 46, 46)
437
/* Source Modifier fields same in align16 */
438
FC(3src_a1_dst_reg_file, /* 4+ */ 36, 36, /* 12+ */ 50, 50, devinfo->ver >= 10)
439
FC(3src_a1_exec_type, /* 4+ */ 35, 35, /* 12+ */ 39, 39, devinfo->ver >= 10)
440
/* Fields below this same in align16 */
443
#define REG_TYPE(reg) \
445
brw_inst_set_3src_a1_##reg##_type(const struct intel_device_info *devinfo, \
446
brw_inst *inst, enum brw_reg_type type) \
448
UNUSED enum gfx10_align1_3src_exec_type exec_type = \
449
(enum gfx10_align1_3src_exec_type) brw_inst_3src_a1_exec_type(devinfo, \
451
if (brw_reg_type_is_floating_point(type)) { \
452
assert(exec_type == BRW_ALIGN1_3SRC_EXEC_TYPE_FLOAT); \
454
assert(exec_type == BRW_ALIGN1_3SRC_EXEC_TYPE_INT); \
456
unsigned hw_type = brw_reg_type_to_a1_hw_3src_type(devinfo, type); \
457
brw_inst_set_3src_a1_##reg##_hw_type(devinfo, inst, hw_type); \
460
static inline enum brw_reg_type \
461
brw_inst_3src_a1_##reg##_type(const struct intel_device_info *devinfo, \
462
const brw_inst *inst) \
464
enum gfx10_align1_3src_exec_type exec_type = \
465
(enum gfx10_align1_3src_exec_type) brw_inst_3src_a1_exec_type(devinfo, \
467
unsigned hw_type = brw_inst_3src_a1_##reg##_hw_type(devinfo, inst); \
468
return brw_a1_hw_3src_type_to_reg_type(devinfo, hw_type, exec_type); \
478
* Three-source align1 instruction immediates:
481
static inline uint16_t
482
brw_inst_3src_a1_src0_imm(ASSERTED const struct intel_device_info *devinfo,
483
const brw_inst *insn)
485
assert(devinfo->ver >= 10);
486
if (devinfo->ver >= 12)
487
return brw_inst_bits(insn, 79, 64);
489
return brw_inst_bits(insn, 82, 67);
492
static inline uint16_t
493
brw_inst_3src_a1_src2_imm(ASSERTED const struct intel_device_info *devinfo,
494
const brw_inst *insn)
496
assert(devinfo->ver >= 10);
497
if (devinfo->ver >= 12)
498
return brw_inst_bits(insn, 127, 112);
500
return brw_inst_bits(insn, 124, 109);
504
brw_inst_set_3src_a1_src0_imm(ASSERTED const struct intel_device_info *devinfo,
505
brw_inst *insn, uint16_t value)
507
assert(devinfo->ver >= 10);
508
if (devinfo->ver >= 12)
509
brw_inst_set_bits(insn, 79, 64, value);
511
brw_inst_set_bits(insn, 82, 67, value);
515
brw_inst_set_3src_a1_src2_imm(ASSERTED const struct intel_device_info *devinfo,
516
brw_inst *insn, uint16_t value)
518
assert(devinfo->ver >= 10);
519
if (devinfo->ver >= 12)
520
brw_inst_set_bits(insn, 127, 112, value);
522
brw_inst_set_bits(insn, 124, 109, value);
527
* Flow control instruction bits:
531
brw_inst_set_uip(const struct intel_device_info *devinfo,
532
brw_inst *inst, int32_t value)
534
assert(devinfo->ver >= 6);
536
if (devinfo->ver >= 12)
537
brw_inst_set_src1_is_imm(devinfo, inst, 1);
539
if (devinfo->ver >= 8) {
540
brw_inst_set_bits(inst, 95, 64, (uint32_t)value);
542
assert(value <= (1 << 16) - 1);
543
assert(value > -(1 << 16));
544
brw_inst_set_bits(inst, 127, 112, (uint16_t)value);
548
static inline int32_t
549
brw_inst_uip(const struct intel_device_info *devinfo, const brw_inst *inst)
551
assert(devinfo->ver >= 6);
553
if (devinfo->ver >= 8) {
554
return brw_inst_bits(inst, 95, 64);
556
return (int16_t)brw_inst_bits(inst, 127, 112);
561
brw_inst_set_jip(const struct intel_device_info *devinfo,
562
brw_inst *inst, int32_t value)
564
assert(devinfo->ver >= 6);
566
if (devinfo->ver >= 12)
567
brw_inst_set_src0_is_imm(devinfo, inst, 1);
569
if (devinfo->ver >= 8) {
570
brw_inst_set_bits(inst, 127, 96, (uint32_t)value);
572
assert(value <= (1 << 15) - 1);
573
assert(value >= -(1 << 15));
574
brw_inst_set_bits(inst, 111, 96, (uint16_t)value);
578
static inline int32_t
579
brw_inst_jip(const struct intel_device_info *devinfo, const brw_inst *inst)
581
assert(devinfo->ver >= 6);
583
if (devinfo->ver >= 8) {
584
return brw_inst_bits(inst, 127, 96);
586
return (int16_t)brw_inst_bits(inst, 111, 96);
590
/** Like FC, but using int16_t to handle negative jump targets. */
591
#define FJ(name, high, low, assertions) \
593
brw_inst_set_##name(const struct intel_device_info *devinfo, brw_inst *inst, int16_t v) \
595
assert(assertions); \
597
brw_inst_set_bits(inst, high, low, (uint16_t) v); \
599
static inline int16_t \
600
brw_inst_##name(const struct intel_device_info *devinfo, const brw_inst *inst)\
602
assert(assertions); \
604
return brw_inst_bits(inst, high, low); \
607
FJ(gfx6_jump_count, 63, 48, devinfo->ver == 6)
608
FJ(gfx4_jump_count, 111, 96, devinfo->ver < 6)
609
FC(gfx4_pop_count, /* 4+ */ 115, 112, /* 12+ */ -1, -1, devinfo->ver < 6)
616
FC(send_ex_desc_ia_subreg_nr, /* 4+ */ 82, 80, /* 12+ */ 42, 40, devinfo->ver >= 9)
617
FC(send_src0_address_mode, /* 4+ */ 79, 79, /* 12+ */ -1, -1, devinfo->ver >= 9)
618
FC(send_sel_reg32_desc, /* 4+ */ 77, 77, /* 12+ */ 48, 48, devinfo->ver >= 9)
619
FC(send_sel_reg32_ex_desc, /* 4+ */ 61, 61, /* 12+ */ 49, 49, devinfo->ver >= 9)
620
F8(send_src0_reg_file, /* 4+ */ 38, 37, /* 8+ */ 42, 41, /* 12+ */ 66, 66)
621
FC(send_src1_reg_nr, /* 4+ */ 51, 44, /* 12+ */ 111, 104, devinfo->ver >= 9)
622
FC(send_src1_reg_file, /* 4+ */ 36, 36, /* 12+ */ 98, 98, devinfo->ver >= 9)
623
FC(send_dst_reg_file, /* 4+ */ 35, 35, /* 12+ */ 50, 50, devinfo->ver >= 9)
626
/* Message descriptor bits */
627
#define MD(x) ((x) + 96)
628
#define MD12(x) ((x) >= 30 ? (x) - 30 + 122 : \
629
(x) >= 25 ? (x) - 25 + 67 : \
630
(x) >= 20 ? (x) - 20 + 51 : \
631
(x) >= 11 ? (x) - 11 + 113 : \
635
* Set the SEND(C) message descriptor immediate.
637
* This doesn't include the SFID nor the EOT field that were considered to be
638
* part of the message descriptor by ancient versions of the BSpec, because
639
* they are present in the instruction even if the message descriptor is
640
* provided indirectly in the address register, so we want to specify them
644
brw_inst_set_send_desc(const struct intel_device_info *devinfo,
645
brw_inst *inst, uint32_t value)
647
if (devinfo->ver >= 12) {
648
brw_inst_set_bits(inst, 123, 122, GET_BITS(value, 31, 30));
649
brw_inst_set_bits(inst, 71, 67, GET_BITS(value, 29, 25));
650
brw_inst_set_bits(inst, 55, 51, GET_BITS(value, 24, 20));
651
brw_inst_set_bits(inst, 121, 113, GET_BITS(value, 19, 11));
652
brw_inst_set_bits(inst, 91, 81, GET_BITS(value, 10, 0));
653
} else if (devinfo->ver >= 9) {
654
brw_inst_set_bits(inst, 126, 96, value);
655
assert(value >> 31 == 0);
656
} else if (devinfo->ver >= 5) {
657
brw_inst_set_bits(inst, 124, 96, value);
658
assert(value >> 29 == 0);
660
brw_inst_set_bits(inst, 119, 96, value);
661
assert(value >> 24 == 0);
666
* Get the SEND(C) message descriptor immediate.
668
* \sa brw_inst_set_send_desc().
670
static inline uint32_t
671
brw_inst_send_desc(const struct intel_device_info *devinfo,
672
const brw_inst *inst)
674
if (devinfo->ver >= 12) {
675
return (brw_inst_bits(inst, 123, 122) << 30 |
676
brw_inst_bits(inst, 71, 67) << 25 |
677
brw_inst_bits(inst, 55, 51) << 20 |
678
brw_inst_bits(inst, 121, 113) << 11 |
679
brw_inst_bits(inst, 91, 81));
680
} else if (devinfo->ver >= 9) {
681
return brw_inst_bits(inst, 126, 96);
682
} else if (devinfo->ver >= 5) {
683
return brw_inst_bits(inst, 124, 96);
685
return brw_inst_bits(inst, 119, 96);
690
* Set the SEND(C) message extended descriptor immediate.
692
* This doesn't include the SFID nor the EOT field that were considered to be
693
* part of the extended message descriptor by some versions of the BSpec,
694
* because they are present in the instruction even if the extended message
695
* descriptor is provided indirectly in a register, so we want to specify them
699
brw_inst_set_send_ex_desc(const struct intel_device_info *devinfo,
700
brw_inst *inst, uint32_t value)
702
if (devinfo->ver >= 12) {
703
brw_inst_set_bits(inst, 127, 124, GET_BITS(value, 31, 28));
704
brw_inst_set_bits(inst, 97, 96, GET_BITS(value, 27, 26));
705
brw_inst_set_bits(inst, 65, 64, GET_BITS(value, 25, 24));
706
brw_inst_set_bits(inst, 47, 35, GET_BITS(value, 23, 11));
707
brw_inst_set_bits(inst, 103, 99, GET_BITS(value, 10, 6));
708
assert(GET_BITS(value, 5, 0) == 0);
710
assert(devinfo->ver >= 9);
711
brw_inst_set_bits(inst, 94, 91, GET_BITS(value, 31, 28));
712
brw_inst_set_bits(inst, 88, 85, GET_BITS(value, 27, 24));
713
brw_inst_set_bits(inst, 83, 80, GET_BITS(value, 23, 20));
714
brw_inst_set_bits(inst, 67, 64, GET_BITS(value, 19, 16));
715
assert(GET_BITS(value, 15, 0) == 0);
720
* Set the SENDS(C) message extended descriptor immediate.
722
* This doesn't include the SFID nor the EOT field that were considered to be
723
* part of the extended message descriptor by some versions of the BSpec,
724
* because they are present in the instruction even if the extended message
725
* descriptor is provided indirectly in a register, so we want to specify them
729
brw_inst_set_sends_ex_desc(const struct intel_device_info *devinfo,
730
brw_inst *inst, uint32_t value)
732
if (devinfo->ver >= 12) {
733
brw_inst_set_send_ex_desc(devinfo, inst, value);
735
brw_inst_set_bits(inst, 95, 80, GET_BITS(value, 31, 16));
736
assert(GET_BITS(value, 15, 10) == 0);
737
brw_inst_set_bits(inst, 67, 64, GET_BITS(value, 9, 6));
738
assert(GET_BITS(value, 5, 0) == 0);
743
* Get the SEND(C) message extended descriptor immediate.
745
* \sa brw_inst_set_send_ex_desc().
747
static inline uint32_t
748
brw_inst_send_ex_desc(const struct intel_device_info *devinfo,
749
const brw_inst *inst)
751
if (devinfo->ver >= 12) {
752
return (brw_inst_bits(inst, 127, 124) << 28 |
753
brw_inst_bits(inst, 97, 96) << 26 |
754
brw_inst_bits(inst, 65, 64) << 24 |
755
brw_inst_bits(inst, 47, 35) << 11 |
756
brw_inst_bits(inst, 103, 99) << 6);
758
assert(devinfo->ver >= 9);
759
return (brw_inst_bits(inst, 94, 91) << 28 |
760
brw_inst_bits(inst, 88, 85) << 24 |
761
brw_inst_bits(inst, 83, 80) << 20 |
762
brw_inst_bits(inst, 67, 64) << 16);
767
* Get the SENDS(C) message extended descriptor immediate.
769
* \sa brw_inst_set_send_ex_desc().
771
static inline uint32_t
772
brw_inst_sends_ex_desc(const struct intel_device_info *devinfo,
773
const brw_inst *inst)
775
if (devinfo->ver >= 12) {
776
return brw_inst_send_ex_desc(devinfo, inst);
778
return (brw_inst_bits(inst, 95, 80) << 16 |
779
brw_inst_bits(inst, 67, 64) << 6);
784
* Fields for SEND messages:
787
F(eot, /* 4+ */ 127, 127, /* 12+ */ 34, 34)
795
/* 12: */ MD12(28), MD12(25));
803
/* 12: */ MD12(24), MD12(20));
805
/* 4: doesn't exist */ -1, -1, -1, -1,
810
/* 12: */ MD12(19), MD12(19))
811
F(gateway_notify, /* 4+ */ MD(16), MD(15), /* 12+ */ -1, -1)
819
/* 12: */ MD12(18), MD12(11), MD12(10), MD12(0))
820
FF(gateway_subfuncid,
821
/* 4: */ MD(1), MD(0),
822
/* 4.5: */ MD(1), MD(0),
823
/* 5: */ MD(1), MD(0), /* 2:0, but bit 2 is reserved MBZ */
824
/* 6: */ MD(2), MD(0),
825
/* 7: */ MD(2), MD(0),
826
/* 8: */ MD(2), MD(0),
827
/* 12: */ MD12(2), MD12(0))
829
/* 4: */ 123, 120, /* called msg_target */
837
/* 4-7: */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
839
/* 12: */ 44, 44) /* actually only Gfx11+ */
840
FC(base_mrf, /* 4+ */ 27, 24, /* 12+ */ -1, -1, devinfo->ver < 6);
852
* URB message function control bits:
855
FF(urb_per_slot_offset,
856
/* 4-6: */ -1, -1, -1, -1, -1, -1, -1, -1,
857
/* 7: */ MD(16), MD(16),
858
/* 8: */ MD(17), MD(17),
859
/* 12: */ MD12(17), MD12(17))
860
FC(urb_channel_mask_present, /* 4+ */ MD(15), MD(15), /* 12+ */ MD12(15), MD12(15), devinfo->ver >= 8)
861
FC(urb_complete, /* 4+ */ MD(15), MD(15), /* 12+ */ -1, -1, devinfo->ver < 8)
862
FC(urb_used, /* 4+ */ MD(14), MD(14), /* 12+ */ -1, -1, devinfo->ver < 7)
863
FC(urb_allocate, /* 4+ */ MD(13), MD(13), /* 12+ */ -1, -1, devinfo->ver < 7)
864
FF(urb_swizzle_control,
865
/* 4: */ MD(11), MD(10),
866
/* 4.5: */ MD(11), MD(10),
867
/* 5: */ MD(11), MD(10),
868
/* 6: */ MD(11), MD(10),
869
/* 7: */ MD(14), MD(14),
870
/* 8: */ MD(15), MD(15),
872
FD(urb_global_offset,
873
/* 4: */ MD( 9), MD(4),
874
/* 4.5: */ MD( 9), MD(4),
875
/* 5: */ MD( 9), MD(4),
876
/* 6: */ MD( 9), MD(4),
877
/* 7: */ MD(13), MD(3),
878
/* 8: */ MD(14), MD(4),
879
/* 12: */ MD12(14), MD12(11), MD12(10), MD12(4))
881
/* 4: */ MD( 3), MD(0),
882
/* 4.5: */ MD( 3), MD(0),
883
/* 5: */ MD( 3), MD(0),
884
/* 6: */ MD( 3), MD(0),
885
/* 7: */ MD( 2), MD(0),
886
/* 8: */ MD( 3), MD(0),
887
/* 12: */ MD12(3), MD12(0))
891
* Gfx4-5 math messages:
894
FC(math_msg_data_type, /* 4+ */ MD(7), MD(7), /* 12+ */ -1, -1, devinfo->ver < 6)
895
FC(math_msg_saturate, /* 4+ */ MD(6), MD(6), /* 12+ */ -1, -1, devinfo->ver < 6)
896
FC(math_msg_precision, /* 4+ */ MD(5), MD(5), /* 12+ */ -1, -1, devinfo->ver < 6)
897
FC(math_msg_signed_int, /* 4+ */ MD(4), MD(4), /* 12+ */ -1, -1, devinfo->ver < 6)
898
FC(math_msg_function, /* 4+ */ MD(3), MD(0), /* 12+ */ -1, -1, devinfo->ver < 6)
902
* Sampler message function control bits:
905
FF(sampler_simd_mode,
906
/* 4: doesn't exist */ -1, -1, -1, -1,
907
/* 5: */ MD(17), MD(16),
908
/* 6: */ MD(17), MD(16),
909
/* 7: */ MD(18), MD(17),
910
/* 8: */ MD(18), MD(17),
911
/* 12: */ MD12(18), MD12(17))
913
/* 4: */ MD(15), MD(14),
914
/* 4.5: */ MD(15), MD(12),
915
/* 5: */ MD(15), MD(12),
916
/* 6: */ MD(15), MD(12),
917
/* 7: */ MD(16), MD(12),
918
/* 8: */ MD(16), MD(12),
919
/* 12: */ MD12(16), MD12(12))
920
FC(sampler_return_format, /* 4+ */ MD(13), MD(12), /* 12+ */ -1, -1, devinfo->verx10 == 40)
922
/* 4: */ MD(11), MD(8),
923
/* 4.5: */ MD(11), MD(8),
924
/* 5: */ MD(11), MD(8),
925
/* 6: */ MD(11), MD(8),
926
/* 7: */ MD(11), MD(8),
927
/* 8: */ MD(11), MD(8),
928
/* 12: */ MD12(11), MD12(11), MD12(10), MD12(8))
929
F(binding_table_index, /* 4+ */ MD(7), MD(0), /* 12+ */ MD12(7), MD12(0)) /* also used by other messages */
933
* Data port message function control bits:
936
FC(dp_category, /* 4+ */ MD(18), MD(18), /* 12+ */ MD12(18), MD12(18), devinfo->ver >= 7)
938
/* Gfx4-5 store fields in different bits for read/write messages. */
940
/* 4: */ MD(13), MD(12),
941
/* 4.5: */ MD(13), MD(11),
942
/* 5: */ MD(13), MD(11),
943
/* 6: */ MD(16), MD(13),
944
/* 7: */ MD(17), MD(14),
945
/* 8: */ MD(17), MD(14),
946
/* 12: */ MD12(17), MD12(14))
947
FF(dp_write_msg_type,
948
/* 4: */ MD(14), MD(12),
949
/* 4.5: */ MD(14), MD(12),
950
/* 5: */ MD(14), MD(12),
951
/* 6: */ MD(16), MD(13),
952
/* 7: */ MD(17), MD(14),
953
/* 8: */ MD(17), MD(14),
954
/* 12: */ MD12(17), MD12(14))
955
FD(dp_read_msg_control,
956
/* 4: */ MD(11), MD( 8),
957
/* 4.5: */ MD(10), MD( 8),
958
/* 5: */ MD(10), MD( 8),
959
/* 6: */ MD(12), MD( 8),
960
/* 7: */ MD(13), MD( 8),
961
/* 8: */ MD(13), MD( 8),
962
/* 12: */ MD12(13), MD12(11), MD12(10), MD12(8))
963
FD(dp_write_msg_control,
964
/* 4: */ MD(11), MD( 8),
965
/* 4.5: */ MD(11), MD( 8),
966
/* 5: */ MD(11), MD( 8),
967
/* 6: */ MD(12), MD( 8),
968
/* 7: */ MD(13), MD( 8),
969
/* 8: */ MD(13), MD( 8),
970
/* 12: */ MD12(13), MD12(11), MD12(10), MD12(8))
971
FC(dp_read_target_cache, /* 4+ */ MD(15), MD(14), /* 12+ */ -1, -1, devinfo->ver < 6);
974
/* 4: */ MD(15), MD(15),
975
/* 4.5: */ MD(15), MD(15),
976
/* 5: */ MD(15), MD(15),
977
/* 6: */ MD(17), MD(17),
978
/* 7+: does not exist */ -1, -1, -1, -1,
981
/* Gfx6+ use the same bit locations for everything. */
983
/* 4-5: use dp_read_msg_type or dp_write_msg_type instead */
984
-1, -1, -1, -1, -1, -1,
985
/* 6: */ MD(16), MD(13),
986
/* 7: */ MD(17), MD(14),
987
/* 8: */ MD(18), MD(14),
988
/* 12: */ MD12(18), MD12(14))
990
/* 4: */ MD(11), MD( 8),
991
/* 4.5-5: use dp_read_msg_control or dp_write_msg_control */ -1, -1, -1, -1,
992
/* 6: */ MD(12), MD( 8),
993
/* 7: */ MD(13), MD( 8),
994
/* 8: */ MD(13), MD( 8),
995
/* 12: */ MD12(13), MD12(11), MD12(10), MD12(8))
999
* Scratch message bits (Gfx7+):
1002
FC(scratch_read_write, /* 4+ */ MD(17), MD(17), /* 12+ */ MD12(17), MD12(17), devinfo->ver >= 7) /* 0 = read, 1 = write */
1003
FC(scratch_type, /* 4+ */ MD(16), MD(16), /* 12+ */ -1, -1, devinfo->ver >= 7) /* 0 = OWord, 1 = DWord */
1004
FC(scratch_invalidate_after_read, /* 4+ */ MD(15), MD(15), /* 12+ */ MD12(15), MD12(15), devinfo->ver >= 7)
1005
FC(scratch_block_size, /* 4+ */ MD(13), MD(12), /* 12+ */ MD12(13), MD12(12), devinfo->ver >= 7)
1006
FD(scratch_addr_offset,
1011
/* 7: */ MD(11), MD(0),
1012
/* 8: */ MD(11), MD(0),
1013
/* 12: */ MD12(11), MD12(11), MD12(10), MD12(0))
1017
* Render Target message function control bits:
1021
/* 4: */ MD(11), MD(11),
1022
/* 4.5: */ MD(11), MD(11),
1023
/* 5: */ MD(11), MD(11),
1024
/* 6: */ MD(12), MD(12),
1025
/* 7: */ MD(12), MD(12),
1026
/* 8: */ MD(12), MD(12),
1027
/* 12: */ MD12(12), MD12(12))
1028
FC(rt_slot_group, /* 4+ */ MD(11), MD(11), /* 12+ */ MD12(11), MD12(11), devinfo->ver >= 6)
1029
F(rt_message_type, /* 4+ */ MD(10), MD( 8), /* 12+ */ MD12(10), MD12(8))
1033
* Thread Spawn message function control bits:
1036
FC(ts_resource_select, /* 4+ */ MD( 4), MD( 4), /* 12+ */ -1, -1, devinfo->ver < 11)
1037
FC(ts_request_type, /* 4+ */ MD( 1), MD( 1), /* 12+ */ -1, -1, devinfo->ver < 11)
1038
F(ts_opcode, /* 4+ */ MD( 0), MD( 0), /* 12+ */ MD12(0), MD12(0))
1042
* Pixel Interpolator message function control bits:
1045
F(pi_simd_mode, /* 4+ */ MD(16), MD(16), /* 12+ */ MD12(16), MD12(16))
1046
F(pi_nopersp, /* 4+ */ MD(14), MD(14), /* 12+ */ MD12(14), MD12(14))
1047
F(pi_message_type, /* 4+ */ MD(13), MD(12), /* 12+ */ MD12(13), MD12(12))
1048
F(pi_slot_group, /* 4+ */ MD(11), MD(11), /* 12+ */ MD12(11), MD12(11))
1049
F(pi_message_data, /* 4+ */ MD(7), MD(0), /* 12+ */ MD12(7), MD12(0))
1057
brw_inst_imm_d(const struct intel_device_info *devinfo, const brw_inst *insn)
1060
return brw_inst_bits(insn, 127, 96);
1063
static inline unsigned
1064
brw_inst_imm_ud(const struct intel_device_info *devinfo, const brw_inst *insn)
1067
return brw_inst_bits(insn, 127, 96);
1070
static inline uint64_t
1071
brw_inst_imm_uq(ASSERTED const struct intel_device_info *devinfo,
1072
const brw_inst *insn)
1074
assert(devinfo->ver >= 8);
1075
return brw_inst_bits(insn, 127, 64);
1079
brw_inst_imm_f(const struct intel_device_info *devinfo, const brw_inst *insn)
1086
ft.u = brw_inst_bits(insn, 127, 96);
1090
static inline double
1091
brw_inst_imm_df(const struct intel_device_info *devinfo, const brw_inst *insn)
1098
dt.u = brw_inst_bits(insn, 127, 64);
1103
brw_inst_set_imm_d(const struct intel_device_info *devinfo,
1104
brw_inst *insn, int value)
1107
return brw_inst_set_bits(insn, 127, 96, value);
1111
brw_inst_set_imm_ud(const struct intel_device_info *devinfo,
1112
brw_inst *insn, unsigned value)
1115
return brw_inst_set_bits(insn, 127, 96, value);
1119
brw_inst_set_imm_f(const struct intel_device_info *devinfo,
1120
brw_inst *insn, float value)
1128
brw_inst_set_bits(insn, 127, 96, ft.u);
1132
brw_inst_set_imm_df(const struct intel_device_info *devinfo,
1133
brw_inst *insn, double value)
1142
if (devinfo->ver >= 12) {
1143
brw_inst_set_bits(insn, 95, 64, dt.u >> 32);
1144
brw_inst_set_bits(insn, 127, 96, dt.u & 0xFFFFFFFF);
1146
brw_inst_set_bits(insn, 127, 64, dt.u);
1151
brw_inst_set_imm_uq(const struct intel_device_info *devinfo,
1152
brw_inst *insn, uint64_t value)
1155
if (devinfo->ver >= 12) {
1156
brw_inst_set_bits(insn, 95, 64, value >> 32);
1157
brw_inst_set_bits(insn, 127, 96, value & 0xFFFFFFFF);
1159
brw_inst_set_bits(insn, 127, 64, value);
1165
#define REG_TYPE(reg) \
1166
static inline void \
1167
brw_inst_set_##reg##_file_type(const struct intel_device_info *devinfo, \
1168
brw_inst *inst, enum brw_reg_file file, \
1169
enum brw_reg_type type) \
1171
assert(file <= BRW_IMMEDIATE_VALUE); \
1172
unsigned hw_type = brw_reg_type_to_hw_type(devinfo, file, type); \
1173
brw_inst_set_##reg##_reg_file(devinfo, inst, file); \
1174
brw_inst_set_##reg##_reg_hw_type(devinfo, inst, hw_type); \
1177
static inline enum brw_reg_type \
1178
brw_inst_##reg##_type(const struct intel_device_info *devinfo, \
1179
const brw_inst *inst) \
1181
unsigned file = __builtin_strcmp("dst", #reg) == 0 ? \
1182
(unsigned) BRW_GENERAL_REGISTER_FILE : \
1183
brw_inst_##reg##_reg_file(devinfo, inst); \
1184
unsigned hw_type = brw_inst_##reg##_reg_hw_type(devinfo, inst); \
1185
return brw_hw_type_to_reg_type(devinfo, (enum brw_reg_file)file, hw_type); \
1194
/* The AddrImm fields are split into two discontiguous sections on Gfx8+ */
1195
#define BRW_IA1_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low, \
1196
g12_high, g12_low) \
1197
static inline void \
1198
brw_inst_set_##reg##_ia1_addr_imm(const struct \
1199
intel_device_info *devinfo, \
1203
assert((value & ~0x3ff) == 0); \
1204
if (devinfo->ver >= 12) { \
1205
brw_inst_set_bits(inst, g12_high, g12_low, value); \
1206
} else if (devinfo->ver >= 8) { \
1207
brw_inst_set_bits(inst, g8_high, g8_low, value & 0x1ff); \
1208
brw_inst_set_bits(inst, g8_nine, g8_nine, value >> 9); \
1210
brw_inst_set_bits(inst, g4_high, g4_low, value); \
1213
static inline unsigned \
1214
brw_inst_##reg##_ia1_addr_imm(const struct intel_device_info *devinfo, \
1215
const brw_inst *inst) \
1217
if (devinfo->ver >= 12) { \
1218
return brw_inst_bits(inst, g12_high, g12_low); \
1219
} else if (devinfo->ver >= 8) { \
1220
return brw_inst_bits(inst, g8_high, g8_low) | \
1221
(brw_inst_bits(inst, g8_nine, g8_nine) << 9); \
1223
return brw_inst_bits(inst, g4_high, g4_low); \
1227
/* AddrImm[9:0] for Align1 Indirect Addressing */
1228
/* -Gen 4- ----Gfx8---- -Gfx12- */
1229
BRW_IA1_ADDR_IMM(src1, 105, 96, 121, 104, 96, 107, 98)
1230
BRW_IA1_ADDR_IMM(src0, 73, 64, 95, 72, 64, 75, 66)
1231
BRW_IA1_ADDR_IMM(dst, 57, 48, 47, 56, 48, 59, 50)
1233
#define BRW_IA16_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low) \
1234
static inline void \
1235
brw_inst_set_##reg##_ia16_addr_imm(const struct \
1236
intel_device_info *devinfo, \
1237
brw_inst *inst, unsigned value) \
1239
assert(devinfo->ver < 12); \
1240
assert((value & ~0x3ff) == 0); \
1241
if (devinfo->ver >= 8) { \
1242
assert(GET_BITS(value, 3, 0) == 0); \
1243
brw_inst_set_bits(inst, g8_high, g8_low, GET_BITS(value, 8, 4)); \
1244
brw_inst_set_bits(inst, g8_nine, g8_nine, GET_BITS(value, 9, 9)); \
1246
brw_inst_set_bits(inst, g4_high, g4_low, value); \
1249
static inline unsigned \
1250
brw_inst_##reg##_ia16_addr_imm(const struct intel_device_info *devinfo, \
1251
const brw_inst *inst) \
1253
assert(devinfo->ver < 12); \
1254
if (devinfo->ver >= 8) { \
1255
return (brw_inst_bits(inst, g8_high, g8_low) << 4) | \
1256
(brw_inst_bits(inst, g8_nine, g8_nine) << 9); \
1258
return brw_inst_bits(inst, g4_high, g4_low); \
1262
/* AddrImm[9:0] for Align16 Indirect Addressing:
1263
* Compared to Align1, these are missing the low 4 bits.
1264
* -Gen 4- ----Gfx8----
1266
BRW_IA16_ADDR_IMM(src1, 105, 96, 121, 104, 100)
1267
BRW_IA16_ADDR_IMM(src0, 73, 64, 95, 72, 68)
1268
BRW_IA16_ADDR_IMM(dst, 57, 52, 47, 56, 52)
1269
BRW_IA16_ADDR_IMM(send_src0, -1, -1, 78, 72, 68)
1270
BRW_IA16_ADDR_IMM(send_dst, -1, -1, 62, 56, 52)
1273
* Fetch a set of contiguous bits from the instruction.
1275
* Bits indices range from 0..127; fields may not cross 64-bit boundaries.
1277
static inline uint64_t
1278
brw_inst_bits(const brw_inst *inst, unsigned high, unsigned low)
1281
assume(high >= low);
1282
/* We assume the field doesn't cross 64-bit boundaries. */
1283
const unsigned word = high / 64;
1284
assert(word == low / 64);
1289
const uint64_t mask = (~0ull >> (64 - (high - low + 1)));
1291
return (inst->data[word] >> low) & mask;
1295
* Set bits in the instruction, with proper shifting and masking.
1297
* Bits indices range from 0..127; fields may not cross 64-bit boundaries.
1300
brw_inst_set_bits(brw_inst *inst, unsigned high, unsigned low, uint64_t value)
1303
assume(high >= low);
1304
const unsigned word = high / 64;
1305
assert(word == low / 64);
1310
const uint64_t mask = (~0ull >> (64 - (high - low + 1))) << low;
1312
/* Make sure the supplied value actually fits in the given bitfield. */
1313
assert((value & (mask >> low)) == value);
1315
inst->data[word] = (inst->data[word] & ~mask) | (value << low);
1318
#undef BRW_IA16_ADDR_IMM
1319
#undef BRW_IA1_ADDR_IMM
1332
* Fetch a set of contiguous bits from the compacted instruction.
1334
* Bits indices range from 0..63.
1336
static inline unsigned
1337
brw_compact_inst_bits(const brw_compact_inst *inst, unsigned high, unsigned low)
1339
const uint64_t mask = (1ull << (high - low + 1)) - 1;
1341
return (inst->data >> low) & mask;
1345
* Set bits in the compacted instruction.
1347
* Bits indices range from 0..63.
1350
brw_compact_inst_set_bits(brw_compact_inst *inst, unsigned high, unsigned low,
1353
const uint64_t mask = ((1ull << (high - low + 1)) - 1) << low;
1355
/* Make sure the supplied value actually fits in the given bitfield. */
1356
assert((value & (mask >> low)) == value);
1358
inst->data = (inst->data & ~mask) | (value << low);
1361
#define FC(name, high, low, gfx12_high, gfx12_low, assertions) \
1362
static inline void \
1363
brw_compact_inst_set_##name(const struct \
1364
intel_device_info *devinfo, \
1365
brw_compact_inst *inst, unsigned v) \
1367
assert(assertions); \
1368
if (devinfo->ver >= 12) \
1369
brw_compact_inst_set_bits(inst, gfx12_high, gfx12_low, v); \
1371
brw_compact_inst_set_bits(inst, high, low, v); \
1373
static inline unsigned \
1374
brw_compact_inst_##name(const struct intel_device_info *devinfo, \
1375
const brw_compact_inst *inst) \
1377
assert(assertions); \
1378
if (devinfo->ver >= 12) \
1379
return brw_compact_inst_bits(inst, gfx12_high, gfx12_low); \
1381
return brw_compact_inst_bits(inst, high, low); \
1384
/* A simple macro for fields which stay in the same place on all generations
1387
#define F(name, high, low, gfx12_high, gfx12_low) \
1388
FC(name, high, low, gfx12_high, gfx12_low, true)
1390
F(src1_reg_nr, /* 4+ */ 63, 56, /* 12+ */ 63, 56)
1391
F(src0_reg_nr, /* 4+ */ 55, 48, /* 12+ */ 47, 40)
1392
F(dst_reg_nr, /* 4+ */ 47, 40, /* 12+ */ 23, 16)
1393
F(src1_index, /* 4+ */ 39, 35, /* 12+ */ 55, 52)
1394
F(src0_index, /* 4+ */ 34, 30, /* 12+ */ 51, 48)
1395
F(cmpt_control, /* 4+ */ 29, 29, /* 12+ */ 29, 29) /* Same location as brw_inst */
1396
FC(flag_subreg_nr, /* 4+ */ 28, 28, /* 12+ */ -1, -1, devinfo->ver <= 6)
1397
F(cond_modifier, /* 4+ */ 27, 24, /* 12+ */ -1, -1) /* Same location as brw_inst */
1398
FC(acc_wr_control, /* 4+ */ 23, 23, /* 12+ */ -1, -1, devinfo->ver >= 6)
1399
FC(mask_control_ex, /* 4+ */ 23, 23, /* 12+ */ -1, -1, devinfo->verx10 == 45 || devinfo->ver == 5)
1400
F(subreg_index, /* 4+ */ 22, 18, /* 12+ */ 39, 35)
1401
F(datatype_index, /* 4+ */ 17, 13, /* 12+ */ 34, 30)
1402
F(control_index, /* 4+ */ 12, 8, /* 12+ */ 28, 24)
1403
FC(swsb, /* 4+ */ -1, -1, /* 12+ */ 15, 8, devinfo->ver >= 12)
1404
F(debug_control, /* 4+ */ 7, 7, /* 12+ */ 7, 7)
1405
F(hw_opcode, /* 4+ */ 6, 0, /* 12+ */ 6, 0) /* Same location as brw_inst */
1407
static inline unsigned
1408
brw_compact_inst_imm(const struct intel_device_info *devinfo,
1409
const brw_compact_inst *inst)
1411
if (devinfo->ver >= 12) {
1412
return brw_compact_inst_bits(inst, 63, 52);
1414
return (brw_compact_inst_bits(inst, 39, 35) << 8) |
1415
(brw_compact_inst_bits(inst, 63, 56));
1420
* (Gfx8+) Compacted three-source instructions:
1423
FC(3src_src2_reg_nr, /* 4+ */ 63, 57, /* 12+ */ 55, 48, devinfo->ver >= 8)
1424
FC(3src_src1_reg_nr, /* 4+ */ 56, 50, /* 12+ */ 63, 56, devinfo->ver >= 8)
1425
FC(3src_src0_reg_nr, /* 4+ */ 49, 43, /* 12+ */ 47, 40, devinfo->ver >= 8)
1426
FC(3src_src2_subreg_nr, /* 4+ */ 42, 40, /* 12+ */ -1, -1, devinfo->ver >= 8)
1427
FC(3src_src1_subreg_nr, /* 4+ */ 39, 37, /* 12+ */ -1, -1, devinfo->ver >= 8)
1428
FC(3src_src0_subreg_nr, /* 4+ */ 36, 34, /* 12+ */ -1, -1, devinfo->ver >= 8)
1429
FC(3src_src2_rep_ctrl, /* 4+ */ 33, 33, /* 12+ */ -1, -1, devinfo->ver >= 8)
1430
FC(3src_src1_rep_ctrl, /* 4+ */ 32, 32, /* 12+ */ -1, -1, devinfo->ver >= 8)
1431
FC(3src_saturate, /* 4+ */ 31, 31, /* 12+ */ -1, -1, devinfo->ver >= 8)
1432
FC(3src_debug_control, /* 4+ */ 30, 30, /* 12+ */ 7, 7, devinfo->ver >= 8)
1433
FC(3src_cmpt_control, /* 4+ */ 29, 29, /* 12+ */ 29, 29, devinfo->ver >= 8)
1434
FC(3src_src0_rep_ctrl, /* 4+ */ 28, 28, /* 12+ */ -1, -1, devinfo->ver >= 8)
1436
FC(3src_dst_reg_nr, /* 4+ */ 18, 12, /* 12+ */ 23, 16, devinfo->ver >= 8)
1437
FC(3src_source_index, /* 4+ */ 11, 10, /* 12+ */ 34, 30, devinfo->ver >= 8)
1438
FC(3src_subreg_index, /* 4+ */ -1, -1, /* 12+ */ 39, 35, devinfo->ver >= 12)
1439
FC(3src_control_index, /* 4+ */ 9, 8, /* 12+ */ 28, 24, devinfo->ver >= 8)
1440
FC(3src_swsb, /* 4+ */ -1, -1, /* 12+ */ 15, 8, devinfo->ver >= 8)
1441
/* Bit 7 is Reserved (for future Opcode expansion) */
1442
FC(3src_hw_opcode, /* 4+ */ 6, 0, /* 12+ */ 6, 0, devinfo->ver >= 8)