Commit 8e4e49e6 authored by Matthias Braun's avatar Matthias Braun
Browse files

irdump: dump interfaces take const ir_node* now

parent b741c12f
......@@ -235,9 +235,6 @@ FIRM_API void dump_globals_as_text(FILE *out);
*/
FIRM_API void dump_loop(FILE *out, ir_loop *loop);
/** Write the irnode and all its attributes to the file passed. */
FIRM_API void dump_irnode_to_file(FILE *out, ir_node *node);
/** Write the graph and all its attributes to the file passed.
* Does not write the nodes. */
FIRM_API void dump_graph_as_text(FILE *out, ir_graph *graph);
......@@ -359,16 +356,20 @@ FIRM_API ir_dump_flags_t ir_get_dump_flags(void);
* If this function returns zero, the default attributes are added, else
* removed.
*/
typedef int (*dump_node_vcgattr_func)(FILE *out, ir_node *node, ir_node *local);
typedef int (*dump_node_vcgattr_func)(FILE *out, const ir_node *node, const ir_node *local);
/**
* This hook is called to dump the vcg attributes of an edge to a file.
* If this function returns zero, the default attributes are added, else
* removed.
*/
typedef int (*dump_edge_vcgattr_func)(FILE *out, ir_node *node, int to);
typedef int (*dump_edge_vcgattr_func)(FILE *out, const ir_node *node, int to);
typedef void (*dump_node_edge_func)(FILE *out, ir_node *node);
/**
* This hook allows dumping of additional edges (it is called outside a node: {}
* environment)
*/
typedef void (*dump_node_edge_func)(FILE *out, const ir_node *node);
/** Set the node_vcgattr hook. */
FIRM_API void set_dump_node_vcgattr_hook(dump_node_vcgattr_func hook);
......
......@@ -230,7 +230,7 @@ typedef enum {
* Writes several informations requested by reason to
* an output file
*/
typedef void (*dump_node_func)(FILE *out, ir_node *self, dump_reason_t reason);
typedef void (*dump_node_func)(FILE *out, const ir_node *self, dump_reason_t reason);
/**
* io_op Operations.
......
......@@ -49,7 +49,7 @@
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
*/
static void TEMPLATE_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
static void TEMPLATE_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
......
......@@ -55,7 +55,7 @@ void set_amd64_ls_mode(ir_node *node, ir_mode *mode)
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
*/
static void amd64_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
static void amd64_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
......
......@@ -99,7 +99,7 @@ static bool has_farith_attr(const ir_node *node)
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
*/
static void arm_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
static void arm_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
{
switch (reason) {
case dump_node_opcode_txt:
......
......@@ -147,7 +147,7 @@ void be_info_init(void)
/**
* Edge hook to dump the schedule edges.
*/
static void sched_edge_hook(FILE *F, ir_node *irn)
static void sched_edge_hook(FILE *F, const ir_node *irn)
{
if (is_Proj(irn))
return;
......
......@@ -1133,7 +1133,7 @@ void be_set_phi_reg_req(ir_node *node, const arch_register_req_t *req)
assert(mode_is_datab(get_irn_mode(node)));
}
void be_dump_phi_reg_reqs(FILE *F, ir_node *node, dump_reason_t reason)
void be_dump_phi_reg_reqs(FILE *F, const ir_node *node, dump_reason_t reason)
{
switch (reason) {
case dump_node_opcode_txt:
......@@ -1173,7 +1173,7 @@ static const arch_irn_ops_t phi_irn_ops = {
/**
* ir_op-Operation: dump a be node to file
*/
static void dump_node(FILE *f, ir_node *irn, dump_reason_t reason)
static void dump_node(FILE *f, const ir_node *irn, dump_reason_t reason)
{
assert(is_be_node(irn));
......
......@@ -445,7 +445,7 @@ void be_node_set_reg_class_out(ir_node *irn, int pos,
*/
void be_set_phi_reg_req(ir_node *phi, const arch_register_req_t *req);
void be_dump_phi_reg_reqs(FILE *out, ir_node *node, dump_reason_t reason);
void be_dump_phi_reg_reqs(FILE *out, const ir_node *node, dump_reason_t reason);
/**
* Creates a new phi with associated backend informations
......
......@@ -61,7 +61,7 @@
* @param reason indicates which kind of information should be dumped
* @return 0 on success or != 0 on failure
*/
static void ia32_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
static void ia32_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
{
ir_mode *mode = NULL;
......@@ -184,7 +184,7 @@ static void ia32_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
/* dump pn code */
if (is_ia32_CMovcc(n) || is_ia32_Setcc(n) || is_ia32_Jcc(n)) {
ia32_attr_t *attr = get_ia32_attr(n);
const ia32_attr_t *attr = get_ia32_attr_const(n);
fprintf(F, "condition_code = 0x%X\n", (unsigned)get_ia32_condcode(n));
fprintf(F, "ins_permuted = %u\n", (unsigned)attr->data.ins_permuted);
}
......
......@@ -80,7 +80,7 @@ static bool has_fp_conv_attr(const ir_node *node)
* @param n the node to dump
* @param reason indicates which kind of information should be dumped
*/
static void sparc_dump_node(FILE *F, ir_node *n, dump_reason_t reason)
static void sparc_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
{
const sparc_attr_t *sparc_attr;
......
......@@ -229,7 +229,7 @@ static void named_color(int num, const char *name)
/** Initializes the used colors. */
static void init_colors(void)
{
static int initialized = 0;
static bool initialized = 0;
if (initialized)
return;
......@@ -267,7 +267,7 @@ static void print_vcg_color(FILE *out, ird_color_t color)
*
* Projs should be dumped near their predecessor, so they get "nearedge".
*/
static void print_node_edge_kind(FILE *out, ir_node *node)
static void print_node_edge_kind(FILE *out, const ir_node *node)
{
if (is_Proj(node)) {
fprintf(out, "nearedge: ");
......@@ -655,7 +655,7 @@ static list_tuple *construct_extblock_lists(ir_graph *irg)
return lists;
}
void dump_node_opcode(FILE *F, ir_node *n)
void dump_node_opcode(FILE *F, const ir_node *n)
{
const ir_op_ops *ops = get_op_ops(get_irn_op(n));
......@@ -732,7 +732,7 @@ void dump_node_opcode(FILE *F, ir_node *n)
* Dump the mode of a node n to a file F.
* Ignore modes that are "always known".
*/
static void dump_node_mode(FILE *F, ir_node *n)
static void dump_node_mode(FILE *F, const ir_node *n)
{
const ir_op_ops *ops = get_op_ops(get_irn_op(n));
unsigned iro;
......@@ -768,7 +768,7 @@ static void dump_node_mode(FILE *F, ir_node *n)
/**
* Dump the type of a node n to a file F if it's known.
*/
static int dump_node_typeinfo(FILE *F, ir_node *n)
static int dump_node_typeinfo(FILE *F, const ir_node *n)
{
int bad = 0;
......@@ -789,7 +789,7 @@ static int dump_node_typeinfo(FILE *F, ir_node *n)
/**
* Dump additional node attributes of some nodes to a file F.
*/
static void dump_node_nodeattr(FILE *F, ir_node *n)
static void dump_node_nodeattr(FILE *F, const ir_node *n)
{
ir_node *pred;
unsigned code;
......@@ -862,14 +862,7 @@ static void dump_node_nodeattr(FILE *F, ir_node *n)
}
}
static void dump_node_ana_vals(FILE *F, ir_node *n)
{
(void) F;
(void) n;
return;
}
void dump_node_label(FILE *F, ir_node *n)
void dump_node_label(FILE *F, const ir_node *n)
{
dump_node_opcode(F, n);
fputs(" ", F);
......@@ -889,10 +882,10 @@ void dump_node_label(FILE *F, ir_node *n)
* Dumps the attributes of a node n into the file F.
* Currently this is only the color of a node.
*/
static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad)
static void dump_node_vcgattr(FILE *F, const ir_node *node, const ir_node *local, bool bad)
{
ir_mode *mode;
ir_node *n;
const ir_node *n;
if (bad) {
print_vcg_color(F, ird_color_error);
......@@ -980,7 +973,7 @@ void dump_remove_node_info_callback(void *handle)
/**
* Dump the node information of a node n to a file F.
*/
static void dump_node_info(FILE *F, ir_node *n)
static void dump_node_info(FILE *F, const ir_node *n)
{
const ir_op_ops *ops = get_op_ops(get_irn_op(n));
......@@ -1004,7 +997,7 @@ static int is_constlike_node(const ir_node *node)
/** outputs the predecessors of n, that are constants, local. I.e.,
generates a copy of the constant predecessors for each node called with. */
static void dump_const_node_local(FILE *F, ir_node *n)
static void dump_const_node_local(FILE *F, const ir_node *n)
{
int i;
if (!get_opt_dump_const_local()) return;
......@@ -1035,7 +1028,7 @@ static void dump_const_node_local(FILE *F, ir_node *n)
}
/** If the block of an edge is a const_like node, dump it local with an edge */
static void dump_const_block_local(FILE *F, ir_node *n)
static void dump_const_block_local(FILE *F, const ir_node *n)
{
ir_node *blk;
......@@ -1106,7 +1099,7 @@ static void print_type_dbg_info(FILE *F, type_dbg_info *dbg)
/**
* Dump a node
*/
static void dump_node(FILE *F, ir_node *n)
void dump_node(FILE *F, const ir_node *n)
{
int bad = 0;
const char *p;
......@@ -1122,7 +1115,6 @@ static void dump_node(FILE *F, ir_node *n)
fputs(" label: \"", F);
bad = ! irn_verify_irg_dump(n, current_ir_graph, &p);
dump_node_label(F, n);
dump_node_ana_vals(F, n);
//dump_node_ana_info(F, n);
fputs("\" ", F);
......@@ -1137,12 +1129,10 @@ static void dump_node(FILE *F, ir_node *n)
fputs("}\n", F);
dump_const_node_local(F, n);
if (dump_node_edge_hook)
dump_node_edge_hook(F, n);
}
/** dump the edge to the block this node belongs to */
static void dump_ir_block_edge(FILE *F, ir_node *n)
static void dump_ir_block_edge(FILE *F, const ir_node *n)
{
if (get_opt_dump_const_local() && is_constlike_node(n)) return;
if (!is_Block(n)) {
......@@ -1172,7 +1162,7 @@ static void dump_ir_block_edge(FILE *F, ir_node *n)
}
}
static void print_data_edge_vcgattr(FILE *F, ir_node *from, int to)
static void print_data_edge_vcgattr(FILE *F, const ir_node *from, int to)
{
/*
* do not use get_nodes_block() here, will fail
......@@ -1184,7 +1174,7 @@ static void print_data_edge_vcgattr(FILE *F, ir_node *from, int to)
fprintf(F, INTER_DATA_EDGE_ATTR);
}
static void print_mem_edge_vcgattr(FILE *F, ir_node *from, int to)
static void print_mem_edge_vcgattr(FILE *F, const ir_node *from, int to)
{
/*
* do not use get_nodes_block() here, will fail
......@@ -1197,7 +1187,7 @@ static void print_mem_edge_vcgattr(FILE *F, ir_node *from, int to)
}
/** Print the vcg attributes for the edge from node "from" to its "to"th input */
static void print_edge_vcgattr(FILE *F, ir_node *from, int to)
static void print_edge_vcgattr(FILE *F, const ir_node *from, int to)
{
assert(from);
......@@ -1240,10 +1230,13 @@ static void print_edge_vcgattr(FILE *F, ir_node *from, int to)
}
/** dump edges to our inputs */
static void dump_ir_data_edges(FILE *F, ir_node *n)
static void dump_ir_data_edges(FILE *F, const ir_node *n)
{
int i, num;
if (dump_node_edge_hook)
dump_node_edge_hook(F, n);
if (!(flags & ir_dump_flag_keepalive_edges) && is_End(n)) {
/* the End node has only keep-alive edges */
return;
......@@ -1323,9 +1316,8 @@ static void dump_ir_edges(ir_node *node, void *env)
/** Dumps a node and its edges but not the block edge */
static void dump_node_wo_blockedge(ir_node *n, void *env)
static void dump_node_wo_blockedge(FILE *F, const ir_node *n)
{
FILE *F = (FILE*)env;
dump_node(F, n);
dump_ir_data_edges(F, n);
}
......@@ -1334,7 +1326,7 @@ static void dump_node_wo_blockedge(ir_node *n, void *env)
static void dump_node_with_edges(ir_node *n, void *env)
{
FILE *F = (FILE*)env;
dump_node_wo_blockedge(n, env);
dump_node_wo_blockedge(F, n);
if (!node_floats(n))
dump_ir_block_edge(F, n);
}
......@@ -1342,8 +1334,9 @@ static void dump_node_with_edges(ir_node *n, void *env)
/** Dumps a const-like node. */
static void dump_const_node(ir_node *n, void *env)
{
FILE *F = (FILE*)env;
if (is_Block(n)) return;
dump_node_wo_blockedge(n, env);
dump_node_wo_blockedge(F, n);
}
/***********************************************************************/
......@@ -1373,7 +1366,7 @@ static void dump_const_expression(FILE *F, ir_node *value)
* Expects to find nodes belonging to the block as list in its
* link field.
* Dumps the edges of all nodes including itself. */
static void dump_whole_block(FILE *F, ir_node *block)
static void dump_whole_block(FILE *F, const ir_node *block)
{
ir_node *node;
ird_color_t color = ird_color_block_background;
......@@ -1977,18 +1970,25 @@ static void dump_loop_nodes_into_graph(FILE *F, ir_graph *irg)
}
}
void dump_vcg_header_colors(FILE *F)
{
int i;
init_colors();
for (i = 0; i < ird_color_count; ++i) {
if (color_rgb[i] != NULL) {
fprintf(F, "colorentry %s: %s\n", color_names[i], color_rgb[i]);
}
}
}
/**
* dumps the VCG header
*/
void dump_vcg_header(FILE *F, const char *name, const char *layout, const char *orientation)
{
int i;
const char *label
= (flags & ir_dump_flag_disable_edge_labels) ? "no" : "yes";
init_colors();
if (! layout) layout = "Compilergraph";
if (!orientation) orientation = "bottom_to_top";
......@@ -2027,12 +2027,7 @@ void dump_vcg_header(FILE *F, const char *name, const char *layout, const char *
"infoname 2: \"Verification errors\"\n"
"infoname 3: \"Debug info\"\n",
name, label, layout, orientation);
for (i = 0; i < ird_color_count; ++i) {
if (color_rgb[i] != NULL) {
fprintf(F, "colorentry %s: %s\n", color_names[i], color_rgb[i]);
}
}
dump_vcg_header_colors(F);
fprintf(F, "\n");
}
......
......@@ -140,8 +140,6 @@ typedef enum {
#define PRINT_ITEMID(X,Y) ir_fprintf(F, "i%ldT%zu", get_type_nr(X), (Y))
#define PRINT_EXTBBID(X) ir_fprintf(F, "x%ld", get_irn_node_nr(X))
void dump_vcg_header(FILE *out, const char *name, const char *layout, const char *orientation);
void dump_vcg_footer(FILE *out);
const char *get_irg_dump_name(const ir_graph *irg);
const char *get_ent_dump_name(const ir_entity *ent);
......@@ -152,11 +150,20 @@ const char *get_ent_dump_name(const ir_entity *ent);
*/
const char *get_mode_name_ex(const ir_mode *mode, int *bad);
/** dump the name of a node n to the File F. */
void dump_node_opcode(FILE *out, ir_node *n);
void dump_node_opcode(FILE *out, const ir_node *n);
void dump_node_label(FILE *out, ir_node *n);
void dump_node_label(FILE *out, const ir_node *n);
/** Writes vcg representation with title "PRINT_TYPEID(tp)" to file F. */
void dump_type_node(FILE *out, ir_type *tp);
void dump_vcg_header(FILE *out, const char *name, const char *layout, const char *orientation);
void dump_vcg_footer(FILE *out);
void dump_vcg_header_colors(FILE *out);
void dump_node(FILE *out, const ir_node *node);
/** Write the irnode and all its attributes to the file passed.
* (plain text format) */
void dump_irnode_to_file(FILE *out, const ir_node *node);
#endif
......@@ -57,7 +57,7 @@ ir_dump_verbosity_t ir_get_dump_verbosity(void)
}
/* Write the irnode and all its attributes to the file passed. */
void dump_irnode_to_file(FILE *F, ir_node *n)
void dump_irnode_to_file(FILE *F, const ir_node *n)
{
char comma;
ir_graph *irg;
......
......@@ -454,9 +454,9 @@ static void dump_split_list(const partition_t *list)
/**
* Dump partition and type for a node.
*/
static int dump_partition_hook(FILE *F, ir_node *n, ir_node *local)
static int dump_partition_hook(FILE *F, const ir_node *n, const ir_node *local)
{
ir_node *irn = local != NULL ? local : n;
const ir_node *irn = local != NULL ? local : n;
node_t *node = get_irn_node(irn);
ir_fprintf(F, "info2 : \"partition %u type %+F\"\n", node->part->nr, node->type);
......
......@@ -70,7 +70,7 @@ struct dag_entry_t {
/**
* return an DAG entry for the node n
*/
static dag_entry_t *get_irn_dag_entry(ir_node *n)
static dag_entry_t *get_irn_dag_entry(const ir_node *n)
{
dag_entry_t *p = (dag_entry_t*)get_irn_link(n);
......@@ -80,7 +80,8 @@ static dag_entry_t *get_irn_dag_entry(ir_node *n)
do {
p = p->link;
} while (p->link != NULL);
set_irn_link(n, p);
/* hacky cast to ir_node* */
set_irn_link((ir_node*)n, p);
}
} /* if */
return p;
......@@ -315,7 +316,7 @@ static unsigned mark_options;
/**
* a vcg attribute hook
*/
static int stat_dag_mark_hook(FILE *F, ir_node *n, ir_node *l)
static int stat_dag_mark_hook(FILE *F, const ir_node *n, const ir_node *l)
{
static const char *colors[] = { "purple", "pink", "lightblue", "orange", "khaki", "orchid", "lilac", "turquoise" };
dag_entry_t *entry;
......
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