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
e7eac363
Commit
e7eac363
authored
Jun 12, 2004
by
Florian Liekweg
Browse files
RTA works, outedges breaks. "Yay." --flo
[r3062]
parent
dd172768
Changes
2
Hide whitespace changes
Inline
Side-by-side
ir/ana/rta.c
View file @
e7eac363
...
...
@@ -18,94 +18,39 @@
* bestimmt.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include
"rta.h"
#
define TRUE 1
#
define FALSE 0
#
include
<stdlib.h>
#
include
"cgana.h"
/* get_implementation */
/* # define RTA_SET */
# ifdef RTA_SET
typedef
struct
rta_set_elt
{
struct
rta_set_elt
*
_next
;
void
*
_obj
;
}
rta_set_elt_t
;
#include
"irnode_t.h"
#include
"irprog.h"
typedef
struct
rta_set
{
rta_set_elt_t
*
_list
;
}
rta_set_t
;
#include
"eset.h"
/* #include "pmap.h" */
/* #include "array.h" */
#include
"irgwalk.h"
/* #include "ircons.h" */
/* #include "irgmod.h" */
/* #include "irflag_t.h" */
# define SET_T rta_set_t
/* #include "dbginfo_t.h" */
# else
/* if defined RTA_SET */
# define SET_T eset
# define new_set eset_create
# define delete_set(SET) eset_destroy(SET)
# define set_insert(SET,ELT) eset_insert(SET,ELT)
# define set_contains(SET,ELT) eset_contains(SET,ELT)
# endif
/* defined RTA_SET */
# define TRUE 1
# define FALSE 0
static
SET_T
*
_live_classes
=
NULL
;
static
SET_T
*
_live_fields
=
NULL
;
static
SET_T
*
_called_methods
=
NULL
;
/* base data */
static
eset
*
_live_classes
=
NULL
;
static
eset
*
_live_fields
=
NULL
;
static
eset
*
_called_methods
=
NULL
;
/* cache computed results */
static
SET_T
*
_live_graphs
=
NULL
;
static
SET_T
*
_dead_graphs
=
NULL
;
# ifdef RTA_SET
/* Reinvent the wheel, err, set. */
/* eset uses obstacks, which fucks up the graph somehow */
static
rta_set_t
*
new_set
()
{
rta_set_t
*
set
=
(
rta_set_t
*
)
xmalloc
(
sizeof
(
rta_set_t
));
set
->
_list
=
NULL
;
return
(
set
);
}
static
void
delete_set
(
rta_set_t
*
set
)
{
rta_set_elt_t
*
elt
=
set
->
_list
;
while
(
NULL
!=
elt
)
{
rta_set_elt_t
*
old
=
elt
;
elt
=
elt
->
_next
;
old
->
_next
=
NULL
;
old
->
_obj
=
NULL
;
free
(
old
);
}
free
(
set
);
}
static
void
set_insert
(
rta_set_t
*
set
,
void
*
obj
)
{
rta_set_elt_t
*
elt
=
(
rta_set_elt_t
*
)
xmalloc
(
sizeof
(
rta_set_elt_t
));
elt
->
_obj
=
obj
;
elt
->
_next
=
set
->
_list
;
set
->
_list
=
elt
;
}
static
int
set_contains
(
rta_set_t
*
set
,
void
*
obj
)
{
rta_set_elt_t
*
elt
=
set
->
_list
;
while
(
NULL
!=
elt
)
{
if
(
elt
->
_obj
==
obj
)
{
return
(
TRUE
);
}
elt
=
elt
->
_next
;
}
return
(
FALSE
);
}
# endif
/* defined RTA_SET */
static
eset
*
_live_graphs
=
NULL
;
static
eset
*
_dead_graphs
=
NULL
;
/* now the meat */
...
...
@@ -124,7 +69,7 @@ static void rta_act (ir_node *node, void *env)
}
if
(
ent
)
{
set_insert
(
_called_methods
,
ent
);
e
set_insert
(
_called_methods
,
ent
);
}
}
else
if
(
iro_Load
==
op
)
{
ir_node
*
ptr
=
get_Load_ptr
(
node
);
...
...
@@ -134,7 +79,7 @@ static void rta_act (ir_node *node, void *env)
ent
=
get_Sel_entity
(
ptr
);
}
if
(
ent
)
{
set_insert
(
_live_fields
,
ent
);
e
set_insert
(
_live_fields
,
ent
);
}
}
else
if
(
iro_Store
==
op
)
{
ir_node
*
ptr
=
get_Store_ptr
(
node
);
...
...
@@ -144,31 +89,55 @@ static void rta_act (ir_node *node, void *env)
ent
=
get_Sel_entity
(
ptr
);
}
if
(
ent
)
{
set_insert
(
_live_fields
,
ent
);
e
set_insert
(
_live_fields
,
ent
);
}
}
else
if
(
iro_Alloc
==
op
)
{
type
*
type
=
get_Alloc_type
(
node
);
set_insert
(
_live_classes
,
type
);
e
set_insert
(
_live_classes
,
type
);
}
}
static
void
rta_fill_graph
(
ir_graph
*
graph
)
{
irg_walk
(
get_irg_end_block
(
graph
),
rta_act
,
NULL
,
NULL
);
if
(
NULL
!=
graph
)
{
if
(
NULL
!=
get_irg_end_block
(
graph
))
{
irg_walk
(
get_irg_end_block
(
graph
),
rta_act
,
NULL
,
NULL
);
}
}
}
static
void
rta_fill_all
()
{
int
i
;
int
old_ip_view
=
interprocedural_view
;
interprocedural_view
=
0
;
for
(
i
=
0
;
i
<
get_irp_n_irgs
();
i
++
)
{
rta_fill_graph
(
get_irp_irg
(
i
));
}
interprocedural_view
=
old_ip_view
;
}
static
int
is_call_target
(
entity
*
method
)
{
return
(
TRUE
);
int
is_target
=
FALSE
;
int
i
;
int
n_over
;
/* The method could be the target of a polymorphic call if it is
called or if it overrides a method that is called. */
if
(
eset_contains
(
_called_methods
,
method
))
{
return
(
TRUE
);
}
n_over
=
get_entity_n_overwrittenby
(
method
);
for
(
i
=
0
;
!
is_target
&&
(
i
<
n_over
);
i
++
)
{
entity
*
over
=
get_entity_overwrittenby
(
method
,
i
);
is_target
|=
is_call_target
(
over
);
}
return
(
is_target
);
}
...
...
@@ -219,7 +188,7 @@ static int has_graph (type *clazz, ir_graph *graph)
int
i
;
int
n_sub
;
if
(
set_contains
(
_live_classes
,
clazz
))
{
if
(
e
set_contains
(
_live_classes
,
clazz
))
{
int
n_meth
=
get_class_n_members
(
clazz
);
for
(
i
=
0
;
i
<
n_meth
;
i
++
)
{
...
...
@@ -269,79 +238,102 @@ static int has_live_class (entity *method, ir_graph *graph)
return
(
has_class
);
}
void
rta_init
()
static
int
rta_check
(
ir_graph
*
graph
)
{
fprintf
(
stdout
,
"BEGIN %s(%i): %s
\n
"
,
__FILE__
,
__LINE__
,
__FUNCTION__
);
return
(
rta_is_alive_graph
(
graph
));
}
_live_classes
=
new_set
();
_live_fields
=
new_set
();
_called_methods
=
new_set
();
_live_graphs
=
new_set
();
_dead_graphs
=
new_set
();
void
rta_init
()
{
_live_classes
=
eset_create
();
_live_fields
=
eset_create
();
_called_methods
=
eset_create
();
fprintf
(
stdout
,
"FILL %s(%i): %s
\n
"
,
__FILE__
,
__LINE__
,
__FUNCTION__
);
rta_fill_all
();
fprintf
(
stdout
,
"DONE %s(%i): %s
\n
"
,
__FILE__
,
__LINE__
,
__FUNCTION__
);
_live_graphs
=
eset_create
();
_dead_graphs
=
eset_create
();
/*
* shold be:
* rta_fill_queue ()
*/
if
(
get_irp_main_irg
())
{
eset_insert
(
_live_graphs
,
get_irp_main_irg
());
}
rta_fill_all
();
}
void
rta_cleanup
()
{
int
i
;
int
n_live_graphs
=
0
;
int
n_graphs
=
get_irp_n_irgs
();
for
(
i
=
0
;
i
<
n_graphs
;
i
++
)
{
ir_graph
*
graph
=
get_irp_irg
(
i
);
if
(
rta_check
(
graph
))
{
char
*
name
=
NULL
;
n_live_graphs
++
;
name
=
get_entity_name
(
get_irg_ent
(
graph
));
fprintf
(
stdout
,
"LIVE %s
\n
"
,
name
);
}
}
fprintf
(
stdout
,
"RES %s: %i graphs, %i live
\n
"
,
__FUNCTION__
,
n_graphs
,
n_live_graphs
);
if
(
_live_classes
)
{
delete_set
(
_live_classes
);
eset_destroy
(
_live_classes
);
_live_classes
=
NULL
;
}
if
(
_live_fields
)
{
delete_set
(
_live_fields
);
eset_destroy
(
_live_fields
);
_live_fields
=
NULL
;
}
if
(
_called_methods
)
{
delete_set
(
_called_methods
);
eset_destroy
(
_called_methods
);
_called_methods
=
NULL
;
}
if
(
_live_graphs
)
{
delete_set
(
_live_graphs
);
eset_destroy
(
_live_graphs
);
_live_graphs
=
NULL
;
}
if
(
_dead_graphs
)
{
delete_set
(
_dead_graphs
);
eset_destroy
(
_dead_graphs
);
_dead_graphs
=
NULL
;
}
}
int
rta_is_alive_class
(
type
*
clazz
)
{
return
(
set_contains
(
_live_classes
,
clazz
));
return
(
e
set_contains
(
_live_classes
,
clazz
));
}
int
rta_is_alive_graph
(
ir_graph
*
graph
)
{
if
(
set_contains
(
_live_graphs
,
graph
))
{
if
(
e
set_contains
(
_live_graphs
,
graph
))
{
return
(
TRUE
);
}
if
(
set_contains
(
_dead_graphs
,
graph
))
{
if
(
e
set_contains
(
_dead_graphs
,
graph
))
{
return
(
FALSE
);
}
entity
*
meth
=
get_irg_ent
(
graph
);
if
(
has_live_call
(
meth
,
graph
)
&&
has_live_class
(
meth
,
graph
))
{
set_insert
(
_live_graphs
,
graph
);
e
set_insert
(
_live_graphs
,
graph
);
return
(
TRUE
);
}
else
{
set_insert
(
_dead_graphs
,
graph
);
e
set_insert
(
_dead_graphs
,
graph
);
return
(
FALSE
);
}
...
...
@@ -349,13 +341,16 @@ int rta_is_alive_graph (ir_graph *graph)
int
rta_is_alive_field
(
entity
*
field
)
{
return
(
set_contains
(
_live_fields
,
field
));
return
(
e
set_contains
(
_live_fields
,
field
));
}
/*
* $Log$
* Revision 1.3 2004/06/12 17:09:46 liekweg
* RTA works, outedges breaks. "Yay." --flo
*
* Revision 1.2 2004/06/11 18:25:39 liekweg
* Added todo
*
...
...
ir/ana/rta.h
View file @
e7eac363
...
...
@@ -3,24 +3,7 @@
#ifndef _RTA_H_
#define _RTA_H_
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include
<stdlib.h>
#include
"cgana.h"
/* get_implementation */
#include
"eset.h"
/* #include "pmap.h" */
/* #include "array.h" */
#include
"irprog.h"
#include
"irgwalk.h"
/* #include "ircons.h" */
/* #include "irgmod.h" */
#include
"irnode_t.h"
/* #include "irflag_t.h" */
/* #include "dbginfo_t.h" */
# include "entity.h"
void
rta_init
(
void
);
void
rta_cleanup
(
void
);
...
...
@@ -33,6 +16,9 @@ int rta_is_alive_field (entity*);
/*
* $Log$
* Revision 1.2 2004/06/12 17:09:46 liekweg
* RTA works, outedges breaks. "Yay." --flo
*
* Revision 1.1 2004/06/11 18:24:18 liekweg
* Added RTA --flo
*
...
...
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