*/
void
-fs_live_variables::setup_one_read(struct block_data *bd, fs_inst *inst,
+fs_live_variables::setup_one_read(struct block_data *bd,
int ip, const fs_reg ®)
{
int var = var_from_reg(reg);
continue;
for (unsigned j = 0; j < regs_read(inst, i); j++) {
- setup_one_read(bd, inst, ip, reg);
+ setup_one_read(bd, ip, reg);
reg.offset += REG_SIZE;
}
}
- bd->flag_use[0] |= inst->flags_read(v->devinfo) & ~bd->flag_def[0];
+ bd->flag_use[0] |= inst->flags_read(devinfo) & ~bd->flag_def[0];
/* Set def[] for this instruction */
if (inst->dst.file == VGRF) {
}
}
-fs_live_variables::fs_live_variables(fs_visitor *v, const cfg_t *cfg)
- : v(v), cfg(cfg)
+fs_live_variables::fs_live_variables(const backend_shader *s)
+ : devinfo(s->devinfo), cfg(s->cfg)
{
mem_ctx = ralloc_context(NULL);
- num_vgrfs = v->alloc.count;
+ num_vgrfs = s->alloc.count;
num_vars = 0;
var_from_vgrf = rzalloc_array(mem_ctx, int, num_vgrfs);
for (int i = 0; i < num_vgrfs; i++) {
var_from_vgrf[i] = num_vars;
- num_vars += v->alloc.sizes[i];
+ num_vars += s->alloc.sizes[i];
}
vgrf_from_var = rzalloc_array(mem_ctx, int, num_vars);
for (int i = 0; i < num_vgrfs; i++) {
- for (unsigned j = 0; j < v->alloc.sizes[i]; j++) {
+ for (unsigned j = 0; j < s->alloc.sizes[i]; j++) {
vgrf_from_var[var_from_vgrf[i] + j] = i;
}
}
ralloc_free(mem_ctx);
}
-void
-fs_visitor::invalidate_live_intervals()
+static bool
+check_register_live_range(const fs_live_variables *live, int ip,
+ const fs_reg ®, unsigned n)
{
- ralloc_free(live_intervals);
- live_intervals = NULL;
+ const unsigned var = live->var_from_reg(reg);
+
+ if (var + n > unsigned(live->num_vars) ||
+ live->vgrf_start[reg.nr] > ip || live->vgrf_end[reg.nr] < ip)
+ return false;
+
+ for (unsigned j = 0; j < n; j++) {
+ if (live->start[var + j] > ip || live->end[var + j] < ip)
+ return false;
+ }
+
+ return true;
}
-/**
- * Compute the live intervals for each virtual GRF.
- *
- * This uses the per-component use/def data, but combines it to produce
- * information about whole VGRFs.
- */
-void
-fs_visitor::calculate_live_intervals()
+bool
+fs_live_variables::validate(const backend_shader *s) const
{
- if (this->live_intervals)
- return;
+ int ip = 0;
+
+ foreach_block_and_inst(block, fs_inst, inst, s->cfg) {
+ for (unsigned i = 0; i < inst->sources; i++) {
+ if (inst->src[i].file == VGRF &&
+ !check_register_live_range(this, ip,
+ inst->src[i], regs_read(inst, i)))
+ return false;
+ }
+
+ if (inst->dst.file == VGRF &&
+ !check_register_live_range(this, ip, inst->dst, regs_written(inst)))
+ return false;
+
+ ip++;
+ }
- this->live_intervals = new(mem_ctx) fs_live_variables(this, cfg);
+ return true;
}
bool