this->fixed_hw_reg = reg.fixed_hw_reg;
}
+bool
+dst_reg::equals(const dst_reg &r) const
+{
+ return (file == r.file &&
+ reg == r.reg &&
+ reg_offset == r.reg_offset &&
+ type == r.type &&
+ negate == r.negate &&
+ abs == r.abs &&
+ writemask == r.writemask &&
+ (reladdr == r.reladdr ||
+ (reladdr && r.reladdr && reladdr->equals(*r.reladdr))) &&
+ memcmp(&fixed_hw_reg, &r.fixed_hw_reg,
+ sizeof(fixed_hw_reg)) == 0);
+}
+
bool
vec4_instruction::is_send_from_grf()
{
}
}
+unsigned
+vec4_instruction::regs_read(unsigned arg) const
+{
+ if (src[arg].file == BAD_FILE)
+ return 0;
+
+ switch (opcode) {
+ case SHADER_OPCODE_SHADER_TIME_ADD:
+ return arg == 0 ? mlen : 1;
+
+ case VS_OPCODE_PULL_CONSTANT_LOAD_GEN7:
+ return arg == 1 ? mlen : 1;
+
+ default:
+ return 1;
+ }
+}
+
bool
vec4_instruction::can_do_source_mods(struct brw_context *brw)
{
int
vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
{
- if (inst->mlen == 0)
+ if (inst->mlen == 0 || inst->is_send_from_grf())
return 0;
switch (inst->opcode) {
int last_reg = -1, last_reg_offset = -1;
enum register_file last_reg_file = BAD_FILE;
- int remaining_channels;
+ int remaining_channels = 0;
uint8_t imm[4];
- int inst_count;
+ int inst_count = 0;
vec4_instruction *imm_inst[4];
foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
bool progress = false;
foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
- if (inst->dst.file == BAD_FILE || inst->dst.file == HW_REG)
+ if (inst->dst.file == BAD_FILE || inst->dst.file == HW_REG ||
+ inst->is_send_from_grf())
continue;
int swizzle[4];
inst->opcode = BRW_OPCODE_MOV;
inst->src[1] = src_reg();
progress = true;
+ } else if (inst->src[1].is_negative_one()) {
+ inst->opcode = BRW_OPCODE_MOV;
+ inst->src[0].negate = !inst->src[0].negate;
+ inst->src[1] = src_reg();
+ progress = true;
}
break;
case BRW_OPCODE_CMP:
}
#undef IS_DWORD
+ if (brw->gen >= 8) {
+ if (inst->opcode == BRW_OPCODE_F32TO16)
+ return true;
+ }
+
/*
* mlen:
* In the presence of send messages, totally interrupt dependency
void
vec4_visitor::split_virtual_grfs()
{
- int num_vars = this->virtual_grf_count;
+ int num_vars = this->alloc.count;
int new_virtual_grf[num_vars];
bool split_grf[num_vars];
/* Try to split anything > 0 sized. */
for (int i = 0; i < num_vars; i++) {
- split_grf[i] = this->virtual_grf_sizes[i] != 1;
+ split_grf[i] = this->alloc.sizes[i] != 1;
}
/* Check that the instructions are compatible with the registers we're trying
if (!split_grf[i])
continue;
- new_virtual_grf[i] = virtual_grf_alloc(1);
- for (int j = 2; j < this->virtual_grf_sizes[i]; j++) {
- int reg = virtual_grf_alloc(1);
+ new_virtual_grf[i] = alloc.allocate(1);
+ for (unsigned j = 2; j < this->alloc.sizes[i]; j++) {
+ unsigned reg = alloc.allocate(1);
assert(reg == new_virtual_grf[i] + j - 1);
(void) reg;
}
- this->virtual_grf_sizes[i] = 1;
+ this->alloc.sizes[i] = 1;
}
foreach_block_and_inst(block, vec4_instruction, inst, cfg) {
vec4_instruction *inst = (vec4_instruction *)be_inst;
if (inst->predicate) {
- fprintf(file, "(%cf0) ",
- inst->predicate_inverse ? '-' : '+');
+ fprintf(file, "(%cf0.%d) ",
+ inst->predicate_inverse ? '-' : '+',
+ inst->flag_subreg);
}
fprintf(file, "%s", brw_instruction_name(inst->opcode));
+ if (inst->saturate)
+ fprintf(file, ".sat");
if (inst->conditional_mod) {
fprintf(file, "%s", conditional_modifier[inst->conditional_mod]);
+ if (!inst->predicate &&
+ (brw->gen < 5 || (inst->opcode != BRW_OPCODE_SEL &&
+ inst->opcode != BRW_OPCODE_IF &&
+ inst->opcode != BRW_OPCODE_WHILE))) {
+ fprintf(file, ".f0.%d", inst->flag_subreg);
+ }
}
fprintf(file, " ");
/* Don't print .0; and only VGRFs have reg_offsets and sizes */
if (inst->src[i].reg_offset != 0 &&
inst->src[i].file == GRF &&
- virtual_grf_sizes[inst->src[i].reg] != 1)
+ alloc.sizes[inst->src[i].reg] != 1)
fprintf(file, ".%d", inst->src[i].reg_offset);
if (inst->src[i].file != IMM) {
time.type = BRW_REGISTER_TYPE_UD;
emit(MOV(time, src_reg(value)));
- emit(SHADER_OPCODE_SHADER_TIME_ADD, dst_reg(), src_reg(dst));
+ vec4_instruction *inst =
+ emit(SHADER_OPCODE_SHADER_TIME_ADD, dst_reg(), src_reg(dst));
+ inst->mlen = 2;
}
bool
if (false) {
/* Debug of register spilling: Go spill everything. */
- const int grf_count = virtual_grf_count;
- float spill_costs[virtual_grf_count];
- bool no_spill[virtual_grf_count];
+ const int grf_count = alloc.count;
+ float spill_costs[alloc.count];
+ bool no_spill[alloc.count];
evaluate_spill_costs(spill_costs, no_spill);
for (int i = 0; i < grf_count; i++) {
if (no_spill[i])
}
fs_generator g(brw, mem_ctx, (void *) &c->key, &prog_data->base.base,
- &c->vp->program.Base, v.runtime_check_aads_emit, "VS");
+ &c->vp->program.Base, v.promoted_constants,
+ v.runtime_check_aads_emit, "VS");
if (INTEL_DEBUG & DEBUG_VS) {
char *name = ralloc_asprintf(mem_ctx, "%s vertex shader %d",
prog->Label ? prog->Label : "unnamed",