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>
34 * This file defines struct brw_reg, which is our representation for EU
35 * registers. They're not a hardware specific format, just an abstraction
36 * that intends to capture the full flexibility of the hardware registers.
38 * The brw_eu_emit.c layer's brw_set_dest/brw_set_src[01] functions encode
39 * the abstract brw_reg type into the actual hardware instruction encoding.
46 #include "main/imports.h"
47 #include "main/compiler.h"
48 #include "program/prog_instruction.h"
49 #include "brw_defines.h"
57 /** Number of general purpose registers (VS, WM, etc) */
58 #define BRW_MAX_GRF 128
61 * First GRF used for the MRF hack.
63 * On gen7, MRFs are no longer used, and contiguous GRFs are used instead. We
64 * haven't converted our compiler to be aware of this, so it asks for MRFs and
65 * brw_eu_emit.c quietly converts them to be accesses of the top GRFs. The
66 * register allocators have to be careful of this to avoid corrupting the "MRF"s
67 * with actual GRF allocations.
69 #define GEN7_MRF_HACK_START 112
71 /** Number of message register file registers */
72 #define BRW_MAX_MRF 16
74 #define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
75 #define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
77 #define BRW_SWIZZLE_NOOP BRW_SWIZZLE4(0,1,2,3)
78 #define BRW_SWIZZLE_XYZW BRW_SWIZZLE4(0,1,2,3)
79 #define BRW_SWIZZLE_XXXX BRW_SWIZZLE4(0,0,0,0)
80 #define BRW_SWIZZLE_YYYY BRW_SWIZZLE4(1,1,1,1)
81 #define BRW_SWIZZLE_ZZZZ BRW_SWIZZLE4(2,2,2,2)
82 #define BRW_SWIZZLE_WWWW BRW_SWIZZLE4(3,3,3,3)
83 #define BRW_SWIZZLE_XYXY BRW_SWIZZLE4(0,1,0,1)
84 #define BRW_SWIZZLE_YZXW BRW_SWIZZLE4(1,2,0,3)
85 #define BRW_SWIZZLE_ZXYW BRW_SWIZZLE4(2,0,1,3)
86 #define BRW_SWIZZLE_ZWZW BRW_SWIZZLE4(2,3,2,3)
89 brw_is_single_value_swizzle(int swiz
)
91 return (swiz
== BRW_SWIZZLE_XXXX
||
92 swiz
== BRW_SWIZZLE_YYYY
||
93 swiz
== BRW_SWIZZLE_ZZZZ
||
94 swiz
== BRW_SWIZZLE_WWWW
);
97 enum PACKED brw_reg_type
{
98 BRW_REGISTER_TYPE_UD
= 0,
100 BRW_REGISTER_TYPE_UW
,
104 /** Non-immediates only: @{ */
105 BRW_REGISTER_TYPE_UB
,
109 /** Immediates only: @{ */
110 BRW_REGISTER_TYPE_UV
,
112 BRW_REGISTER_TYPE_VF
,
115 BRW_REGISTER_TYPE_DF
, /* Gen7+ (no immediates until Gen8+) */
118 BRW_REGISTER_TYPE_HF
,
119 BRW_REGISTER_TYPE_UQ
,
123 unsigned brw_reg_type_to_hw_type(const struct brw_context
*brw
,
124 enum brw_reg_type type
, unsigned file
);
125 const char *brw_reg_type_letters(unsigned brw_reg_type
);
127 #define REG_SIZE (8*4)
129 /* These aren't hardware structs, just something useful for us to pass around:
131 * Align1 operation has a lot of control over input ranges. Used in
132 * WM programs to implement shaders decomposed into "channel serial"
133 * or "structure of array" form:
136 enum brw_reg_type type
:4;
139 unsigned subnr
:5; /* :1 in align16 */
140 unsigned negate
:1; /* source only */
141 unsigned abs
:1; /* source only */
142 unsigned vstride
:4; /* source only */
143 unsigned width
:3; /* src only, align1 only */
144 unsigned hstride
:2; /* align1 only */
145 unsigned address_mode
:1; /* relative addressing, hopefully! */
150 unsigned swizzle
:8; /* src only, align16 only */
151 unsigned writemask
:4; /* dest only, align16 only */
152 int indirect_offset
:10; /* relative addressing offset */
153 unsigned pad1
:10; /* two dwords total */
163 struct brw_indirect
{
164 unsigned addr_subnr
:4;
171 type_sz(unsigned type
)
174 case BRW_REGISTER_TYPE_UQ
:
175 case BRW_REGISTER_TYPE_Q
:
177 case BRW_REGISTER_TYPE_UD
:
178 case BRW_REGISTER_TYPE_D
:
179 case BRW_REGISTER_TYPE_F
:
181 case BRW_REGISTER_TYPE_UW
:
182 case BRW_REGISTER_TYPE_W
:
184 case BRW_REGISTER_TYPE_UB
:
185 case BRW_REGISTER_TYPE_B
:
193 type_is_signed(unsigned type
)
196 case BRW_REGISTER_TYPE_D
:
197 case BRW_REGISTER_TYPE_W
:
198 case BRW_REGISTER_TYPE_F
:
199 case BRW_REGISTER_TYPE_B
:
200 case BRW_REGISTER_TYPE_V
:
201 case BRW_REGISTER_TYPE_VF
:
202 case BRW_REGISTER_TYPE_DF
:
203 case BRW_REGISTER_TYPE_HF
:
204 case BRW_REGISTER_TYPE_Q
:
207 case BRW_REGISTER_TYPE_UD
:
208 case BRW_REGISTER_TYPE_UW
:
209 case BRW_REGISTER_TYPE_UB
:
210 case BRW_REGISTER_TYPE_UV
:
211 case BRW_REGISTER_TYPE_UQ
:
215 unreachable("not reached");
220 * Construct a brw_reg.
221 * \param file one of the BRW_x_REGISTER_FILE values
222 * \param nr register number/index
223 * \param subnr register sub number
224 * \param negate register negate modifier
225 * \param abs register abs modifier
226 * \param type one of BRW_REGISTER_TYPE_x
227 * \param vstride one of BRW_VERTICAL_STRIDE_x
228 * \param width one of BRW_WIDTH_x
229 * \param hstride one of BRW_HORIZONTAL_STRIDE_x
230 * \param swizzle one of BRW_SWIZZLE_x
231 * \param writemask WRITEMASK_X/Y/Z/W bitfield
233 static inline struct brw_reg
234 brw_reg(unsigned file
,
239 enum brw_reg_type type
,
247 if (file
== BRW_GENERAL_REGISTER_FILE
)
248 assert(nr
< BRW_MAX_GRF
);
249 else if (file
== BRW_MESSAGE_REGISTER_FILE
)
250 assert((nr
& ~(1 << 7)) < BRW_MAX_MRF
);
251 else if (file
== BRW_ARCHITECTURE_REGISTER_FILE
)
252 assert(nr
<= BRW_ARF_TIMESTAMP
);
257 reg
.subnr
= subnr
* type_sz(type
);
260 reg
.vstride
= vstride
;
262 reg
.hstride
= hstride
;
263 reg
.address_mode
= BRW_ADDRESS_DIRECT
;
266 /* Could do better: If the reg is r5.3<0;1,0>, we probably want to
267 * set swizzle and writemask to W, as the lower bits of subnr will
268 * be lost when converted to align16. This is probably too much to
269 * keep track of as you'd want it adjusted by suboffset(), etc.
270 * Perhaps fix up when converting to align16?
272 reg
.dw1
.bits
.swizzle
= swizzle
;
273 reg
.dw1
.bits
.writemask
= writemask
;
274 reg
.dw1
.bits
.indirect_offset
= 0;
275 reg
.dw1
.bits
.pad1
= 0;
279 /** Construct float[16] register */
280 static inline struct brw_reg
281 brw_vec16_reg(unsigned file
, unsigned nr
, unsigned subnr
)
289 BRW_VERTICAL_STRIDE_16
,
291 BRW_HORIZONTAL_STRIDE_1
,
296 /** Construct float[8] register */
297 static inline struct brw_reg
298 brw_vec8_reg(unsigned file
, unsigned nr
, unsigned subnr
)
306 BRW_VERTICAL_STRIDE_8
,
308 BRW_HORIZONTAL_STRIDE_1
,
313 /** Construct float[4] register */
314 static inline struct brw_reg
315 brw_vec4_reg(unsigned file
, unsigned nr
, unsigned subnr
)
323 BRW_VERTICAL_STRIDE_4
,
325 BRW_HORIZONTAL_STRIDE_1
,
330 /** Construct float[2] register */
331 static inline struct brw_reg
332 brw_vec2_reg(unsigned file
, unsigned nr
, unsigned subnr
)
340 BRW_VERTICAL_STRIDE_2
,
342 BRW_HORIZONTAL_STRIDE_1
,
347 /** Construct float[1] register */
348 static inline struct brw_reg
349 brw_vec1_reg(unsigned file
, unsigned nr
, unsigned subnr
)
357 BRW_VERTICAL_STRIDE_0
,
359 BRW_HORIZONTAL_STRIDE_0
,
364 static inline struct brw_reg
365 brw_vecn_reg(unsigned width
, unsigned file
, unsigned nr
, unsigned subnr
)
369 return brw_vec1_reg(file
, nr
, subnr
);
371 return brw_vec2_reg(file
, nr
, subnr
);
373 return brw_vec4_reg(file
, nr
, subnr
);
375 return brw_vec8_reg(file
, nr
, subnr
);
377 return brw_vec16_reg(file
, nr
, subnr
);
379 unreachable("Invalid register width");
383 static inline struct brw_reg
384 retype(struct brw_reg reg
, enum brw_reg_type type
)
390 static inline struct brw_reg
391 firsthalf(struct brw_reg reg
)
396 static inline struct brw_reg
397 sechalf(struct brw_reg reg
)
404 static inline struct brw_reg
405 suboffset(struct brw_reg reg
, unsigned delta
)
407 reg
.subnr
+= delta
* type_sz(reg
.type
);
412 static inline struct brw_reg
413 offset(struct brw_reg reg
, unsigned delta
)
420 static inline struct brw_reg
421 byte_offset(struct brw_reg reg
, unsigned bytes
)
423 unsigned newoffset
= reg
.nr
* REG_SIZE
+ reg
.subnr
+ bytes
;
424 reg
.nr
= newoffset
/ REG_SIZE
;
425 reg
.subnr
= newoffset
% REG_SIZE
;
430 /** Construct unsigned word[16] register */
431 static inline struct brw_reg
432 brw_uw16_reg(unsigned file
, unsigned nr
, unsigned subnr
)
434 return suboffset(retype(brw_vec16_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
437 /** Construct unsigned word[8] register */
438 static inline struct brw_reg
439 brw_uw8_reg(unsigned file
, unsigned nr
, unsigned subnr
)
441 return suboffset(retype(brw_vec8_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
444 /** Construct unsigned word[1] register */
445 static inline struct brw_reg
446 brw_uw1_reg(unsigned file
, unsigned nr
, unsigned subnr
)
448 return suboffset(retype(brw_vec1_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
451 static inline struct brw_reg
452 brw_imm_reg(enum brw_reg_type type
)
454 return brw_reg(BRW_IMMEDIATE_VALUE
,
460 BRW_VERTICAL_STRIDE_0
,
462 BRW_HORIZONTAL_STRIDE_0
,
467 /** Construct float immediate register */
468 static inline struct brw_reg
471 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_F
);
476 /** Construct integer immediate register */
477 static inline struct brw_reg
480 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_D
);
485 /** Construct uint immediate register */
486 static inline struct brw_reg
487 brw_imm_ud(unsigned ud
)
489 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_UD
);
494 /** Construct ushort immediate register */
495 static inline struct brw_reg
496 brw_imm_uw(uint16_t uw
)
498 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_UW
);
499 imm
.dw1
.ud
= uw
| (uw
<< 16);
503 /** Construct short immediate register */
504 static inline struct brw_reg
507 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_W
);
508 imm
.dw1
.d
= w
| (w
<< 16);
512 /* brw_imm_b and brw_imm_ub aren't supported by hardware - the type
513 * numbers alias with _V and _VF below:
516 /** Construct vector of eight signed half-byte values */
517 static inline struct brw_reg
518 brw_imm_v(unsigned v
)
520 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_V
);
521 imm
.vstride
= BRW_VERTICAL_STRIDE_0
;
522 imm
.width
= BRW_WIDTH_8
;
523 imm
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
528 /** Construct vector of four 8-bit float values */
529 static inline struct brw_reg
530 brw_imm_vf(unsigned v
)
532 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_VF
);
533 imm
.vstride
= BRW_VERTICAL_STRIDE_0
;
534 imm
.width
= BRW_WIDTH_4
;
535 imm
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
541 * Convert an integer into a "restricted" 8-bit float, used in vector
542 * immediates. The 8-bit floating point format has a sign bit, an
543 * excess-3 3-bit exponent, and a 4-bit mantissa. All integer values
544 * from -31 to 31 can be represented exactly.
546 static inline uint8_t
552 return 1 << 7 | int_to_float8(-x
);
554 const unsigned exponent
= _mesa_logbase2(x
);
555 const unsigned mantissa
= (x
- (1 << exponent
)) << (4 - exponent
);
556 assert(exponent
<= 4);
557 return (exponent
+ 3) << 4 | mantissa
;
562 * Construct a floating-point packed vector immediate from its integer
563 * values. \sa int_to_float8()
565 static inline struct brw_reg
566 brw_imm_vf4(int v0
, int v1
, int v2
, int v3
)
568 return brw_imm_vf((int_to_float8(v0
) << 0) |
569 (int_to_float8(v1
) << 8) |
570 (int_to_float8(v2
) << 16) |
571 (int_to_float8(v3
) << 24));
575 static inline struct brw_reg
576 brw_address(struct brw_reg reg
)
578 return brw_imm_uw(reg
.nr
* REG_SIZE
+ reg
.subnr
);
581 /** Construct float[1] general-purpose register */
582 static inline struct brw_reg
583 brw_vec1_grf(unsigned nr
, unsigned subnr
)
585 return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
588 /** Construct float[2] general-purpose register */
589 static inline struct brw_reg
590 brw_vec2_grf(unsigned nr
, unsigned subnr
)
592 return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
595 /** Construct float[4] general-purpose register */
596 static inline struct brw_reg
597 brw_vec4_grf(unsigned nr
, unsigned subnr
)
599 return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
602 /** Construct float[8] general-purpose register */
603 static inline struct brw_reg
604 brw_vec8_grf(unsigned nr
, unsigned subnr
)
606 return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
610 static inline struct brw_reg
611 brw_uw8_grf(unsigned nr
, unsigned subnr
)
613 return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
616 static inline struct brw_reg
617 brw_uw16_grf(unsigned nr
, unsigned subnr
)
619 return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
623 /** Construct null register (usually used for setting condition codes) */
624 static inline struct brw_reg
627 return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE
, BRW_ARF_NULL
, 0);
630 static inline struct brw_reg
631 brw_null_vec(unsigned width
)
633 return brw_vecn_reg(width
, BRW_ARCHITECTURE_REGISTER_FILE
, BRW_ARF_NULL
, 0);
636 static inline struct brw_reg
637 brw_address_reg(unsigned subnr
)
639 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
, BRW_ARF_ADDRESS
, subnr
);
642 /* If/else instructions break in align16 mode if writemask & swizzle
643 * aren't xyzw. This goes against the convention for other scalar
646 static inline struct brw_reg
649 return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
654 BRW_REGISTER_TYPE_UD
,
655 BRW_VERTICAL_STRIDE_4
, /* ? */
657 BRW_HORIZONTAL_STRIDE_0
,
658 BRW_SWIZZLE_XYZW
, /* NOTE! */
659 WRITEMASK_XYZW
); /* NOTE! */
662 static inline struct brw_reg
663 brw_acc_reg(unsigned width
)
665 return brw_vecn_reg(width
, BRW_ARCHITECTURE_REGISTER_FILE
,
666 BRW_ARF_ACCUMULATOR
, 0);
669 static inline struct brw_reg
670 brw_flag_reg(int reg
, int subreg
)
672 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
673 BRW_ARF_FLAG
+ reg
, subreg
);
677 static inline struct brw_reg
678 brw_mask_reg(unsigned subnr
)
680 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
, BRW_ARF_MASK
, subnr
);
683 static inline struct brw_reg
684 brw_message_reg(unsigned nr
)
686 assert((nr
& ~(1 << 7)) < BRW_MAX_MRF
);
687 return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE
, nr
, 0);
690 static inline struct brw_reg
691 brw_uvec_mrf(unsigned width
, unsigned nr
, unsigned subnr
)
693 return retype(brw_vecn_reg(width
, BRW_MESSAGE_REGISTER_FILE
, nr
, subnr
),
694 BRW_REGISTER_TYPE_UD
);
697 /* This is almost always called with a numeric constant argument, so
698 * make things easy to evaluate at compile time:
700 static inline unsigned cvt(unsigned val
)
714 static inline struct brw_reg
715 stride(struct brw_reg reg
, unsigned vstride
, unsigned width
, unsigned hstride
)
717 reg
.vstride
= cvt(vstride
);
718 reg
.width
= cvt(width
) - 1;
719 reg
.hstride
= cvt(hstride
);
724 static inline struct brw_reg
725 vec16(struct brw_reg reg
)
727 return stride(reg
, 16,16,1);
730 static inline struct brw_reg
731 vec8(struct brw_reg reg
)
733 return stride(reg
, 8,8,1);
736 static inline struct brw_reg
737 vec4(struct brw_reg reg
)
739 return stride(reg
, 4,4,1);
742 static inline struct brw_reg
743 vec2(struct brw_reg reg
)
745 return stride(reg
, 2,2,1);
748 static inline struct brw_reg
749 vec1(struct brw_reg reg
)
751 return stride(reg
, 0,1,0);
755 static inline struct brw_reg
756 get_element(struct brw_reg reg
, unsigned elt
)
758 return vec1(suboffset(reg
, elt
));
761 static inline struct brw_reg
762 get_element_ud(struct brw_reg reg
, unsigned elt
)
764 return vec1(suboffset(retype(reg
, BRW_REGISTER_TYPE_UD
), elt
));
767 static inline struct brw_reg
768 get_element_d(struct brw_reg reg
, unsigned elt
)
770 return vec1(suboffset(retype(reg
, BRW_REGISTER_TYPE_D
), elt
));
774 static inline struct brw_reg
775 brw_swizzle(struct brw_reg reg
, unsigned x
, unsigned y
, unsigned z
, unsigned w
)
777 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
779 reg
.dw1
.bits
.swizzle
= BRW_SWIZZLE4(BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, x
),
780 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, y
),
781 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, z
),
782 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, w
));
787 static inline struct brw_reg
788 brw_swizzle1(struct brw_reg reg
, unsigned x
)
790 return brw_swizzle(reg
, x
, x
, x
, x
);
793 static inline struct brw_reg
794 brw_writemask(struct brw_reg reg
, unsigned mask
)
796 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
797 reg
.dw1
.bits
.writemask
&= mask
;
801 static inline struct brw_reg
802 brw_set_writemask(struct brw_reg reg
, unsigned mask
)
804 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
805 reg
.dw1
.bits
.writemask
= mask
;
809 static inline struct brw_reg
810 negate(struct brw_reg reg
)
816 static inline struct brw_reg
817 brw_abs(struct brw_reg reg
)
824 /************************************************************************/
826 static inline struct brw_reg
827 brw_vec4_indirect(unsigned subnr
, int offset
)
829 struct brw_reg reg
= brw_vec4_grf(0, 0);
831 reg
.address_mode
= BRW_ADDRESS_REGISTER_INDIRECT_REGISTER
;
832 reg
.dw1
.bits
.indirect_offset
= offset
;
836 static inline struct brw_reg
837 brw_vec1_indirect(unsigned subnr
, int offset
)
839 struct brw_reg reg
= brw_vec1_grf(0, 0);
841 reg
.address_mode
= BRW_ADDRESS_REGISTER_INDIRECT_REGISTER
;
842 reg
.dw1
.bits
.indirect_offset
= offset
;
846 static inline struct brw_reg
847 deref_4f(struct brw_indirect ptr
, int offset
)
849 return brw_vec4_indirect(ptr
.addr_subnr
, ptr
.addr_offset
+ offset
);
852 static inline struct brw_reg
853 deref_1f(struct brw_indirect ptr
, int offset
)
855 return brw_vec1_indirect(ptr
.addr_subnr
, ptr
.addr_offset
+ offset
);
858 static inline struct brw_reg
859 deref_4b(struct brw_indirect ptr
, int offset
)
861 return retype(deref_4f(ptr
, offset
), BRW_REGISTER_TYPE_B
);
864 static inline struct brw_reg
865 deref_1uw(struct brw_indirect ptr
, int offset
)
867 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_UW
);
870 static inline struct brw_reg
871 deref_1d(struct brw_indirect ptr
, int offset
)
873 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_D
);
876 static inline struct brw_reg
877 deref_1ud(struct brw_indirect ptr
, int offset
)
879 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_UD
);
882 static inline struct brw_reg
883 get_addr_reg(struct brw_indirect ptr
)
885 return brw_address_reg(ptr
.addr_subnr
);
888 static inline struct brw_indirect
889 brw_indirect_offset(struct brw_indirect ptr
, int offset
)
891 ptr
.addr_offset
+= offset
;
895 static inline struct brw_indirect
896 brw_indirect(unsigned addr_subnr
, int offset
)
898 struct brw_indirect ptr
;
899 ptr
.addr_subnr
= addr_subnr
;
900 ptr
.addr_offset
= offset
;
906 region_matches(struct brw_reg reg
, enum brw_vertical_stride v
,
907 enum brw_width w
, enum brw_horizontal_stride h
)
909 return reg
.vstride
== v
&&
914 #define has_scalar_region(reg) \
915 region_matches(reg, BRW_VERTICAL_STRIDE_0, BRW_WIDTH_1, \
916 BRW_HORIZONTAL_STRIDE_0)
918 /* brw_packed_float.c */
919 int brw_float_to_vf(float f
);
920 float brw_vf_to_float(unsigned char vf
);