i965: Replace default case with list of enum values.
authorMatt Turner <mattst88@gmail.com>
Mon, 26 Oct 2015 13:58:56 +0000 (06:58 -0700)
committerMatt Turner <mattst88@gmail.com>
Mon, 2 Nov 2015 17:33:31 +0000 (09:33 -0800)
If we add a new file type, we'd like to get warnings if it's not
handled.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
src/mesa/drivers/dri/i965/brw_fs_generator.cpp
src/mesa/drivers/dri/i965/brw_ir_fs.h
src/mesa/drivers/dri/i965/brw_vec4.cpp

index 2d0acb9..5ab8c15 100644 (file)
@@ -88,8 +88,6 @@ fs_inst::init(enum opcode opcode, uint8_t exec_size, const fs_reg &dst,
    case IMM:
    case UNIFORM:
       unreachable("Invalid destination register file");
-   default:
-      unreachable("Invalid register file");
    }
 
    this->writes_accumulator = false;
@@ -845,9 +843,8 @@ fs_inst::regs_read(int arg) const
                           REG_SIZE);
    case MRF:
       unreachable("MRF registers are not allowed as sources");
-   default:
-      unreachable("Invalid register file");
    }
+   return 0;
 }
 
 bool
@@ -4506,9 +4503,8 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
       if (inst->dst.fixed_hw_reg.subnr)
          fprintf(file, "+%d", inst->dst.fixed_hw_reg.subnr);
       break;
-   default:
-      fprintf(file, "???");
-      break;
+   case IMM:
+      unreachable("not reached");
    }
    fprintf(file, ":%s, ", brw_reg_type_letters(inst->dst.type));
 
@@ -4601,9 +4597,6 @@ fs_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
          if (inst->src[i].fixed_hw_reg.abs)
             fprintf(file, "|");
          break;
-      default:
-         fprintf(file, "???");
-         break;
       }
       if (inst->src[i].abs)
          fprintf(file, "|");
index 97e206d..2620482 100644 (file)
@@ -416,9 +416,10 @@ fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
          inst->src[arg].subreg_offset = offset % 32;
       }
       break;
-   default:
-      unreachable("Invalid register file");
-      break;
+
+   case MRF:
+   case IMM:
+      unreachable("not reached");
    }
 
    if (has_source_modifiers) {
index 58bd23f..e207a77 100644 (file)
@@ -42,9 +42,13 @@ static uint32_t brw_file_from_reg(fs_reg *reg)
       return BRW_MESSAGE_REGISTER_FILE;
    case IMM:
       return BRW_IMMEDIATE_VALUE;
-   default:
+   case BAD_FILE:
+   case HW_REG:
+   case ATTR:
+   case UNIFORM:
       unreachable("not reached");
    }
+   return 0;
 }
 
 static struct brw_reg
@@ -116,7 +120,8 @@ brw_reg_from_fs_reg(fs_inst *inst, fs_reg *reg, unsigned gen)
       /* Probably unused. */
       brw_reg = brw_null_reg();
       break;
-   default:
+   case ATTR:
+   case UNIFORM:
       unreachable("not reached");
    }
    if (reg->abs)
index 7726e4b..4417555 100644 (file)
@@ -97,7 +97,9 @@ byte_offset(fs_reg reg, unsigned delta)
    case MRF:
       reg.reg += delta / 32;
       break;
-   default:
+   case IMM:
+   case HW_REG:
+   case UNIFORM:
       assert(delta == 0);
    }
    reg.subreg_offset += delta % 32;
@@ -119,7 +121,7 @@ horiz_offset(fs_reg reg, unsigned delta)
    case MRF:
    case ATTR:
       return byte_offset(reg, delta * reg.stride * type_sz(reg.type));
-   default:
+   case HW_REG:
       assert(delta == 0);
    }
    return reg;
@@ -163,7 +165,6 @@ half(fs_reg reg, unsigned idx)
 
    case ATTR:
    case HW_REG:
-   default:
       unreachable("Cannot take half of this register type");
    }
    return reg;
index 3353e1e..01eb158 100644 (file)
@@ -1427,9 +1427,10 @@ vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
    case BAD_FILE:
       fprintf(file, "(null)");
       break;
-   default:
-      fprintf(file, "???");
-      break;
+   case IMM:
+   case ATTR:
+   case UNIFORM:
+      unreachable("not reached");
    }
    if (inst->dst.writemask != WRITEMASK_XYZW) {
       fprintf(file, ".");
@@ -1521,9 +1522,8 @@ vec4_visitor::dump_instruction(backend_instruction *be_inst, FILE *file)
       case BAD_FILE:
          fprintf(file, "(null)");
          break;
-      default:
-         fprintf(file, "???");
-         break;
+      case MRF:
+         unreachable("not reached");
       }
 
       /* Don't print .0; and only VGRFs have reg_offsets and sizes */
@@ -1839,7 +1839,8 @@ vec4_visitor::convert_to_hw_regs()
             reg = brw_null_reg();
             break;
 
-         default:
+         case MRF:
+         case ATTR:
             unreachable("not reached");
          }
          src.fixed_hw_reg = reg;
@@ -1871,7 +1872,9 @@ vec4_visitor::convert_to_hw_regs()
          reg = brw_null_reg();
          break;
 
-      default:
+      case IMM:
+      case ATTR:
+      case UNIFORM:
          unreachable("not reached");
       }