From 0ce6f490b4d0801f61f64f829323cf3f692318a9 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 21 Dec 2004 15:07:55 +0000 Subject: [PATCH] removed C99 contructs removed unnecessary allocation removed use of mode_P, use mode_is_reference() instead removed handling of Const with pointer tarvals, these constructs are removed [r4692] --- ir/ana2/pto_init.c | 134 ++++++++++++++++++--------------------------- 1 file changed, 54 insertions(+), 80 deletions(-) diff --git a/ir/ana2/pto_init.c b/ir/ana2/pto_init.c index e16b26cea..2a8f9eb07 100644 --- a/ir/ana2/pto_init.c +++ b/ir/ana2/pto_init.c @@ -71,11 +71,13 @@ static pto_t *new_pto (ir_node *node) /* Allocate a new alloc_pto */ static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs) { - assert (iro_Alloc == get_irn_opcode (alloc)); - int i; - alloc_pto_t *alloc_pto = obstack_alloc (pto_obst, sizeof (alloc_pto_t)); - type *tp = get_Alloc_type (alloc); + alloc_pto_t *alloc_pto = obstack_alloc (pto_obst, sizeof(*alloc_pto)); + type *tp; + + assert (op_Alloc == get_irn_op(alloc)); + + tp = get_Alloc_type (alloc); alloc_pto->ptos = (pto_t**) obstack_alloc (pto_obst, n_ctxs * sizeof (pto_t*)); @@ -91,12 +93,15 @@ static alloc_pto_t *new_alloc_pto (ir_node *alloc, int n_ctxs) /* Allocate a new pto for a symconst */ static pto_t* new_symconst_pto (ir_node *symconst) { - assert (iro_SymConst == get_irn_opcode (symconst)); - - pto_t *pto = new_pto (symconst); - entity *ent = get_SymConst_entity (symconst); + pto_t *pto; + entity *ent; desc_t *desc = NULL; + assert (op_SymConst == get_irn_op(symconst)); + + pto = new_pto (symconst); + ent = get_SymConst_entity (symconst); + /* const char *ent_name = (char*) get_entity_name (ent); const char *own_name = (char*) get_type_name (get_entity_owner (ent)); @@ -111,8 +116,7 @@ static pto_t* new_symconst_pto (ir_node *symconst) } else if (is_class_type (get_entity_type (ent))) { desc = new_name (get_entity_type (ent), symconst, -1); } else { - fprintf (stderr, "%s: not handled: %s[%li] (\"%s\")\n", - __FUNCTION__, + fprintf (stderr, "new_symconst_pto(): not handled: %s[%li] (\"%s\")\n", get_op_name (get_irn_op (symconst)), get_irn_node_nr (symconst), get_entity_name (ent)); @@ -126,29 +130,6 @@ static pto_t* new_symconst_pto (ir_node *symconst) return (pto); } -/* Allocate a new pto for a constant */ -static pto_t *new_const_pto (ir_node *cnst) -{ - assert (iro_Const == get_irn_opcode (cnst)); - assert (mode_P == get_irn_mode (cnst)); - - static pto_t *cnst_pto = NULL; - - /* since 'store's and 'load's via a NULL pointer are hardly ever - successful, we get away with an empty set */ - - tarval *tv = get_Const_tarval (cnst); - - assert (tv == get_tarval_null (mode_P)); - - if (NULL == cnst_pto) { - cnst_pto = new_pto (cnst); - } - - return (cnst_pto); -} - - /* Helper to pto_init --- clear the link fields of class types */ static void clear_type_link (type_or_ent *thing, void *_unused) { @@ -156,16 +137,16 @@ static void clear_type_link (type_or_ent *thing, void *_unused) type *tp = (type*) thing; if (is_class_type (tp)) { - DBGPRINT (1, (stdout, "%s (\"%s\")\n", - __FUNCTION__, get_type_name (tp))); + DBGPRINT (1, (stdout, "clear_type_link() (\"%s\")\n", + get_type_name (tp))); set_type_link (tp, NULL); } } else if (is_entity (thing)) { entity *ent = (entity*) thing; - DBGPRINT (1, (stdout, "%s (\"%s\")\n", - __FUNCTION__, get_entity_name (ent))); + DBGPRINT (1, (stdout, "clear_type_link() (\"%s\")\n", + get_entity_name (ent))); set_entity_link (ent, NULL); } @@ -188,7 +169,7 @@ static void reset_node_pto (ir_node *node, void *env) { reset_env_t *reset_env = (reset_env_t*) env; int ctx_idx = reset_env->ctx_idx; - const opcode op = get_irn_opcode (node); + opcode op = get_irn_opcode (node); /* HERE ("start"); */ @@ -207,23 +188,20 @@ static void reset_node_pto (ir_node *node, void *env) alloc_pto_t *alloc_pto = (alloc_pto_t*) get_irn_link (node); alloc_pto->curr_pto = alloc_pto->ptos [ctx_idx]; - DBGPRINT (1, (stdout, "%s: setting pto of \"%s[%li]\" for ctx %i\n", - __FUNCTION__, + DBGPRINT (1, (stdout, "reset_node_pto(): setting pto of \"%s[%li]\" for ctx %i\n", OPNAME (node), OPNUM (node), ctx_idx)); assert (alloc_pto->curr_pto); } break; - case (iro_Const): case (iro_SymConst): { /* nothing, leave as-is */ } break; default: { /* basically, nothing */ - DBGPRINT (2, (stdout, "%s: resetting pto of \"%s[%li]\"\n", - __FUNCTION__, + DBGPRINT (2, (stdout, "reset_node_pto(): resetting pto of \"%s[%li]\"\n", OPNAME (node), OPNUM (node))); set_node_pto (node, NULL); @@ -239,11 +217,11 @@ static void init_pto (ir_node *node, void *env) init_env_t *init_env = (init_env_t*) env; int n_ctxs = init_env->n_ctxs; - const opcode op = get_irn_opcode (node); + opcode op = get_irn_opcode (node); switch (op) { case (iro_SymConst): { - if (mode_P == 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)) { @@ -251,8 +229,7 @@ static void init_pto (ir_node *node, void *env) set_node_pto (node, symconst_pto); /* debugging only */ - DBGPRINT (1, (stdout, "%s: new name \"%s\" for \"%s[%li]\"\n", - __FUNCTION__, + DBGPRINT (1, (stdout, "init_pto(): new name \"%s\" for \"%s[%li]\"\n", get_entity_name (ent), OPNAME (node), OPNUM (node))); @@ -262,24 +239,18 @@ static void init_pto (ir_node *node, void *env) case (iro_Alloc): { alloc_pto_t *alloc_pto = new_alloc_pto (node, n_ctxs); + type *tp; + set_alloc_pto (node, alloc_pto); - type *tp = get_Alloc_type (node); /* debugging only */ - DBGPRINT (1, (stdout, "%s: %i names \"%s\" for \"%s[%li]\"\n", - __FUNCTION__, + tp = get_Alloc_type (node); /* debugging only */ + DBGPRINT (1, (stdout, "init_pto(): %i names \"%s\" for \"%s[%li]\"\n", n_ctxs, get_type_name (tp), OPNAME (node), OPNUM (node))); } break; - case (iro_Const): { - if (mode_P == get_irn_mode (node)) { - pto_t *pto = new_const_pto (node); - set_node_pto (node, pto); - } - } break; - case (iro_Load): case (iro_Call): case (iro_Phi): @@ -296,17 +267,13 @@ static void init_pto (ir_node *node, void *env) static void pto_init_graph_allocs (ir_graph *graph) { graph_info_t *ginfo = ecg_get_info (graph); - int n_ctxs = ginfo->n_ctxs; + init_env_t init_env; - init_env_t *init_env = xmalloc (sizeof (init_env_t)); - init_env->n_ctxs = n_ctxs; + init_env.n_ctxs = ginfo->n_ctxs; /* HERE ("start"); */ - irg_walk_graph (graph, init_pto, NULL, init_env); - - memset (init_env, 0x00, sizeof (init_env_t)); - free (init_env); + irg_walk_graph (graph, init_pto, NULL, &init_env); /* HERE ("end"); */ } @@ -323,6 +290,8 @@ void fake_main_args (ir_graph *graph) type *mtp = get_entity_type (ent); ir_node **args = find_irg_args (graph); type *ctp = get_method_param_type (mtp, 1); /* ctp == char[]*[]* */ + desc_t *arg_desc; + pto_t *arg_pto; /* 'main' has signature 'void(int, char[]*[]*)' */ assert (NULL == args [2]); @@ -333,15 +302,15 @@ void fake_main_args (ir_graph *graph) assert (is_array_type (ctp)); - desc_t *arg_desc = new_name (ctp, args [1], -1); - pto_t *arg_pto = new_pto (args [1]); + arg_desc = new_name (ctp, args [1], -1); + arg_pto = new_pto (args [1]); /* todo: simulate 'store' to arg1[] ?!? */ qset_insert (arg_pto->values, arg_desc); set_node_pto (args [1], arg_pto); - DBGPRINT (1, (stdout, "%s:%i (%s[%li])\n", - __FUNCTION__, __LINE__, OPNAME (args [1]), OPNUM (args [1]))); + DBGPRINT (1, (stdout, "fake_main_args():%i (%s[%li])\n", + __LINE__, OPNAME (args [1]), OPNUM (args [1]))); # ifdef TEST_MAIN_TYPE ctp = get_array_element_type (ctp); /* ctp == char[]* */ @@ -361,18 +330,18 @@ 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)); + pto_obst = xmalloc(sizeof(*pto_obst)); obstack_init (pto_obst); } /* 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)); + memset (pto_obst, 0, sizeof (*pto_obst)); free (pto_obst); pto_obst = NULL; } @@ -389,6 +358,7 @@ void pto_init_type_names () /* Initialise the given graph for a new pass run */ void pto_init_graph (ir_graph *graph) { + ir_node **proj_args; graph_info_t *ginfo = ecg_get_info (graph); const int n_ctxs = ginfo->n_ctxs; @@ -397,7 +367,7 @@ void pto_init_graph (ir_graph *graph) const char *ent_name = (char*) get_entity_name (ent); const char *own_name = (char*) get_type_name (get_entity_owner (ent)); - DBGPRINT (2, (stdout, "%s: init \"%s.%s\" for %i ctxs\n", __FUNCTION__, + DBGPRINT (2, (stdout, "pto_init_graph(): init \"%s.%s\" for %i ctxs\n", own_name, ent_name, n_ctxs)); /* HERE ("start"); */ @@ -408,7 +378,7 @@ void pto_init_graph (ir_graph *graph) /* HERE ("end"); */ assert (NULL == get_irg_proj_args (graph)); - ir_node **proj_args = find_irg_args (graph); + proj_args = find_irg_args (graph); set_irg_proj_args (graph, proj_args); assert (proj_args == get_irg_proj_args (graph)); } @@ -416,21 +386,25 @@ void pto_init_graph (ir_graph *graph) /* Reset the given graph for a new pass run */ void pto_reset_graph_pto (ir_graph *graph, int ctx_idx) { - /* HERE ("start"); */ + reset_env_t reset_env; + reset_env.ctx_idx = ctx_idx; - reset_env_t *reset_env = (reset_env_t*) xmalloc (sizeof (reset_env_t)); - reset_env->ctx_idx = ctx_idx; + /* HERE ("start"); */ - irg_walk_graph (graph, reset_node_pto, NULL, reset_env); + irg_walk_graph (graph, reset_node_pto, NULL, &reset_env); - memset (reset_env, 0x00, sizeof (reset_env_t)); - free (reset_env); /* HERE ("end"); */ } /* $Log$ + Revision 1.13 2004/12/21 15:07:55 beck + removed C99 contructs + removed unnecessary allocation + removed use of mode_P, use mode_is_reference() instead + removed handling of Const with pointer tarvals, these constructs are removed + Revision 1.12 2004/12/20 17:41:14 liekweg __unused -> _unused -- 2.20.1