Commit 060aa4c9 authored by Matthias Braun's avatar Matthias Braun
Browse files

cleanup and rewrite dumper interface

[r27653]
parent 84d05703
......@@ -21,8 +21,8 @@
* @file
* @date 18.04.2007
* @author Christian Wuerdig
* @brief Implementation of a priority queue. This is the ported version of the
* original Java implementation by Matthias Braun.
* @brief Implementation of a priority queue. This is the ported version of
the original Java implementation by Matthias Braun.
* @version $Id$
*/
#ifndef FIRM_ADT_PQUEUE_H
......
......@@ -74,8 +74,8 @@ FIRM_API void construct_intervals(ir_graph *irg);
/** frees interval information of all graphs. */
FIRM_API void free_intervals(void);
/** dump a graph with the intervals. File name suffix "-interval". */
FIRM_API void dump_interval_graph(ir_graph *irg, const char *suffix);
/** dump a vcg graph with the intervals */
FIRM_API void dump_interval_graph(FILE *out, ir_graph *irg);
#include "end.h"
......
This diff is collapsed.
......@@ -408,7 +408,7 @@ typedef enum {
* Writes several informations requested by reason to
* an output file
*/
typedef int (*dump_node_func)(ir_node *self, FILE *F, dump_reason_t reason);
typedef void (*dump_node_func)(FILE *out, ir_node *self, dump_reason_t reason);
/**
* io_op Operations.
......
......@@ -253,6 +253,6 @@ heights_t *heights_new(ir_graph *irg)
void heights_free(heights_t *h)
{
phase_deinit(&h->ph);
dump_remv_node_info_callback(h->dump_handle);
dump_remove_node_info_callback(h->dump_handle);
xfree(h);
}
......@@ -546,7 +546,7 @@ static void dump_interval_block(FILE *F, ir_node *block)
fprintf(F, " n_exc_outs: %d", get_region_n_exc_outs(block));
fprintf(F, "\" ");
fprintf(F, "info1:\"");
if (dump_dominator_information_flag)
if (ir_get_dump_flags() & ir_dump_flag_dominance)
fprintf(F, "dom depth %d\n", get_Block_dom_depth(block));
/* show arity and possible Bad predecessors of the block */
......@@ -604,25 +604,14 @@ static void dump_interval_loop(FILE *F, ir_loop *l)
fprintf(F, "}\n\n");
}
void dump_interval_graph(ir_graph *irg, const char *suffix)
void dump_interval_graph(FILE *out, ir_graph *irg)
{
FILE *f;
ir_graph *rem;
if (!is_filtered_dump_name(get_entity_ident(get_irg_entity(irg))))
return;
f = vcg_open(irg, suffix, "-intervals");
dump_vcg_header(f, get_irg_dump_name(irg), NULL, NULL);
rem = current_ir_graph;
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
dump_interval_loop(f, get_irg_loop(irg));
dump_vcg_footer(f);
fclose(f);
dump_vcg_header(out, get_irg_dump_name(irg), NULL, NULL);
dump_interval_loop(out, get_irg_loop(irg));
dump_vcg_footer(out);
current_ir_graph = rem;
}
......@@ -1047,8 +1047,6 @@ ir_reg_tree *construct_region_tree(ir_graph *irg)
DB((dbg, LEVEL_1, "Structural analysis on %+F starts...\n", irg));
dump_ir_block_graph(irg, "-structure_start");
/* we need dominance info */
assure_doms(irg);
/* and out edges */
......
......@@ -47,12 +47,11 @@
/**
* Dumper interface for dumping TEMPLATE nodes in vcg.
* @param n the node to dump
* @param F the output file
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int TEMPLATE_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
static void TEMPLATE_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
......@@ -82,8 +81,6 @@ static int TEMPLATE_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
arch_dump_reqs_and_registers(F, n);
break;
}
return 0;
}
const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
......
......@@ -126,10 +126,7 @@ static void TEMPLATE_prepare_graph(void *self)
*/
static void TEMPLATE_finish_irg(void *self)
{
TEMPLATE_code_gen_t *cg = self;
ir_graph *irg = cg->irg;
dump_ir_block_graph_sched(irg, "-TEMPLATE-finished");
(void) self;
}
......
......@@ -47,12 +47,11 @@
/**
* Dumper interface for dumping amd64 nodes in vcg.
* @param n the node to dump
* @param F the output file
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int amd64_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
static void amd64_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
......@@ -82,8 +81,6 @@ static int amd64_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
arch_dump_reqs_and_registers(F, n);
break;
}
return 0;
}
const amd64_attr_t *get_amd64_attr_const(const ir_node *node)
......
......@@ -30,6 +30,7 @@
#include "irprintf.h"
#include "ircons.h"
#include "irgmod.h"
#include "irdump.h"
#include "bitset.h"
#include "debug.h"
......@@ -118,7 +119,7 @@ static void amd64_prepare_graph(void *self)
amd64_transform_graph (cg);
if (cg->dump)
be_dump(cg->irg, "-transformed", dump_ir_block_graph_sched);
dump_ir_graph(cg->irg, "transformed");
}
......@@ -131,7 +132,7 @@ static void amd64_finish_irg(void *self)
amd64_code_gen_t *cg = self;
ir_graph *irg = cg->irg;
dump_ir_block_graph_sched(irg, "-amd64-finished");
dump_ir_graph(irg, "amd64-finished");
}
......
......@@ -70,12 +70,11 @@ const char *arm_get_fpa_imm_name(long imm_value)
/**
* Dumper interface for dumping arm nodes in vcg.
* @param n the node to dump
* @param F the output file
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static int arm_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
static void arm_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
//arm_attr_t *attr = get_arm_attr(n);
......@@ -124,8 +123,6 @@ static int arm_dump_node(ir_node *n, FILE *F, dump_reason_t reason)
#endif
break;
}
return 0;
}
......
......@@ -36,6 +36,7 @@
#include "irgmod.h"
#include "irgopt.h"
#include "iroptimize.h"
#include "irdump.h"
#include "lowering.h"
#include "error.h"
......@@ -153,13 +154,13 @@ static void arm_prepare_graph(void *self)
local_optimize_graph(cg->irg);
if (cg->dump)
be_dump(cg->irg, "-transformed", dump_ir_block_graph_sched);
dump_ir_graph(cg->irg, "transformed");
/* do code placement, to optimize the position of constants */
place_code(cg->irg);
if (cg->dump)
be_dump(cg->irg, "-place", dump_ir_block_graph_sched);
dump_ir_graph(cg->irg, "place");
}
/**
......
......@@ -563,8 +563,8 @@ void be_ra_chordal_color(be_chordal_env_t *chordal_env)
dom_tree_walk_irg(irg, constraints, NULL, &env);
if (chordal_env->opts->dump_flags & BE_CH_DUMP_CONSTR) {
snprintf(buf, sizeof(buf), "-%s-constr", chordal_env->cls->name);
be_dump(chordal_env->irg, buf, dump_ir_block_graph_sched);
snprintf(buf, sizeof(buf), "%s-constr", chordal_env->cls->name);
dump_ir_graph(chordal_env->irg, buf);
}
be_timer_pop(T_CONSTR);
......
......@@ -175,17 +175,16 @@ static void be_ra_chordal_coloring(be_chordal_env_t *env)
static void dump(unsigned mask, ir_graph *irg,
const arch_register_class_t *cls,
const char *suffix,
void (*dump_func)(ir_graph *, const char *))
const char *suffix)
{
if ((options.dump_flags & mask) == mask) {
if (cls) {
char buf[256];
snprintf(buf, sizeof(buf), "-%s%s", cls->name, suffix);
be_dump(irg, buf, dump_func);
snprintf(buf, sizeof(buf), "%s-%s", cls->name, suffix);
dump_ir_graph(irg, buf);
} else {
dump_ir_graph(irg, suffix);
}
else
be_dump(irg, suffix, dump_func);
}
}
......@@ -266,7 +265,7 @@ static void pre_spill(post_spill_env_t *pse, const arch_register_class_t *cls)
be_pre_spill_prepare_constr(chordal_env->birg, chordal_env->cls);
be_timer_pop(T_RA_CONSTR);
dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "-constr-pre", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "constr-pre");
}
/**
......@@ -314,7 +313,7 @@ static void post_spill(post_spill_env_t *pse, int iteration)
be_ra_chordal_coloring(chordal_env);
be_timer_pop(T_RA_COLOR);
dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "-color", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "color");
/* Create the ifg with the selected flavor */
be_timer_push(T_RA_IFG);
......@@ -359,14 +358,14 @@ static void post_spill(post_spill_env_t *pse, int iteration)
co_driver(chordal_env);
be_timer_pop(T_RA_COPYMIN);
dump(BE_CH_DUMP_COPYMIN, irg, pse->cls, "-copymin", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_COPYMIN, irg, pse->cls, "copymin");
/* ssa destruction */
be_timer_push(T_RA_SSA);
be_ssa_destruction(chordal_env);
be_timer_pop(T_RA_SSA);
dump(BE_CH_DUMP_SSADESTR, irg, pse->cls, "-ssadestr", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_SSADESTR, irg, pse->cls, "ssadestr");
if (chordal_env->opts->vrfy_option != BE_CH_VRFY_OFF) {
be_timer_push(T_VERIFY);
......@@ -447,8 +446,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
be_do_spill(birg, cls);
be_timer_pop(T_RA_SPILL);
dump(BE_CH_DUMP_SPILL, irg, pse.cls, "-spill",
dump_ir_block_graph_sched);
dump(BE_CH_DUMP_SPILL, irg, pse.cls, "spill");
post_spill(&pse, 0);
......@@ -480,7 +478,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
be_timer_push(T_RA_SPILL);
arch_code_generator_spill(birg->cg, birg);
be_timer_pop(T_RA_SPILL);
dump(BE_CH_DUMP_SPILL, irg, NULL, "-spill", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_SPILL, irg, NULL, "spill");
for (j = 0; j < m; ++j) {
post_spill(&pse[j], j);
......@@ -498,7 +496,7 @@ static void be_ra_chordal_main(be_irg_t *birg)
be_timer_push(T_RA_EPILOG);
lower_nodes_after_ra(birg, options.lower_perm_opt & BE_CH_LOWER_PERM_COPY ? 1 : 0);
dump(BE_CH_DUMP_LOWER, irg, NULL, "-belower-after-ra", dump_ir_block_graph_sched);
dump(BE_CH_DUMP_LOWER, irg, NULL, "belower-after-ra");
obstack_free(&obst, NULL);
be_liveness_invalidate(be_get_birg_liveness(birg));
......
......@@ -215,6 +215,23 @@ void copystat_add_ilp_iter(int iters)
#endif /* WITH_ILP */
/**
* Opens a file named base.ext with the mode mode.
*/
static FILE *be_ffopen(const char *base, const char *ext, const char *mode)
{
FILE *out;
char buf[1024];
snprintf(buf, sizeof(buf), "%s.%s", base, ext);
buf[sizeof(buf) - 1] = '\0';
if (! (out = fopen(buf, mode))) {
fprintf(stderr, "Cannot open file %s in mode %s\n", buf, mode);
return NULL;
}
return out;
}
void copystat_dump(ir_graph *irg)
{
int i;
......
......@@ -1948,7 +1948,7 @@ static void create_ilp(ir_node *block, void *walk_env)
fclose(f);
snprintf(buf, sizeof(buf), "lpp_block_%lu.infeasible.mps", get_irn_node_nr(block));
lpp_dump(lpp, buf);
dump_ir_block_graph(env->irg, "-infeasible");
dump_ir_graph(env->irg, "infeasible");
}
})
......
......@@ -29,8 +29,10 @@
#include "beinfo.h"
#include "bearch.h"
#include "benode.h"
#include "besched.h"
#include "irgwalk.h"
#include "irnode_t.h"
#include "irdump_t.h"
#include "error.h"
static copy_attr_func old_phi_copy_attr;
......@@ -75,8 +77,8 @@ static void new_Phi_copy_attr(ir_graph *irg, const ir_node *old_node,
int be_infos_equal(const backend_info_t *info1, const backend_info_t *info2)
{
int len = ARR_LEN(info1->out_infos);
int i;
int len = ARR_LEN(info1->out_infos);
int i;
if (ARR_LEN(info2->out_infos) != len)
return false;
......@@ -122,9 +124,31 @@ void be_info_init(void)
op_Phi->ops.dump_node = be_dump_phi_reg_reqs;
}
/**
* Edge hook to dump the schedule edges.
*/
static void sched_edge_hook(FILE *F, ir_node *irn)
{
if (is_Proj(irn))
return;
if (get_irn_irg(irn)->be_data == NULL)
return;
if (sched_is_scheduled(irn) && sched_has_prev(irn)) {
ir_node *prev = sched_prev(irn);
fprintf(F, "edge:{sourcename:\"");
PRINT_NODEID(irn);
fprintf(F, "\" targetname:\"");
PRINT_NODEID(prev);
fprintf(F, "\" color:magenta}\n");
}
}
void be_info_init_irg(ir_graph *irg)
{
irg_walk_anchors(irg, init_walker, NULL, NULL);
set_dump_node_edge_hook(sched_edge_hook);
}
void be_info_free(void)
......
......@@ -434,11 +434,10 @@ static void be_done_env(be_main_env_t *env)
* @param suffix the suffix for the dumper
* @param dumper the dumper to be called
*/
static void dump(int mask, ir_graph *irg, const char *suffix,
void (*dumper)(ir_graph *, const char *))
static void dump(int mask, ir_graph *irg, const char *suffix)
{
if (be_options.dump_flags & mask)
be_dump(irg, suffix, dumper);
dump_ir_graph(irg, suffix);
}
/**
......@@ -446,6 +445,8 @@ static void dump(int mask, ir_graph *irg, const char *suffix,
*/
static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
{
dump(DUMP_INITIAL, irg, "begin");
irg->be_data = birg;
memset(birg, 0, sizeof(*birg));
......@@ -456,8 +457,6 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
edges_deactivate_kind(irg, EDGE_KIND_DEP);
edges_activate_kind(irg, EDGE_KIND_DEP);
dump(DUMP_INITIAL, irg, "-begin", dump_ir_block_graph);
/* set the current graph (this is important for several firm functions) */
current_ir_graph = irg;
......@@ -477,7 +476,7 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env)
set_irg_phase_state(irg, phase_backend);
be_info_init_irg(irg);
dump(DUMP_INITIAL, irg, "-prepared", dump_ir_block_graph);
dump(DUMP_INITIAL, irg, "prepared");
}
#define BE_TIMER_ONLY(code) do { if (be_timing) { code; } } while (0)
......@@ -637,7 +636,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
birg->abi = be_abi_introduce(birg);
be_timer_pop(T_ABI);
dump(DUMP_ABI, irg, "-abi", dump_ir_block_graph);
dump(DUMP_ABI, irg, "abi");
/* do local optimizations */
optimize_graph_df(irg);
......@@ -653,7 +652,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
edges_deactivate(irg);
edges_activate(irg);
dump(DUMP_PREPARED, irg, "-pre_transform", dump_ir_block_graph_sched);
dump(DUMP_PREPARED, irg, "pre_transform");
if (be_options.vrfy_option == BE_VRFY_WARN) {
be_check_dominance(irg);
......@@ -666,7 +665,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
arch_code_generator_prepare_graph(birg->cg);
be_timer_pop(T_CODEGEN);
dump(DUMP_PREPARED, irg, "-prepared", dump_ir_block_graph);
dump(DUMP_PREPARED, irg, "prepared");
if (be_options.vrfy_option == BE_VRFY_WARN) {
be_check_dominance(irg);
......@@ -708,7 +707,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
};
be_timer_pop(T_SCHED);
dump(DUMP_SCHED, irg, "-sched", dump_ir_block_graph_sched);
dump(DUMP_SCHED, irg, "sched");
/* check schedule */
be_timer_push(T_VERIFY);
......@@ -728,7 +727,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
assure_constraints(birg);
be_timer_pop(T_CONSTR);
dump(DUMP_SCHED, irg, "-assured", dump_ir_block_graph_sched);
dump(DUMP_SCHED, irg, "assured");
/* stuff needs to be done after scheduling but before register allocation */
be_timer_push(T_RA_PREPARATION);
......@@ -740,7 +739,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_abi_fix_stack_nodes(birg->abi);
be_timer_pop(T_ABI);
dump(DUMP_SCHED, irg, "-fix_stack", dump_ir_block_graph_sched);
dump(DUMP_SCHED, irg, "fix_stack");
/* check schedule */
be_timer_push(T_VERIFY);
......@@ -761,7 +760,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
stat_ev_dbl("bemain_costs_before_ra", be_estimate_irg_costs(irg, birg->exec_freq));
#endif
dump(DUMP_RA, irg, "-ra", dump_ir_block_graph_sched);
dump(DUMP_RA, irg, "ra");
/* let the code generator prepare the graph for emitter */
be_timer_push(T_FINISH);
......@@ -775,13 +774,13 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
be_abi_fix_stack_bias(birg->abi);
be_timer_pop(T_ABI);
dump(DUMP_SCHED, irg, "-fix_stack_after_ra", dump_ir_block_graph_sched);
dump(DUMP_SCHED, irg, "fix_stack_after_ra");
be_timer_push(T_FINISH);
arch_code_generator_finish(birg->cg);
be_timer_pop(T_FINISH);
dump(DUMP_FINAL, irg, "-finish", dump_ir_block_graph_sched);
dump(DUMP_FINAL, irg, "finish");
stat_ev_if {
be_stat_ev("bemain_insns_finish", be_count_insns(irg));
......@@ -810,7 +809,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
arch_code_generator_done(birg->cg);
be_timer_pop(T_EMIT);
dump(DUMP_FINAL, irg, "-end", dump_ir_block_graph_sched);
dump(DUMP_FINAL, irg, "end");
be_timer_push(T_ABI);
be_abi_free(birg->abi);
......
......@@ -1289,7 +1289,7 @@ void be_set_phi_reg_req(ir_node *node, const arch_register_req_t *req)
assert(mode_is_datab(get_irn_mode(node)));
}
int be_dump_phi_reg_reqs(ir_node *node, FILE *F, dump_reason_t reason)
void be_dump_phi_reg_reqs(FILE *F, ir_node *node, dump_reason_t reason)
{
switch (reason) {
case dump_node_opcode_txt:
......@@ -1312,8 +1312,6 @@ int be_dump_phi_reg_reqs(ir_node *node, FILE *F, dump_reason_t reason)
default:
break;
}
return 0;
}
static const arch_irn_ops_t phi_irn_ops = {
......@@ -1341,7 +1339,7 @@ static const arch_irn_ops_t phi_irn_ops = {
/**
* ir_op-Operation: dump a be node to file
*/
static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
static void dump_node(FILE *f, ir_node *irn, dump_reason_t reason)
{
be_node_attr_t *at = get_irn_attr(irn);
......@@ -1427,8 +1425,6 @@ static int dump_node(ir_node *irn, FILE *f, dump_reason_t reason)
break;
}
}
return 0;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment