summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhenyu Wang <zhenyuw@linux.intel.com>2015-07-09 13:58:41 +0800
committerMatt Turner <mattst88@gmail.com>2015-11-09 11:49:04 -0800
commitd1622528d71f74775889de63b2dbd4b37d148975 (patch)
treec491bf11edd5a2de007946a348529016eb2a8164
parent3ea3727998add8ba201e48934febc96be2cbdb99 (diff)
i965: Replace illegal compacted NOP with valid compact instructioncompact
NOP actually has no compact version, but we use it for instruction alignment for compact kernel. Although it seems working on HW, it is illegal and might not be valid for any future one. This trys to get a temporary compact instruction with no effect for alignment to replace compacted NOP. G45 spec has note that HW compact logic could determine NENOP and drop it right away, so we can still keep with that. v2: rebase to master, we still need this to work with internal tool. v3: [mattst88] Rename brw_get_noop_compact -> fill_compaction_padding Generate uncompacted NOP MOV instruction in local variable Replace fprintf/exit with assert Reviewed-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu_compact.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_eu_compact.c b/src/mesa/drivers/dri/i965/brw_eu_compact.c
index 07ace6bfbcb3..3ed8e288bfab 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_compact.c
@@ -1403,6 +1403,34 @@ brw_init_compaction_tables(const struct brw_device_info *devinfo)
}
}
+static void
+fill_compaction_padding(struct brw_codegen *p, brw_compact_inst *dst)
+{
+ const struct brw_device_info *devinfo = p->devinfo;
+ struct brw_reg g0 = brw_vec8_grf(0, 0);
+ brw_inst inst;
+
+ if (devinfo->is_g4x) {
+ memset(dst, 0, sizeof(*dst));
+ brw_compact_inst_set_opcode(devinfo, dst, BRW_OPCODE_NENOP);
+ brw_compact_inst_set_cmpt_control(devinfo, dst, true);
+ return;
+ }
+
+ /* As NOP has no legal compact version, try to use a legal compact
+ * instruction for compact instruction alignment.
+ */
+ memcpy(&inst, p->current, sizeof(inst));
+ brw_inst_set_opcode(devinfo, &inst, BRW_OPCODE_MOV);
+ brw_inst_set_pred_control(devinfo, &inst, BRW_PREDICATE_NONE);
+ brw_inst_set_access_mode(devinfo, &inst, BRW_ALIGN_1);
+ brw_set_dest(p, &inst, g0);
+ brw_set_src0(p, &inst, g0);
+
+ bool UNUSED ret = brw_try_compact_instruction(devinfo, dst, &inst);
+ assert(ret);
+}
+
void
brw_compact_instructions(struct brw_codegen *p, int start_offset,
int num_annotations, struct annotation *annotation)
@@ -1453,9 +1481,7 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset,
/* All uncompacted instructions need to be aligned on G45. */
if ((offset & sizeof(brw_compact_inst)) != 0 && devinfo->is_g4x){
brw_compact_inst *align = store + offset;
- memset(align, 0, sizeof(*align));
- brw_compact_inst_set_opcode(devinfo, align, BRW_OPCODE_NENOP);
- brw_compact_inst_set_cmpt_control(devinfo, align, true);
+ fill_compaction_padding(p, align);
offset += sizeof(brw_compact_inst);
compacted_count--;
compacted_counts[src_offset / sizeof(brw_inst)] = compacted_count;
@@ -1562,9 +1588,7 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset,
*/
if (p->next_insn_offset & sizeof(brw_compact_inst)) {
brw_compact_inst *align = store + offset;
- memset(align, 0, sizeof(*align));
- brw_compact_inst_set_opcode(devinfo, align, BRW_OPCODE_NOP);
- brw_compact_inst_set_cmpt_control(devinfo, align, true);
+ fill_compaction_padding(p, align);
p->next_insn_offset += sizeof(brw_compact_inst);
}
p->nr_insn = p->next_insn_offset / sizeof(brw_inst);