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
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);
if (reg == -1) {
fail("no register to spill:\n");
- dump_instructions();
+ dump_instructions(NULL);
} else if (allow_spilling) {
spill_reg(reg);
}
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);
}
}
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);