i965/fs: Keep a copy of the live variables class around.
authorEric Anholt <eric@anholt.net>
Tue, 5 Jun 2012 18:37:22 +0000 (11:37 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 10 Oct 2013 22:54:15 +0000 (15:54 -0700)
Now optimization passes will be able to look at the per-channel ranges.

v2: Rebase on various optimization pass changes.
v3 (Kenneth Graunke): Rename live_variables to live_intervals; split
   introduction of invalidate_live_intervals() into a separate patch.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/drivers/dri/i965/brw_fs.h
src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp
src/mesa/drivers/dri/i965/brw_fs_visitor.cpp

index c8f10c3..360dbad 100644 (file)
@@ -55,6 +55,10 @@ namespace {
    struct acp_entry;
 }
 
+namespace brw {
+   class fs_live_variables;
+}
+
 class fs_reg {
 public:
    DECLARE_RALLOC_CXX_OPERATORS(fs_reg)
@@ -413,7 +417,7 @@ public:
    int virtual_grf_array_size;
    int *virtual_grf_start;
    int *virtual_grf_end;
-   bool live_intervals_valid;
+   brw::fs_live_variables *live_intervals;
 
    /* This is the map from UNIFORM hw_reg + reg_offset as generated by
     * the visitor to the packed uniform number after
index 497a0db..41176c7 100644 (file)
@@ -247,7 +247,7 @@ fs_live_variables::compute_start_end()
 fs_live_variables::fs_live_variables(fs_visitor *v, cfg_t *cfg)
    : v(v), cfg(cfg)
 {
-   mem_ctx = ralloc_context(cfg->mem_ctx);
+   mem_ctx = this;
 
    num_vgrfs = v->virtual_grf_count;
    num_vars = 0;
@@ -294,7 +294,8 @@ fs_live_variables::~fs_live_variables()
 void
 fs_visitor::invalidate_live_intervals()
 {
-   this->live_intervals_valid = false;
+   ralloc_free(live_intervals);
+   live_intervals = NULL;
 }
 
 /**
@@ -306,7 +307,7 @@ fs_visitor::invalidate_live_intervals()
 void
 fs_visitor::calculate_live_intervals()
 {
-   if (this->live_intervals_valid)
+   if (this->live_intervals)
       return;
 
    int num_vgrfs = this->virtual_grf_count;
@@ -321,16 +322,16 @@ fs_visitor::calculate_live_intervals()
    }
 
    cfg_t cfg(this);
-   fs_live_variables livevars(this, &cfg);
+   this->live_intervals = new(mem_ctx) fs_live_variables(this, &cfg);
 
    /* Merge the per-component live ranges to whole VGRF live ranges. */
-   for (int i = 0; i < livevars.num_vars; i++) {
-      int vgrf = livevars.vgrf_from_var[i];
-      virtual_grf_start[vgrf] = MIN2(virtual_grf_start[vgrf], livevars.start[i]);
-      virtual_grf_end[vgrf] = MAX2(virtual_grf_end[vgrf], livevars.end[i]);
+   for (int i = 0; i < live_intervals->num_vars; i++) {
+      int vgrf = live_intervals->vgrf_from_var[i];
+      virtual_grf_start[vgrf] = MIN2(virtual_grf_start[vgrf],
+                                     live_intervals->start[i]);
+      virtual_grf_end[vgrf] = MAX2(virtual_grf_end[vgrf],
+                                   live_intervals->end[i]);
    }
-
-   this->live_intervals_valid = true;
 }
 
 bool
index 15cfaa7..728567c 100644 (file)
@@ -2694,7 +2694,7 @@ fs_visitor::fs_visitor(struct brw_context *brw,
    this->virtual_grf_array_size = 0;
    this->virtual_grf_start = NULL;
    this->virtual_grf_end = NULL;
-   this->live_intervals_valid = false;
+   this->live_intervals = NULL;
 
    this->params_remap = NULL;
    this->nr_params_remap = 0;