summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2012-10-30 15:35:44 -0700
committerEric Anholt <[email protected]>2012-11-28 11:26:33 -0800
commit154ef07aa74e1d91e16cf9f2492cae33790b0998 (patch)
treef2a2bfa175ce5e848c3d593eb2884efb781d4dbe
parent960ab06da05390a5f53163016dddd51ba118b7bc (diff)
i965/fs: Add some minimal backend-IR dumping.
Reviewed-by: Kenneth Graunke <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp89
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.h3
2 files changed, 92 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index f19f2752e7a..cc5a790dc9c 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1935,6 +1935,95 @@ fs_visitor::remove_duplicate_mrf_writes()
return progress;
}
+void
+fs_visitor::dump_instruction(fs_inst *inst)
+{
+ if (inst->opcode < ARRAY_SIZE(opcode_descs) &&
+ opcode_descs[inst->opcode].name) {
+ printf("%s", opcode_descs[inst->opcode].name);
+ } else {
+ printf("op%d", inst->opcode);
+ }
+ if (inst->saturate)
+ printf(".sat");
+ printf(" ");
+
+ switch (inst->dst.file) {
+ case GRF:
+ printf("vgrf%d", inst->dst.reg);
+ if (inst->dst.reg_offset)
+ printf("+%d", inst->dst.reg_offset);
+ break;
+ case MRF:
+ printf("m%d", inst->dst.reg);
+ break;
+ case BAD_FILE:
+ printf("(null)");
+ break;
+ case UNIFORM:
+ printf("***u%d***", inst->dst.reg);
+ break;
+ default:
+ printf("???");
+ break;
+ }
+ printf(", ");
+
+ for (int i = 0; i < 3; i++) {
+ if (inst->src[i].negate)
+ printf("-");
+ if (inst->src[i].abs)
+ printf("|");
+ switch (inst->src[i].file) {
+ case GRF:
+ printf("vgrf%d", inst->src[i].reg);
+ if (inst->src[i].reg_offset)
+ printf("+%d", inst->src[i].reg_offset);
+ break;
+ case MRF:
+ printf("***m%d***", inst->src[i].reg);
+ break;
+ case UNIFORM:
+ printf("u%d", inst->src[i].reg);
+ if (inst->src[i].reg_offset)
+ printf(".%d", inst->src[i].reg_offset);
+ break;
+ case BAD_FILE:
+ printf("(null)");
+ break;
+ default:
+ printf("???");
+ break;
+ }
+ if (inst->src[i].abs)
+ printf("|");
+
+ if (i < 3)
+ printf(", ");
+ }
+
+ printf(" ");
+
+ if (inst->force_uncompressed)
+ printf("1sthalf ");
+
+ if (inst->force_sechalf)
+ printf("2ndhalf ");
+
+ printf("\n");
+}
+
+void
+fs_visitor::dump_instructions()
+{
+ int ip = 0;
+ foreach_list(node, &this->instructions) {
+ fs_inst *inst = (fs_inst *)node;
+ printf("%d: ", ip++);
+ dump_instruction(inst);
+ }
+}
+
/**
* Possibly returns an instruction that set up @param reg.
*
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 489b9700523..a0ed743486b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -365,6 +365,9 @@ public:
void setup_builtin_uniform_values(ir_variable *ir);
int implied_mrf_writes(fs_inst *inst);
+ void dump_instructions();
+ void dump_instruction(fs_inst *inst);
+
const struct gl_fragment_program *fp;
struct brw_wm_compile *c;