i965/fs: Factor def[]/use[] setup out to a separate function.
These blocks are about to grow some more code, and the indentation was getting out of hand. v2 (Kenneth Graunke): Rebase, minor typo fixes and style changes. Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -50,6 +50,35 @@ using namespace brw;
|
|||||||
* 14.1 (p444).
|
* 14.1 (p444).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
fs_live_variables::setup_one_read(bblock_t *block, fs_inst *inst,
|
||||||
|
int ip, fs_reg reg)
|
||||||
|
{
|
||||||
|
int var = var_from_vgrf[reg.reg] + reg.reg_offset;
|
||||||
|
|
||||||
|
/* The use[] bitset marks when the block makes use of a variable (VGRF
|
||||||
|
* channel) without having completely defined that variable within the
|
||||||
|
* block.
|
||||||
|
*/
|
||||||
|
if (!BITSET_TEST(bd[block->block_num].def, var))
|
||||||
|
BITSET_SET(bd[block->block_num].use, var);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fs_live_variables::setup_one_write(bblock_t *block, fs_inst *inst,
|
||||||
|
int ip, fs_reg reg)
|
||||||
|
{
|
||||||
|
int var = var_from_vgrf[reg.reg] + reg.reg_offset;
|
||||||
|
|
||||||
|
/* The def[] bitset marks when an initialization in a block completely
|
||||||
|
* screens off previous updates of that variable (VGRF channel).
|
||||||
|
*/
|
||||||
|
if (inst->dst.file == GRF && !inst->is_partial_write()) {
|
||||||
|
if (!BITSET_TEST(bd[block->block_num].use, var))
|
||||||
|
BITSET_SET(bd[block->block_num].def, var);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up the use[] and def[] bitsets.
|
* Sets up the use[] and def[] bitsets.
|
||||||
*
|
*
|
||||||
@@ -77,7 +106,9 @@ fs_live_variables::setup_def_use()
|
|||||||
|
|
||||||
/* Set use[] for this instruction */
|
/* Set use[] for this instruction */
|
||||||
for (unsigned int i = 0; i < 3; i++) {
|
for (unsigned int i = 0; i < 3; i++) {
|
||||||
if (inst->src[i].file != GRF)
|
fs_reg reg = inst->src[i];
|
||||||
|
|
||||||
|
if (reg.file != GRF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
int regs_read = 1;
|
int regs_read = 1;
|
||||||
@@ -85,26 +116,20 @@ fs_live_variables::setup_def_use()
|
|||||||
* so just assume "all of them."
|
* so just assume "all of them."
|
||||||
*/
|
*/
|
||||||
if (inst->is_send_from_grf())
|
if (inst->is_send_from_grf())
|
||||||
regs_read = v->virtual_grf_sizes[inst->src[i].reg];
|
regs_read = v->virtual_grf_sizes[reg.reg];
|
||||||
|
|
||||||
for (int j = 0; j < regs_read; j++) {
|
for (int i = 0; i < regs_read; i++) {
|
||||||
int var = var_from_vgrf[inst->src[i].reg] +
|
setup_one_read(block, inst, ip, reg);
|
||||||
inst->src[i].reg_offset + j;
|
reg.reg_offset++;
|
||||||
|
|
||||||
if (!BITSET_TEST(bd[b].def, var))
|
|
||||||
BITSET_SET(bd[b].use, var);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for unconditional writes to whole registers. These
|
/* Set def[] for this instruction */
|
||||||
* are the things that screen off preceding definitions of a
|
if (inst->dst.file == GRF) {
|
||||||
* variable, and thus qualify for being in def[].
|
fs_reg reg = inst->dst;
|
||||||
*/
|
|
||||||
if (inst->dst.file == GRF && !inst->is_partial_write()) {
|
|
||||||
int var = var_from_vgrf[inst->dst.reg] + inst->dst.reg_offset;
|
|
||||||
for (int j = 0; j < inst->regs_written; j++) {
|
for (int j = 0; j < inst->regs_written; j++) {
|
||||||
if (!BITSET_TEST(bd[b].use, var + j))
|
setup_one_write(block, inst, ip, reg);
|
||||||
BITSET_SET(bd[b].def, var + j);
|
reg.reg_offset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,6 +59,8 @@ public:
|
|||||||
~fs_live_variables();
|
~fs_live_variables();
|
||||||
|
|
||||||
void setup_def_use();
|
void setup_def_use();
|
||||||
|
void setup_one_read(bblock_t *block, fs_inst *inst, int ip, fs_reg reg);
|
||||||
|
void setup_one_write(bblock_t *block, fs_inst *inst, int ip, fs_reg reg);
|
||||||
void compute_live_variables();
|
void compute_live_variables();
|
||||||
|
|
||||||
fs_visitor *v;
|
fs_visitor *v;
|
||||||
|
Reference in New Issue
Block a user