i965/vec4: use byte_offset() instead of offset()
authorIago Toral Quiroga <itoral@igalia.com>
Mon, 3 Oct 2016 11:26:54 +0000 (13:26 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Thu, 27 Oct 2016 08:59:31 +0000 (10:59 +0200)
In a later patch we want to change the semantics of offset() to be in terms
of SIMD width and scalar channels so it is consistent with the definition
of the same helper in the scalar backend. However, some uses of offset()
in the vec4 backend do not operate naturally in terms of these
semantics. In these cases it is more natural to use the byte_offset() helper
instead.

Reviewed-by: Francisco Jerez <currojerez@riseup.net>
src/mesa/drivers/dri/i965/brw_vec4_cse.cpp
src/mesa/drivers/dri/i965/brw_vec4_dead_code_eliminate.cpp
src/mesa/drivers/dri/i965/brw_vec4_live_variables.cpp
src/mesa/drivers/dri/i965/brw_vec4_tcs.cpp
src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp

index 1b91db95a8097042ae4816bd6f6aa0d1df34a363..bf7e4a4f070d62b9a683b3f4041bf493629515f0 100644 (file)
@@ -182,8 +182,9 @@ vec4_visitor::opt_cse_local(bblock_t *block)
                                            NULL), inst->dst.type);
 
                for (unsigned i = 0; i < regs_written(entry->generator); ++i) {
-                  vec4_instruction *copy = MOV(offset(entry->generator->dst, i),
-                                               offset(entry->tmp, i));
+                  vec4_instruction *copy =
+                     MOV(byte_offset(entry->generator->dst, i * REG_SIZE),
+                         byte_offset(entry->tmp, i * REG_SIZE));
                   copy->force_writemask_all =
                      entry->generator->force_writemask_all;
                   entry->generator->insert_after(block, copy);
@@ -197,8 +198,9 @@ vec4_visitor::opt_cse_local(bblock_t *block)
                assert(inst->dst.type == entry->tmp.type);
 
                for (unsigned i = 0; i < regs_written(inst); ++i) {
-                  vec4_instruction *copy = MOV(offset(inst->dst, i),
-                                               offset(entry->tmp, i));
+                  vec4_instruction *copy =
+                     MOV(byte_offset(inst->dst, i * REG_SIZE),
+                         byte_offset(entry->tmp, i * REG_SIZE));
                   copy->force_writemask_all = inst->force_writemask_all;
                   inst->insert_before(block, copy);
                }
index 50706a977cb64ac33fa9829577a965cc3385c231..916a3fb26d1ccaebac9c9971831fb0ba0145f347 100644 (file)
@@ -61,8 +61,9 @@ vec4_visitor::dead_code_eliminate()
             if (inst->dst.file == VGRF) {
                for (unsigned i = 0; i < regs_written(inst); i++) {
                   for (int c = 0; c < 4; c++)
-                     result_live[c] |= BITSET_TEST(
-                        live, var_from_reg(alloc, offset(inst->dst, i), c));
+                     result_live[c] |= BITSET_TEST(live,
+                        var_from_reg(alloc,
+                                     byte_offset(inst->dst, i * REG_SIZE), c));
                }
             } else {
                for (unsigned c = 0; c < 4; c++)
@@ -113,8 +114,11 @@ vec4_visitor::dead_code_eliminate()
             for (unsigned i = 0; i < regs_written(inst); i++) {
                for (int c = 0; c < 4; c++) {
                   if (inst->dst.writemask & (1 << c)) {
-                     BITSET_CLEAR(live, var_from_reg(alloc,
-                                                     offset(inst->dst, i), c));
+                     BITSET_CLEAR(live,
+                                  var_from_reg(alloc,
+                                               byte_offset(inst->dst,
+                                                           i * REG_SIZE),
+                                               c));
                   }
                }
             }
@@ -135,7 +139,9 @@ vec4_visitor::dead_code_eliminate()
                for (unsigned j = 0; j < regs_read(inst, i); j++) {
                   for (int c = 0; c < 4; c++) {
                      BITSET_SET(live, var_from_reg(alloc,
-                                                   offset(inst->src[i], j), c));
+                                                   byte_offset(inst->src[i],
+                                                               j * REG_SIZE),
+                                                   c));
                   }
                }
             }
index 20344ed17708586afc96247f993b7170cb2717b9..b70d6c2fab68e40e3cb5b2bc01943e186c41c2a1 100644 (file)
@@ -79,7 +79,9 @@ vec4_live_variables::setup_def_use()
                for (unsigned j = 0; j < regs_read(inst, i); j++) {
                   for (int c = 0; c < 4; c++) {
                      const unsigned v =
-                        var_from_reg(alloc, offset(inst->src[i], j), c);
+                        var_from_reg(alloc,
+                                     byte_offset(inst->src[i], j * REG_SIZE),
+                                     c);
                      if (!BITSET_TEST(bd->def, v))
                         BITSET_SET(bd->use, v);
                   }
@@ -103,7 +105,8 @@ vec4_live_variables::setup_def_use()
                for (int c = 0; c < 4; c++) {
                   if (inst->dst.writemask & (1 << c)) {
                      const unsigned v =
-                        var_from_reg(alloc, offset(inst->dst, i), c);
+                        var_from_reg(alloc,
+                                     byte_offset(inst->dst, i * REG_SIZE), c);
                      if (!BITSET_TEST(bd->use, v))
                         BITSET_SET(bd->def, v);
                   }
@@ -260,7 +263,8 @@ vec4_visitor::calculate_live_intervals()
             for (unsigned j = 0; j < regs_read(inst, i); j++) {
                for (int c = 0; c < 4; c++) {
                   const unsigned v =
-                     var_from_reg(alloc, offset(inst->src[i], j), c);
+                     var_from_reg(alloc,
+                                  byte_offset(inst->src[i], j * REG_SIZE), c);
                   start[v] = MIN2(start[v], ip);
                   end[v] = ip;
                }
@@ -273,7 +277,8 @@ vec4_visitor::calculate_live_intervals()
             for (int c = 0; c < 4; c++) {
                if (inst->dst.writemask & (1 << c)) {
                   const unsigned v =
-                     var_from_reg(alloc, offset(inst->dst, i), c);
+                     var_from_reg(alloc,
+                                  byte_offset(inst->dst, i * REG_SIZE), c);
                   start[v] = MIN2(start[v], ip);
                   end[v] = ip;
                }
index 124632cdbc58a0a4e826086cdd781eca87ec76ed..c6a6b5e151695963f36c740d389f49f06e8ed3a4 100644 (file)
@@ -240,7 +240,8 @@ vec4_tcs_visitor::emit_urb_write(const src_reg &value,
    inst = emit(TCS_OPCODE_SET_OUTPUT_URB_OFFSETS, dst_reg(message),
                brw_imm_ud(writemask), indirect_offset);
    inst->force_writemask_all = true;
-   inst = emit(MOV(offset(dst_reg(retype(message, value.type)), 1), value));
+   inst = emit(MOV(byte_offset(dst_reg(retype(message, value.type)), REG_SIZE),
+                   value));
    inst->force_writemask_all = true;
 
    inst = emit(TCS_OPCODE_URB_WRITE, dst_null_f(), message);
index eca753c7a74fe24ae8a3401fb64e3d5459f418c3..954f147fe7e83dc50c6813a221d63ec69ff68370 100644 (file)
@@ -781,7 +781,7 @@ vec4_visitor::emit_pull_constant_load_reg(dst_reg dst,
       else
          emit(pull);
 
-      dst_reg index_reg = retype(offset(dst_reg(header), 1),
+      dst_reg index_reg = retype(byte_offset(dst_reg(header), REG_SIZE),
                                  offset_reg.type);
       pull = MOV(writemask(index_reg, WRITEMASK_X), offset_reg);