i965/fs: Preserve CFG in register allocation.
authorMatt Turner <mattst88@gmail.com>
Tue, 15 Jul 2014 18:45:20 +0000 (11:45 -0700)
committerMatt Turner <mattst88@gmail.com>
Fri, 22 Aug 2014 17:23:34 +0000 (10:23 -0700)
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp

index e42b93ad901cf733baa5661ab78e8e1485d71c5d..c2bc1f0e1302851944f5c921b19f384b0ea85e6a 100644 (file)
@@ -400,8 +400,8 @@ public:
    bool opt_saturate_propagation();
    void emit_bool_to_cond_code(ir_rvalue *condition);
    void emit_if_gen6(ir_if *ir);
-   void emit_unspill(fs_inst *inst, fs_reg reg, uint32_t spill_offset,
-                     int count);
+   void emit_unspill(bblock_t *block, fs_inst *inst, fs_reg reg,
+                     uint32_t spill_offset, int count);
 
    void emit_fragment_program_code();
    void setup_fp_regs();
index fb77b925b1a9894c53c158a5145050b9e35e6057..a9bff65ea01c83cbede170a1875bb0291c789fc0 100644 (file)
@@ -26,6 +26,7 @@
  */
 
 #include "brw_fs.h"
+#include "brw_cfg.h"
 #include "glsl/glsl_types.h"
 #include "glsl/ir_optimization.h"
 
@@ -533,8 +534,8 @@ fs_visitor::assign_regs(bool allow_spilling)
 }
 
 void
-fs_visitor::emit_unspill(fs_inst *inst, fs_reg dst, uint32_t spill_offset,
-                         int count)
+fs_visitor::emit_unspill(bblock_t *block, fs_inst *inst, fs_reg dst,
+                         uint32_t spill_offset, int count)
 {
    for (int i = 0; i < count; i++) {
       /* The gen7 descriptor-based offset is 12 bits of HWORD units. */
@@ -553,7 +554,7 @@ fs_visitor::emit_unspill(fs_inst *inst, fs_reg dst, uint32_t spill_offset,
          unspill_inst->base_mrf = 14;
          unspill_inst->mlen = 1; /* header contains offset */
       }
-      inst->insert_before(unspill_inst);
+      inst->insert_before(block, unspill_inst);
 
       dst.reg_offset++;
       spill_offset += dispatch_width * sizeof(float);
@@ -668,12 +669,14 @@ fs_visitor::spill_reg(int spill_reg)
 
    last_scratch += size * reg_size;
 
+   calculate_cfg();
+
    /* Generate spill/unspill instructions for the objects being
     * spilled.  Right now, we spill or unspill the whole thing to a
     * virtual grf of the same size.  For most instructions, though, we
     * could just spill/unspill the GRF being accessed.
     */
-   foreach_in_list(fs_inst, inst, &instructions) {
+   foreach_block_and_inst (block, fs_inst, inst, cfg) {
       for (unsigned int i = 0; i < inst->sources; i++) {
         if (inst->src[i].file == GRF &&
             inst->src[i].reg == spill_reg) {
@@ -685,7 +688,8 @@ fs_visitor::spill_reg(int spill_reg)
             inst->src[i].reg = unspill_dst.reg;
             inst->src[i].reg_offset = 0;
 
-            emit_unspill(inst, unspill_dst, subset_spill_offset, regs_read);
+            emit_unspill(block, inst, unspill_dst, subset_spill_offset,
+                         regs_read);
         }
       }
 
@@ -704,7 +708,7 @@ fs_visitor::spill_reg(int spill_reg)
          */
         if (inst->predicate || inst->force_uncompressed ||
              inst->force_sechalf || inst->dst.subreg_offset) {
-            emit_unspill(inst, spill_src, subset_spill_offset,
+            emit_unspill(block, inst, spill_src, subset_spill_offset,
                          inst->regs_written);
         }
 
@@ -718,10 +722,10 @@ fs_visitor::spill_reg(int spill_reg)
            spill_inst->annotation = inst->annotation;
            spill_inst->mlen = 1 + dispatch_width / 8; /* header, value */
            spill_inst->base_mrf = spill_base_mrf;
-           inst->insert_after(spill_inst);
+           inst->insert_after(block, spill_inst);
         }
       }
    }
 
-   invalidate_live_intervals();
+   invalidate_live_intervals(false);
 }