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:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user