if ((inst->dst.file == VGRF && !inst->has_side_effects()) ||
(inst->dst.is_null() && inst->writes_flag())){
bool result_live[4] = { false };
-
if (inst->dst.file == VGRF) {
- for (unsigned i = 0; i < regs_written(inst); i++) {
- for (int c = 0; c < 4; c++)
- result_live[c] |= BITSET_TEST(live,
- var_from_reg(alloc,
- byte_offset(inst->dst, i * REG_SIZE), c));
+ for (unsigned i = 0; i < DIV_ROUND_UP(inst->size_written, 16); i++) {
+ for (int c = 0; c < 4; c++) {
+ const unsigned v = var_from_reg(alloc, inst->dst, c, i);
+ result_live[c] |= BITSET_TEST(live, v);
+ }
}
} else {
for (unsigned c = 0; c < 4; c++)
if (inst->dst.file == VGRF && !inst->predicate &&
!inst->is_align1_partial_write()) {
- for (unsigned i = 0; i < regs_written(inst); i++) {
+ for (unsigned i = 0; i < DIV_ROUND_UP(inst->size_written, 16); i++) {
for (int c = 0; c < 4; c++) {
if (inst->dst.writemask & (1 << c)) {
- BITSET_CLEAR(live,
- var_from_reg(alloc,
- byte_offset(inst->dst,
- i * REG_SIZE),
- c));
+ const unsigned v = var_from_reg(alloc, inst->dst, c, i);
+ BITSET_CLEAR(live, v);
}
}
}
for (int i = 0; i < 3; i++) {
if (inst->src[i].file == VGRF) {
- for (unsigned j = 0; j < regs_read(inst, i); j++) {
+ for (unsigned j = 0; j < DIV_ROUND_UP(inst->size_read(i), 16); j++) {
for (int c = 0; c < 4; c++) {
- BITSET_SET(live, var_from_reg(alloc,
- byte_offset(inst->src[i],
- j * REG_SIZE),
- c));
+ const unsigned v = var_from_reg(alloc, inst->src[i], c, j);
+ BITSET_SET(live, v);
}
}
}
/* Set use[] for this instruction */
for (unsigned int i = 0; i < 3; i++) {
if (inst->src[i].file == VGRF) {
- for (unsigned j = 0; j < regs_read(inst, i); j++) {
+ for (unsigned j = 0; j < DIV_ROUND_UP(inst->size_read(i), 16); j++) {
for (int c = 0; c < 4; c++) {
- const unsigned v =
- var_from_reg(alloc,
- byte_offset(inst->src[i], j * REG_SIZE),
- c);
+ const unsigned v = var_from_reg(alloc, inst->src[i], c, j);
if (!BITSET_TEST(bd->def, v))
BITSET_SET(bd->use, v);
}
*/
if (inst->dst.file == VGRF &&
(!inst->predicate || inst->opcode == BRW_OPCODE_SEL)) {
- for (unsigned i = 0; i < regs_written(inst); i++) {
+ for (unsigned i = 0; i < DIV_ROUND_UP(inst->size_written, 16); i++) {
for (int c = 0; c < 4; c++) {
if (inst->dst.writemask & (1 << c)) {
- const unsigned v =
- var_from_reg(alloc,
- byte_offset(inst->dst, i * REG_SIZE), c);
+ const unsigned v = var_from_reg(alloc, inst->dst, c, i);
if (!BITSET_TEST(bd->use, v))
BITSET_SET(bd->def, v);
}
{
mem_ctx = ralloc_context(NULL);
- num_vars = alloc.total_size * 4;
+ num_vars = alloc.total_size * 8;
block_data = rzalloc_array(mem_ctx, struct block_data, cfg->num_blocks);
bitset_words = BITSET_WORDS(num_vars);
if (this->live_intervals)
return;
- int *start = ralloc_array(mem_ctx, int, this->alloc.total_size * 4);
- int *end = ralloc_array(mem_ctx, int, this->alloc.total_size * 4);
+ int *start = ralloc_array(mem_ctx, int, this->alloc.total_size * 8);
+ int *end = ralloc_array(mem_ctx, int, this->alloc.total_size * 8);
ralloc_free(this->virtual_grf_start);
ralloc_free(this->virtual_grf_end);
this->virtual_grf_start = start;
this->virtual_grf_end = end;
- for (unsigned i = 0; i < this->alloc.total_size * 4; i++) {
+ for (unsigned i = 0; i < this->alloc.total_size * 8; i++) {
start[i] = MAX_INSTRUCTION;
end[i] = -1;
}
foreach_block_and_inst(block, vec4_instruction, inst, cfg) {
for (unsigned int i = 0; i < 3; i++) {
if (inst->src[i].file == VGRF) {
- for (unsigned j = 0; j < regs_read(inst, i); j++) {
+ for (unsigned j = 0; j < DIV_ROUND_UP(inst->size_read(i), 16); j++) {
for (int c = 0; c < 4; c++) {
- const unsigned v =
- var_from_reg(alloc,
- byte_offset(inst->src[i], j * REG_SIZE), c);
+ const unsigned v = var_from_reg(alloc, inst->src[i], c, j);
start[v] = MIN2(start[v], ip);
end[v] = ip;
}
}
if (inst->dst.file == VGRF) {
- for (unsigned i = 0; i < regs_written(inst); i++) {
+ for (unsigned i = 0; i < DIV_ROUND_UP(inst->size_written, 16); i++) {
for (int c = 0; c < 4; c++) {
if (inst->dst.writemask & (1 << c)) {
- const unsigned v =
- var_from_reg(alloc,
- byte_offset(inst->dst, i * REG_SIZE), c);
+ const unsigned v = var_from_reg(alloc, inst->dst, c, i);
start[v] = MIN2(start[v], ip);
end[v] = ip;
}
bool
vec4_visitor::virtual_grf_interferes(int a, int b)
{
- return !((var_range_end(4 * alloc.offsets[a], 4 * alloc.sizes[a]) <=
- var_range_start(4 * alloc.offsets[b], 4 * alloc.sizes[b])) ||
- (var_range_end(4 * alloc.offsets[b], 4 * alloc.sizes[b]) <=
- var_range_start(4 * alloc.offsets[a], 4 * alloc.sizes[a])));
+ return !((var_range_end(8 * alloc.offsets[a], 8 * alloc.sizes[a]) <=
+ var_range_start(8 * alloc.offsets[b], 8 * alloc.sizes[b])) ||
+ (var_range_end(8 * alloc.offsets[b], 8 * alloc.sizes[b]) <=
+ var_range_start(8 * alloc.offsets[a], 8 * alloc.sizes[a])));
}
void *mem_ctx;
};
+/* Returns the variable index for the k-th dword of the c-th component of
+ * register reg.
+ */
inline unsigned
var_from_reg(const simple_allocator &alloc, const src_reg ®,
- unsigned c = 0)
+ unsigned c = 0, unsigned k = 0)
{
- assert(reg.file == VGRF && reg.nr < alloc.count &&
- reg.offset / REG_SIZE < alloc.sizes[reg.nr] && c < 4);
- return (4 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) +
- BRW_GET_SWZ(reg.swizzle, c));
+ assert(reg.file == VGRF && reg.nr < alloc.count && c < 4);
+ const unsigned csize = DIV_ROUND_UP(type_sz(reg.type), 4);
+ unsigned result =
+ 8 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) +
+ (BRW_GET_SWZ(reg.swizzle, c) + k / csize * 4) * csize + k % csize;
+ /* Do not exceed the limit for this register */
+ assert(result < 8 * (alloc.offsets[reg.nr] + alloc.sizes[reg.nr]));
+ return result;
}
inline unsigned
var_from_reg(const simple_allocator &alloc, const dst_reg ®,
- unsigned c = 0)
+ unsigned c = 0, unsigned k = 0)
{
- assert(reg.file == VGRF && reg.nr < alloc.count &&
- reg.offset / REG_SIZE < alloc.sizes[reg.nr] && c < 4);
- return 4 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) + c;
+ assert(reg.file == VGRF && reg.nr < alloc.count && c < 4);
+ const unsigned csize = DIV_ROUND_UP(type_sz(reg.type), 4);
+ unsigned result =
+ 8 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) +
+ (c + k / csize * 4) * csize + k % csize;
+ /* Do not exceed the limit for this register */
+ assert(result < 8 * (alloc.offsets[reg.nr] + alloc.sizes[reg.nr]));
+ return result;
}
} /* namespace brw */