-/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
-* All rights reserved.
-*
-* Authors: Martin Trapp, Christian Schaefer
-*
-* irdump.h: dumping of an intermediate representation graph
-*/
+/*
+ * Project: libFIRM
+ * File name: ir/ir/irdump.c
+ * Purpose: Write vcg representation of firm to file.
+ * Author: Martin Trapp, Christian Schaefer
+ * Modified by: Goetz Lindenmaier, Hubert Schmidt
+ * Created:
+ * CVS-ID: $Id$
+ * Copyright: (c) 1998-2003 Universität Karlsruhe
+ * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ */
-/* $Id$ */
#ifdef HAVE_CONFIG_H
# include <config.h>
int dump_dominator_information_flag = 0;
int dump_loop_information_flag = 0;
int dump_const_local = 0;
+bool opt_dump_analysed_type_info = 1;
INLINE bool get_opt_dump_const_local(void) {
if (!dump_out_edge_flag && !dump_loop_information_flag)
} else if (get_irn_opcode(n) == iro_SymConst) {
if (get_SymConst_kind(n) == linkage_ptr_info) {
/* don't use get_SymConst_ptr_info as it mangles the name. */
- fprintf (F, "SymC %s", id_to_str(get_SymConst_ptrinfo(n)));
+ fprintf (F, "SymC %s", get_id_str(get_SymConst_ptrinfo(n)));
} else {
assert(get_kind(get_SymConst_type(n)) == k_type);
assert(get_type_ident(get_SymConst_type(n)));
- fprintf (F, "SymC %s ", id_to_str(get_type_ident(get_SymConst_type(n))));
+ fprintf (F, "SymC %s ", get_type_name(get_SymConst_type(n)));
if (get_SymConst_kind(n) == type_tag)
fprintf (F, "tag");
else
/* all others */
} else {
- fprintf (F, "%s", id_to_str(get_irn_opident(n)));
+ fprintf (F, "%s", get_id_str(get_irn_opident(n)));
}
}
case iro_Shr:
case iro_Abs:
case iro_Cmp:
- fprintf (F, "%s", id_to_str(get_mode_ident(get_irn_mode(n))));
+ fprintf (F, "%s", get_mode_name(get_irn_mode(n)));
break;
default:
;
}
}
+static void dump_node_typeinfo(ir_node *n) {
+ if (!opt_dump_analysed_type_info) return;
+ if (get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_consistent ||
+ get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_inconsistent ) {
+ type *tp = get_irn_type(n);
+ if (tp != none_type)
+ fprintf (F, " [%s]", get_type_name(tp));
+ else
+ fprintf (F, " []");
+ }
+}
+
static INLINE void
dump_node_nodeattr (ir_node *n)
{
switch (get_irn_opcode(n)) {
case iro_Start:
if (false && interprocedural_view) {
- fprintf (F, "%s", id_to_str(get_entity_ident(get_irg_ent(current_ir_graph))));
+ fprintf (F, "%s", get_entity_name(get_irg_ent(current_ir_graph)));
}
break;
case iro_Proj:
break;
case iro_Sel: {
assert(get_kind(get_Sel_entity(n)) == k_entity);
- fprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
+ fprintf (F, "%s", get_entity_name(get_Sel_entity(n)));
+ } break;
+ case iro_Cast: {
+ fprintf (F, "(%s)", get_type_name(get_Cast_type(n)));
} break;
default:
;
static INLINE void
dump_node_info (ir_node *n) {
- fprintf (F, " info1: \"visited: %ld\n\"", get_irn_visited(n));
+ int i;
+ fprintf (F, " info1: \"");
+ fprintf (F, "visited: %ld \n", get_irn_visited(n));
+
+ /* Source types */
+ switch(get_irn_opcode(n)) {
+ case iro_Start: {
+ type *tp = get_entity_type(get_irg_ent(get_Start_irg(n)));
+ fprintf(F, "start of method of type %s \n", get_type_name(tp));
+ for (i = 0; i < get_method_n_params(tp); ++i)
+ fprintf(F, " param %d type: %s \n", i, get_type_name(get_method_param_type(tp, i)));
+ } break;
+ case iro_Alloc: {
+ fprintf(F, "allocating entity of type %s \n", get_type_name(get_Alloc_type(n)));
+ } break;
+ case iro_Free: {
+ fprintf(F, "freeing entity of type %s \n", get_type_name(get_Free_type(n)));
+ } break;
+ case iro_Sel: {
+ fprintf(F, "Selecting entity of type %s \n", get_type_name(get_entity_type(get_Sel_entity(n))));
+ fprintf(F, " from entity of type %s \n", get_type_name(get_entity_owner(get_Sel_entity(n))));
+ } break;
+ case iro_Call: {
+ type *tp = get_Call_type(n);
+ fprintf(F, "calling method of type %s \n", get_type_name(tp));
+ for (i = 0; i < get_method_n_params(tp); ++i)
+ fprintf(F, " param %d type: %s \n", i, get_type_name(get_method_param_type(tp, i)));
+ for (i = 0; i < get_method_n_ress(tp); ++i)
+ fprintf(F, " resul %d type: %s \n", i, get_type_name(get_method_res_type(tp, i)));
+ } break;
+ case iro_Return: {
+ if (!interprocedural_view) {
+ type *tp = get_entity_type(get_irg_ent(current_ir_graph));
+ fprintf(F, "return in method of type %s \n", get_type_name(tp));
+ for (i = 0; i < get_method_n_ress(tp); ++i)
+ fprintf(F, " res %d type: %s \n", i, get_type_name(get_method_res_type(tp, i)));
+ }
+ } break;
+ case iro_Const: {
+ type *tp = get_Const_type(n);
+ assert(tp != none_type);
+ fprintf(F, "Const of type %s \n", get_type_name(get_Const_type(n)));
+ } break;
+ default: ;
+ }
+
+ if (get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_consistent ||
+ get_irg_typeinfo_state(current_ir_graph) == irg_typeinfo_inconsistent )
+ if (get_irn_type(n) != none_type)
+ fprintf (F, "\nAnalysed type: %s", get_type_name(get_irn_type(n)));
+
+ fprintf (F, "\"");
+
}
static bool pred_in_wrong_graph(ir_node *n, int pos, pmap *irgmap) {
fprintf(F, " label: \"");
dump_node_opcode(con);
dump_node_mode (con);
+ dump_node_typeinfo(con);
fprintf (F, " ");
dump_node_nodeattr(con);
#ifdef DEBUG_libfirm
dump_node_opcode(n);
dump_node_mode (n);
+ dump_node_typeinfo(n);
fprintf (F, " ");
dump_node_nodeattr(n);
#ifdef DEBUG_libfirm
if ((interprocedural_view && get_irn_visited(pred) < visited))
continue; /* pred not dumped */
if (is_backedge(n, i))
- fprintf (F, "backedge: {sourcename: ");
+ fprintf (F, "backedge: {sourcename: \"");
else
fprintf (F, "edge: {sourcename: \"");
PRINT_NODEID(n);
case iro_SymConst:
if ( (get_SymConst_kind(n) == type_tag)
|| (get_SymConst_kind(n) == size))
- {
- PRINT_NODE_TYPE_EDGE(n,get_SymConst_type(n),NODE2TYPE_EDGE_ATTR);
- }
+ {
+ PRINT_NODE_TYPE_EDGE(n,get_SymConst_type(n),NODE2TYPE_EDGE_ATTR);
+ }
break;
case iro_Sel: {
- PRINT_NODE_ENT_EDGE(n,get_Sel_entity(n),NODE2TYPE_EDGE_ATTR);
+ PRINT_NODE_ENT_EDGE(n,get_Sel_entity(n),NODE2TYPE_EDGE_ATTR);
} break;
case iro_Call: {
- PRINT_NODE_TYPE_EDGE(n,get_Call_type(n),NODE2TYPE_EDGE_ATTR);
+ PRINT_NODE_TYPE_EDGE(n,get_Call_type(n),NODE2TYPE_EDGE_ATTR);
} break;
case iro_Alloc: {
- PRINT_NODE_TYPE_EDGE(n,get_Alloc_type(n),NODE2TYPE_EDGE_ATTR);
+ PRINT_NODE_TYPE_EDGE(n,get_Alloc_type(n),NODE2TYPE_EDGE_ATTR);
} break;
case iro_Free: {
- PRINT_NODE_TYPE_EDGE(n,get_Free_type(n),NODE2TYPE_EDGE_ATTR);
+ PRINT_NODE_TYPE_EDGE(n,get_Free_type(n),NODE2TYPE_EDGE_ATTR);
+ } break;
+ case iro_Cast: {
+ PRINT_NODE_TYPE_EDGE(n,get_Cast_type(n),NODE2TYPE_EDGE_ATTR);
} break;
default:
break;
}
-/* @@@@ Does not work as someone kills the visited flag. */
static void dump_const_expression(ir_node *value) {
ir_graph *rem = current_ir_graph;
int rem_dump_const_local = dump_const_local;
fprintf(F, "state: layout_fixed,\n");
}
if (get_type_mode(tp))
- fprintf(F, "mode: %s,\n", id_to_str(get_mode_ident(get_type_mode(tp))));
+ fprintf(F, "mode: %s,\n", get_mode_name(get_type_mode(tp)));
fprintf(F, "size: %dB,\n", get_type_size(tp));
}
switch (get_type_tpop_code(tp)) {
case tpo_class:
{
- if(existent == get_class_peculiarity(tp))
+ if (peculiarity_existent == get_class_peculiarity(tp))
fprintf (F, " " TYPE_CLASS_NODE_ATTR);
else
fprintf (F, " " TYPE_DESCRIPTION_NODE_ATTR);
} /* switch type */
}
-static void print_type_node(type *tp) {
+static void print_type_node(type *tp)
+{
fprintf (F, "node: {title: ");
PRINT_TYPEID(tp);
- fprintf (F, " label: \"%s %s\"", id_to_str(get_type_tpop_nameid(tp)), id_to_str(get_type_ident(tp)));
+ fprintf (F, " label: \"%s %s\"", get_type_tpop_name(tp), get_type_name(tp));
fprintf (F, " info1: \"");
print_type_info(tp);
fprintf (F, "\"");
fprintf (F, "}\n");
}
-void dump_entity_node(entity *ent) {
+#define X(a) case a: fprintf(F, #a); break
+void dump_entity_node(entity *ent)
+{
fprintf (F, "node: {title: \"");
PRINT_ENTID(ent); fprintf(F, "\"");
fprintf (F, DEFAULT_TYPE_ATTRIBUTE);
fprintf (F, "label: ");
- fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , id_to_str(get_entity_ident(ent)));
+ fprintf (F, "\"ent %s\" " ENTITY_NODE_ATTR , get_entity_name(ent));
fprintf (F, "\n info1: \"\nid: "); PRINT_ENTID(ent);
+
fprintf (F, "\nallocation: ");
switch (get_entity_allocation(ent)) {
- case dynamic_allocated: fprintf (F, "dynamic allocated"); break;
- case automatic_allocated: fprintf (F, "automatic allocated"); break;
- case static_allocated: fprintf (F, "static allocated"); break;
- case parameter_allocated: fprintf (F, "parameter allocated"); break;
+ X(allocation_dynamic);
+ X(allocation_automatic);
+ X(allocation_static);
+ X(allocation_parameter);
}
+
fprintf (F, "\nvisibility: ");
switch (get_entity_visibility(ent)) {
- case local: fprintf (F, "local"); break;
- case external_visible: fprintf (F, "external visible"); break;
- case external_allocated: fprintf (F, "external allocated"); break;
+ X(visibility_local);
+ X(visibility_external_visible);
+ X(visibility_external_allocated);
}
+
fprintf (F, "\nvariability: ");
switch (get_entity_variability(ent)) {
- case uninitialized: fprintf (F, "uninitialized");break;
- case initialized: fprintf (F, "initialized"); break;
- case part_constant: fprintf (F, "part_constant");break;
- case constant: fprintf (F, "constant"); break;
+ X(variability_uninitialized);
+ X(variability_initialized);
+ X(variability_part_constant);
+ X(variability_constant);
}
+
fprintf (F, "\nvolatility: ");
switch (get_entity_volatility(ent)) {
- case non_volatile: fprintf (F, "non_volatile"); break;
- case is_volatile: fprintf (F, "is_volatile"); break;
+ X(volatility_non_volatile);
+ X(volatility_is_volatile);
}
+
fprintf (F, "\npeculiarity: ");
switch (get_entity_peculiarity(ent)) {
- case description: fprintf (F, "description"); break;
- case inherited: fprintf (F, "inherited"); break;
- case existent: fprintf (F, "existent"); break;
+ X(peculiarity_description);
+ X(peculiarity_inherited);
+ X(peculiarity_existent);
}
fprintf(F, "\nname: %s\nld_name: %s",
- id_to_str(get_entity_ident(ent)),
- id_to_str(get_entity_ld_ident(ent)));
+ get_entity_name(ent), get_entity_ld_name(ent));
fprintf(F, "\noffset: %d", get_entity_offset(ent));
if (is_method_type(get_entity_type(ent))) {
if (get_entity_irg(ent)) /* can be null */
}
fprintf(F, "\"\n}\n");
}
+#undef X
/* dumps a type or entity and it's edges. */
static void
}
}
/* attached subgraphs */
- if (const_entities && (get_entity_variability(ent) != uninitialized)) {
+ if (const_entities && (get_entity_variability(ent) != variability_uninitialized)) {
if (is_atomic_entity(ent)) {
value = get_atomic_ent_value(ent);
if (value) {
{
PRINT_TYPE_TYPE_EDGE(tp,get_array_element_type(tp),ARR_ELT_TYPE_EDGE_ATTR);
PRINT_TYPE_ENT_EDGE(tp,get_array_element_entity(tp),ARR_ENT_EDGE_ATTR);
+ for (i = 0; i < get_array_n_dimensions(tp); i++) {
+ ir_node *upper = get_array_upper_bound(tp, i);
+ ir_node *lower = get_array_lower_bound(tp, i);
+ PRINT_NODE_TYPE_EDGE(upper, tp, "label: \"upper %d\"", get_array_order(tp, i));
+ PRINT_NODE_TYPE_EDGE(lower, tp, "label: \"lower %d\"", get_array_order(tp, i));
+ dump_const_expression(upper);
+ dump_const_expression(lower);
+ }
+
} break;
case tpo_enumeration:
{
ent = get_irg_ent(irg);
id = ent->ld_name ? ent->ld_name : ent->name;
/* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
- len = id_to_strlen (id);
- cp = id_to_str (id);
+ len = get_id_strlen (id);
+ cp = get_id_str (id);
if (dump_file_suffix)
fname = malloc (len + 5 + strlen(suffix) + strlen(dump_file_suffix));
else
ir_node ** arr;
arr = entry->value;
assert(arr);
- ARR_APP1(ir_node *, arr , node);
+ ARR_APP1(ir_node *, arr, node);
+ entry->value = (void *)arr;
} else {
ir_node ** arr = NEW_ARR_F(ir_node *, 1);
assert(arr);
int i;
fprintf(F, "graph: { title: %p label: %s status:clustered color:white \n",
- (void*) irg, id_to_str(get_entity_ident(get_irg_ent(irg))));
+ (void*) irg, get_entity_name(get_irg_ent(irg)));
for (i = ARR_LEN(arr) - 1; i >= 0; --i) {
ir_node * node = arr[i];
ident * irg_ident = get_entity_ident(get_irg_ent(entry->key));
fprintf(F, "graph: { title: %s label: %s status:clustered color:white \n",
- id_to_str(irg_ident), id_to_str(irg_ident));
+ get_id_str(irg_ident), get_id_str(irg_ident));
for (i = ARR_LEN(arr) - 1; i >= 0; --i) {
ir_node * node = arr[i];
vcg_close();
}
+
+/* Dump the information of type field specified in ana/irtypeinfo.h.
+ * If the flag is set, the type name is output in [] in the node label,
+ * else it is output as info.
+ */
+void dump_analysed_type_info(bool b) {
+ opt_dump_analysed_type_info = b;
+}