}
}
+bool
+fs_inst::is_copy_payload(const brw::simple_allocator &grf_alloc) const
+{
+ if (this->opcode != SHADER_OPCODE_LOAD_PAYLOAD)
+ return false;
+
+ fs_reg reg = this->src[0];
+ if (reg.file != GRF || reg.reg_offset != 0 || reg.stride == 0)
+ return false;
+
+ if (grf_alloc.sizes[reg.reg] != this->regs_written)
+ return false;
+
+ for (int i = 1; i < this->sources; i++)
+ if (!this->src[i].equals(::offset(reg, i)))
+ return false;
+
+ return true;
+}
+
bool
fs_inst::can_do_source_mods(const struct brw_device_info *devinfo)
{
}
static bool
-is_copy_payload(const fs_inst *inst)
-{
- const int reg = inst->src[0].reg;
- if (inst->src[0].reg_offset != 0)
- return false;
-
- for (int i = 1; i < inst->sources; i++) {
- if (inst->src[i].reg != reg ||
- inst->src[i].reg_offset != i) {
- return false;
- }
- }
- return true;
-}
-
-static bool
-is_expression(const fs_inst *const inst)
+is_expression(const fs_visitor *v, const fs_inst *const inst)
{
switch (inst->opcode) {
case BRW_OPCODE_MOV:
case SHADER_OPCODE_COS:
return inst->mlen < 2;
case SHADER_OPCODE_LOAD_PAYLOAD:
- return !is_copy_payload(inst);
+ return !inst->is_copy_payload(v->alloc);
default:
return inst->is_send_from_grf() && !inst->has_side_effects();
}
int ip = block->start_ip;
foreach_inst_in_block(fs_inst, inst, block) {
/* Skip some cases. */
- if (is_expression(inst) && !inst->is_partial_write() &&
+ if (is_expression(this, inst) && !inst->is_partial_write() &&
(inst->dst.file != HW_REG || inst->dst.is_null()))
{
bool found = false;
return false;
}
-static bool
-is_copy_payload(const fs_visitor *v, const fs_inst *inst)
-{
- if (v->alloc.sizes[inst->src[0].reg] != inst->regs_written)
- return false;
-
- fs_reg reg = inst->src[0];
-
- for (int i = 0; i < inst->sources; i++)
- if (!inst->src[i].equals(offset(reg, i)))
- return false;
-
- return true;
-}
-
static bool
is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst)
{
return false;
if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD) {
- if (!is_copy_payload(v, inst)) {
+ if (!inst->is_copy_payload(v->alloc)) {
return false;
}
}
bool overwrites_reg(const fs_reg ®) const;
bool is_send_from_grf() const;
bool is_partial_write() const;
+ bool is_copy_payload(const brw::simple_allocator &grf_alloc) const;
int regs_read(int arg) const;
bool can_do_source_mods(const struct brw_device_info *devinfo);
bool has_side_effects() const;