1b8e80941Smrg/* -*- c++ -*- */
2b8e80941Smrg/*
3b8e80941Smrg * Copyright © 2011-2015 Intel Corporation
4b8e80941Smrg *
5b8e80941Smrg * Permission is hereby granted, free of charge, to any person obtaining a
6b8e80941Smrg * copy of this software and associated documentation files (the "Software"),
7b8e80941Smrg * to deal in the Software without restriction, including without limitation
8b8e80941Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9b8e80941Smrg * and/or sell copies of the Software, and to permit persons to whom the
10b8e80941Smrg * Software is furnished to do so, subject to the following conditions:
11b8e80941Smrg *
12b8e80941Smrg * The above copyright notice and this permission notice (including the next
13b8e80941Smrg * paragraph) shall be included in all copies or substantial portions of the
14b8e80941Smrg * Software.
15b8e80941Smrg *
16b8e80941Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17b8e80941Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18b8e80941Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19b8e80941Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20b8e80941Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21b8e80941Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22b8e80941Smrg * IN THE SOFTWARE.
23b8e80941Smrg */
24b8e80941Smrg
25b8e80941Smrg#ifndef BRW_IR_VEC4_H
26b8e80941Smrg#define BRW_IR_VEC4_H
27b8e80941Smrg
28b8e80941Smrg#include "brw_shader.h"
29b8e80941Smrg
30b8e80941Smrgnamespace brw {
31b8e80941Smrg
32b8e80941Smrgclass dst_reg;
33b8e80941Smrg
34b8e80941Smrgclass src_reg : public backend_reg
35b8e80941Smrg{
36b8e80941Smrgpublic:
37b8e80941Smrg   DECLARE_RALLOC_CXX_OPERATORS(src_reg)
38b8e80941Smrg
39b8e80941Smrg   void init();
40b8e80941Smrg
41b8e80941Smrg   src_reg(enum brw_reg_file file, int nr, const glsl_type *type);
42b8e80941Smrg   src_reg();
43b8e80941Smrg   src_reg(struct ::brw_reg reg);
44b8e80941Smrg
45b8e80941Smrg   bool equals(const src_reg &r) const;
46b8e80941Smrg   bool negative_equals(const src_reg &r) const;
47b8e80941Smrg
48b8e80941Smrg   src_reg(class vec4_visitor *v, const struct glsl_type *type);
49b8e80941Smrg   src_reg(class vec4_visitor *v, const struct glsl_type *type, int size);
50b8e80941Smrg
51b8e80941Smrg   explicit src_reg(const dst_reg &reg);
52b8e80941Smrg
53b8e80941Smrg   src_reg *reladdr;
54b8e80941Smrg};
55b8e80941Smrg
56b8e80941Smrgstatic inline src_reg
57b8e80941Smrgretype(src_reg reg, enum brw_reg_type type)
58b8e80941Smrg{
59b8e80941Smrg   reg.type = type;
60b8e80941Smrg   return reg;
61b8e80941Smrg}
62b8e80941Smrg
63b8e80941Smrgnamespace detail {
64b8e80941Smrg
65b8e80941Smrgstatic inline void
66b8e80941Smrgadd_byte_offset(backend_reg *reg, unsigned bytes)
67b8e80941Smrg{
68b8e80941Smrg   switch (reg->file) {
69b8e80941Smrg      case BAD_FILE:
70b8e80941Smrg         break;
71b8e80941Smrg      case VGRF:
72b8e80941Smrg      case ATTR:
73b8e80941Smrg      case UNIFORM:
74b8e80941Smrg         reg->offset += bytes;
75b8e80941Smrg         assert(reg->offset % 16 == 0);
76b8e80941Smrg         break;
77b8e80941Smrg      case MRF: {
78b8e80941Smrg         const unsigned suboffset = reg->offset + bytes;
79b8e80941Smrg         reg->nr += suboffset / REG_SIZE;
80b8e80941Smrg         reg->offset = suboffset % REG_SIZE;
81b8e80941Smrg         assert(reg->offset % 16 == 0);
82b8e80941Smrg         break;
83b8e80941Smrg      }
84b8e80941Smrg      case ARF:
85b8e80941Smrg      case FIXED_GRF: {
86b8e80941Smrg         const unsigned suboffset = reg->subnr + bytes;
87b8e80941Smrg         reg->nr += suboffset / REG_SIZE;
88b8e80941Smrg         reg->subnr = suboffset % REG_SIZE;
89b8e80941Smrg         assert(reg->subnr % 16 == 0);
90b8e80941Smrg         break;
91b8e80941Smrg      }
92b8e80941Smrg      default:
93b8e80941Smrg         assert(bytes == 0);
94b8e80941Smrg   }
95b8e80941Smrg}
96b8e80941Smrg
97b8e80941Smrg} /* namepace detail */
98b8e80941Smrg
99b8e80941Smrgstatic inline src_reg
100b8e80941Smrgbyte_offset(src_reg reg, unsigned bytes)
101b8e80941Smrg{
102b8e80941Smrg   detail::add_byte_offset(&reg, bytes);
103b8e80941Smrg   return reg;
104b8e80941Smrg}
105b8e80941Smrg
106b8e80941Smrgstatic inline src_reg
107b8e80941Smrgoffset(src_reg reg, unsigned width, unsigned delta)
108b8e80941Smrg{
109b8e80941Smrg   const unsigned stride = (reg.file == UNIFORM ? 0 : 4);
110b8e80941Smrg   const unsigned num_components = MAX2(width / 4 * stride, 4);
111b8e80941Smrg   return byte_offset(reg, num_components * type_sz(reg.type) * delta);
112b8e80941Smrg}
113b8e80941Smrg
114b8e80941Smrgstatic inline src_reg
115b8e80941Smrghoriz_offset(src_reg reg, unsigned delta)
116b8e80941Smrg{
117b8e80941Smrg   return byte_offset(reg, delta * type_sz(reg.type));
118b8e80941Smrg}
119b8e80941Smrg
120b8e80941Smrg/**
121b8e80941Smrg * Reswizzle a given source register.
122b8e80941Smrg * \sa brw_swizzle().
123b8e80941Smrg */
124b8e80941Smrgstatic inline src_reg
125b8e80941Smrgswizzle(src_reg reg, unsigned swizzle)
126b8e80941Smrg{
127b8e80941Smrg   if (reg.file == IMM)
128b8e80941Smrg      reg.ud = brw_swizzle_immediate(reg.type, reg.ud, swizzle);
129b8e80941Smrg   else
130b8e80941Smrg      reg.swizzle = brw_compose_swizzle(swizzle, reg.swizzle);
131b8e80941Smrg
132b8e80941Smrg   return reg;
133b8e80941Smrg}
134b8e80941Smrg
135b8e80941Smrgstatic inline src_reg
136b8e80941Smrgnegate(src_reg reg)
137b8e80941Smrg{
138b8e80941Smrg   assert(reg.file != IMM);
139b8e80941Smrg   reg.negate = !reg.negate;
140b8e80941Smrg   return reg;
141b8e80941Smrg}
142b8e80941Smrg
143b8e80941Smrgstatic inline bool
144b8e80941Smrgis_uniform(const src_reg &reg)
145b8e80941Smrg{
146b8e80941Smrg   return (reg.file == IMM || reg.file == UNIFORM || reg.is_null()) &&
147b8e80941Smrg          (!reg.reladdr || is_uniform(*reg.reladdr));
148b8e80941Smrg}
149b8e80941Smrg
150b8e80941Smrgclass dst_reg : public backend_reg
151b8e80941Smrg{
152b8e80941Smrgpublic:
153b8e80941Smrg   DECLARE_RALLOC_CXX_OPERATORS(dst_reg)
154b8e80941Smrg
155b8e80941Smrg   void init();
156b8e80941Smrg
157b8e80941Smrg   dst_reg();
158b8e80941Smrg   dst_reg(enum brw_reg_file file, int nr);
159b8e80941Smrg   dst_reg(enum brw_reg_file file, int nr, const glsl_type *type,
160b8e80941Smrg           unsigned writemask);
161b8e80941Smrg   dst_reg(enum brw_reg_file file, int nr, brw_reg_type type,
162b8e80941Smrg           unsigned writemask);
163b8e80941Smrg   dst_reg(struct ::brw_reg reg);
164b8e80941Smrg   dst_reg(class vec4_visitor *v, const struct glsl_type *type);
165b8e80941Smrg
166b8e80941Smrg   explicit dst_reg(const src_reg &reg);
167b8e80941Smrg
168b8e80941Smrg   bool equals(const dst_reg &r) const;
169b8e80941Smrg
170b8e80941Smrg   src_reg *reladdr;
171b8e80941Smrg};
172b8e80941Smrg
173b8e80941Smrgstatic inline dst_reg
174b8e80941Smrgretype(dst_reg reg, enum brw_reg_type type)
175b8e80941Smrg{
176b8e80941Smrg   reg.type = type;
177b8e80941Smrg   return reg;
178b8e80941Smrg}
179b8e80941Smrg
180b8e80941Smrgstatic inline dst_reg
181b8e80941Smrgbyte_offset(dst_reg reg, unsigned bytes)
182b8e80941Smrg{
183b8e80941Smrg   detail::add_byte_offset(&reg, bytes);
184b8e80941Smrg   return reg;
185b8e80941Smrg}
186b8e80941Smrg
187b8e80941Smrgstatic inline dst_reg
188b8e80941Smrgoffset(dst_reg reg, unsigned width, unsigned delta)
189b8e80941Smrg{
190b8e80941Smrg   const unsigned stride = (reg.file == UNIFORM ? 0 : 4);
191b8e80941Smrg   const unsigned num_components = MAX2(width / 4 * stride, 4);
192b8e80941Smrg   return byte_offset(reg, num_components * type_sz(reg.type) * delta);
193b8e80941Smrg}
194b8e80941Smrg
195b8e80941Smrgstatic inline dst_reg
196b8e80941Smrghoriz_offset(const dst_reg &reg, unsigned delta)
197b8e80941Smrg{
198b8e80941Smrg   if (is_uniform(src_reg(reg)))
199b8e80941Smrg      return reg;
200b8e80941Smrg   else
201b8e80941Smrg      return byte_offset(reg, delta * type_sz(reg.type));
202b8e80941Smrg}
203b8e80941Smrg
204b8e80941Smrgstatic inline dst_reg
205b8e80941Smrgwritemask(dst_reg reg, unsigned mask)
206b8e80941Smrg{
207b8e80941Smrg   assert(reg.file != IMM);
208b8e80941Smrg   assert((reg.writemask & mask) != 0);
209b8e80941Smrg   reg.writemask &= mask;
210b8e80941Smrg   return reg;
211b8e80941Smrg}
212b8e80941Smrg
213b8e80941Smrg/**
214b8e80941Smrg * Return an integer identifying the discrete address space a register is
215b8e80941Smrg * contained in.  A register is by definition fully contained in the single
216b8e80941Smrg * reg_space it belongs to, so two registers with different reg_space ids are
217b8e80941Smrg * guaranteed not to overlap.  Most register files are a single reg_space of
218b8e80941Smrg * its own, only the VGRF file is composed of multiple discrete address
219b8e80941Smrg * spaces, one for each VGRF allocation.
220b8e80941Smrg */
221b8e80941Smrgstatic inline uint32_t
222b8e80941Smrgreg_space(const backend_reg &r)
223b8e80941Smrg{
224b8e80941Smrg   return r.file << 16 | (r.file == VGRF ? r.nr : 0);
225b8e80941Smrg}
226b8e80941Smrg
227b8e80941Smrg/**
228b8e80941Smrg * Return the base offset in bytes of a register relative to the start of its
229b8e80941Smrg * reg_space().
230b8e80941Smrg */
231b8e80941Smrgstatic inline unsigned
232b8e80941Smrgreg_offset(const backend_reg &r)
233b8e80941Smrg{
234b8e80941Smrg   return (r.file == VGRF || r.file == IMM ? 0 : r.nr) *
235b8e80941Smrg          (r.file == UNIFORM ? 16 : REG_SIZE) + r.offset +
236b8e80941Smrg          (r.file == ARF || r.file == FIXED_GRF ? r.subnr : 0);
237b8e80941Smrg}
238b8e80941Smrg
239b8e80941Smrg/**
240b8e80941Smrg * Return whether the register region starting at \p r and spanning \p dr
241b8e80941Smrg * bytes could potentially overlap the register region starting at \p s and
242b8e80941Smrg * spanning \p ds bytes.
243b8e80941Smrg */
244b8e80941Smrgstatic inline bool
245b8e80941Smrgregions_overlap(const backend_reg &r, unsigned dr,
246b8e80941Smrg                const backend_reg &s, unsigned ds)
247b8e80941Smrg{
248b8e80941Smrg   if (r.file == MRF && (r.nr & BRW_MRF_COMPR4)) {
249b8e80941Smrg      /* COMPR4 regions are translated by the hardware during decompression
250b8e80941Smrg       * into two separate half-regions 4 MRFs apart from each other.
251b8e80941Smrg       */
252b8e80941Smrg      backend_reg t0 = r;
253b8e80941Smrg      t0.nr &= ~BRW_MRF_COMPR4;
254b8e80941Smrg      backend_reg t1 = t0;
255b8e80941Smrg      t1.offset += 4 * REG_SIZE;
256b8e80941Smrg      return regions_overlap(t0, dr / 2, s, ds) ||
257b8e80941Smrg             regions_overlap(t1, dr / 2, s, ds);
258b8e80941Smrg
259b8e80941Smrg   } else if (s.file == MRF && (s.nr & BRW_MRF_COMPR4)) {
260b8e80941Smrg      return regions_overlap(s, ds, r, dr);
261b8e80941Smrg
262b8e80941Smrg   } else {
263b8e80941Smrg      return reg_space(r) == reg_space(s) &&
264b8e80941Smrg             !(reg_offset(r) + dr <= reg_offset(s) ||
265b8e80941Smrg               reg_offset(s) + ds <= reg_offset(r));
266b8e80941Smrg   }
267b8e80941Smrg}
268b8e80941Smrg
269b8e80941Smrgclass vec4_instruction : public backend_instruction {
270b8e80941Smrgpublic:
271b8e80941Smrg   DECLARE_RALLOC_CXX_OPERATORS(vec4_instruction)
272b8e80941Smrg
273b8e80941Smrg   vec4_instruction(enum opcode opcode,
274b8e80941Smrg                    const dst_reg &dst = dst_reg(),
275b8e80941Smrg                    const src_reg &src0 = src_reg(),
276b8e80941Smrg                    const src_reg &src1 = src_reg(),
277b8e80941Smrg                    const src_reg &src2 = src_reg());
278b8e80941Smrg
279b8e80941Smrg   dst_reg dst;
280b8e80941Smrg   src_reg src[3];
281b8e80941Smrg
282b8e80941Smrg   enum brw_urb_write_flags urb_write_flags;
283b8e80941Smrg
284b8e80941Smrg   unsigned sol_binding; /**< gen6: SOL binding table index */
285b8e80941Smrg   bool sol_final_write; /**< gen6: send commit message */
286b8e80941Smrg   unsigned sol_vertex; /**< gen6: used for setting dst index in SVB header */
287b8e80941Smrg
288b8e80941Smrg   bool is_send_from_grf();
289b8e80941Smrg   unsigned size_read(unsigned arg) const;
290b8e80941Smrg   bool can_reswizzle(const struct gen_device_info *devinfo, int dst_writemask,
291b8e80941Smrg                      int swizzle, int swizzle_mask);
292b8e80941Smrg   void reswizzle(int dst_writemask, int swizzle);
293b8e80941Smrg   bool can_do_source_mods(const struct gen_device_info *devinfo);
294b8e80941Smrg   bool can_do_cmod();
295b8e80941Smrg   bool can_do_writemask(const struct gen_device_info *devinfo);
296b8e80941Smrg   bool can_change_types() const;
297b8e80941Smrg   bool has_source_and_destination_hazard() const;
298b8e80941Smrg
299b8e80941Smrg   bool is_align1_partial_write()
300b8e80941Smrg   {
301b8e80941Smrg      return opcode == VEC4_OPCODE_SET_LOW_32BIT ||
302b8e80941Smrg             opcode == VEC4_OPCODE_SET_HIGH_32BIT;
303b8e80941Smrg   }
304b8e80941Smrg
305b8e80941Smrg   bool reads_flag()
306b8e80941Smrg   {
307b8e80941Smrg      return predicate || opcode == VS_OPCODE_UNPACK_FLAGS_SIMD4X2;
308b8e80941Smrg   }
309b8e80941Smrg
310b8e80941Smrg   bool reads_flag(unsigned c)
311b8e80941Smrg   {
312b8e80941Smrg      if (opcode == VS_OPCODE_UNPACK_FLAGS_SIMD4X2)
313b8e80941Smrg         return true;
314b8e80941Smrg
315b8e80941Smrg      switch (predicate) {
316b8e80941Smrg      case BRW_PREDICATE_NONE:
317b8e80941Smrg         return false;
318b8e80941Smrg      case BRW_PREDICATE_ALIGN16_REPLICATE_X:
319b8e80941Smrg         return c == 0;
320b8e80941Smrg      case BRW_PREDICATE_ALIGN16_REPLICATE_Y:
321b8e80941Smrg         return c == 1;
322b8e80941Smrg      case BRW_PREDICATE_ALIGN16_REPLICATE_Z:
323b8e80941Smrg         return c == 2;
324b8e80941Smrg      case BRW_PREDICATE_ALIGN16_REPLICATE_W:
325b8e80941Smrg         return c == 3;
326b8e80941Smrg      default:
327b8e80941Smrg         return true;
328b8e80941Smrg      }
329b8e80941Smrg   }
330b8e80941Smrg
331b8e80941Smrg   bool writes_flag()
332b8e80941Smrg   {
333b8e80941Smrg      return (conditional_mod && (opcode != BRW_OPCODE_SEL &&
334b8e80941Smrg                                  opcode != BRW_OPCODE_CSEL &&
335b8e80941Smrg                                  opcode != BRW_OPCODE_IF &&
336b8e80941Smrg                                  opcode != BRW_OPCODE_WHILE));
337b8e80941Smrg   }
338b8e80941Smrg
339b8e80941Smrg   bool reads_g0_implicitly() const
340b8e80941Smrg   {
341b8e80941Smrg      switch (opcode) {
342b8e80941Smrg      case SHADER_OPCODE_TEX:
343b8e80941Smrg      case SHADER_OPCODE_TXL:
344b8e80941Smrg      case SHADER_OPCODE_TXD:
345b8e80941Smrg      case SHADER_OPCODE_TXF:
346b8e80941Smrg      case SHADER_OPCODE_TXF_CMS_W:
347b8e80941Smrg      case SHADER_OPCODE_TXF_CMS:
348b8e80941Smrg      case SHADER_OPCODE_TXF_MCS:
349b8e80941Smrg      case SHADER_OPCODE_TXS:
350b8e80941Smrg      case SHADER_OPCODE_TG4:
351b8e80941Smrg      case SHADER_OPCODE_TG4_OFFSET:
352b8e80941Smrg      case SHADER_OPCODE_SAMPLEINFO:
353b8e80941Smrg      case VS_OPCODE_PULL_CONSTANT_LOAD:
354b8e80941Smrg      case GS_OPCODE_SET_PRIMITIVE_ID:
355b8e80941Smrg      case GS_OPCODE_GET_INSTANCE_ID:
356b8e80941Smrg      case SHADER_OPCODE_GEN4_SCRATCH_READ:
357b8e80941Smrg      case SHADER_OPCODE_GEN4_SCRATCH_WRITE:
358b8e80941Smrg         return true;
359b8e80941Smrg      default:
360b8e80941Smrg         return false;
361b8e80941Smrg      }
362b8e80941Smrg   }
363b8e80941Smrg};
364b8e80941Smrg
365b8e80941Smrg/**
366b8e80941Smrg * Make the execution of \p inst dependent on the evaluation of a possibly
367b8e80941Smrg * inverted predicate.
368b8e80941Smrg */
369b8e80941Smrginline vec4_instruction *
370b8e80941Smrgset_predicate_inv(enum brw_predicate pred, bool inverse,
371b8e80941Smrg                  vec4_instruction *inst)
372b8e80941Smrg{
373b8e80941Smrg   inst->predicate = pred;
374b8e80941Smrg   inst->predicate_inverse = inverse;
375b8e80941Smrg   return inst;
376b8e80941Smrg}
377b8e80941Smrg
378b8e80941Smrg/**
379b8e80941Smrg * Make the execution of \p inst dependent on the evaluation of a predicate.
380b8e80941Smrg */
381b8e80941Smrginline vec4_instruction *
382b8e80941Smrgset_predicate(enum brw_predicate pred, vec4_instruction *inst)
383b8e80941Smrg{
384b8e80941Smrg   return set_predicate_inv(pred, false, inst);
385b8e80941Smrg}
386b8e80941Smrg
387b8e80941Smrg/**
388b8e80941Smrg * Write the result of evaluating the condition given by \p mod to a flag
389b8e80941Smrg * register.
390b8e80941Smrg */
391b8e80941Smrginline vec4_instruction *
392b8e80941Smrgset_condmod(enum brw_conditional_mod mod, vec4_instruction *inst)
393b8e80941Smrg{
394b8e80941Smrg   inst->conditional_mod = mod;
395b8e80941Smrg   return inst;
396b8e80941Smrg}
397b8e80941Smrg
398b8e80941Smrg/**
399b8e80941Smrg * Clamp the result of \p inst to the saturation range of its destination
400b8e80941Smrg * datatype.
401b8e80941Smrg */
402b8e80941Smrginline vec4_instruction *
403b8e80941Smrgset_saturate(bool saturate, vec4_instruction *inst)
404b8e80941Smrg{
405b8e80941Smrg   inst->saturate = saturate;
406b8e80941Smrg   return inst;
407b8e80941Smrg}
408b8e80941Smrg
409b8e80941Smrg/**
410b8e80941Smrg * Return the number of dataflow registers written by the instruction (either
411b8e80941Smrg * fully or partially) counted from 'floor(reg_offset(inst->dst) /
412b8e80941Smrg * register_size)'.  The somewhat arbitrary register size unit is 16B for the
413b8e80941Smrg * UNIFORM and IMM files and 32B for all other files.
414b8e80941Smrg */
415b8e80941Smrginline unsigned
416b8e80941Smrgregs_written(const vec4_instruction *inst)
417b8e80941Smrg{
418b8e80941Smrg   assert(inst->dst.file != UNIFORM && inst->dst.file != IMM);
419b8e80941Smrg   return DIV_ROUND_UP(reg_offset(inst->dst) % REG_SIZE + inst->size_written,
420b8e80941Smrg                       REG_SIZE);
421b8e80941Smrg}
422b8e80941Smrg
423b8e80941Smrg/**
424b8e80941Smrg * Return the number of dataflow registers read by the instruction (either
425b8e80941Smrg * fully or partially) counted from 'floor(reg_offset(inst->src[i]) /
426b8e80941Smrg * register_size)'.  The somewhat arbitrary register size unit is 16B for the
427b8e80941Smrg * UNIFORM and IMM files and 32B for all other files.
428b8e80941Smrg */
429b8e80941Smrginline unsigned
430b8e80941Smrgregs_read(const vec4_instruction *inst, unsigned i)
431b8e80941Smrg{
432b8e80941Smrg   const unsigned reg_size =
433b8e80941Smrg      inst->src[i].file == UNIFORM || inst->src[i].file == IMM ? 16 : REG_SIZE;
434b8e80941Smrg   return DIV_ROUND_UP(reg_offset(inst->src[i]) % reg_size + inst->size_read(i),
435b8e80941Smrg                       reg_size);
436b8e80941Smrg}
437b8e80941Smrg
438b8e80941Smrgstatic inline enum brw_reg_type
439b8e80941Smrgget_exec_type(const vec4_instruction *inst)
440b8e80941Smrg{
441b8e80941Smrg   enum brw_reg_type exec_type = BRW_REGISTER_TYPE_B;
442b8e80941Smrg
443b8e80941Smrg   for (int i = 0; i < 3; i++) {
444b8e80941Smrg      if (inst->src[i].file != BAD_FILE) {
445b8e80941Smrg         const brw_reg_type t = get_exec_type(brw_reg_type(inst->src[i].type));
446b8e80941Smrg         if (type_sz(t) > type_sz(exec_type))
447b8e80941Smrg            exec_type = t;
448b8e80941Smrg         else if (type_sz(t) == type_sz(exec_type) &&
449b8e80941Smrg                  brw_reg_type_is_floating_point(t))
450b8e80941Smrg            exec_type = t;
451b8e80941Smrg      }
452b8e80941Smrg   }
453b8e80941Smrg
454b8e80941Smrg   if (exec_type == BRW_REGISTER_TYPE_B)
455b8e80941Smrg      exec_type = inst->dst.type;
456b8e80941Smrg
457b8e80941Smrg   /* TODO: We need to handle half-float conversions. */
458b8e80941Smrg   assert(exec_type != BRW_REGISTER_TYPE_HF ||
459b8e80941Smrg          inst->dst.type == BRW_REGISTER_TYPE_HF);
460b8e80941Smrg   assert(exec_type != BRW_REGISTER_TYPE_B);
461b8e80941Smrg
462b8e80941Smrg   return exec_type;
463b8e80941Smrg}
464b8e80941Smrg
465b8e80941Smrgstatic inline unsigned
466b8e80941Smrgget_exec_type_size(const vec4_instruction *inst)
467b8e80941Smrg{
468b8e80941Smrg   return type_sz(get_exec_type(inst));
469b8e80941Smrg}
470b8e80941Smrg
471b8e80941Smrg} /* namespace brw */
472b8e80941Smrg
473b8e80941Smrg#endif
474