i965/vs: Add a function for how many MRFs get written as part of a SEND.
authorEric Anholt <eric@anholt.net>
Tue, 6 Sep 2011 19:26:42 +0000 (12:26 -0700)
committerEric Anholt <eric@anholt.net>
Tue, 20 Sep 2011 18:28:56 +0000 (11:28 -0700)
This will be used for compute-to-mrf, which needs to know when MRFs
get overwritten.

src/mesa/drivers/dri/i965/brw_vec4.cpp
src/mesa/drivers/dri/i965/brw_vec4.h

index 1f2cebe157c36243d5ec33dc96699f6138c23ba8..9079ca1d6cefb236cae2aeba1c5306f5bf11663a 100644 (file)
@@ -43,6 +43,43 @@ vec4_instruction::is_math()
           opcode == SHADER_OPCODE_COS ||
           opcode == SHADER_OPCODE_POW);
 }
+/**
+ * Returns how many MRFs an opcode will write over.
+ *
+ * Note that this is not the 0 or 1 implied writes in an actual gen
+ * instruction -- the generate_* functions generate additional MOVs
+ * for setup.
+ */
+int
+vec4_visitor::implied_mrf_writes(vec4_instruction *inst)
+{
+   if (inst->mlen == 0)
+      return 0;
+
+   switch (inst->opcode) {
+   case SHADER_OPCODE_RCP:
+   case SHADER_OPCODE_RSQ:
+   case SHADER_OPCODE_SQRT:
+   case SHADER_OPCODE_EXP2:
+   case SHADER_OPCODE_LOG2:
+   case SHADER_OPCODE_SIN:
+   case SHADER_OPCODE_COS:
+      return 1;
+   case SHADER_OPCODE_POW:
+      return 2;
+   case VS_OPCODE_URB_WRITE:
+      return 1;
+   case VS_OPCODE_PULL_CONSTANT_LOAD:
+      return 2;
+   case VS_OPCODE_SCRATCH_READ:
+      return 2;
+   case VS_OPCODE_SCRATCH_WRITE:
+      return 3;
+   default:
+      assert(!"not reached");
+      return inst->mlen;
+   }
+}
 
 bool
 src_reg::equals(src_reg *r)
index 317c981a40a3f5ab62e7ef05dc99a21d6139dd7a..900c0a9037fbd0825f9cf71fef0d66932d2cd520 100644 (file)
@@ -441,6 +441,8 @@ public:
    vec4_instruction *SCRATCH_READ(dst_reg dst, src_reg index);
    vec4_instruction *SCRATCH_WRITE(dst_reg dst, src_reg src, src_reg index);
 
+   int implied_mrf_writes(vec4_instruction *inst);
+
    bool try_rewrite_rhs_to_dst(ir_assignment *ir,
                               dst_reg dst,
                               src_reg src,