i965/fs: Migrate opt_cse to the IR builder.
Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
e7069fbc70
commit
74c2458ecf
|
@ -32,6 +32,8 @@
|
||||||
* 13.1 (p378).
|
* 13.1 (p378).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using namespace brw;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct aeb_entry : public exec_node {
|
struct aeb_entry : public exec_node {
|
||||||
/** The instruction that generates the expression value. */
|
/** 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);
|
operands_match(a, b, negate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static fs_inst *
|
static void
|
||||||
create_copy_instr(fs_visitor *v, fs_inst *inst, fs_reg src, bool negate)
|
create_copy_instr(const fs_builder &bld, fs_inst *inst, fs_reg src, bool negate)
|
||||||
{
|
{
|
||||||
int written = inst->regs_written;
|
int written = inst->regs_written;
|
||||||
int dst_width = inst->dst.width / 8;
|
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;
|
fs_inst *copy;
|
||||||
|
|
||||||
if (written > dst_width) {
|
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);
|
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++) {
|
for (int i = 0; i < header_size; i++) {
|
||||||
payload[i] = src;
|
payload[i] = src;
|
||||||
payload[i].width = 8;
|
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;
|
payload[i] = src;
|
||||||
src = offset(src, 1);
|
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 {
|
} else {
|
||||||
copy = v->MOV(inst->dst, src);
|
copy = ubld.MOV(inst->dst, src);
|
||||||
copy->src[0].negate = negate;
|
copy->src[0].negate = negate;
|
||||||
}
|
}
|
||||||
copy->force_writemask_all = inst->force_writemask_all;
|
|
||||||
copy->force_sechalf = inst->force_sechalf;
|
|
||||||
assert(copy->regs_written == written);
|
assert(copy->regs_written == written);
|
||||||
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -266,9 +266,8 @@ fs_visitor::opt_cse_local(bblock_t *block)
|
||||||
entry->generator->dst.type,
|
entry->generator->dst.type,
|
||||||
entry->generator->dst.width);
|
entry->generator->dst.width);
|
||||||
|
|
||||||
fs_inst *copy = create_copy_instr(this, entry->generator,
|
create_copy_instr(bld.at(block, entry->generator->next),
|
||||||
entry->tmp, false);
|
entry->generator, entry->tmp, false);
|
||||||
entry->generator->insert_after(block, copy);
|
|
||||||
|
|
||||||
entry->generator->dst = entry->tmp;
|
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.width == entry->generator->dst.width);
|
||||||
assert(inst->dst.type == entry->tmp.type);
|
assert(inst->dst.type == entry->tmp.type);
|
||||||
|
|
||||||
fs_inst *copy = create_copy_instr(this, inst,
|
create_copy_instr(bld.at(block, inst), inst, entry->tmp, negate);
|
||||||
entry->tmp, negate);
|
|
||||||
inst->insert_before(block, copy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set our iterator so that next time through the loop inst->next
|
/* Set our iterator so that next time through the loop inst->next
|
||||||
|
|
Loading…
Reference in New Issue