summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-05-29 13:08:59 -0700
committerMatt Turner <[email protected]>2014-06-01 13:18:52 -0700
commite9bf1662b048e5927f841e84719a3180650a2b0a (patch)
tree51032c7bc3b0fce6f79cb589e829c53d22adf34b /src/mesa
parent56d6dcf4f771d57d2759b2a5c5006f24444c696f (diff)
i965: Give dump_instructions() a filename argument.
This will allow debugging code to dump the IR after an optimization pass makes progress (the next patch). Only let it open and write to a file if the effective user isn't root. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp22
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp2
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp22
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.h1
5 files changed, 42 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 8bd3f612532..c9b31fef5b2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -2571,17 +2571,33 @@ fs_visitor::lower_uniform_pull_constant_loads()
void
fs_visitor::dump_instructions()
{
+ dump_instructions(NULL);
+}
+
+void
+fs_visitor::dump_instructions(const char *name)
+{
calculate_register_pressure();
+ FILE *file = stderr;
+ if (name && geteuid() != 0) {
+ file = fopen(name, "w");
+ if (!file)
+ file = stderr;
+ }
int ip = 0, max_pressure = 0;
foreach_list(node, &this->instructions) {
backend_instruction *inst = (backend_instruction *)node;
max_pressure = MAX2(max_pressure, regs_live_at_ip[ip]);
- fprintf(stderr, "{%3d} %4d: ", regs_live_at_ip[ip], ip);
- dump_instruction(inst);
+ fprintf(file, "{%3d} %4d: ", regs_live_at_ip[ip], ip);
+ dump_instruction(inst, file);
++ip;
}
- fprintf(stderr, "Maximum %3d registers live at once.\n", max_pressure);
+ fprintf(file, "Maximum %3d registers live at once.\n", max_pressure);
+
+ if (file != stderr) {
+ fclose(file);
+ }
}
void
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index 90cf6fb3014..789f0b38c53 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -484,6 +484,7 @@ public:
int implied_mrf_writes(fs_inst *inst);
virtual void dump_instructions();
+ virtual void dump_instructions(const char *name);
void dump_instruction(backend_instruction *inst);
void dump_instruction(backend_instruction *inst, FILE *file);
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 717a94e90f3..bbaf8107ec7 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -498,7 +498,7 @@ fs_visitor::assign_regs(bool allow_spilling)
if (reg == -1) {
fail("no register to spill:\n");
- dump_instructions();
+ dump_instructions(NULL);
} else if (allow_spilling) {
spill_reg(reg);
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index f4f1334d9ef..69eab598ba2 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -700,11 +700,29 @@ backend_instruction::has_side_effects() const
void
backend_visitor::dump_instructions()
{
+ dump_instructions(NULL);
+}
+
+void
+backend_visitor::dump_instructions(const char *name)
+{
+ FILE *file = stderr;
+ if (name && geteuid() != 0) {
+ file = fopen(name, "w");
+ if (!file)
+ file = stderr;
+ }
+
int ip = 0;
foreach_list(node, &this->instructions) {
backend_instruction *inst = (backend_instruction *)node;
- fprintf(stderr, "%d: ", ip++);
- dump_instruction(inst);
+ if (!name)
+ fprintf(stderr, "%d: ", ip++);
+ dump_instruction(inst, file);
+ }
+
+ if (file != stderr) {
+ fclose(file);
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h
index 0dc87789b78..222b0a933cd 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -111,6 +111,7 @@ public:
virtual void dump_instruction(backend_instruction *inst) = 0;
virtual void dump_instruction(backend_instruction *inst, FILE *file) = 0;
virtual void dump_instructions();
+ virtual void dump_instructions(const char *name);
void assign_common_binding_table_offsets(uint32_t next_binding_table_offset);