i965: Drop the reg/hw_reg distinction.
authorEric Anholt <eric@anholt.net>
Sun, 15 May 2011 16:36:19 +0000 (09:36 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 10 Aug 2011 18:03:48 +0000 (11:03 -0700)
"reg" was set in only one case, virtual GRFs pre register allocation,
and would be unset and have hw_reg set after allocation.  Since we
never bothered with looking at virtual GRF number after allocation
anyway, just use the same storage and avoid confusion.

src/mesa/drivers/dri/i965/brw_fs.cpp
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_emit.cpp
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
src/mesa/drivers/dri/i965/brw_fs_schedule_instructions.cpp

index d57a67cc4fc728327199c9d04f244ea2ea57d2aa..cafb7092ac8d4ff40c797a4fc9be8601ff80595e 100644 (file)
@@ -187,20 +187,20 @@ fs_visitor::virtual_grf_alloc(int size)
 }
 
 /** Fixed HW reg constructor. */
-fs_reg::fs_reg(enum register_file file, int hw_reg)
+fs_reg::fs_reg(enum register_file file, int reg)
 {
    init();
    this->file = file;
-   this->hw_reg = hw_reg;
+   this->reg = reg;
    this->type = BRW_REGISTER_TYPE_F;
 }
 
 /** Fixed HW reg constructor. */
-fs_reg::fs_reg(enum register_file file, int hw_reg, uint32_t type)
+fs_reg::fs_reg(enum register_file file, int reg, uint32_t type)
 {
    init();
    this->file = file;
-   this->hw_reg = hw_reg;
+   this->reg = reg;
    this->type = type;
 }
 
@@ -636,7 +636,7 @@ fs_visitor::assign_curb_setup()
 
       for (unsigned int i = 0; i < 3; i++) {
         if (inst->src[i].file == UNIFORM) {
-           int constant_nr = inst->src[i].hw_reg + inst->src[i].reg_offset;
+           int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
            struct brw_reg brw_reg = brw_vec1_grf(c->nr_payload_regs +
                                                  constant_nr / 8,
                                                  constant_nr % 8);
@@ -810,7 +810,7 @@ fs_visitor::remove_dead_constants()
         fs_inst *inst = (fs_inst *)node;
 
         for (int i = 0; i < 3; i++) {
-           int constant_nr = inst->src[i].hw_reg + inst->src[i].reg_offset;
+           int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
 
            if (inst->src[i].file != UNIFORM)
               continue;
@@ -862,13 +862,13 @@ fs_visitor::remove_dead_constants()
       fs_inst *inst = (fs_inst *)node;
 
       for (int i = 0; i < 3; i++) {
-        int constant_nr = inst->src[i].hw_reg + inst->src[i].reg_offset;
+        int constant_nr = inst->src[i].reg + inst->src[i].reg_offset;
 
         if (inst->src[i].file != UNIFORM)
            continue;
 
         assert(this->params_remap[constant_nr] != -1);
-        inst->src[i].hw_reg = this->params_remap[constant_nr];
+        inst->src[i].reg = this->params_remap[constant_nr];
         inst->src[i].reg_offset = 0;
       }
    }
@@ -912,7 +912,7 @@ fs_visitor::setup_pull_constants()
         if (inst->src[i].file != UNIFORM)
            continue;
 
-        int uniform_nr = inst->src[i].hw_reg + inst->src[i].reg_offset;
+        int uniform_nr = inst->src[i].reg + inst->src[i].reg_offset;
         if (uniform_nr < pull_uniform_base)
            continue;
 
@@ -1374,9 +1374,9 @@ fs_visitor::compute_to_mrf()
       /* Work out which hardware MRF registers are written by this
        * instruction.
        */
-      int mrf_low = inst->dst.hw_reg & ~BRW_MRF_COMPR4;
+      int mrf_low = inst->dst.reg & ~BRW_MRF_COMPR4;
       int mrf_high;
-      if (inst->dst.hw_reg & BRW_MRF_COMPR4) {
+      if (inst->dst.reg & BRW_MRF_COMPR4) {
         mrf_high = mrf_low + 4;
       } else if (c->dispatch_width == 16 &&
                 (!inst->force_uncompressed && !inst->force_sechalf)) {
@@ -1443,7 +1443,7 @@ fs_visitor::compute_to_mrf()
            if (scan_inst->dst.reg_offset == inst->src[0].reg_offset) {
               /* Found the creator of our MRF's source value. */
               scan_inst->dst.file = MRF;
-              scan_inst->dst.hw_reg = inst->dst.hw_reg;
+              scan_inst->dst.reg = inst->dst.reg;
               scan_inst->saturate |= inst->saturate;
               inst->remove();
               progress = true;
@@ -1480,10 +1480,10 @@ fs_visitor::compute_to_mrf()
            /* If somebody else writes our MRF here, we can't
             * compute-to-MRF before that.
             */
-           int scan_mrf_low = scan_inst->dst.hw_reg & ~BRW_MRF_COMPR4;
+           int scan_mrf_low = scan_inst->dst.reg & ~BRW_MRF_COMPR4;
            int scan_mrf_high;
 
-           if (scan_inst->dst.hw_reg & BRW_MRF_COMPR4) {
+           if (scan_inst->dst.reg & BRW_MRF_COMPR4) {
               scan_mrf_high = scan_mrf_low + 4;
            } else if (c->dispatch_width == 16 &&
                       (!scan_inst->force_uncompressed &&
@@ -1555,7 +1555,7 @@ fs_visitor::remove_duplicate_mrf_writes()
 
       if (inst->opcode == BRW_OPCODE_MOV &&
          inst->dst.file == MRF) {
-        fs_inst *prev_inst = last_mrf_move[inst->dst.hw_reg];
+        fs_inst *prev_inst = last_mrf_move[inst->dst.reg];
         if (prev_inst && inst->equals(prev_inst)) {
            inst->remove();
            progress = true;
@@ -1565,7 +1565,7 @@ fs_visitor::remove_duplicate_mrf_writes()
 
       /* Clear out the last-write records for MRFs that were overwritten. */
       if (inst->dst.file == MRF) {
-        last_mrf_move[inst->dst.hw_reg] = NULL;
+        last_mrf_move[inst->dst.reg] = NULL;
       }
 
       if (inst->mlen > 0) {
@@ -1591,7 +1591,7 @@ fs_visitor::remove_duplicate_mrf_writes()
          inst->dst.file == MRF &&
          inst->src[0].file == GRF &&
          !inst->predicated) {
-        last_mrf_move[inst->dst.hw_reg] = inst;
+        last_mrf_move[inst->dst.reg] = inst;
       }
    }
 
index 0375f672beca1097fa392bea2e6833f7791caa5d..4ec649014de58ec65a80a820cd1c5742d1e7f4d2 100644 (file)
@@ -51,7 +51,7 @@ enum register_file {
    MRF = BRW_MESSAGE_REGISTER_FILE,
    IMM = BRW_IMMEDIATE_VALUE,
    FIXED_HW_REG, /* a struct brw_reg */
-   UNIFORM, /* prog_data->params[hw_reg] */
+   UNIFORM, /* prog_data->params[reg] */
    BAD_FILE
 };
 
@@ -99,7 +99,6 @@ public:
    void init()
    {
       memset(this, 0, sizeof(*this));
-      this->hw_reg = -1;
       this->smear = -1;
    }
 
@@ -146,8 +145,8 @@ public:
       this->type = fixed_hw_reg.type;
    }
 
-   fs_reg(enum register_file file, int hw_reg);
-   fs_reg(enum register_file file, int hw_reg, uint32_t type);
+   fs_reg(enum register_file file, int reg);
+   fs_reg(enum register_file file, int reg, uint32_t type);
    fs_reg(class fs_visitor *v, const struct glsl_type *type);
 
    bool equals(fs_reg *r)
@@ -155,7 +154,6 @@ public:
       return (file == r->file &&
              reg == r->reg &&
              reg_offset == r->reg_offset &&
-             hw_reg == r->hw_reg &&
              type == r->type &&
              negate == r->negate &&
              abs == r->abs &&
@@ -167,12 +165,17 @@ public:
 
    /** Register file: ARF, GRF, MRF, IMM. */
    enum register_file file;
-   /** virtual register number.  0 = fixed hw reg */
+   /**
+    * Register number.  For ARF/MRF, it's the hardware register.  For
+    * GRF, it's a virtual register number until register allocation
+    */
    int reg;
-   /** Offset within the virtual register. */
+   /**
+    * For virtual registers, this is a hardware register offset from
+    * the start of the register block (for example, a constant index
+    * in an array access).
+    */
    int reg_offset;
-   /** HW register number.  Generally unset until register allocation. */
-   int hw_reg;
    /** Register type.  BRW_REGISTER_TYPE_* */
    int type;
    bool negate;
index 9fb0153d1f85cc8180abef51d534133f512935fd..e168e541bef179762787ae7584384d8343cc03a7 100644 (file)
@@ -538,11 +538,9 @@ brw_reg_from_fs_reg(fs_reg *reg)
    case ARF:
    case MRF:
       if (reg->smear == -1) {
-        brw_reg = brw_vec8_reg(reg->file,
-                               reg->hw_reg, 0);
+        brw_reg = brw_vec8_reg(reg->file, reg->reg, 0);
       } else {
-        brw_reg = brw_vec1_reg(reg->file,
-                               reg->hw_reg, reg->smear);
+        brw_reg = brw_vec1_reg(reg->file, reg->reg, reg->smear);
       }
       brw_reg = retype(brw_reg, reg->type);
       if (reg->sechalf)
index 8e44a0105769ae787cea5af3cc45422fcf113086..5c9cba99ae5c8f817c66ce5ccd7f479ef8923f04 100644 (file)
@@ -52,8 +52,8 @@ assign_reg(int *reg_hw_locations, fs_reg *reg, int reg_width)
 {
    if (reg->file == GRF) {
       assert(reg->reg_offset >= 0);
-      reg->hw_reg = reg_hw_locations[reg->reg] + reg->reg_offset * reg_width;
-      reg->reg = 0;
+      reg->reg = reg_hw_locations[reg->reg] + reg->reg_offset * reg_width;
+      reg->reg_offset = 0;
    }
 }
 
index 9ec3f502764617e891ad7c1c333f9a3ab6046f33..f1a88fcfa79f4aa610471b51546c1025724d91bc 100644 (file)
@@ -321,12 +321,12 @@ instruction_scheduler::calculate_deps()
         add_dep(last_grf_write[inst->dst.reg], n);
         last_grf_write[inst->dst.reg] = n;
       } else if (inst->dst.file == MRF) {
-        int reg = inst->dst.hw_reg & ~BRW_MRF_COMPR4;
+        int reg = inst->dst.reg & ~BRW_MRF_COMPR4;
 
         add_dep(last_mrf_write[reg], n);
         last_mrf_write[reg] = n;
         if (is_compressed(inst)) {
-           if (inst->dst.hw_reg & BRW_MRF_COMPR4)
+           if (inst->dst.reg & BRW_MRF_COMPR4)
               reg += 4;
            else
               reg++;
@@ -401,12 +401,12 @@ instruction_scheduler::calculate_deps()
       if (inst->dst.file == GRF) {
         last_grf_write[inst->dst.reg] = n;
       } else if (inst->dst.file == MRF) {
-        int reg = inst->dst.hw_reg & ~BRW_MRF_COMPR4;
+        int reg = inst->dst.reg & ~BRW_MRF_COMPR4;
 
         last_mrf_write[reg] = n;
 
         if (is_compressed(inst)) {
-           if (inst->dst.hw_reg & BRW_MRF_COMPR4)
+           if (inst->dst.reg & BRW_MRF_COMPR4)
               reg += 4;
            else
               reg++;