+ 6.9.00 Goetz
+ Added irdump routine dump_all_types.
+ Did changes to irprog, type, typewalk to achieve this.
+ typewalk needs to walk along members, sub and supertypes, this
+ is still missing! irdump then needs to output these edges.
+
+======================================================================
+==================== New version: 0.2.5 ==============================
+======================================================================
+
+ 3.9.00 Goetz
+ Made new Version: 0.2.5
+
15.8.2000 Goetz until 3.9.00
Separated irnode.h and many others into two files: one public
one private.
int len;
/** open file for vcg graph */
- id = get_entity_ld_name (irg->ent);
-
+ id = get_entity_ld_name (get_irg_ent(irg));
len = id_to_strlen (id);
cp = id_to_str (id);
fname = malloc (len + 5 + strlen(suffix));
strcpy (fname, cp); /* copy the filename */
strcat (fname, suffix); /* append file suffix */
strcat (fname, ".vcg"); /* append the .vcg suffix */
-
F = fopen (fname, "w"); /* open file for writing */
if (!F) {
panic ("cannot open %s for writing (%m)", fname); /* not reached */
xfprintf (F, "\n"); /* a separator */
}
+void vcg_open_name (const char *name) {
+ char *fname; /* filename to put the vcg information in */
+ int len;
+
+ /** open file for vcg graph */
+ len = strlen(name);
+ fname = malloc (len + 5);
+ strcpy (fname, name); /* copy the filename */
+ strcat (fname, ".vcg"); /* append the .vcg suffix */
+ F = fopen (fname, "w"); /* open file for writing */
+ if (!F) {
+ panic ("cannot open %s for writing (%m)", fname); /* not reached */
+ }
+
+ /* print header */
+ xfprintf (F,
+ "graph: { title: \"ir graph of %s\"\n"
+ "display_edge_labels: yes\n"
+ "layoutalgorithm: mindepth\n"
+ "manhattan_edges: yes\n"
+ "port_sharing: no\n"
+ "orientation: bottom_to_top\n"
+ "classname 1: \"Data\"\n"
+ "classname 2: \"Block\"\n", name);
+
+ xfprintf (F, "\n"); /* a separator */
+}
+
void
vcg_close () {
xfprintf (F, "}\n"); /* print footer */
/***********************************************************************/
-/* the following routine dumps all type information */
+/* the following routine dumps all type information reachable from an */
+/* irg */
/***********************************************************************/
vcg_open (irg, "-type");
/* walk over the blocks in the graph */
- type_walk(irg, dump_type_info, NULL, NULL);
+ type_walk_irg(irg, dump_type_info, NULL, NULL);
vcg_close();
current_ir_graph = rem;
}
+/***********************************************************************/
+/* the following routine dumps all type information */
+/***********************************************************************/
+
+
+void
+dump_all_types (void)
+{
+ vcg_open_name ("All_types");
+ type_walk(dump_type_info, NULL, NULL);
+ vcg_close();
+}
/***********************************************************************/
/* dumps a graph with type information */
/* irg_block_walk(irg->end, dump_ir_block, NULL, irg); */
irg_walk(irg->end, dump_whole_node, NULL, NULL);
/* dump type info */
- type_walk(irg, dump_type_info, NULL, NULL);
+ type_walk_irg(irg, dump_type_info, NULL, NULL);
/* dump edges from graph to type info */
irg_walk(irg->end, dump_node2type_edges, NULL, NULL);
/* dumps the type information reachable from an ir graph. */
void dump_type_graph (ir_graph *irg);
+/* dumps all type information (reachable from ir prog). */
+void dump_all_types (void);
+
/* dumps a graph and the type inforamtion. */
void dump_ir_graph_w_types (ir_graph *irg);
entity *
get_irg_ent (ir_graph *irg)
{
+ assert(irg && irg->ent);
return irg->ent;
}
return irp->graphs[pos+1];
}
+void set_irp_irg(int pos, ir_graph *irg) {
+ assert (irp && irg);
+ assert (pos < (ARR_LEN((irp)->graphs) - 1));
+ /* Strangely the first element of the array is NULL. Why?? */
+ irp->graphs[pos+1] = irg;
+}
+
/* Adds type to the list of types in irp. */
void add_irp_type(type *typ) {
assert (typ != NULL);
ARR_APP1 (type *, irp->types, typ);
}
+int get_irp_n_types (void) {
+ assert (irp && irp->types);
+ /* Strangely the first element of the array is NULL. Why?? */
+ return (ARR_LEN((irp)->types) - 1);
+}
+
+type *get_irp_type(int pos) {
+ assert (irp && irp->types);
+ /* Strangely the first element of the array is NULL. Why?? */
+ return irp->types[pos+1];
+
+}
+
+void set_irp_type(int pos, type *typ) {
+ assert (irp && typ);
+ assert (pos < (ARR_LEN((irp)->types) - 1));
+ /* Strangely the first element of the array is NULL. Why?? */
+ irp->types[pos+1] = typ;
+
+}
+
int get_irp_new_node_nr() {
assert(irp);
irp->max_node_nr = irp->max_node_nr + 1;
ir_graph *main_irg; /* entry point to the compiled program */
/* or a list, in case we compile a library or the like? */
ir_graph **graphs; /* all graphs in the ir */
- type **types; /* all types in the ir */
type_class *glob_type; /* global type. Class as it can have
fields and procedures. Does this work?
Better name??? @@@ */
+ type **types; /* all types in the ir */
/*struct obstack *obst; * @@@ Should we place all types and
entities on an obstack, too? */
#ifdef DEBUG_libfirm
void add_irp_irg(ir_graph *irg);
int get_irp_n_irgs();
ir_graph *get_irp_irg(int pos);
- /* set_irp_irg() und das gleiche fuer type */
+void set_irp_irg(int pos, ir_graph *irg);
/* Adds type to the list of types in irp. */
-void add_irp_type(type *typ);
+void add_irp_type(type *typ);
+int get_irp_n_types();
+type *get_irp_type(int pos);
+void set_irp_type(int pos, type *typ);
/** Functions to access the fields of ir_prog **/
type_class *get_glob_type(void);
typedef struct entity entity;
#endif
-/*CS*/
-//#ifndef _TYPE_TYPEDEF_
-//#define _TYPE_TYPEDEF_
-/* to resolve recursion between entity.h and irgraph.h */
-//typedef union type type;
-//#endif
-
-//typedef struct entity entity;
-
/* create a new entity */
entity *new_entity (type *owner, ident *name, type *type);
# include "irprog.h" /* So that constructors can add the type to global
data structure. */
# include "array.h"
+# include "ident_t.h"
unsigned long type_visited = 0;
res->members = NEW_ARR_F (entity *, 1);
res->subtypes = NEW_ARR_F (type_class *, 1);
res->supertypes = NEW_ARR_F (type_class *, 1);
- // res->n_members = 0;
- // res->max_members = members;
- // res->member = (entity **) xmalloc (sizeof (entity*) * members);
res->visit = 0;
res->kind = k_type_strct;
res->name = name;
- // res->n_members = 0;
- // res->max_members = members;
- // res->member = (entity **) xmalloc (sizeof (entity*) * members);
-
+ res->members = NEW_ARR_F (entity *, 1);
res->visit = 0;
return res;
}
/* manipulate fields of type_strct */
-/*
-char *
+
+const char *
get_strct_name (type_strct *strct) {
assert(strct);
return ID_TO_STR(strct->name);
}
-*/
+
ident *
get_strct_ident (type_strct *strct) {
}
/* manipulate fields of type_method */
-/*
-char *
+const char *
get_method_name (type_method *method) {
assert(method);
return ID_TO_STR(method->name);
}
-*/
ident *
get_method_ident (type_method *method) {
void set_class_supertype (type_class *class, type_class *supertype, int pos);
-/* get_class_entity_arr
+/*
get_class_n_entities
get_class_entity(class, pos)
set_class_entity(class, pos, entity)
- get_class_sub_arr
+ get_class_n_sub
...
- get_class_super_arr
+
+
+ Bitte implementieren, und dann in walker (Suche nach !!!! )
+ einfuegen.
+ Genauso Struct!!
+
+ Dann ev. noch in irdump Ausgabe der Kanten eingeben.
*/
/*******************************************************************/
typedef struct {
firm_kind kind;
ident *name;
- /** needs list with it's entities -- does it really??
- Entities can be added during their creation.
- int n_members;
- entity **member; **/
+ entity **members;
unsigned long visit; /* visited counter for walks of the type information */
} type_strct;
type_strct *new_type_strct (ident *name);
/* manipulate fields of type_strct */
-char *get_strct_name (type_strct *strct);
+const char *get_strct_name (type_strct *strct);
ident *get_strct_ident (type_strct *strct);
/*
void set_strct_name (type_strct *strct, char *name);
unsigned long visit; /* visited counter for walks of the type information */
} type_method;
-/* create a new type_method */
+/* create a new type_method
+ arity is number of parameters. */
type_method *new_type_method (ident *name, int arity, int n_res);
/* manipulate fields of type_method */
-char *get_method_name (type_method *method);
+const char *get_method_name (type_method *method);
ident *get_method_ident (type_method *method);
/*
void set_method_name (type_method *method, char *name);
type_union *new_type_union (ident *name, int n_types);
/* manipulate fields of type_union */
-char *get_union_name (type_union *uni);
+const char *get_union_name (type_union *uni);
ident *get_union_ident (type_union *uni);
/*
void set_union_name (type_union *union, char *name);
type_array *new_type_array (ident *name, int n_dimensions);
/* manipulate fields of type_array */
-char *get_array_name (type_array *array);
+const char *get_array_name (type_array *array);
ident *get_array_ident (type_array *array);
/*
void set_array_name (type_array *array, char *name);
type_enumeration *new_type_enumeration (ident *name /* , int n_enums */);
/* manipulate fields of type_enumeration */
-char *get_enumeration_name (type_enumeration *enumeration);
+const char *get_enumeration_name (type_enumeration *enumeration);
ident *get_enumeration_ident (type_enumeration *enumeration);
/*
void set_enumeration_name (type_enumeration *enumeration, char *name);
type_pointer *new_type_pointer (ident *name, type *points_to);
/* manipulate fields of type_pointer */
-char *get_pointer_name (type_pointer *pointer);
+const char *get_pointer_name (type_pointer *pointer);
ident *get_pointer_ident (type_pointer *pointer);
/*
void set_pointer_name (type_pointer *pointer, char *name);
type_primitive *new_type_primitive (ident *name, ir_mode *mode);
/* manipulate fields of type_primitive */
-char *get_primitive_name (type_primitive *primitive);
+const char *get_primitive_name (type_primitive *primitive);
ident *get_primitive_ident (type_primitive *primitive);
/*
void set_primitive_name (type_primitive *primitive, char *name);
** - execute the post function after recursion
*/
-#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include "irgwalk.h"
#include "irgraph.h"
#include "irnode.h"
+#include "irprog.h"
#include "type_or_entity.h"
/* Make types visible to allow most efficient access */
void type_walk_2(type_or_ent *tore,
- void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
- void *env)
+ void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env)
{
int i, visited = 0;
break;
case k_type_union:
((type_union *)tore)->visit = type_visited;
+ /* !!!!! */
break;
case k_type_array:
((type_array *)tore)->visit = type_visited;
}
}
-void type_walk(ir_graph *irg,
- void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
- void *env)
+void type_walk(void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env) {
+ int i;
+ ++type_visited;
+ type_walk_2((type_or_ent *)get_glob_type(), pre, post, env);
+ for (i = 0; i < get_irp_n_types(); i++) {
+ type_walk_2((type_or_ent *)get_irp_type(i), pre, post, env);
+ }
+}
+
+void type_walk_irg (ir_graph *irg,
+ void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env)
{
/* this is needed to pass the parameters to the walker that actually
walks the type information */
/* walk over all type information reachable from the ir graph. */
-
+#ifndef _TYPEWALK_H_
+#define _TYPEWALK_H_
# include "type_or_entity.h"
+/** dumps all type information reachable from global roots **/
+void type_walk(void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env);
+
/** dumps all type information reachable from irg **/
-void type_walk(ir_graph *irg,
- void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
- void *env);
+void type_walk_irg(ir_graph *irg,
+ void (pre)(type_or_ent*, void*),
+ void (post)(type_or_ent*, void*),
+ void *env);
+
+
+#endif /* _TYPEWALK_H_ */
INCDIRS = -I../include
LIBDIRS=-L.. -L/usr/public/lib/gmp/
-LIBS=-lfirm -lgmp -lm
+LIBS=-lfirm -lgmp
%.o: %.c
gcc -c $(INCDIRS) -g $<
printf("Done building the graph. Dumping it.\n");
dump_ir_block_graph (irg);
+ dump_all_types();
+
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");