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 <kenneth@whitecape.org>
This commit is contained in:
Matt Turner
2014-05-29 13:08:59 -07:00
parent 56d6dcf4f7
commit e9bf1662b0
5 changed files with 42 additions and 6 deletions
+19 -3
View File
@@ -2570,18 +2570,34 @@ 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
+1
View File
@@ -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);
@@ -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);
}
+20 -2
View File
@@ -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);
}
}
+1
View File
@@ -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);