i965: Stop using hardware register types directly
authorMatt Turner <mattst88@gmail.com>
Thu, 27 Jul 2017 04:08:20 +0000 (21:08 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 21 Aug 2017 21:05:23 +0000 (14:05 -0700)
Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
src/intel/compiler/brw_disasm.c
src/intel/compiler/brw_eu_validate.c
src/intel/compiler/brw_reg_type.c
src/intel/compiler/brw_reg_type.h

index 02b48c9cf2a5b5031a259899f78df5f50ca336ed..e2675b5f4c9bc416662f0141e8e977ac8599fb56 100644 (file)
@@ -707,7 +707,8 @@ reg(FILE *file, unsigned _reg_file, unsigned _reg_nr)
 static int
 dest(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
 {
-   unsigned elem_size = brw_element_size(devinfo, inst, dst);
+   enum brw_reg_type type = brw_inst_dst_type(devinfo, inst);
+   unsigned elem_size = brw_reg_type_to_size(type);
    int err = 0;
 
    if (brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1) {
@@ -723,10 +724,7 @@ dest(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          err |= control(file, "horiz stride", horiz_stride,
                         brw_inst_dst_hstride(devinfo, inst), NULL);
          string(file, ">");
-         string(file,
-                brw_hw_reg_type_to_letters(devinfo,
-                                           brw_inst_dst_reg_file(devinfo, inst),
-                                           brw_inst_dst_reg_hw_type(devinfo, inst)));
+         string(file, brw_reg_type_to_letters(type));
       } else {
          string(file, "g[a0");
          if (brw_inst_dst_ia_subreg_nr(devinfo, inst))
@@ -738,10 +736,7 @@ dest(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          err |= control(file, "horiz stride", horiz_stride,
                         brw_inst_dst_hstride(devinfo, inst), NULL);
          string(file, ">");
-         string(file,
-                brw_hw_reg_type_to_letters(devinfo,
-                                           brw_inst_dst_reg_file(devinfo, inst),
-                                           brw_inst_dst_reg_hw_type(devinfo, inst)));
+         string(file, brw_reg_type_to_letters(type));
       }
    } else {
       if (brw_inst_dst_address_mode(devinfo, inst) == BRW_ADDRESS_DIRECT) {
@@ -754,10 +749,7 @@ dest(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          string(file, "<1>");
          err |= control(file, "writemask", writemask,
                         brw_inst_da16_writemask(devinfo, inst), NULL);
-         string(file,
-                brw_hw_reg_type_to_letters(devinfo,
-                                           brw_inst_dst_reg_file(devinfo, inst),
-                                           brw_inst_dst_reg_hw_type(devinfo, inst)));
+         string(file, brw_reg_type_to_letters(type));
       } else {
          err = 1;
          string(file, "Indirect align16 address mode not supported");
@@ -812,7 +804,7 @@ static int
 src_da1(FILE *file,
         const struct gen_device_info *devinfo,
         unsigned opcode,
-        unsigned type, unsigned _reg_file,
+        enum brw_reg_type type, unsigned _reg_file,
         unsigned _vert_stride, unsigned _width, unsigned _horiz_stride,
         unsigned reg_num, unsigned sub_reg_num, unsigned __abs,
         unsigned _negate)
@@ -830,11 +822,11 @@ src_da1(FILE *file,
    if (err == -1)
       return 0;
    if (sub_reg_num) {
-      unsigned elem_size = brw_hw_reg_type_to_size(devinfo, _reg_file, type);
+      unsigned elem_size = brw_reg_type_to_size(type);
       format(file, ".%d", sub_reg_num / elem_size);   /* use formal style like spec */
    }
    src_align1_region(file, _vert_stride, _width, _horiz_stride);
-   string(file, brw_hw_reg_type_to_letters(devinfo, _reg_file, type));
+   string(file, brw_reg_type_to_letters(type));
    return err;
 }
 
@@ -842,7 +834,7 @@ static int
 src_ia1(FILE *file,
         const struct gen_device_info *devinfo,
         unsigned opcode,
-        unsigned type,
+        enum brw_reg_type type,
         unsigned _reg_file,
         int _addr_imm,
         unsigned _addr_subreg_nr,
@@ -866,7 +858,7 @@ src_ia1(FILE *file,
       format(file, " %d", _addr_imm);
    string(file, "]");
    src_align1_region(file, _vert_stride, _width, _horiz_stride);
-   string(file, brw_hw_reg_type_to_letters(devinfo, _reg_file, type));
+   string(file, brw_reg_type_to_letters(type));
    return err;
 }
 
@@ -896,7 +888,7 @@ static int
 src_da16(FILE *file,
          const struct gen_device_info *devinfo,
          unsigned opcode,
-         unsigned _reg_type,
+         enum brw_reg_type type,
          unsigned _reg_file,
          unsigned _vert_stride,
          unsigned _reg_nr,
@@ -918,8 +910,7 @@ src_da16(FILE *file,
    if (err == -1)
       return 0;
    if (_subreg_nr) {
-      unsigned elem_size =
-         brw_hw_reg_type_to_size(devinfo, _reg_file, _reg_type);
+      unsigned elem_size = brw_reg_type_to_size(type);
 
       /* bit4 for subreg number byte addressing. Make this same meaning as
          in da1 case, so output looks consistent. */
@@ -929,7 +920,7 @@ src_da16(FILE *file,
    err |= control(file, "vert stride", vert_stride, _vert_stride, NULL);
    string(file, ">");
    err |= src_swizzle(file, BRW_SWIZZLE4(swz_x, swz_y, swz_z, swz_w));
-   string(file, brw_hw_reg_type_to_letters(devinfo, _reg_file, _reg_type));
+   string(file, brw_reg_type_to_letters(type));
    return err;
 }
 
@@ -1077,7 +1068,7 @@ src0(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_da1(file,
                         devinfo,
                         brw_inst_opcode(devinfo, inst),
-                        brw_inst_src0_reg_hw_type(devinfo, inst),
+                        brw_inst_src0_type(devinfo, inst),
                         brw_inst_src0_reg_file(devinfo, inst),
                         brw_inst_src0_vstride(devinfo, inst),
                         brw_inst_src0_width(devinfo, inst),
@@ -1090,7 +1081,7 @@ src0(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_ia1(file,
                         devinfo,
                         brw_inst_opcode(devinfo, inst),
-                        brw_inst_src0_reg_hw_type(devinfo, inst),
+                        brw_inst_src0_type(devinfo, inst),
                         brw_inst_src0_reg_file(devinfo, inst),
                         brw_inst_src0_ia1_addr_imm(devinfo, inst),
                         brw_inst_src0_ia_subreg_nr(devinfo, inst),
@@ -1105,7 +1096,7 @@ src0(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_da16(file,
                          devinfo,
                          brw_inst_opcode(devinfo, inst),
-                         brw_inst_src0_reg_hw_type(devinfo, inst),
+                         brw_inst_src0_type(devinfo, inst),
                          brw_inst_src0_reg_file(devinfo, inst),
                          brw_inst_src0_vstride(devinfo, inst),
                          brw_inst_src0_da_reg_nr(devinfo, inst),
@@ -1133,7 +1124,7 @@ src1(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_da1(file,
                         devinfo,
                         brw_inst_opcode(devinfo, inst),
-                        brw_inst_src1_reg_hw_type(devinfo, inst),
+                        brw_inst_src1_type(devinfo, inst),
                         brw_inst_src1_reg_file(devinfo, inst),
                         brw_inst_src1_vstride(devinfo, inst),
                         brw_inst_src1_width(devinfo, inst),
@@ -1146,7 +1137,7 @@ src1(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_ia1(file,
                         devinfo,
                         brw_inst_opcode(devinfo, inst),
-                        brw_inst_src1_reg_hw_type(devinfo, inst),
+                        brw_inst_src1_type(devinfo, inst),
                         brw_inst_src1_reg_file(devinfo, inst),
                         brw_inst_src1_ia1_addr_imm(devinfo, inst),
                         brw_inst_src1_ia_subreg_nr(devinfo, inst),
@@ -1161,7 +1152,7 @@ src1(FILE *file, const struct gen_device_info *devinfo, const brw_inst *inst)
          return src_da16(file,
                          devinfo,
                          brw_inst_opcode(devinfo, inst),
-                         brw_inst_src1_reg_hw_type(devinfo, inst),
+                         brw_inst_src1_type(devinfo, inst),
                          brw_inst_src1_reg_file(devinfo, inst),
                          brw_inst_src1_vstride(devinfo, inst),
                          brw_inst_src1_da_reg_nr(devinfo, inst),
index c004e62ffbae2ed6efded7c21b60734a8e4a0bc4..249342fb9dc6d720b4c9e12a9b1c98d3c6674933 100644 (file)
@@ -82,25 +82,25 @@ static unsigned
 signed_type(unsigned type)
 {
    switch (type) {
-   case BRW_HW_REG_TYPE_UD:  return BRW_HW_REG_TYPE_D;
-   case BRW_HW_REG_TYPE_UW:  return BRW_HW_REG_TYPE_W;
-   case BRW_HW_REG_TYPE_UB:  return BRW_HW_REG_TYPE_B;
-   case GEN8_HW_REG_TYPE_UQ: return GEN8_HW_REG_TYPE_Q;
-   default:                  return type;
+   case BRW_REGISTER_TYPE_UD: return BRW_REGISTER_TYPE_D;
+   case BRW_REGISTER_TYPE_UW: return BRW_REGISTER_TYPE_W;
+   case BRW_REGISTER_TYPE_UB: return BRW_REGISTER_TYPE_B;
+   case BRW_REGISTER_TYPE_UQ: return BRW_REGISTER_TYPE_Q;
+   default:                   return type;
    }
 }
 
 static bool
 inst_is_raw_move(const struct gen_device_info *devinfo, const brw_inst *inst)
 {
-   unsigned dst_type = signed_type(brw_inst_dst_reg_hw_type(devinfo, inst));
-   unsigned src_type = signed_type(brw_inst_src0_reg_hw_type(devinfo, inst));
+   unsigned dst_type = signed_type(brw_inst_dst_type(devinfo, inst));
+   unsigned src_type = signed_type(brw_inst_src0_type(devinfo, inst));
 
    if (brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE) {
       /* FIXME: not strictly true */
-      if (brw_inst_src0_reg_hw_type(devinfo, inst) == BRW_HW_IMM_TYPE_VF ||
-          brw_inst_src0_reg_hw_type(devinfo, inst) == BRW_HW_IMM_TYPE_UV ||
-          brw_inst_src0_reg_hw_type(devinfo, inst) == BRW_HW_IMM_TYPE_V) {
+      if (brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_VF ||
+          brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_UV ||
+          brw_inst_src0_type(devinfo, inst) == BRW_REGISTER_TYPE_V) {
          return false;
       }
    } else if (brw_inst_src0_negate(devinfo, inst) ||
@@ -261,84 +261,63 @@ is_unsupported_inst(const struct gen_device_info *devinfo,
    return brw_opcode_desc(devinfo, brw_inst_opcode(devinfo, inst)) == NULL;
 }
 
-static unsigned
-execution_type_for_type(unsigned type, bool is_immediate)
+static enum brw_reg_type
+execution_type_for_type(enum brw_reg_type type)
 {
-   /* The meaning of the type bits is dependent on whether the operand is an
-    * immediate, so normalize them first.
-    */
-   if (is_immediate) {
-      switch (type) {
-      case BRW_HW_IMM_TYPE_UV:
-      case BRW_HW_IMM_TYPE_V:
-         type = BRW_HW_REG_TYPE_W;
-         break;
-      case BRW_HW_IMM_TYPE_VF:
-         type = BRW_HW_REG_TYPE_F;
-         break;
-      case GEN8_HW_IMM_TYPE_DF:
-         type = GEN7_HW_REG_TYPE_DF;
-         break;
-      case GEN8_HW_IMM_TYPE_HF:
-         type = GEN8_HW_IMM_TYPE_HF;
-         break;
-      default:
-         break;
-      }
-   }
-
    switch (type) {
-   case BRW_HW_REG_TYPE_UD:
-   case BRW_HW_REG_TYPE_D:
-      return BRW_HW_REG_TYPE_D;
-   case BRW_HW_REG_TYPE_UW:
-   case BRW_HW_REG_TYPE_W:
-   case BRW_HW_REG_TYPE_UB:
-   case BRW_HW_REG_TYPE_B:
-      return BRW_HW_REG_TYPE_W;
-   case GEN8_HW_REG_TYPE_UQ:
-   case GEN8_HW_REG_TYPE_Q:
-      return GEN8_HW_REG_TYPE_Q;
-   case BRW_HW_REG_TYPE_F:
-   case GEN7_HW_REG_TYPE_DF:
-   case GEN8_HW_REG_TYPE_HF:
+   case BRW_REGISTER_TYPE_DF:
+   case BRW_REGISTER_TYPE_F:
+   case BRW_REGISTER_TYPE_HF:
       return type;
-   default:
-      unreachable("not reached");
+
+   case BRW_REGISTER_TYPE_VF:
+      return BRW_REGISTER_TYPE_F;
+
+   case BRW_REGISTER_TYPE_Q:
+   case BRW_REGISTER_TYPE_UQ:
+      return BRW_REGISTER_TYPE_Q;
+
+   case BRW_REGISTER_TYPE_D:
+   case BRW_REGISTER_TYPE_UD:
+      return BRW_REGISTER_TYPE_D;
+
+   case BRW_REGISTER_TYPE_W:
+   case BRW_REGISTER_TYPE_UW:
+   case BRW_REGISTER_TYPE_B:
+   case BRW_REGISTER_TYPE_UB:
+   case BRW_REGISTER_TYPE_V:
+   case BRW_REGISTER_TYPE_UV:
+      return BRW_REGISTER_TYPE_W;
    }
+   unreachable("not reached");
 }
 
 /**
  * Returns the execution type of an instruction \p inst
  */
-static unsigned
+static enum brw_reg_type
 execution_type(const struct gen_device_info *devinfo, const brw_inst *inst)
 {
    unsigned num_sources = num_sources_from_inst(devinfo, inst);
-   unsigned src0_exec_type, src1_exec_type;
-   unsigned src0_type = brw_inst_src0_reg_hw_type(devinfo, inst);
-   unsigned src1_type = brw_inst_src1_reg_hw_type(devinfo, inst);
-
-   bool src0_is_immediate =
-      brw_inst_src0_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE;
-   bool src1_is_immediate =
-      brw_inst_src1_reg_file(devinfo, inst) == BRW_IMMEDIATE_VALUE;
+   enum brw_reg_type src0_exec_type, src1_exec_type;
+   enum brw_reg_type src0_type = brw_inst_src0_type(devinfo, inst);
+   enum brw_reg_type src1_type = brw_inst_src1_type(devinfo, inst);
 
    /* Execution data type is independent of destination data type, except in
     * mixed F/HF instructions on CHV and SKL+.
     */
-   unsigned dst_exec_type = brw_inst_dst_reg_hw_type(devinfo, inst);
+   enum brw_reg_type dst_exec_type = brw_inst_dst_type(devinfo, inst);
 
-   src0_exec_type = execution_type_for_type(src0_type, src0_is_immediate);
+   src0_exec_type = execution_type_for_type(src0_type);
    if (num_sources == 1) {
       if ((devinfo->gen >= 9 || devinfo->is_cherryview) &&
-          src0_exec_type == GEN8_HW_REG_TYPE_HF) {
+          src0_exec_type == BRW_REGISTER_TYPE_HF) {
          return dst_exec_type;
       }
       return src0_exec_type;
    }
 
-   src1_exec_type = execution_type_for_type(src1_type, src1_is_immediate);
+   src1_exec_type = execution_type_for_type(src1_type);
    if (src0_exec_type == src1_exec_type)
       return src0_exec_type;
 
@@ -346,38 +325,38 @@ execution_type(const struct gen_device_info *devinfo, const brw_inst *inst)
     * (and not allowed on later platforms)
     */
    if (devinfo->gen < 6 &&
-       (src0_exec_type == BRW_HW_REG_TYPE_F ||
-        src1_exec_type == BRW_HW_REG_TYPE_F))
-      return BRW_HW_REG_TYPE_F;
+       (src0_exec_type == BRW_REGISTER_TYPE_F ||
+        src1_exec_type == BRW_REGISTER_TYPE_F))
+      return BRW_REGISTER_TYPE_F;
 
-   if (src0_exec_type == GEN8_HW_REG_TYPE_Q ||
-       src1_exec_type == GEN8_HW_REG_TYPE_Q)
-      return GEN8_HW_REG_TYPE_Q;
+   if (src0_exec_type == BRW_REGISTER_TYPE_Q ||
+       src1_exec_type == BRW_REGISTER_TYPE_Q)
+      return BRW_REGISTER_TYPE_Q;
 
-   if (src0_exec_type == BRW_HW_REG_TYPE_D ||
-       src1_exec_type == BRW_HW_REG_TYPE_D)
-      return BRW_HW_REG_TYPE_D;
+   if (src0_exec_type == BRW_REGISTER_TYPE_D ||
+       src1_exec_type == BRW_REGISTER_TYPE_D)
+      return BRW_REGISTER_TYPE_D;
 
-   if (src0_exec_type == BRW_HW_REG_TYPE_W ||
-       src1_exec_type == BRW_HW_REG_TYPE_W)
-      return BRW_HW_REG_TYPE_W;
+   if (src0_exec_type == BRW_REGISTER_TYPE_W ||
+       src1_exec_type == BRW_REGISTER_TYPE_W)
+      return BRW_REGISTER_TYPE_W;
 
-   if (src0_exec_type == GEN7_HW_REG_TYPE_DF ||
-       src1_exec_type == GEN7_HW_REG_TYPE_DF)
-      return GEN7_HW_REG_TYPE_DF;
+   if (src0_exec_type == BRW_REGISTER_TYPE_DF ||
+       src1_exec_type == BRW_REGISTER_TYPE_DF)
+      return BRW_REGISTER_TYPE_DF;
 
    if (devinfo->gen >= 9 || devinfo->is_cherryview) {
-      if (dst_exec_type == BRW_HW_REG_TYPE_F ||
-          src0_exec_type == BRW_HW_REG_TYPE_F ||
-          src1_exec_type == BRW_HW_REG_TYPE_F) {
-         return BRW_HW_REG_TYPE_F;
+      if (dst_exec_type == BRW_REGISTER_TYPE_F ||
+          src0_exec_type == BRW_REGISTER_TYPE_F ||
+          src1_exec_type == BRW_REGISTER_TYPE_F) {
+         return BRW_REGISTER_TYPE_F;
       } else {
-         return GEN8_HW_REG_TYPE_HF;
+         return BRW_REGISTER_TYPE_HF;
       }
    }
 
-   assert(src0_exec_type == BRW_HW_REG_TYPE_F);
-   return BRW_HW_REG_TYPE_F;
+   assert(src0_exec_type == BRW_REGISTER_TYPE_F);
+   return BRW_REGISTER_TYPE_F;
 }
 
 /**
@@ -442,9 +421,10 @@ general_restrictions_based_on_operand_types(const struct gen_device_info *devinf
     */
 
    unsigned dst_stride = 1 << (brw_inst_dst_hstride(devinfo, inst) - 1);
+   enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
    bool dst_type_is_byte =
-      brw_inst_dst_reg_hw_type(devinfo, inst) == BRW_HW_REG_TYPE_B ||
-      brw_inst_dst_reg_hw_type(devinfo, inst) == BRW_HW_REG_TYPE_UB;
+      brw_inst_dst_type(devinfo, inst) == BRW_REGISTER_TYPE_B ||
+      brw_inst_dst_type(devinfo, inst) == BRW_REGISTER_TYPE_UB;
 
    if (dst_type_is_byte) {
       if (is_packed(exec_size * dst_stride, exec_size, dst_stride)) {
@@ -458,9 +438,8 @@ general_restrictions_based_on_operand_types(const struct gen_device_info *devinf
    }
 
    unsigned exec_type = execution_type(devinfo, inst);
-   unsigned exec_type_size =
-      brw_hw_reg_type_to_size(devinfo, BRW_GENERAL_REGISTER_FILE, exec_type);
-   unsigned dst_type_size = brw_element_size(devinfo, inst, dst);
+   unsigned exec_type_size = brw_reg_type_to_size(exec_type);
+   unsigned dst_type_size = brw_reg_type_to_size(dst_type);
 
    /* On IVB/BYT, region parameters and execution size for DF are in terms of
     * 32-bit elements, so they are doubled. For evaluating the validity of an
@@ -558,6 +537,7 @@ general_restrictions_on_region_parameters(const struct gen_device_info *devinfo,
 
    for (unsigned i = 0; i < num_sources; i++) {
       unsigned vstride, width, hstride, element_size, subreg;
+      enum brw_reg_type type;
 
 #define DO_SRC(n)                                                              \
       if (brw_inst_src ## n ## _reg_file(devinfo, inst) ==                     \
@@ -569,7 +549,8 @@ general_restrictions_on_region_parameters(const struct gen_device_info *devinfo,
       width = 1 << brw_inst_src ## n ## _width(devinfo, inst);                 \
       hstride = brw_inst_src ## n ## _hstride(devinfo, inst) ?                 \
                 (1 << (brw_inst_src ## n ## _hstride(devinfo, inst) - 1)) : 0; \
-      element_size = brw_element_size(devinfo, inst, src ## n);                \
+      type = brw_inst_src ## n ## _type(devinfo, inst);                        \
+      element_size = brw_reg_type_to_size(type);                               \
       subreg = brw_inst_src ## n ## _da1_subreg_nr(devinfo, inst)
 
       if (i == 0) {
@@ -748,6 +729,7 @@ region_alignment_rules(const struct gen_device_info *devinfo,
 
    for (unsigned i = 0; i < num_sources; i++) {
       unsigned vstride, width, hstride, element_size, subreg;
+      enum brw_reg_type type;
 
       /* In Direct Addressing mode, a source cannot span more than 2 adjacent
        * GRF registers.
@@ -767,7 +749,8 @@ region_alignment_rules(const struct gen_device_info *devinfo,
       width = 1 << brw_inst_src ## n ## _width(devinfo, inst);                 \
       hstride = brw_inst_src ## n ## _hstride(devinfo, inst) ?                 \
                 (1 << (brw_inst_src ## n ## _hstride(devinfo, inst) - 1)) : 0; \
-      element_size = brw_element_size(devinfo, inst, src ## n);                \
+      type = brw_inst_src ## n ## _type(devinfo, inst);                        \
+      element_size = brw_reg_type_to_size(type);                               \
       subreg = brw_inst_src ## n ## _da1_subreg_nr(devinfo, inst);             \
       align1_access_mask(src ## n ## _access_mask,                             \
                          exec_size, element_size, subreg,                      \
@@ -794,7 +777,8 @@ region_alignment_rules(const struct gen_device_info *devinfo,
       return error_msg;
 
    unsigned stride = 1 << (brw_inst_dst_hstride(devinfo, inst) - 1);
-   unsigned element_size = brw_element_size(devinfo, inst, dst);
+   enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
+   unsigned element_size = brw_reg_type_to_size(dst_type);
    unsigned subreg = brw_inst_dst_da1_subreg_nr(devinfo, inst);
    unsigned offset = ((exec_size - 1) * stride * element_size) + subreg;
    ERROR_IF(offset >= 64,
@@ -1000,9 +984,10 @@ region_alignment_rules(const struct gen_device_info *devinfo,
     * is that the size of the destination type is 4 bytes.
     */
    if (devinfo->gen <= 7 && dst_regs == 2) {
+      enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
       bool dst_is_packed_dword =
          is_packed(exec_size * stride, exec_size, stride) &&
-         brw_element_size(devinfo, inst, dst) == 4;
+         brw_reg_type_to_size(dst_type) == 4;
 
       for (unsigned i = 0; i < num_sources; i++) {
 #define DO_SRC(n)                                                                  \
@@ -1014,8 +999,8 @@ region_alignment_rules(const struct gen_device_info *devinfo,
                    (1 << (brw_inst_src ## n ## _hstride(devinfo, inst) - 1)) : 0;  \
          bool src ## n ## _is_packed_word =                                        \
             is_packed(vstride, width, hstride) &&                                  \
-            (brw_inst_src ## n ## _reg_hw_type(devinfo, inst) == BRW_HW_REG_TYPE_W || \
-             brw_inst_src ## n ## _reg_hw_type(devinfo, inst) == BRW_HW_REG_TYPE_UW); \
+            (brw_inst_src ## n ## _type(devinfo, inst) == BRW_REGISTER_TYPE_W ||   \
+             brw_inst_src ## n ## _type(devinfo, inst) == BRW_REGISTER_TYPE_UW);   \
                                                                                    \
          ERROR_IF(src ## n ## _regs == 1 &&                                        \
                   !src ## n ## _has_scalar_region(devinfo, inst) &&                \
@@ -1052,13 +1037,14 @@ vector_immediate_restrictions(const struct gen_device_info *devinfo,
    if (file != BRW_IMMEDIATE_VALUE)
       return (struct string){};
 
-   unsigned dst_type_size = brw_element_size(devinfo, inst, dst);
+   enum brw_reg_type dst_type = brw_inst_dst_type(devinfo, inst);
+   unsigned dst_type_size = brw_reg_type_to_size(dst_type);
    unsigned dst_subreg = brw_inst_access_mode(devinfo, inst) == BRW_ALIGN_1 ?
                          brw_inst_dst_da1_subreg_nr(devinfo, inst) : 0;
    unsigned dst_stride = 1 << (brw_inst_dst_hstride(devinfo, inst) - 1);
-   unsigned type = num_sources == 1 ?
-                   brw_inst_src0_reg_hw_type(devinfo, inst) :
-                   brw_inst_src1_reg_hw_type(devinfo, inst);
+   enum brw_reg_type type = num_sources == 1 ?
+                            brw_inst_src0_type(devinfo, inst) :
+                            brw_inst_src1_type(devinfo, inst);
 
    /* The PRMs say:
     *
@@ -1072,14 +1058,14 @@ vector_immediate_restrictions(const struct gen_device_info *devinfo,
     * applies.
     */
    switch (type) {
-   case BRW_HW_IMM_TYPE_V:
-   case BRW_HW_IMM_TYPE_UV:
-   case BRW_HW_IMM_TYPE_VF:
+   case BRW_REGISTER_TYPE_V:
+   case BRW_REGISTER_TYPE_UV:
+   case BRW_REGISTER_TYPE_VF:
       ERROR_IF(dst_subreg % (128 / 8) != 0,
                "Destination must be 128-bit aligned in order to use immediate "
                "vector types");
 
-      if (type == BRW_HW_IMM_TYPE_VF) {
+      if (type == BRW_REGISTER_TYPE_VF) {
          ERROR_IF(dst_type_size * dst_stride != 4,
                   "Destination must have stride equivalent to dword in order "
                   "to use the VF type");
index 3246ffc3113d89d5669917d209bbfabe8e975a1f..e2f4d3558d806b7b2a81626ae51bae19a6e06312 100644 (file)
@@ -95,14 +95,10 @@ brw_hw_type_to_reg_type(const struct gen_device_info *devinfo,
 }
 
 /**
- * Return the element size given a hardware register type and file.
- *
- * The hardware encoding may depend on whether the value is an immediate.
+ * Return the element size given a register type.
  */
 unsigned
-brw_hw_reg_type_to_size(const struct gen_device_info *devinfo,
-                        enum brw_reg_file file,
-                        unsigned hw_type)
+brw_reg_type_to_size(enum brw_reg_type type)
 {
    static const unsigned type_size[] = {
       [BRW_REGISTER_TYPE_DF] = 8,
@@ -121,7 +117,6 @@ brw_hw_reg_type_to_size(const struct gen_device_info *devinfo,
       [BRW_REGISTER_TYPE_V]  = 2,
       [BRW_REGISTER_TYPE_UV] = 2,
    };
-   enum brw_reg_type type = brw_hw_type_to_reg_type(devinfo, file, hw_type);
    return type_size[type];
 }
 
@@ -154,11 +149,3 @@ brw_reg_type_to_letters(enum brw_reg_type type)
    assert(type < ARRAY_SIZE(letters));
    return letters[type];
 }
-
-const char *
-brw_hw_reg_type_to_letters(const struct gen_device_info *devinfo,
-                           enum brw_reg_file file, unsigned hw_type)
-{
-   enum brw_reg_type type = brw_hw_type_to_reg_type(devinfo, file, hw_type);
-   return brw_reg_type_to_letters(type);
-}
index 75f115111486a7f78c0afcd215cdd23c8bbe36fc..6fc57792b4b5e54674d64534b10258e97db5e5e0 100644 (file)
@@ -67,21 +67,12 @@ enum brw_reg_type
 brw_hw_type_to_reg_type(const struct gen_device_info *devinfo,
                         enum brw_reg_file file, unsigned hw_type);
 
-#define brw_element_size(devinfo, inst, operand)                                \
-   brw_hw_reg_type_to_size(devinfo,                                             \
-                           brw_inst_ ## operand ## _reg_file(devinfo, inst),    \
-                           brw_inst_ ## operand ## _reg_hw_type(devinfo, inst))
 unsigned
-brw_hw_reg_type_to_size(const struct gen_device_info *devinfo,
-                        enum brw_reg_file file, unsigned hw_type);
+brw_reg_type_to_size(enum brw_reg_type type);
 
 const char *
 brw_reg_type_to_letters(enum brw_reg_type type);
 
-const char *
-brw_hw_reg_type_to_letters(const struct gen_device_info *devinfo,
-                           enum brw_reg_file file, unsigned hw_type);
-
 #ifdef __cplusplus
 }
 #endif