X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana2%2Fpto_init.c;h=781cfd8d9adcf2daad21399ba0b3d9ddc86b87a2;hb=6df6ae7f6b5d09f8fd599eba67aaba289b12c19c;hp=6a5514ce1e2ff82a643e61fb3d3f4ec5f0e8977b;hpb=f75c9d04c9b10670c0456bb61727f25ee7c2aac0;p=libfirm diff --git a/ir/ana2/pto_init.c b/ir/ana2/pto_init.c index 6a5514ce1..781cfd8d9 100644 --- a/ir/ana2/pto_init.c +++ b/ir/ana2/pto_init.c @@ -20,8 +20,14 @@ pto_init: Initialisation Functions */ +# include # include +#ifdef HAVE_STRING_H # include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif # include "pto.h" # include "pto_init.h" @@ -32,8 +38,11 @@ # include "typewalk.h" # include "irgwalk.h" +# include "tv.h" # include "xmalloc.h" +# include "gnu_ext.h" + /* Local Defines: */ # define obstack_chunk_alloc xmalloc # define obstack_chunk_free free @@ -59,7 +68,7 @@ static struct obstack *pto_obst = NULL; /* all pto_t's go onto this one */ /* =================================================== Local Implementation: =================================================== */ -/* Allocate a new pto */ +/** Allocate a new pto */ static pto_t *new_pto (ir_node *node) { pto_t *pto = obstack_alloc (pto_obst, sizeof (pto_t)); @@ -68,7 +77,7 @@ static pto_t *new_pto (ir_node *node) return (pto); } -/* Allocate a new alloc_pto */ +/** Allocate a new alloc_pto */ static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs) { int i; @@ -90,7 +99,7 @@ static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs) return (alloc_pto); } -/* Allocate a new pto for a symconst */ +/** Allocate a new pto for a symconst */ static pto_t* new_symconst_pto (ir_node *symconst) { pto_t *pto; @@ -155,19 +164,19 @@ static void clear_type_link (type_or_ent *thing, void *_unused) } } -/* Helper to pto_init_graph --- clear the links of the given node */ +/** Helper to pto_init_graph --- clear the links of the given node */ static void clear_node_link (ir_node *node, void *_unused) { set_irn_link (node, NULL); } -/* Helper to pto_init_graph --- clear the links of all nodes */ +/** Helper to pto_init_graph --- clear the links of all nodes */ static void clear_graph_links (ir_graph *graph) { irg_walk_graph (graph, clear_node_link, NULL, NULL); } -/* Reset ALL the pto values for a new pass */ +/** Reset ALL the pto values for a new pass */ static void reset_node_pto (ir_node *node, void *env) { reset_env_t *reset_env = (reset_env_t*) env; @@ -199,6 +208,7 @@ static void reset_node_pto (ir_node *node, void *env) assert (alloc_pto->curr_pto); } break; + case (iro_Const): case (iro_SymConst): { /* nothing, leave as-is */ } break; @@ -216,7 +226,7 @@ static void reset_node_pto (ir_node *node, void *env) /* HERE ("end"); */ } -/* Initialise primary name sources */ +/** Initialise primary name sources */ static void init_pto (ir_node *node, void *env) { init_env_t *init_env = (init_env_t*) env; @@ -226,7 +236,7 @@ static void init_pto (ir_node *node, void *env) switch (op) { case (iro_SymConst): { - if (mode_is_reference(get_irn_mode (node))) { + if (mode_is_reference (get_irn_mode (node))) { entity *ent = get_SymConst_entity (node); type *tp = get_entity_type (ent); if (is_Class_type (tp) || is_Pointer_type (tp)) { @@ -258,6 +268,17 @@ static void init_pto (ir_node *node, void *env) OPNUM (node))); } break; + case (iro_Const): { + tarval *tv = get_Const_tarval (node); + + /* only need 'NULL' pointer constants */ + if (mode_P == get_tarval_mode (tv)) { + if (get_tarval_null (mode_P) == tv) { + pto_t *pto = new_pto (node); + set_node_pto (node, pto); + } + } + } break; case (iro_Load): case (iro_Call): case (iro_Phi): @@ -270,7 +291,7 @@ static void init_pto (ir_node *node, void *env) } -/* Initialise the given graph for a new pass run */ +/** Initialise the given graph for a new pass run */ static void pto_init_graph_allocs (ir_graph *graph) { graph_info_t *ginfo = ecg_get_info (graph); @@ -341,7 +362,7 @@ void fake_main_args (ir_graph *graph) } /* Initialise the Init module */ -void pto_init_init () +void pto_init_init (void) { pto_obst = (struct obstack*) xmalloc (sizeof (struct obstack)); @@ -349,7 +370,7 @@ void pto_init_init () } /* Cleanup the Init module */ -void pto_init_cleanup () +void pto_init_cleanup (void) { obstack_free (pto_obst, NULL); memset (pto_obst, 0x00, sizeof (struct obstack)); @@ -359,7 +380,7 @@ void pto_init_cleanup () /* Initialise the Names of the Types/Entities */ -void pto_init_type_names () +void pto_init_type_names (void) { /* HERE ("start"); */ type_walk (clear_type_link, NULL, NULL); @@ -405,7 +426,7 @@ void pto_reset_graph_pto (ir_graph *graph, int ctx_idx) /* HERE ("start"); */ - irg_walk_graph (graph, reset_node_pto, NULL, &reset_env); + irg_walk_graph (graph, reset_node_pto, NULL, reset_env); /* HERE ("end"); */ memset (reset_env, 0x00, sizeof (reset_env_t)); @@ -415,6 +436,22 @@ void pto_reset_graph_pto (ir_graph *graph, int ctx_idx) /* $Log$ + Revision 1.20 2005/12/05 12:19:54 beck + added missing include (not anymore included in libFirm) + + Revision 1.19 2005/06/17 17:42:32 beck + added doxygen docu + fixed (void) function headers + + Revision 1.18 2005/02/16 13:27:52 beck + added needed tv.h include + + Revision 1.17 2005/01/14 14:12:51 liekweg + prepare gnu extension fix + + Revision 1.16 2005/01/14 13:36:50 liekweg + don't put environments on the stack; handle consts + Revision 1.15 2005/01/10 17:26:34 liekweg fixup printfs, don't put environments on the stack