From: Eric Anholt Date: Tue, 5 Jun 2012 18:37:22 +0000 (-0700) Subject: i965/fs: Keep a copy of the live variables class around. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b4d676d71006e5e85893d7b44740860b1b2c3425;p=mesa.git i965/fs: Keep a copy of the live variables class around. 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 Reviewed-by: Kenneth Graunke --- diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index c8f10c39ea6..360dbadc19d 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -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 diff --git a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp index 497a0db8e94..41176c74236 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_live_variables.cpp @@ -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 diff --git a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp index 15cfaa7e34a..728567cc2a8 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_visitor.cpp @@ -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;