i965/fs: Migrate opt_cse to the IR builder.

Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
Francisco Jerez 2015-06-04 16:13:35 +03:00
parent e7069fbc70
commit 74c2458ecf
1 changed files with 12 additions and 15 deletions

View File

@ -32,6 +32,8 @@
* 13.1 (p378).
*/
using namespace brw;
namespace {
struct aeb_entry : public exec_node {
/** The instruction that generates the expression value. */
@ -173,11 +175,13 @@ instructions_match(fs_inst *a, fs_inst *b, bool *negate)
operands_match(a, b, negate);
}
static fs_inst *
create_copy_instr(fs_visitor *v, fs_inst *inst, fs_reg src, bool negate)
static void
create_copy_instr(const fs_builder &bld, fs_inst *inst, fs_reg src, bool negate)
{
int written = inst->regs_written;
int dst_width = inst->dst.width / 8;
const fs_builder ubld = bld.group(inst->exec_size, inst->force_sechalf)
.exec_all(inst->force_writemask_all);
fs_inst *copy;
if (written > dst_width) {
@ -193,7 +197,7 @@ create_copy_instr(fs_visitor *v, fs_inst *inst, fs_reg src, bool negate)
}
assert(src.file == GRF);
payload = ralloc_array(v->mem_ctx, fs_reg, sources);
payload = ralloc_array(bld.shader->mem_ctx, fs_reg, sources);
for (int i = 0; i < header_size; i++) {
payload[i] = src;
payload[i].width = 8;
@ -203,16 +207,12 @@ create_copy_instr(fs_visitor *v, fs_inst *inst, fs_reg src, bool negate)
payload[i] = src;
src = offset(src, 1);
}
copy = v->LOAD_PAYLOAD(inst->dst, payload, sources, header_size);
copy = ubld.LOAD_PAYLOAD(inst->dst, payload, sources, header_size);
} else {
copy = v->MOV(inst->dst, src);
copy = ubld.MOV(inst->dst, src);
copy->src[0].negate = negate;
}
copy->force_writemask_all = inst->force_writemask_all;
copy->force_sechalf = inst->force_sechalf;
assert(copy->regs_written == written);
return copy;
}
bool
@ -266,9 +266,8 @@ fs_visitor::opt_cse_local(bblock_t *block)
entry->generator->dst.type,
entry->generator->dst.width);
fs_inst *copy = create_copy_instr(this, entry->generator,
entry->tmp, false);
entry->generator->insert_after(block, copy);
create_copy_instr(bld.at(block, entry->generator->next),
entry->generator, entry->tmp, false);
entry->generator->dst = entry->tmp;
}
@ -279,9 +278,7 @@ fs_visitor::opt_cse_local(bblock_t *block)
assert(inst->dst.width == entry->generator->dst.width);
assert(inst->dst.type == entry->tmp.type);
fs_inst *copy = create_copy_instr(this, inst,
entry->tmp, negate);
inst->insert_before(block, copy);
create_copy_instr(bld.at(block, inst), inst, entry->tmp, negate);
}
/* Set our iterator so that next time through the loop inst->next