i965: Mad hacks to avoid using MRFs on Ivybridge.
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 9 Apr 2011 07:32:46 +0000 (00:32 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 18 May 2011 06:33:00 +0000 (23:33 -0700)
Ivybridge's SEND instruction uses GRFs instead of MRFs.  Unfortunately,
a lot of our code explicitly uses MRFs, and rewriting it would take a
fair bit of effort.  In the meantime, use a hack:

- Change brw_set_dest, brw_set_src0, and brw_set_src1 to implicitly
  convert any MRFs into the top 16 GRFs.
- Enable gen6_resolve_implied_move on Ivybridge: Moving g0 to m0
  actually moves it to g111 thanks to the previous hack.

It remains to officially reserve these registers so the allocator
doesn't try to reuse them.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/i965/brw_eu_emit.c

index 13c925d..7372f94 100644 (file)
@@ -64,7 +64,7 @@ gen6_resolve_implied_move(struct brw_compile *p,
                          GLuint msg_reg_nr)
 {
    struct intel_context *intel = &p->brw->intel;
-   if (intel->gen != 6)
+   if (intel->gen < 6)
       return;
 
    if (src->file != BRW_ARCHITECTURE_REGISTER_FILE || src->nr != BRW_ARF_NULL) {
@@ -78,15 +78,29 @@ gen6_resolve_implied_move(struct brw_compile *p,
    *src = brw_message_reg(msg_reg_nr);
 }
 
+static void
+gen7_convert_mrf_to_grf(struct brw_compile *p, struct brw_reg *reg)
+{
+   struct intel_context *intel = &p->brw->intel;
+   if (intel->gen == 7 && reg->file == BRW_MESSAGE_REGISTER_FILE) {
+      reg->file = BRW_GENERAL_REGISTER_FILE;
+      reg->nr += 111;
+   }
+}
+
 
 static void brw_set_dest(struct brw_compile *p,
                         struct brw_instruction *insn,
                         struct brw_reg dest)
 {
+   struct intel_context *intel = &p->brw->intel;
+
    if (dest.file != BRW_ARCHITECTURE_REGISTER_FILE &&
        dest.file != BRW_MESSAGE_REGISTER_FILE)
       assert(dest.nr < 128);
 
+   gen7_convert_mrf_to_grf(p, &dest);
+
    insn->bits1.da1.dest_reg_file = dest.file;
    insn->bits1.da1.dest_reg_type = dest.type;
    insn->bits1.da1.dest_address_mode = dest.address_mode;
@@ -216,6 +230,8 @@ static void brw_set_src0(struct brw_compile *p,
    if (reg.type != BRW_ARCHITECTURE_REGISTER_FILE)
       assert(reg.nr < 128);
 
+   gen7_convert_mrf_to_grf(p, &reg);
+
    validate_reg(insn, reg);
 
    insn->bits1.da1.src0_reg_file = reg.file;
@@ -294,6 +310,8 @@ void brw_set_src1(struct brw_compile *p,
 
    assert(reg.nr < 128);
 
+   gen7_convert_mrf_to_grf(p, &reg);
+
    validate_reg(insn, reg);
 
    insn->bits1.da1.src1_reg_file = reg.file;