Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
95016d86
Commit
95016d86
authored
Sep 06, 2000
by
Götz Lindenmaier
Browse files
*** empty log message ***
[r65]
parent
fe9e69fb
Changes
13
Hide whitespace changes
Inline
Side-by-side
Changes
View file @
95016d86
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.
...
...
ir/ir/irdump.c
View file @
95016d86
...
...
@@ -497,15 +497,13 @@ void vcg_open (ir_graph *irg, char *suffix) {
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 */
...
...
@@ -525,6 +523,34 @@ void vcg_open (ir_graph *irg, char *suffix) {
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 */
...
...
@@ -651,7 +677,8 @@ dump_cfg (ir_graph *irg)
/***********************************************************************/
/* the following routine dumps all type information */
/* the following routine dumps all type information reachable from an */
/* irg */
/***********************************************************************/
...
...
@@ -665,12 +692,24 @@ dump_type_graph (ir_graph *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 */
...
...
@@ -690,7 +729,7 @@ dump_ir_graph_w_types (ir_graph *irg)
/* 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
);
...
...
ir/ir/irdump.h
View file @
95016d86
...
...
@@ -31,6 +31,9 @@ void dump_cfg (ir_graph *irg);
/* 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
);
...
...
ir/ir/irgraph.c
View file @
95016d86
...
...
@@ -221,6 +221,7 @@ set_irg_current_block (ir_graph *irg, ir_node *node)
entity
*
get_irg_ent
(
ir_graph
*
irg
)
{
assert
(
irg
&&
irg
->
ent
);
return
irg
->
ent
;
}
...
...
ir/ir/irprog.c
View file @
95016d86
...
...
@@ -72,6 +72,13 @@ ir_graph *get_irp_irg(int pos){
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
);
...
...
@@ -79,6 +86,27 @@ void add_irp_type(type *typ) {
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/ir/irprog.h
View file @
95016d86
...
...
@@ -26,10 +26,10 @@ struct ir_prog {
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
...
...
@@ -58,10 +58,13 @@ void set_irp_main_irg(ir_graph *main_irg);
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
);
...
...
ir/tr/entity.h
View file @
95016d86
...
...
@@ -55,15 +55,6 @@ typedef struct ir_graph ir_graph;
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
);
...
...
ir/tr/type.c
View file @
95016d86
...
...
@@ -11,6 +11,7 @@
# 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
;
...
...
@@ -36,9 +37,6 @@ new_type_class (ident *name)//, int members)
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
;
...
...
@@ -138,23 +136,20 @@ new_type_strct (ident *name)//, int members)
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
)
{
...
...
@@ -193,13 +188,11 @@ new_type_method (ident *name, int arity, int n_res)
}
/* 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
)
{
...
...
ir/tr/type.h
View file @
95016d86
...
...
@@ -248,13 +248,19 @@ type_class *get_class_supertype (type_class *class, int pos);
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.
*/
/*******************************************************************/
...
...
@@ -264,10 +270,7 @@ void set_class_supertype (type_class *class, type_class *supertype, int pos);
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
;
...
...
@@ -276,7 +279,7 @@ typedef struct {
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);
...
...
@@ -303,11 +306,12 @@ typedef struct {
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);
...
...
@@ -340,7 +344,7 @@ typedef struct {
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);
...
...
@@ -372,7 +376,7 @@ typedef struct {
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);
...
...
@@ -414,7 +418,7 @@ typedef struct {
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);
...
...
@@ -447,7 +451,7 @@ typedef struct {
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);
...
...
@@ -474,7 +478,7 @@ typedef struct {
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);
...
...
ir/tr/typewalk.c
View file @
95016d86
...
...
@@ -9,11 +9,12 @@
** - 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 */
...
...
@@ -27,8 +28,9 @@ typedef struct type_walk_env {
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
;
...
...
@@ -92,6 +94,7 @@ void type_walk_2(type_or_ent *tore,
break
;
case
k_type_union
:
((
type_union
*
)
tore
)
->
visit
=
type_visited
;
/* !!!!! */
break
;
case
k_type_array
:
((
type_array
*
)
tore
)
->
visit
=
type_visited
;
...
...
@@ -155,9 +158,21 @@ void start_type_walk(ir_node *node, void *env) {
}
}
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 */
...
...
ir/tr/typewalk.h
View file @
95016d86
...
...
@@ -13,12 +13,22 @@
/* 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_ */
testprograms/Makefile
View file @
95016d86
...
...
@@ -2,7 +2,7 @@ DIRS = adt common debug ident ir tr tv
INCDIRS
=
-I
../include
LIBDIRS
=
-L
..
-L
/usr/public/lib/gmp/
LIBS
=
-lfirm
-lgmp
-lm
LIBS
=
-lfirm
-lgmp
%.o
:
%.c
gcc
-c
$(INCDIRS)
-g
$<
...
...
testprograms/empty.c
View file @
95016d86
...
...
@@ -92,6 +92,8 @@ int main(int argc, char **argv)
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
"
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment